[webkit-dev] Adding Javascript object to Webkit

Shakti Ashirvad shakti.ashirvad at gmail.com
Thu Apr 3 22:42:31 PDT 2008


Hi Lee,

There are two ways we can bind C with JS. First implementation is to create
a runtime object which doesn't have a data type
(JavaScriptCore/bindings/testbindings.cpp). This means you can create an
object like "foo" with any number of properties and methods. and you can
directly access

foo.fooBar(); or foo.var

However you cannot create more than one object like:

var a = new Complex(a,b);
a.real
a.img

For this you need to understand the math_object.cpp.

Regards,
Shakti


On Thu, Apr 3, 2008 at 3:31 PM, Lee Ka Yuk <kylee at astri.org> wrote:

>  Hi all,
>
> I'm using the WebKit project for webpage rendering on Qtopia.
> I would like to add some Javascript objects that can be accessed in the
> webpage and implemented with C/C++.
>
> I studied JavaScriptCore/kjs/math_object.* and successfully added a object
> in JavaScriptCore/kjs.
> But I doubt if this is the "correct" way of doing so.
> And this method is not at all useful if I would like to access the SAME
> C/C++ object in the main application.
> Say I added a foo object with member var, I would like to modify and
> retrieve foo.var in BOTH QtLauncher and Javascript (synchronization put
> aside first).
>
> There are some test apps in JavaScriptCore/bindings/ that seems to do what
> I wanted.
> But I'm again confused what are the different between C-binding in
> JavaScriptCore/bindings/c and those code in JavaScriptCore/bindings/.
> JavaScriptCore/bindings/NP_jsobject.h seems to be yet another API.
>
> Then I noticed WebCore also provide some binding in WebCore/bindings/js.
> How is it different from that in JavaScriptCore/bindings?
>
> Which binding should I use that would fit the architecture best?
> Must I understand JavaScriptCore/API in order to add the object? What is
> the life cycle of the Javascript objects?
>
> I can hardly find any information concering the implementation of
> JavaScriptCore, could someone giva me a pointer?
> (A "JavaScriptCore" search in the list yields too little info while
> "JavaScript" yeilds too much.)
>
> Thanks a lot,
> LEE
>
>
> ------------------------------
>  This message (including any attachments) is for the named addressee(s)'s
> use only. It may contain sensitive, confidential, private proprietary or
> legally privileged information intended for a specific individual and
> purpose, and is protected by law. If you are not the intended recipient,
> please immediately delete it and all copies of it from your system, destroy
> any hard copies of it and notify the sender. Any use, disclosure, copying,
> or distribution of this message and/or any attachments is strictly
> prohibited.
> ------------------------------
>
>
>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo/webkit-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.webkit.org/pipermail/webkit-dev/attachments/20080404/0c9590d6/attachment-0001.html


More information about the webkit-dev mailing list