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 634253 - Support any null-terminated C array (to JS)
Support any null-terminated C array (to JS)
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks: 634332
 
 
Reported: 2010-11-07 21:59 UTC by Giovanni Campagna
Modified: 2011-05-13 15:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Support null terminated C arrays of any type (3.96 KB, patch)
2010-11-07 22:01 UTC, Giovanni Campagna
needs-work Details | Review
Support null terminated C arrays of any type (5.89 KB, patch)
2011-02-17 21:41 UTC, Giovanni Campagna
reviewed Details | Review
Add tests for returning zero-terminated arrays of non-strings (2.66 KB, patch)
2011-05-12 20:49 UTC, Giovanni Campagna
committed Details | Review
Support null terminated C arrays of any type (6.36 KB, patch)
2011-05-12 20:50 UTC, Giovanni Campagna
committed Details | Review

Description Giovanni Campagna 2010-11-07 21:59:38 UTC
gjs_value_from_g_argument says:
"FIXME: Only supporting null-terminated arrays of strings"

and we don't like FIXMEs, do we?
Comment 1 Giovanni Campagna 2010-11-07 22:01:18 UTC
Created attachment 174030 [details] [review]
Support null terminated C arrays of any type

Before, only string arrays (GStrv) were supported.
Now C arrays can be converted to JS arrays regardless of their
type.
Comment 2 Johan (not receiving bugmail) Dahlin 2011-02-17 17:24:50 UTC
Review of attachment 174030 [details] [review]:

This looks quite good in general, but you need to add some tests for this and run make valgrind-check to make sure you don't leak anything.
Comment 3 Giovanni Campagna 2011-02-17 21:41:35 UTC
Created attachment 181176 [details] [review]
Support null terminated C arrays of any type

Before, only string arrays (GStrv) were supported.
Now C arrays can be converted to JS arrays regardless of their
type.
Comment 4 Alphazo 2011-05-06 16:01:52 UTC
It looks like this issue prevents xrandr-indicator to work https://bugzilla.gnome.org/show_bug.cgi?id=649077

Why has this patch not applied yet to the git version?
Comment 5 Colin Walters 2011-05-11 20:54:29 UTC
Review of attachment 181176 [details] [review]:

::: gi/arg.c
@@ +1986,2 @@
                 }
 

Is there a reason we can't remove the special case for GI_TYPE_TAG_UTF8 above and just rely on gjs_array_from_zero_terminated_c_array() to handle char**?
Comment 6 Giovanni Campagna 2011-05-12 20:49:44 UTC
Created attachment 187740 [details] [review]
Add tests for returning zero-terminated arrays of non-strings

gjs has always supported zero-terminated arrays of strings, and
nothing else. Now that this changed, we need to test it.

(Patch against gobject-introspection for libgimarshallingtests)
Comment 7 Giovanni Campagna 2011-05-12 20:50:17 UTC
Created attachment 187741 [details] [review]
Support null terminated C arrays of any type

Before, only string arrays (GStrv) were supported.
Now C arrays can be converted to JS arrays regardless of their
type.

Now with tests!
Comment 8 Colin Walters 2011-05-12 20:59:48 UTC
Review of attachment 187741 [details] [review]:

One minor issue (only relevant on older SpiderMonkey), feel free to commit after fixing.

::: gi/arg.c
@@ +1914,3 @@
+
+finally:
+    JS_RemoveValueRoot(context, &elem);

There's no call to JS_AddValueRoot corresponding to this.
Comment 9 Giovanni Campagna 2011-05-13 15:48:17 UTC
Comment on attachment 187740 [details] [review]
Add tests for returning zero-terminated arrays of non-strings

Attachment 187740 [details] pushed as b29b3ec - Add tests for returning zero-terminated arrays of non-strings
Comment 10 Giovanni Campagna 2011-05-13 15:49:05 UTC
Attachment 187741 [details] pushed as 23c687d - Support null terminated C arrays of any type