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 552377 - String/length parameter pairs should reference each other.
String/length parameter pairs should reference each other.
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks: 559704
 
 
Reported: 2008-09-15 16:24 UTC by Mike Kestner
Modified: 2015-02-07 16:54 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Mike Kestner 2008-09-15 16:24:42 UTC
Please describe the problem:
Often, methods have the form void Foo (gchar *text, int text_len);

The association between the two parameters needs annotation so that bindings can perform the proper encoding manipulations for the len parameter.

Another, potentially more difficult to annotate, scenario is the scenario where an out string parameter has its length annotated by the return value of a function.  I vaguely recall working around that one.  I'll see if I can come up with a real example.

Steps to reproduce:


Actual results:


Expected results:


Does this happen every time?


Other information:
Comment 1 Colin Walters 2008-10-02 14:19:33 UTC
Note for this one right now the typelib format only has ArrayTypeBlob with a length index.  

A few things are needed for this - first we need to come up with an annotation for binding buffers and length together.  For arrays this looks currently like:

<array,length=3>

Maybe we could use:

<utf8,length=3>

After that the typelib format needs to support this.  One random thought is to actually compile these as GI_TYPE_TAG_ARRAY.  We then take one of the reserved bits in ArrayTypeBlob to say "this is a utf8".  It basically is a special kind of byte[] C-land.
Comment 2 Havoc Pennington 2008-11-30 19:44:19 UTC
There's a g_file_get_contents() annotation as if it should be working, but it seems to end up in the typelib as "array of strings" not "string" - is this theoretically working now or known still-not-done?

(as a side note, g_file_get_contents() probably returns a byte array, not a utf8)

    <function name="file_get_contents"
              c:identifier="g_file_get_contents"
              throws="1">
      <return-value transfer-ownership="none">
        <type name="boolean" c:type="gboolean"/>
      </return-value>
      <parameters>
        <parameter name="filename" transfer-ownership="none">
          <type name="utf8" c:type="gchar*"/>
        </parameter>
        <parameter name="contents" direction="out" transfer-ownership="full">
          <array c:type="gchar**">
            <type name="utf8"/>
          </array>
        </parameter>
        <parameter name="length"
                   direction="out"
                   transfer-ownership="full"
                   allow-none="1">
          <type name="size_t" c:type="gsize*"/>
        </parameter>
      </parameters>
    </function>
Comment 3 Emmanuele Bassi (:ebassi) 2013-08-26 10:57:00 UTC
this has long since been fixed: we can associated array arguments with length ones.
Comment 4 André Klapper 2015-02-07 16:54:24 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]