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 650176 - Use (skip) annotation on return-val/args where appropriate
Use (skip) annotation on return-val/args where appropriate
Status: RESOLVED DUPLICATE of bug 708301
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: 2011-05-14 14:11 UTC by David Zeuthen (not reading bugmail)
Modified: 2015-02-07 16:45 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description David Zeuthen (not reading bugmail) 2011-05-14 14:11:36 UTC
In bug 649657 we added support for using the (skip) annotation on return values and parameters. We should convert all of GLib (and everything else but those are separate bugs) to use this annotation everywhere where appropriate.

For example, as pointed out in bug 649657 comment 5, g_file_get_contents() should use this so python programmers can write e.g.

 [contents, len] = GLib.file_get_contents('/etc/hosts')

instead of

 [success, contents, len] = GLib.file_get_contents('/etc/hosts')

where the success return value is True unless an exception was raised (e.g. rendering success useless which is why we want to skip it).

(Btw, another problem is that the returned contents variable probably shouldn't be of Python type 'str' since that won't work with embedded NUL bytes. Maybe g_file_get_contents() should a guchar* (or guint8*) instead of gchar* and then the binding would just DTRT - this would be an API break but not an ABI break. So I guess it's fine doing this in GLib.)

Obviously, this breaks the Introspectable ABI of GLib but in a way it's really not different from all the other annotation additions that has been added to fix bugs. Well, maybe it is. So probably want to wait until the next ABI break. I don't know.

I don't know how much change this is but I don't think it's too hard to do.
Comment 1 Mikhail Zabaluev 2014-10-08 20:52:57 UTC
This sounds like a tedious task to do manually.
Perhaps a silent assumption can be made for gboolean return values that they are redundant for throwing functions, and the fact of no-throw can itself indicate success in the binding. There might need to be an annotation to mark out non-redundant boolean returns, though.

For one binding, Rust's would use a generically defined algebraic type `Result<RetType, Error>` for return values of throwing functions, which would carry an `Ok` value wrapping the return value in the no-error case, or an `Err` value with a wrapped `GError` in case of the `GError*` being set. The out parameter slots would be passed by mutable reference. So, no problem with the return signature there: if the error slot is not set, a Ok(false) will be returned.
Comment 2 Allison Karlitskaya (desrt) 2014-10-09 13:37:29 UTC

*** This bug has been marked as a duplicate of bug 708301 ***
Comment 3 André Klapper 2015-02-07 16:45:23 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]