diff options
author | Abderrahim Kitouni <a.kitouni@gmail.com> | 2016-12-27 16:21:20 +0100 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2017-01-05 20:04:49 +0100 |
commit | 415b300e01b64ba3515179af43a6a9f031a5dba2 (patch) | |
tree | 337b2822695ba7f40f618b56cd990262ef3df42f /codegen/valagdbusservermodule.vala | |
parent | 77f31adac2e27e75f2f046019b6225d7acfa5881 (diff) | |
download | vala-415b300e01b64ba3515179af43a6a9f031a5dba2.tar.gz |
D-Bus: support [DBus (signature = ...)] for properties
This was working for methods and signals, but not for properties.
Also add tests for all cases.
https://bugzilla.gnome.org/show_bug.cgi?id=744595
Diffstat (limited to 'codegen/valagdbusservermodule.vala')
-rw-r--r-- | codegen/valagdbusservermodule.vala | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/codegen/valagdbusservermodule.vala b/codegen/valagdbusservermodule.vala index daf2a629c..617df210b 100644 --- a/codegen/valagdbusservermodule.vala +++ b/codegen/valagdbusservermodule.vala @@ -491,15 +491,21 @@ public class Vala.GDBusServerModule : GDBusClientModule { } } - var reply_expr = serialize_expression (prop.get_accessor.value_type, new CCodeIdentifier ("result")); - ccode.add_declaration ("GVariant*", new CCodeVariableDeclarator ("_reply")); - ccode.add_assignment (new CCodeIdentifier ("_reply"), reply_expr); - if (requires_destroy (prop.get_accessor.value_type)) { - // keep local alive (symbol_reference is weak) - var local = new LocalVariable (prop.get_accessor.value_type, ".result"); - ccode.add_expression (destroy_local (local)); + if (get_dbus_signature (prop) != null) { + // raw GVariant + ccode.add_assignment (new CCodeIdentifier ("_reply"), new CCodeIdentifier("result")); + } else { + var reply_expr = serialize_expression (prop.get_accessor.value_type, new CCodeIdentifier ("result")); + + ccode.add_assignment (new CCodeIdentifier ("_reply"), reply_expr); + + if (requires_destroy (prop.get_accessor.value_type)) { + // keep local alive (symbol_reference is weak) + var local = new LocalVariable (prop.get_accessor.value_type, ".result"); + ccode.add_expression (destroy_local (local)); + } } ccode.add_return (new CCodeIdentifier ("_reply")); @@ -546,15 +552,20 @@ public class Vala.GDBusServerModule : GDBusClientModule { } var target = new CCodeIdentifier ("value"); - var expr = deserialize_expression (prop.property_type, new CCodeIdentifier ("_value"), target); - ccode.add_assignment (target, expr); - ccode.add_expression (ccall); + if (get_dbus_signature (prop) != null) { + ccode.add_assignment (target, new CCodeIdentifier("_value")); + ccode.add_expression (ccall); + } else { + var expr = deserialize_expression (prop.property_type, new CCodeIdentifier ("_value"), target); + ccode.add_assignment (target, expr); + ccode.add_expression (ccall); - if (requires_destroy (owned_type)) { - // keep local alive (symbol_reference is weak) - var local = new LocalVariable (owned_type, "value"); - ccode.add_expression (destroy_local (local)); + if (requires_destroy (owned_type)) { + // keep local alive (symbol_reference is weak) + var local = new LocalVariable (owned_type, "value"); + ccode.add_expression (destroy_local (local)); + } } pop_function (); |