Commit d86047af authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

support virtual methods in interfaces, fixes bug 443525

2008-04-19  Juerg Billeter  <j@bitron.ch>

	* vala/valasemanticanalyzer.vala,
	  gobject/valaccodeinterfacebinding.vala: support virtual methods
	  in interfaces, fixes bug 443525

svn path=/trunk/; revision=1275
parent 0e64d336
2008-04-19 Jürg Billeter <j@bitron.ch>
* vala/valasemanticanalyzer.vala,
gobject/valaccodeinterfacebinding.vala: support virtual methods
in interfaces, fixes bug 443525
2008-04-19 Jürg Billeter <j@bitron.ch>
* vala/valaattributeprocessor.vala, vala/valaerrortype.vala,
......
......@@ -131,7 +131,16 @@ public class Vala.CCodeInterfaceBinding : CCodeTypesymbolBinding {
foreach (Signal sig in iface.get_signals ()) {
init_block.add_statement (new CCodeExpressionStatement (get_signal_creation (sig, iface)));
}
// connect default implementations
foreach (Method m in iface.get_methods ()) {
if (m.is_virtual) {
var ciface = new CCodeIdentifier ("iface");
var cname = m.get_real_cname ();
base_init.block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess.pointer (ciface, m.vfunc_name), new CCodeIdentifier (cname))));
}
}
codegen.source_type_member_definition.append (base_init);
}
}
......@@ -367,9 +367,9 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
return;
}
} else if (m.is_virtual) {
if (!(m.parent_symbol is Class)) {
if (!(m.parent_symbol is Class) && !(m.parent_symbol is Interface)) {
m.error = true;
Report.error (m.source_reference, "Virtual methods may not be declared outside of classes");
Report.error (m.source_reference, "Virtual methods may not be declared outside of classes and interfaces");
return;
}
} else if (m.overrides) {
......@@ -497,7 +497,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
var sym = type.data_type.scope.lookup (m.name);
if (sym is Method) {
var base_method = (Method) sym;
if (base_method.is_abstract) {
if (base_method.is_abstract || base_method.is_virtual) {
string invalid_match;
if (!m.compatible (base_method, out invalid_match)) {
m.error = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment