NimYAML version 0.5.1

* Fixed a problem that was caused by a change in getType in Nim devel
This commit is contained in:
Felix Krause 2016-06-05 20:52:43 +02:00
parent 2ce212b79a
commit 152a4f3bd3
5 changed files with 20 additions and 9 deletions

View File

@ -1,3 +1,9 @@
### 0.5.1
Bugfixes:
* Fixed a problem that was introduced by a change in Nim devel
### 0.5.0
Features:

View File

@ -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.

View File

@ -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]))

View File

@ -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

View File

@ -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"