[vala] D-Bus: Fix dbus-glib servers
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] D-Bus: Fix dbus-glib servers
- Date: Thu, 7 Oct 2010 21:03:29 +0000 (UTC)
commit 4fd230d24c3d5fef67ca1fcbe6bb8ad9ee650cdf
Author: Jürg Billeter <j bitron ch>
Date: Thu Oct 7 23:02:11 2010 +0200
D-Bus: Fix dbus-glib servers
codegen/valaccodebasemodule.vala | 3 +--
codegen/valadbusservermodule.vala | 12 ++++--------
codegen/valagdbusmodule.vala | 4 ----
codegen/valagtypemodule.vala | 36 +++++++++++++++++++-----------------
4 files changed, 24 insertions(+), 31 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 71368d8..fb52bf8 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -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) {
diff --git a/codegen/valadbusservermodule.vala b/codegen/valadbusservermodule.vala
index 1a0ffd7..e1325a5 100644
--- a/codegen/valadbusservermodule.vala
+++ b/codegen/valadbusservermodule.vala
@@ -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);
}
}
diff --git a/codegen/valagdbusmodule.vala b/codegen/valagdbusmodule.vala
index 0fff2c1..55aece2 100644
--- a/codegen/valagdbusmodule.vala
+++ b/codegen/valagdbusmodule.vala
@@ -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 ();
- }
}
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index f85a3ed..a09551f 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]