Skip to content

Commit

Permalink
I think I fixed the compiler errors with the correct exports
Browse files Browse the repository at this point in the history
  • Loading branch information
tanelso2 committed Dec 27, 2023
1 parent d51f1c1 commit 914fef2
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/yanyl/codegen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import
sequtils,
strformat,
sugar,
./core,
./reflection

proc mkYNodeGetCall(n: NimNode, k: string): NimNode =
Expand Down
9 changes: 6 additions & 3 deletions src/yanyl/core.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import
strutils,
sugar,
tables,
yaml
yaml,
yaml/data,
yaml/dom

export data, dom

type
YNodeKind* = enum
Expand Down Expand Up @@ -343,8 +347,7 @@ proc loadNode*(s: string | Stream): YNode =
doAssert n.get("i", int) == 3
doAssert n.get("f", float) == 0.32

var node: YamlNode
load(s,node)
var node: YamlNode = loadAs[YamlNode](s)
return translate(node)

proc newline(i: int): string =
Expand Down
5 changes: 5 additions & 0 deletions tests/example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: Peter Parker
occupation: Photographer
aliases:
- Tiger
- Pete
4 changes: 2 additions & 2 deletions tests/tcomparison_output.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ deriveYaml Obj

var o = Obj(i: 42, s: "Hello galaxy")
# NimYAML
echo dump(o)
echo dump(jsonDumper(), o)
# Yanyl
echo toYamlStr(o)
echo toYamlStr(o)
5 changes: 3 additions & 2 deletions tests/tderiveyamls.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import
yanyl
yanyl,
std/macros

type
Owner = ref object of RootObj
Expand All @@ -22,4 +23,4 @@ owner:
let garf = ofYamlStr(sample, Pet)
doAssert garf.name == "Garfield"
doAssert garf.kind == "cat"
doAssert garf.owner.name == "J. Arbuckle"
doAssert garf.owner.name == "J. Arbuckle"
3 changes: 2 additions & 1 deletion tests/tloadnode.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ assert y.get("c").kind == ynList
import
streams

let s2 = newFileStream("example.yaml")
let s2 = newFileStream("tests/example.yaml")
let y2: YNode = s2.loadNode()
assert y2.get("name").kind == ynString

0 comments on commit 914fef2

Please sign in to comment.