diff options
| author | bptato <nincsnevem662@gmail.com> | 2024-04-15 22:09:32 +0200 |
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2024-04-15 22:13:51 +0200 |
| commit | 0d8ebdce2897244d8297eecd175441e541292b94 (patch) | |
| tree | 8331642e3a2163530651801c21556ef39c8ecdaa /src/html | |
| parent | 8df9ef9cbbd284afac4d26494d45253a43aa3146 (diff) | |
| download | chawan-0d8ebdce2897244d8297eecd175441e541292b94.tar.gz | |
js: remove automatic function -> closure conversion
It's a bad idea for several reasons:
* it's inefficient; must allocate an environment for a closure in Nim,
even though we already have one in JS
* writing macros for automatically creating functions with variadic
arguments is suprisingly difficult (see the entire `js/javascript'
module)
* it never really worked properly, because we never freed the associated
function pointer.
We hardly used it anyway, so the easiest fix is to get rid of it
completely.
Diffstat (limited to 'src/html')
| -rw-r--r-- | src/html/dom.nim | 10 | ||||
| -rw-r--r-- | src/html/env.nim | 2 |
2 files changed, 5 insertions, 7 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim index 28e3f558..e3d62b60 100644 --- a/src/html/dom.nim +++ b/src/html/dom.nim @@ -2846,9 +2846,8 @@ proc reflectEvent(element: Element; target: EventTarget; name: StaticAtom; let fun = ctx.newFunction(["event"], value) assert ctx != nil if JS_IsException(fun): - let s = ctx.getExceptionStr() document.window.console.log("Exception in body content attribute of", - urls, s) + urls, ctx.getExceptionMsg()) else: let jsTarget = ctx.toJS(target) ctx.definePropertyC(jsTarget, $name, fun) @@ -3628,13 +3627,12 @@ proc execute*(element: HTMLScriptElement) = let urls = script.baseURL.serialize(excludepassword = true) let ctx = window.jsctx if JS_IsException(script.record): - let s = ctx.getExceptionStr() - window.console.log("Exception in document", urls, s) + window.console.log("Exception in document", urls, ctx.getExceptionMsg()) else: let ret = ctx.evalFunction(script.record) if JS_IsException(ret): - let s = ctx.getExceptionStr() - window.console.log("Exception in document", urls, s) + window.console.log("Exception in document", urls, + ctx.getExceptionMsg()) JS_FreeValue(ctx, ret) document.currentScript = oldCurrentScript else: discard #TODO diff --git a/src/html/env.nim b/src/html/env.nim index ebd9e83e..14a12edd 100644 --- a/src/html/env.nim +++ b/src/html/env.nim @@ -169,7 +169,7 @@ proc addScripting*(window: Window; selector: Selector[int]) = let ret = window.jsctx.eval(src, file, JS_EVAL_TYPE_GLOBAL) if JS_IsException(ret): window.console.log("Exception in document", $window.document.url, - window.jsctx.getExceptionStr()) + window.jsctx.getExceptionMsg()) else: JS_FreeValue(ctx, ret) ) |