[webkit-help] Exposing C++ objects to JavaScript through JavaScriptCore
Chris Hatko
chatko at gmail.com
Fri Dec 21 06:40:08 PST 2012
Although its mac, this is a useful explanation:
http://parmanoir.com/Taming_JavascriptCore_within_and_without_WebView
On Fri, Dec 21, 2012 at 9:12 AM, newbie <newbie.programming at yahoo.com>wrote:
> newbie <newbie.programming at ...> writes:
>
> >
> >
> > Brent Fulgham <bfulgham at ...> writes:
> >
> > >
> > >
> > > Hi Rippel,
> > >
> > > I wrote an example application under Windows that uses the
> JavaScriptCore
> API
> > to execute arbitrary JavaScript code. (See
> https://github.com/bfulgham/CallJS)
> > >
> > >
> > > It's really not very complicated, and is also illustrated in the
> Inspector
> > code in the WebKit archive. E-mail if you have any problems.
> > >
> > > -BrentSent from my iPad
> > >
> > > On Jun 22, 2012, at 9:41 AM, rippel tippel <rippeltippel <at>
> gmail.com>
> > wrote:
> > >
> > >
> > > Hi,I need to expose some C++ classes/methods to JavaScript
> > usingJavaScriptCore, so that they can be instantiated/called by
> aJavaScript
> > application.I found plenty of documentation and examples regarding v8 and
> > Node.js,but not much about JavaScriptCore API (apart from some old
> orincomplete
> > docs, e.g. [1], [2], and [3]).Can anyone point me to some documentation
> and/or
> > examples, and/oroutline the basic steps for doing it?mKind
> regards,Rippel[1]
> >
>
> http://article.gmane.org/gmane.os.opendarwin.webkit.user/1067/match=javascriptco
> > re[2]
> >
>
> http://developer.apple.com/library/mac/#documentation/Carbon/Reference/WebKit_Ja
> > vaScriptCore_Ref/[3]
> >
>
> http://developer.apple.com/library/mac/#samplecode/JSPong/Introduction/Intro.htm
> > l_______________________________________________webkit-help mailing
> listwebkit-
> > help-
> > L0Ma0HqZfWbjwXJbYFA32Q <at>
> public.gmane.org.orghttp://lists.webkit.org/mailman/listi
> > nfo.cgi/webkit-help
> > >
> > >
> >
> > Hi Brent,
> >
> > I am really a newbie to programming. I know a bit of c++ but have no
> knowledge
> > of JaveScriptCore.
> > I am working on a webkit project where I have to call, the c++ object
> methods
> > from JavascriptCore. This is a linux based port.
> >
> > I looked at the CallJS code but as I said, I am a newbie, I could not
> understand
> > it properly.(Sorry for being a pain.)
> >
> > I tried to build in Visual Studio 10(It converted the project before
> opening
> > it).
> > I am able to build it but not run it. I get the error "This application
> has
> > failed to start as application configurtaion is incorrect".
> >
> > So, I am unable to run it in debugger and what is going on.
> >
> > Also, the thing that I haven't understood is that, is this for calling
> C++
> > objects from JavaScriptcore or for calling Javascripts from C++.( I am
> not
> sure
> > if this makes any sense).
> >
> > My question is suppose, I have a simple c++ class called temp and that
> has a
> > method called doTemp(), then how do I call that method from JS Core.
> >
> > Class Temp
> > {
> > public:
> > Temp();
> > ~Temp();
> >
> > int doTemp(int x, char *y, InsOfSomeClass& z);
> > }
> > Here z is instance of some other class defined in some other file
> >
> > Is it like, we are registering C++ methods in callJsFunction() function
> and
> then
> > they can be called from JS Core when needed?
> >
> > Thanks,
> > newbie
> >
> > _______________________________________________
> > webkit-help mailing list
> > webkit-help <at> lists.webkit.org
> > http://lists.webkit.org/mailman/listinfo/webkit-help
> >
>
>
> Hi,
>
>
> Having dug deeper into it, I found JSBindings.cpp.
> So, now I know CallJS works both ways, basically, we can call JS core code
> from
> C++ and vice-versa.
> But, still I haven't understood how it is being done.
>
> Do, we need to make bindings for every C++ function that we call from JS
> core,
> something like:
>
> static JSValueRef console_setscript(JSContextRef ctx, JSObjectRef
> /*function*/,
> JSObjectRef thisObject, size_t /*argumentCount*/, const JSValueRef[]
> /*arguments*/, JSValueRef* /*exception*/);
>
> What will be the best place to do it?
>
> Is it possible for soemone to explain me the flow, how we are achieving
> this.
> I can see CallJSDlg::callJsFunction() fn. doing some kind of bindings but
> what
> exactly is happening and what is the flow.
>
> Thanks,
> newbie.
>
>
>
> _______________________________________________
> webkit-help mailing list
> webkit-help at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo/webkit-help
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-help/attachments/20121221/d81a12c3/attachment.html>
More information about the webkit-help
mailing list