From e1e2c2d4fa0a520bdd41b714d7792ac1a788e78c 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. 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/node_api.h | 6 ++-- src/node_api_types.h | 4 +-- src/node_version.h | 5 +-- test/addons-napi/test_bigint/test_bigint.c | 2 -- test/addons-napi/test_general/test.js | 2 +- .../test_instance_data/test_instance_data.c | 1 - test/addons-napi/test_object/test_object.c | 1 - 8 files changed, 21 insertions(+), 32 deletions(-) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 383b70625e0396..f00111faa3b835 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -189,6 +189,7 @@ tied to the life cycle of the Agent. ### napi_set_instance_data ```C @@ -216,6 +217,7 @@ by the previous call, it will not be called. ### napi_get_instance_data ```C @@ -1375,10 +1377,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, @@ -1397,10 +1398,9 @@ of the objects's prototype chain as well. #### napi_key_filter -> Stability: 1 - Experimental - ```C typedef enum { napi_key_all_properties = 0, @@ -1417,10 +1417,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, @@ -1940,10 +1939,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, @@ -1961,10 +1959,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, @@ -1982,10 +1979,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, @@ -2319,10 +2315,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, @@ -2347,10 +2342,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, @@ -2375,10 +2369,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, @@ -3189,10 +3182,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/node_api.h b/src/node_api.h index 0bf2e2a912f562..4b881027494591 100644 --- a/src/node_api.h +++ b/src/node_api.h @@ -10,7 +10,7 @@ #define NAPI_VERSION 2147483647 #else // The baseline version for N-API -#define NAPI_VERSION 5 +#define NAPI_VERSION 6 #endif #endif @@ -699,7 +699,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, @@ -745,7 +745,7 @@ napi_get_all_property_names(napi_env env, napi_key_conversion key_conversion, napi_value* result); -#endif // NAPI_EXPERIMENTAL +#endif // NAPI_VERSION >= 6 EXTERN_C_END diff --git a/src/node_api_types.h b/src/node_api_types.h index 9f89710d92901b..55158fa412ea4e 100644 --- a/src/node_api_types.h +++ b/src/node_api_types.h @@ -147,7 +147,7 @@ typedef struct { const char* release; } napi_node_version; -#ifdef NAPI_EXPERIMENTAL +#if NAPI_VERSION >= 6 typedef enum { napi_key_include_prototypes, napi_key_own_only @@ -166,6 +166,6 @@ typedef enum { napi_key_keep_numbers, napi_key_numbers_to_strings } napi_key_conversion; -#endif +#endif // NAPI_VERSION >= 6 #endif // SRC_NODE_API_TYPES_H_ diff --git a/src/node_version.h b/src/node_version.h index 793d07592f760a..cb310f216f9c96 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -113,7 +113,8 @@ */ #define NODE_MODULE_VERSION 64 -// the NAPI_VERSION provided by this version of the runtime -#define NAPI_VERSION 5 +// The NAPI_VERSION provided by this version of the runtime. This is the version +// which the Node binary being built supports. +#define NAPI_VERSION 6 #endif // SRC_NODE_VERSION_H_ diff --git a/test/addons-napi/test_bigint/test_bigint.c b/test/addons-napi/test_bigint/test_bigint.c index b1e6c359db6add..b7c887fa33eebf 100644 --- a/test/addons-napi/test_bigint/test_bigint.c +++ b/test/addons-napi/test_bigint/test_bigint.c @@ -1,5 +1,3 @@ -#define NAPI_EXPERIMENTAL - #include #include #include diff --git a/test/addons-napi/test_general/test.js b/test/addons-napi/test_general/test.js index 3ed1f5199dd0c6..1e0a98f48d320b 100644 --- a/test/addons-napi/test_general/test.js +++ b/test/addons-napi/test_general/test.js @@ -34,7 +34,7 @@ assert.notStrictEqual(test_general.testGetPrototype(baseObject), // test version management functions // expected version is currently 4 -assert.strictEqual(test_general.testGetVersion(), 5); +assert.strictEqual(test_general.testGetVersion(), 6); const [ major, minor, patch, release ] = test_general.testGetNodeVersion(); assert.strictEqual(process.version.split('-')[0], diff --git a/test/addons-napi/test_instance_data/test_instance_data.c b/test/addons-napi/test_instance_data/test_instance_data.c index edf564080611c6..55e0deba54b253 100644 --- a/test/addons-napi/test_instance_data/test_instance_data.c +++ b/test/addons-napi/test_instance_data/test_instance_data.c @@ -1,7 +1,6 @@ #include #include #include -#define NAPI_EXPERIMENTAL #include #include "../common.h" diff --git a/test/addons-napi/test_object/test_object.c b/test/addons-napi/test_object/test_object.c index dbf840cb09c19e..90fa69dd6a119b 100644 --- a/test/addons-napi/test_object/test_object.c +++ b/test/addons-napi/test_object/test_object.c @@ -1,4 +1,3 @@ -#define NAPI_EXPERIMENTAL #include #include "../common.h" #include