Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2020-09-22 21:35:48 +0300
committerNode.js GitHub Bot <github-bot@iojs.org>2020-09-26 11:22:47 +0300
commitff38165820da2a9eaddabbce23f3e75aa502900b (patch)
tree61b7c444eecbb96a7dacc4b0460c0e3eee93165a /src/node_api.cc
parentaa99bb47bfbfc0fdf0d0ca4f452b527b02b83d2d (diff)
src: allow N-API addon in `AddLinkedBinding()`
`AddLinkedBinding()` can be used to load old-style Node.js addons, but currently not N-API addons. There’s no good reason not to support N-API addons as well, so add that. PR-URL: https://github.com/nodejs/node/pull/35301 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Zeyu Yang <himself65@outlook.com>
Diffstat (limited to 'src/node_api.cc')
-rw-r--r--src/node_api.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/node_api.cc b/src/node_api.cc
index 93488146d56..12f369a8097 100644
--- a/src/node_api.cc
+++ b/src/node_api.cc
@@ -447,7 +447,7 @@ static void napi_module_register_cb(v8::Local<v8::Object> exports,
v8::Local<v8::Context> context,
void* priv) {
napi_module_register_by_symbol(exports, module, context,
- static_cast<napi_module*>(priv)->nm_register_func);
+ static_cast<const napi_module*>(priv)->nm_register_func);
}
void napi_module_register_by_symbol(v8::Local<v8::Object> exports,
@@ -480,9 +480,9 @@ void napi_module_register_by_symbol(v8::Local<v8::Object> exports,
}
}
-// Registers a NAPI module.
-void napi_module_register(napi_module* mod) {
- node::node_module* nm = new node::node_module {
+namespace node {
+node_module napi_module_to_node_module(const napi_module* mod) {
+ return {
-1,
mod->nm_flags | NM_F_DELETEME,
nullptr,
@@ -490,9 +490,16 @@ void napi_module_register(napi_module* mod) {
nullptr,
napi_module_register_cb,
mod->nm_modname,
- mod, // priv
+ const_cast<napi_module*>(mod), // priv
nullptr,
};
+}
+} // namespace node
+
+// Registers a NAPI module.
+void napi_module_register(napi_module* mod) {
+ node::node_module* nm = new node::node_module(
+ node::napi_module_to_node_module(mod));
node::node_module_register(nm);
}