]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
dbusgen: Implement org.gtk.GDBus.C.ForceGVariant
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 19 Sep 2018 19:19:46 +0000 (21:19 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 29 Apr 2023 19:00:17 +0000 (21:00 +0200)
dbusgen/valadbusparser.vala

index fa1e4b0e838a958808710dd082f9f5f11833401e..f33ac5f1178e52fd39a807696d334df7e3155e95 100644 (file)
@@ -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");
        }