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 581696 - Support is_garray variants of array types in gjs
Support is_garray variants of array types in gjs
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on: 581687
Blocks:
 
 
Reported: 2009-05-07 04:31 UTC by C. Scott Ananian
Modified: 2010-05-27 18:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Support-is_garray-variants-of-array-types.patch (10.57 KB, patch)
2009-05-07 04:32 UTC, C. Scott Ananian
none Details | Review
Allow-conversion-of-JS-string-to-GArray-guchar.patch (1.29 KB, patch)
2009-05-11 19:25 UTC, C. Scott Ananian
none Details | Review
build GJS arrays from GArrays (7.03 KB, patch)
2010-04-29 08:14 UTC, Danielle Madeley
committed Details | Review
Build GArrays from GJS arrays (3.83 KB, patch)
2010-04-29 10:05 UTC, Danielle Madeley
committed Details | Review

Description C. Scott Ananian 2009-05-07 04:31:58 UTC
This patch uses the GArray support in g-object-introspection (bug 581687) to allow gjs to marshal GArray as in/out parameters (even if wrapped as a gvalue, if bug 581686 and patch 134169 are applied).
Comment 1 C. Scott Ananian 2009-05-07 04:32:23 UTC
Created attachment 134170 [details] [review]
Support-is_garray-variants-of-array-types.patch
Comment 2 C. Scott Ananian 2009-05-11 19:25:39 UTC
Created attachment 134435 [details] [review]
Allow-conversion-of-JS-string-to-GArray-guchar.patch

This additional patch allows converting strings to GArrays of characters/int8/etc.  It depends on the patches attached to bug 581691, and simply broadens an overly restrictive test against JSVAL_IS_OBJECT, since JSVAL_IS_STRING objects can be passed to gjs_value_to_g_argument() too (this was added in bug 581695).
Comment 3 Danielle Madeley 2010-04-29 08:14:05 UTC
Created attachment 159848 [details] [review]
build GJS arrays from GArrays

The existing patches no longer apply to GJS and are not compatible with Tomeu's latest work in bug #581687

This patch will convert GArray arguments into GJS arrays. Tested against the new Telepathy-GLib.gir. Hypothetically it might handle GByteArrays and GPtrArrays but I haven't tested that yet.

Need to support converting from GJS arrays to GArrays. Working on this now.

http://git.collabora.co.uk/?p=user/danni/gjs.git;a=shortlog;h=refs/heads/bug-581696
Comment 4 Danielle Madeley 2010-04-29 10:05:18 UTC
Created attachment 159857 [details] [review]
Build GArrays from GJS arrays

This second patch builds a GArray from the GJS array. Requires extending for GPtrArray and GByteArray.

Tested with Telepathy-GLib.
Comment 5 Danielle Madeley 2010-04-30 02:12:58 UTC
Added a unit test using GIMarshallingTests.
Comment 6 Colin Walters 2010-05-19 21:21:00 UTC
Review of attachment 159848 [details] [review]:

Minor comments, please commit after fixing.

::: gi/arg.c
@@ +1237,3 @@
+        arg.v_##type = g_array_index(array, g##type, i); \
+        if (!gjs_value_from_g_argument(context, &elem, param_info, &arg)) \
+          goto finally; \

I'm a little dropping into gjs_value_from_g_argument for all the integer and FP types as opposed to just calling JS_NewNumberValue directly, but this is OK for now.

@@ +1284,3 @@
+          break;
+        default:
+          gjs_throw(context, "Unknown GArray element-type %d", element_type);

Need goto finally;, right?
Comment 7 Colin Walters 2010-05-27 18:53:24 UTC
I fixed this up for comments and added some tests.

There's definitely more to do here; we need to support e.g. input arrays of utf8.