Skip to content

Commit

Permalink
pango: Implement GlyphItemIter constructors
Browse files Browse the repository at this point in the history
Fixes gtk-rs#36
  • Loading branch information
sdroege committed Oct 28, 2021
1 parent 495b6ff commit 321e8ed
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 24 deletions.
9 changes: 8 additions & 1 deletion pango/Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ generate = [
"Pango.FontsetSimple",
"Pango.Glyph",
"Pango.GlyphItem",
"Pango.GlyphItemIter",
"Pango.GlyphString",
"Pango.GlyphUnit",
"Pango.Gravity",
Expand Down Expand Up @@ -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"
Expand Down
23 changes: 0 additions & 23 deletions pango/src/auto/glyph_item_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand All @@ -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 {
Expand Down
44 changes: 44 additions & 0 deletions pango/src/glyph_item_iter.rs
Original file line number Diff line number Diff line change
@@ -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<Self, glib::BoolError> {
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<Self, glib::BoolError> {
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"))
}
}
}
}
1 change: 1 addition & 0 deletions pango/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

0 comments on commit 321e8ed

Please sign in to comment.