From: Juerg Billeter Date: Mon, 6 Aug 2007 20:23:49 +0000 (+0000) Subject: support D-Bus replies with string arrays X-Git-Tag: VALA_0_1_3~130 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64d55a77d981dea2b89667a0cb1716aaeec98be7;p=thirdparty%2Fvala.git support D-Bus replies with string arrays 2007-08-06 Juerg Billeter * gobject/valacodegeneratorinvocationexpression.vala: support D-Bus replies with string arrays svn path=/trunk/; revision=424 --- diff --git a/ChangeLog b/ChangeLog index 24205f631..c9e4dd33f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-08-06 Jürg Billeter + + * gobject/valacodegeneratorinvocationexpression.vala: support D-Bus + replies with string arrays + 2007-08-06 Jürg Billeter * gobject/valacodegenerator.vala: cleanup and fix GList and GSList diff --git a/gobject/valacodegeneratorinvocationexpression.vala b/gobject/valacodegeneratorinvocationexpression.vala index 7a432870d..888f7940b 100644 --- a/gobject/valacodegeneratorinvocationexpression.vala +++ b/gobject/valacodegeneratorinvocationexpression.vala @@ -178,6 +178,12 @@ public class Vala.CodeGenerator { cb_fun.block.add_statement (cdecl); cend_call.add_argument (new CCodeIdentifier (param.type_reference.data_type.get_type_id ())); cend_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (param.name))); + if (param.type_reference.data_type is Array && ((Array) param.type_reference.data_type).element_type == string_type.data_type) { + // special case string array + var cstrvlen = new CCodeFunctionCall (new CCodeIdentifier ("g_strv_length")); + cstrvlen.add_argument (new CCodeIdentifier (param.name)); + creply_call.add_argument (cstrvlen); + } creply_call.add_argument (new CCodeIdentifier (param.name)); } } @@ -394,6 +400,7 @@ public class Vala.CodeGenerator { expr.ccodenode = ccomma; } else if (m is DBusMethod && m.return_type.data_type != null) { + // synchronous D-Bus method call with reply if (m.return_type.data_type is Array && ((Array) m.return_type.data_type).element_type != string_type.data_type) { var array = (Array) m.return_type.data_type; @@ -430,6 +437,17 @@ public class Vala.CodeGenerator { ccomma.append_expression (ccall); ccomma.append_expression (new CCodeIdentifier (temp_decl.name)); expr.ccodenode = ccomma; + + if (m.return_type.data_type is Array && ((Array) m.return_type.data_type).element_type == string_type.data_type) { + // special case string array + if (!m.no_array_length) { + var cstrvlen = new CCodeFunctionCall (new CCodeIdentifier ("g_strv_length")); + cstrvlen.add_argument (new CCodeIdentifier (temp_decl.name)); + expr.append_array_size (cstrvlen); + } else { + expr.append_array_size (new CCodeConstant ("-1")); + } + } } } }