[vala] Add support for constants in interfaces



commit 7eafd52a225bc857a9979325a069a18556fcc0a5
Author: Didier 'Ptitjes <ptitjes free fr>
Date:   Mon Sep 14 18:31:22 2009 +0200

    Add support for constants in interfaces

 vala/valacodewriter.vala |    1 +
 vala/valainterface.vala  |   32 ++++++++++++++++++++++++++++++--
 vala/valaparser.vala     |    2 ++
 3 files changed, 33 insertions(+), 2 deletions(-)
---
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala
index ee294e5..cf6a682 100644
--- a/vala/valacodewriter.vala
+++ b/vala/valacodewriter.vala
@@ -441,6 +441,7 @@ public class Vala.CodeWriter : CodeVisitor {
 		visit_sorted (iface.get_enums ());
 		visit_sorted (iface.get_delegates ());
 		visit_sorted (iface.get_fields ());
+		visit_sorted (iface.get_constants ());
 		visit_sorted (iface.get_methods ());
 		visit_sorted (iface.get_properties ());
 		visit_sorted (iface.get_signals ());
diff --git a/vala/valainterface.vala b/vala/valainterface.vala
index 44de8f6..7d831ed 100644
--- a/vala/valainterface.vala
+++ b/vala/valainterface.vala
@@ -31,6 +31,7 @@ public class Vala.Interface : ObjectTypeSymbol {
 
 	private Gee.List<Method> methods = new ArrayList<Method> ();
 	private Gee.List<Field> fields = new ArrayList<Field> ();
+	private Gee.List<Constant> constants = new ArrayList<Constant> ();
 	private Gee.List<Property> properties = new ArrayList<Property> ();
 	private Gee.List<Signal> signals = new ArrayList<Signal> ();
 
@@ -177,6 +178,25 @@ public class Vala.Interface : ObjectTypeSymbol {
 	}
 
 	/**
+	 * Adds the specified constant as a member to this interface.
+	 *
+	 * @param c a constant
+	 */
+	public 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 Gee.List<Constant> get_constants () {
+		return new ReadOnlyList<Constant> (constants);
+	}
+
+	/**
 	 * Adds the specified property as a member to this interface.
 	 *
 	 * @param prop a property
@@ -359,7 +379,11 @@ public class Vala.Interface : ObjectTypeSymbol {
 		foreach (Field f in fields) {
 			f.accept (visitor);
 		}
-		
+
+		foreach (Constant c in constants) {
+			c.accept (visitor);
+		}
+
 		foreach (Property prop in properties) {
 			prop.accept (visitor);
 		}
@@ -601,7 +625,11 @@ public class Vala.Interface : ObjectTypeSymbol {
 		foreach (Field f in fields) {
 			f.check (analyzer);
 		}
-		
+
+		foreach (Constant c in constants) {
+			c.check (analyzer);
+		}
+
 		foreach (Property prop in properties) {
 			prop.check (analyzer);
 		}
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 7725343..58fcff7 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -2607,6 +2607,8 @@ public class Vala.Parser : CodeVisitor {
 			iface.add_signal ((Signal) sym);
 		} else if (sym is Field) {
 			iface.add_field ((Field) sym);
+		} else if (sym is Constant) {
+			iface.add_constant ((Constant) sym);
 		} else if (sym is Property) {
 			iface.add_property ((Property) sym);
 		} else {



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