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: define release 6 #32058

Closed
wants to merge 1 commit into from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -1663,10 +1665,9 @@ the `napi_value` in question is of the JavaScript type expected by the API.
#### napi_key_collection_mode
<!-- YAML
added: v13.7.0
napiVersion: 6
-->

> Stability: 1 - Experimental

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

> Stability: 1 - Experimental

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

> Stability: 1 - Experimental

```C
typedef enum {
napi_key_keep_numbers,
Expand Down Expand Up @@ -2262,10 +2261,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 @@ -2283,10 +2281,9 @@ This API converts the C `int64_t` type to the JavaScript `BigInt` type.
#### napi_create_bigint_uint64
<!-- YAML
added: v10.7.0
gabrielschulhof marked this conversation as resolved.
Show resolved Hide resolved
napiVersion: 6
-->

> Stability: 1 - Experimental

```C
napi_status napi_create_bigint_uint64(napi_env env,
uint64_t value,
Expand All @@ -2304,10 +2301,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 @@ -2653,10 +2649,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 @@ -2680,10 +2675,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 @@ -2707,10 +2701,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 @@ -3595,10 +3588,9 @@ included.
#### napi_get_all_property_names
<!-- YAML
added: v13.7.0
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