[webkit-dev] JSObjectGetClass proposal

Danilo Cesar Lemes de Paula danilo.eu at gmail.com
Thu Jul 21 12:09:59 PDT 2016

Hello there,

So, when working on a javascript binding engine we faced the following
How to create a JSObjectRef as the same type as another one.

With SpiderMonkey, we could use JS_GetClass to get the JSObject's class,
and then use that JSClass to build the new object.
There's no such API on JavaScriptCore.

I'd heard some suggestions to workaround the issue with Set/Get privates
or prototypes, but it definitely didn't get the expected result.

So, I know the JSObjectRef API has been stable for a while, but I would
like to propose the inclusion of the following API in the public list of
jsc APIs.

* JSClassRef JSObjectGetClass(JSObjectRef obj).

I can see this API being used for:
 * Knowing if two objects are from the same class (by using
 * Creating dynamic constructors using another JSObjectRef as reference
for the class.

I did submit a bug and a patch for it:

Would be lovely if a JSC engineer could drop some thoughts or maybe a
review there...


Danilo Cesar Lemes de Paula

More information about the webkit-dev mailing list