mirror of
https://github.com/status-im/NimYAML.git
synced 2025-01-11 20:14:19 +00:00
Small improvements
This commit is contained in:
parent
36872370d5
commit
f2c81f1fc5
@ -164,7 +164,7 @@ proc present*(s: YamlStream, target: Stream, tagLib: TagLibrary,
|
||||
if finished(s):
|
||||
break
|
||||
cached.enqueue(item)
|
||||
except:
|
||||
except Exception:
|
||||
var e = newException(YamlPresenterStreamError, "")
|
||||
e.parent = getCurrentException()
|
||||
raise e
|
||||
@ -257,7 +257,7 @@ proc present*(s: YamlStream, target: Stream, tagLib: TagLibrary,
|
||||
else:
|
||||
length = high(int)
|
||||
break
|
||||
except:
|
||||
except Exception:
|
||||
var e = newException(YamlPresenterStreamError, "")
|
||||
e.parent = getCurrentException()
|
||||
raise e
|
||||
@ -322,7 +322,7 @@ proc present*(s: YamlStream, target: Stream, tagLib: TagLibrary,
|
||||
break
|
||||
else:
|
||||
mps = mpNeedBlock
|
||||
except:
|
||||
except Exception:
|
||||
var e = newException(YamlPresenterStreamError, "")
|
||||
e.parent = getCurrentException()
|
||||
raise e
|
||||
@ -448,7 +448,7 @@ proc present*(s: YamlStream, target: Stream, tagLib: TagLibrary,
|
||||
if finished(s):
|
||||
break
|
||||
cached.enqueue(next)
|
||||
except:
|
||||
except Exception:
|
||||
var e = newException(YamlPresenterStreamError, "")
|
||||
e.parent = getCurrentException()
|
||||
raise e
|
||||
|
@ -144,7 +144,7 @@ macro serializable*(types: stmt): stmt =
|
||||
while event.kind != yamlEndMap:
|
||||
assert event.kind == yamlScalar
|
||||
assert event.scalarTag in [yTagQuestionMark, yTagString]
|
||||
case hash(event.scalarContent)
|
||||
case event.scalarContent
|
||||
else:
|
||||
raise newException(YamlConstructionError,
|
||||
"Unknown key for " & `tName` & ": " &
|
||||
@ -154,9 +154,8 @@ macro serializable*(types: stmt): stmt =
|
||||
var keyCase = impl[5][1][2]
|
||||
assert keyCase.kind == nnkCaseStmt
|
||||
for field in objectFields(recList):
|
||||
let nameHash = hash($field.name.ident)
|
||||
keyCase.insert(1, newNimNode(nnkOfBranch).add(
|
||||
newIntLitNode(nameHash)).add(newStmtList(
|
||||
newStrLitNode($field.name.ident)).add(newStmtList(
|
||||
newCall("construct", [newIdentNode("s"), newDotExpr(
|
||||
newIdentNode("result"), field.name)])
|
||||
))
|
||||
|
Loading…
x
Reference in New Issue
Block a user