From: Rico Tzschichholz Date: Wed, 17 Jan 2018 09:26:10 +0000 (+0100) Subject: vala: Move constant lists from Class/Interface up to ObjectTypeSymbol X-Git-Tag: 0.39.5~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1fa7cf7bfd791f227d0b72d4a57fce9e59d44dcc;p=thirdparty%2Fvala.git vala: Move constant lists from Class/Interface up to ObjectTypeSymbol --- diff --git a/vala/valaclass.vala b/vala/valaclass.vala index c76cf5584..f61bb350e 100644 --- a/vala/valaclass.vala +++ b/vala/valaclass.vala @@ -100,8 +100,6 @@ public class Vala.Class : ObjectTypeSymbol { private List base_types = new ArrayList (); - private List constants = new ArrayList (); - /** * Specifies the default construction method. */ @@ -192,16 +190,6 @@ public class Vala.Class : ObjectTypeSymbol { return base_types; } - /** - * 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. * @@ -217,15 +205,6 @@ public class Vala.Class : ObjectTypeSymbol { } } - /** - * Returns a copy of the list of constants. - * - * @return list of constants - */ - public List get_constants () { - return constants; - } - /** * Adds the specified method as a member to this class. * @@ -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 c12a6ce90..8e3229c94 100644 --- a/vala/valainterface.vala +++ b/vala/valainterface.vala @@ -28,7 +28,6 @@ using GLib; public class Vala.Interface : ObjectTypeSymbol { private List prerequisites = new ArrayList (); - private List constants = new ArrayList (); private List virtuals = new ArrayList (); /** @@ -96,25 +95,6 @@ public class Vala.Interface : ObjectTypeSymbol { base.add_method (m); } - /** - * 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 get_constants () { - return constants; - } - /** * Adds the specified property as a member to this interface. * @@ -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 ab90322c4..aca53ed00 100644 --- a/vala/valaobjecttypesymbol.vala +++ b/vala/valaobjecttypesymbol.vala @@ -45,6 +45,8 @@ public abstract class Vala.ObjectTypeSymbol : TypeSymbol { private List enums = new ArrayList (); private List delegates = new ArrayList (); + private List constants = new ArrayList (); + public ObjectTypeSymbol (string name, SourceReference? source_reference = null, Comment? comment = null) { base (name, source_reference, comment); } @@ -214,6 +216,25 @@ public abstract class Vala.ObjectTypeSymbol : TypeSymbol { scope.add (d.name, d); } + /** + * 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 get_constants () { + return constants; + } + /** * Appends the specified parameter to the list of type parameters. *