Skip to content

Commit

Permalink
n-api: mark version 5 N-APIs as stable
Browse files Browse the repository at this point in the history
PR-URL: #29401
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
  • Loading branch information
Gabriel Schulhof authored and targos committed Sep 20, 2019
1 parent 2f81d59 commit 50d7c39
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 23 deletions.
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

0 comments on commit 50d7c39

Please sign in to comment.