mirror of https://github.com/status-im/NimYAML.git
Fixed remaining JS compilation issues
* Changed transform() to not use first class iterators * provide a archaic `$` for uints that will break if poked * TODO: test JS output!
This commit is contained in:
parent
ad18db5113
commit
5a90255993
|
@ -601,7 +601,7 @@ proc transform*(input: Stream, output: Stream,
|
|||
events = parser.parse(input)
|
||||
try:
|
||||
if options.style == psCanonical:
|
||||
var specificTagEvents = iterator(): YamlStreamEvent =
|
||||
var bys: YamlStream = newBufferYamlStream()
|
||||
for e in events:
|
||||
var event = e
|
||||
case event.kind
|
||||
|
@ -624,9 +624,8 @@ proc transform*(input: Stream, output: Stream,
|
|||
of yTypeUnknown: event.scalarTag = yTagString
|
||||
elif event.scalarTag == yTagExclamationMark:
|
||||
event.scalarTag = yTagString
|
||||
yield event
|
||||
var s = initYamlStream(specificTagEvents)
|
||||
present(s, output, tagLib, options)
|
||||
BufferYamlStream(bys).buf.add(e)
|
||||
present(bys, output, tagLib, options)
|
||||
else: present(events, output, tagLib, options)
|
||||
except YamlStreamError:
|
||||
var e = getCurrentException()
|
||||
|
|
|
@ -121,6 +121,11 @@ proc constructObject*(s: var YamlStream, c: ConstructionContext,
|
|||
constructObject(s, c, u32Result)
|
||||
result= uint(u32Result)
|
||||
|
||||
when defined(JS):
|
||||
# TODO: this is a dirty hack and may lead to overflows!
|
||||
proc `$`(x: uint8|uint16|uint32|uint64|uint): string =
|
||||
result = $BiggestInt(x)
|
||||
|
||||
proc representObject*[T: uint8|uint16|uint32|uint64](value: T, ts: TagStyle,
|
||||
c: SerializationContext, tag: TagId) {.raises: [].} =
|
||||
## represents an unsigned integer value as YAML scalar
|
||||
|
|
|
@ -85,7 +85,6 @@ proc finished*(s: YamlStream): bool =
|
|||
raise e
|
||||
except Exception:
|
||||
let cur = getCurrentException()
|
||||
echo cur.getStackTrace()
|
||||
var e = newException(YamlStreamError, cur.msg)
|
||||
e.parent = cur
|
||||
raise e
|
||||
|
|
2
yaml.nim
2
yaml.nim
|
@ -750,9 +750,9 @@ setTagUri(float64, "!nim:system:float64", yTagNimFloat64)
|
|||
include private.tagLibrary
|
||||
include private.events
|
||||
include private.json
|
||||
include private.streams
|
||||
include private.presenter
|
||||
include private.parse
|
||||
include private.hints
|
||||
include private.streams
|
||||
include private.serialization
|
||||
include private.dom
|
||||
|
|
Loading…
Reference in New Issue