gtk-rs / gir

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

GIR doesn't apply version constraints correctly #720

Closed jsparber closed 5 years ago

jsparber commented 5 years ago

Gir doesn't add a version annotation to getter function. https://gitlab.gnome.org/World/Rust/libhandy-rs/merge_requests/10/diffs?commit_id=befe3cfdef9330f03832458c6276156ff28aedd1#3ed5e305c730954a5c3ce7add7498557d3950080_0_107

sdroege commented 5 years ago

The problem here is that the version is not in the .gir file. But because the whole module/class is only available from a specific version, all those versions given in the file are not needed and only add noise.

sdroege commented 5 years ago

And gir should be able to detect that the property also has a getter function and not generate anything for the property.

EPashkin commented 5 years ago
        #[cfg(any(feature = "v0_0_8", feature = "dox"))]
        fn get_value(&self) -> Option<glib::Value> {
            unsafe {
                from_glib_none(ffi::hdy_value_object_get_value(self.to_glib_none().0))
            }
        }

        fn get_property_value(&self) -> Option<glib::Value> {
            unsafe {
                let mut value = Value::from_type(<glib::Value as StaticType>::static_type());
                gobject_ffi::g_object_get_property(self.to_glib_none().0, "value".to_glib_none().0, value.to_glib_none_mut().0);
                value.get()
            }
        }

Agree that gir better assume that all method in module has at minimum "v0_0_8" constraint even if it not in .gir file, but this IMHO not that urgent. @jsparber You have 2 temporary solution for manually define:

jsparber commented 5 years ago

@EPashkin I disabled the getter generation, but didn't know i could set it to notify. Thanks

jsparber commented 5 years ago

I needed to update the gir version

GuillaumeGomez commented 5 years ago

Is it still an issue?

GuillaumeGomez commented 5 years ago

Closing it then. Don't hesitate to reopen if it's still there.