17777dab0Sopenharmony_ci/* 27777dab0Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 37777dab0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 47777dab0Sopenharmony_ci * you may not use this file except in compliance with the License. 57777dab0Sopenharmony_ci * You may obtain a copy of the License at 67777dab0Sopenharmony_ci * 77777dab0Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 87777dab0Sopenharmony_ci * 97777dab0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 107777dab0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 117777dab0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 127777dab0Sopenharmony_ci * See the License for the specific language governing permissions and 137777dab0Sopenharmony_ci * limitations under the License. 147777dab0Sopenharmony_ci */ 157777dab0Sopenharmony_ci 167777dab0Sopenharmony_ci/** 177777dab0Sopenharmony_ci * @addtogroup ArkUI_NativeModule 187777dab0Sopenharmony_ci * @{ 197777dab0Sopenharmony_ci * 207777dab0Sopenharmony_ci * @brief Provides UI capabilities of ArkUI on the native side, such as UI component creation and destruction, 217777dab0Sopenharmony_ci * tree node operations, attribute setting, and event listening. 227777dab0Sopenharmony_ci * 237777dab0Sopenharmony_ci * @since 12 247777dab0Sopenharmony_ci */ 257777dab0Sopenharmony_ci 267777dab0Sopenharmony_ci/** 277777dab0Sopenharmony_ci * @file native_interface.h 287777dab0Sopenharmony_ci * 297777dab0Sopenharmony_ci * @brief Provides a unified entry for the native module APIs. 307777dab0Sopenharmony_ci * 317777dab0Sopenharmony_ci * @library libace_ndk.z.so 327777dab0Sopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 337777dab0Sopenharmony_ci * @kit ArkUI 347777dab0Sopenharmony_ci * @since 12 357777dab0Sopenharmony_ci */ 367777dab0Sopenharmony_ci 377777dab0Sopenharmony_ci#ifndef ARKUI_NATIVE_INTERFACE_H 387777dab0Sopenharmony_ci#define ARKUI_NATIVE_INTERFACE_H 397777dab0Sopenharmony_ci 407777dab0Sopenharmony_ci#include <stdint.h> 417777dab0Sopenharmony_ci 427777dab0Sopenharmony_ci#ifdef __cplusplus 437777dab0Sopenharmony_ciextern "C" { 447777dab0Sopenharmony_ci#endif 457777dab0Sopenharmony_ci 467777dab0Sopenharmony_ci/** 477777dab0Sopenharmony_ci * @brief Defines the native API types. 487777dab0Sopenharmony_ci * 497777dab0Sopenharmony_ci * @since 12 507777dab0Sopenharmony_ci */ 517777dab0Sopenharmony_citypedef enum { 527777dab0Sopenharmony_ci /** API related to UI components. For details, see the struct definition in <arkui/native_node.h>. */ 537777dab0Sopenharmony_ci ARKUI_NATIVE_NODE, 547777dab0Sopenharmony_ci /** API related to dialog boxes. For details, see the struct definition in <arkui/native_dialog.h>. */ 557777dab0Sopenharmony_ci ARKUI_NATIVE_DIALOG, 567777dab0Sopenharmony_ci /** API related to gestures. For details, see the struct definition in <arkui/native_gesture.h>. */ 577777dab0Sopenharmony_ci ARKUI_NATIVE_GESTURE, 587777dab0Sopenharmony_ci /** API related to animations. For details, see the struct definition in <arkui/native_animate.h>.*/ 597777dab0Sopenharmony_ci ARKUI_NATIVE_ANIMATE, 607777dab0Sopenharmony_ci} ArkUI_NativeAPIVariantKind; 617777dab0Sopenharmony_ci 627777dab0Sopenharmony_ci/** 637777dab0Sopenharmony_ci * @brief Obtains the native API set of a specified type. 647777dab0Sopenharmony_ci * 657777dab0Sopenharmony_ci * @param type Indicates the type of the native API set provided by ArkUI, for example, <b>ARKUI_NATIVE_NODE</b> 667777dab0Sopenharmony_ci * and <b>ARKUI_NATIVE_GESTURE</b>. 677777dab0Sopenharmony_ci * @param sturctName Indicates the name of a native struct defined in the corresponding header file, for example, 687777dab0Sopenharmony_ci * <b>ArkUI_NativeNodeAPI_1</b> in <arkui/native_node.h>. 697777dab0Sopenharmony_ci * @return Returns the pointer to the abstract native API, which can be used after being converted into a specific type. 707777dab0Sopenharmony_ci * @code {.cpp} 717777dab0Sopenharmony_ci * #include<arkui/native_interface.h> 727777dab0Sopenharmony_ci * #include<arkui/native_node.h> 737777dab0Sopenharmony_ci * #include<arkui/native_gesture.h> 747777dab0Sopenharmony_ci * 757777dab0Sopenharmony_ci * auto* anyNativeAPI = OH_ArkUI_QueryModuleInterfaceByName(ARKUI_NATIVE_NODE, "ArkUI_NativeNodeAPI_1"); 767777dab0Sopenharmony_ci * if (anyNativeAPI) { 777777dab0Sopenharmony_ci * auto nativeNodeApi = reinterpret_cast<ArkUI_NativeNodeAPI_1*>(anyNativeAPI); 787777dab0Sopenharmony_ci * } 797777dab0Sopenharmony_ci * auto anyGestureAPI = OH_ArkUI_QueryModuleInterface(ARKUI_NATIVE_GESTURE, "ArkUI_NativeGestureAPI_1"); 807777dab0Sopenharmony_ci * if (anyNativeAPI) { 817777dab0Sopenharmony_ci * auto basicGestureApi = reinterpret_cast<ArkUI_NativeGestureAPI_1*>(anyGestureAPI); 827777dab0Sopenharmony_ci * } 837777dab0Sopenharmony_ci * @endcode 847777dab0Sopenharmony_ci * 857777dab0Sopenharmony_ci * @since 12 867777dab0Sopenharmony_ci */ 877777dab0Sopenharmony_civoid* OH_ArkUI_QueryModuleInterfaceByName(ArkUI_NativeAPIVariantKind type, const char* structName); 887777dab0Sopenharmony_ci 897777dab0Sopenharmony_ci/** 907777dab0Sopenharmony_ci * @brief Obtains the macro function corresponding to a struct pointer based on the struct type. 917777dab0Sopenharmony_ci * 927777dab0Sopenharmony_ci * @code {.cpp} 937777dab0Sopenharmony_ci * #include<arkui/native_interface.h> 947777dab0Sopenharmony_ci * #include<arkui/native_node.h> 957777dab0Sopenharmony_ci * 967777dab0Sopenharmony_ci * ArkUI_NativeNodeAPI_1* nativeNodeApi = nullptr; 977777dab0Sopenharmony_ci * OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nativeNodeApi); 987777dab0Sopenharmony_ci * @endcode 997777dab0Sopenharmony_ci * 1007777dab0Sopenharmony_ci * @since 12 1017777dab0Sopenharmony_ci */ 1027777dab0Sopenharmony_ci#define OH_ArkUI_GetModuleInterface(nativeAPIVariantKind, structType, structPtr) \ 1037777dab0Sopenharmony_ci do { \ 1047777dab0Sopenharmony_ci void* anyNativeAPI = OH_ArkUI_QueryModuleInterfaceByName(nativeAPIVariantKind, #structType); \ 1057777dab0Sopenharmony_ci if (anyNativeAPI) { \ 1067777dab0Sopenharmony_ci structPtr = (structType*)(anyNativeAPI); \ 1077777dab0Sopenharmony_ci } \ 1087777dab0Sopenharmony_ci } while (0) 1097777dab0Sopenharmony_ci 1107777dab0Sopenharmony_ci#ifdef __cplusplus 1117777dab0Sopenharmony_ci}; 1127777dab0Sopenharmony_ci#endif 1137777dab0Sopenharmony_ci 1147777dab0Sopenharmony_ci#endif // ARKUI_NATIVE_INTERFACE_H 1157777dab0Sopenharmony_ci/** @} */ 116