make it more Nim 1.4+ compatible (#131)

* make it more 1.6-compatible

* these changes are from 1.4 forward
This commit is contained in:
Miran 2022-07-26 19:52:59 +02:00 committed by GitHub
parent c020fd80f1
commit d37e77a72b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 91 additions and 34 deletions

View File

@ -1,10 +1,13 @@
# Copyright (c) 2020 Status Research & Development GmbH # Copyright (c) 2020-2022 Status Research & Development GmbH
# Licensed and distributed under either of # Licensed and distributed under either of
# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT). # * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0). # * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms. # at your option. This file may not be copied, modified, or distributed except according to those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
## Operations on array and openArray ## Operations on array and openArray

View File

@ -2,7 +2,10 @@ import
std/typetraits, std/typetraits,
./shims/macros ./shims/macros
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
func assign*[T](tgt: var seq[T], src: openArray[T]) {.gcsafe.} func assign*[T](tgt: var seq[T], src: openArray[T]) {.gcsafe.}
func assign*[T](tgt: var openArray[T], src: openArray[T]) {.gcsafe.} func assign*[T](tgt: var openArray[T], src: openArray[T]) {.gcsafe.}

View File

@ -1,4 +1,4 @@
## Copyright (c) 2021 Status Research & Development GmbH ## Copyright (c) 2021-2022 Status Research & Development GmbH
## Licensed under either of ## Licensed under either of
## * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE)) ## * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
## * MIT license ([LICENSE-MIT](LICENSE-MIT)) ## * MIT license ([LICENSE-MIT](LICENSE-MIT))
@ -13,7 +13,10 @@
import results import results
export results export results
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
type type
Base10* = object Base10* = object

View File

@ -1,4 +1,7 @@
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import import
bitops2, ptrops bitops2, ptrops

View File

@ -16,7 +16,10 @@ import
# backwards compat # backwards compat
export arrayops.`&`, arrayops.initArrayWith, arrayops.`[]=` export arrayops.`&`, arrayops.initArrayWith, arrayops.`[]=`
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
######################################################################################################## ########################################################################################################
##################################### Hex utilities ################################################ ##################################### Hex utilities ################################################

View File

@ -1,6 +1,6 @@
# Nimbus - Types, data structures and shared utilities used in network sync # Nimbus - Types, data structures and shared utilities used in network sync
# #
# Copyright (c) 2018-2021 Status Research & Development GmbH # Copyright (c) 2018-2022 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0) # http://www.apache.org/licenses/LICENSE-2.0)
@ -111,7 +111,10 @@
import import
"."/[results, sorted_set] "."/[results, sorted_set]
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
export export
`isRed=`, `isRed=`,

View File

@ -1,4 +1,4 @@
## Copyright (c) 2020 Status Research & Development GmbH ## Copyright (c) 2020-2022 Status Research & Development GmbH
## Licensed under either of ## Licensed under either of
## * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE)) ## * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
## * MIT license ([LICENSE-MIT](LICENSE-MIT)) ## * MIT license ([LICENSE-MIT](LICENSE-MIT))
@ -10,7 +10,10 @@
## not use exceptions and using Result[T] for error handling. ## not use exceptions and using Result[T] for error handling.
## ##
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import algorithm import algorithm
import results import results

View File

@ -1,5 +1,5 @@
# Nimbus # Nimbus
# Copyright (c) 2018 Status Research & Development GmbH # Copyright (c) 2018-2022 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0) # http://www.apache.org/licenses/LICENSE-2.0)
@ -29,7 +29,10 @@ import
export export
results results
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
type type
KeyedQueueItem*[K,V] = object ##\ KeyedQueueItem*[K,V] = object ##\

View File

@ -5,7 +5,10 @@ type
ValidIpAddress* {.requiresInit.} = object ValidIpAddress* {.requiresInit.} = object
value: IpAddress value: IpAddress
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
proc ipv4*(address: array[4, byte]): ValidIpAddress = proc ipv4*(address: array[4, byte]): ValidIpAddress =
ValidIpAddress(value: IpAddress(family: IPv4, address_v4: address)) ValidIpAddress(value: IpAddress(family: IPv4, address_v4: address))

View File

@ -1,5 +1,5 @@
# Nimbus # Nimbus
# Copyright (c) 2018 Status Research & Development GmbH # Copyright (c) 2018-2022 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0) # http://www.apache.org/licenses/LICENSE-2.0)
@ -87,7 +87,10 @@ type
## returned from functions. ## returned from functions.
RbResult[SortedSetItemRef[K,V]] RbResult[SortedSetItemRef[K,V]]
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Private helpers # Private helpers

View File

@ -1,5 +1,5 @@
# Nimbus # Nimbus
# Copyright (c) 2018 Status Research & Development GmbH # Copyright (c) 2018-2022 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0) # http://www.apache.org/licenses/LICENSE-2.0)
@ -13,7 +13,10 @@ import
./rbtree_rotate, ./rbtree_rotate,
../results ../results
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Public # Public

View File

@ -1,5 +1,5 @@
# Nimbus # Nimbus
# Copyright (c) 2018 Status Research & Development GmbH # Copyright (c) 2018-2022 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0) # http://www.apache.org/licenses/LICENSE-2.0)
@ -170,7 +170,10 @@ type
start*: bool ## `true` after a rewind operation start*: bool ## `true` after a rewind operation
stop*: bool ## End of traversal stop*: bool ## End of traversal
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Public functions, constructor # Public functions, constructor

View File

@ -1,5 +1,5 @@
# Nimbus # Nimbus
# Copyright (c) 2018 Status Research & Development GmbH # Copyright (c) 2018-2022 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0) # http://www.apache.org/licenses/LICENSE-2.0)
@ -12,7 +12,10 @@ import
./rbtree_desc, ./rbtree_desc,
../results ../results
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
# ----------------------------------------------------------------------- ------ # ----------------------------------------------------------------------- ------
# Public # Public

View File

@ -1,5 +1,5 @@
# Nimbus # Nimbus
# Copyright (c) 2018 Status Research & Development GmbH # Copyright (c) 2018-2022 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0) # http://www.apache.org/licenses/LICENSE-2.0)
@ -14,7 +14,10 @@ import
type type
RbTreeFlushDel*[C] = proc(c: var C) {.gcsafe.} RbTreeFlushDel*[C] = proc(c: var C) {.gcsafe.}
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
# ----------------------------------------------------------------------- ------ # ----------------------------------------------------------------------- ------
# Private # Private

View File

@ -1,5 +1,5 @@
# Nimbus # Nimbus
# Copyright (c) 2018 Status Research & Development GmbH # Copyright (c) 2018-2022 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0) # http://www.apache.org/licenses/LICENSE-2.0)
@ -13,7 +13,10 @@ import
./rbtree_rotate, ./rbtree_rotate,
../results ../results
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
# ----------------------------------------------------------------------- ------ # ----------------------------------------------------------------------- ------
# Private functions # Private functions

View File

@ -1,5 +1,5 @@
# Nimbus # Nimbus
# Copyright (c) 2018 Status Research & Development GmbH # Copyright (c) 2018-2022 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0) # http://www.apache.org/licenses/LICENSE-2.0)
@ -13,7 +13,10 @@ import
./rbtree_flush, ./rbtree_flush,
./rbtree_walk ./rbtree_walk
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
# ----------------------------------------------------------------------- ------ # ----------------------------------------------------------------------- ------
# Public # Public

View File

@ -1,5 +1,5 @@
# Nimbus # Nimbus
# Copyright (c) 2018 Status Research & Development GmbH # Copyright (c) 2018-2022 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0) # http://www.apache.org/licenses/LICENSE-2.0)
@ -11,7 +11,10 @@
import import
./rbtree_desc ./rbtree_desc
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
proc rbTreeRotateSingle*[C](node: RbNodeRef[C]; dir: RbDir): RbNodeRef[C] = proc rbTreeRotateSingle*[C](node: RbNodeRef[C]; dir: RbDir): RbNodeRef[C] =
## Perform a single red-black tree rotation in the specified direction. ## Perform a single red-black tree rotation in the specified direction.

View File

@ -1,5 +1,5 @@
# Nimbus # Nimbus
# Copyright (c) 2018 Status Research & Development GmbH # Copyright (c) 2018-2022 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0) # http://www.apache.org/licenses/LICENSE-2.0)
@ -33,7 +33,10 @@ type
pr: RbPrnFn pr: RbPrnFn
msg: string ## collect data msg: string ## collect data
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
# ----------------------------------------------------------------------- ------ # ----------------------------------------------------------------------- ------
# Private # Private

View File

@ -1,5 +1,5 @@
# Nimbus # Nimbus
# Copyright (c) 2018 Status Research & Development GmbH # Copyright (c) 2018-2022 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0) # http://www.apache.org/licenses/LICENSE-2.0)
@ -13,7 +13,10 @@ import
./rbtree_desc, ./rbtree_desc,
../results ../results
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
# ----------------------------------------------------------------------- ------ # ----------------------------------------------------------------------- ------
# Priv # Priv