GNOME Bugzilla – Bug 779887
GTypeInterface does not require that properties have getter or setter vfuncs
Last modified: 2017-10-18 19:05:38 UTC
Say you have a GTypeInterface in C, and it has a property "foo". Implementing the property in Vala requires that the base interface has a set_foo and get_foo (depending on R/W of the property) to chain up. This makes using interfaces+properties from C libraries rather painful, as they have to change code to add a dummy vfunc entry to chain up to.
*** This bug has been marked as a duplicate of bug 638434 ***
If getter and/or setter methods in C API are missing for a foo property is installed, may is an API error, so you don't know if you want that property to be read-write, read only or write only, property at C API level; you need to introspect available properties to know how it is declared on G_PARAM_*. This is so much work in order to use a property, correctly as author expect Of course you can use g_object_get_property from C, but that means you don't want your C library to be binding friendly, because your users should use "obj.get_property ("foo")" instead of "obj.get_foo ()". So, may foo property should be removed from VAPI bindings, so no compiler errors. Your Vala users can use GLib.Object.get_property(), to access your unfriendly bindings hidden property, by checking C documentation.
(In reply to Daniel Espinosa from comment #2) > Of course you can use g_object_get_property from C, but that means you don't > want your C library to be binding friendly, because your users should use > "obj.get_property ("foo")" instead of "obj.get_foo ()". Not using get_* or set_* vfunc's in the classes vtable does not imply that you have to use get_property() or set_property(). It just means that the class isn't designed to have the property overridden by subclasses. It's expected to use the public accessor functions. Compare this to "final" on a property in other languages (or lack of "virtual" keyword). > So, may foo property should be removed from VAPI bindings, so no compiler > errors. Your Vala users can use GLib.Object.get_property(), to access your > unfriendly bindings hidden property, by checking C documentation. I would expect it to continue to use the foo.prop style like the other bindings, and call the getter or setter function appropriately.