a few more cleanups

* add raises to endians2, bitops2 since they sometimes call C functions
This commit is contained in:
Jacek Sieka 2020-04-10 16:30:38 +02:00 committed by zah
parent 87ccf8e66b
commit 5512e89d4c
3 changed files with 7 additions and 3 deletions

View File

@ -18,6 +18,8 @@
## This module is also compatible with other backends: ``Javascript``, ``Nimscript``
## as well as the ``compiletime VM``.
{.push raises: [].}
const
useBuiltins = not defined(noIntrinsicsBitOpts)
@ -470,7 +472,7 @@ func setBitBE*(x: var BitIndexable, bit: Natural) {.inline.} =
x = x or mask
func clearBit*(x: var BitIndexable, bit: Natural) {.inline.} =
## raises bit in a byte, assuming 0 to be the position of the
## clears bit in a byte, assuming 0 to be the position of the
## least significant bit
type T = type(x)
let mask = T(1) shl bit
@ -480,7 +482,7 @@ template clearBitLE*(x: var BitIndexable, bit: Natural) =
clearBit(x, bit)
func clearBitBE*(x: var BitIndexable, bit: Natural) {.inline.} =
## raises a bit in `x`, assuming 0 to be the position of the
## clears a bit in `x`, assuming 0 to be the position of the
## most significant bit
let mask = mostSignificantBit(x.type) shr bit
x = x and not mask

View File

@ -18,6 +18,8 @@
# hold values of specific endianness and read them out with `fromBytes` when the
# integer interpretation of the bytes is needed.
{.push raises: [].}
type
SomeEndianInt* = uint8|uint16|uint32|uint64
## types that we support endian conversions for - uint8 is there for

View File

@ -6,7 +6,7 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms.
import unittest,
../stew/[byteutils, io]
../stew/byteutils
proc compilationTest {.exportc: "compilationTest".} =
var bytes = @[1.byte, 2, 3, 4]