diff options
author | Flaviu Tamas <tamasflaviu@gmail.com> | 2015-05-26 19:32:50 -0400 |
---|---|---|
committer | Flaviu Tamas <tamasflaviu@gmail.com> | 2015-06-07 13:12:18 -0400 |
commit | 90ed34db72e8ea8f70d1e86dd2335efe48532fa8 (patch) | |
tree | 9d9e46c0ddbb87f562981f072220bd36a7f199cb /lib/pure/marshal.nim | |
parent | 075a5e844069979f1fc3782839e9e2cc62c61ad5 (diff) | |
parent | bbb1bdb4a939aa43ed981acc2f96bce918be7d21 (diff) | |
download | Nim-90ed34db72e8ea8f70d1e86dd2335efe48532fa8.tar.gz |
Merge branch 'devel' of https://github.com/Araq/Nim into add-nre
* 'devel' of https://github.com/Araq/Nim: Fix #964, fix #1384 Don't inspect typedescs
Diffstat (limited to 'lib/pure/marshal.nim')
-rw-r--r-- | lib/pure/marshal.nim | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/pure/marshal.nim b/lib/pure/marshal.nim index e0092f314..49f049e46 100644 --- a/lib/pure/marshal.nim +++ b/lib/pure/marshal.nim @@ -17,13 +17,13 @@ ## .. code-block:: nim ## ## type -## TA = object -## TB = object of TA +## A = object +## B = object of A ## f: int ## ## var -## a: ref TA -## b: ref TB +## a: ref A +## b: ref B ## ## new(b) ## a = b @@ -36,7 +36,7 @@ import streams, typeinfo, json, intsets, tables proc ptrToInt(x: pointer): int {.inline.} = result = cast[int](x) # don't skip alignment -proc storeAny(s: Stream, a: TAny, stored: var IntSet) = +proc storeAny(s: Stream, a: Any, stored: var IntSet) = case a.kind of akNone: assert false of akBool: s.write($getBool(a)) @@ -96,7 +96,7 @@ proc storeAny(s: Stream, a: TAny, stored: var IntSet) = of akInt..akInt64, akUInt..akUInt64: s.write($getBiggestInt(a)) of akFloat..akFloat128: s.write($getBiggestFloat(a)) -proc loadAny(p: var JsonParser, a: TAny, t: var Table[BiggestInt, pointer]) = +proc loadAny(p: var JsonParser, a: Any, t: var Table[BiggestInt, pointer]) = case a.kind of akNone: assert false of akBool: @@ -222,7 +222,7 @@ proc loadAny(p: var JsonParser, a: TAny, t: var Table[BiggestInt, pointer]) = raiseParseErr(p, "float expected") of akRange: loadAny(p, a.skipRange, t) -proc loadAny(s: Stream, a: TAny, t: var Table[BiggestInt, pointer]) = +proc loadAny(s: Stream, a: Any, t: var Table[BiggestInt, pointer]) = var p: JsonParser open(p, s, "unknown file") next(p) @@ -278,10 +278,11 @@ when not defined(testing) and isMainModule: else: nil - PNode = ref TNode - TNode = object + PNode = ref Node + Node = object next, prev: PNode data: string + {.deprecated: [TNode: Node].} proc buildList(): PNode = new(result) @@ -317,14 +318,15 @@ when not defined(testing) and isMainModule: testit(test7) type - TA {.inheritable.} = object - TB = object of TA + A {.inheritable.} = object + B = object of A f: int var - a: ref TA - b: ref TB + a: ref A + b: ref B new(b) a = b echo($$a[]) # produces "{}", not "{f: 0}" + |