vala r1631 - in trunk: . gobject vala



Author: juergbi
Date: Sun Jun 22 22:23:20 2008
New Revision: 1631
URL: http://svn.gnome.org/viewvc/vala?rev=1631&view=rev

Log:
2008-06-23  JÃrg Billeter  <j bitron ch>

	* vala/valasemanticanalyzer.vala:
	* gobject/valaccodeclassbinding.vala:

	Support inherited interface implementation, fixes bug 536863


Modified:
   trunk/ChangeLog
   trunk/gobject/valaccodeclassbinding.vala
   trunk/vala/valasemanticanalyzer.vala

Modified: trunk/gobject/valaccodeclassbinding.vala
==============================================================================
--- trunk/gobject/valaccodeclassbinding.vala	(original)
+++ trunk/gobject/valaccodeclassbinding.vala	Sun Jun 22 22:23:20 2008
@@ -533,7 +533,25 @@
 			}
 			init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess.pointer (ciface, m.base_interface_method.vfunc_name), new CCodeIdentifier (cname))));
 		}
-		
+
+		// connect inherited implementations
+		foreach (Method m in iface.get_methods ()) {
+			if (m.is_abstract) {
+				Method cl_method = null;
+				var base_class = cl;
+				while (cl_method == null) {
+					cl_method = base_class.scope.lookup (m.name) as Method;
+					base_class = base_class.base_class;
+				}
+				if (cl_method.parent_symbol != cl) {
+					// method inherited from base class
+					
+					var ciface = new CCodeIdentifier ("iface");
+					init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess.pointer (ciface, m.vfunc_name), new CCodeIdentifier (cl_method.get_cname ()))));
+				}
+			}
+		}
+
 		codegen.source_type_member_definition.append (iface_init);
 	}
 	

Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala	(original)
+++ trunk/vala/valasemanticanalyzer.vala	Sun Jun 22 22:23:20 2008
@@ -214,7 +214,12 @@
 					/* check methods */
 					foreach (Method m in iface.get_methods ()) {
 						if (m.is_abstract) {
-							var sym = cl.scope.lookup (m.name);
+							Symbol sym = null;
+							var base_class = cl;
+							while (base_class != null && !(sym is Method)) {
+								sym = base_class.scope.lookup (m.name);
+								base_class = base_class.base_class;
+							}
 							if (!(sym is Method)) {
 								cl.error = true;
 								Report.error (cl.source_reference, "`%s' does not implement interface method `%s'".printf (cl.get_full_name (), m.get_full_name ()));
@@ -225,7 +230,12 @@
 					/* check properties */
 					foreach (Property prop in iface.get_properties ()) {
 						if (prop.is_abstract) {
-							var sym = cl.scope.lookup (prop.name);
+							Symbol sym = null;
+							var base_class = cl;
+							while (base_class != null && !(sym is Property)) {
+								sym = base_class.scope.lookup (prop.name);
+								base_class = base_class.base_class;
+							}
 							if (!(sym is Property)) {
 								cl.error = true;
 								Report.error (cl.source_reference, "`%s' does not implement interface property `%s'".printf (cl.get_full_name (), prop.get_full_name ()));



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