[webkit-help] Exposing C++ objects to JavaScript through JavaScriptCore

newbie newbie.programming at yahoo.com
Fri Dec 21 04:27:56 PST 2012


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








More information about the webkit-help mailing list