On May 14, 2009, at 8:03 AM, Jack Wootton wrote:

My question: I do not understand how JSObject can be used to allow for the JavaScript syntax of : myNewJSObject.someObject.hello().

My first comment is that you should not be using JSObject directly. The right way to do this is to use the C-based public API of JavaScriptCore, which includes types like JSObjectRef. The JSObject internal interface is constantly being changed and not suitable for use outside the WebKit project.

In JavaScript, if you want:

    a.b.c()

to work, then the object "a" need a property "b" with a property "c" that is callable as a function. At each level, the object can just be a general purpose object with a property attached, which can be set up with functions like JSObjectSetProperty, or the property can come from the object’s prototype, or the property can be “built in” to the object, which can by done with JSClassCreate supplying a JSObjectGetPropertyCallback function.

When it comes to the value of the property named "c", to make something callable as a function, you can either use an actual compiled JavaScript function, one of the built in JavaScript functions such as String.prototype.toLowerCase or you can make an object that acts like a function using JSClassCreate supplying a JSObjectCallAsFunctionCallback function.

    -- Darin

_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

Reply via email to