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.