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:
authorAlba Mendez <me@alba.sh>2020-12-26 23:15:28 +0300
committerGabriel Schulhof <gabriel.schulhof@intel.com>2021-01-06 00:51:18 +0300
commita3fcf24a6c2f1c3089eb11b585143a70126046ab (patch)
tree6981fadde17534d5b6d1e054ea79e830e5ca7345 /doc/api/n-api.md
parent15164cebcebfcad9822d3f065234a8c1511776a4 (diff)
doc: clarify that N-API addons are context-aware
The docs on N-API say that NAPI_MODULE_INIT must be used for the addon to be context-aware. That seems to be wrong, i.e. all N-API addons are context-aware(?) PR-URL: https://github.com/nodejs/node/pull/36640 Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
Diffstat (limited to 'doc/api/n-api.md')
-rw-r--r--doc/api/n-api.md14
1 files changed, 5 insertions, 9 deletions
diff --git a/doc/api/n-api.md b/doc/api/n-api.md
index e40d2cc9ac2..15ed0837968 100644
--- a/doc/api/n-api.md
+++ b/doc/api/n-api.md
@@ -1853,8 +1853,8 @@ napi_value Init(napi_env env, napi_value exports) {
}
```
-If the module will be loaded multiple times during the lifetime of the Node.js
-process, use the `NAPI_MODULE_INIT` macro to initialize the module:
+You can also use the `NAPI_MODULE_INIT` macro, which acts as a shorthand
+for `NAPI_MODULE` and defining an `Init` function:
```c
NAPI_MODULE_INIT() {
@@ -1871,13 +1871,9 @@ NAPI_MODULE_INIT() {
}
```
-This macro includes `NAPI_MODULE`, and declares an `Init` function with a
-special name and with visibility beyond the addon. This will allow Node.js to
-initialize the module even if it is loaded multiple times.
-
-There are a few design considerations when declaring a module that may be loaded
-multiple times. The documentation of [context-aware addons][] provides more
-details.
+All N-API addons are context-aware, meaning they may be loaded multiple
+times. There are a few design considerations when declaring such a module.
+The documentation on [context-aware addons][] provides more details.
The variables `env` and `exports` will be available inside the function body
following the macro invocation.