GNOME Bugzilla – Bug 565147
[annotation] Add type overriding
Last modified: 2015-02-07 16:46:07 UTC
clutter_stage_get_default() and clutter_actor_get_stage() are annoying because they're prototyped to return a "ClutterActor *", even though statically they are always a ClutterStage *. For constructors this isn't a problem for JGIR (and in general I believe all static bindings) because we know we can override the return type for constructors. But this appears as a generic method. Suggested fix: a new annotation: (return ClutterStage) Feel free to bikeshed on the name etc.
Yes, this is important and something we need pretty soon. I think we should try to be a bit more generic and use just 'type', eg: @param_name: (type GObject): Return value: (type Stage): It's already mentioned on the http://live.gnome.org/GObjectIntrospection/Annotations page.
Ah, (type) is indeed nicer.
I've actually started to use this already. Only tested for signal callbacks, it probably works elsewhere but it would have to tested first.
Created attachment 129079 [details] [review] Bug 565147 - Add (type) annotation to override the C type definition This is useful for a few cases where libraries use a superclass like GtkWidget* for C convenience, where the actual type is subclass.
Created attachment 129367 [details] [review] Bug 565147 - Add (type) annotation to override the C type definition We previously supported (type) on signals only, extend it to all cases. This is useful for a few cases where libraries use a superclass like GtkWidget* for C convenience, where the actual type is a subclass.
This new version merges in the tests from bug 552375, adjusting them to use (type filename) instead of just (filename). It also fixes trailing whitespace.
*** Bug 552375 has been marked as a duplicate of this bug. ***
Comment on attachment 129367 [details] [review] Bug 565147 - Add (type) annotation to override the C type definition Looks great, thanks!
This does not handle soup_auth_domain_basic_set_auth_callback(): void soup_auth_domain_basic_set_auth_callback (SoupAuthDomain *domain, SoupAuthDomainBasicAuthCallback callback, gpointer user_data, GDestroyNotify dnotify); note that the first arg is listed as a SoupAuthDomain, even though really it needs to be a SoupAuthDomainBasic. Since soup_auth_domain_basic_new() returns a SoupAuthDomain, and there are no other SoupAuthDomainBasic methods, I decided to cheat and make _set_auth_callback() take a SoupAuthDomain instead of forcing you to cast the object to the more specific type in order to make that one method call... The scanner currently turns this into a method called "basic_set_auth_callback" on SoupAuthDomain. I'd thought I'd be able to fix it with: /** * soup_auth_domain_basic_set_auth_callback: * @domain: (type SoupAuthDomainBasic): */ but that has no effect. Should that work?
Hmm...it should probably work, but reason it doesn't right now is that we currently parse annotations *after* we've paired up a method with its class.
Created attachment 131187 [details] [review] Add (non-working) test case for re-typing the first argument of a method In order to trigger the bug, we need to rename FooSubobject to FooObjectSub so that the parent class name is a substring of the child class name.
(In reply to comment #10) > Hmm...it should probably work reopening with an addition to the tests for that case then
*** Bug 615233 has been marked as a duplicate of this bug. ***
Should the patch be marked needs-work then?
Since the transformer rework before g-i 1.0, annotations are read before matching methods, so (type) works on the first argument too. I'd say this is fixed and the patch is no longer needed.
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]