[vala] D-Bus: Fix methods returning GLib.Value in dynamic clients
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] D-Bus: Fix methods returning GLib.Value in dynamic clients
- Date: Sun, 21 Mar 2010 15:23:30 +0000 (UTC)
commit 7a74bdc1d17f27b201e12e27cab33f23c6e29c87
Author: Michal Hruby <michal mhr gmail com>
Date: Sun Mar 21 16:22:15 2010 +0100
D-Bus: Fix methods returning GLib.Value in dynamic clients
codegen/valadbusclientmodule.vala | 53 +++++++++++++++++++++----------------
1 files changed, 30 insertions(+), 23 deletions(-)
---
diff --git a/codegen/valadbusclientmodule.vala b/codegen/valadbusclientmodule.vala
index 990f8e3..f3c97c3 100644
--- a/codegen/valadbusclientmodule.vala
+++ b/codegen/valadbusclientmodule.vala
@@ -416,37 +416,44 @@ internal class Vala.DBusClientModule : DBusModule {
// structs are returned via out parameter
var st = (Struct) method.return_type.data_type;
- var cdecl = new CCodeDeclaration ("GValueArray*");
- cdecl.add_declarator (new CCodeVariableDeclarator ("dbus_result"));
- block.add_statement (cdecl);
+ if (st.get_full_name () == "GLib.Value") {
+ ccall.add_argument (new CCodeIdentifier ("result"));
+ ccall.add_argument (new CCodeIdentifier ("G_TYPE_INVALID"));
- int i = 0;
- foreach (Field f in st.get_fields ()) {
- if (f.binding != MemberBinding.INSTANCE) {
- continue;
- }
+ block.add_statement (new CCodeExpressionStatement (ccall));
+ } else {
+ var cdecl = new CCodeDeclaration ("GValueArray*");
+ cdecl.add_declarator (new CCodeVariableDeclarator ("dbus_result"));
+ block.add_statement (cdecl);
- var cget_call = new CCodeFunctionCall (new CCodeIdentifier (f.field_type.data_type.get_get_value_function ()));
- cget_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeElementAccess (new CCodeMemberAccess.pointer (new CCodeIdentifier ("dbus_result"), "values"), new CCodeConstant (i.to_string ()))));
+ int i = 0;
+ foreach (Field f in st.get_fields ()) {
+ if (f.binding != MemberBinding.INSTANCE) {
+ continue;
+ }
- var converted_value = cget_call;
+ var cget_call = new CCodeFunctionCall (new CCodeIdentifier (f.field_type.data_type.get_get_value_function ()));
+ cget_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeElementAccess (new CCodeMemberAccess.pointer (new CCodeIdentifier ("dbus_result"), "values"), new CCodeConstant (i.to_string ()))));
- if (requires_copy (f.field_type)) {
- var dupexpr = get_dup_func_expression (f.field_type, expr.source_reference);
- converted_value = new CCodeFunctionCall (dupexpr);
- converted_value.add_argument (cget_call);
- }
+ var converted_value = cget_call;
- var assign = new CCodeAssignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("result"), f.name), converted_value);
- out_marshalling_fragment.append (new CCodeExpressionStatement (assign));
+ if (requires_copy (f.field_type)) {
+ var dupexpr = get_dup_func_expression (f.field_type, expr.source_reference);
+ converted_value = new CCodeFunctionCall (dupexpr);
+ converted_value.add_argument (cget_call);
+ }
- i++;
- }
+ var assign = new CCodeAssignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("result"), f.name), converted_value);
+ out_marshalling_fragment.append (new CCodeExpressionStatement (assign));
- ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("dbus_result")));
- ccall.add_argument (new CCodeIdentifier ("G_TYPE_INVALID"));
+ i++;
+ }
- block.add_statement (new CCodeExpressionStatement (ccall));
+ ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("dbus_result")));
+ ccall.add_argument (new CCodeIdentifier ("G_TYPE_INVALID"));
+
+ block.add_statement (new CCodeExpressionStatement (ccall));
+ }
// don't access result when error occured
var creturnblock = new CCodeBlock ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]