Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Add manual sys functions where GIR is incorrect #93

Closed
wants to merge 1 commit into from

Conversation

bvinc
Copy link

@bvinc bvinc commented Apr 25, 2018

Issue #92

These sys functions have the wrong definition because the GIR files have incorrect array tags due to issue 189 in gi-introspection. It occurs when the C function definition uses the [] operator in a parameter. I've searched through header files and these are the only functions that I could find. It's possible that I missed some though.

These sys functions have the wrong definition because the GIR files have incorrect array tags due to issue 189 in gi-introspection.
@EPashkin
Copy link
Member

EPashkin commented May 12, 2018

@bvinc Sorry for long wait for review.

Thanks for PR, but now this type of error better solved by patching .gir files.
Ex. adding to https://github.com/gtk-rs/gir-files/blob/master/fix.sh this

xmlstarlet ed -P -L \
	-u '//_:class[@name="IconTheme"]/_:method//_:parameter[@name="icon_names"]/_:array/@c:type' -v "gchar const* *" \
	Gtk-3.0.gir

can fix generation 2 function in sys

pub fn gtk_icon_theme_choose_icon(icon_theme: *mut GtkIconTheme, icon_names: *mut *const c_char, size: c_int, flags: GtkIconLookupFlags) -> *mut GtkIconInfo;
pub fn gtk_icon_theme_choose_icon_for_scale(icon_theme: *mut GtkIconTheme, icon_names: *mut *const c_char, size: c_int, scale: c_int, flags: GtkIconLookupFlags) -> *mut GtkIconInfo;

and allow generate functions in gtk

fn choose_icon(&self, icon_names: &[&str], size: i32, flags: IconLookupFlags) -> Option<IconInfo> {
    unsafe {
        from_glib_full(ffi::gtk_icon_theme_choose_icon(self.to_glib_none().0, icon_names.to_glib_none().0, size, flags.to_glib()))
    }
}

#[cfg(any(feature = "v3_10", feature = "dox"))]
fn choose_icon_for_scale(&self, icon_names: &[&str], size: i32, scale: i32, flags: IconLookupFlags) -> Option<IconInfo> {
    unsafe {
        from_glib_full(ffi::gtk_icon_theme_choose_icon_for_scale(self.to_glib_none().0, icon_names.to_glib_none().0, size, scale, flags.to_glib()))
    }
}

PS. It better be "gchar const* const*" in .gir, but glib need fix for support it too.

Edit: fixed sys functions, it was actually *mut *const c_char, same as in this PR

@bvinc
Copy link
Author

bvinc commented Jun 5, 2018

Fixed with gtk-rs/gir-files#23

@bvinc bvinc closed this Jun 5, 2018
@EPashkin
Copy link
Member

EPashkin commented Jun 6, 2018

@bvinc So you don't want update this PR with right version? 😉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants