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 629691 - Shared length parameter generates invalid C code
Shared length parameter generates invalid C code
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
0.9.x
Other Linux
: Normal major
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks: 629676
 
 
Reported: 2010-09-14 17:40 UTC by Philip Withnall
Modified: 2010-09-15 21:10 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Philip Withnall 2010-09-14 17:40:48 UTC
I've got some Vala:

          this.conn.request_handles (-1, HandleType.CONTACT, contacts,
            (c, ht, h, i, e, w) =>
              {
                try
                  {
                    this.change_favourites_by_request_handles ((Handle[]) h, i,
                        e, true);
                  }
                catch (GLib.Error e)
                  {
                    warning ("couldn't get list of favourite contacts: %s",
                        e.message);
                  }
              },
            this);

where this.conn.request_handles() is defined by the following VAPI:

	public async void request_handles (int timeout_ms, TelepathyGLib.HandleType handle_type, [CCode (array_length = false)] string[] ids, [CCode (delegate_target_pos = 4.33333)] owned TelepathyGLib.ConnectionRequestHandlesCb callback, GLib.Object weak_object);

	[CCode (cheader_filename = "telepathy-glib/telepathy-glib.h", instance_pos = 5.9)]
	public delegate void ConnectionRequestHandlesCb (TelepathyGLib.Connection connection, TelepathyGLib.HandleType handle_type, [CCode (array_length_pos = 2.5)] uint[] handles, [CCode (array_length_pos = 2.5)] string[] ids, GLib.Error error, GLib.Object weak_object);

When this is compiled, the following C code is generated:

Call:

tp_connection_request_handles (data->self->priv->conn, -1, TP_HANDLE_TYPE_CONTACT, data->contacts, __lambda7__tp_connection_request_handles_cb, g_object_ref (data->self), g_object_unref, (GObject*) data->self, NULL, NULL);

Callback:

static void _lambda7_ (TpConnection* c, TpHandleType ht, guint* h, int h_length1, char** i, int i_length1, GError* e, TpfPersonaStore* self, GObject* w);

static void __lambda7__tp_connection_request_handles_cb (TpConnection* connection, TpHandleType handle_type, int ids_length1, guint* handles, char** ids, GError* _error_, gpointer self, GObject* weak_object) {
	_lambda7_ (connection, handle_type, handles, handles_length1, ids, ids_length1, _error_, self, weak_object);
}

The length parameter for ids and handles in the callback should be the ids_length1 parameter in both cases (it's shared), but Vala's trying to use a non-existent handles_length1 variable for the length of handles.

The second problem is that Vala's adding two extraneous NULL parameters to the call to tp_connection_request_handles().

Overall, this is resulting in the following errors from gcc:

tpf-persona-store.c: In function ‘__lambda7__tp_connection_request_handles_cb’:
tpf-persona-store.c:774: error: ‘handles_length1’ undeclared (first use in this function)
tpf-persona-store.c:774: error: (Each undeclared identifier is reported only once
tpf-persona-store.c:774: error: for each function it appears in.)
tpf-persona-store.c: In function ‘tpf_persona_store_initialise_favourite_contacts_co’:
tpf-persona-store.c:825: error: too many arguments to function ‘tp_connection_request_handles’
Comment 1 Philip Withnall 2010-09-14 17:41:15 UTC
This is with the 0.10-gir branch (http://git.gnome.org/browse/vala/commit/?h=0.10-gir&id=65fde53c99728fd406422d3193f6cf898f3a162d).
Comment 2 Jürg Billeter 2010-09-15 21:10:11 UTC
commit 288baf24219ed0e3ad7f15b44ef7b2369bb80c74
Author: Jürg Billeter <j@bitron.ch>
Date:   Wed Sep 15 20:09:16 2010 +0200

    girparser: Set array_length_cname
    
    Fixes bug 629691.