Added string.add(openarray[char]) and macros.typedParams

This commit is contained in:
Zahary Karadjov 2019-03-11 11:37:51 +02:00
parent b18e8877a7
commit 3b28f390fc
2 changed files with 14 additions and 0 deletions

View File

@ -226,3 +226,11 @@ proc newLitFixed*(arg: tuple): NimNode {.compileTime.} =
for a,b in arg.fieldPairs:
result.add nnkExprColonExpr.newTree(newIdentNode(a), newLitFixed(b))
iterator typedParams*(n: NimNode, skip = 0): (NimNode, NimNode) =
for i in (1 + skip) ..< n.params.len:
let paramNodes = n.params[i]
let paramType = paramNodes[^2]
for j in 0 ..< paramNodes.len - 2:
yield (paramNodes[j], paramType)

6
std_shims/strings.nim Normal file
View File

@ -0,0 +1,6 @@
proc add*(s: var string, data: openarray[char]) =
if data.len > 0:
let prevEnd = s.len
s.setLen(prevEnd + data.len)
copyMem(addr s[prevEnd], unsafeAddr data[0], data.len)