xmltree: remove usage of deprecated callsite()

This commit is contained in:
Andreas Rumpf 2018-04-24 08:25:00 +02:00
commit 8ce9e43434

View file

@ -12,9 +12,9 @@
import macros, strtabs import macros, strtabs
type type
XmlNode* = ref XmlNodeObj ## an XML tree consists of ``PXmlNode``'s. XmlNode* = ref XmlNodeObj ## an XML tree consists of ``XmlNode``'s.
XmlNodeKind* = enum ## different kinds of ``PXmlNode``'s XmlNodeKind* = enum ## different kinds of ``XmlNode``'s
xnText, ## a text element xnText, ## a text element
xnElement, ## an element with 0 or more children xnElement, ## an element with 0 or more children
xnCData, ## a CDATA node xnCData, ## a CDATA node
@ -315,9 +315,7 @@ proc newXmlTree*(tag: string, children: openArray[XmlNode],
for i in 0..children.len-1: result.s[i] = children[i] for i in 0..children.len-1: result.s[i] = children[i]
result.fAttr = attributes result.fAttr = attributes
proc xmlConstructor(e: NimNode): NimNode {.compileTime.} = proc xmlConstructor(a: NimNode): NimNode {.compileTime.} =
expectLen(e, 2)
var a = e[1]
if a.kind == nnkCall: if a.kind == nnkCall:
result = newCall("newXmlTree", toStrLit(a[0])) result = newCall("newXmlTree", toStrLit(a[0]))
var attrs = newNimNode(nnkBracket, a) var attrs = newNimNode(nnkBracket, a)
@ -348,7 +346,6 @@ macro `<>`*(x: untyped): untyped =
## ##
## <a href="http://nim-lang.org">Nim rules.</a> ## <a href="http://nim-lang.org">Nim rules.</a>
## ##
let x = callsite()
result = xmlConstructor(x) result = xmlConstructor(x)
proc child*(n: XmlNode, name: string): XmlNode = proc child*(n: XmlNode, name: string): XmlNode =