[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
problem:
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
JSValueIsObjectOfClass)
 * Creating dynamic constructors using another JSObjectRef as reference
for the class.

I did submit a bug and a patch for it:
https://bugs.webkit.org/show_bug.cgi?id=160032

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

Thanks,

Danilo Cesar Lemes de Paula


More information about the webkit-dev mailing list