|
(I tried to send this a few hours ago, but the firewall of the building I was in apparently blocks SMTP) You'd do something somewhat like this: //somewhere: Persistent<Function> callback; //in C++ function if (args.Length() > 0) { callback = Persistent<Function>::New(Handle<Function>::Cast(args[0])); } //where you use the callback if (!callback.IsEmpty()) { Handle<Value> arguments[1]; arguments[0] = String::New("Hello, World!"); callback->Call(context->Global(), 1, arguments); } That's the gist, but it's nowhere near complete. Note: using a Persistent handle allows the function to remain in memory even if _javascript_ no longer references it, by maintaining a reference in C++. For more information on Function::Call, look in v8.h (which basically contains all of the v8 documentation). Alex On Mar 3, 2009, at 8:48 AM, p1r0 wrote: Hi! I want to create a callback from C++ to _javascript_. Like this, I want to be able to do something in C++ and let _javascript_ know when it's done by calling a funcion. Is there a way to do that? Thanks!
|
- [v8-users] Trigger JavaScript function from C++ p1r0
- [v8-users] Re: Trigger JavaScript function from C++ Stephan Beal
- [v8-users] Re: Trigger JavaScript function from C++ Alex Iskander
