On Mon, Mar 12, 2012 at 03:35, m1k3l <[email protected]> wrote: > Hi, > > I'd like to integrate a C library with node and there is a feature I don't > seem to find a way to implement. Hopefully you can help. > > In this library, in C, one can pass a reference to a variable so it can be > get/set by your code and get/set by the library, something > like: addVar(&aVar). > Later in your code, one can change the value. During the main loop, the > library can query this variable and do some processing with its value. It > may also set the value of this variable so that later in your code, you can > use the new value. > > So my problems are: > 1- to pass a JS variable to this library > 2- to have this library set the value this JS variable > > Any idea, pointer, etc.. to do that?
Look up v8::ObjectTemplate::SetNamedPropertyHandler(). It's basically the C++ counterpart to Object.defineProperty() and obj.__defineGetter__() / obj.__defineSetter__().
