]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Added more TODOs and a mitigation measure for duplicate argnames (org.freedesktop...
authorJCWasmx86 <JCWasmx86@t-online.de>
Sat, 4 Jun 2022 06:27:55 +0000 (08:27 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 29 Apr 2023 19:00:17 +0000 (21:00 +0200)
dbusgen/tests/test-codegen.xml
dbusgen/tests/test-codegen.xml.vala-expected
dbusgen/valadbusgen.vala
dbusgen/valadbusparser.vala
dbusgen/valadbusvariantmodule.vala

index 033cd9c76b9088844be1b2f7f1afa4349a7a35c7..f9b8b3a2f61e7aaf648e0c01505e5b40a7ec5dc6 100644 (file)
       <arg direction="out" type="ay" name="result" />
     </method>
 
+    <method name="TestDuplicateArgname">
+        <arg direction="in" type="s" name="arg" />
+        <arg direction="out" type="s" name="arg" />
+    </method>
+
     <method name="RequestSignalEmission">
       <arg direction="in" type="i" name="which_one" />
     </method>
index e2b8dc89454e4530b7a2c91a757a6733154efbb8..42c2f32b01a102c87659f70c607b099f91f29d8a 100644 (file)
@@ -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<string,string> 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;
index dfd616ca300e2ca0d0435feed5eb95c0eefc3d25..5daa100bd044a446220ecd3c681f7e00ed26c871 100644 (file)
@@ -25,7 +25,7 @@
 using GLib;
 
 public class Vala.DBusGen {
-
+       // TODO: Colored output
        public class ConcatenationStrategy : NamespaceStrategy {
 
                public override string? get_namespace (string ns) {
index 4acf2d3ef935b24090cbf5aa3360ed00fb79c406..338be76f20c596bd70b3931a08cd58cd939bd353 100644 (file)
@@ -51,6 +51,7 @@ public class Vala.DBusParser : CodeVisitor {
        private SourceLocation end;
 
        private HashMap<string, DBusExtension> extensions = new HashMap<string, DBusExtension> ();
+       private Set<string> argnames = new HashSet<string> (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) {
index 38d1a4a8a6095dbe8994b614ed9d07deabc82ff3..74dd8c6ee30c0a618c1b6cf15928f53bad957711 100644 (file)
@@ -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 ()));