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 604023 - Allow any basic type to be used as the key in a dbus dict
Allow any basic type to be used as the key in a dbus dict
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2009-12-07 21:33 UTC by Dan Winship
Modified: 2009-12-08 20:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Allow any basic type to be used as the key in a dbus dict (3.34 KB, patch)
2009-12-07 21:33 UTC, Dan Winship
committed Details | Review

Description Dan Winship 2009-12-07 21:33:17 UTC
Telepathy has a method with return type a{us}. gjs doesn't like this
because the key type isn't 's', but there's no real reason it couldn't
just toString() the key in this case, and it would all just work from
the js side.

I'm not totally sure the memory management here is correct because I'm
not familiar with spidermonkey. (I just copied code that was used in other
places in gjs.)
Comment 1 Dan Winship 2009-12-07 21:33:19 UTC
Created attachment 149295 [details] [review]
Allow any basic type to be used as the key in a dbus dict
Comment 2 Johan (not receiving bugmail) Dahlin 2009-12-08 17:49:46 UTC
Review of attachment 149295 [details] [review]:

Rest looks quite good to me.

::: modules/dbus-values.c
@@ +119,3 @@
+                    if (!gjs_js_one_value_from_dbus(context, &entry_iter, &key_value)) {
+                    JS_AddRoot(context, &entry_value);
+                    entry_value = JSVAL_VOID;

You should probably call JS_AddRoot upon this as well, to protect it from being GC:ed.
Comment 3 Dan Winship 2009-12-08 20:04:20 UTC
fixed and pushed

Attachment 149295 [details] pushed as 3c094bb - Allow any basic type to be used as the key in a dbus dict