On Sat, Jul 10, 2010 at 19:20:34 +0000, Peterpaul Klein Haneveld wrote:
> ---
> start of EnumTest.vala:
> enum EnumTest {TEST1, TEST2, TEST3}
>
> void
> main() {
> EnumClass enumClass = (EnumClass) typeof
> (EnumTest).class_ref();
> unowned EnumValue[] falues =
> enumClass.values;
> for (int i = 0; i < falues.length; i++) {
I believe vala supports foreach-style syntax here, but I am not certain
enough of the exact syntax to write it off the top of my head.
> unowned EnumValue falue = falues[i];
> stdout.printf("%s",
> falue.value_name);
> }
> }
> --- end of EnumTest.vala.
>
> $ valac EnumTest.vala
> /home/peterpaul/projects/vala/EnumTest.vala.c:
> In function ‘_vala_main’:
> /home/peterpaul/projects/vala/EnumTest.vala.c:45:
> warning: assignment from incompatible pointer type
> /home/peterpaul/projects/vala/EnumTest.vala.c:45:
> error: ‘GEnumClass’ has no member named ‘values_length1’
> error: cc
> exited with status 256
> Compilation failed: 1 error(s), 0 warning(s)
The warning can be safely ignored I believe (though it is a bug in valac --
it should know to emit correct cast). The error is caused by error in the
bindings.
The GLib.EnumClass.values member in gobject-2.0.vapi needs annotation:
[CCode (array_length_cname = "n_values", array_length_type = "guint")]
(the same annotation is correctly used in other places in the file, e.g. the
ValueArray class).
The Glib.FlagsClass.values member needs the same annotation, too.
--
Jan 'Bulb' Hudec <[email protected]>
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list