mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
doc: add blurb about implications of ABI stability
Mention that ABI stability can be achieved only by linking to ABI- stable parts of Node.js and to other libraries which are ABI-stable. PR-URL: https://github.com/nodejs/node/pull/22508 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
This commit is contained in:
1 parent
c8cd90df6f
commit
032d88695c
2 files changed
+34
No files matched your search
@@ -367,6 +367,10 @@ set of APIs that are used by the native code. Instead of using the V8
|
||||
or [Native Abstractions for Node.js][] APIs, the functions available
|
||||
in the N-API are used.
|
||||
|
||||
Creating and maintaining an addon that benefits from the ABI stability
|
||||
provided by N-API carries with it certain
|
||||
[implementation considerations](n-api.html#n_api_implications_of_abi_stability).
|
||||
|
||||
To use N-API in the above "Hello world" example, replace the content of
|
||||
`hello.cc` with the following. All other instructions remain the same.
|
||||
|
||||
|
||||
@@ -42,6 +42,36 @@ for the N-API C based functions exported by Node.js. These wrappers are not
|
||||
part of N-API, nor will they be maintained as part of Node.js. One such
|
||||
example is: [node-addon-api](https://github.com/nodejs/node-addon-api).
|
||||
|
||||
## Implications of ABI Stability
|
||||
|
||||
Although N-API provides an ABI stability guarantee, other parts of Node.js do
|
||||
not, and any external libraries used from the addon may not. In particular,
|
||||
none of the following APIs provide an ABI stability guarantee across major
|
||||
versions:
|
||||
* the Node.js C++ APIs available via any of
|
||||
```C++
|
||||
#include <node.h>
|
||||
#include <node_buffer.h>
|
||||
#include <node_version.h>
|
||||
#include <node_object_wrap.h>
|
||||
```
|
||||
* the libuv APIs which are also included with Node.js and available via
|
||||
```C++
|
||||
#include <uv.h>
|
||||
```
|
||||
* the V8 API available via
|
||||
```C++
|
||||
#include <v8.h>
|
||||
```
|
||||
|
||||
Thus, for an addon to remain ABI-compatible across Node.js major versions, it
|
||||
must make use exclusively of N-API by restricting itself to using
|
||||
```C
|
||||
#include <node_api.h>
|
||||
```
|
||||
and by checking, for all external libraries that it uses, that the external
|
||||
library makes ABI stability guarantees similar to N-API.
|
||||
|
||||
## Usage
|
||||
|
||||
In order to use the N-API functions, include the file
|
||||
|
||||
Reference in new issue
Block a user