After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 779887 - GTypeInterface does not require that properties have getter or setter vfuncs
GTypeInterface does not require that properties have getter or setter vfuncs
Status: RESOLVED DUPLICATE of bug 638434
Product: vala
Classification: Core
Component: Basic Types
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2017-03-11 04:15 UTC by Christian Hergert
Modified: 2017-10-18 19:05 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Christian Hergert 2017-03-11 04:15:21 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.
Comment 1 Rico Tzschichholz 2017-03-11 16:15:10 UTC

*** This bug has been marked as a duplicate of bug 638434 ***
Comment 2 Daniel Espinosa 2017-10-18 16:26:04 UTC
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.
Comment 3 Christian Hergert 2017-10-18 19:05:38 UTC
(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.