Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JS_LookupElement Broken in 1.8RC1?

9 views
Skip to first unread message

dave

unread,
Mar 31, 2009, 9:06:41 AM3/31/09
to
I recently started compiling my project against the new release of
spidermonkey (1.8 release candidate 1) and noticed that one of my
functions stopped behaving properly. I looked into it and it seems as
though JS_LookupElement, when run on an array, returns every element
of the array as being a boolean value.

Here's a short snippet of my code:

if (JS_FALSE == JS_GetArrayLength(cx, obj, &a_len)) {
EDJS_ERR(cx, EDJSERR_ARRAY_LEN);
goto error;
}
printf("array: %s\n", JS_GetStringBytes(JS_ValueToString(cx,
OBJECT_TO_JSVAL(obj))));
//prints: "array: a,b,c"

for (i = 0; i < a_len; i++) {
if (JS_FALSE == JS_LookupElement(cx, obj, i, &a_val)) {
goto error;
}

if (JS_TRUE == JSVAL_IS_BOOLEAN(a_val))
printf("value %d is boolean\n", i);
//prints boolean 3 times
//...
}

Am I crazy?

Igor Bukanov

unread,
Mar 31, 2009, 9:35:59 AM3/31/09
to dave, dev-tech-...@lists.mozilla.org
This is a regression in JS1.8RC1 which I filed as
https://bugzilla.mozilla.org/show_bug.cgi?id=486106 . Thanks for
reporting this!

Igor

2009/3/31 dave <man...@gmail.com>:

> _______________________________________________
> dev-tech-js-engine mailing list
> dev-tech-...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine
>

dave

unread,
Mar 31, 2009, 10:33:55 AM3/31/09
to
On Mar 31, 9:35 am, Igor Bukanov <i...@mir2.org> wrote:
> This is a regression in JS1.8RC1 which I filed ashttps://bugzilla.mozilla.org/show_bug.cgi?id=486106. Thanks for
> reporting this!
>
> Igor
>

No, thank you!

Igor Bukanov

unread,
Mar 31, 2009, 12:40:08 PM3/31/09
to dave, dev-tech-...@lists.mozilla.org
Another note is that in your case you should use JS_GetElement API to
get the elements of the array. JS_LookupElement will give you a wrong
result when the corresponding element in the array has a getter as the
API does not run the getter. Its purpose is mostly intended to query
if the corresponding element exists rather then querying its value.

Igor

2009/3/31 dave <man...@gmail.com>:

dave

unread,
Mar 31, 2009, 1:11:55 PM3/31/09
to
On Mar 31, 12:40 pm, Igor Bukanov <i...@mir2.org> wrote:
> Another note is that in your case you should use JS_GetElement API to
> get the elements of the array. JS_LookupElement will give you a wrong
> result when the corresponding element in the array has a getter as the
> API does not run the getter. Its purpose is mostly intended to query
> if the corresponding element exists rather then querying its value.
>
> Igor

Thanks for the tip. I will implement the change.

0 new messages