diff options
author | bptato <nincsnevem662@gmail.com> | 2023-04-30 12:19:24 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-04-30 12:19:24 +0200 |
commit | a02c408f933aea6f405ed3c64ab151b01b33ae9e (patch) | |
tree | 4946f6b13da782a92a1ecc0f03402abacf2614b3 /src/js/javascript.nim | |
parent | 05b64a1d8fa95381d756231f665c0b8c79787b67 (diff) | |
download | chawan-a02c408f933aea6f405ed3c64ab151b01b33ae9e.tar.gz |
WIP fetch
Diffstat (limited to 'src/js/javascript.nim')
-rw-r--r-- | src/js/javascript.nim | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/js/javascript.nim b/src/js/javascript.nim index f3193199..263fa8aa 100644 --- a/src/js/javascript.nim +++ b/src/js/javascript.nim @@ -1545,15 +1545,21 @@ proc findPragmas(t: NimNode): JSObjectPragmas = of "jsget": result.jsget.add(varName) of "jsset": result.jsset.add(varName) -type TabGetSet* = object - name*: string - get*: JSGetterMagicFunction - set*: JSSetterMagicFunction - magic*: uint16 +type + TabGetSet* = object + name*: string + get*: JSGetterMagicFunction + set*: JSSetterMagicFunction + magic*: uint16 + + TabFunc* = object + name*: string + fun*: JSCFunction macro registerType*(ctx: typed, t: typed, parent: JSClassID = 0, asglobal = false, nointerface = false, name: static string = "", - extra_getset: static openarray[TabGetSet] = []): JSClassID = + extra_getset: static openarray[TabGetSet] = [], + extra_funcs: static openarray[TabFunc] = []): JSClassID = result = newStmtList() let tname = t.strVal # the nim type's name. let name = if name == "": tname else: name # possibly a different name, e.g. Buffer for Container @@ -1649,6 +1655,14 @@ macro registerType*(ctx: typed, t: typed, parent: JSClassID = 0, asglobal = let m = x.magic tabList.add(quote do: JS_CGETSET_MAGIC_DEF(`k`, `g`, `s`, `m`)) + for x in extra_funcs: + #TODO TODO TODO ditto. wtf + if repr(x) != "" and repr(x) != "[]": + let name = x.name + let fun = x.fun + tabList.add(quote do: + JS_CFUNC_DEF(`name`, 0, (`fun`))) + if ctorFun != nil: sctr = ctorFun result.add(ctorImpl) |