From cea4aa0374a2f8c1df40a30060c34de8ce257090 Mon Sep 17 00:00:00 2001 From: bptato Date: Wed, 14 Sep 2022 19:33:27 +0200 Subject: Tweaks/bugfixes for arm --- src/js/javascript.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/js/javascript.nim') diff --git a/src/js/javascript.nim b/src/js/javascript.nim index 9ba4e87f..0bb7b12f 100644 --- a/src/js/javascript.nim +++ b/src/js/javascript.nim @@ -1,6 +1,5 @@ import macros import options -import sequtils import strformat import strutils import tables @@ -272,7 +271,10 @@ func newJSClass*(ctx: JSContext, cdef: JSClassDefConst, cctor: JSCFunction, func else: proto = JS_NewObject(ctx) if funcs.len > 0: - rtOpaque.flist.add(funcs.toSeq()) + # We avoid funcs being GC'ed by putting the list in rtOpaque. + # (QuickJS uses the pointer later.) + #TODO maybe put them in ctxOpaque instead? + rtOpaque.flist.add(@funcs) JS_SetPropertyFunctionList(ctx, proto, addr rtOpaque.flist[^1][0], cint(funcs.len)) assert JS_SetProperty(ctx, proto, ctxOpaque.sym_toStringTag, JS_NewString(ctx, cdef.class_name)) == 1 JS_SetClassProto(ctx, result, proto) -- cgit 1.4.1-2-gfad0