gtk-rs / gir

Tool to generate rust bindings and user API for glib-based libraries
https://gtk-rs.org/gir/book/
MIT License
237 stars 107 forks source link

gir confuses the callback definition with params nullability #1104

Closed bilelmoussaoui closed 3 years ago

bilelmoussaoui commented 3 years ago

If you take a Callback defined as such

pub type GtkShortcutFunc = Option<unsafe extern "C" fn(*mut GtkWidget, *mut glib::GVariant, gpointer) -> gboolean>;

Any function that takes that callback as input param, it will have a Option<Box<F>> even if the param isn't marked as nullable in the introspection data. see https://github.com/gtk-rs/gtk4-rs/pull/268#discussion_r607078820 for details

fengalin commented 3 years ago

I can look into this as part of https://github.com/gtk-rs/gir/pull/1092 which I resumed today. Hopefully, I should to be able to push something before the weekend.

fengalin commented 3 years ago

Actually, the callback parameter is marked nullable = "1" in Gtk-4.0.gir. See line 10 305. As discussed on IRC, this can be closed.

bilelmoussaoui commented 3 years ago

Thanks for checking this one @fengalin