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 592993 - Templated delegates
Templated delegates
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Delegates
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: Vala maintainers
Vala maintainers
: 615040 (view as bug list)
Depends on:
Blocks: 589968 624005
 
 
Reported: 2009-08-25 09:23 UTC by Maciej (Matthew) Piechotka
Modified: 2010-10-17 22:23 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Maciej (Matthew) Piechotka 2009-08-25 09:23:32 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.
Comment 1 Jürg Billeter 2010-07-10 07:30:16 UTC
commit ac780b92d6b561f422e7935a8a9735464dc1540a
Author: Jürg Billeter <j@bitron.ch>
Date:   Sat Jul 3 09:28:33 2010 +0200

    Prepare support for generic delegates
Comment 2 Daniel Svensson 2010-08-02 19:37:32 UTC
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?
Comment 3 Maciej (Matthew) Piechotka 2010-08-18 22:52:44 UTC
I assume I can mark it as RESOLVED FIXED
Comment 4 Daniel Svensson 2010-08-19 07:43:33 UTC
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.
Comment 5 Daniel Svensson 2010-08-19 10:24:37 UTC
(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/
Comment 6 Maciej (Matthew) Piechotka 2010-08-19 12:38:38 UTC
(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?
Comment 7 Maciej (Matthew) Piechotka 2010-10-17 22:23:55 UTC
*** Bug 615040 has been marked as a duplicate of this bug. ***