]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
WIP dbusgen: Add namespace options
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 20 Sep 2018 08:57:10 +0000 (10:57 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 29 Apr 2023 19:00:17 +0000 (21:00 +0200)
dbusgen/valadbusgen.vala
dbusgen/valadbusnamespacestrategy.vala
dbusgen/valadbusparser.vala
dbusgen/valadbusvariantmodule.vala
doc/valadbusgen.1

index f0ceb2bc1c1fceba78bc48c6afd7ce23469492ba..e659e01894aa8a7a7b4921aa426b20c7640d3ef3 100644 (file)
@@ -29,7 +29,7 @@ public class Vala.DBusGen {
        public class ConcatenationStrategy : NamespaceStrategy {
 
                public override string? get_namespace (string ns) {
-                       return null;
+                       return root_name;
                }
 
                public override string get_name (string ns) {
@@ -58,6 +58,11 @@ public class Vala.DBusGen {
        [CCode (array_length = false, array_null_terminated = true)]
        static string[] packages;
        static int dbus_timeout = 120000;
+       static string root_namespace;
+       [CCode (array_length = false, array_null_terminated = true)]
+       static string[] rename_namespaces;
+       [CCode (array_length = false, array_null_terminated = true)]
+       static string[] strip_namespaces;
 
        CodeContext context;
 
@@ -66,6 +71,9 @@ public class Vala.DBusGen {
                { "pkg", 0, 0, OptionArg.STRING_ARRAY, ref packages, "Include binding for PACKAGE", "PACKAGE..." },
                { "directory", 'd', 0, OptionArg.FILENAME, ref directory, "Output directory", "DIRECTORY" },
                { "disable-warnings", 0, 0, OptionArg.NONE, ref disable_warnings, "Disable warnings", null },
+               { "namespace", 'n', 0, OptionArg.STRING, ref root_namespace, "Name of the parent namespace", null },
+               { "rename-namespace", 0, 0, OptionArg.STRING_ARRAY, ref rename_namespaces, "Namespace to rename to", "SOURCE_NS:TARGET_NS..." },
+               { "strip-namespace", 0, 0, OptionArg.STRING_ARRAY, ref strip_namespaces, "Namespace to strip", "NAMESPACE..." },
                { "dbus-timeout", 0, 0, OptionArg.INT, ref dbus_timeout, "DBus timeout", null },
                { "version", 0, 0, OptionArg.NONE, ref version, "Display version number", null },
                { "quiet", 'q', 0, OptionArg.NONE, ref quiet_mode, "Do not print messages to the console", null },
@@ -152,7 +160,9 @@ public class Vala.DBusGen {
 
                var parser = new DBusParser ();
                parser.dbus_timeout = dbus_timeout;
-               parser.namespace_strategy = new ConcatenationStrategy ();
+               parser.namespace_strategy = new ConcatenationStrategy () {
+                       root_name = root_namespace
+               };
                parser.parse (context);
 
                if (context.report.get_errors () > 0) {
index 3c95f1b6e819e05a7d451fe7be868c900fef5e3f..fc85d9ec9ec78f11f181d4031f2d3d39352788cf 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 public abstract class Vala.NamespaceStrategy {
+       public string root_name { get; set; }
 
        public abstract string? get_namespace (string ns);
 
index 816913fbe0b43cc5f286d6d875dd2edc6d25c8de..9b9287aabc4c12cd2b34b1b34cb6d56cedff0d02 100644 (file)
@@ -127,7 +127,7 @@ public class Vala.DBusParser : CodeVisitor {
                }
 
                string? ns_name = namespace_strategy.get_namespace (name);
-               if (ns_name != null) {
+               if (ns_name != null && current_ns.name != ns_name) {
                        var ns = new Namespace (ns_name, get_current_src ());
                        current_ns.add_namespace (ns);
                        current_ns = ns;
index 42b08780acad63766eb564ad3b2a601950593887..38d1a4a8a6095dbe8994b614ed9d07deabc82ff3 100644 (file)
@@ -188,6 +188,8 @@ public class Vala.DBusVariantModule {
                                        return array;
                                }
                        }
+               } else if (type.equal (VariantType.TUPLE)) {
+                       
                }
 
                Report.warning (null, "Unresolved type: %s".printf ((string) type.peek_string ()));
index a0404f7ef9daffbd4f522d4501be3e5e9c305d87..07d8e82eab658eb8890134fec774950a49803606 100644 (file)
@@ -29,6 +29,15 @@ Output directory
 \fB\-\-disable\-warnings\fR
 Disable warnings
 .TP
+\fB\-n\fR, \fB\-\-namespace\fR
+Name of the parent namespace
+.TP
+\fB\-\-rename\-namespace\fR=\fI\,SOURCE_NS\/\fR:TARGET_NS...
+Namespace to rename to
+.TP
+\fB\-\-strip\-namespace\fR=\fI\,NAMESPACE\/\fR...
+Namespace to strip
+.TP
 \fB\-\-dbus\-timeout\fR
 DBus timeout
 .TP