]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Work around missing enum support in dbus-glib
authorJürg Billeter <j@bitron.ch>
Sun, 9 Nov 2008 23:12:41 +0000 (23:12 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Sun, 9 Nov 2008 23:12:41 +0000 (23:12 +0000)
2008-11-10  Jürg Billeter  <j@bitron.ch>

* gobject/valadbusservermodule.vala:

Work around missing enum support in dbus-glib

svn path=/trunk/; revision=2008

ChangeLog
gobject/valadbusservermodule.vala

index d945bb92fc81bf587ff83ebc7be3b9ba2101b150..0d7530e0e75e5bc476313525126fbbeb688353fa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-11-10  Jürg Billeter  <j@bitron.ch>
+
+       * gobject/valadbusservermodule.vala:
+
+       Work around missing enum support in dbus-glib
+
 2008-11-10  Jürg Billeter  <j@bitron.ch>
 
        * gobject/valadbusservermodule.vala:
index 5b1a8d7c2f574aee1bcbff7c932a0e4dcfd68ba7..67c16e2e96d83b6af38266d4d130467aae601556 100644 (file)
@@ -255,12 +255,27 @@ public class Vala.DBusServerModule : DBusClientModule {
 
                        var val_ptr = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (val_name));
 
+                       string type_id = f.field_type.data_type.get_type_id ();
+                       string set_value_function = f.field_type.data_type.get_set_value_function ();
+
+                       if (f.field_type.data_type is Enum) {
+                               // dbus-glib does not support enums
+                               var en = (Enum) f.field_type.data_type;
+                               if (!en.is_flags) {
+                                       type_id = "G_TYPE_INT";
+                                       set_value_function = "g_value_set_int";
+                               } else {
+                                       type_id = "G_TYPE_UINT";
+                                       set_value_function = "g_value_set_uint";
+                               }
+                       }
+
                        var cinit_call = new CCodeFunctionCall (new CCodeIdentifier ("g_value_init"));
                        cinit_call.add_argument (val_ptr);
-                       cinit_call.add_argument (new CCodeIdentifier (f.field_type.data_type.get_type_id ()));
+                       cinit_call.add_argument (new CCodeIdentifier (type_id));
                        block.add_statement (new CCodeExpressionStatement (cinit_call));
 
-                       var cset_call = new CCodeFunctionCall (new CCodeIdentifier (f.field_type.data_type.get_set_value_function ()));
+                       var cset_call = new CCodeFunctionCall (new CCodeIdentifier (set_value_function));
                        cset_call.add_argument (val_ptr);
                        if (f.field_type.data_type is Struct) {
                                cset_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeMemberAccess (st_expr, f.name)));