From: Jürg Billeter Date: Tue, 19 Oct 2010 06:23:24 +0000 (+0200) Subject: D-Bus: Use builder API for interface_method_call in GDBus servers X-Git-Tag: 0.11.1~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=516bc7994ab52255811dfeffd315861b5a04ed8d;p=thirdparty%2Fvala.git D-Bus: Use builder API for interface_method_call in GDBus servers --- diff --git a/codegen/valagdbusservermodule.vala b/codegen/valagdbusservermodule.vala index 7bb9a4313..4e28f366b 100644 --- a/codegen/valagdbusservermodule.vala +++ b/codegen/valagdbusservermodule.vala @@ -556,20 +556,12 @@ public class Vala.GDBusServerModule : GDBusClientModule { cfunc.modifiers |= CCodeModifiers.STATIC; - cfile.add_function_declaration (cfunc); + push_function (cfunc); - var block = new CCodeBlock (); - cfunc.block = block; + ccode.add_declaration ("gpointer*", new CCodeVariableDeclarator ("data", new CCodeIdentifier ("user_data"))); + ccode.add_declaration ("gpointer", new CCodeVariableDeclarator ("object", new CCodeElementAccess (new CCodeIdentifier ("data"), new CCodeConstant ("0")))); - var cdecl = new CCodeDeclaration ("gpointer*"); - cdecl.add_declarator (new CCodeVariableDeclarator ("data", new CCodeIdentifier ("user_data"))); - block.add_statement (cdecl); - - cdecl = new CCodeDeclaration ("gpointer"); - cdecl.add_declarator (new CCodeVariableDeclarator ("object", new CCodeElementAccess (new CCodeIdentifier ("data"), new CCodeConstant ("0")))); - block.add_statement (cdecl); - - CCodeIfStatement clastif = null; + bool first = true; foreach (Method m in sym.get_methods ()) { if (m is CreationMethod || m.binding != MemberBinding.INSTANCE @@ -584,25 +576,25 @@ public class Vala.GDBusServerModule : GDBusClientModule { ccheck.add_argument (new CCodeIdentifier ("method_name")); ccheck.add_argument (new CCodeConstant ("\"%s\"".printf (get_dbus_name_for_member (m)))); - var callblock = new CCodeBlock (); + if (first) { + ccode.open_if (new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, ccheck, new CCodeConstant ("0"))); + first = false; + } else { + ccode.else_if (new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, ccheck, new CCodeConstant ("0"))); + } var ccall = new CCodeFunctionCall (new CCodeIdentifier (generate_dbus_wrapper (m, sym))); ccall.add_argument (new CCodeIdentifier ("object")); ccall.add_argument (new CCodeIdentifier ("parameters")); ccall.add_argument (new CCodeIdentifier ("invocation")); + ccode.add_expression (ccall); + } - callblock.add_statement (new CCodeExpressionStatement (ccall)); - - var cif = new CCodeIfStatement (new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, ccheck, new CCodeConstant ("0")), callblock); - if (clastif == null) { - block.add_statement (cif); - } else { - clastif.false_statement = cif; - } + ccode.close (); - clastif = cif; - } + pop_function (); + cfile.add_function_declaration (cfunc); cfile.add_function (cfunc); }