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 633447 - add annotations for override="always" and override="never"
add annotations for override="always" and override="never"
Status: RESOLVED OBSOLETE
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2010-10-29 11:22 UTC by Jonathan Matthew
Modified: 2018-02-08 12:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
add annotations, write vfunc flags into typelib (6.89 KB, patch)
2010-10-29 11:23 UTC, Jonathan Matthew
none Details | Review
use (contains-default) option instead (9.25 KB, patch)
2010-10-31 05:02 UTC, Jonathan Matthew
none Details | Review
add (has-default) option (9.20 KB, patch)
2010-11-06 08:57 UTC, Jonathan Matthew
none Details | Review

Description Jonathan Matthew 2010-10-29 11:22:13 UTC
There's currently no way to have any of the vfunc flags set in a typelib.  The patch I'm attaching here adds 'override: always' and 'override: never' annotations, which end up looking something like this:

/**
 * interface_method:
 * override: always
 */

and which set the must_be_implemented and must_not_be_implemented flags in the vfunc blob in the typelib.
Comment 1 Jonathan Matthew 2010-10-29 11:23:41 UTC
Created attachment 173469 [details] [review]
add annotations, write vfunc flags into typelib
Comment 2 Colin Walters 2010-10-29 15:34:00 UTC
What are examples of real-world code where this is needed?
Comment 4 Colin Walters 2010-10-29 15:46:34 UTC
Without doing actual research, my instinct is that "most" vfuncs don't contain defaults.  In other words, the existing GIVFuncInfoFlags are not optimal.

GI_VFUNC_MUST_OVERRIDE is basically the opposite of what I'd expect, which would be GI_VFUNC_CONTAINS_DEFAULT.

And what is GI_VFUNC_MUST_NOT_OVERRIDE?  I don't understand that one.  What would be the point of a virtual one can't override?

Adding mclasen@ to CC as he stubbed out this API long ago and may still remember the rationale =)
Comment 5 johnp 2010-10-29 17:36:26 UTC
The most important flag for us is the MUST_OVERRIDE flag.  This gives us the ability to warn the user much more effectively.  This is similar to C++'s pure virtual interfaces which will error out if one of the pure virtual methods isn't implemented.  I think we are still doing the wrong thing in PyGI though.  We need to be able to ignore this issue when overriding because in essence we are not creating final classes.  I would like us to have a MUST_OVERRIDE, PURE_VIRTUAL or HAS_DEFAULT flag.  The rest I don't think is particularly interesting unless there is such things as MUST_NOT_OVERRIDE.
Comment 6 Colin Walters 2010-10-29 17:51:30 UTC
(In reply to comment #5)

Right, but I think that following the principle of safety, we should assume you have to override, and the annotation should be more of the form:

/**
 * foo_vfunc: (contains-default)
 *
 */
Comment 7 Jonathan Matthew 2010-10-30 01:29:02 UTC
Sounds reasonable.  I have no idea what MUST_NOT_OVERRIDE is for either.
Comment 8 Jonathan Matthew 2010-10-31 05:02:38 UTC
Created attachment 173583 [details] [review]
use (contains-default) option instead

I'm not sure if 'contains-default' is the right name, but I can't think of anything better right now.
Comment 9 Dan Winship 2010-10-31 15:46:13 UTC
people don't generally refer to interfaces as "containing" methods. I'd say "has-default". or even "has-default-implementation".
Comment 10 Jonathan Matthew 2010-11-06 08:57:41 UTC
Created attachment 173936 [details] [review]
add (has-default) option

OK, let's try (has-default) instead.
Comment 11 André Klapper 2015-02-07 17:14:43 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]
Comment 12 GNOME Infrastructure Team 2018-02-08 12:01:28 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gobject-introspection/issues/39.