From e22d853c5d17d3d2ac813f1b282aae128a089dba Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Mon, 2 Mar 2020 16:53:06 -0800 Subject: [PATCH] n-api: define release 6 Mark all N-APIs that have been added since version 5 as stable. Backport-PR-URL: https://github.com/nodejs/node/pull/32482 PR-URL: https://github.com/nodejs/node/pull/32058 Fixes: https://github.com/nodejs/abi-stable-node/issues/393 Co-Authored-By: legendecas Signed-off-by: Gabriel Schulhof Reviewed-By: Chengzhong Wu Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater Reviewed-By: Michael Dawson --- doc/api/n-api.md | 32 +++++++------------ src/js_native_api.h | 9 ++++-- src/js_native_api_types.h | 4 +-- src/node_version.h | 2 +- test/js-native-api/test_bigint/test_bigint.c | 2 -- test/js-native-api/test_general/test.js | 2 +- .../test_instance_data/test_instance_data.c | 1 - test/js-native-api/test_object/test_null.c | 1 - test/js-native-api/test_object/test_object.c | 2 -- test/node-api/test_general/test_general.c | 1 - test/node-api/test_instance_data/addon.c | 1 - .../test_instance_data/test_instance_data.c | 1 - .../test_instance_data/test_ref_then_set.c | 1 - .../test_instance_data/test_set_then_ref.c | 1 - 14 files changed, 22 insertions(+), 38 deletions(-) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index f3f22157a05d06..4ce76b06c896b4 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -374,6 +374,7 @@ tied to the life cycle of the Agent. ### napi_set_instance_data ```C @@ -401,6 +402,7 @@ by the previous call, it will not be called. ### napi_get_instance_data ```C @@ -1662,10 +1664,9 @@ the `napi_value` in question is of the JavaScript type expected by the API. #### napi_key_collection_mode -> Stability: 1 - Experimental - ```C typedef enum { napi_key_include_prototypes, @@ -1684,10 +1685,9 @@ of the objects's prototype chain as well. #### napi_key_filter -> Stability: 1 - Experimental - ```C typedef enum { napi_key_all_properties = 0, @@ -1704,10 +1704,9 @@ Property filter bits. They can be or'ed to build a composite filter. #### napi_key_conversion -> Stability: 1 - Experimental - ```C typedef enum { napi_key_keep_numbers, @@ -2261,10 +2260,9 @@ The JavaScript `Number` type is described in #### napi_create_bigint_int64 -> Stability: 1 - Experimental - ```C napi_status napi_create_bigint_int64(napi_env env, int64_t value, @@ -2282,10 +2280,9 @@ This API converts the C `int64_t` type to the JavaScript `BigInt` type. #### napi_create_bigint_uint64 -> Stability: 1 - Experimental - ```C napi_status napi_create_bigint_uint64(napi_env env, uint64_t value, @@ -2303,10 +2300,9 @@ This API converts the C `uint64_t` type to the JavaScript `BigInt` type. #### napi_create_bigint_words -> Stability: 1 - Experimental - ```C napi_status napi_create_bigint_words(napi_env env, int sign_bit, @@ -2656,10 +2652,9 @@ This API returns the C double primitive equivalent of the given JavaScript #### napi_get_value_bigint_int64 -> Stability: 1 - Experimental - ```C napi_status napi_get_value_bigint_int64(napi_env env, napi_value value, @@ -2683,10 +2678,9 @@ This API returns the C `int64_t` primitive equivalent of the given JavaScript #### napi_get_value_bigint_uint64 -> Stability: 1 - Experimental - ```C napi_status napi_get_value_bigint_uint64(napi_env env, napi_value value, @@ -2710,10 +2704,9 @@ This API returns the C `uint64_t` primitive equivalent of the given JavaScript #### napi_get_value_bigint_words -> Stability: 1 - Experimental - ```C napi_status napi_get_value_bigint_words(napi_env env, napi_value value, @@ -3598,10 +3591,9 @@ included. #### napi_get_all_property_names -> Stability: 1 - Experimental - ```C napi_get_all_property_names(napi_env env, napi_value object, diff --git a/src/js_native_api.h b/src/js_native_api.h index cb69fde5d1990e..2675da505c2368 100644 --- a/src/js_native_api.h +++ b/src/js_native_api.h @@ -4,7 +4,6 @@ // This file needs to be compatible with C compilers. #include // NOLINT(modernize-deprecated-headers) #include // 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 @@ -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 instead, or // define NAPI_EXTERN as __declspec(dllimport) on the compiler's command line. #ifndef NAPI_EXTERN @@ -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, @@ -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); diff --git a/src/js_native_api_types.h b/src/js_native_api_types.h index ef44dd457dba6d..7a49fc9f719b30 100644 --- a/src/js_native_api_types.h +++ b/src/js_native_api_types.h @@ -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 @@ -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_ diff --git a/src/node_version.h b/src/node_version.h index ab9c0ce0e9b3cb..6ce4f598ac3573 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -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_ diff --git a/test/js-native-api/test_bigint/test_bigint.c b/test/js-native-api/test_bigint/test_bigint.c index 4befc171baa5da..c62a0a6a6c2bbc 100644 --- a/test/js-native-api/test_bigint/test_bigint.c +++ b/test/js-native-api/test_bigint/test_bigint.c @@ -1,5 +1,3 @@ -#define NAPI_EXPERIMENTAL - #include #include #include diff --git a/test/js-native-api/test_general/test.js b/test/js-native-api/test_general/test.js index 9b847f4f339e49..a4b3df5535a365 100644 --- a/test/js-native-api/test_general/test.js +++ b/test/js-native-api/test_general/test.js @@ -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, diff --git a/test/js-native-api/test_instance_data/test_instance_data.c b/test/js-native-api/test_instance_data/test_instance_data.c index a64ebec0c1aba9..5255c3e4a02b94 100644 --- a/test/js-native-api/test_instance_data/test_instance_data.c +++ b/test/js-native-api/test_instance_data/test_instance_data.c @@ -1,6 +1,5 @@ #include #include -#define NAPI_EXPERIMENTAL #include #include "../common.h" diff --git a/test/js-native-api/test_object/test_null.c b/test/js-native-api/test_object/test_null.c index 523217f3c0aad2..b6bf4df31cc918 100644 --- a/test/js-native-api/test_object/test_null.c +++ b/test/js-native-api/test_object/test_null.c @@ -1,4 +1,3 @@ -#define NAPI_EXPERIMENTAL #include #include "../common.h" diff --git a/test/js-native-api/test_object/test_object.c b/test/js-native-api/test_object/test_object.c index 9d9589238d4079..08f619bf7ffc88 100644 --- a/test/js-native-api/test_object/test_object.c +++ b/test/js-native-api/test_object/test_object.c @@ -1,5 +1,3 @@ -#define NAPI_EXPERIMENTAL - #include #include "../common.h" #include diff --git a/test/node-api/test_general/test_general.c b/test/node-api/test_general/test_general.c index 05bccaf5c2cf4f..be805f782be8d5 100644 --- a/test/node-api/test_general/test_general.c +++ b/test/node-api/test_general/test_general.c @@ -1,4 +1,3 @@ -#define NAPI_EXPERIMENTAL #include #include #include "../../js-native-api/common.h" diff --git a/test/node-api/test_instance_data/addon.c b/test/node-api/test_instance_data/addon.c index 928b4dfaf8e11e..7cf27bf28ab7eb 100644 --- a/test/node-api/test_instance_data/addon.c +++ b/test/node-api/test_instance_data/addon.c @@ -1,6 +1,5 @@ #include #include -#define NAPI_EXPERIMENTAL #include static void addon_free(napi_env env, void* data, void* hint) { diff --git a/test/node-api/test_instance_data/test_instance_data.c b/test/node-api/test_instance_data/test_instance_data.c index 1a814e91c0665b..24fd502e836176 100644 --- a/test/node-api/test_instance_data/test_instance_data.c +++ b/test/node-api/test_instance_data/test_instance_data.c @@ -1,6 +1,5 @@ #include #include -#define NAPI_EXPERIMENTAL #include #include "../../js-native-api/common.h" diff --git a/test/node-api/test_instance_data/test_ref_then_set.c b/test/node-api/test_instance_data/test_ref_then_set.c index a0df1e5b9f8a64..10c779d3241e0e 100644 --- a/test/node-api/test_instance_data/test_ref_then_set.c +++ b/test/node-api/test_instance_data/test_ref_then_set.c @@ -1,6 +1,5 @@ #include #include -#define NAPI_EXPERIMENTAL #include napi_value addon_new(napi_env env, napi_value exports, bool ref_first); diff --git a/test/node-api/test_instance_data/test_set_then_ref.c b/test/node-api/test_instance_data/test_set_then_ref.c index 6ebed2d1e86871..9a1b31aeed390b 100644 --- a/test/node-api/test_instance_data/test_set_then_ref.c +++ b/test/node-api/test_instance_data/test_set_then_ref.c @@ -1,6 +1,5 @@ #include #include -#define NAPI_EXPERIMENTAL #include napi_value addon_new(napi_env env, napi_value exports, bool ref_first);