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 694627 - Broken "array length=..." handling
Broken "array length=..." handling
Status: RESOLVED OBSOLETE
Product: gobject-introspection
Classification: Platform
Component: g-ir-scanner
unspecified
Other All
: Normal major
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2013-02-24 22:51 UTC by Morten Welinder
Modified: 2018-02-08 12:20 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Morten Welinder 2013-02-24 22:51:52 UTC
I want to add introspection hints for this function

guint8 const *
gsf_input_read (GsfInput *input, size_t num_bytes, guint8 *optional_buffer)

FYI, optional_buffer should either be NULL or a buffer of length num_bytes.
I would be happy if there was a way to simply make bindings always use NULL.
The return value is either the optional_buffer, or -- in case of NULL, an
internal buffer of length num_bytes.

Note, that num_bytes is of an integral type.  There is absolute no way any
information can be returned through that.  In other words, it's an "in" node.



Here's what should work:

 * gsf_input_read:
 * @input: the input stream
 * @num_bytes (in): number of bytes to read
 * @optional_buffer: (array length=num_bytes) (allow-none) (transfer none)

 * Returns: (transfer none) (array length=num_bytes) pointer to the...


This doesn't work: first num_bytes' direction gets overwritten by @optional_buffer's.  Then it gets overwritten by the result's direction
and ends up as an "out" node.  That makes no sense!
Comment 1 Dan Winship 2013-02-25 08:18:36 UTC
ignoring the question of whether or not this *should* work, a workaround is to add

  guint8 const *gsf_input_read_to_internal_buffer (GsfInput *input, size_t num_bytes);

and annotate it 'Rename to: gsf_input_read' to have it replace the non-introspectable version in the gir.
Comment 2 Morten Welinder 2013-02-25 14:07:00 UTC
that doesn't actually work either because if I do...

 * Returns: (transfer none) (array length=num_bytes) pointer to the...

...then num_bytes becomes an "out" parameter and the python bindings don't
let me supply the argument at all.  However, if I do...

guint8 *
gsf_input_read0 (GsfInput *input, size_t num_bytes, size_t *bytes_read)

...where bytes_read is just filled in with num_bytes, then it does
actually work.

The array-length handling really shouldn't override a user's direction
annotation.
Comment 3 Morten Welinder 2014-06-03 11:50:23 UTC
>...and annotate it 'Rename to: gsf_input_read' to have it replace the
>non-introspectable version in the gir.

What's the current incantation for this?  this syntax seems to be deprecated.
Comment 4 Dan Winship 2014-06-03 12:32:12 UTC
"Rename-to" with a hyphen?
Comment 5 Simon Feltman 2014-08-20 01:55:04 UTC
(In reply to comment #3)
> >...and annotate it 'Rename to: gsf_input_read' to have it replace the
> >non-introspectable version in the gir.
> 
> What's the current incantation for this?  this syntax seems to be deprecated.

I believe it would be:

/**
 * gsf_input_read_to_internal_buffer: (rename-to gsf_input_read)
...
 */
Comment 6 André Klapper 2015-02-07 17:17:54 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]
Comment 7 Emmanuele Bassi (:ebassi) 2018-01-25 16:32:32 UTC
Is this still relevant?
Comment 8 Morten Welinder 2018-01-25 17:12:10 UTC
> Is this still relevant?

In the sense that it's a bug, yes.  It's been worked around, of course,
but the original bug description still applies.

Here's what it creates for num_bytes:

          <parameter name="num_bytes"
                     direction="out"
                     caller-allocates="0"
                     transfer-ownership="full">
            <type name="gulong" c:type="size_t"/>
          </parameter>

Somehow it thinks it is going to return a value in something that has
C type "size_t".
Comment 9 GNOME Infrastructure Team 2018-02-08 12:20:07 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/78.