Skip to content

Commit

Permalink
xcomponent: Update bindings to API-13
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Schwender <[email protected]>
  • Loading branch information
jschwe committed Jan 8, 2025
1 parent 2d629a7 commit 91995b5
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/opaque-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ohos-sys-opaque-types"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
keywords = ["OpenHarmony", "HarmonyOS"]
description = "Internal helper cratefor opaque type bindings that are used in multiple ohos-sys crates"
Expand Down
4 changes: 4 additions & 0 deletions components/opaque-types/src/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ pub struct OH_PixelmapNative {
pub struct NativePixelMap_ {
_unused: [u8; 0],
}
#[repr(C)]
pub struct ArkUI_AccessibilityProvider {
_unused: [u8; 0],
}
3 changes: 3 additions & 0 deletions components/opaque-types/wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
#include "multimedia/image_framework/image/pixelmap_native.h"
#include "multimedia/image_framework/image_pixel_map_mdk.h"
#include "native_window/external_window.h"
#if BINDGEN_OHOS_API_LEVEL >= 13
#include "arkui/native_interface_accessibility.h"
#endif
4 changes: 3 additions & 1 deletion components/xcomponent/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xcomponent-sys"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
description = "Raw Bindings to the `xcomponent` API of OpenHarmony"
license = "Apache-2.0"
Expand All @@ -13,13 +13,15 @@ readme = "README.md"
document-features = { version = "0.2", optional = true }
keyboard-types = {version = "0.7.0", optional = true}
arkui-sys = { version = "0.2.0", path = "../arkui", optional = true}
ohos-sys-opaque-types = { workspace = true}

[features]
default = []

api-10 = []
api-11 = ["api-10"]
api-12 = ["api-11", "arkui-sys?/api-12"]
api-13 = ["api-12" ]
## Enables XComponent APIs that depend on ArkUI.
arkui = ["dep:arkui-sys"]
## Provides optional conversion from the OH keyboard enum to the keyboard-types enum.
Expand Down
23 changes: 23 additions & 0 deletions components/xcomponent/src/xcomponent_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#[cfg(feature = "api-13")]
use ohos_sys_opaque_types::ArkUI_AccessibilityProvider;

pub const OH_NATIVE_XCOMPONENT_OBJ: &[u8; 26] = b"__NATIVE_XCOMPONENT_OBJ__\0";
impl OH_NativeXComponent_KeyCode {
Expand Down Expand Up @@ -2175,4 +2177,25 @@ extern "C" {
pointId: i32,
sourceType: *mut OH_NativeXComponent_EventSourceType,
) -> i32;
/// Obtains the pointer to the <b> ArkUI_AccessibilityProvider</b>
/// instance of this <b>OH_NativeXComponent</b> instance.
///
/// # Arguments
///
/// `component` - Indicates the pointer to the <b>OH_NativeXComponent</b> instance.
///
/// `handle` - Indicates the pointer to the <b>ArkUI_AccessibilityProvider</b> instance.
///
/// # Returns
///
/// Returns [`OH_NATIVEXCOMPONENT_RESULT_SUCCESS`] if the operation is successful.
/// Returns [`OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER`] if a parameter error occurs.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_NativeXComponent_GetNativeAccessibilityProvider(
component: *mut OH_NativeXComponent,
handle: *mut *mut ArkUI_AccessibilityProvider,
) -> i32;
}
5 changes: 5 additions & 0 deletions scripts/generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ fn get_bindings_config(api_version: u32) -> Vec<BindingConf> {
.blocklist_function("OH_NativeXComponent_RegisterUIInputEventCallback")
.blocklist_function("OH_NativeXComponent_RegisterOnTouchInterceptCallback")
.blocklist_function("OH_NativeXComponent_GetNativeXComponent")
.raw_line("#[cfg(feature = \"api-13\")]")
.raw_line("use ohos_sys_opaque_types::{ArkUI_AccessibilityProvider};")
.clang_args(&["-x", "c++"])
}),
},
Expand Down Expand Up @@ -773,6 +775,9 @@ fn generate_opaque_types_bindings(root_dir: &Path, builder: bindgen::Builder, sy

fn generate_bindings(sdk_native_dir: &Path, api_version: u32) -> anyhow::Result<()> {
let base_builder = base_bindgen_builder(&sdk_native_dir.join("sysroot"))?;
let base_builder = base_builder
.clang_arg("-D")
.clang_arg(format!("BINDGEN_OHOS_API_LEVEL={api_version}"));
let sysroot_include_dir = sdk_native_dir.join("sysroot/usr/include");
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));

Expand Down
3 changes: 2 additions & 1 deletion scripts/generator/src/opaque_types.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
pub(crate) static OPAQUE_TYPES: [&str; 7] = [
pub(crate) static OPAQUE_TYPES: [&str; 8] = [
"OH_PixelmapNative",
"NativePixelMap_",
"OH_NativeBuffer",
"NativeWindow",
"NativeWindowBuffer",
"OHNativeWindow",
"OHNativeWindowBuffer",
"ArkUI_AccessibilityProvider",
];

0 comments on commit 91995b5

Please sign in to comment.