[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Vala] Code generation error



On Jan 3, 2008 11:47 PM, Jürg Billeter <j bitron ch> wrote:
> Hi Daniel,
> > But _tmp1 will be declared in __lambda0 function and not in the
> > function it's used.
>
> I can't reproduce the bug here, do you have a stand-alone testcase?

This vala code:

		private void on_playlist_insert(Client c, string playlist, uint mid,
int pos) {
			Gtk.ListStore store = (Gtk.ListStore) model;
			Gtk.TreePath path;
			Gtk.TreeIter iter;

			if (playlist != _playlist) {
				return;
			}

			path = new Gtk.TreePath.from_indices(pos, -1);
			if (model.get_iter(out iter, path)) {
				Gtk.TreeIter added;

				store.insert_before (out added, iter);

				c.xmms.medialib_get_info(mid).notifier_set( (r, u) => {
					GLib.stdout.printf("apan\n");
				});
			}


Generates this C-code, notice where _tmp2 is defined:

static void __lambda0 (xmmsc_result_t* r, gpointer u) {
	xmmsc_result_t* _tmp2;
	_tmp2 = NULL;
	fprintf (stdout, "apan\n");
	(_tmp2 == NULL ? NULL : (_tmp2 = (xmmsc_result_unref (_tmp2), NULL)));
}


static void abraca_playlist_tree_on_playlist_insert (AbracaClient* c,
const char* playlist, guint mid, gint pos, AbracaPlaylistTree* self) {
	GtkListStore* _tmp0;
	GtkListStore* store;
	GtkTreePath* path;
	GtkTreeIter iter;
	GtkTreePath* _tmp1;
	g_return_if_fail (ABRACA_IS_PLAYLIST_TREE (self));
	g_return_if_fail (c == NULL || ABRACA_IS_CLIENT (c));
	_tmp0 = NULL;
	store = (_tmp0 = GTK_LIST_STORE (gtk_tree_view_get_model
(GTK_TREE_VIEW (self))), (_tmp0 == NULL ? NULL : g_object_ref
(_tmp0)));
	path = NULL;
	memset (&iter, 0, sizeof (GtkTreeIter));
	if (g_utf8_collate (playlist, self->priv->_playlist) != 0) {
		(store == NULL ? NULL : (store = (g_object_unref (store), NULL)));
		(path == NULL ? NULL : (path = (gtk_tree_path_free (path), NULL)));
		return;
	}
	_tmp1 = NULL;
	path = (_tmp1 = gtk_tree_path_new_from_indices (pos, -1, NULL), (path
== NULL ? NULL : (path = (gtk_tree_path_free (path), NULL))), _tmp1);
	if (gtk_tree_model_get_iter (gtk_tree_view_get_model (GTK_TREE_VIEW
(self)), &iter, path)) {
		GtkTreeIter added;
		memset (&added, 0, sizeof (GtkTreeIter));
		gtk_list_store_insert_before (store, &added, iter);
		xmmsc_result_notifier_set ((_tmp2 = xmmsc_medialib_get_info
(abraca_client_get_xmms (c), mid)), ((xmmsc_result_notifier_t)
__lambda0), NULL);
	}
	(store == NULL ? NULL : (store = (g_object_unref (store), NULL)));
	(path == NULL ? NULL : (path = (gtk_tree_path_free (path), NULL)));
}

Which then ofc gives this errror when gcc enters the game:

playlist_tree.c: In function 'abraca_playlist_tree_on_playlist_insert':
playlist_tree.c:181: error: incompatible type for argument 3 of
'gtk_list_store_insert_before'
playlist_tree.c:182: error: '_tmp2' undeclared (first use in this function)
playlist_tree.c:182: error: (Each undeclared identifier is reported only once
playlist_tree.c:182: error: for each function it appears in.)

This is Vala 0.1.5, so maybe this mail is just stupid. I don't suppose
there are any snapshot builds of vala for ubuntu gutsy?

-- 
Daniel Svensson


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]