[vala] Fix critical warnings when using signals in interfaces



commit 4bcb6d57e8a8ec55e3fc33972cc4f48b6d9b8398
Author: Jürg Billeter <j bitron ch>
Date:   Sat Oct 31 14:30:01 2009 +0100

    Fix critical warnings when using signals in interfaces

 vala/valaclass.vala            |   40 ----------------------------------------
 vala/valainterface.vala        |    2 +-
 vala/valaobjecttypesymbol.vala |   40 ++++++++++++++++++++++++++++++++++++++++
 vala/valasignal.vala           |    2 +-
 4 files changed, 42 insertions(+), 42 deletions(-)
---
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index 7b3f3ef..aee7743 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -310,16 +310,6 @@ public class Vala.Class : ObjectTypeSymbol {
 		return new ReadOnlyList<Constant> (constants);
 	}
 
-	ObjectType get_this_type () {
-		var result = new ObjectType (this);
-		foreach (var type_parameter in get_type_parameters ()) {
-			var type_arg = new GenericType (type_parameter);
-			type_arg.value_owned = true;
-			result.add_type_argument (type_arg);
-		}
-		return result;
-	}
-
 	/**
 	 * Adds the specified method as a member to this class.
 	 *
@@ -358,36 +348,6 @@ public class Vala.Class : ObjectTypeSymbol {
 		methods.add (m);
 		scope.add (m.name, m);
 	}
-	
-	/**
-	 * Adds the specified method as a hidden member to this class,
-	 * primarily used for default signal handlers.
-	 *
-	 * The hidden methods are not part of the `methods` collection.
-	 *
-	 * There may also be other use cases, eg, convert array.resize() to
-	 * this type of method?
-	 *
-	 * @param m a method
-	 */
-	public void add_hidden_method (Method m) {
-		if (m.binding == MemberBinding.INSTANCE) {
-			if (m.this_parameter != null) {
-				m.scope.remove (m.this_parameter.name);
-			}
-			m.this_parameter = new FormalParameter ("this", get_this_type ());
-			m.scope.add (m.this_parameter.name, m.this_parameter);
-		}
-		if (!(m.return_type is VoidType) && m.get_postconditions ().size > 0) {
-			if (m.result_var != null) {
-				m.scope.remove (m.result_var.name);
-			}
-			m.result_var = new LocalVariable (m.return_type.copy (), "result");
-			m.result_var.is_result = true;
-		}
-
-		scope.add (null, m);
-	}
 
 	/**
 	 * Returns a copy of the list of methods.
diff --git a/vala/valainterface.vala b/vala/valainterface.vala
index 1538736..076ba2e 100644
--- a/vala/valainterface.vala
+++ b/vala/valainterface.vala
@@ -135,7 +135,7 @@ public class Vala.Interface : ObjectTypeSymbol {
 			return;
 		}
 		if (m.binding == MemberBinding.INSTANCE) {
-			m.this_parameter = new FormalParameter ("this", new ObjectType (this));
+			m.this_parameter = new FormalParameter ("this", get_this_type ());
 			m.scope.add (m.this_parameter.name, m.this_parameter);
 		}
 		if (!(m.return_type is VoidType) && m.get_postconditions ().size > 0) {
diff --git a/vala/valaobjecttypesymbol.vala b/vala/valaobjecttypesymbol.vala
index 5539bf0..8849ae7 100644
--- a/vala/valaobjecttypesymbol.vala
+++ b/vala/valaobjecttypesymbol.vala
@@ -68,4 +68,44 @@ public abstract class Vala.ObjectTypeSymbol : TypeSymbol {
 		}
 		return -1;
 	}
+
+	public ObjectType get_this_type () {
+		var result = new ObjectType (this);
+		foreach (var type_parameter in get_type_parameters ()) {
+			var type_arg = new GenericType (type_parameter);
+			type_arg.value_owned = true;
+			result.add_type_argument (type_arg);
+		}
+		return result;
+	}
+
+	/**
+	 * Adds the specified method as a hidden member to this class,
+	 * primarily used for default signal handlers.
+	 *
+	 * The hidden methods are not part of the `methods` collection.
+	 *
+	 * There may also be other use cases, eg, convert array.resize() to
+	 * this type of method?
+	 *
+	 * @param m a method
+	 */
+	public void add_hidden_method (Method m) {
+		if (m.binding == MemberBinding.INSTANCE) {
+			if (m.this_parameter != null) {
+				m.scope.remove (m.this_parameter.name);
+			}
+			m.this_parameter = new FormalParameter ("this", get_this_type ());
+			m.scope.add (m.this_parameter.name, m.this_parameter);
+		}
+		if (!(m.return_type is VoidType) && m.get_postconditions ().size > 0) {
+			if (m.result_var != null) {
+				m.scope.remove (m.result_var.name);
+			}
+			m.result_var = new LocalVariable (m.return_type.copy (), "result");
+			m.result_var.is_result = true;
+		}
+
+		scope.add (null, m);
+	}
 }
diff --git a/vala/valasignal.vala b/vala/valasignal.vala
index 207d8f7..94e3623 100644
--- a/vala/valasignal.vala
+++ b/vala/valasignal.vala
@@ -260,7 +260,7 @@ public class Vala.Signal : Member, Lockable {
 				default_handler.add_parameter (param);
 			}
 
-			var cl = parent_symbol as Class;
+			var cl = parent_symbol as ObjectTypeSymbol;
 
 			cl.add_hidden_method (default_handler);
 			default_handler.check (analyzer);



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