[Vala] Cannot implement interfaces
- From: Dominique Würtz <housirer gmx de>
- To: vala paldo org
- Subject: [Vala] Cannot implement interfaces
- Date: Thu, 24 Aug 2006 11:45:16 +0200
Hi again,
so now I ran into another bug. Implementing interfaces from bindings
doesn't work.
For example,
using Gtk;
class MyModel : Gtk.TreeModel {
}
fails to compile and gives the error message
test.c: In function 'my_model_get_type':
test.c:71: error: 'my_model_gtk_tree_model_interface_init' undeclared
(first use in this function)
This is because Vala generates a function like this:
static void my_model_gtk_tree_model_interface_init
(GtkTreeModelInterface * iface)
{
}
The interface structs however are usually called GtkTreeModelIface
rather than GtkTreeModelInterface. I attached a patch which lets Vala
use this kind of naming convention.
Regards,
Dominique
diff -Naur old/valacodegenerator.vala new/valacodegenerator.vala
--- old/valacodegenerator.vala 2006-08-24 11:23:00.000000000 +0200
+++ new/valacodegenerator.vala 2006-08-24 10:14:37.000000000 +0200
@@ -508,7 +508,7 @@
private void add_interface_init_function (Class! cl, Interface! iface) {
var iface_init = new CCodeFunction ("%s_%s_interface_init".printf (cl.get_lower_case_cname
(null), iface.get_lower_case_cname (null)), "void");
- iface_init.add_parameter (new CCodeFormalParameter ("iface", "%sInterface *".printf
(iface.get_cname ())));
+ iface_init.add_parameter (new CCodeFormalParameter ("iface", "%sIface *".printf
(iface.get_cname ())));
iface_init.modifiers = CCodeModifiers.STATIC;
var init_block = new CCodeBlock ();
@@ -783,7 +783,7 @@
current_symbol = iface.symbol;
current_type_symbol = iface.symbol;
- type_struct = new CCodeStruct ("_%sInterface".printf (iface.get_cname ()));
+ type_struct = new CCodeStruct ("_%sIface".printf (iface.get_cname ()));
header_type_declaration.append (new CCodeNewline ());
var macro = "(%s_get_type ())".printf (iface.get_lower_case_cname (null));
@@ -795,14 +795,14 @@
macro = "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), %s))".printf (iface.get_upper_case_cname
("TYPE_"));
header_type_declaration.append (new CCodeMacroReplacement ("%s(obj)".printf
(iface.get_upper_case_cname ("IS_")), macro));
- macro = "(G_TYPE_INSTANCE_GET_INTERFACE ((obj), %s, %sInterface))".printf
(iface.get_upper_case_cname ("TYPE_"), iface.get_cname ());
+ macro = "(G_TYPE_INSTANCE_GET_INTERFACE ((obj), %s, %sIface))".printf
(iface.get_upper_case_cname ("TYPE_"), iface.get_cname ());
header_type_declaration.append (new CCodeMacroReplacement ("%s_GET_INTERFACE(obj)".printf
(iface.get_upper_case_cname (null)), macro));
header_type_declaration.append (new CCodeNewline ());
if (iface.source_reference.file.cycle == null) {
header_type_declaration.append (new CCodeTypeDefinition ("struct _%s".printf
(iface.get_cname ()), new CCodeVariableDeclarator (iface.get_cname ())));
- header_type_declaration.append (new CCodeTypeDefinition ("struct %s".printf
(type_struct.name), new CCodeVariableDeclarator ("%sInterface".printf (iface.get_cname ()))));
+ header_type_declaration.append (new CCodeTypeDefinition ("struct %s".printf
(type_struct.name), new CCodeVariableDeclarator ("%sIface".printf (iface.get_cname ()))));
}
type_struct.add_field ("GTypeInterface", "parent");
diff -Naur old/valainterfaceregisterfunction.vala new/valainterfaceregisterfunction.vala
--- old/valainterfaceregisterfunction.vala 2006-08-24 11:23:17.000000000 +0200
+++ new/valainterfaceregisterfunction.vala 2006-08-24 10:40:59.000000000 +0200
@@ -40,7 +40,7 @@
}
public override ref string! get_type_struct_name () {
- return "%sInterface".printf (interface_reference.get_cname ());
+ return "%sIface".printf (interface_reference.get_cname ());
}
public override ref string! get_class_init_func_name () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]