[vala] Remove Member class



commit 11170a0962836e3d7ee79b4b92e58849a63c6e95
Author: Jürg Billeter <j bitron ch>
Date:   Sun Jul 25 11:27:35 2010 +0200

    Remove Member class

 codegen/valaccodebasemodule.vala |    4 +-
 codegen/valaccodemodule.vala     |    2 +-
 vala/Makefile.am                 |    1 -
 vala/valaconstant.vala           |    2 +-
 vala/valaenumvalue.vala          |    2 -
 vala/valafield.vala              |    2 +-
 vala/valamember.vala             |  102 --------------------------------------
 vala/valamethod.vala             |    2 +-
 vala/valanamespace.vala          |   28 +----------
 vala/valaproperty.vala           |    2 +-
 vala/valasignal.vala             |    2 +-
 vala/valasymbol.vala             |   79 ++++++++++++++++++++++++++++-
 vala/valatypesymbol.vala         |   33 +------------
 13 files changed, 87 insertions(+), 174 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 05f8e93..4edeb1a 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -733,7 +733,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 		}
 	}
 
-	public override void visit_member (Member m) {
+	public override void visit_member (Symbol m) {
 		/* stuff meant for all lockable members */
 		if (m is Lockable && ((Lockable) m).get_lock_used ()) {
 			CCodeExpression l = new CCodeIdentifier ("self");
@@ -3438,7 +3438,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 	private CCodeExpression get_lock_expression (Statement stmt, Expression resource) {
 		CCodeExpression l = null;
 		var inner_node = ((MemberAccess)resource).inner;
-		var member = (Member)resource.symbol_reference;
+		var member = resource.symbol_reference;
 		var parent = (TypeSymbol)resource.symbol_reference.parent_symbol;
 		
 		if (member.is_instance_member ()) {
diff --git a/codegen/valaccodemodule.vala b/codegen/valaccodemodule.vala
index 1afeac2..a7cb112 100644
--- a/codegen/valaccodemodule.vala
+++ b/codegen/valaccodemodule.vala
@@ -79,7 +79,7 @@ public abstract class Vala.CCodeModule {
 		next.visit_delegate (d);
 	}
 	
-	public virtual void visit_member (Member m) {
+	public virtual void visit_member (Symbol m) {
 		next.visit_member (m);
 	}
 
diff --git a/vala/Makefile.am b/vala/Makefile.am
index e0a5f38..1dc0ca8 100644
--- a/vala/Makefile.am
+++ b/vala/Makefile.am
@@ -94,7 +94,6 @@ libvalacore_la_VALASOURCES = \
 	valaloop.vala \
 	valamapliteral.vala \
 	valamarkupreader.vala \
-	valamember.vala \
 	valamemberaccess.vala \
 	valamemberinitializer.vala \
 	valamethod.vala \
diff --git a/vala/valaconstant.vala b/vala/valaconstant.vala
index e889e40..416ab22 100644
--- a/vala/valaconstant.vala
+++ b/vala/valaconstant.vala
@@ -25,7 +25,7 @@ using GLib;
 /**
  * Represents a type member with a constant value.
  */
-public class Vala.Constant : Member, Lockable {
+public class Vala.Constant : Symbol, Lockable {
 	/**
 	 * The data type of this constant.
 	 */
diff --git a/vala/valaenumvalue.vala b/vala/valaenumvalue.vala
index 47f11ee..0c3d0ea 100644
--- a/vala/valaenumvalue.vala
+++ b/vala/valaenumvalue.vala
@@ -31,8 +31,6 @@ public class Vala.EnumValue : Symbol {
 	 */
 	public Expression value { get; set; }
 
-	public Comment comment { get; set; }
-
 	private string cname;
 
 	/**
diff --git a/vala/valafield.vala b/vala/valafield.vala
index 82e48f1..85029d2 100644
--- a/vala/valafield.vala
+++ b/vala/valafield.vala
@@ -25,7 +25,7 @@ using GLib;
 /**
  * Represents a type or namespace field.
  */
-public class Vala.Field : Member, Lockable {
+public class Vala.Field : Symbol, Lockable {
 	/**
 	 * The data type of this field.
 	 */
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index 0319868..8b36106 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -27,7 +27,7 @@ using GLib;
 /**
  * Represents a type or namespace method.
  */
-public class Vala.Method : Member {
+public class Vala.Method : Symbol {
 	List<TypeParameter> type_parameters = new ArrayList<TypeParameter> ();
 
 	public const string DEFAULT_SENTINEL = "NULL";
diff --git a/vala/valanamespace.vala b/vala/valanamespace.vala
index 1417f10..e7b5109 100644
--- a/vala/valanamespace.vala
+++ b/vala/valanamespace.vala
@@ -41,8 +41,6 @@ public class Vala.Namespace : Symbol {
 	private List<string> cprefixes = new ArrayList<string> ();
 	private string lower_case_cprefix;
 	
-	private List<string> cheader_filenames = new ArrayList<string> ();
-
 	private List<Namespace> namespaces = new ArrayList<Namespace> ();
 
 	private List<UsingDirective> using_directives = new ArrayList<UsingDirective> ();
@@ -517,30 +515,6 @@ public class Vala.Namespace : Symbol {
 		this.lower_case_cprefix = cprefix;
 	}
 
-	public override List<string> get_cheader_filenames () {
-		return cheader_filenames;
-	}
-
-	/**
-	 * Sets the C header filename of this namespace to the specified
-	 * filename.
-	 *
-	 * @param cheader_filename header filename
-	 */
-	public void set_cheader_filename (string cheader_filename) {
-		cheader_filenames = new ArrayList<string> ();
-		cheader_filenames.add (cheader_filename);
-	}
-	
-	/**
-	 * Adds a C header filename of this namespace.
-	 *
-	 * @param cheader_filename header filename
-	 */
-	public void add_cheader_filename (string cheader_filename) {
-		cheader_filenames.add (cheader_filename);
-	}
-
 	private void process_ccode_attribute (Attribute a) {
 		if (a.has_argument ("cprefix")) {
 			string value = a.get_string ("cprefix");
@@ -559,7 +533,7 @@ public class Vala.Namespace : Symbol {
 		if (a.has_argument ("cheader_filename")) {
 			var val = a.get_string ("cheader_filename");
 			foreach (string filename in val.split (",")) {
-				cheader_filenames.add (filename);
+				add_cheader_filename (filename);
 			}
 		}
 		if (a.has_argument ("gir_namespace")) {
diff --git a/vala/valaproperty.vala b/vala/valaproperty.vala
index 3cb8afa..4f31ae2 100644
--- a/vala/valaproperty.vala
+++ b/vala/valaproperty.vala
@@ -26,7 +26,7 @@ using GLib;
 /**
  * Represents a property declaration in the source code.
  */
-public class Vala.Property : Member, Lockable {
+public class Vala.Property : Symbol, Lockable {
 	/**
 	 * The property type.
 	 */
diff --git a/vala/valasignal.vala b/vala/valasignal.vala
index 443f4b4..87d2efe 100644
--- a/vala/valasignal.vala
+++ b/vala/valasignal.vala
@@ -25,7 +25,7 @@ using GLib;
 /**
  * Represents an object signal. Signals enable objects to provide notifications.
  */
-public class Vala.Signal : Member, Lockable {
+public class Vala.Signal : Symbol, Lockable {
 	/**
 	 * The return type of handlers of this signal.
 	 */
diff --git a/vala/valasymbol.vala b/vala/valasymbol.vala
index 8cb6e43..2fb6c3a 100644
--- a/vala/valasymbol.vala
+++ b/vala/valasymbol.vala
@@ -95,6 +95,16 @@ public abstract class Vala.Symbol : CodeNode {
 	 */
 	public SymbolAccessibility access { get; set; }
 
+	public Comment? comment { get; set; }
+
+	private List<string> cheader_filenames = new ArrayList<string> ();
+
+	/**
+	 * Specifies whether this method explicitly hides a member of a base
+	 * type.
+	 */
+	public bool hides { get; set; }
+
 	/**
 	 * Check if this symbol is just internal API (and therefore doesn't need 
 	 * to be listed in header files for instance) by traversing parent symbols
@@ -153,9 +163,10 @@ public abstract class Vala.Symbol : CodeNode {
 	private weak Scope _owner;
 	private Scope _scope;
 
-	public Symbol (string? name, SourceReference? source_reference) {
+	public Symbol (string? name, SourceReference? source_reference, Comment? comment = null) {
 		this.name = name;
 		this.source_reference = source_reference;
+		this.comment = comment;
 		_scope = new Scope (this);
 	}
 	
@@ -229,7 +240,19 @@ public abstract class Vala.Symbol : CodeNode {
 	 * @return list of C header filenames for this symbol
 	 */
 	public virtual List<string> get_cheader_filenames () {
-		return new ArrayList<string> ();
+		// parent_symbol can be null on incremental parsing
+		if (cheader_filenames.size == 0 && parent_symbol != null) {
+			/* default to header filenames of the namespace */
+			foreach (string filename in parent_symbol.get_cheader_filenames ()) {
+				add_cheader_filename (filename);
+			}
+
+			if (cheader_filenames.size == 0 && source_reference != null && !external_package) {
+				// don't add default include directives for VAPI files
+				cheader_filenames.add (source_reference.file.get_cinclude_filename ());
+			}
+		}
+		return cheader_filenames;
 	}
 
 	/**
@@ -413,6 +436,53 @@ public abstract class Vala.Symbol : CodeNode {
 			return false;
 		}
 	}
+
+	/**
+	 * Sets the C header filename of this namespace to the specified
+	 * filename.
+	 *
+	 * @param cheader_filename header filename
+	 */
+	public void set_cheader_filename (string cheader_filename) {
+		cheader_filenames = new ArrayList<string> ();
+		cheader_filenames.add (cheader_filename);
+	}
+
+	/**
+	 * Adds a filename to the list of C header filenames users of this data
+	 * type must include.
+	 *
+	 * @param filename a C header filename
+	 */
+	public void add_cheader_filename (string filename) {
+		cheader_filenames.add (filename);
+	}
+
+	public Symbol? get_hidden_member () {
+		Symbol sym = null;
+
+		if (parent_symbol is Class) {
+			var cl = ((Class) parent_symbol).base_class;
+			while (cl != null) {
+				sym = cl.scope.lookup (name);
+				if (sym != null && sym.access != SymbolAccessibility.PRIVATE) {
+					return sym;
+				}
+				cl = cl.base_class;
+			}
+		} else if (parent_symbol is Struct) {
+			var st = ((Struct) parent_symbol).base_struct;
+			while (st != null) {
+				sym = st.scope.lookup (name);
+				if (sym != null && sym.access != SymbolAccessibility.PRIVATE) {
+					return sym;
+				}
+				st = st.base_struct;
+			}
+		}
+
+		return null;
+	}
 }
 
 public enum Vala.SymbolAccessibility {
@@ -422,3 +492,8 @@ public enum Vala.SymbolAccessibility {
 	PUBLIC
 }
 
+public enum MemberBinding {
+	INSTANCE,
+	CLASS,
+	STATIC
+}
diff --git a/vala/valatypesymbol.vala b/vala/valatypesymbol.vala
index 996e5dc..956939b 100644
--- a/vala/valatypesymbol.vala
+++ b/vala/valatypesymbol.vala
@@ -29,13 +29,8 @@ using GLib;
  * code or imported from an external library with a Vala API file.
  */
 public abstract class Vala.TypeSymbol : Symbol {
-	public Comment? comment { get; set; }
-
-	private List<string> cheader_filenames = new ArrayList<string> ();
-
 	public TypeSymbol (string? name, SourceReference? source_reference = null, Comment? comment = null) {
-		base (name, source_reference);
-		this.comment = comment;
+		base (name, source_reference, comment);
 	}
 
 	/**
@@ -227,32 +222,6 @@ public abstract class Vala.TypeSymbol : Symbol {
 		return null;
 	}
 
-	public override List<string> get_cheader_filenames () {
-		// parent_symbol can be null on incremental parsing
-		if (cheader_filenames.size == 0 && parent_symbol != null) {
-			/* default to header filenames of the namespace */
-			foreach (string filename in parent_symbol.get_cheader_filenames ()) {
-				add_cheader_filename (filename);
-			}
-
-			if (cheader_filenames.size == 0 && source_reference != null && !external_package) {
-				// don't add default include directives for VAPI files
-				cheader_filenames.add (source_reference.file.get_cinclude_filename ());
-			}
-		}
-		return cheader_filenames;
-	}
-
-	/**
-	 * Adds a filename to the list of C header filenames users of this data
-	 * type must include.
-	 *
-	 * @param filename a C header filename
-	 */
-	public void add_cheader_filename (string filename) {
-		cheader_filenames.add (filename);
-	}
-
 	/**
 	 * Checks whether this data type is equal to or a subtype of the
 	 * specified data type.



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