diff --git a/src/flatty.nim b/src/flatty.nim index 650994f..73ef65f 100644 --- a/src/flatty.nim +++ b/src/flatty.nim @@ -1,9 +1,12 @@ ## Convert any Nim objects, numbers, strings, refs to and from binary format. +import + std/[tables, typetraits, sets], + flatty/objvar + when defined(js): import flatty/jsbinny else: import flatty/binny -import flatty/objvar, tables, typetraits, sets, sequtils type SomeTable*[K, V] = Table[K, V] | OrderedTable[K, V] type SomeSet[A] = set[A] | HashSet[A] | OrderedSet[A] @@ -43,7 +46,7 @@ proc toFlatty*(s: var string, x: char) = proc fromFlatty*(s: string, i: var int, x: var char) = x = s.readUint8(i).char i += 1 - + # Numbers proc toFlatty*(s: var string, x: uint8) = s.addUint8(x) proc toFlatty*(s: var string, x: int8) = s.addInt8(x) diff --git a/src/flatty/binlisting.nim b/src/flatty/binlisting.nim index 46b8986..9e2bf87 100644 --- a/src/flatty/binlisting.nim +++ b/src/flatty/binlisting.nim @@ -1,8 +1,8 @@ ## Takes bin-listing in ASCII format and turns them into real binary. -import parseutils, strutils +import std/[parseutils, strutils] proc decodeBinListing*(text: string): string = - + ## Takes bin-listing in ASCII format and turns them into real binary. for line in text.split("\n"): let line = line.strip() if line == "": continue diff --git a/src/flatty/encode.nim b/src/flatty/encode.nim index 4451f71..2e012e0 100644 --- a/src/flatty/encode.nim +++ b/src/flatty/encode.nim @@ -1,4 +1,4 @@ -import unicode +import std/unicode proc maybeSwap(u: uint16, swap: bool): uint16 = ## Swaps from big endian to little endian if swap is true. diff --git a/src/flatty/hashy.nim b/src/flatty/hashy.nim index 94866ab..245fc57 100644 --- a/src/flatty/hashy.nim +++ b/src/flatty/hashy.nim @@ -1,6 +1,8 @@ ## Hash functions based on flatty, hash any nested object. -import flatty, hashes +import + std/hashes, + flatty export Hash diff --git a/src/flatty/hashy2.nim b/src/flatty/hashy2.nim index 185110f..836986f 100644 --- a/src/flatty/hashy2.nim +++ b/src/flatty/hashy2.nim @@ -1,6 +1,8 @@ ## Hash functions based on flatty, hash any nested object. -import flatty/objvar, typetraits +import + std/typetraits, + flatty/objvar {.push overflowChecks: off.} diff --git a/src/flatty/hexprint.nim b/src/flatty/hexprint.nim index 06024c0..7a696f8 100644 --- a/src/flatty/hexprint.nim +++ b/src/flatty/hexprint.nim @@ -1,7 +1,6 @@ -import strutils +import std/strutils when defined(js): - proc hexPrint*(buf: string): string = ## Prints a string in hex format of the old DOS debug program. ## Useful for looking at binary dumps. @@ -41,7 +40,6 @@ when defined(js): result.add("\n") else: - proc hexPrint*(p: ptr uint8, len: int, startAddress = 0): string = ## Prints a string in hex format of the old DOS debug program. ## Useful for looking at binary dumps. diff --git a/src/flatty/objvar.nim b/src/flatty/objvar.nim index 554835a..f59a670 100644 --- a/src/flatty/objvar.nim +++ b/src/flatty/objvar.nim @@ -1,4 +1,4 @@ -import macros +import std/macros proc hasKind(node: NimNode, kind: NimNodeKind): bool = for c in node.children: diff --git a/tests/test_flatty.nim b/tests/test_flatty.nim index d002324..de1b16f 100644 --- a/tests/test_flatty.nim +++ b/tests/test_flatty.nim @@ -1,4 +1,6 @@ -import flatty, intsets, json, tables, sets, flatty/hexprint +import + std/[intsets, json, tables, sets], + flatty # Test booleans. doAssert true.toFlatty.fromFlatty(bool) == true