[vala/staging: 4/4] vala: Move constant lists from Class/Interface up to ObjectTypeSymbol



commit 1fa7cf7bfd791f227d0b72d4a57fce9e59d44dcc
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Wed Jan 17 10:26:10 2018 +0100

    vala: Move constant lists from Class/Interface up to ObjectTypeSymbol

 vala/valaclass.vala            |   25 ++-----------------------
 vala/valainterface.vala        |   24 ++----------------------
 vala/valaobjecttypesymbol.vala |   21 +++++++++++++++++++++
 3 files changed, 25 insertions(+), 45 deletions(-)
---
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index c76cf55..f61bb35 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -100,8 +100,6 @@ public class Vala.Class : ObjectTypeSymbol {
 
        private List<DataType> base_types = new ArrayList<DataType> ();
 
-       private List<Constant> constants = new ArrayList<Constant> ();
-
        /**
         * Specifies the default construction method.
         */
@@ -193,16 +191,6 @@ public class Vala.Class : ObjectTypeSymbol {
        }
 
        /**
-        * Adds the specified constant as a member to this class.
-        *
-        * @param c a constant
-        */
-       public override void add_constant (Constant c) {
-               constants.add (c);
-               scope.add (c.name, c);
-       }
-       
-       /**
         * Adds the specified field as a member to this class.
         *
         * @param f a field
@@ -218,15 +206,6 @@ public class Vala.Class : ObjectTypeSymbol {
        }
        
        /**
-        * Returns a copy of the list of constants.
-        *
-        * @return list of constants
-        */
-       public List<Constant> get_constants () {
-               return constants;
-       }
-
-       /**
         * Adds the specified method as a member to this class.
         *
         * @param m a method
@@ -345,7 +324,7 @@ public class Vala.Class : ObjectTypeSymbol {
                        f.accept (visitor);
                }
                
-               foreach (Constant c in constants) {
+               foreach (Constant c in get_constants ()) {
                        c.accept (visitor);
                }
                
@@ -531,7 +510,7 @@ public class Vala.Class : ObjectTypeSymbol {
                        f.check (context);
                }
                
-               foreach (Constant c in constants) {
+               foreach (Constant c in get_constants ()) {
                        c.check (context);
                }
                
diff --git a/vala/valainterface.vala b/vala/valainterface.vala
index c12a6ce..8e3229c 100644
--- a/vala/valainterface.vala
+++ b/vala/valainterface.vala
@@ -28,7 +28,6 @@ using GLib;
 public class Vala.Interface : ObjectTypeSymbol {
        private List<DataType> prerequisites = new ArrayList<DataType> ();
 
-       private List<Constant> constants = new ArrayList<Constant> ();
        private List<Symbol> virtuals = new ArrayList<Symbol> ();
 
        /**
@@ -97,25 +96,6 @@ public class Vala.Interface : ObjectTypeSymbol {
        }
 
        /**
-        * Adds the specified constant as a member to this interface.
-        *
-        * @param c a constant
-        */
-       public override void add_constant (Constant c) {
-               constants.add (c);
-               scope.add (c.name, c);
-       }
-
-       /**
-        * Returns a copy of the list of constants.
-        *
-        * @return list of constants
-        */
-       public List<Constant> get_constants () {
-               return constants;
-       }
-
-       /**
         * Adds the specified property as a member to this interface.
         *
         * @param prop a property
@@ -164,7 +144,7 @@ public class Vala.Interface : ObjectTypeSymbol {
                        f.accept (visitor);
                }
 
-               foreach (Constant c in constants) {
+               foreach (Constant c in get_constants ()) {
                        c.accept (visitor);
                }
 
@@ -292,7 +272,7 @@ public class Vala.Interface : ObjectTypeSymbol {
                        f.check (context);
                }
 
-               foreach (Constant c in constants) {
+               foreach (Constant c in get_constants ()) {
                        c.check (context);
                }
 
diff --git a/vala/valaobjecttypesymbol.vala b/vala/valaobjecttypesymbol.vala
index ab90322..aca53ed 100644
--- a/vala/valaobjecttypesymbol.vala
+++ b/vala/valaobjecttypesymbol.vala
@@ -45,6 +45,8 @@ public abstract class Vala.ObjectTypeSymbol : TypeSymbol {
        private List<Enum> enums = new ArrayList<Enum> ();
        private List<Delegate> delegates = new ArrayList<Delegate> ();
 
+       private List<Constant> constants = new ArrayList<Constant> ();
+
        public ObjectTypeSymbol (string name, SourceReference? source_reference = null, Comment? comment = 
null) {
                base (name, source_reference, comment);
        }
@@ -215,6 +217,25 @@ public abstract class Vala.ObjectTypeSymbol : TypeSymbol {
        }
 
        /**
+        * Adds the specified constant as a member to this interface.
+        *
+        * @param c a constant
+        */
+       public override void add_constant (Constant c) {
+               constants.add (c);
+               scope.add (c.name, c);
+       }
+
+       /**
+        * Returns the list of constants.
+        *
+        * @return list of constants
+        */
+       public List<Constant> get_constants () {
+               return constants;
+       }
+
+       /**
         * Appends the specified parameter to the list of type parameters.
         *
         * @param p a type parameter


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