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 584568 - Array support
Array support
Status: RESOLVED DUPLICATE of bug 560567
Product: gjs
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2009-06-02 00:28 UTC by David Zeuthen (not reading bugmail)
Modified: 2010-02-08 20:07 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add Array support (4.92 KB, patch)
2009-06-02 00:37 UTC, David Zeuthen (not reading bugmail)
needs-work Details | Review

Description David Zeuthen (not reading bugmail) 2009-06-02 00:28:23 UTC
As I blogged about here http://blog.fubar.dk/?p=106 I ran into problems with gjs when trying to use methods returning arrays of strings, e.g. when using a function like

http://people.freedesktop.org/~david/gudev/GUdevDevice.html#g-udev-device-get-device-file-symlinks

with these GIR bits

        <return-value transfer-ownership="none"
                      doc="A %NULL terminated string array of symlinks. This array is owned by @device and should not be freed by the caller.">
          <array c:type="gchar**">
            <type name="utf8"/>
          </array>
        </return-value>

Specifically I ran into this bug

 FIXME: Only supporting null ARRAYs

in gi/arg.c. I will attach a patch that attempts to fix this.
Comment 1 David Zeuthen (not reading bugmail) 2009-06-02 00:37:59 UTC
Created attachment 135781 [details] [review]
Add Array support

Here's a patch to handle arrays. I've tested it with GUdev and it seems to work great.

Note that due to bug 584453 this isn't terribly useful until either people start annotating libraries correctly or we start adopting more useful default annotations. For example, consider g_get_system_data_dirs()

    <function name="get_system_data_dirs"
              c:identifier="g_get_system_data_dirs">
      <return-value transfer-ownership="full">
        <type name="utf8" c:type="gchar**"/>
      </return-value>
    </function>

However if we fix that, e.g. change the GIR to

    <function name="get_system_data_dirs"
              c:identifier="g_get_system_data_dirs">
      <return-value transfer-ownership="none">
        <array c:type="gchar**">
          <type name="utf8"/>
        </array>
      </return-value>
    </function>

and rebuild the typelib then things work as expected:

$ gjs-console 
gjs> const GLib = imports.gi.GLib;
gjs> GLib.get_system_data_dirs ();
/usr/local/share/,/usr/share/
Comment 2 Johan Bilien 2009-06-15 16:45:09 UTC
I missed that one and ended up implementing something similar in bug# 585852

I think my patch has the advantage of not duplicating some code by reusing the list -> array code path, while your has the advantage of handling non-zero-terminated arrays.

I think your patch should check whether the array is an array of strings (or at least an array of pointers).
Comment 3 Owen Taylor 2009-08-24 17:00:51 UTC
Comment on attachment 135781 [details] [review]
Add Array support

Patch overlaps and conflicts with Johan's committed patch. Is there some part of this that still makes sense, or should the bug be closed?
Comment 4 Johan (not receiving bugmail) Dahlin 2010-02-08 20:07:12 UTC
I'm  marking this as a duplicate of bug 560567 as the patch for array support should probably do input and output arguments.

*** This bug has been marked as a duplicate of bug 560567 ***