From 007326feb04d8d75ce1fd7b8e0128abcf47b7c35 Mon Sep 17 00:00:00 2001 From: Andy Davidoff Date: Tue, 2 Jun 2020 00:14:02 -0400 Subject: [PATCH] 0.0.4: please test --- frosty.nim | 29 ++++++++++------------------- frosty.nimble | 2 +- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/frosty.nim b/frosty.nim index 9a08983..21debfd 100644 --- a/frosty.nim +++ b/frosty.nim @@ -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 @@ -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 diff --git a/frosty.nimble b/frosty.nimble index 7b5785b..1a9090a 100644 --- a/frosty.nimble +++ b/frosty.nimble @@ -1,4 +1,4 @@ -version = "0.0.3" +version = "0.0.4" author = "disruptek" description = "marshal native Nim objects via streams, channels" license = "MIT"