[webkit-dev] Embedding JavaScriptCore - Creating new object types ???

Darin Adler darin at apple.com
Wed Jan 7 13:28:40 PST 2009

On Jan 7, 2009, at 11:50 AM, Martin Wengenmayer wrote:

> var a = new Vector3f(0,1,0);

In JavaScript. the way this works is that Vector3f has to be some  
object that's in scope. This is normally accomplished by adding it as  
a property to the global object. That object is called the  
"constructor". If the object is one that created with the  
JavaScriptCore API, then the function callAsConstructor will be called  
on it to implement the new expression. See JSClassDefinition in  
JSObjectRef.h for details. The callAsConstructor object can then  
return an object of any type, including some other type of custom  
object backed by native code.

     -- Darin

More information about the webkit-dev mailing list