mirror of
https://github.com/status-im/NimYAML.git
synced 2025-01-27 11:34:56 +00:00
Fixed issues in quickstart and taglib
* Updated expected YAML in 02 * Fixed duplicate TagIds in taglib
This commit is contained in:
parent
0f2e077b87
commit
4bde3a7986
@ -2,15 +2,15 @@
|
||||
---
|
||||
!nim:system:seq(nim:custom:Person) [
|
||||
!nim:custom:Person {
|
||||
? !!str "name"
|
||||
? !nim:field "name"
|
||||
: !!str "Karl Koch",
|
||||
? !!str "age"
|
||||
? !nim:field "age"
|
||||
: !nim:system:int32 "23"
|
||||
},
|
||||
!nim:custom:Person {
|
||||
? !!str "name"
|
||||
? !nim:field "name"
|
||||
: !!str "Peter Pan",
|
||||
? !!str "age"
|
||||
? !nim:field "age"
|
||||
: !nim:system:int32 "12"
|
||||
}
|
||||
]
|
||||
|
@ -46,6 +46,8 @@ proc outputTest(path: string): bool =
|
||||
currentDir = getCurrentDir()
|
||||
basePath = currentDir / ".."
|
||||
absolutePath = currentDir / path
|
||||
outFileExpected = path / "01-out.yaml"
|
||||
outFileActual = path / "out.yaml"
|
||||
copyFile(codeFileOrig, codeFileDest)
|
||||
defer: removeFile(codeFileDest)
|
||||
var process = startProcess("nim c --hints:off -p:" & escape(basePath) &
|
||||
@ -69,9 +71,10 @@ proc outputTest(path: string): bool =
|
||||
echo process.outputStream().readAll()
|
||||
result = false
|
||||
else:
|
||||
defer: removeFile(outFileActual)
|
||||
var
|
||||
expected = open(path / "01-out.yaml", fmRead)
|
||||
actual = open(path / "out.yaml", fmRead)
|
||||
expected = open(outFileExpected, fmRead)
|
||||
actual = open(outFileActual, fmRead)
|
||||
lineNumber = 1
|
||||
defer:
|
||||
expected.close()
|
||||
|
@ -94,7 +94,10 @@ const
|
||||
## for seqs that are nil. This tag is used regardless of the seq's generic
|
||||
## type parameter.
|
||||
|
||||
yFirstCustomTagId* : TagId = 1000.TagId ## \
|
||||
yFirstStaticTagId* : TagId = 1000.TagId ## \
|
||||
## The first ``TagId`` assigned by the ``setTagId`` templates.
|
||||
|
||||
yFirstCustomTagId* : TagId = 10000.TagId ## \
|
||||
## The first ``TagId`` which should be assigned to an URI that does not
|
||||
## exist in the ``YamlTagLibrary`` which is used for parsing.
|
||||
|
||||
@ -217,7 +220,7 @@ var
|
||||
## `serializable <#serializable,stmt,stmt>`_.
|
||||
|
||||
var
|
||||
nextStaticTagId {.compileTime.} = 100.TagId ## \
|
||||
nextStaticTagId {.compileTime.} = yFirstStaticTagId ## \
|
||||
## used for generating unique TagIds with ``setTagUri``.
|
||||
registeredUris {.compileTime.} = newSeq[string]() ## \
|
||||
## Since Table doesn't really work at compile time, we also store
|
||||
@ -249,6 +252,8 @@ template setTagUri*(t: typedesc, uri: string, idName: untyped): typed =
|
||||
static:
|
||||
registeredUris.add(uri)
|
||||
nextStaticTagId = TagId(int(nextStaticTagId) + 1)
|
||||
when nextStaticTagId == yFirstCustomTagId:
|
||||
{.fatal: "Too many tags!".}
|
||||
serializationTagLibrary.tags[uri] = idName
|
||||
proc yamlTag*(T: typedesc[t]): TagId {.inline, raises: [].} = idName
|
||||
## autogenerated
|
||||
|
Loading…
x
Reference in New Issue
Block a user