Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions yaml/dom.nim
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,11 @@ proc constructChild*(
c.refs[target] = (tag: yamlTag(YamlNode), p: cast[pointer](result))

var start: Event
when defined(gcArc) or defined(gcOrc):
start = ctx.input.next()
else:
# instead of checking whether gcArc, gcOrc, or gcAtomicArc are defined, we use compiles to make it future proof. note that shallowCopy is only defined when for mm:arc/orc/atomicArc
when compiles(shallowCopy(start, ctx.input.next())):
shallowCopy(start, ctx.input.next())
else:
start = ctx.input.next()

case start.kind
of yamlStartMap:
Expand Down Expand Up @@ -213,10 +214,10 @@ proc constructChild*(
endPos: start.endPos,
)
ctx.addAnchor(start.scalarProperties.anchor)
when defined(gcArc) or defined(gcOrc):
result.content = move start.scalarContent
else:
when compiles(shallowCopy(result.content, start.scalarContent)):
shallowCopy(result.content, start.scalarContent)
else:
result.content = move start.scalarContent
of yamlAlias:
result = cast[YamlNode](ctx.refs.getOrDefault(start.aliasTarget).p)
else: internalError("Malformed YamlStream")
Expand Down
6 changes: 3 additions & 3 deletions yaml/tojson.nim
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ proc jsonFromScalar(
result = JsonNode(kind: JNull)
else:
result = JsonNode(kind: JString)
when defined(gcArc) or defined(gcOrc):
result.str = content
else:
when compiles(shallowCopy(result.str, content)): # instead of checking whether gcArc, gcOrc, or gcAtomicArc are defined, we use compiles to make it future proof. note that shallowCopy is only defined when for mm:arc/orc/atomicArc
shallowCopy(result.str, content)
else:
result.str = content
except ValueError as ve:
var e = newException(YamlConstructionError, "Cannot parse numeric value")
e.parent = ve
Expand Down