Calling Javascript function from a C++ callback in V8
问题 I'm trying to call a registered JS function when a c++ callback is called, but I'm getting a segfault for what I assume is a scoping issue. Handle<Value> addEventListener( const Arguments& args ) { HandleScope scope; if (!args[0]->IsFunction()) { return ThrowException(Exception::TypeError(String::New("Wrong arguments"))); } Persistent<Function> fn = Persistent<Function>::New(Handle<Function>::Cast(args[0])); Local<Number> num = Number::New(registerListener(&callback, &fn)); scope.Close(num);