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 787812 - Annotation Documentation for gchar* incorrect
Annotation Documentation for gchar* incorrect
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: docs
1.46.x
Other All
: Normal minor
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2017-09-17 23:26 UTC by Alisa Maas
Modified: 2017-09-18 12:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Example to reproduce the issue. (83.13 KB, application/zip)
2017-09-17 23:26 UTC, Alisa Maas
Details

Description Alisa Maas 2017-09-17 23:26:05 UTC
Created attachment 359954 [details]
Example to reproduce the issue.

The documentation indicates that the default annotations for gchar* should be (type utf8) (transfer full) (see https://wiki.gnome.org/Projects/GObjectIntrospection/Annotations). However, in practice, it appears that they are actually annotated (type utf8) (transfer none). 

Attached is a modified version of the tutorial code with function parameters that are gchar* and char*, but receive annotations of (type utf8) (transfer none). I don't know whether (transfer none) might actually be the right thing to do in many cases, but if it is now the default, the documentation should reflect this.
Comment 1 Emmanuele Bassi (:ebassi) 2017-09-18 11:58:47 UTC
The default annotation of `(type utf8) (transfer full)` for `char*` is for return types.

For out and in-out arguments, the default annotation is `(transfer full)`, unless marked as `(caller-allocates)`, in which case you get a `(transfer none)`.

In your example, the API uses a `char*` as an in-argument to a function, which means that the default transfer rule is `none`.

I'll amend the documentation.
Comment 2 Emmanuele Bassi (:ebassi) 2017-09-18 12:04:46 UTC
The wiki page now reads:

```
Default Annotations: To avoid having the developers annotate everything the introspection framework is providing sane default annotation values for a couple of situations:

 * (in) parameters: (transfer none)
 * (inout) and (out) parameters: (transfer full)
  * if (caller allocates) is set: (transfer none)
 * gchar* means (type utf8)
 * return values: (transfer full)
  * gchar* means (type utf8) (transfer full)
  * const gchar* means (type utf8) (transfer none)
  * GObject* defaults to (transfer full)
```

The confusion was mostly due to the fact that the last three items in the list were supposed to refer to the "return values" item, but the indentation to create a sub-list was missing.