[webkit-dev] how to extend the javascript native object?
Jack Wootton
jackwootton at gmail.com
Fri Jul 3 09:26:11 PDT 2009
To add, it maybe useful to look at the following files in the
JavaScriptCore (Although, personally I didn't find them particularly
easy to understand.)
JavaScriptCore\API\testapi.c
testapi.js
There are also some example programs that do what you want to do, only
with different objects.
JSPong: http://developer.apple.com/SampleCode/JSPong/index.html
JSInterpreter: http://developer.apple.com/samplecode/JSInterpreter/index.html
More programs can be found here:
http://developer.apple.com/SampleCode/Cocoa/idxInternetWeb-date.html
2009/7/3 Jack Wootton <jackwootton at gmail.com>:
> Are you saying you wan to add a 'widget' property to the Window
> object? If so, then the JavaScriptCore API has methods that will
> help you:
>
> Here is the API:
>
> http://gemma.apple.com/documentation/Carbon/Reference/WebKit_JavaScriptCore_Ref/index.html#//apple_ref/doc/framework/javascriptcore_fw
>
> If this is what you wish to do, then the following is a rough guide of
> what you need to do:
>
> 1. Create an empty class definition, you can create an empty class
> definition using kJSClassDefinitionEmpty.
> 2. Use the class definition with the JSCoreAPI method "JSClassCreate"
> to create your class.
> 3. Use your new class with JSObjectMake to create your new JSObject
> (this will be your widget object).
> 4 Use JSObjectSetProperty to add your new JSObject as a property of
> the Window object.
>
>
> On Fri, Jul 3, 2009 at 4:51 PM, 胡 波<h3282129 at yahoo.com.cn> wrote:
>> I want to extend the javascript native object,such as widget object,and
>> make it inherit window object. That is to say,when the widget object is
>> extended, and we can use it by the window.widget.(method/property) in the
>> html document?
>> ________________________________
>> 好玩贺卡等你发,邮箱贺卡全新上线!
>> _______________________________________________
>> webkit-dev mailing list
>> webkit-dev at lists.webkit.org
>> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>>
>>
>
>
>
> --
> Regards
> Jack
>
--
Regards
Jack
More information about the webkit-dev
mailing list