From 152a4f3bd3c84e8d070767caccc068fead968d79 Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Sun, 5 Jun 2016 20:52:43 +0200 Subject: [PATCH] NimYAML version 0.5.1 * Fixed a problem that was caused by a change in getType in Nim devel --- CHANGELOG.md | 6 ++++++ README.md | 2 +- private/serialization.nim | 11 ++++++++--- yaml.nim | 8 ++++---- yaml.nimble | 2 +- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbed1db..12249fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### 0.5.1 + +Bugfixes: + + * Fixed a problem that was introduced by a change in Nim devel + ### 0.5.0 Features: diff --git a/README.md b/README.md index f727075..7a4ead0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # NimYAML - YAML implementation for Nim -NimYAML is currently being developed. The current release 0.5.0 is not +NimYAML is currently being developed. The current release 0.5.1 is not considered stable. See [the documentation](http://flyx.github.io/NimYAML/) for an overview of already available features. diff --git a/private/serialization.nim b/private/serialization.nim index cf91b69..a9a3664 100644 --- a/private/serialization.nim +++ b/private/serialization.nim @@ -411,7 +411,7 @@ macro constructFieldValue(t: typedesc, stream: expr, context: expr, name: expr, o: expr): stmt = let tDesc = getType(getType(t)[1]) result = newNimNode(nnkCaseStmt).add(name) - for child in tDesc[1].children: + for child in tDesc[2].children: if child.kind == nnkRecCase: let discriminant = newDotExpr(o, newIdentNode($child[0])) @@ -460,7 +460,12 @@ proc constructObject*[O: object|tuple]( raise newException(YamlConstructionError, "Expected field name, got " & $e.kind) let name = e.scalarContent - constructFieldValue(O, s, c, name, result) + when result is tuple: + for fname, value in fieldPairs(result): + if fname == name: + constructChild(s, c, value) + break + else: constructFieldValue(O, s, c, name, result) discard s.next() proc representObject*[O: object|tuple](value: O, ts: TagStyle, @@ -507,7 +512,7 @@ macro constructImplicitVariantObject(s, c, r, possibleTagIds: expr, t: typedesc): stmt = let tDesc = getType(getType(t)[1]) assert tDesc.kind == nnkObjectTy - let recCase = tDesc[1][0] + let recCase = tDesc[2][0] assert recCase.kind == nnkRecCase let discriminant = newDotExpr(r, newIdentNode($recCase[0])) diff --git a/yaml.nim b/yaml.nim index 6852d2c..94f3bd3 100644 --- a/yaml.nim +++ b/yaml.nim @@ -696,11 +696,11 @@ template setTagUri*(t: typedesc, uri: string, idName: expr): stmt = proc canBeImplicit(t: typedesc): bool {.compileTime.} = let tDesc = getType(t) if tDesc.kind != nnkObjectTy: return false - if tDesc[1].len != 1: return false - if tDesc[1][0].kind != nnkRecCase: return false + if tDesc[2].len != 1: return false + if tDesc[2][0].kind != nnkRecCase: return false var foundEmptyBranch = false - for i in 1.. tDesc[1][0].len - 1: - case tDesc[1][0][i][1].len # branch contents + for i in 1.. tDesc[2][0].len - 1: + case tDesc[2][0][i][1].len # branch contents of 0: if foundEmptyBranch: return false else: foundEmptyBranch = true diff --git a/yaml.nimble b/yaml.nimble index 2dbd55e..fd7f553 100644 --- a/yaml.nimble +++ b/yaml.nimble @@ -1,6 +1,6 @@ # Package -version = "0.5.0" +version = "0.5.1" author = "Felix Krause" description = "YAML 1.2 implementation for Nim" license = "MIT"