- Node.js Version:6.9
- OS:linux
- Scope (install, code, runtime, meta, other?):addon
- Module (and version) (if relevant):addon
Like this problem here: [http://stackoverflow.com/questions/40856548/no-matching-function-for-call-to-persistentfunctionnewisolate-localfunct][1] , but when I using the callback function, it alaways coredump.
classtest : publicnode::ObjectWrap
{
public:voidstart();
staticvoidon(const v8::FunctionCallbackInfo<v8::Value>& args);
std::map<string, v8::Persistent<v8::Function> > callback; }//Register callback functionvoidtest::On(const FunctionCallbackInfo<Value>& args)
{
Isolate* isolate = args.GetIsolate();
Local<String> eventName = args[0]->ToString(); Local<Function> cb = Local<Function>::Cast(args[1]); String::Utf8Value eNameUtf8(eventName); callback[*eNameUtf8].Reset(isolate, cb);
} voidtest::start()
{
Isolate* isolate = Isolate::GetCurrent();
for(typeof(callback.begin()) it=callback.begin(); it!=callback.end(); it++)
{ Local<Value> argv[1] = { Local<Value>::New(isolate, String::New(isolate, itr->first)) }; //How to call the registered callback function just now?//will coredump on here
it->second.Call(Null(isolate), 1, argv); }
}
//test.js
var t = require('bindings')('test')
t.on("test1", function(){})
t.on("test2", function(){})
t.start()
Like this problem here: [http://stackoverflow.com/questions/40856548/no-matching-function-for-call-to-persistentfunctionnewisolate-localfunct][1] , but when I using the callback function, it alaways coredump.