]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
D-Bus: Fix dbus-glib servers
authorJürg Billeter <j@bitron.ch>
Thu, 7 Oct 2010 21:02:11 +0000 (23:02 +0200)
committerJürg Billeter <j@bitron.ch>
Thu, 7 Oct 2010 21:02:11 +0000 (23:02 +0200)
codegen/valaccodebasemodule.vala
codegen/valadbusservermodule.vala
codegen/valagdbusmodule.vala
codegen/valagtypemodule.vala

index 71368d8e2b4010145f2ddf7092195113dce6a7b0..fb52bf8ea5f53ebd0589bb041bae494745ed3618 100644 (file)
@@ -5587,8 +5587,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
                return new CCodeFunctionCall (new CCodeIdentifier (""));
        }
 
-       public virtual CCodeFragment register_dbus_info (ObjectTypeSymbol bindable) {
-               return new CCodeFragment ();
+       public virtual void register_dbus_info (ObjectTypeSymbol bindable) {
        }
 
        public virtual string get_dynamic_property_getter_cname (DynamicProperty node) {
index 1a0ffd70301b487457ae9d58804e68c3518ecd7a..e1325a5077adbcab952022160fc84f98ce2c005b 100644 (file)
@@ -1,6 +1,6 @@
 /* valadbusservermodule.vala
  *
- * Copyright (C) 2007-2009  Jürg Billeter
+ * Copyright (C) 2007-2010  Jürg Billeter
 *  Copyright (C) 2008  Philip Van Hoof
  *
  * This library is free software; you can redistribute it and/or
@@ -1674,11 +1674,9 @@ public class Vala.DBusServerModule : DBusClientModule {
                return false;
        }
 
-       public override CCodeFragment register_dbus_info (ObjectTypeSymbol sym) {
-               CCodeFragment fragment = new CCodeFragment ();
-
+       public override void register_dbus_info (ObjectTypeSymbol sym) {
                if (!type_implements_dbus_interface (sym)) {
-                       return fragment;
+                       return;
                }
 
                var quark = new CCodeFunctionCall (new CCodeIdentifier ("g_quark_from_static_string"));
@@ -1689,8 +1687,6 @@ public class Vala.DBusServerModule : DBusClientModule {
                set_qdata.add_argument (quark);
                set_qdata.add_argument (new CCodeCastExpression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_vtable (new ObjectType (sym))), "void*"));
 
-               fragment.append (new CCodeExpressionStatement (set_qdata));
-
-               return fragment;
+               ccode.add_expression (set_qdata);
        }
 }
index 0fff2c10eafc552f3daef56876b94da22140777b..55aece233dffcdb89e5596b2b41e1d91a2c708fc 100644 (file)
@@ -99,8 +99,4 @@ public class Vala.GDBusModule : GVariantModule {
                cquark_fun.block = cquark_block;
                cfile.add_function (cquark_fun);
        }
-
-       public override CCodeFragment register_dbus_info (ObjectTypeSymbol sym) {
-               return new CCodeFragment ();
-       }
 }
index f85a3ed2546b4e17216a76d735db642ee4af6431..a09551f0446ca6046271ccb58cfc151a754a895b 100644 (file)
@@ -2010,21 +2010,19 @@ public class Vala.GTypeModule : GErrorModule {
        }
 
        private void add_interface_base_init_function (Interface iface) {
+               push_context (new EmitContext (iface));
+
                var base_init = new CCodeFunction ("%s_base_init".printf (iface.get_lower_case_cname (null)), "void");
                base_init.add_parameter (new CCodeFormalParameter ("iface", "%sIface *".printf (iface.get_cname ())));
                base_init.modifiers = CCodeModifiers.STATIC;
-               
-               var init_block = new CCodeBlock ();
-               
+
+               push_function (base_init);
+
                /* make sure not to run the initialization code twice */
-               base_init.block = new CCodeBlock ();
-               var decl = new CCodeDeclaration (bool_type.get_cname ());
-               decl.modifiers |= CCodeModifiers.STATIC;
-               decl.add_declarator (new CCodeVariableDeclarator ("initialized", new CCodeConstant ("FALSE")));
-               base_init.block.add_statement (decl);
-               var cif = new CCodeIfStatement (new CCodeUnaryExpression (CCodeUnaryOperator.LOGICAL_NEGATION, new CCodeIdentifier ("initialized")), init_block);
-               base_init.block.add_statement (cif);
-               init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("initialized"), new CCodeConstant ("TRUE"))));
+               ccode.add_declaration (bool_type.get_cname (), new CCodeVariableDeclarator ("initialized", new CCodeConstant ("FALSE")), CCodeModifiers.STATIC);
+               ccode.open_if (new CCodeUnaryExpression (CCodeUnaryOperator.LOGICAL_NEGATION, new CCodeIdentifier ("initialized")));
+
+               ccode.add_expression (new CCodeAssignment (new CCodeIdentifier ("initialized"), new CCodeConstant ("TRUE")));
 
                if (iface.is_subtype_of (gobject_type)) {
                        /* create properties */
@@ -2036,14 +2034,14 @@ public class Vala.GTypeModule : GErrorModule {
                                        }
 
                                        if (prop.comment != null) {
-                                               init_block.add_statement (new CCodeComment (prop.comment.content));
+                                               ccode.add_statement (new CCodeComment (prop.comment.content));
                                        }
 
                                        var cinst = new CCodeFunctionCall (new CCodeIdentifier ("g_object_interface_install_property"));
                                        cinst.add_argument (new CCodeIdentifier ("iface"));
                                        cinst.add_argument (get_param_spec (prop));
 
-                                       init_block.add_statement (new CCodeExpressionStatement (cinst));
+                                       ccode.add_expression (cinst);
                                }
                        }
                }
@@ -2051,9 +2049,9 @@ public class Vala.GTypeModule : GErrorModule {
                /* create signals */
                foreach (Signal sig in iface.get_signals ()) {
                        if (sig.comment != null) {
-                               init_block.add_statement (new CCodeComment (sig.comment.content));
+                               ccode.add_statement (new CCodeComment (sig.comment.content));
                        }
-                       init_block.add_statement (new CCodeExpressionStatement (get_signal_creation (sig, iface)));
+                       ccode.add_expression (get_signal_creation (sig, iface));
                }
 
                // connect default implementations
@@ -2061,11 +2059,15 @@ public class Vala.GTypeModule : GErrorModule {
                        if (m.is_virtual) {
                                var ciface = new CCodeIdentifier ("iface");
                                var cname = m.get_real_cname ();
-                               base_init.block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess.pointer (ciface, m.vfunc_name), new CCodeIdentifier (cname))));
+                               ccode.add_expression (new CCodeAssignment (new CCodeMemberAccess.pointer (ciface, m.vfunc_name), new CCodeIdentifier (cname)));
                        }
                }
 
-               init_block.add_statement (register_dbus_info (iface));
+               register_dbus_info (iface);
+
+               ccode.close ();
+
+               pop_context ();
 
                cfile.add_function (base_init);
        }