about summary refs log tree commit diff stats
path: root/lib/quickjs
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-06-27 22:56:47 +0200
committerbptato <nincsnevem662@gmail.com>2023-06-27 22:56:47 +0200
commit756ac1277b8e19769827dd08a764105e4c4720a6 (patch)
treeb6a705dd7cf0e941ec7016d6c308c314994556d0 /lib/quickjs
parent50eead4e8a483c06008553d803af8d1adaa0cc4f (diff)
downloadchawan-756ac1277b8e19769827dd08a764105e4c4720a6.tar.gz
Remove getClassID hack
Add a JS_GetClassID function to QJS instead.
Diffstat (limited to 'lib/quickjs')
-rw-r--r--lib/quickjs/quickjs.c9
-rw-r--r--lib/quickjs/quickjs.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/quickjs/quickjs.c b/lib/quickjs/quickjs.c
index 2d50e247..52f1d159 100644
--- a/lib/quickjs/quickjs.c
+++ b/lib/quickjs/quickjs.c
@@ -9886,6 +9886,15 @@ void *JS_GetOpaque2(JSContext *ctx, JSValueConst obj, JSClassID class_id)
     return p;
 }
 
+JSClassID JS_GetClassID(JSValueConst obj)
+{
+    JSObject *p;
+    if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT)
+        return 0;
+    p = JS_VALUE_GET_OBJ(obj);
+    return p->class_id;
+}
+
 #define HINT_STRING  0
 #define HINT_NUMBER  1
 #define HINT_NONE    2
diff --git a/lib/quickjs/quickjs.h b/lib/quickjs/quickjs.h
index b05e510d..1d761379 100644
--- a/lib/quickjs/quickjs.h
+++ b/lib/quickjs/quickjs.h
@@ -803,6 +803,7 @@ int JS_DefinePropertyGetSet(JSContext *ctx, JSValueConst this_obj,
 void JS_SetOpaque(JSValue obj, void *opaque);
 void *JS_GetOpaque(JSValueConst obj, JSClassID class_id);
 void *JS_GetOpaque2(JSContext *ctx, JSValueConst obj, JSClassID class_id);
+JSClassID JS_GetClassID(JSValueConst obj);
 
 /* 'buf' must be zero terminated i.e. buf[buf_len] = '\0'. */
 JSValue JS_ParseJSON(JSContext *ctx, const char *buf, size_t buf_len,