GNOME Bugzilla – Bug 592993
Templated delegates
Last modified: 2010-10-17 22:23:55 UTC
It should be allowed to declare: namespace Something { public delegate T produce<T>(); class Something<T,G> { public void method(produce<T>, produce<G>); } } In C produce would by of type: void *produce(void *user_data); But type checking would be done in-vala.
commit ac780b92d6b561f422e7935a8a9735464dc1540a Author: Jürg Billeter <j@bitron.ch> Date: Sat Jul 3 09:28:33 2010 +0200 Prepare support for generic delegates
Nice, works good enough for me. I do however get a warning when compiling the code: build/src/components/playlist/playlist_view.c: In function '__lambda16__abraca_selected_rows_mixin_row_iterator_func': build/src/components/playlist/playlist_view.c:984: warning: passing argument 2 of '_lambda16_' makes integer from pointer without a cast build/src/components/playlist/playlist_view.c:976: note: expected 'guint' but argument is of type 'gconstpointer' The code in question is: static void _lambda16_ (gint pos, guint mid, AbracaPlaylistView* self) { AbracaAbraca* _tmp0_; abraca_medialib_info_dialog_add_id (abraca_abraca_get_medialib (_tmp0_ = abraca_abraca_instance ()), mid); _g_object_unref0 (_tmp0_); } static void __lambda16__abraca_selected_rows_mixin_row_iterator_func (gint pos, gconstpointer ret, gpointer self) { _lambda16_ (pos, ret, self); } So the _lambda16_ function has the correct parameter types, but the function that calls it does not convert/cast the variable before passing it to the target function. Is vala supposed to generate two functions in this case?
I assume I can mark it as RESOLVED FIXED
i'm about to post some test cases that produce incorrect code.. i'll be on a train the next few hours, hope to get it done by then.
(In reply to comment #4) > i'm about to post some test cases that produce incorrect code.. i'll be on a > train the next few hours, hope to get it done by then. And here is the test case: http://26e5a0dc09a889ac.paste.se/
(In reply to comment #5) > (In reply to comment #4) > > i'm about to post some test cases that produce incorrect code.. i'll be on a > > train the next few hours, hope to get it done by then. > > And here is the test case: > http://26e5a0dc09a889ac.paste.se/ What's the problem?
*** Bug 615040 has been marked as a duplicate of this bug. ***