From 0d8ebdce2897244d8297eecd175441e541292b94 Mon Sep 17 00:00:00 2001 From: bptato Date: Mon, 15 Apr 2024 22:09:32 +0200 Subject: 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. --- src/js/jstypes.nim | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/js/jstypes.nim') diff --git a/src/js/jstypes.nim b/src/js/jstypes.nim index 5336f067..9e1d72ea 100644 --- a/src/js/jstypes.nim +++ b/src/js/jstypes.nim @@ -33,3 +33,11 @@ type func high*(abuf: JSArrayBuffer): int = return int(abuf.len) - 1 + +# A specialization of JSValue to make writing generic code for functions +# easier. +type JSValueFunction* = ref object + fun*: JSValue + +converter toJSValue*(f: JSValueFunction): JSValue = + f.fun -- cgit 1.4.1-2-gfad0