mirror of https://github.com/status-im/NimYAML.git
replace shallowCopy for ARC/ORC
This commit is contained in:
parent
c7d8aa6467
commit
a5552a1a18
|
@ -162,6 +162,9 @@ proc constructChild*(s: var YamlStream, c: ConstructionContext,
|
|||
c.refs[target] = (tag: yamlTag(YamlNode), p: cast[pointer](result))
|
||||
|
||||
var start: Event
|
||||
when defined(gcArc) or defined(gcOrc):
|
||||
start = s.next()
|
||||
else:
|
||||
shallowCopy(start, s.next())
|
||||
|
||||
case start.kind
|
||||
|
@ -198,6 +201,9 @@ proc constructChild*(s: var YamlStream, c: ConstructionContext,
|
|||
result = YamlNode(tag: start.scalarProperties.tag,
|
||||
kind: yScalar, scalarStyle: start.scalarStyle,
|
||||
startPos: start.startPos, endPos: start.endPos)
|
||||
when defined(gcArc) or defined(gcOrc):
|
||||
result.content = move start.scalarContent
|
||||
else:
|
||||
shallowCopy(result.content, start.scalarContent)
|
||||
addAnchor(c, start.scalarProperties.anchor)
|
||||
of yamlAlias:
|
||||
|
|
|
@ -105,14 +105,14 @@ proc next*(s: YamlStream): Event {.raises: [YamlStreamError], gcSafe.} =
|
|||
e.parent = cur
|
||||
raise e
|
||||
|
||||
proc peek*(s: YamlStream): Event {.raises: [YamlStreamError].} =
|
||||
proc peek*(s: YamlStream): lent Event {.raises: [YamlStreamError].} =
|
||||
## Get the next item of the stream without advancing the stream.
|
||||
## Requires ``finished(s) == true``. Handles exceptions of the backend like
|
||||
## ``next()``.
|
||||
if not s.peeked:
|
||||
s.cached = s.next()
|
||||
s.peeked = true
|
||||
shallowCopy(result, s.cached)
|
||||
result = s.cached
|
||||
|
||||
proc `peek=`*(s: YamlStream, value: Event) {.raises: [].} =
|
||||
## Set the next item of the stream. Will replace a previously peeked item,
|
||||
|
|
|
@ -21,7 +21,7 @@ type Level = tuple[node: JsonNode, key: string, expKey: bool]
|
|||
proc initLevel(node: JsonNode): Level {.raises: [].} =
|
||||
(node: node, key: "", expKey: true)
|
||||
|
||||
proc jsonFromScalar(content: string, tag: Tag): JsonNode
|
||||
proc jsonFromScalar(content: sink string, tag: Tag): JsonNode
|
||||
{.raises: [YamlConstructionError].}=
|
||||
new(result)
|
||||
var mappedType: TypeHint
|
||||
|
@ -66,6 +66,9 @@ proc jsonFromScalar(content: string, tag: Tag): JsonNode
|
|||
result = JsonNode(kind: JNull)
|
||||
else:
|
||||
result = JsonNode(kind: JString)
|
||||
when defined(gcArc) or defined(gcOrc):
|
||||
result.str = content
|
||||
else:
|
||||
shallowCopy(result.str, content)
|
||||
except ValueError:
|
||||
var e = newException(YamlConstructionError, "Cannot parse numeric value")
|
||||
|
|
Loading…
Reference in New Issue