Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

n-api: mark version 5 N-APIs as stable #29401

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1758,8 +1758,6 @@ structure, in most cases using a `TypedArray` will suffice.
added: v11.11.0
-->

> Stability: 1 - Experimental

```C
napi_status napi_create_date(napi_env env,
double time,
Expand Down Expand Up @@ -2420,8 +2418,6 @@ This API returns various properties of a `DataView`.
added: v11.11.0
-->

> Stability: 1 - Experimental

```C
napi_status napi_get_date_value(napi_env env,
napi_value value,
Expand Down Expand Up @@ -3048,8 +3044,6 @@ This API checks if the `Object` passed in is a buffer.
added: v11.11.0
-->

> Stability: 1 - Experimental

```C
napi_status napi_is_date(napi_env env, napi_value value, bool* result)
```
Expand Down Expand Up @@ -4186,8 +4180,6 @@ JavaScript object becomes garbage-collected.

### napi_add_finalizer

> Stability: 1 - Experimental

<!-- YAML
added: v8.0.0
-->
Expand Down
2 changes: 1 addition & 1 deletion doc/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ An example of the possible output looks like:
variables:
{
host_arch: 'x64',
napi_build_version: 4,
napi_build_version: 5,
node_install_npm: 'true',
node_prefix: '',
node_shared_cares: 'false',
Expand Down
22 changes: 14 additions & 8 deletions src/js_native_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// functions available in a new version of N-API that is not yet ported in all
// LTS versions, they can set NAPI_VERSION knowing that they have specifically
// depended on that version.
#define NAPI_VERSION 4
#define NAPI_VERSION 5
#endif
#endif

Expand Down Expand Up @@ -453,7 +453,7 @@ NAPI_EXTERN napi_status napi_adjust_external_memory(napi_env env,
int64_t change_in_bytes,
int64_t* adjusted_value);

#ifdef NAPI_EXPERIMENTAL
#if NAPI_VERSION >= 5

// Dates
NAPI_EXTERN napi_status napi_create_date(napi_env env,
Expand All @@ -468,6 +468,18 @@ NAPI_EXTERN napi_status napi_get_date_value(napi_env env,
napi_value value,
double* result);

// Add finalizer for pointer
NAPI_EXTERN napi_status napi_add_finalizer(napi_env env,
napi_value js_object,
void* native_object,
napi_finalize finalize_cb,
void* finalize_hint,
napi_ref* result);

#endif // NAPI_VERSION >= 5

#ifdef NAPI_EXPERIMENTAL

// BigInt
NAPI_EXTERN napi_status napi_create_bigint_int64(napi_env env,
int64_t value,
Expand All @@ -493,12 +505,6 @@ NAPI_EXTERN napi_status napi_get_value_bigint_words(napi_env env,
int* sign_bit,
size_t* word_count,
uint64_t* words);
NAPI_EXTERN napi_status napi_add_finalizer(napi_env env,
napi_value js_object,
void* native_object,
napi_finalize finalize_cb,
void* finalize_hint,
napi_ref* result);

// Instance data
NAPI_EXTERN napi_status napi_set_instance_data(napi_env env,
Expand Down
2 changes: 1 addition & 1 deletion src/node_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@

// The NAPI_VERSION provided by this version of the runtime. This is the version
// which the Node binary being built supports.
#define NAPI_VERSION 4
#define NAPI_VERSION 5

#endif // SRC_NODE_VERSION_H_
2 changes: 0 additions & 2 deletions test/js-native-api/test_date/test_date.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#define NAPI_EXPERIMENTAL

#include <js_native_api.h>
#include "../common.h"

Expand Down
2 changes: 1 addition & 1 deletion test/js-native-api/test_general/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ assert.notStrictEqual(test_general.testGetPrototype(baseObject),
test_general.testGetPrototype(extendedObject));

// Test version management functions. The expected version is currently 4.
assert.strictEqual(test_general.testGetVersion(), 4);
assert.strictEqual(test_general.testGetVersion(), 5);

[
123,
Expand Down
1 change: 0 additions & 1 deletion test/js-native-api/test_general/test_general.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define NAPI_EXPERIMENTAL
#include <js_native_api.h>
#include <stdlib.h>
#include "../common.h"
Expand Down
1 change: 0 additions & 1 deletion test/node-api/test_make_callback/binding.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define NAPI_EXPERIMENTAL // napi_add_finalizer
#include <node_api.h>
#include <assert.h>
#include "../../js-native-api/common.h"
Expand Down