mirror of
https://github.com/bellard/quickjs.git
synced 2025-09-30 15:04:24 +03:00
Add C API function JS_GetClassID()
If you want to extend a built-in class you need it's class ID and there is no robust way to get that without this accessor. * add JS_INVALID_CLASS_ID constant for invalid class ID. Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
This commit is contained in:
committed by
Charlie Gordon
parent
12c91df577
commit
b91a2aec67
@@ -3391,6 +3391,15 @@ JSClassID JS_NewClassID(JSClassID *pclass_id)
|
||||
return class_id;
|
||||
}
|
||||
|
||||
JSClassID JS_GetClassID(JSValue v)
|
||||
{
|
||||
JSObject *p;
|
||||
if (JS_VALUE_GET_TAG(v) != JS_TAG_OBJECT)
|
||||
return JS_INVALID_CLASS_ID;
|
||||
p = JS_VALUE_GET_OBJ(v);
|
||||
return p->class_id;
|
||||
}
|
||||
|
||||
BOOL JS_IsRegisteredClass(JSRuntime *rt, JSClassID class_id)
|
||||
{
|
||||
return (class_id < rt->class_count &&
|
||||
|
Reference in New Issue
Block a user