0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-22 09:21:52 +00:00

Passing integers that didn't fit in 32-bit integers from PHP to Javascript

did not work properly, now uses float to pass larger numbers.
This commit is contained in:
Taneli Leppa 2014-03-20 12:00:45 +02:00
parent 0a85d27ee7
commit 9ddac3f124
2 changed files with 9 additions and 1 deletions

View File

@ -91,6 +91,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
<file name="array_pass.phpt" role="test" />
<file name="array_pass_flags.phpt" role="test" />
<file name="timezones.phpt" role="test" />
<file name="long.phpt" role="test" />
</dir>
</dir>
</contents>

View File

@ -28,6 +28,7 @@ extern "C" {
#include "php_v8js_macros.h"
#include <v8.h>
#include <stdexcept>
#include <limits>
static void php_v8js_weak_object_callback(const v8::WeakCallbackData<v8::Object, zval> &data);
@ -852,6 +853,7 @@ static v8::Handle<v8::Value> php_v8js_hash_to_jsarr(zval *value, v8::Isolate *is
v8::Handle<v8::Value> zval_to_v8js(zval *value, v8::Isolate *isolate TSRMLS_DC) /* {{{ */
{
v8::Handle<v8::Value> jsValue;
long v;
switch (Z_TYPE_P(value))
{
@ -868,7 +870,12 @@ v8::Handle<v8::Value> zval_to_v8js(zval *value, v8::Isolate *isolate TSRMLS_DC)
break;
case IS_LONG:
jsValue = V8JS_INT(Z_LVAL_P(value));
v = Z_LVAL_P(value);
if (v < - std::numeric_limits<int32_t>::min() || v > std::numeric_limits<int32_t>::max()) {
jsValue = V8JS_FLOAT((double)v);
} else {
jsValue = V8JS_INT(v);
}
break;
case IS_DOUBLE: