Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor refactoring and add Input-kit bindings #72

Merged
merged 4 commits into from
Jan 11, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
drawing: rework copy blocklist
The manual blocklist is not necessary anymore,
since we already blocklist all opaque structs via
our bindgen fork.
Deriving copy, clone and debug on the OH_Drawing_Point2D seems reasonable.

Signed-off-by: Jonathan Schwender <[email protected]>
  • Loading branch information
jschwe committed Jan 11, 2025
commit 304a525638ef54e7765043403e1febc7ae24c8d7
6 changes: 6 additions & 0 deletions components/drawing/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Changelog

## unreleased

- `OH_Drawing_Point2D` and `OH_Drawing_Point3D` now derive Copy, Clone and Debug

## v0.2.1 (2025-01-08)

- Update bindings for API-13
1 change: 1 addition & 0 deletions components/drawing/src/text_blob/text_blob_ffi.rs
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ use crate::error_code::OH_Drawing_ErrorCode;
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
#[repr(C)]
#[derive(Debug)]
pub struct OH_Drawing_RunBuffer {
/// storage for glyph indexes in run
pub glyphs: *mut u16,
2 changes: 2 additions & 0 deletions components/drawing/src/types/types_ffi.rs
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ pub struct OH_Drawing_ColorSpace {
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct OH_Drawing_Point2D {
pub x: f32,
pub y: f32,
@@ -71,6 +72,7 @@ pub type OH_Drawing_Corner_Radii = OH_Drawing_Point2D;
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct OH_Drawing_Point3D {
pub x: f32,
pub y: f32,
69 changes: 7 additions & 62 deletions scripts/generator/src/main.rs
Original file line number Diff line number Diff line change
@@ -454,64 +454,6 @@ fn strip_prefix(input: &str, prefix: &str) -> String {
}
}

fn apply_drawing_nocopy(builder: bindgen::Builder) -> bindgen::Builder {
let blocklist = [
"OH_Drawing_Canvas",
"OH_Drawing_Pen",
"OH_Drawing_Brush",
"OH_Drawing_Path",
"OH_Drawing_Bitmap",
"OH_Drawing_FontCollection",
"OH_Drawing_Typography",
"OH_Drawing_TextStyle",
"OH_Drawing_TypographyStyle",
"OH_Drawing_TypographyCreate",
//--- API-11 -------------------------------------
"OH_Drawing_Point",
"OH_Drawing_Rect",
"OH_Drawing_RoundRect",
"OH_Drawing_ShaderEffect",
"OH_Drawing_Filter",
"OH_Drawing_MaskFilter",
"OH_Drawing_ColorFilter",
"OH_Drawing_Font",
"OH_Drawing_Typeface",
"OH_Drawing_TextBlob",
"OH_Drawing_TextBlobBuilder",
"OH_Drawing_TextBox",
"OH_Drawing_PositionAndAffinity",
"OH_Drawing_Range",
"OH_Drawing_Matrix",
"OH_Drawing_RunBuffer",
// ---- API-12 ---------------------------------------
"OH_Drawing_Region",
"OH_Drawing_PixelMap",
"OH_Drawing_ColorSpace",
"OH_Drawing_Point2D",
"OH_Drawing_Point3D",
"OH_Drawing_PathEffect",
"OH_Drawing_ShadowLayer",
"OH_Drawing_MemoryStream",
"OH_Drawing_Image",
"OH_Drawing_ImageFilter",
"OH_Drawing_SamplingOptions",
"OH_Drawing_GpuContext",
"OH_Drawing_Surface",
"OH_Drawing_FontMgr",
"OH_Drawing_FontStyleSet",
"OH_Drawing_BitmapFormat",
"OH_Drawing_FontParser",
"OH_Drawing_TextShadow",
// Maybe: OH_Drawing_StrutStyle
];
let mut builder = builder;
for obj in blocklist {
builder = builder.no_copy(obj);
builder = builder.no_debug(obj);
}
builder
}

// todo: unify via trait
fn get_module_bindings_config(api_version: u32) -> Vec<DirBindingsConf> {
vec![DirBindingsConf {
@@ -683,19 +625,22 @@ fn get_module_bindings_config(api_version: u32) -> Vec<DirBindingsConf> {
"pixel_map" => {
builder.raw_line("use ohos_sys_opaque_types::{OH_PixelmapNative, NativePixelMap_};")
}
_ => builder,
"text_blob" => {
builder
.no_copy("OH_Drawing_RunBuffer")
}
_ => builder,
};
let builder = builder
builder
.allowlist_file(format!("{}", header_path.to_str().unwrap()))
.allowlist_recursively(false)
.default_enum_style(EnumVariation::NewType {
is_bitfield: false,
is_global: false,
})
.prepend_enum_name(false)
.clang_args(&["-x", "c++"]);
.clang_args(&["-x", "c++"])

apply_drawing_nocopy(builder)
}
),
},