vala r1567 - in trunk: . gobject
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1567 - in trunk: . gobject
- Date: Wed, 11 Jun 2008 12:52:25 +0000 (UTC)
Author: juergbi
Date: Wed Jun 11 12:52:24 2008
New Revision: 1567
URL: http://svn.gnome.org/viewvc/vala?rev=1567&view=rev
Log:
2008-06-11 JÃrg Billeter <j bitron ch>
* gobject/valaccodedynamicmethodbinding.vala:
Support array parameters in D-Bus client methods
Modified:
trunk/ChangeLog
trunk/gobject/valaccodedynamicmethodbinding.vala
Modified: trunk/gobject/valaccodedynamicmethodbinding.vala
==============================================================================
--- trunk/gobject/valaccodedynamicmethodbinding.vala (original)
+++ trunk/gobject/valaccodedynamicmethodbinding.vala Wed Jun 11 12:52:24 2008
@@ -188,7 +188,37 @@
continue;
}
- if (param.parameter_type.get_type_signature ().has_prefix ("(")) {
+ var array_type = param.parameter_type as ArrayType;
+ if (array_type != null) {
+ // 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));
+
+ var array_construct = new CCodeFunctionCall (new CCodeIdentifier ("g_array_new"));
+ array_construct.add_argument (new CCodeConstant ("TRUE"));
+ array_construct.add_argument (new CCodeConstant ("TRUE"));
+ var sizeof_call = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
+ sizeof_call.add_argument (new CCodeIdentifier (array_type.element_type.get_cname ()));
+ array_construct.add_argument (sizeof_call);
+
+ var cdecl = new CCodeDeclaration ("GArray*");
+ cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer ("dbus_%s".printf (param.name), array_construct));
+ block.add_statement (cdecl);
+
+ var cappend_call = new CCodeFunctionCall (new CCodeIdentifier ("g_array_append_vals"));
+ cappend_call.add_argument (new CCodeIdentifier ("dbus_%s".printf (param.name)));
+ cappend_call.add_argument (new CCodeIdentifier (param.name));
+ cappend_call.add_argument (new CCodeIdentifier (codegen.get_array_length_cname (param.name, 1)));
+ block.add_statement (new CCodeExpressionStatement (cappend_call));
+
+ ccall.add_argument (new CCodeIdentifier ("dbus_%s".printf (param.name)));
+ } else {
+ // string arrays
+ ccall.add_argument (new CCodeIdentifier ("G_TYPE_STRV"));
+ ccall.add_argument (new CCodeIdentifier (param.name));
+ }
+ } else if (param.parameter_type.get_type_signature ().has_prefix ("(")) {
// struct parameter
var st = (Struct) param.parameter_type.data_type;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]