On Sun, Apr 04, 2010 at 10:09:24 -0700, Tristin Celestin wrote:
> Is there a means to figure out what kinds of variables a Gee.List stores?
> 
> The following doesn't work because if I call mystery_list.get(0), I get
> the compiler error: has no member named ‘g_destroy_func’.

Hm, that's bad compiler error. It should tell you that Gee.List is generic
and can't be used without the type parameter.

> using Gee;
> 
> public bool perform (Gee.List mystery_list) {
>     if (! mystery_list.is_empty) {
>         Value val = mystery_list.get (0);
>         if (val.type().is_value_type) {
>             // something something
>         }
>     }
> }
> 
> If I cast mystery_list to Gee.List <Object>, my problem is solved (because
> now a destructor is available), but then that means that mystery list
> can only contain items descended from GObject.

The list can't contain types not derived from common base. Simply because it
does not have any per-element type tag. It only has one for the whole list
(the type parameter).

If you really wanted to have a list of mixed non-Object items, you can get it
by creating a list of GLib.Value (it's a struct, so you'll have to box it by
writing Value?). Value can store anything and knows what it stores.

-- 
                                                 Jan 'Bulb' Hudec <[email protected]>
_______________________________________________
Vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to