Skip Menu |

This queue is for tickets about the JavaScript-SpiderMonkey CPAN distribution.

Report information
The Basics
Id: 17627
Status: open
Priority: 0/
Queue: JavaScript-SpiderMonkey

People
Owner: Nobody in particular
Requestors: whatever [...] davidnicol.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.12
Fixed in: (no value)



Subject: is coercing undefineds to q/undef/ in property_by_path really necessary?
line 403 of SpiderMonkey.pm sets $value= q'undef' when !defined($value). This has caused some surprises. JS has a perfectly well-defined undefined value, why can't perl/undef()/ get mapped to js/undefined/?
From: benkasminbullock [...] gmail.com
On Mon Feb 13 20:25:48 2006, guest wrote: Show quoted text
> line 403 of SpiderMonkey.pm sets $value= q'undef' when
!defined($value). Show quoted text
> > This has caused some surprises. JS has a perfectly well-defined
undefined Show quoted text
> value, why can't perl/undef()/ get mapped to js/undefined/? >
This is actually very easy to fix inside SpiderMonkey.xs as follows: if (strcmp (value, "undef") == 0) { rc = JS_DefineProperty(cx, obj, name, JSVAL_VOID, getter_dispatcher, setter_dispatcher, 0); } else { /* This implementation is somewhat sub-optimal, since it * calls back into perl even if no getters/setters have * been defined. The necessity for a callback is determined * at the perl level, where there's a data structure mapping * out each object's properties and their getter/setter settings. */ rc = JS_DefineProperty(cx, obj, name, STRING_TO_JSVAL(str), getter_dispatcher, setter_dispatcher, 0); } That has the bug that if the user actually wants a string with value "undef" it won't work, but there must be an easy way around that. All the tests of the module pass with the above alteration.