add create env api

Signed-off-by: zhuhan <zhuhan10@huawei.com>
Change-Id: I5de6fd308000650f60cb872287726a5beacfe52d
This commit is contained in:
zhuhan 2024-03-06 10:34:57 +08:00
parent 05fb411f3e
commit 5f28296047
3 changed files with 30 additions and 1 deletions

View File

@ -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"
}
]

View File

@ -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
}

View File

@ -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()'