diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2018-09-17 12:23:52 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2018-11-25 11:03:58 +0100 |
commit | 9d827dd744d425bd7a39df7fa19def6c3a4398ea (patch) | |
tree | 8a1ba4fd7b293d03558c6356d13a939968229fef /libvaladoc | |
parent | 77c480431bc87350b592a5c1c836be6e9bb9e63c (diff) | |
download | vala-9d827dd744d425bd7a39df7fa19def6c3a4398ea.tar.gz |
libvaladoc: Drop AttributeArgument
Diffstat (limited to 'libvaladoc')
-rw-r--r-- | libvaladoc/Makefile.am | 1 | ||||
-rw-r--r-- | libvaladoc/api/attribute.vala | 75 | ||||
-rw-r--r-- | libvaladoc/api/attributeargument.vala | 132 | ||||
-rw-r--r-- | libvaladoc/api/symbol.vala | 18 | ||||
-rw-r--r-- | libvaladoc/html/basicdoclet.vala | 19 |
5 files changed, 47 insertions, 198 deletions
diff --git a/libvaladoc/Makefile.am b/libvaladoc/Makefile.am index 29386d473..413d12dd1 100644 --- a/libvaladoc/Makefile.am +++ b/libvaladoc/Makefile.am @@ -55,7 +55,6 @@ libvaladoc_la_VALASOURCES = \ importer/internalidregistrar.vala \ api/sourcecomment.vala \ api/girsourcecomment.vala \ - api/attributeargument.vala \ api/attribute.vala \ api/array.vala \ api/callable.vala \ diff --git a/libvaladoc/api/attribute.vala b/libvaladoc/api/attribute.vala index b80a1b52c..befdfe95d 100644 --- a/libvaladoc/api/attribute.vala +++ b/libvaladoc/api/attribute.vala @@ -24,7 +24,6 @@ using Valadoc.Content; public class Valadoc.Api.Attribute : Item { - private Vala.ArrayList<AttributeArgument> args = new Vala.ArrayList<AttributeArgument> (); private SourceFile file; public string name { @@ -40,42 +39,6 @@ public class Valadoc.Api.Attribute : Item { this.file = file; } - public AttributeArgument? get_argument (string name) { - if (args != null) { - foreach (AttributeArgument arg in args) { - if (arg.name == name) { - return arg; - } - } - } - - return null; - } - - public AttributeArgument add_boolean (string name, bool value, Vala.Attribute data) { - AttributeArgument arg = new AttributeArgument.boolean (this, file, name, value, data); - args.add (arg); - return arg; - } - - public AttributeArgument add_integer (string name, int value, Vala.Attribute data) { - AttributeArgument arg = new AttributeArgument.integer (this, file, name, value, data); - args.add (arg); - return arg; - } - - public AttributeArgument add_double (string name, double value, Vala.Attribute data) { - AttributeArgument arg = new AttributeArgument.double (this, file, name, value, data); - args.add (arg); - return arg; - } - - public AttributeArgument add_string (string name, string value, Vala.Attribute data) { - AttributeArgument arg = new AttributeArgument.string (this, file, name, value, data); - args.add (arg); - return arg; - } - public SourceFile get_source_file () { return file; } @@ -83,23 +46,45 @@ public class Valadoc.Api.Attribute : Item { protected override Inline build_signature () { SignatureBuilder builder = new SignatureBuilder (); + unowned Vala.Attribute attr = (Vala.Attribute) data; + + var keys = new GLib.Sequence<string> (); + foreach (var key in attr.args.get_keys ()) { + if (key == "cheader_filename") { + continue; + } + keys.insert_sorted (key, (CompareDataFunc<string>) strcmp); + } + + if (attr.name == "CCode" && keys.get_length () == 0) { + // only cheader_filename on namespace + return builder.get (); + } + builder.append_attribute ("["); - builder.append_type_name (name); + builder.append_type_name (attr.name); - if (args.size > 0) { + if (keys.get_length () > 0) { builder.append_attribute ("("); - bool first = true; - foreach (AttributeArgument arg in args) { - if (first == false) { + unowned string separator = ""; + var arg_iter = keys.get_begin_iter (); + while (!arg_iter.is_end ()) { + unowned string arg_name = arg_iter.get (); + arg_iter = arg_iter.next (); + if (separator != "") { builder.append_attribute (", "); } - builder.append_content (arg.signature); - first = false; + if (arg_name != "cheader_filename") { + builder.append_attribute (arg_name); + builder.append_attribute ("="); + builder.append_literal (attr.args.get (arg_name)); + } + separator = ", "; } + builder.append_attribute (")"); } - builder.append_attribute ("]"); return builder.get (); diff --git a/libvaladoc/api/attributeargument.vala b/libvaladoc/api/attributeargument.vala deleted file mode 100644 index 374b3d6fc..000000000 --- a/libvaladoc/api/attributeargument.vala +++ /dev/null @@ -1,132 +0,0 @@ -/* attributeargument.vala - * - * Copyright (C) 2011 Florian Brosch - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Author: - * Florian Brosch <flo.brosch@gmail.com> - */ - - -using Valadoc.Content; - -public class Valadoc.Api.AttributeArgument : Item { - public enum Type { - BOOLEAN, - INTEGER, - DOUBLE, - STRING - } - - private SourceFile file; - - public string name { - private set; - get; - } - - public AttributeArgument.Type argument_type { - private set; - get; - } - - public string value { - private set; - get; - } - - public AttributeArgument.boolean (Attribute parent, SourceFile file, string name, bool value, Vala.Attribute data) { - this (parent, file, name, Type.BOOLEAN, value.to_string (), data); - } - - public AttributeArgument.integer (Attribute parent, SourceFile file, string name, int value, Vala.Attribute data) { - this (parent, file, name, Type.INTEGER, value.to_string (), data); - } - - public AttributeArgument.double (Attribute parent, SourceFile file, string name, double value, Vala.Attribute data) { - this (parent, file, name, Type.DOUBLE, value.to_string (), data); - } - - public AttributeArgument.string (Attribute parent, SourceFile file, string name, string value, Vala.Attribute data) { - this (parent, file, name, Type.STRING, value, data); - } - - private AttributeArgument (Attribute parent, SourceFile file, string name, Type type, string value, Vala.Attribute data) { - base (data); - - this.argument_type = type; - this.parent = parent; - this.value = value; - this.file = file; - this.name = name; - } - - public SourceFile get_source_file () { - return file; - } - - public bool get_value_as_boolean () { - assert (argument_type == Type.BOOLEAN); - - bool tmp; - - if (bool.try_parse (value, out tmp)) { - return tmp; - } - - assert_not_reached (); - } - - public int get_value_as_integer () { - assert (argument_type == Type.INTEGER); - - double tmp; - - if (global::double.try_parse (value, out tmp) && tmp >= int.MIN && tmp <= int.MAX) { - return (int) tmp; - } - - assert_not_reached (); - } - - public double get_value_as_double () { - assert (argument_type == Type.DOUBLE); - - double tmp; - - if (global::double.try_parse (value, out tmp)) { - return tmp; - } - - assert_not_reached (); - } - - public string get_value_as_string () { - assert (argument_type == Type.STRING); - - return value; - } - - protected override Inline build_signature () { - SignatureBuilder builder = new SignatureBuilder (); - - builder.append_attribute (name); - builder.append_attribute ("="); - builder.append_literal (value); - - return builder.get (); - } -} diff --git a/libvaladoc/api/symbol.vala b/libvaladoc/api/symbol.vala index 7acc29bc5..22466981e 100644 --- a/libvaladoc/api/symbol.vala +++ b/libvaladoc/api/symbol.vala @@ -49,21 +49,19 @@ public abstract class Valadoc.Api.Symbol : Node { attributes = new Vala.ArrayList<Attribute> (); } + Vala.Attribute attr = (Vala.Attribute) att.data; + // register deprecated symbols: if (att.name == "Version") { - AttributeArgument? deprecated = att.get_argument ("deprecated"); - AttributeArgument? version = att.get_argument ("deprecated_since"); - if ((deprecated != null && deprecated.get_value_as_boolean ()) || version != null) { - string? version_str = (version != null) ? version.get_value_as_string () : null; - - package.register_deprecated_symbol (this, version_str); + var deprecated = attr.get_bool ("deprecated"); + var version = attr.get_string ("deprecated_since"); + if (deprecated || version != null) { + package.register_deprecated_symbol (this, version); is_deprecated = true; } } else if (att.name == "Deprecated") { - AttributeArgument? version = att.get_argument ("version"); - string? version_str = (version != null) ? version.get_value_as_string () : null; - - package.register_deprecated_symbol (this, version_str); + var version = attr.get_string ("version"); + package.register_deprecated_symbol (this, version); is_deprecated = true; } diff --git a/libvaladoc/html/basicdoclet.vala b/libvaladoc/html/basicdoclet.vala index 192e488cd..acd94cf5f 100644 --- a/libvaladoc/html/basicdoclet.vala +++ b/libvaladoc/html/basicdoclet.vala @@ -473,14 +473,14 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { Symbol symbol = (Symbol) element; Attribute? version; Attribute? deprecated; - AttributeArgument? replacement; - AttributeArgument? since; + string? replacement; + string? since; if ((version = symbol.get_attribute ("Version")) != null) { - replacement = version.get_argument ("replacement"); - since = version.get_argument ("deprecated_since"); + replacement = ((Vala.Attribute) version.data).get_string ("replacement"); + since = ((Vala.Attribute) version.data).get_string ("deprecated_since"); } else if ((deprecated = symbol.get_attribute ("Deprecated")) != null) { - replacement = deprecated.get_argument ("replacement"); - since = deprecated.get_argument ("version"); + replacement = ((Vala.Attribute) deprecated.data).get_string ("replacement"); + since = ((Vala.Attribute) deprecated.data).get_string ("version"); } else { assert_not_reached (); } @@ -492,19 +492,18 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { writer.text (" %s is deprecated".printf (element.name)); if (since != null) { - writer.text (" since %s".printf (since.get_value_as_string ())); + writer.text (" since %s".printf (since)); } writer.text ("."); if (replacement != null) { - string replacement_name = replacement.get_value_as_string (); Api.Node? replacement_node = tree.search_symbol_str (pos, - replacement_name.substring (1, replacement_name.length - 2)); + replacement.substring (1, replacement.length - 2)); writer.text (" Use "); if (replacement_node == null) { - writer.text (replacement_name); + writer.text (replacement); } else { string? link = get_link (replacement_node, pos); if (link != null) { |