[vala] D-Bus: Support array properties in servers
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Subject: [vala] D-Bus: Support array properties in servers
- Date: Sun, 14 Jun 2009 10:35:02 -0400 (EDT)
commit 6aaa5869989db75a507decd1440601524b53c26f
Author: Jürg Billeter <j bitron ch>
Date: Sun Jun 14 15:47:21 2009 +0200
D-Bus: Support array properties in servers
Fixes bug 585434.
codegen/valadbusmodule.vala | 10 ++++++++++
codegen/valadbusservermodule.vala | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valadbusmodule.vala b/codegen/valadbusmodule.vala
index 5e7fe11..81ed0d7 100644
--- a/codegen/valadbusmodule.vala
+++ b/codegen/valadbusmodule.vala
@@ -62,10 +62,20 @@ internal class Vala.DBusModule : GAsyncModule {
CCodeExpression? get_array_length (CCodeExpression expr, int dim) {
var id = expr as CCodeIdentifier;
var ma = expr as CCodeMemberAccess;
+ var call = expr as CCodeFunctionCall;
if (id != null) {
return new CCodeIdentifier ("%s_length%d".printf (id.name, dim));
} else if (ma != null) {
return new CCodeMemberAccess.pointer (ma.inner, "%s_length%d".printf (ma.member_name, dim));
+ } else if (call != null) {
+ // array property
+ var args = call.get_arguments ();
+ if (args.size > 0) {
+ var arg = args[args.size - 1] as CCodeUnaryExpression;
+ if (arg != null && arg.operator == CCodeUnaryOperator.ADDRESS_OF) {
+ return arg.inner;
+ }
+ }
}
return null;
}
diff --git a/codegen/valadbusservermodule.vala b/codegen/valadbusservermodule.vala
index 51154c9..4862f50 100644
--- a/codegen/valadbusservermodule.vala
+++ b/codegen/valadbusservermodule.vala
@@ -567,6 +567,19 @@ internal class Vala.DBusServerModule : DBusClientModule {
var ccall = new CCodeFunctionCall (new CCodeIdentifier (prop.get_accessor.get_cname ()));
ccall.add_argument (new CCodeIdentifier ("self"));
+ var array_type = prop.property_type as ArrayType;
+ if (array_type != null) {
+ for (int dim = 1; dim <= array_type.rank; dim++) {
+ string length_name = "_tmp%d_".printf (next_temp_var_id++);
+
+ cdecl = new CCodeDeclaration ("int");
+ cdecl.add_declarator (new CCodeVariableDeclarator (length_name));
+ postfragment.append (cdecl);
+
+ ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (length_name)));
+ }
+ }
+
write_expression (postfragment, prop.property_type, new CCodeIdentifier ("subiter"), ccall);
iter_call = new CCodeFunctionCall (new CCodeIdentifier ("dbus_message_iter_close_container"));
@@ -733,6 +746,19 @@ internal class Vala.DBusServerModule : DBusClientModule {
var ccall = new CCodeFunctionCall (new CCodeIdentifier (prop.get_accessor.get_cname ()));
ccall.add_argument (new CCodeIdentifier ("self"));
+ var array_type = prop.property_type as ArrayType;
+ if (array_type != null) {
+ for (int dim = 1; dim <= array_type.rank; dim++) {
+ string length_name = "_tmp%d_".printf (next_temp_var_id++);
+
+ cdecl = new CCodeDeclaration ("int");
+ cdecl.add_declarator (new CCodeVariableDeclarator (length_name));
+ postfragment.append (cdecl);
+
+ ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (length_name)));
+ }
+ }
+
write_expression (postfragment, prop.property_type, new CCodeIdentifier ("value_iter"), ccall);
iter_call = new CCodeFunctionCall (new CCodeIdentifier ("dbus_message_iter_close_container"));
@@ -873,6 +899,17 @@ internal class Vala.DBusServerModule : DBusClientModule {
ccall.add_argument (new CCodeIdentifier ("self"));
ccall.add_argument (new CCodeIdentifier ("value"));
+ var array_type = prop.property_type as ArrayType;
+ if (array_type != null) {
+ for (int dim = 1; dim <= array_type.rank; dim++) {
+ cdecl = new CCodeDeclaration ("int");
+ cdecl.add_declarator (new CCodeVariableDeclarator (head.get_array_length_cname ("value", dim)));
+ prefragment.append (cdecl);
+
+ ccall.add_argument (new CCodeIdentifier (head.get_array_length_cname ("value", dim)));
+ }
+ }
+
prop_block.add_statement (new CCodeExpressionStatement (ccall));
var cif = new CCodeIfStatement (ccheck, prop_block);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]