From 64d55a77d981dea2b89667a0cb1716aaeec98be7 Mon Sep 17 00:00:00 2001 From: Juerg Billeter Date: Mon, 6 Aug 2007 20:23:49 +0000 Subject: [PATCH] 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 --- ChangeLog | 5 +++++ gobject/valacodegeneratorinvocationexpression.vala | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/ChangeLog b/ChangeLog index 24205f6..c9e4dd3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 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 destruction diff --git a/gobject/valacodegeneratorinvocationexpression.vala b/gobject/valacodegeneratorinvocationexpression.vala index 7a43287..888f794 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")); + } + } } } } -- 2.7.4