From: JCWasmx86 Date: Sat, 4 Jun 2022 06:27:55 +0000 (+0200) Subject: Added more TODOs and a mitigation measure for duplicate argnames (org.freedesktop... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed2edcab3f5cf5a0c304aebfb06ec518d66f10c8;p=thirdparty%2Fvala.git Added more TODOs and a mitigation measure for duplicate argnames (org.freedesktop.systemd1.Mount) --- diff --git a/dbusgen/tests/test-codegen.xml b/dbusgen/tests/test-codegen.xml index 033cd9c76..f9b8b3a2f 100644 --- a/dbusgen/tests/test-codegen.xml +++ b/dbusgen/tests/test-codegen.xml @@ -61,6 +61,11 @@ + + + + + diff --git a/dbusgen/tests/test-codegen.xml.vala-expected b/dbusgen/tests/test-codegen.xml.vala-expected index e2b8dc894..42c2f32b0 100644 --- a/dbusgen/tests/test-codegen.xml.vala-expected +++ b/dbusgen/tests/test-codegen.xml.vala-expected @@ -6,7 +6,8 @@ public interface OrgProjectBar : GLib.Object { public abstract void hello_world (string greeting, out string response) throws GLib.DBusError, GLib.IOError; public abstract void test_primitive_types (char val_byte, bool val_boolean, int16 val_int16, uint16 val_uint16, int32 val_int32, uint32 val_uint32, int64 val_int64, uint64 val_uint64, double val_double, string val_string, GLib.ObjectPath val_objpath, string val_signature, string val_bytestring, out char ret_byte, out bool ret_boolean, out int16 ret_int16, out uint16 ret_uint16, out int32 ret_int32, out uint32 ret_uint32, out int64 ret_int64, out uint64 ret_uint64, out double ret_double, out string ret_string, out GLib.ObjectPath ret_objpath, out string ret_signature, out string ret_bytestring) throws GLib.DBusError, GLib.IOError; public abstract void test_non_primitive_types (GLib.HashTable dict_s_to_s, [DBus (signature = "a{s(ii)}")] GLib.Variant dict_s_to_pairs, [DBus (signature = "(iss)")] GLib.Variant a_struct, string[] array_of_strings, out string[] ret_array_of_strings, GLib.ObjectPath[] array_of_objpaths, out GLib.ObjectPath[] ret_array_of_objpaths, string[] array_of_signatures, out string[] ret_array_of_signatures, string[] array_of_bytestrings, out string[] ret_array_of_bytestrings, out string result) throws GLib.DBusError, GLib.IOError; - public abstract void request_signal_emission (int32 which_one) throws GLib.DBusError, GLib.IOError; + public abstract void test_duplicate_argname (string arg, out string arg0) throws GLib.DBusError, GLib.IOError; + public abstract void request_signal_emission (int32 which_one) throws GLib.DBusError, GLib.IOError; public abstract void request_multi_property_mods () throws GLib.DBusError, GLib.IOError; public abstract void unimplemented_method () throws GLib.DBusError, GLib.IOError; public abstract void property_cancellation () throws GLib.DBusError, GLib.IOError; diff --git a/dbusgen/valadbusgen.vala b/dbusgen/valadbusgen.vala index dfd616ca3..5daa100bd 100644 --- a/dbusgen/valadbusgen.vala +++ b/dbusgen/valadbusgen.vala @@ -25,7 +25,7 @@ using GLib; public class Vala.DBusGen { - + // TODO: Colored output public class ConcatenationStrategy : NamespaceStrategy { public override string? get_namespace (string ns) { diff --git a/dbusgen/valadbusparser.vala b/dbusgen/valadbusparser.vala index 4acf2d3ef..338be76f2 100644 --- a/dbusgen/valadbusparser.vala +++ b/dbusgen/valadbusparser.vala @@ -51,6 +51,7 @@ public class Vala.DBusParser : CodeVisitor { private SourceLocation end; private HashMap extensions = new HashMap (); + private Set argnames = new HashSet (str_hash, str_equal); public int dbus_timeout { get; set; } @@ -305,7 +306,6 @@ public class Vala.DBusParser : CodeVisitor { private void parse_method () { start_element ("method"); string? name = reader.get_attribute ("name"); - if (name == null) { Report.error (get_current_src (), "Interface method declarations require a name attribute"); return; @@ -340,7 +340,7 @@ public class Vala.DBusParser : CodeVisitor { private void parse_method_body () { current_param_index = 0U; - + argnames.clear (); while (current_token == MarkupTokenType.START_ELEMENT) { switch (reader.name) { case "annotation": @@ -433,7 +433,10 @@ public class Vala.DBusParser : CodeVisitor { string? name = reader.get_attribute ("name"); if (name == null) { name = "arg%u".printf (current_param_index++); + } else if (argnames.contains (name)) { + name = "%s%u".printf (name, current_param_index++); } + argnames.add (name); string? type = reader.get_attribute ("type"); if (type == null) { diff --git a/dbusgen/valadbusvariantmodule.vala b/dbusgen/valadbusvariantmodule.vala index 38d1a4a8a..74dd8c6ee 100644 --- a/dbusgen/valadbusvariantmodule.vala +++ b/dbusgen/valadbusvariantmodule.vala @@ -189,7 +189,7 @@ public class Vala.DBusVariantModule { } } } else if (type.equal (VariantType.TUPLE)) { - + // TODO: Emit structure } Report.warning (null, "Unresolved type: %s".printf ((string) type.peek_string ()));