You can call a globally accessible function by doing the following:
Local<Function> fun = Local<Function>::Cast(context->Global()-
>Get(String::New("Name_Of_Function")));
fun->Call(fun, argc, argv); // argc and argv are your standard
arguments to a function
If you want to call a function on an object you could do the
following:
Handle<Function> fun = Handle<Function>::Cast(env->Global()-
>Get(String::New("Name_Of_Function")));
Handle<Object> object = fun->NewInstance(argc, argv); // again argc
and argv are your arguments
Handle<Function> fun_to_call = Handle<Function>::Cast(object-
>Get(String::New("Function_To_Call")));
fun_to_call->Call(object, argc, argv);
The last example assumes that you have a function constructor and you
have defined a function_to_call on that object.
Corey
On Oct 1, 7:40 am, ondras <[EMAIL PROTECTED]> wrote:
> I am also interested in this. Particularly, I would like to call a JS-
> defined function from C++. Is this possible?
>
> On 1 Říj, 15:23, [EMAIL PROTECTED] wrote:
>
> > Is it possible to access objects which are created in Javascript
> > within C++, so that I can use that object in C++?
>
> > Thanks,
> > bg
--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---