From: Rico Tzschichholz Date: Wed, 19 Sep 2018 19:19:46 +0000 (+0200) Subject: dbusgen: Implement org.gtk.GDBus.C.ForceGVariant X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8dfd930f7eb90774693ac2c51fdf0196181f1bea;p=thirdparty%2Fvala.git dbusgen: Implement org.gtk.GDBus.C.ForceGVariant --- 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 and 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"); }