1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup ArkUI_NativeModule 18 * @{ 19 * 20 * @brief 提供ArkUI在Native侧的UI能力,如UI组件创建销毁、树节点操作,属性设置,事件监听等。 21 * 22 * @since 12 23 */ 24 25 /** 26 * @file native_interface.h 27 * 28 * @brief 提供NativeModule接口的统一入口函数。 29 * 30 * @library libace_ndk.z.so 31 * @syscap SystemCapability.ArkUI.ArkUI.Full 32 * @since 12 33 */ 34 35 #ifndef ARKUI_NATIVE_INTERFACE_H 36 #define ARKUI_NATIVE_INTERFACE_H 37 38 #include <stdint.h> 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 /** 45 * @brief 定义任意版本的Native接口类型。 46 * 47 * @since 12 48 */ 49 typedef struct { 50 /** 51 * @brief 定义Native接口集合的版本信息。 52 * 53 * 不同于NDK版本,NativeNode接口的version字段标识自身结构体的版本信息。 54 */ 55 int32_t version; 56 } ArkUI_AnyNativeAPI; 57 58 /** 59 * @brief 定义Native接口集合类型。 60 * 61 * @since 12 62 */ 63 typedef enum { 64 /** UI组件相关接口类型。*/ 65 ARKUI_NATIVE_NODE, 66 } ArkUI_NativeAPIVariantKind; 67 68 /** 69 * @brief 获取指定版本的Native接口集合。 70 * 71 * @param type ArkUI提供的Native接口集合大类,例如UI组件接口类:ARKUI_NATIVE_NODE。 72 * @param version native接口结构体的版本信息,通过结构体定义的后缀获得,如版本1的UI组件结构体:ArkUI_NativeNodeAPI_1。 73 * @return ArkUI_AnyNativeAPI* 返回携带版本的Native接口抽象对象。 74 * @code {.cpp} 75 * #include<arkui/native_interface.h> 76 * #include<arkui/native_node.h> 77 * 78 * auto anyNativeAPI = OH_ArkUI_GetNativeAPI(ARKUI_NATIVE_NODE, 1); 79 * if (anyNativeAPI->version == 1) { 80 * auto basicNodeApi = reinterpret_cast<ArkUI_NativeNodeAPI_1*>(anyNativeAPI); 81 * } 82 * @endcode 83 * 84 * @since 12 85 */ 86 ArkUI_AnyNativeAPI* OH_ArkUI_GetNativeAPI(ArkUI_NativeAPIVariantKind type, int32_t version); 87 88 #ifdef __cplusplus 89 }; 90 #endif 91 92 #endif // ARKUI_NATIVE_INTERFACE_H 93 /** @} */ 94