I would like to implement this functionality

function myFunction1() {
   //do stuff
}

function myFunction2() {
   //do other stuff
}

myAddon.addCallback(myFunction1);
myAddon.addCallback(myFunction2);
myAddon.removeCallback(myFunction1);

In order to do this I need to store these function in a std::set like so

void addCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
   v8::HandleScope scope(args.GetIsolate());
   v8::Local<v8::Function> cb = v8::Local<v8::Function>::Cast(args[0]);
   std::set mySet = this->mySet;
   //now how do I insert a reference to this function into mySet so I can 
retrieve
   //it later
}

void removeCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
   v8::HandleScope scope(args.GetIsolate());
   v8::Local<v8::Function> cb = v8::Local<v8::Function>::Cast(args[0]);
   std::set mySet = this->mySet;
   //now how do I remove the element in this set that refers to this 
function?
}

How does one go about doing this? I don't want to use 
v8::Object::GetIdentityHash() 
because the result is not guaranteed to be unique.

I also can't just store the Local<Function> in the std::set because the 
copy constructor is private and it would also get descoped once 
removeCallback or addCallback return.

Thanks for any help in advance.

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" 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