Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 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
9 changes: 9 additions & 0 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -3609,6 +3609,15 @@ 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 id)
{
if(!JS_IsRegisteredClass(rt, id)) {
return JS_ATOM_NULL;
}
JSAtom ret = rt->class_array[id].class_name;
JS_DupAtomRT(rt, ret);
return ret;
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

}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
JSAtom JS_GetClassName(JSRuntime *rt, JSClassID id)
{
if(!JS_IsRegisteredClass(rt, id)) {
return JS_ATOM_NULL;
}
JSAtom ret = rt->class_array[id].class_name;
JS_DupAtomRT(rt, ret);
return ret;
}
JSAtom JS_GetClassName(JSRuntime *rt, JSClassID class_id)
{
if (JS_IsRegisteredClass(rt, class_id)) {
return JS_DupAtomRT(rt, rt->class_array[class_id].class_name);
} else {
return JS_ATOM_NULL;
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Github wouldn't let me directly commit the suggestions for whatever reason. I think I got 'em all?
Once again thanks for your patience with this. As a blind person especially whitespace-related inconsistencies are very difficult to even notice without proofreading letter-by-letter and even then they're easy to miss.

Copy link
Contributor

Choose a reason for hiding this comment

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

There are still some left but I'll fix them manually when I merge your PR.


/* 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 id);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
JS_EXTERN JSAtom JS_GetClassName(JSRuntime *rt, JSClassID id);
JS_EXTERN JSAtom JS_GetClassName(JSRuntime *rt, JSClassID class_id);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you.


/* value handling */

Expand Down