From 70a1b53477633504cc5b2983e71610236085b2f7 Mon Sep 17 00:00:00 2001 From: liyi0309 Date: Tue, 5 Mar 2024 20:34:34 +0800 Subject: [PATCH] add build node API Signed-off-by: liyi0309 --- arkui/ace_engine/native/BUILD.gn | 1 + arkui/ace_engine/native/libace.ndk.json | 4 ++ arkui/ace_engine/native/native_node_napi.h | 64 ++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 arkui/ace_engine/native/native_node_napi.h diff --git a/arkui/ace_engine/native/BUILD.gn b/arkui/ace_engine/native/BUILD.gn index df21fe5b3..2dc4d659a 100644 --- a/arkui/ace_engine/native/BUILD.gn +++ b/arkui/ace_engine/native/BUILD.gn @@ -29,6 +29,7 @@ if (!is_arkui_x) { "native_event.h", "native_interface.h", "native_node.h", + "native_node_napi.h", "native_type.h", "ui_input_event.h", ] diff --git a/arkui/ace_engine/native/libace.ndk.json b/arkui/ace_engine/native/libace.ndk.json index af9796452..bb3303979 100644 --- a/arkui/ace_engine/native/libace.ndk.json +++ b/arkui/ace_engine/native/libace.ndk.json @@ -150,5 +150,9 @@ { "first_introduced": "12", "name": "OH_ArkUI_AxisEvent_GetPinchAxisScaleValue" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetNodeHandleFromNapiValue" } ] \ No newline at end of file diff --git a/arkui/ace_engine/native/native_node_napi.h b/arkui/ace_engine/native/native_node_napi.h new file mode 100644 index 000000000..cc219bd5a --- /dev/null +++ b/arkui/ace_engine/native/native_node_napi.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 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_napi.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 + * @since 12 + */ + +#ifndef ARKUI_NATIVE_NODE_NAPI_H +#define ARKUI_NATIVE_NODE_NAPI_H + +#include "napi/native_api.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 NAPI 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 0 if success. + * Returns 401 if a parameter exception occurs. + * @since 12 + */ +int32_t OH_ArkUI_GetNodeHandleFromNapiValue(napi_env env, napi_value frameNode, ArkUI_NodeHandle* handle); + +#ifdef __cplusplus +}; +#endif + +#endif // ARKUI_NATIVE_NODE_NAPI_H +/** @} */ -- Gitee