[vala/staging: 19/22] libvaladoc: Clean up Api.TypeSymbol constructor



commit 5b7dda57d8b1ef6b91cf3e51d091c41f78d906cf
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun Nov 25 13:17:54 2018 +0100

    libvaladoc: Clean up Api.TypeSymbol constructor

 libvaladoc/api/class.vala       |  5 +---
 libvaladoc/api/delegate.vala    |  2 +-
 libvaladoc/api/enum.vala        |  7 +++--
 libvaladoc/api/errordomain.vala |  2 +-
 libvaladoc/api/interface.vala   |  6 ++---
 libvaladoc/api/struct.vala      |  7 +++--
 libvaladoc/api/typesymbol.vala  | 59 +++++++++++++++++++++++++++--------------
 valadoc/treebuilder.vala        | 52 ------------------------------------
 8 files changed, 50 insertions(+), 90 deletions(-)
---
diff --git a/libvaladoc/api/class.vala b/libvaladoc/api/class.vala
index c5712a94a..9c003e8ab 100644
--- a/libvaladoc/api/class.vala
+++ b/libvaladoc/api/class.vala
@@ -47,14 +47,11 @@ public class Valadoc.Api.Class : TypeSymbol {
 
        public Class (Node parent, SourceFile file, string name, Vala.SymbolAccessibility accessibility,
                                  SourceComment? comment,
-                                 string? type_macro_name, string? is_type_macro_name, string? 
type_cast_macro_name,
-                                 string? type_function_name,
                                  Vala.Class data)
        {
                bool is_basic_type = data.base_class == null && data.name == "string";
 
-               base (parent, file, name, accessibility, comment, type_macro_name,
-                       is_type_macro_name, type_cast_macro_name, type_function_name, is_basic_type, data);
+               base (parent, file, name, accessibility, comment, is_basic_type, data);
 
                this.interfaces = new Vala.ArrayList<TypeReference> ();
 
diff --git a/libvaladoc/api/delegate.vala b/libvaladoc/api/delegate.vala
index e175f19d1..8987b0356 100644
--- a/libvaladoc/api/delegate.vala
+++ b/libvaladoc/api/delegate.vala
@@ -42,7 +42,7 @@ public class Valadoc.Api.Delegate : TypeSymbol, Callable {
        public Delegate (Node parent, SourceFile file, string name, Vala.SymbolAccessibility accessibility,
                                         SourceComment? comment, Vala.Delegate data)
        {
-               base (parent, file, name, accessibility, comment, null, null, null, null, false, data);
+               base (parent, file, name, accessibility, comment, false, data);
 
                this.is_static = !data.has_target;
                this.cname = Vala.get_ccode_name (data);
diff --git a/libvaladoc/api/enum.vala b/libvaladoc/api/enum.vala
index f78fbb487..1f72872c6 100644
--- a/libvaladoc/api/enum.vala
+++ b/libvaladoc/api/enum.vala
@@ -31,11 +31,10 @@ public class Valadoc.Api.Enum : TypeSymbol {
        private string? type_id;
 
        public Enum (Node parent, SourceFile file, string name, Vala.SymbolAccessibility accessibility,
-                                SourceComment? comment, string? cname, string? type_macro_name,
-                                string? type_function_name, Vala.Enum data)
+                                SourceComment? comment, string? cname,
+                                Vala.Enum data)
        {
-               base (parent, file, name, accessibility, comment, type_macro_name, null, null,
-                       type_function_name, false, data);
+               base (parent, file, name, accessibility, comment, false, data);
                this.cname = cname;
                this.type_id = Vala.get_ccode_type_id (data);
        }
diff --git a/libvaladoc/api/errordomain.vala b/libvaladoc/api/errordomain.vala
index 905c2317e..e363cc7a5 100644
--- a/libvaladoc/api/errordomain.vala
+++ b/libvaladoc/api/errordomain.vala
@@ -35,7 +35,7 @@ public class Valadoc.Api.ErrorDomain : TypeSymbol {
        public ErrorDomain (Node parent, SourceFile file, string name, Vala.SymbolAccessibility accessibility,
                                                SourceComment? comment, Vala.ErrorDomain data)
        {
-               base (parent, file, name, accessibility, comment, null, null, null, null, false, data);
+               base (parent, file, name, accessibility, comment, false, data);
 
                this.quark_function_name = _get_quark_function_name (data);
                this.quark_macro_name = _get_quark_macro_name (data);
diff --git a/libvaladoc/api/interface.vala b/libvaladoc/api/interface.vala
index 8c6a9ab77..3b336bdfc 100644
--- a/libvaladoc/api/interface.vala
+++ b/libvaladoc/api/interface.vala
@@ -33,12 +33,10 @@ public class Valadoc.Api.Interface : TypeSymbol {
        private string? type_id;
 
        public Interface (Node parent, SourceFile file, string name, Vala.SymbolAccessibility accessibility,
-                                         SourceComment? comment, string? type_macro_name, string? 
is_type_macro_name,
-                                         string? type_cast_macro_name, string? type_function_name,
+                                         SourceComment? comment,
                                          Vala.Interface data)
        {
-               base (parent, file, name, accessibility, comment, type_macro_name, is_type_macro_name,
-                         type_cast_macro_name, type_function_name, false, data);
+               base (parent, file, name, accessibility, comment, false, data);
 
                this.interface_macro_name = Vala.get_ccode_interface_get_function (data);
                this.dbus_name = Vala.GDBusModule.get_dbus_name (data);
diff --git a/libvaladoc/api/struct.vala b/libvaladoc/api/struct.vala
index 983eb2a84..3144d1c9b 100644
--- a/libvaladoc/api/struct.vala
+++ b/libvaladoc/api/struct.vala
@@ -35,16 +35,15 @@ public class Valadoc.Api.Struct : TypeSymbol {
        private string? cname;
 
        public Struct (Node parent, SourceFile file, string name, Vala.SymbolAccessibility accessibility,
-                                  SourceComment? comment, string? type_macro_name,
-                                  string? type_function_name, Vala.Struct data)
+                                  SourceComment? comment,
+                                  Vala.Struct data)
        {
                bool is_basic_type = data.base_type == null
                        && (data.is_boolean_type ()
                        || data.is_floating_type ()
                        || data.is_integer_type ());
 
-               base (parent, file, name, accessibility, comment, type_macro_name, null, null,
-                       type_function_name, is_basic_type, data);
+               base (parent, file, name, accessibility, comment, is_basic_type, data);
 
                this.dup_function_cname = Vala.get_ccode_dup_function (data);
                this.copy_function_cname = Vala.get_ccode_copy_function (data);
diff --git a/libvaladoc/api/typesymbol.vala b/libvaladoc/api/typesymbol.vala
index e58a56525..4891548a4 100644
--- a/libvaladoc/api/typesymbol.vala
+++ b/libvaladoc/api/typesymbol.vala
@@ -26,23 +26,12 @@
  * Represents a runtime data type.
  */
 public abstract class Valadoc.Api.TypeSymbol : Symbol {
-       private string? type_macro_name;
-       private string? is_type_macro_name;
-       private string? type_cast_macro_name;
-       private string? type_function_name;
-
        public TypeSymbol (Node parent, SourceFile file, string name, Vala.SymbolAccessibility accessibility,
-                                          SourceComment? comment, string? type_macro_name, string? 
is_type_macro_name,
-                                          string? type_cast_macro_name, string? type_function_name, bool 
is_basic_type,
+                                          SourceComment? comment, bool is_basic_type,
                                           Vala.TypeSymbol data)
        {
                base (parent, file, name, accessibility, comment, data);
 
-               this.type_cast_macro_name = type_cast_macro_name;
-               this.is_type_macro_name = is_type_macro_name;
-               this.type_function_name = type_function_name;
-               this.type_macro_name = type_macro_name;
-
                this.is_basic_type = is_basic_type;
        }
 
@@ -57,28 +46,58 @@ public abstract class Valadoc.Api.TypeSymbol : Symbol {
        /**
         * Gets the name of the GType macro which represents the type symbol
         */
-       public string get_type_macro_name () {
-               return type_macro_name;
+       public string? get_type_macro_name () {
+               if ((data is Vala.Class
+                       && ((Vala.Class) data).is_compact)
+                       || data is Vala.ErrorDomain
+                       || data is Vala.Delegate)
+               {
+                       return null;
+               }
+
+               return Vala.get_ccode_type_id (data);
        }
 
        /**
         * Gets the name of the GType macro which casts a type instance to the given type.
         */
-       public string get_type_cast_macro_name () {
-               return type_cast_macro_name;
+       public string? get_type_cast_macro_name () {
+               if ((data is Vala.Class
+                       && !((Vala.Class) data).is_compact)
+                       || data is Vala.Interface)
+               {
+                       return Vala.get_ccode_upper_case_name ((Vala.TypeSymbol) data, null);
+               } else {
+                       return null;
+               }
        }
 
        /**
         * Gets the name of the GType macro which determines whether a type instance is of a given type.
         */
-       public string get_is_type_macro_name () {
-               return is_type_macro_name;
+       public string? get_is_type_macro_name () {
+               if ((data is Vala.Class
+                       && !((Vala.Class) data).is_compact)
+                       || data is Vala.Interface)
+               {
+                       return Vala.get_ccode_type_check_function ((Vala.TypeSymbol) data);
+               } else {
+                       return null;
+               }
        }
 
        /**
         * Gets the name of the get_type() function which represents the type symbol
         */
-       public string get_type_function_name () {
-               return type_function_name;
+       public string? get_type_function_name () {
+               if ((data is Vala.Class
+                       && ((Vala.Class) data).is_compact)
+                       || data is Vala.ErrorDomain
+                       || data is Vala.Delegate)
+               {
+                       return null;
+               }
+
+               return "%s_get_type".printf (Vala.get_ccode_lower_case_name (data, null));
        }
 }
diff --git a/valadoc/treebuilder.vala b/valadoc/treebuilder.vala
index cfe04edc3..9c6243ea8 100644
--- a/valadoc/treebuilder.vala
+++ b/valadoc/treebuilder.vala
@@ -274,46 +274,6 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
                return element.name;
        }
 
-       private string? get_is_type_macro_name (Vala.TypeSymbol element) {
-               string? name = Vala.get_ccode_type_check_function (element);
-               return (name != null && name != "")? name : null;
-       }
-
-       private string? get_type_function_name (Vala.TypeSymbol element) {
-               if ((element is Vala.Class
-                       && ((Vala.Class) element).is_compact)
-                       || element is Vala.ErrorDomain
-                       || element is Vala.Delegate)
-               {
-                       return null;
-               }
-
-               return "%s_get_type".printf (Vala.get_ccode_lower_case_name (element, null));
-       }
-
-       private string? get_type_macro_name (Vala.TypeSymbol element) {
-               if ((element is Vala.Class
-                       && ((Vala.Class) element).is_compact)
-                       || element is Vala.ErrorDomain
-                       || element is Vala.Delegate)
-               {
-                       return null;
-               }
-
-               return Vala.get_ccode_type_id (element);
-       }
-
-       private string? get_type_cast_macro_name (Vala.TypeSymbol element) {
-               if ((element is Vala.Class
-                       && !((Vala.Class) element).is_compact)
-                       || element is Vala.Interface)
-               {
-                       return Vala.get_ccode_upper_case_name (element, null);
-               } else {
-                       return null;
-               }
-       }
-
        private PackageMetaData? get_package_meta_data (Package pkg) {
                foreach (PackageMetaData data in packages) {
                        if (data.package == pkg) {
@@ -637,10 +597,6 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
                                                                element.name,
                                                                element.access,
                                                                comment,
-                                                               get_type_macro_name (element),
-                                                               get_is_type_macro_name (element),
-                                                               get_type_cast_macro_name (element),
-                                                               get_type_function_name (element),
                                                                element);
                symbol_map.set (element, node);
                parent.add_child (node);
@@ -678,10 +634,6 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
                                                                                element.name,
                                                                                element.access,
                                                                                comment,
-                                                                               get_type_macro_name (element),
-                                                                               get_is_type_macro_name 
(element),
-                                                                               get_type_cast_macro_name 
(element),
-                                                                               get_type_function_name 
(element),
                                                                                element);
                symbol_map.set (element, node);
                parent.add_child (node);
@@ -713,8 +665,6 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
                                                                  element.name,
                                                                  element.access,
                                                                  comment,
-                                                                 get_type_macro_name (element),
-                                                                 get_type_function_name (element),
                                                                  element);
                symbol_map.set (element, node);
                parent.add_child (node);
@@ -902,8 +852,6 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
                                                                element.access,
                                                                comment,
                                                                Vala.get_ccode_name (element),
-                                                               get_type_macro_name (element),
-                                                               get_type_function_name (element),
                                                                element);
                symbol_map.set (element, node);
                parent.add_child (node);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]