【发布时间】:2019-12-24 02:54:32
【问题描述】:
我的工作需要一个旧的 Node.js 本机插件,但由于许多本机 API 已弃用,因此不再适用于 Node.js 12 及更高版本。在几十个错误中,除了一个与初始化和调用回调函数有关的错误外,我已经修复了所有错误。新的 API 需要 4 个参数,而旧的 API 需要 3 个。这是损坏的代码:
void node_mpg123_feed_after (uv_work_t *req) {
Nan::HandleScope scope;
feed_req *r = (feed_req *)req->data;
Local<Value> argv[1];
argv[0] = Nan::New<Integer>(r->rtn);
Nan::TryCatch try_catch;
Nan::New(r->callback)->Call(Nan::GetCurrentContext()->Global(), 1, argv); //Compilation error in this line
// cleanup
r->callback.Reset();
delete r;
if (try_catch.HasCaught()) {
FatalException(try_catch);
}
}
具体来说,note the new API 使用 4 个参数,contrast it with the old one 只需要三个参数。我不知道要输入什么参数,因为互联网上基本上没有新 API 的教程,而且互联网上充斥着旧 API 的示例。
谁能指出我正确的方向?我收到的确切错误消息是error C2660: 'v8::Function::Call': function does not take 3 arguments,在我用上面的注释标记的行中。
【问题讨论】:
-
哎呀,将 0.8 API 移植到当前版本。我已经很长时间没有深入研究了,但也许这里有一些有用的掘金可能会有所帮助? stackoverflow.com/questions/45900692/…
-
它不一定是 0.8 API,但它与节点 10 之前工作的签名匹配。感谢您的链接,我会检查一下。
标签: c++ node.js node-native-addon