From 08d3b1fdceda1feb10094587fc420bb5865b1a63 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrg=20Billeter?= Date: Wed, 11 Jun 2008 13:04:23 +0000 Subject: [PATCH] Support arrays of string arrays in D-Bus client methods MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2008-06-11 Jürg Billeter * gobject/valaccodedynamicmethodbinding.vala: Support arrays of string arrays in D-Bus client methods svn path=/trunk/; revision=1568 --- ChangeLog | 6 ++++++ gobject/valaccodedynamicmethodbinding.vala | 26 ++++++++++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 511a957..16e11f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,12 @@ * gobject/valaccodedynamicmethodbinding.vala: + Support arrays of string arrays in D-Bus client methods + +2008-06-11 Jürg Billeter + + * gobject/valaccodedynamicmethodbinding.vala: + Support array parameters in D-Bus client methods 2008-06-10 Jürg Billeter diff --git a/gobject/valaccodedynamicmethodbinding.vala b/gobject/valaccodedynamicmethodbinding.vala index 6618cf9..9e9d98e 100644 --- a/gobject/valaccodedynamicmethodbinding.vala +++ b/gobject/valaccodedynamicmethodbinding.vala @@ -136,7 +136,7 @@ public class Vala.CCodeDynamicMethodBinding : CCodeMethodBinding { var cdecl = new CCodeDeclaration ("GArray*"); cdecl.add_declarator (new CCodeVariableDeclarator (param.name)); cb_fun.block.add_statement (cdecl); - cend_call.add_argument (get_dbus_array_type (array_type)); + cend_call.add_argument (get_dbus_g_type (array_type)); cend_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (param.name))); creply_call.add_argument (new CCodeMemberAccess.pointer (new CCodeIdentifier (param.name), "data")); creply_call.add_argument (new CCodeMemberAccess.pointer (new CCodeIdentifier (param.name), "len")); @@ -193,7 +193,7 @@ public class Vala.CCodeDynamicMethodBinding : CCodeMethodBinding { // array parameter if (array_type.element_type.data_type != codegen.string_type.data_type) { // non-string arrays (use GArray) - ccall.add_argument (get_dbus_array_type (array_type)); + ccall.add_argument (get_dbus_g_type (array_type)); var array_construct = new CCodeFunctionCall (new CCodeIdentifier ("g_array_new")); array_construct.add_argument (new CCodeConstant ("TRUE")); @@ -332,7 +332,7 @@ public class Vala.CCodeDynamicMethodBinding : CCodeMethodBinding { var array_type = method.return_type as ArrayType; if (array_type != null && array_type.element_type.data_type != codegen.string_type.data_type) { // non-string arrays (use GArray) - ccall.add_argument (get_dbus_array_type (array_type)); + ccall.add_argument (get_dbus_g_type (array_type)); var garray_type_reference = codegen.get_data_type_for_symbol (codegen.garray_type); var cdecl = new CCodeDeclaration (garray_type_reference.get_cname ()); @@ -396,13 +396,19 @@ public class Vala.CCodeDynamicMethodBinding : CCodeMethodBinding { } } - CCodeExpression get_dbus_array_type (ArrayType array_type) { - if (array_type.element_type.data_type == null) { - Report.error (array_type.source_reference, "internal error: unsupported array type for use with D-Bus"); + CCodeExpression get_dbus_g_type (DataType data_type) { + var array_type = data_type as ArrayType; + if (array_type != null) { + if (array_type.element_type.data_type == codegen.string_type.data_type) { + return new CCodeIdentifier ("G_TYPE_STRV"); + } + + var carray_type = new CCodeFunctionCall (new CCodeIdentifier ("dbus_g_type_get_collection")); + carray_type.add_argument (new CCodeConstant ("\"GArray\"")); + carray_type.add_argument (get_dbus_g_type (array_type.element_type)); + return carray_type; + } else { + return new CCodeIdentifier (data_type.data_type.get_type_id ()); } - var carray_type = new CCodeFunctionCall (new CCodeIdentifier ("dbus_g_type_get_collection")); - carray_type.add_argument (new CCodeConstant ("\"GArray\"")); - carray_type.add_argument (new CCodeIdentifier (array_type.element_type.data_type.get_type_id ())); - return carray_type; } } -- 2.7.4