From 5f28296047d81774d08ed27aeda14d078bec60e3 Mon Sep 17 00:00:00 2001 From: zhuhan Date: Wed, 6 Mar 2024 10:34:57 +0800 Subject: [PATCH] add create env api Signed-off-by: zhuhan Change-Id: I5de6fd308000650f60cb872287726a5beacfe52d --- arkui/napi/libnapi.ndk.json | 8 ++++++++ arkui/napi/native_api.h | 15 +++++++++++++++ third_party/node/src/js_native_api_types.h | 8 +++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/arkui/napi/libnapi.ndk.json b/arkui/napi/libnapi.ndk.json index f541fdd9a..d9d055527 100644 --- a/arkui/napi/libnapi.ndk.json +++ b/arkui/napi/libnapi.ndk.json @@ -154,5 +154,13 @@ { "first_introduced": "11", "name": "napi_make_callback" + }, + { + "first_introduced": "12", + "name": "napi_create_ark_runtime" + }, + { + "first_introduced": "12", + "name": "napi_destroy_ark_runtime" } ] diff --git a/arkui/napi/native_api.h b/arkui/napi/native_api.h index 6b20b1c6e..6aa257d18 100644 --- a/arkui/napi/native_api.h +++ b/arkui/napi/native_api.h @@ -127,6 +127,21 @@ NAPI_EXTERN napi_status napi_add_finalizer(napi_env env, napi_finalize finalize_cb, void* finalize_hint, napi_ref* result); +/** + * @brief Create the ark runtime. + * + * @param env Indicates the ark runtime environment. + * @since 12 + */ +NAPI_EXTERN napi_status napi_create_ark_runtime(napi_env* env); + +/** + * @brief Destroy the ark runtime. + * + * @param env Indicates the ark runtime environment. + * @since 12 + */ +NAPI_EXTERN napi_status napi_destroy_ark_runtime(napi_env* env); #ifdef __cplusplus } diff --git a/third_party/node/src/js_native_api_types.h b/third_party/node/src/js_native_api_types.h index 6aba06629..74dc6d148 100644 --- a/third_party/node/src/js_native_api_types.h +++ b/third_party/node/src/js_native_api_types.h @@ -92,7 +92,13 @@ typedef enum { napi_date_expected, napi_arraybuffer_expected, napi_detachable_arraybuffer_expected, - napi_would_deadlock // unused + napi_would_deadlock, // unused + // Created too many ark runtime environment, up to 16. + napi_create_ark_runtime_too_many_envs = 22, + // Only one ark runtime environment can be created per thread. + napi_create_ark_runtime_only_one_env_per_thread = 23, + // The ark runtime environment to be destroyed does not exist. + napi_destroy_ark_runtime_env_not_exist = 24 } napi_status; // Note: when adding a new enum value to `napi_status`, please also update // * `const int last_status` in the definition of `napi_get_last_error_info()' -- Gitee