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 565147 - [annotation] Add type overriding
[annotation] Add type overriding
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
: 552375 615233 (view as bug list)
Depends on: 563794
Blocks:
 
 
Reported: 2008-12-20 02:46 UTC by Colin Walters
Modified: 2015-02-07 16:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Bug 565147 - Add (type) annotation to override the C type definition (4.71 KB, patch)
2009-02-19 17:17 UTC, Colin Walters
none Details | Review
Bug 565147 - Add (type) annotation to override the C type definition (8.74 KB, patch)
2009-02-23 20:30 UTC, Colin Walters
rejected Details | Review
Add (non-working) test case for re-typing the first argument of a method (11.09 KB, patch)
2009-03-23 14:20 UTC, Dan Winship
none Details | Review

Description Colin Walters 2008-12-20 02:46:43 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.
Comment 1 Johan (not receiving bugmail) Dahlin 2008-12-20 02:52:07 UTC
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.
Comment 2 Colin Walters 2008-12-20 02:53:37 UTC
Ah, (type) is indeed nicer.
Comment 3 Johan (not receiving bugmail) Dahlin 2009-01-22 11:57:14 UTC
I've actually started to use this already. Only tested for signal callbacks, it probably works elsewhere but it would have to tested first.
Comment 4 Colin Walters 2009-02-19 17:17:39 UTC
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.
Comment 5 Colin Walters 2009-02-23 20:30:52 UTC
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.
Comment 6 Colin Walters 2009-02-23 20:31:38 UTC
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.
Comment 7 Colin Walters 2009-02-23 20:32:12 UTC
*** Bug 552375 has been marked as a duplicate of this bug. ***
Comment 8 Johan (not receiving bugmail) Dahlin 2009-03-15 15:01:14 UTC
Comment on attachment 129367 [details] [review]
Bug 565147 - Add (type) annotation to override the C type definition

Looks great, thanks!
Comment 9 Dan Winship 2009-03-18 00:01:23 UTC
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?
Comment 10 Colin Walters 2009-03-18 17:23:53 UTC
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.

Comment 11 Dan Winship 2009-03-23 14:20:44 UTC
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.
Comment 12 Dan Winship 2009-03-23 14:22:09 UTC
(In reply to comment #10)
> Hmm...it should probably work

reopening with an addition to the tests for that case then
Comment 13 Dan Winship 2010-04-26 20:13:33 UTC
*** Bug 615233 has been marked as a duplicate of this bug. ***
Comment 14 Kjartan Maraas 2010-09-07 07:24:55 UTC
Should the patch be marked needs-work then?
Comment 15 Giovanni Campagna 2012-03-15 21:19:57 UTC
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.
Comment 16 André Klapper 2015-02-07 16:46:07 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]