[vala/wip/dbusgen: 70/78] dbusgen: Add DBus signature attribute if type is not supported yet
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/dbusgen: 70/78] dbusgen: Add DBus signature attribute if type is not supported yet
- Date: Thu, 16 Jan 2020 16:14:09 +0000 (UTC)
commit 7b011d6ed5cc99e0c149870bbe3289b860f36ae6
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Sep 19 19:13:18 2018 +0200
dbusgen: Add DBus signature attribute if type is not supported yet
dbusgen/valadbusparser.vala | 18 ++++++++++++++++++
dbusgen/valadbusvariantmodule.vala | 24 +++++++++++++++++-------
2 files changed, 35 insertions(+), 7 deletions(-)
---
diff --git a/dbusgen/valadbusparser.vala b/dbusgen/valadbusparser.vala
index e265d08a8..fa1e4b0e8 100644
--- a/dbusgen/valadbusparser.vala
+++ b/dbusgen/valadbusparser.vala
@@ -347,7 +347,12 @@ public class Vala.DBusParser : CodeVisitor {
return;
}
+ var needs_signature = false;
var data_type = dbus_module.get_dbus_type (type);
+ if (data_type == null) {
+ data_type = dbus_module.gvariant_type.copy ();
+ needs_signature = true;
+ }
PropertyAccessor get_access = null;
PropertyAccessor set_access = null;
@@ -369,6 +374,10 @@ 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) {
@@ -396,12 +405,21 @@ public class Vala.DBusParser : CodeVisitor {
return;
}
+ var needs_signature = false;
var data_type = dbus_module.get_dbus_type (type);
+ if (data_type == null) {
+ data_type = dbus_module.gvariant_type.copy ();
+ needs_signature = true;
+ }
data_type.value_owned = false;
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") {
diff --git a/dbusgen/valadbusvariantmodule.vala b/dbusgen/valadbusvariantmodule.vala
index df69a2c15..fdb57f7c2 100644
--- a/dbusgen/valadbusvariantmodule.vala
+++ b/dbusgen/valadbusvariantmodule.vala
@@ -120,7 +120,7 @@ public class Vala.DBusVariantModule {
}
}
- private DataType get_variant_type (VariantType type) {
+ private DataType? get_variant_type (VariantType type) {
if (type.is_basic ()) {
if (type.equal (VariantType.BOOLEAN)) {
return bool_type.copy ();
@@ -155,16 +155,26 @@ public class Vala.DBusVariantModule {
return get_complex_type (type);
}
- private DataType get_complex_type (VariantType type) {
+ private DataType? get_complex_type (VariantType type) {
if (type.is_array ()) {
var element = type.element ();
if (element.equal (VariantType.DICTIONARY) || element.is_dict_entry ()) {
var res = dictionary_type.copy ();
- res.add_type_argument (get_variant_type (element.key ()));
- res.add_type_argument (get_variant_type (element.value ()));
- return res;
+ var key = get_variant_type (element.key ());
+ var value = get_variant_type (element.value ());
+ if (key != null && value != null) {
+ res.add_type_argument (key);
+ res.add_type_argument (value);
+ return res;
+ }
+ } else {
+ var element_type = get_variant_type (element);
+ if (element != null && !(element_type is ArrayType)) {
+ var array = new ArrayType (element_type, 1, null);
+ array.value_owned = true;
+ return array;
+ }
}
- return new ArrayType (get_variant_type (element), 1, null);
} else if (type.equal (VariantType.BYTESTRING)) {
return string_type.copy (); //new ArrayType (uchar_type.copy (), 1, null);
} else if (type.equal (VariantType.BYTESTRING_ARRAY)) {
@@ -177,7 +187,7 @@ public class Vala.DBusVariantModule {
Report.warning (null, "Unresolved type: %s".printf ((string) type.peek_string ()));
- return gvariant_type.copy ();
+ return null;
if (type.equal (VariantType.DICT_ENTRY) || type.is_dict_entry ()) {
return dictionary_type.copy ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]