0
我想使用旧的v8 API更新一个node.js插件。如何将node-addon持久<function>转换为本地<function>?
这里是我的wrapper.cpp
代码:
std::map<int, Persistent<Function> > WrapMdUser::callback_map;
void WrapMdUser::FunCallback(CbRtnField *data) {
std::map<int, Persistent<Function> >::iterator cIt = callback_map.find(data->eFlag);
Local<Number> argv[1] = Nan::New(data->nReason);
cIt->second->Call(Nan::GetCurrentContext()->Global(), 1, argv);
}
如果我理解正确的话,笔者使用的地图Persistent<function>
存储回调中(见callback_map
STD),但是当node-gyp build
,编译器抛出此错误:
wrapper.cpp:331:19: error: base operand of ‘->’ has non-pointer type ‘v8::Persistent<v8::Function>’
cIt->second->Call(Nan::GetCurrentContext()->Global(), 1, argv);
将此代码更新到新的v8 API的最佳方法是什么,以便我可以使用最后一个节点版本运行它?
非常感谢。
很确定这个问题在这里介绍:https://stackoverflow.com/questions/13826803/calling-javascript-function-from-a-c-callback-in-v8/28554065#28554065 –