[webkit-dev] KJS::JSObject question
jackwootton at gmail.com
Fri May 15 08:06:25 PDT 2009
I am using kJSClassDefinitionEmpty to help create the JSClassDefinition.
Also, myObjectDef.myObjectName; should be myObjectDef.className = myObjectName;
On Fri, May 15, 2009 at 3:35 PM, Jack Wootton <jackwootton at gmail.com> wrote:
> My understanding now is that to add a custo object, the following
> steps would need to be taken:
> 1. Create a name for the new object, for example:
> JSStringRef myObjectName = JSStringCreateWithUTF8CString("foo");
> 2. Create the class definition structure;
> JSClassDefinition myObjectDef;
> myObjectDef.version = 1;
> 3. Create the class.
> JSClassRef globalObjectClass = JSClassCreate(&myObjectDef);
> 4. Create the context:
> JSGlobalContextRef context = JSGlobalContextCreate(globalObjectClass);
> 5. Make the object:
> JSObjectRef JSObjectMake(context, globalObjectClass, NULL)
> However I have the following questions.
> 1. Who should share the context? Is a single context used for a
> single webpage / frame?
> 2. Where do I define the class that will actually handle the
> implementation of any methods on my new object?
> 3. The object has been made using "JSObjectMake", but how is it added to WebKit?
> Many thanks,
> 2009/5/15 browserwk <browserwk at gmail.com>:
>> Following file is need carefully.
>> -------- Original Message --------
>> Subject: Re: [webkit-dev] KJS::JSObject question
>> From: Jack Wootton <jackwootton at gmail.com>
>> To: Darin Adler <darin at apple.com>
>> Cc: "webkit-dev at lists.webkit.org" <webkit-dev at lists.webkit.org>
>> Date: 2009年05月15日 星期五 17时40分40秒
>>> 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: 營 do not understand how JSObject can be used to allow for
>>>> My first comment is that you should not be using JSObject directly. The
>>>> which includes types like JSObjectRef. The JSObject internal interface is
>>>> constantly being changed and not suitable for use outside the WebKit
>>>> 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抯
>>>> prototype, or the property can be 揵uilt 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
>>>> String.prototype.toLowerCase or you can make an object that acts like a
>>>> function using JSClassCreate supplying a JSObjectCallAsFunctionCallback
>>>> -- Darin
More information about the webkit-dev