From 680e419d12df9c25f991b9941055e48febf3d1d1 Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Thu, 22 Sep 2016 14:16:10 +0200 Subject: [PATCH] Simplified field checking --- yaml/serialization.nim | 58 +++++++++++++----------------------------- 1 file changed, 18 insertions(+), 40 deletions(-) diff --git a/yaml/serialization.nim b/yaml/serialization.nim index 0ecce94..fb1b8f8 100644 --- a/yaml/serialization.nim +++ b/yaml/serialization.nim @@ -480,33 +480,25 @@ proc yamlTag*(T: typedesc[tuple]): try: serializationTagLibrary.tags[uri] except KeyError: serializationTagLibrary.registerUri(uri) -proc fieldAnalyzer(t: typedesc): tuple[sections, maxlen: int] {.compileTime.} = - result = (1, 0) +proc fieldCount(t: typedesc): int {.compileTime.} = + result = 0 let tDesc = getType(getType(t)[1]) - echo "fieldAnalyzer: " & tDesc.treeRepr if tDesc.kind == nnkBracketExpr: # tuple - result.maxlen = tDesc.len - 1 + result = tDesc.len - 1 else: # object - var outerLen = 0 for child in tDesc[2].children: - inc(outerLen) + inc(result) if child.kind == nnkRecCase: - inc(result.sections) - var innerLen = 0 for bIndex in 1..