diff --git a/def/js_native_api.def b/def/js_native_api.def index dc0d9d5..99a5422 100644 --- a/def/js_native_api.def +++ b/def/js_native_api.def @@ -117,4 +117,9 @@ napi_object_seal napi_type_tag_object node_api_create_syntax_error node_api_symbol_for -node_api_throw_syntax_error \ No newline at end of file +node_api_throw_syntax_error +node_api_create_external_string_latin1 +node_api_create_external_string_utf16 +node_api_create_property_key_latin1 +node_api_create_property_key_utf16 +node_api_create_property_key_utf8 \ No newline at end of file diff --git a/def/node_api.def b/def/node_api.def index 81c7d35..1c53ce0 100644 --- a/def/node_api.def +++ b/def/node_api.def @@ -148,4 +148,10 @@ napi_type_tag_object node_api_get_module_file_name node_api_create_syntax_error node_api_symbol_for -node_api_throw_syntax_error \ No newline at end of file +node_api_throw_syntax_error +node_api_create_buffer_from_arraybuffer +node_api_create_external_string_latin1 +node_api_create_external_string_utf16 +node_api_create_property_key_latin1 +node_api_create_property_key_utf16 +node_api_create_property_key_utf8 \ No newline at end of file diff --git a/include/js_native_api.h b/include/js_native_api.h index b4d349e..e1d27a8 100644 --- a/include/js_native_api.h +++ b/include/js_native_api.h @@ -88,7 +88,31 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_create_string_utf16(napi_env env, const char16_t* str, size_t length, napi_value* result); - +#if NAPI_VERSION >= 10 +NAPI_EXTERN napi_status NAPI_CDECL node_api_create_external_string_latin1( + napi_env env, + char* str, + size_t length, + node_api_basic_finalize finalize_callback, + void* finalize_hint, + napi_value* result, + bool* copied); +NAPI_EXTERN napi_status NAPI_CDECL +node_api_create_external_string_utf16(napi_env env, + char16_t* str, + size_t length, + node_api_basic_finalize finalize_callback, + void* finalize_hint, + napi_value* result, + bool* copied); + +NAPI_EXTERN napi_status NAPI_CDECL node_api_create_property_key_latin1( + napi_env env, const char* str, size_t length, napi_value* result); +NAPI_EXTERN napi_status NAPI_CDECL node_api_create_property_key_utf8( + napi_env env, const char* str, size_t length, napi_value* result); +NAPI_EXTERN napi_status NAPI_CDECL node_api_create_property_key_utf16( + napi_env env, const char16_t* str, size_t length, napi_value* result); +#endif // NAPI_VERSION >= 10 NAPI_EXTERN napi_status NAPI_CDECL napi_create_symbol(napi_env env, napi_value description, diff --git a/include/js_native_api_types.h b/include/js_native_api_types.h index 43e7bb7..7853a8d 100644 --- a/include/js_native_api_types.h +++ b/include/js_native_api_types.h @@ -43,14 +43,7 @@ typedef struct napi_env__* napi_env; // basic APIs (unless the user explicitly casts the environment), we achieve // the ability to ensure at compile time that we do not call APIs that affect // the state of the JS engine from a synchronous (basic) finalizer. -#if !defined(NAPI_EXPERIMENTAL) || \ - (defined(NAPI_EXPERIMENTAL) && \ - (defined(NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT) || \ - defined(NODE_API_EXPERIMENTAL_BASIC_ENV_OPT_OUT))) typedef struct napi_env__* node_api_nogc_env; -#else -typedef const struct napi_env__* node_api_nogc_env; -#endif typedef node_api_nogc_env node_api_basic_env; typedef struct napi_value__* napi_value; @@ -147,16 +140,7 @@ typedef void(NAPI_CDECL* napi_finalize)(napi_env env, void* finalize_data, void* finalize_hint); -#if !defined(NAPI_EXPERIMENTAL) || \ - (defined(NAPI_EXPERIMENTAL) && \ - (defined(NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT) || \ - defined(NODE_API_EXPERIMENTAL_BASIC_ENV_OPT_OUT))) typedef napi_finalize node_api_nogc_finalize; -#else -typedef void(NAPI_CDECL* node_api_nogc_finalize)(node_api_nogc_env env, - void* finalize_data, - void* finalize_hint); -#endif typedef node_api_nogc_finalize node_api_basic_finalize; typedef struct { diff --git a/include/node_api.h b/include/node_api.h index 526cdd5..35e5c3e 100644 --- a/include/node_api.h +++ b/include/node_api.h @@ -90,9 +90,6 @@ EXTERN_C_START // Deprecated. Replaced by symbol-based registration defined by NAPI_MODULE // and NAPI_MODULE_INIT macros. -#if defined(__cplusplus) && __cplusplus >= 201402L -[[deprecated]] -#endif NAPI_EXTERN void NAPI_CDECL napi_module_register(napi_module* mod); @@ -135,6 +132,17 @@ napi_create_external_buffer(napi_env env, void* finalize_hint, napi_value* result); #endif // NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED + +#if NAPI_VERSION >= 10 + +NAPI_EXTERN napi_status NAPI_CDECL +node_api_create_buffer_from_arraybuffer(napi_env env, + napi_value arraybuffer, + size_t byte_offset, + size_t byte_length, + napi_value* result); +#endif // NAPI_VERSION >= 10 + NAPI_EXTERN napi_status NAPI_CDECL napi_create_buffer_copy(napi_env env, size_t length, const void* data, diff --git a/symbols.js b/symbols.js index 855526a..3cf6b4e 100644 --- a/symbols.js +++ b/symbols.js @@ -228,6 +228,21 @@ const v9 = { ] } +const v10 = { + js_native_api_symbols: [ + ...v9.js_native_api_symbols, + 'node_api_create_external_string_latin1', + 'node_api_create_external_string_utf16', + 'node_api_create_property_key_latin1', + 'node_api_create_property_key_utf16', + 'node_api_create_property_key_utf8' + ], + node_api_symbols: [ + ...v9.node_api_symbols, + 'node_api_create_buffer_from_arraybuffer' + ] +} + module.exports = { v1, v2, @@ -237,5 +252,6 @@ module.exports = { v6, v7, v8, - v9 + v9, + v10 }