You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previously, I could set an opaque on the global object, but now I can't because it's a JS_CLASS_OBJECT which is < JS_CLASS_INIT_COUNT.
The latter one is a bit problematic, because my type conversion functions expect the global object to have an opaque. I would change its class ID if I could, but at least when I was writing my wrapper for qjs I couldn't, and I don't see any changes in -ng that would enable this.
I don't know what the preferred fix is for this one; this patch works for me:
diff --git a/quickjs.c b/quickjs.c
index 9cac6de..e268ce3 100644
--- a/quickjs.c
+++ b/quickjs.c
@@ -10102,7 +10102,8 @@ JS_BOOL JS_SetOpaque(JSValue obj, void *opaque)
if (JS_VALUE_GET_TAG(obj) == JS_TAG_OBJECT) {
p = JS_VALUE_GET_OBJ(obj);
// User code can't set the opaque of internal objects.
- if (p->class_id >= JS_CLASS_INIT_COUNT) {
+ if (p->class_id >= JS_CLASS_INIT_COUNT ||
+ p->class_id == JS_CLASS_OBJECT) {
p->u.opaque = opaque;
return 0;
}
Attempting to upgrade to the new version (?), I've noticed some oddities with SetOpaque:
JS_FALSE(0) on success andJS_TRUE(1) on failure, which I find somewhat counter-intuitive. Maybe it's not too late to change it?JS_CLASS_OBJECTwhich is <JS_CLASS_INIT_COUNT.The latter one is a bit problematic, because my type conversion functions expect the global object to have an opaque. I would change its class ID if I could, but at least when I was writing my wrapper for qjs I couldn't, and I don't see any changes in -ng that would enable this.
I don't know what the preferred fix is for this one; this patch works for me: