You do it the same way you get a function handle:

Handle<Object> obj = Handle<Object>::Cast(val); //just like  
Handle<Function>::Cast()
Handle<Value> bazVal = obj->Get(String::New("baz"));
Handle<Function> baz = Handle<Function>::Cast(bazVal);

On May 1, 2009, at 8:26 AM, jimt wrote:

>
> Hi,
>
> I've got another question about accessing JS object instances from C+
> +.
>
> I've got a big pile of JS that does something like this:
>
> var x = makeSomething( );
>
> function makeSomething() {
>    var stuff = {};
>
>    stuff.foo = 1;
>    stuff.bar = 1;
>    stuff.baz = function ( ) { }
>    ...
>
>   return stuff;
> }
>
> So, 'x' is filled with a bunch of fields and functions when
> makeSomething() is called.
>
> What I would like to do, is to be able to get a reference to the 'x'
> object as a Handle<Object>, so that I can directly invoke methods on
> that object from C++ like this (where OBJ is the Handle<Object>
> pointing to 'x':
>
> Handle<Value> fn = OBJ->Get(String::New("baz"));
> Handle<Value> val = Handle<Function>::Cast(fn)->Call(OBJ, 0, 0);
>
> The question I have is how to go about getting the Handle<Object> 'x'.
> I can call makeSomething() directly from C++ and receive a
> Handle<Value>, but I don't know how to get a Handle<Object> from that
> Value. Certainly it's possible, but I'm getting confused....
>
> Thanks again.
>
> jt
> >

Alex Iskander, TPSi






--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to