[vala/wip/dbusgen: 57/60] dbusgen: Implement org.gtk.GDBus.C.ForceGVariant



commit 124bc32d3fe2e27976a51cb3105225c08c18f8ec
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Wed Sep 19 21:19:46 2018 +0200

    dbusgen: Implement org.gtk.GDBus.C.ForceGVariant

 dbusgen/valadbusparser.vala | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/dbusgen/valadbusparser.vala b/dbusgen/valadbusparser.vala
index 6d38d99ad..81362e0cc 100644
--- a/dbusgen/valadbusparser.vala
+++ b/dbusgen/valadbusparser.vala
@@ -255,7 +255,13 @@ public class Vala.DBusParser : CodeVisitor {
                        case "org.gtk.GDBus.C.ForceGVariant":
                                // If set to a non-empty string, a #GVariant instance will be used instead of 
the natural C type. This annotation can be
                                // used on any <arg> and <property> element.
-                               //TODO
+                               if (current_node is Parameter) {
+                                       var type = dbus_module.gvariant_type.copy ();
+                                       type.value_owned = false;
+                                       ((Parameter) current_node).variable_type = type;
+                               } else if (current_node is Property) {
+                                       ((Property) current_node).property_type = 
dbus_module.gvariant_type.copy ();
+                               }
                                break;
                        case "org.gtk.GDBus.C.UnixFD":
                                // If set to a non-empty string, the generated code will include parameters 
to exchange file descriptors using the
@@ -376,10 +382,6 @@ public class Vala.DBusParser : CodeVisitor {
                current_property.access = SymbolAccessibility.PUBLIC;
                current_iface.add_property (current_property);
 
-               if (needs_signature) {
-                       current_node.set_attribute_string ("DBus", "signature", type);
-               }
-
                next ();
 
                while (current_token == MarkupTokenType.START_ELEMENT) {
@@ -390,6 +392,10 @@ public class Vala.DBusParser : CodeVisitor {
                        }
                }
 
+               if (needs_signature || !current_property.property_type.equals (data_type)) {
+                       current_node.set_attribute_string ("DBus", "signature", type);
+               }
+
                end_element ("property");
        }
 
@@ -418,10 +424,6 @@ public class Vala.DBusParser : CodeVisitor {
                current_node = current_param = new Parameter (name, data_type, get_current_src ());
                current_method.add_parameter (current_param);
 
-               if (needs_signature) {
-                       current_node.set_attribute_string ("DBus", "signature", type);
-               }
-
                if (current_method is Method) {
                        string? direction = reader.get_attribute ("direction");
                        if (direction == "out") {
@@ -442,6 +444,10 @@ public class Vala.DBusParser : CodeVisitor {
                        }
                }
 
+               if (needs_signature || !current_param.variable_type.equals (data_type)) {
+                       current_node.set_attribute_string ("DBus", "signature", type);
+               }
+
                end_element ("arg");
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]