thank you all!

this is great help.

I'm sorry I didn't take a look at v8.h before posting, will do that
now

On Mar 3, 4:36 pm, Alex Iskander <[email protected]> wrote:
> (I tried to send this a few hours ago, but the firewall of the building I was 
> in apparently blocks SMTP)
>
>
>
> It's possible, and generally pretty simple. Assume you have a function in C++ 
> which would be called from JavaScript, and which should take a JavaScript 
> function as one of the arguments.
> 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 
> JavaScriptknow when it's done by callinga funcion.Is there a way to do 
> that?Thanks!
--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to