[vala/wip/dbusgen: 397/403] dbusgen: Implement org.gtk.GDBus.C.ForceGVariant




commit 0edc3f2313d7b9e6f46a7132b27950736204499e
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 fa1e4b0e8..f33ac5f11 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
@@ -374,10 +380,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) {
@@ -388,6 +390,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");
        }
 
@@ -416,10 +422,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") {
@@ -440,6 +442,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]