Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Commit 487137a

Browse files
committed
Handle V8\IntegerValue sub-types when returning values from V8, fixes #19
1 parent de10a0e commit 487137a

6 files changed

+22
-26
lines changed

src/php_v8_value.cc

+7-11
Original file line numberDiff line numberDiff line change
@@ -262,19 +262,15 @@ zend_class_entry *php_v8_get_class_entry_from_value(v8::Local<v8::Value> value)
262262
return php_v8_symbol_class_entry;
263263
}
264264

265-
/* currently we ignore detectind v8::Number sub-types */
266-
267-
/*
268-
if (value->IsUint32()) {
269-
return php_v8_uint32_class_entry;
270-
}
265+
if (value->IsNumber()) {
266+
if (value->IsInt32()) {
267+
return php_v8_int32_class_entry;
268+
}
271269

272-
if (value->IsInt32()) {
273-
return php_v8_int32_class_entry;
274-
}
275-
*/
270+
if (value->IsUint32()) {
271+
return php_v8_uint32_class_entry;
272+
}
276273

277-
if (value->IsNumber()) {
278274
return php_v8_number_class_entry;
279275
}
280276

tests/V8ArrayObject.phpt

+4-4
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ V8\ArrayObject(V8\Value)->ToBoolean():
200200
}
201201
}
202202
V8\ArrayObject(V8\Value)->ToNumber():
203-
object(V8\NumberValue)#118 (1) {
203+
object(V8\Int32Value)#118 (1) {
204204
["isolate":"V8\Value":private]=>
205205
object(V8\Isolate)#3 (5) {
206206
["snapshot":"V8\Isolate":private]=>
@@ -298,7 +298,7 @@ V8\ArrayObject(V8\Value)->ToObject():
298298
}
299299
}
300300
V8\ArrayObject(V8\Value)->ToInteger():
301-
object(V8\NumberValue)#118 (1) {
301+
object(V8\Int32Value)#118 (1) {
302302
["isolate":"V8\Value":private]=>
303303
object(V8\Isolate)#3 (5) {
304304
["snapshot":"V8\Isolate":private]=>
@@ -314,7 +314,7 @@ V8\ArrayObject(V8\Value)->ToInteger():
314314
}
315315
}
316316
V8\ArrayObject(V8\Value)->ToUint32():
317-
object(V8\NumberValue)#118 (1) {
317+
object(V8\Int32Value)#118 (1) {
318318
["isolate":"V8\Value":private]=>
319319
object(V8\Isolate)#3 (5) {
320320
["snapshot":"V8\Isolate":private]=>
@@ -330,7 +330,7 @@ V8\ArrayObject(V8\Value)->ToUint32():
330330
}
331331
}
332332
V8\ArrayObject(V8\Value)->ToInt32():
333-
object(V8\NumberValue)#118 (1) {
333+
object(V8\Int32Value)#118 (1) {
334334
["isolate":"V8\Value":private]=>
335335
object(V8\Isolate)#3 (5) {
336336
["snapshot":"V8\Isolate":private]=>

tests/V8MapObject.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ V8\MapObject(V8\Value)->ToObject():
340340
}
341341
}
342342
V8\MapObject(V8\Value)->ToInteger():
343-
object(V8\NumberValue)#119 (1) {
343+
object(V8\Int32Value)#119 (1) {
344344
["isolate":"V8\Value":private]=>
345345
object(V8\Isolate)#3 (5) {
346346
["snapshot":"V8\Isolate":private]=>
@@ -356,7 +356,7 @@ V8\MapObject(V8\Value)->ToInteger():
356356
}
357357
}
358358
V8\MapObject(V8\Value)->ToUint32():
359-
object(V8\NumberValue)#119 (1) {
359+
object(V8\Int32Value)#119 (1) {
360360
["isolate":"V8\Value":private]=>
361361
object(V8\Isolate)#3 (5) {
362362
["snapshot":"V8\Isolate":private]=>
@@ -372,7 +372,7 @@ V8\MapObject(V8\Value)->ToUint32():
372372
}
373373
}
374374
V8\MapObject(V8\Value)->ToInt32():
375-
object(V8\NumberValue)#119 (1) {
375+
object(V8\Int32Value)#119 (1) {
376376
["isolate":"V8\Value":private]=>
377377
object(V8\Isolate)#3 (5) {
378378
["snapshot":"V8\Isolate":private]=>

tests/V8ObjectValue.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ V8\ObjectValue(V8\Value)->ToObject():
287287
}
288288
}
289289
V8\ObjectValue(V8\Value)->ToInteger():
290-
object(V8\NumberValue)#116 (1) {
290+
object(V8\Int32Value)#116 (1) {
291291
["isolate":"V8\Value":private]=>
292292
object(V8\Isolate)#3 (5) {
293293
["snapshot":"V8\Isolate":private]=>
@@ -303,7 +303,7 @@ V8\ObjectValue(V8\Value)->ToInteger():
303303
}
304304
}
305305
V8\ObjectValue(V8\Value)->ToUint32():
306-
object(V8\NumberValue)#116 (1) {
306+
object(V8\Int32Value)#116 (1) {
307307
["isolate":"V8\Value":private]=>
308308
object(V8\Isolate)#3 (5) {
309309
["snapshot":"V8\Isolate":private]=>
@@ -319,7 +319,7 @@ V8\ObjectValue(V8\Value)->ToUint32():
319319
}
320320
}
321321
V8\ObjectValue(V8\Value)->ToInt32():
322-
object(V8\NumberValue)#116 (1) {
322+
object(V8\Int32Value)#116 (1) {
323323
["isolate":"V8\Value":private]=>
324324
object(V8\Isolate)#3 (5) {
325325
["snapshot":"V8\Isolate":private]=>

tests/V8Script_Run.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ $helper->dump($res->Value());
3232

3333
$helper->space();
3434

35-
$scalar = new V8\NumberValue($isolate, 123);
35+
$scalar = new V8\Int32Value($isolate, 123);
3636
$obj = new V8\ObjectValue($context);
3737
$context->GlobalObject()->Set($context, new \V8\StringValue($isolate, 'scalar'), $scalar);
3838
$context->GlobalObject()->Set($context, new \V8\StringValue($isolate, 'obj'), $obj);
@@ -113,7 +113,7 @@ string(25) "TEST VALUE 111, confirmed"
113113

114114
Scalar:
115115
-------
116-
Expected 123.0 value is identical to actual value 123.0
116+
Expected 123 value is identical to actual value 123
117117
Expected value is not identical to actual value
118118

119119

tests/V8SetObject.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ V8\SetObject(V8\Value)->ToObject():
347347
}
348348
}
349349
V8\SetObject(V8\Value)->ToInteger():
350-
object(V8\NumberValue)#120 (1) {
350+
object(V8\Int32Value)#120 (1) {
351351
["isolate":"V8\Value":private]=>
352352
object(V8\Isolate)#3 (5) {
353353
["snapshot":"V8\Isolate":private]=>
@@ -363,7 +363,7 @@ V8\SetObject(V8\Value)->ToInteger():
363363
}
364364
}
365365
V8\SetObject(V8\Value)->ToUint32():
366-
object(V8\NumberValue)#120 (1) {
366+
object(V8\Int32Value)#120 (1) {
367367
["isolate":"V8\Value":private]=>
368368
object(V8\Isolate)#3 (5) {
369369
["snapshot":"V8\Isolate":private]=>
@@ -379,7 +379,7 @@ V8\SetObject(V8\Value)->ToUint32():
379379
}
380380
}
381381
V8\SetObject(V8\Value)->ToInt32():
382-
object(V8\NumberValue)#120 (1) {
382+
object(V8\Int32Value)#120 (1) {
383383
["isolate":"V8\Value":private]=>
384384
object(V8\Isolate)#3 (5) {
385385
["snapshot":"V8\Isolate":private]=>

0 commit comments

Comments
 (0)