summaryrefslogtreecommitdiff
path: root/valadoc
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2018-09-17 12:23:52 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2018-11-25 11:03:58 +0100
commit9d827dd744d425bd7a39df7fa19def6c3a4398ea (patch)
tree8a1ba4fd7b293d03558c6356d13a939968229fef /valadoc
parent77c480431bc87350b592a5c1c836be6e9bb9e63c (diff)
downloadvala-9d827dd744d425bd7a39df7fa19def6c3a4398ea.tar.gz
libvaladoc: Drop AttributeArgument
Diffstat (limited to 'valadoc')
-rw-r--r--valadoc/doclets/gtkdoc/generator.vala16
-rw-r--r--valadoc/tests/drivers/generic-api-test.vala27
-rw-r--r--valadoc/treebuilder.vala66
3 files changed, 26 insertions, 83 deletions
diff --git a/valadoc/doclets/gtkdoc/generator.vala b/valadoc/doclets/gtkdoc/generator.vala
index 6e389d7b7..5be0b746f 100644
--- a/valadoc/doclets/gtkdoc/generator.vala
+++ b/valadoc/doclets/gtkdoc/generator.vala
@@ -1339,21 +1339,21 @@ It is important that your <link linkend="GValue"><type>GValue</type></link> hold
if (sym.is_deprecated) {
Attribute? version;
Attribute? deprecated;
- AttributeArgument? deprecated_since;
- AttributeArgument? replacement;
+ string? deprecated_since;
+ string? replacement;
if ((version = sym.get_attribute ("Version")) != null) {
- deprecated_since = version.get_argument ("deprecated_since");
- replacement = version.get_argument ("replacement");
+ deprecated_since = ((Vala.Attribute) version.data).get_string ("deprecated_since");
+ replacement = ((Vala.Attribute) version.data).get_string ("replacement");
} else if ((deprecated = sym.get_attribute ("Deprecated")) != null) {
- deprecated_since = deprecated.get_argument ("since");
- replacement = deprecated.get_argument ("replacement");
+ deprecated_since = ((Vala.Attribute) deprecated.data).get_string ("since");
+ replacement = ((Vala.Attribute) deprecated.data).get_string ("replacement");
} else {
assert_not_reached ();
}
string? since = null;
if (deprecated_since != null) {
- since = deprecated_since.value;
+ since = deprecated_since;
// Strip surrounding quotation marks.
if (since.has_prefix ("\"")) {
@@ -1368,7 +1368,7 @@ It is important that your <link linkend="GValue"><type>GValue</type></link> hold
Api.Node? replacement_symbol = null;
if (replacement != null) {
- replacement_symbol_name = replacement.value;
+ replacement_symbol_name = replacement;
// Strip surrounding quotation marks.
if (replacement_symbol_name.has_prefix ("\"")) {
diff --git a/valadoc/tests/drivers/generic-api-test.vala b/valadoc/tests/drivers/generic-api-test.vala
index 789b0e009..24ef6954f 100644
--- a/valadoc/tests/drivers/generic-api-test.vala
+++ b/valadoc/tests/drivers/generic-api-test.vala
@@ -2579,6 +2579,11 @@ public static void version_test (Api.Namespace ns, Api.Package pkg) {
Api.TypeReference? ret = m.return_type;
assert (ret != null);
+ Api.Attribute? dattr = m.get_attribute ("Deprecated");
+ Api.Attribute? vattr = m.get_attribute ("Version");
+ Vala.Attribute? attr_deprecated = (dattr != null ? dattr.data as Vala.Attribute : null);
+ Vala.Attribute? attr_version = (vattr != null ? vattr.data as Vala.Attribute : null);
+
switch (m.name) {
case "test_function_1":
assert (m.get_attribute ("Deprecated") != null);
@@ -2588,8 +2593,8 @@ public static void version_test (Api.Namespace ns, Api.Package pkg) {
break;
case "test_function_2":
- assert (m.get_attribute ("Deprecated").get_argument ("since").get_value_as_string () == "\"1.0\"");
- assert (m.get_attribute ("Deprecated").get_argument ("replacement").get_value_as_string () == "\"test_function_4\"");
+ assert (attr_deprecated.get_string ("since") == "1.0");
+ assert (attr_deprecated.get_string ("replacement") == "test_function_4");
assert (m.is_deprecated == true);
func2 = true;
@@ -2602,45 +2607,45 @@ public static void version_test (Api.Namespace ns, Api.Package pkg) {
break;
case "test_function_4":
- assert (m.get_attribute ("Version").get_argument ("since").get_value_as_string () == "\"2.0\"");
+ assert (attr_version.get_string ("since") == "2.0");
assert (m.is_deprecated == false);
func4 = true;
break;
case "test_function_5":
- assert (m.get_attribute ("Version").get_argument ("deprecated").get_value_as_boolean () == true);
+ assert (attr_version.get_bool ("deprecated") == true);
assert (m.is_deprecated == true);
func5 = true;
break;
case "test_function_6":
- assert (m.get_attribute ("Version").get_argument ("deprecated").get_value_as_boolean () == true);
- assert (m.get_attribute ("Version").get_argument ("deprecated_since").get_value_as_string () == "\"2.0\"");
- assert (m.get_attribute ("Version").get_argument ("replacement").get_value_as_string () == "\"test_function_4\"");
- assert (m.get_attribute ("Version").get_argument ("since").get_value_as_string () == "\"1.0\"");
+ assert (attr_version.get_bool ("deprecated") == true);
+ assert (attr_version.get_string ("deprecated_since") == "2.0");
+ assert (attr_version.get_string ("replacement") == "test_function_4");
+ assert (attr_version.get_string ("since") == "1.0");
assert (m.is_deprecated == true);
func6 = true;
break;
case "test_function_7":
- assert (m.get_attribute ("Version").get_argument ("deprecated_since").get_value_as_string () == "\"2.0\"");
+ assert (attr_version.get_string ("deprecated_since") == "2.0");
assert (m.is_deprecated == true);
func7 = true;
break;
case "test_function_8":
- assert (m.get_attribute ("Version").get_argument ("deprecated").get_value_as_boolean () == false);
+ assert (attr_version.get_bool ("deprecated") == false);
assert (m.is_deprecated == false);
func8 = true;
break;
case "test_function_9":
- //assert (m.get_attribute ("Version").get_argument ("experimental").get_value_as_boolean () == true);
+ //assert (attr_version.get_bool ("experimental") == true);
func9 = true;
break;
diff --git a/valadoc/treebuilder.vala b/valadoc/treebuilder.vala
index 40cffb474..b81d01613 100644
--- a/valadoc/treebuilder.vala
+++ b/valadoc/treebuilder.vala
@@ -213,71 +213,9 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
//
private void process_attributes (Api.Symbol parent, GLib.List<Vala.Attribute> lst) {
- // attributes without arguments:
- string[] attributes = {
- "ReturnsModifiedPointer",
- "DestroysInstance",
- "GenericAccessors",
- "NoAccessorMethod",
- "SingleInstance",
- "NoArrayLength",
- "Experimental",
- "Diagnostics",
- "PrintfFormat",
- "PointerType",
- "ScanfFormat",
- "ThreadLocal",
- "SimpleType",
- "HasEmitter",
- "ModuleInit",
- "NoWrapper",
- "Immutable",
- "ErrorBase",
- "NoReturn",
- "NoThrow",
- "Compact",
- "Assert",
- "Flags"
- };
-
- string? tmp = "";
-
foreach (Vala.Attribute att in lst) {
- if (att.name == "CCode" && (tmp = att.args.get ("has_target")) != null && tmp == "false") {
- Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att);
- new_attribute.add_boolean ("has_target", false, att);
- parent.add_attribute (new_attribute);
- } else if (att.name == "Version") {
- Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att);
- if ((tmp = att.args.get ("deprecated")) != null) {
- new_attribute.add_boolean ("deprecated", bool.parse (tmp), att);
- }
- if ((tmp = att.args.get ("since")) != null) {
- new_attribute.add_string ("since", tmp, att);
- }
- if ((tmp = att.args.get ("deprecated_since")) != null) {
- new_attribute.add_string ("deprecated_since", tmp, att);
- if (att.args.get ("deprecated") == null) {
- new_attribute.add_boolean ("deprecated", true, att);
- }
- }
- if ((tmp = att.args.get ("replacement")) != null) {
- new_attribute.add_string ("replacement", tmp, att);
- }
- parent.add_attribute (new_attribute);
- } else if (att.name == "Deprecated") {
- Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att);
- if ((tmp = att.args.get ("since")) != null) {
- new_attribute.add_string ("since", tmp, att);
- }
- if ((tmp = att.args.get ("replacement")) != null) {
- new_attribute.add_string ("replacement", tmp, att);
- }
- parent.add_attribute (new_attribute);
- } else if (att.name in attributes) {
- Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att);
- parent.add_attribute (new_attribute);
- }
+ Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att);
+ parent.add_attribute (new_attribute);
}
}