GNOME Bugzilla – Bug 625026
Support for inheritance from interfaces defined using G_DEFINE_INTERFACE
Last modified: 2010-11-21 19:50:29 UTC
When G_DEFINE_INTERFACE is used, the resulting interface definition has a "Interface" suffix instead of the "Iface" suffix expected by vala. This makes it impossible to inherit from such an interface using vala, as the generated code contains the "Iface" suffix instead of the right "Interface" one. This basically makes it impossible to use some new libraries using G_DEFINE_INTERFACE. Bug 559704 has a patch to allow support for such interfaces when using data from a GIR file, but the code generator still expects an "Iface" suffix.
As libpeas use G_DEFINE_INTERFACE, this bug makes it currently impossible to write vala plugins for gedit or totem, among others.
You can use [CCode (type_cname = "YourInterface")] around your interface delcaration in the vapi.
What if I'm using a GIR?
Created attachment 166513 [details] [review] GIR parser: use interface glib:type-name. Fixes bug 625026. The patch is untested.
Created attachment 166514 [details] [review] GIR parser: use interface glib:type-struct. Fixes bug 625026. This patch is untested.
Review of attachment 166514 [details] [review]: ::: vala/valagirparser.vala @@ +89,3 @@ var ns = iface.parent_symbol as Namespace; // remove Iface records + var iface_struct = ns.scope.lookup (iface.get_type_cname ()) as Struct; this will no longer be necessary after my patch in bug 559704 is applied. @@ +769,3 @@ } + string type_cname = reader.get_attribute ("glib:type-struct"); This gives the type name, not the type cname. I'm not sure how to fix this though. (a possible solution is to use a Map from Interface name to type structs and using the cname of that when removing them. I'll try to take a closer look at this)
telepathy-glib in git master uses G_DEFINE_INTERFACE as well, so this breaks the GIR-generated Vala bindings, which Folks depend upon (which Empathy depends upon). I saw that this fix is in the switch-to-gir branch. Is there any way we could get this (and any dependent patches) reviewed and cherry-picked into Vala master when ready?
*** Bug 631834 has been marked as a duplicate of this bug. ***
commit 283a7fcb70fe68a79174cd7e1ff37c8aa07281a9 Author: Luca Bruno <lucabru@src.gnome.org> Date: Thu Sep 2 00:52:57 2010 +0200 girparser: Set type_cname of interfaces from the relative struct cname. Fixes bug 625026.