diff --git a/pango/Gir.toml b/pango/Gir.toml index 89a08a923130..d8e6079822b9 100644 --- a/pango/Gir.toml +++ b/pango/Gir.toml @@ -41,7 +41,6 @@ generate = [ "Pango.FontsetSimple", "Pango.Glyph", "Pango.GlyphItem", - "Pango.GlyphItemIter", "Pango.GlyphString", "Pango.GlyphUnit", "Pango.Gravity", @@ -237,6 +236,14 @@ status = "generate" name = "language" const = true +[[object]] +name = "Pango.GlyphItemIter" +status = "generate" + [[object.function]] + pattern = "init.*" + # converted to proper constructors + manual = true + [[object]] name = "Pango.Layout" status = "generate" diff --git a/pango/src/auto/glyph_item_iter.rs b/pango/src/auto/glyph_item_iter.rs index 93fa9620dfc4..b3c3a745f95a 100644 --- a/pango/src/auto/glyph_item_iter.rs +++ b/pango/src/auto/glyph_item_iter.rs @@ -2,7 +2,6 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use crate::GlyphItem; use glib::translate::*; glib::wrapper! { @@ -17,28 +16,6 @@ glib::wrapper! { } impl GlyphItemIter { - #[doc(alias = "pango_glyph_item_iter_init_end")] - pub fn init_end(&mut self, glyph_item: &mut GlyphItem, text: &str) -> bool { - unsafe { - from_glib(ffi::pango_glyph_item_iter_init_end( - self.to_glib_none_mut().0, - glyph_item.to_glib_none_mut().0, - text.to_glib_none().0, - )) - } - } - - #[doc(alias = "pango_glyph_item_iter_init_start")] - pub fn init_start(&mut self, glyph_item: &mut GlyphItem, text: &str) -> bool { - unsafe { - from_glib(ffi::pango_glyph_item_iter_init_start( - self.to_glib_none_mut().0, - glyph_item.to_glib_none_mut().0, - text.to_glib_none().0, - )) - } - } - #[doc(alias = "pango_glyph_item_iter_next_cluster")] pub fn next_cluster(&mut self) -> bool { unsafe { diff --git a/pango/src/glyph_item_iter.rs b/pango/src/glyph_item_iter.rs new file mode 100644 index 000000000000..029d6c3868d3 --- /dev/null +++ b/pango/src/glyph_item_iter.rs @@ -0,0 +1,44 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +use crate::GlyphItem; +use crate::GlyphItemIter; +use glib::translate::*; +use std::mem; + +impl GlyphItemIter { + #[doc(alias = "pango_glyph_item_iter_init_end")] + pub fn new_end(glyph_item: &GlyphItem, text: &str) -> Result { + unsafe { + let mut iter = mem::MaybeUninit::zeroed(); + let res: bool = from_glib(ffi::pango_glyph_item_iter_init_end( + iter.as_mut_ptr(), + mut_override(glyph_item.to_glib_none().0), + text.to_glib_none().0, + )); + + if res { + Ok(from_glib_none(&iter.assume_init() as *const _)) + } else { + Err(glib::bool_error!("Failed to create glyph item iter")) + } + } + } + + #[doc(alias = "pango_glyph_item_iter_init_start")] + pub fn new_start(glyph_item: &GlyphItem, text: &str) -> Result { + unsafe { + let mut iter = mem::MaybeUninit::zeroed(); + let res: bool = from_glib(ffi::pango_glyph_item_iter_init_start( + iter.as_mut_ptr(), + mut_override(glyph_item.to_glib_none().0), + text.to_glib_none().0, + )); + + if res { + Ok(from_glib_none(&iter.assume_init() as *const _)) + } else { + Err(glib::bool_error!("Failed to create glyph item iter")) + } + } + } +} diff --git a/pango/src/lib.rs b/pango/src/lib.rs index fe9e5788c4d1..fac53402c009 100644 --- a/pango/src/lib.rs +++ b/pango/src/lib.rs @@ -63,6 +63,7 @@ pub mod rectangle; pub use crate::rectangle::Rectangle; pub mod glyph; pub use glyph::{GlyphGeometry, GlyphInfo}; +mod glyph_item_iter; mod coverage; pub use crate::coverage::*;