Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
n-api: define release 6
Mark all N-APIs that have been added since version 5 as stable.

Backport-PR-URL: #32482
PR-URL: #32058
Fixes: nodejs/abi-stable-node#393
Co-Authored-By: legendecas <legendecas@gmail.com>
Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
  • Loading branch information
2 people authored and targos committed Apr 28, 2020
1 parent 02ec03c commit e22d853
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 38 deletions.
32 changes: 12 additions & 20 deletions doc/api/n-api.md
Expand Up @@ -374,6 +374,7 @@ tied to the life cycle of the Agent.
### napi_set_instance_data
<!-- YAML
added: v12.8.0
napiVersion: 6
-->

```C
Expand Down Expand Up @@ -401,6 +402,7 @@ by the previous call, it will not be called.
### napi_get_instance_data
<!-- YAML
added: v12.8.0
napiVersion: 6
-->
```C
Expand Down Expand Up @@ -1662,10 +1664,9 @@ the `napi_value` in question is of the JavaScript type expected by the API.
#### napi_key_collection_mode
<!-- YAML
added: REPLACEME
napiVersion: 6
-->

> Stability: 1 - Experimental
```C
typedef enum {
napi_key_include_prototypes,
Expand All @@ -1684,10 +1685,9 @@ of the objects's prototype chain as well.
#### napi_key_filter
<!-- YAML
added: REPLACEME
napiVersion: 6
-->

> Stability: 1 - Experimental
```C
typedef enum {
napi_key_all_properties = 0,
Expand All @@ -1704,10 +1704,9 @@ Property filter bits. They can be or'ed to build a composite filter.
#### napi_key_conversion
<!-- YAML
added: REPLACEME
napiVersion: 6
-->

> Stability: 1 - Experimental
```C
typedef enum {
napi_key_keep_numbers,
Expand Down Expand Up @@ -2261,10 +2260,9 @@ The JavaScript `Number` type is described in
#### napi_create_bigint_int64
<!-- YAML
added: v10.7.0
napiVersion: 6
-->
> Stability: 1 - Experimental
```C
napi_status napi_create_bigint_int64(napi_env env,
int64_t value,
Expand All @@ -2282,10 +2280,9 @@ This API converts the C `int64_t` type to the JavaScript `BigInt` type.
#### napi_create_bigint_uint64
<!-- YAML
added: v10.7.0
napiVersion: 6
-->

> Stability: 1 - Experimental
```C
napi_status napi_create_bigint_uint64(napi_env env,
uint64_t value,
Expand All @@ -2303,10 +2300,9 @@ This API converts the C `uint64_t` type to the JavaScript `BigInt` type.
#### napi_create_bigint_words
<!-- YAML
added: v10.7.0
napiVersion: 6
-->
> Stability: 1 - Experimental
```C
napi_status napi_create_bigint_words(napi_env env,
int sign_bit,
Expand Down Expand Up @@ -2656,10 +2652,9 @@ This API returns the C double primitive equivalent of the given JavaScript
#### napi_get_value_bigint_int64
<!-- YAML
added: v10.7.0
napiVersion: 6
-->

> Stability: 1 - Experimental
```C
napi_status napi_get_value_bigint_int64(napi_env env,
napi_value value,
Expand All @@ -2683,10 +2678,9 @@ This API returns the C `int64_t` primitive equivalent of the given JavaScript
#### napi_get_value_bigint_uint64
<!-- YAML
added: v10.7.0
napiVersion: 6
-->
> Stability: 1 - Experimental
```C
napi_status napi_get_value_bigint_uint64(napi_env env,
napi_value value,
Expand All @@ -2710,10 +2704,9 @@ This API returns the C `uint64_t` primitive equivalent of the given JavaScript
#### napi_get_value_bigint_words
<!-- YAML
added: v10.7.0
napiVersion: 6
-->

> Stability: 1 - Experimental
```C
napi_status napi_get_value_bigint_words(napi_env env,
napi_value value,
Expand Down Expand Up @@ -3598,10 +3591,9 @@ included.
#### napi_get_all_property_names
<!-- YAML
added: REPLACEME
napiVersion: 6
-->
> Stability: 1 - Experimental
```C
napi_get_all_property_names(napi_env env,
napi_value object,
Expand Down
9 changes: 6 additions & 3 deletions src/js_native_api.h
Expand Up @@ -4,7 +4,6 @@
// This file needs to be compatible with C compilers.
#include <stddef.h> // NOLINT(modernize-deprecated-headers)
#include <stdbool.h> // NOLINT(modernize-deprecated-headers)
#include "js_native_api_types.h"

// Use INT_MAX, this should only be consumed by the pre-processor anyway.
#define NAPI_VERSION_EXPERIMENTAL 2147483647
Expand All @@ -18,10 +17,12 @@
// 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 5
#define NAPI_VERSION 6
#endif
#endif

#include "js_native_api_types.h"

// If you need __declspec(dllimport), either include <node_api.h> instead, or
// define NAPI_EXTERN as __declspec(dllimport) on the compiler's command line.
#ifndef NAPI_EXTERN
Expand Down Expand Up @@ -478,7 +479,7 @@ NAPI_EXTERN napi_status napi_add_finalizer(napi_env env,

#endif // NAPI_VERSION >= 5

#ifdef NAPI_EXPERIMENTAL
#if NAPI_VERSION >= 6

// BigInt
NAPI_EXTERN napi_status napi_create_bigint_int64(napi_env env,
Expand Down Expand Up @@ -523,7 +524,9 @@ NAPI_EXTERN napi_status napi_set_instance_data(napi_env env,

NAPI_EXTERN napi_status napi_get_instance_data(napi_env env,
void** data);
#endif // NAPI_VERSION >= 6

#ifdef NAPI_EXPERIMENTAL
// ArrayBuffer detaching
NAPI_EXTERN napi_status napi_detach_arraybuffer(napi_env env,
napi_value arraybuffer);
Expand Down
4 changes: 2 additions & 2 deletions src/js_native_api_types.h
Expand Up @@ -115,7 +115,7 @@ typedef struct {
napi_status error_code;
} napi_extended_error_info;

#ifdef NAPI_EXPERIMENTAL
#if NAPI_VERSION >= 6
typedef enum {
napi_key_include_prototypes,
napi_key_own_only
Expand All @@ -134,6 +134,6 @@ typedef enum {
napi_key_keep_numbers,
napi_key_numbers_to_strings
} napi_key_conversion;
#endif
#endif // NAPI_VERSION >= 6

#endif // SRC_JS_NATIVE_API_TYPES_H_
2 changes: 1 addition & 1 deletion src/node_version.h
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 5
#define NAPI_VERSION 6

#endif // SRC_NODE_VERSION_H_
2 changes: 0 additions & 2 deletions test/js-native-api/test_bigint/test_bigint.c
@@ -1,5 +1,3 @@
#define NAPI_EXPERIMENTAL

#include <inttypes.h>
#include <stdio.h>
#include <js_native_api.h>
Expand Down
2 changes: 1 addition & 1 deletion test/js-native-api/test_general/test.js
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(), 5);
assert.strictEqual(test_general.testGetVersion(), 6);

[
123,
Expand Down
1 change: 0 additions & 1 deletion test/js-native-api/test_instance_data/test_instance_data.c
@@ -1,6 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#define NAPI_EXPERIMENTAL
#include <js_native_api.h>
#include "../common.h"

Expand Down
1 change: 0 additions & 1 deletion test/js-native-api/test_object/test_null.c
@@ -1,4 +1,3 @@
#define NAPI_EXPERIMENTAL
#include <js_native_api.h>

#include "../common.h"
Expand Down
2 changes: 0 additions & 2 deletions test/js-native-api/test_object/test_object.c
@@ -1,5 +1,3 @@
#define NAPI_EXPERIMENTAL

#include <js_native_api.h>
#include "../common.h"
#include <string.h>
Expand Down
1 change: 0 additions & 1 deletion test/node-api/test_general/test_general.c
@@ -1,4 +1,3 @@
#define NAPI_EXPERIMENTAL
#include <node_api.h>
#include <stdlib.h>
#include "../../js-native-api/common.h"
Expand Down
1 change: 0 additions & 1 deletion test/node-api/test_instance_data/addon.c
@@ -1,6 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#define NAPI_EXPERIMENTAL
#include <node_api.h>

static void addon_free(napi_env env, void* data, void* hint) {
Expand Down
1 change: 0 additions & 1 deletion test/node-api/test_instance_data/test_instance_data.c
@@ -1,6 +1,5 @@
#include <stdlib.h>
#include <uv.h>
#define NAPI_EXPERIMENTAL
#include <node_api.h>
#include "../../js-native-api/common.h"

Expand Down
1 change: 0 additions & 1 deletion test/node-api/test_instance_data/test_ref_then_set.c
@@ -1,6 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#define NAPI_EXPERIMENTAL
#include <node_api.h>

napi_value addon_new(napi_env env, napi_value exports, bool ref_first);
Expand Down
1 change: 0 additions & 1 deletion test/node-api/test_instance_data/test_set_then_ref.c
@@ -1,6 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#define NAPI_EXPERIMENTAL
#include <node_api.h>

napi_value addon_new(napi_env env, napi_value exports, bool ref_first);
Expand Down

0 comments on commit e22d853

Please sign in to comment.