Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -3609,6 +3609,14 @@ bool JS_IsRegisteredClass(JSRuntime *rt, JSClassID class_id)
return (class_id < rt->class_count &&
rt->class_array[class_id].class_id != 0);
}
JSAtom JS_GetClassName(JSRuntime *rt, JSClassID class_id)
{
if (JS_IsRegisteredClass(rt, class_id)) {
return JS_DupAtomRT(rt, rt->class_array[class_id].class_id);
} else {
return JS_ATOM_NULL;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style, spacing


/* create a new object internal class. Return -1 if error, 0 if
OK. The finalizer can be NULL if none is needed. */
Expand Down
2 changes: 2 additions & 0 deletions quickjs.h
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,8 @@ JS_EXTERN JSClassID JS_NewClassID(JSRuntime *rt, JSClassID *pclass_id);
JS_EXTERN JSClassID JS_GetClassID(JSValueConst v);
JS_EXTERN int JS_NewClass(JSRuntime *rt, JSClassID class_id, const JSClassDef *class_def);
JS_EXTERN bool JS_IsRegisteredClass(JSRuntime *rt, JSClassID class_id);
/* Returns the class name or JS_ATOM_NULL if `id` is not a registered class. Must be freed with JS_FreeAtom. */
JS_EXTERN JSAtom JS_GetClassName(JSRuntime *rt, JSClassID class_id);

/* value handling */

Expand Down