More capable alternative of unpackVarargs

This commit is contained in:
Zahary Karadjov 2019-07-18 21:30:03 +03:00
parent 5b6881588c
commit 4f4f138fb4
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 11 additions and 0 deletions

View File

@ -253,3 +253,14 @@ iterator typedParams*(n: NimNode, skip = 0): (NimNode, NimNode) =
for j in 0 ..< paramNodes.len - 2:
yield (paramNodes[j], paramType)
macro unpackArgs*(callee: typed, args: untyped): untyped =
result = newCall(callee)
for arg in args:
let arg = if arg.kind == nnkHiddenStdConv: arg[1]
else: arg
if arg.kind == nnkArgList:
for subarg in arg:
result.add subarg
else:
result.add arg