From 50d013362893f3f3a0f2a1d232f73508e3933fe0 Mon Sep 17 00:00:00 2001 From: bptato Date: Sun, 2 Feb 2025 17:02:09 +0100 Subject: javascript: derive ctor functions from parent ctor functions no idea why JS_NewCFunction3 is not public... --- src/html/script.nim | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/html') diff --git a/src/html/script.nim b/src/html/script.nim index 65601d9c..6ee89da2 100644 --- a/src/html/script.nim +++ b/src/html/script.nim @@ -175,12 +175,11 @@ func uninitIfNull*(val: JSValue): JSValue = proc defineConsts*(ctx: JSContext; classid: JSClassID; consts: typedesc[enum]) = let proto = JS_GetClassProto(ctx, classid) - let ctorProto = JS_GetPrototype(ctx, ctx.getOpaque().ctors[classid]) + let ctor = ctx.getOpaque().ctors[classid] #TODO it should be enough to define on the proto only, but apparently # it isn't... for e in consts: let s = $e ctx.definePropertyE(proto, s, uint16(e)) - ctx.definePropertyE(ctorProto, s, uint16(e)) - JS_FreeValue(ctx, ctorProto) + ctx.definePropertyE(ctor, s, uint16(e)) JS_FreeValue(ctx, proto) -- cgit