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 641781 - Using [CCode (cname = "…")] with property getters doesn't work
Using [CCode (cname = "…")] with property getters doesn't work
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator: GObject
0.11.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks: 629078
 
 
Reported: 2011-02-07 22:24 UTC by Philip Withnall
Modified: 2011-02-08 17:08 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Philip Withnall 2011-02-07 22:24:36 UTC
The following Vala code:

  public GLib.List<Backend> enabled_backends
    {
      owned get
        {
          var backends = new GLib.List<Backend> ();
          foreach (var backend in this._prepared_backends.values)
            backends.prepend (backend);

          return backends;
        }

      private set {}
    }

results in the following C declaration:

GList* folks_backend_store_get_enabled_backends (FolksBackendStore* self);

If a CCode attribute is added to the getter as follows:

  public GLib.List<Backend> enabled_backends
    {
      [CCode (cname = "folks_backend_store_dup_enabled_backends")]
      owned get
        {
          …

the following C declaration is (correctly) generated:

GList* folks_backend_store_dup_enabled_backends (FolksBackendStore* self);



However, the get_property method for the class still refers to the property getter by its old name:

static void _vala_folks_backend_store_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	FolksBackendStore * self;
	self = FOLKS_BACKEND_STORE (object);
	switch (property_id) {
		case FOLKS_BACKEND_STORE_ENABLED_BACKENDS:
		g_value_set_pointer (value, folks_backend_store_get_enabled_backends (self));
		break;

Everything else seems to use the new name of the C getter function correctly, though.
Comment 1 Jürg Billeter 2011-02-08 17:08:08 UTC
commit b0a3014bbe40b96ea543853060d4faeb41f75cf0
Author: Jürg Billeter <j@bitron.ch>
Date:   Tue Feb 8 09:06:09 2011 +0100

    codegen: Fix property accessor definitions with custom cname
    
    Fixes bug 641781.