Skip to content

Commit

Permalink
0.0.4: please test
Browse files Browse the repository at this point in the history
  • Loading branch information
disruptek committed Jun 2, 2020
1 parent 947d2f8 commit 007326f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
29 changes: 10 additions & 19 deletions frosty.nim
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,15 @@ proc read(s: var Serializer; o: var string)
when enableLists:
import std/lists

template makeListSupportDeclarations(name: untyped): untyped =
proc write[T](s: Serializer; o: name[T])
proc read[T](s: Serializer; o: var name[T])

proc write[T](s: Serializer; o: SinglyLinkedList[T])
proc read[T](s: Serializer; o: var SinglyLinkedList[T])
proc write[T](s: Serializer; o: DoublyLinkedList[T])
proc read[T](s: Serializer; o: var DoublyLinkedList[T])
proc write[T](s: Serializer; o: SinglyLinkedRing[T])
proc read[T](s: Serializer; o: var SinglyLinkedRing[T])
proc write[T](s: Serializer; o: DoublyLinkedRing[T])
proc read[T](s: Serializer; o: var DoublyLinkedRing[T])

template makeListSupport(name: untyped): untyped =
when not compiles(len(name)):
proc len(o: name): int {.used.} =
proc write[T](s: var Serializer; o: name[T]) =
when compiles(len(o)):
var l = len(o) # type inference
else:
var l = 0
for item in items(o):
inc result
inc l

proc write[T](s: var Serializer; o: name[T]) =
var l = len(o) # type inference
s.write l
for item in items(o):
s.write item.value
Expand All @@ -77,7 +65,10 @@ when enableLists:

proc read[T](s: var Serializer; o: var name[T]) =
o = `init name`[T]()
var l = len(o)
when compiles(len(o)):
var l = len(o) # type inference
else:
var l = 0
s.read l
while l > 0:
var value: T
Expand Down
2 changes: 1 addition & 1 deletion frosty.nimble
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "0.0.3"
version = "0.0.4"
author = "disruptek"
description = "marshal native Nim objects via streams, channels"
license = "MIT"
Expand Down

0 comments on commit 007326f

Please sign in to comment.