[vala/wip/dbusgen: 76/78] WIP dbusgen: Add namespace options
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/dbusgen: 76/78] WIP dbusgen: Add namespace options
- Date: Thu, 16 Jan 2020 16:14:39 +0000 (UTC)
commit 3e3fd0ebd888e42bae29203d20d4ab02ec6c5ee6
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Sep 20 10:57:10 2018 +0200
WIP dbusgen: Add namespace options
dbusgen/valadbusgen.vala | 14 ++++++++++++--
dbusgen/valadbusnamespacestrategy.vala | 1 +
dbusgen/valadbusparser.vala | 2 +-
dbusgen/valadbusvariantmodule.vala | 2 ++
doc/valadbusgen.1 | 9 +++++++++
5 files changed, 25 insertions(+), 3 deletions(-)
---
diff --git a/dbusgen/valadbusgen.vala b/dbusgen/valadbusgen.vala
index 098e0ebbe..b89d80459 100644
--- a/dbusgen/valadbusgen.vala
+++ b/dbusgen/valadbusgen.vala
@@ -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) {
@@ -59,6 +59,11 @@ public class Vala.DBusGen {
static string[] packages;
static bool nostdpkg;
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;
@@ -68,6 +73,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 },
@@ -155,7 +163,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) {
diff --git a/dbusgen/valadbusnamespacestrategy.vala b/dbusgen/valadbusnamespacestrategy.vala
index 3c95f1b6e..fc85d9ec9 100644
--- a/dbusgen/valadbusnamespacestrategy.vala
+++ b/dbusgen/valadbusnamespacestrategy.vala
@@ -21,6 +21,7 @@
*/
public abstract class Vala.NamespaceStrategy {
+ public string root_name { get; set; }
public abstract string? get_namespace (string ns);
diff --git a/dbusgen/valadbusparser.vala b/dbusgen/valadbusparser.vala
index 816913fbe..9b9287aab 100644
--- a/dbusgen/valadbusparser.vala
+++ b/dbusgen/valadbusparser.vala
@@ -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;
diff --git a/dbusgen/valadbusvariantmodule.vala b/dbusgen/valadbusvariantmodule.vala
index 42b08780a..38d1a4a8a 100644
--- a/dbusgen/valadbusvariantmodule.vala
+++ b/dbusgen/valadbusvariantmodule.vala
@@ -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 ()));
diff --git a/doc/valadbusgen.1 b/doc/valadbusgen.1
index 738509d57..c5e03cd4b 100644
--- a/doc/valadbusgen.1
+++ b/doc/valadbusgen.1
@@ -32,6 +32,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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]