GNOME Bugzilla – Bug 694627
Broken "array length=..." handling
Last modified: 2018-02-08 12:20:07 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!
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.
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.
>...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.
"Rename-to" with a hyphen?
(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) ... */
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]
Is this still relevant?
> 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".
-- 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.