[webkit-dev] KJS::JSObject question

Jack Wootton jackwootton at gmail.com
Fri May 15 02:40:40 PDT 2009


OK.  It seems I was on completely the wrong track.  I was under the
impression WebKit didn't have public and non public APIs as such, at
least I haven't read anything to this effect.  Where can I read what
the published Vs non published APIs are?  Or which ones I should use
and which ones I shouldn't?

On Thu, May 14, 2009 at 6:02 PM, Darin Adler <darin at apple.com> wrote:
> 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
>
>



-- 
Regards
Jack


More information about the webkit-dev mailing list