mirror of
https://github.com/status-im/nim-stew.git
synced 2025-01-09 11:45:42 +00:00
Added string.add(openarray[char]) and macros.typedParams
This commit is contained in:
parent
b18e8877a7
commit
3b28f390fc
@ -226,3 +226,11 @@ proc newLitFixed*(arg: tuple): NimNode {.compileTime.} =
|
|||||||
for a,b in arg.fieldPairs:
|
for a,b in arg.fieldPairs:
|
||||||
result.add nnkExprColonExpr.newTree(newIdentNode(a), newLitFixed(b))
|
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
6
std_shims/strings.nim
Normal 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)
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user