[vala] Support constructor chain up to GObject using Object (...)



commit ba8f9c8b66204a0680d3c7e4447a745ba9903d13
Author: Jürg Billeter <j bitron ch>
Date:   Wed Oct 21 21:28:28 2009 +0200

    Support constructor chain up to GObject using Object (...)

 vala/valamethodcall.vala |   36 ++++++++++++++++++++++++------------
 1 files changed, 24 insertions(+), 12 deletions(-)
---
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index aedeb96..ab47024 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -141,7 +141,7 @@ public class Vala.MethodCall : Expression {
 
 		var mtype = call.value_type;
 
-		if (mtype is ObjectType) {
+		if (mtype is ObjectType || (analyzer.context.profile == Profile.GOBJECT && call.symbol_reference == analyzer.object_type)) {
 			// constructor chain-up
 			var cm = analyzer.find_current_method () as CreationMethod;
 			if (cm == null) {
@@ -155,17 +155,29 @@ public class Vala.MethodCall : Expression {
 			}
 			cm.chain_up = true;
 
-			var otype = (ObjectType) mtype;
-			var cl = (Class) otype.type_symbol;
-			var base_cm = cl.default_construction_method;
-			if (base_cm == null) {
-				error = true;
-				Report.error (source_reference, "chain up to `%s' not supported".printf (cl.get_full_name ()));
-				return false;
-			} else if (!base_cm.has_construct_function) {
-				error = true;
-				Report.error (source_reference, "chain up to `%s' not supported".printf (base_cm.get_full_name ()));
-				return false;
+			if (mtype is ObjectType) {
+				var otype = (ObjectType) mtype;
+				var cl = (Class) otype.type_symbol;
+				var base_cm = cl.default_construction_method;
+				if (base_cm == null) {
+					error = true;
+					Report.error (source_reference, "chain up to `%s' not supported".printf (cl.get_full_name ()));
+					return false;
+				} else if (!base_cm.has_construct_function) {
+					error = true;
+					Report.error (source_reference, "chain up to `%s' not supported".printf (base_cm.get_full_name ()));
+					return false;
+				}
+			} else {
+				// GObject chain up
+				var cl = cm.parent_symbol as Class;
+				if (cl == null || !cl.is_subtype_of (analyzer.object_type)) {
+					error = true;
+					Report.error (source_reference, "chain up to `GLib.Object' not supported");
+					return false;
+				}
+				call.value_type = new ObjectType (analyzer.object_type);
+				mtype = call.value_type;
 			}
 		}
 



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