That worked. Thanks

On Monday, July 1, 2013 12:22:26 PM UTC+1, Ben Noordhuis wrote:
>
> On Mon, Jul 1, 2013 at 1:01 PM, Luís Miranda <[email protected]<javascript:>> 
> wrote: 
> > Hi. 
> > 
> > Does anyone know how to access, from javascript, to the data members of 
> a 
> > wrapped object? 
> > 
> > I was checking the 'Factory of wrapped objects' in the node.js addons 
> > (http://nodejs.org/api/addons.html#addons_factory_of_wrapped_objects), 
> and i 
> > want to able to do something like this: 
> > 
> > var createObject = require('./build/Release/addon'); 
> > 
> > var obj = createObject(10); 
> > console.log( obj.plusOne() ); // 11 
> > console.log( obj.plusOne() ); // 12 
> > console.log( obj.plusOne() ); // 13 
> > 
> > var obj2 = createObject(20); 
> > console.log( obj2.plusOne() ); // 21 
> > console.log( obj2.plusOne() ); // 22 
> > console.log( obj2.plusOne() ); // 23 
> > 
> > console.log(counter_); // How should i do this??? 
> > 
> > 
> > Does anyone knows how to do this? 
> > 
> > I'm trying to use an accessor, but without success... maybe i'm doing 
> > something wrong. 
> > 
> > Thanks in advance! 
>
> Something like this: 
>
>   Local<FunctionTemplate> t = FunctionTemplate::New(MyConstructor); 
>   t->InstanceTemplate()->SetAccessor(String::New("counter"), 
> CounterGetter); 
>
> CounterGetter looks like this: 
>
>   Handle<Value> CounterGetter(Local<String> name, const AccessorInfo& 
> info) { 
>     // Do whatever. 
>   } 
>
> SetAccessor() lets you define a setter and property attributes as 
> well, see v8.h for more details.  You can also pass it a data handle 
> that you can then retrieve with info.Data() in your getter/setter. 
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to