From c61370761ac52ee5f280a96891e30ceba4a29a49 Mon Sep 17 00:00:00 2001 From: shilei Date: Sun, 18 May 2025 21:30:11 +0800 Subject: [PATCH] add multi-context interface Signed-off-by: shilei Change-Id: Id14baf8157f97411148be57d95ba82ee0b51dc9e --- arkui/napi/libnapi.ndk.json | 8 ++++++++ arkui/napi/native_api.h | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/arkui/napi/libnapi.ndk.json b/arkui/napi/libnapi.ndk.json index 04e3cc6d4..7460d98ae 100644 --- a/arkui/napi/libnapi.ndk.json +++ b/arkui/napi/libnapi.ndk.json @@ -242,5 +242,13 @@ { "first_introduced": "18", "name": "napi_wrap_enhance" + }, + { + "first_introduced": "20", + "name": "napi_create_ark_context" + }, + { + "first_introduced": "20", + "name": "napi_destroy_ark_context" } ] diff --git a/arkui/napi/native_api.h b/arkui/napi/native_api.h index 788a6df98..ff5d8a52b 100644 --- a/arkui/napi/native_api.h +++ b/arkui/napi/native_api.h @@ -1646,6 +1646,31 @@ NAPI_EXTERN napi_status napi_define_class(napi_env env, * @since 17 */ NAPI_EXTERN void napi_onLoad(); + +/** + * @brief To create a new virtual machine context. + * @param env Current running virtual machine context. + * @param newEnv New generated virtual machine context which is expected to be used later. + * + * @return Returns the function execution status. + * {@link napi_ok } If the function executed successfully.\n + * {@link napi_invalid_arg } If the param env is nullptr.\n + * {@link napi_pending_exception } If have uncaught exception, or exception occurs in execution.\n + * @since 20 + */ +NAPI_EXTERN napi_status napi_create_ark_context(napi_env env, napi_env *newEnv); + +/** + * @brief To destroy a virtual machine context which will not be used again. + * @param env Virtual machine context expected to be destroyed. + * + * @return Returns the function execution status. + * {@link napi_ok } If the function executed successfully.\n + * {@link napi_invalid_arg } If the param env is nullptr.\n + * {@link napi_pending_exception } If have uncaught exception, or exception occurs in execution.\n + * @since 20 + */ +NAPI_EXTERN napi_status napi_destroy_ark_context(napi_env env); #ifdef __cplusplus } #endif -- Gitee