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

[v10.x] n-api: mark version 5 N-APIs as stable #29458

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 @@ -1475,8 +1475,6 @@ added: REPLACEME
napiVersion: 4
-->

> Stability: 1 - Experimental

```C
napi_status napi_create_date(napi_env env,
double time,
Expand Down Expand Up @@ -2120,8 +2118,6 @@ added: REPLACEME
napiVersion: 4
-->

> Stability: 1 - Experimental

```C
napi_status napi_get_date_value(napi_env env,
napi_value value,
Expand Down Expand Up @@ -2729,8 +2725,6 @@ added: REPLACEME
napiVersion: 4
-->

> Stability: 1 - Experimental

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

### napi_add_finalizer

> Stability: 1 - Experimental

<!-- YAML
added: v8.0.0
napiVersion: 1
Expand Down
22 changes: 14 additions & 8 deletions src/node_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define NAPI_VERSION 2147483647
#else
// The baseline version for N-API
#define NAPI_VERSION 4
#define NAPI_VERSION 5
#endif
#endif

Expand Down Expand Up @@ -674,7 +674,7 @@ napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func);

#endif // NAPI_VERSION >= 4

#ifdef NAPI_EXPERIMENTAL
#if NAPI_VERSION >= 5

// Dates
NAPI_EXTERN napi_status napi_create_date(napi_env env,
Expand All @@ -689,6 +689,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 @@ -714,12 +726,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);
#endif // NAPI_EXPERIMENTAL

EXTERN_C_END
Expand Down
2 changes: 1 addition & 1 deletion src/node_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,6 @@
#define NODE_MODULE_VERSION 64

// the NAPI_VERSION provided by this version of the runtime
#define NAPI_VERSION 4
#define NAPI_VERSION 5

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

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

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

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

const [ major, minor, patch, release ] = test_general.testGetNodeVersion();
assert.strictEqual(process.version.split('-')[0],
Expand Down
1 change: 0 additions & 1 deletion test/addons-napi/test_general/test_general.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define NAPI_EXPERIMENTAL
#include <node_api.h>
#include <stdlib.h>
#include "../common.h"
Expand Down