I've entered a bug in the database (
http://bugzilla.gnome.org/show_bug.cgi?id=580513) but am posting here
because this problem blocks me from transitioning to Vala 0.7, which I would
like to do.
In my code, a delegate returns an enum. In valac's generated C code, the
delegate is typedef'd before the enum, which the compiler obviously doesn't
like.
There's a twist to all of this. It will only compile under 0.6.1 if the
enum is in a different file as the delegate declaration (because the enum is
declared in a separate, guarded .h file). Even separating the two, this
code will not compile in 0.7.1.
If anyone can suggest a workaround until this is fixed, it would be greatly
appreciated.
Here's the vala code:
enum TestEnum {
foo,
bar,
xyzzy,
}
delegate void tdelegate(TestEnum te);
void main() {
}
which 0.7.1 transforms into this C code:
#include <glib.h>
#include <glib-object.h>
#define TYPE_TEST_ENUM (test_enum_get_type ())
// *** Next line generates error: "error: expected β)β before βteβ"
typedef void (*tdelegate) (TestEnum te, void* user_data);
typedef enum {
TEST_ENUM_foo,
TEST_ENUM_bar,
TEST_ENUM_xyzzy
} TestEnum;
GType test_enum_get_type (void);
void _main (void);
GType test_enum_get_type (void) {
static GType test_enum_type_id = 0;
if (G_UNLIKELY (test_enum_type_id == 0)) {
static const GEnumValue values[] = {{TEST_ENUM_foo, "TEST_ENUM_foo",
"foo"}, {TEST_ENUM_bar, "TEST_ENUM_bar", "bar"}, {TEST_ENUM_xyzzy,
"TEST_ENUM_xyzzy", "xyzzy"}, {0, NULL, NULL}};
test_enum_type_id = g_enum_register_static ("TestEnum", values);
}
return test_enum_type_id;
}
void _main (void) {
}
int main (int argc, char ** argv) {
g_type_init ();
_main ();
return 0;
}
Thanks,
-- Jim Nelson
Yorba
_______________________________________________
Vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list