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 559425 - Length of arrays arguments treated inconsistently wrt. implicit "self" parameter
Length of arrays arguments treated inconsistently wrt. implicit "self" parameter
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: general
2.19.x
Other Linux
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks: 559704
 
 
Reported: 2008-11-05 14:23 UTC by Andreas Rottmann
Modified: 2015-02-07 16:54 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Andreas Rottmann 2008-11-05 14:23:17 UTC
When you have multiple array arguments that refer to a single length argument, the index of the generated length ends up wrong, for example:

void     annotation_object_compute_msq_n(AnnotationObject *object,
                                         int n_nums,
                                         double *nums1,
                                         double *nums2);

In this case, "nums1" and "nums2" get a length index of one, instead of zero (as the "object" parameter is implicit).
Comment 1 Andreas Rottmann 2008-11-05 14:36:26 UTC
I just noticed that this affects all array arguments with length annotations, i.e. the "self" parameter taken into account for the length, but it is implicit in the GIR/typelib. Is this in fact intended behaviour? If so, this bug can be closed.
Comment 2 Colin Walters 2008-11-05 18:54:24 UTC
Well, you could alternatively think of it as being 1-based.  But I don't have a strong opinion either way; if we keep it this way we should document it, if we change it we should document it and go through the bindings to fix them.
Comment 3 Andreas Rottmann 2008-11-10 23:28:54 UTC
Well, if it's one-based, then it's only one-based for methods, e.g. from the g-ir-generate output for the GTK+ typelib:

   <function name="init" c:identifier="gtk_init">
      <return-value transfer-ownership="none">
        <type name="none"/>
      </return-value>
       <parameters>
        <parameter name="argc" transfer-ownership="full" direction="inout">
          <type name="int"/>
        </parameter>
        <parameter name="argv" transfer-ownership="none" direction="inout">
          <array length="0" zero-terminated="1">
            <type name="utf8"/>
          </array>
        </parameter>
      </parameters>
    </function>

I think that's a little bit inconsistent.
Comment 4 Colin Walters 2010-10-29 17:38:51 UTC
Array lengths should be consistent now.
Comment 5 André Klapper 2015-02-07 16:54:53 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]