Subject: | Passing large 32-bit integer value becomes negative on 32-bit Perl |
The function sv2v8 uses SvIOK to determine integer compatibility of Sv as numeric value. On 32-bit Perls, however, this will convert unsigned 32-bit value to signed 32-bit value, causing a corresponding test failure.
Before the SvIOK test, something like this should be done:
if (SvUOK(sv)) {
UV v = SvUV(sv);
return (v < 0xffffffffUL) ? (Handle<Number>)Integer::NewFromUnsigned(v) : Number::New(SvNV(v));
}
which allows representation range up to 0xffffffff on 32-bit hardware, and should work correctly on 64-bit hardware.