After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 625026 - Support for inheritance from interfaces defined using G_DEFINE_INTERFACE
Support for inheritance from interfaces defined using G_DEFINE_INTERFACE
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator: GObject
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
: 631834 (view as bug list)
Depends on:
Blocks: 622664
 
 
Reported: 2010-07-22 11:10 UTC by Steve Frécinaux
Modified: 2010-11-21 19:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GIR parser: use interface glib:type-name. (2.77 KB, patch)
2010-07-25 10:16 UTC, Luca Bruno
none Details | Review
GIR parser: use interface glib:type-struct. (2.78 KB, patch)
2010-07-25 10:23 UTC, Luca Bruno
needs-work Details | Review

Description Steve Frécinaux 2010-07-22 11:10:12 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.
Comment 1 Steve Frécinaux 2010-07-22 11:11:00 UTC
As libpeas use G_DEFINE_INTERFACE, this bug makes it currently impossible to write vala plugins for gedit or totem, among others.
Comment 2 Luca Bruno 2010-07-25 06:18:10 UTC
You can use [CCode (type_cname = "YourInterface")] around your interface delcaration in the vapi.
Comment 3 Steve Frécinaux 2010-07-25 09:51:11 UTC
What if I'm using a GIR?
Comment 4 Luca Bruno 2010-07-25 10:16:42 UTC
Created attachment 166513 [details] [review]
GIR parser: use interface glib:type-name.

Fixes bug 625026.

The patch is untested.
Comment 5 Luca Bruno 2010-07-25 10:23:32 UTC
Created attachment 166514 [details] [review]
GIR parser: use interface glib:type-struct.

Fixes bug 625026.

This patch is untested.
Comment 6 Abderrahim Kitouni 2010-08-12 11:35:11 UTC
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)
Comment 7 Travis Reitter 2010-10-15 16:39:56 UTC
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?
Comment 8 Jürg Billeter 2010-10-16 07:44:39 UTC
*** Bug 631834 has been marked as a duplicate of this bug. ***
Comment 9 Luca Bruno 2010-11-21 19:50:29 UTC
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.