diff options
author | cooldome <ariabushenko@gmail.com> | 2020-09-16 17:25:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-16 17:25:24 +0100 |
commit | 341be0b61cc0603dc921c99b891208dcda274c98 (patch) | |
tree | 49d50667c74a64d230eda9369fb2b9dcddc2ace2 /lib | |
parent | a3e9cc52343a54cadc7b77b783e1c8b6ba2b327f (diff) | |
download | Nim-341be0b61cc0603dc921c99b891208dcda274c98.tar.gz |
proc params as syms (#15332)
* proc params are now syms * Fix typesrenderer * Add testcase for disrupteks issue * fix test * Trigger build * Trigger build * Trigger build Co-authored-by: Clyybber <darkmine956@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/js/jsffi.nim | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/js/jsffi.nim b/lib/js/jsffi.nim index e79e4e20d..0dce6f3b9 100644 --- a/lib/js/jsffi.nim +++ b/lib/js/jsffi.nim @@ -458,6 +458,14 @@ macro `{}`*(typ: typedesc, xs: varargs[untyped]): auto = # Macro to build a lambda using JavaScript's `this` # from a proc, `this` being the first argument. +proc replaceSyms(n: NimNode): NimNode = + if n.kind == nnkSym: + result = newIdentNode($n) + else: + result = n + for i in 0..<n.len: + result[i] = replaceSyms(n[i]) + macro bindMethod*(procedure: typed): auto = ## Takes the name of a procedure and wraps it into a lambda missing the first ## argument, which passes the JavaScript builtin ``this`` as the first @@ -491,7 +499,7 @@ macro bindMethod*(procedure: typed): auto = getImpl(procedure) else: procedure - args = rawProc[3] + args = rawProc[3].copyNimTree.replaceSyms thisType = args[1][1] params = newNimNode(nnkFormalParams).add(args[0]) body = newNimNode(nnkLambda) |