node-addon-examples
node-addon-examples copied to clipboard
Call Local<Function> with ObjectWrap as argument
I cannot find any information on how to create an ObjectWrap and pass it as an argument to a Local<Function>. I have a persistent callback registered and need to call it with a new instance of an ObjectWrap. I could do this by calling the (JS) constructor and pass it (JS) arguments which returns a new instance, but I want to avoid this round tripping.
Basically: how to create an ObjectWrap and get a Local<Value> out of it so that I can pass it as an argument to a JS function?
You can get a v8::Local<v8::Object> from an ObjectWrap by calling its Handle() method.
Hi.
Thanks for the interest. The problem is (was) that I had no Object in the first place. I wanted to create an object. I solved this by using the ObjectTemplate and a HandleScope (I have now gone from using ObjectWrap to using pure V8 calls).