[webkit-dev] JavaScriptCore constructor callback and class questions

Dan Waylonis danw at nekotech.com
Tue Jan 8 20:24:48 PST 2008


Hi,

I'm using JavaScriptCore and have created a custom class to be used  
within the global context.  I've defined a constructor callback with  
the signature of JSObjectCallAsConstructorCallback:

JSObjectRef PointConstructor(JSContextRef ctx, JSObjectRef  
constructor, size_t argumentCount, const JSValueRef arguments[],  
JSValueRef* exception);

and set the returned object as the value of the "Point" property on  
the global object.  When the interpreter encounters the line "var p =  
new Point();" it calls things correctly and I'm able to create my  
Point object and it works properly in the scripting environment.

I'm interested in generalizing my code so that I could have a single  
constructor callback function for multiple objects, and based on the  
value of the "constructor" argument, create the correct object.

Can any information (e.g., name or JSClassRef) about the class being  
constructed be extracted from the "constructor" argument?  I don't get  
any enumerable properties from it.  I did noticed that the memory  
address of the "constructor" argument is identical to the one that I  
got when I called JSObjectMakeConstructor() and set it as a property  
on the global object.

Also, there doesn't seem to be a way to look up the name (or any other  
information) on a JSClassRef object.  It would be nice to have a  
function to get back a copy of the JSClassDefinition used to create  
the class.

Thanks,
Dan
-----------------------------------------------------------------
Dan Waylonis                    danw at nekotech.com
nekotech SOFTWARE
http://www.nekotech.com
650.964.2490 Voice / Fax



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.webkit.org/pipermail/webkit-dev/attachments/20080108/d3e49f0f/attachment-0001.html


More information about the webkit-dev mailing list