From 74d8a43081ee36d15be2b51982ff9d04fd59edcd Mon Sep 17 00:00:00 2001 From: wangyang2022 Date: Mon, 14 Jul 2025 14:34:09 +0000 Subject: [PATCH] =?UTF-8?q?C-API=20NAPI=E6=8E=A5=E5=8F=A3ANI=E9=80=82?= =?UTF-8?q?=E9=85=8D=20Signed-off-by:=20wangyang2022=20=20Change-Id:=20I0fad9e5c35e2e35fee2b838d59655de29333f95f?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arkui/ace_engine/native/BUILD.gn | 1 + arkui/ace_engine/native/libace.ndk.json | 8 +++ arkui/ace_engine/native/native_node_ani.h | 82 +++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 arkui/ace_engine/native/native_node_ani.h diff --git a/arkui/ace_engine/native/BUILD.gn b/arkui/ace_engine/native/BUILD.gn index 13d3f7c20..149637785 100644 --- a/arkui/ace_engine/native/BUILD.gn +++ b/arkui/ace_engine/native/BUILD.gn @@ -36,6 +36,7 @@ if (!is_arkui_x) { "native_interface_focus.h", "native_key_event.h", "native_node.h", + "native_node_ani.h", "native_node_napi.h", "native_type.h", "styled_string.h", diff --git a/arkui/ace_engine/native/libace.ndk.json b/arkui/ace_engine/native/libace.ndk.json index 4881b6a04..e36fe8b1a 100644 --- a/arkui/ace_engine/native/libace.ndk.json +++ b/arkui/ace_engine/native/libace.ndk.json @@ -3502,5 +3502,13 @@ { "first_introduced": "20", "name": "OH_ArkUI_SetForceDarkConfig" + }, + { + "first_introduced": "20", + "name": "OH_ArkUI_NativeModule_GetNodeHandleFromAniValue" + }, + { + "first_introduced": "20", + "name": "OH_ArkUI_NativeModule_GetContextFromAniValue" } ] \ No newline at end of file diff --git a/arkui/ace_engine/native/native_node_ani.h b/arkui/ace_engine/native/native_node_ani.h new file mode 100644 index 000000000..7068bfa2c --- /dev/null +++ b/arkui/ace_engine/native/native_node_ani.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup ArkUI_NativeModule + * @{ + * + * @brief Provides UI capabilities of ArkUI on the native side, such as UI component creation and destruction, + * tree node operations, attribute setting, and event listening. + * + * @since 12 + */ + +/** + * @file native_node_ani.h + * + * @brief Declares APIs for converting FrameNode objects on the ArkTS side to ArkUI_NodeHandle objects on + * the native side. + * + * @library libace_ndk.z.so + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @kit ArkUI + * @since 20 + */ + +#ifndef ARKUI_NATIVE_NODE_ANI_H +#define ARKUI_NATIVE_NODE_ANI_H + +#include "ani/ani.h" + +#include "native_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Obtains a FrameNode object on the ArkTS side and maps it to an ArkUI_NodeHandle object on the + * native side. + * + * @param env Indicates the ANI environment pointer. + * @param frameNode Indicates the FrameNode object created on the ArkTS side. + * @param handle Indicates the pointer to the ArkUI_NodeHandle object. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + * @since 20 + */ +int32_t OH_ArkUI_NativeModule_GetNodeHandleFromAniValue(ani_env* env, ani_object frameNode, ArkUI_NodeHandle* handle); + +/** + * @brief Obtains a UIContext object on the ArkTS side and maps it to an ArkUI_ContextHandle object on the + * native side. + * + * @param env ndicates the ANI environment pointer. + * @param context Indicates the UIContext object created on the ArkTS side. + * @param handle Indicates the pointer to the ArkUI_ContextHandle object. + * @return Returns the error code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + * @since 20 + */ +int32_t OH_ArkUI_NativeModule_GetContextFromAniValue(ani_env* env, ani_object context, ArkUI_ContextHandle* handle); + +#ifdef __cplusplus +}; +#endif + +#endif // ARKUI_NATIVE_NODE_ANI_H +/** @} */ \ No newline at end of file -- Gitee