Skip to content

Commit

Permalink
a few more cleanups
Browse files Browse the repository at this point in the history
* add raises to endians2, bitops2 since they sometimes call C functions
  • Loading branch information
arnetheduck authored and zah committed Apr 10, 2020
1 parent 87ccf8e commit 5512e89
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions stew/bitops2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions stew/endians2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_byteutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 5512e89

Please sign in to comment.