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

Commit 596e566

Browse files
committed
Handle V8\IntegerValue sub-types when returning values from V8, fixes #19
1 parent ab24569 commit 596e566

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
@@ -204,7 +204,7 @@ V8\ArrayObject(V8\Value)->ToBoolean():
204204
}
205205
}
206206
V8\ArrayObject(V8\Value)->ToNumber():
207-
object(V8\NumberValue)#118 (1) {
207+
object(V8\Int32Value)#118 (1) {
208208
["isolate":"V8\Value":private]=>
209209
object(V8\Isolate)#3 (5) {
210210
["snapshot":"V8\Isolate":private]=>
@@ -305,7 +305,7 @@ V8\ArrayObject(V8\Value)->ToObject():
305305
}
306306
}
307307
V8\ArrayObject(V8\Value)->ToInteger():
308-
object(V8\NumberValue)#118 (1) {
308+
object(V8\Int32Value)#118 (1) {
309309
["isolate":"V8\Value":private]=>
310310
object(V8\Isolate)#3 (5) {
311311
["snapshot":"V8\Isolate":private]=>
@@ -321,7 +321,7 @@ V8\ArrayObject(V8\Value)->ToInteger():
321321
}
322322
}
323323
V8\ArrayObject(V8\Value)->ToUint32():
324-
object(V8\NumberValue)#118 (1) {
324+
object(V8\Int32Value)#118 (1) {
325325
["isolate":"V8\Value":private]=>
326326
object(V8\Isolate)#3 (5) {
327327
["snapshot":"V8\Isolate":private]=>
@@ -337,7 +337,7 @@ V8\ArrayObject(V8\Value)->ToUint32():
337337
}
338338
}
339339
V8\ArrayObject(V8\Value)->ToInt32():
340-
object(V8\NumberValue)#118 (1) {
340+
object(V8\Int32Value)#118 (1) {
341341
["isolate":"V8\Value":private]=>
342342
object(V8\Isolate)#3 (5) {
343343
["snapshot":"V8\Isolate":private]=>

tests/V8MapObject.phpt

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

tests/V8ObjectValue.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ V8\ObjectValue(V8\Value)->ToObject():
294294
}
295295
}
296296
V8\ObjectValue(V8\Value)->ToInteger():
297-
object(V8\NumberValue)#116 (1) {
297+
object(V8\Int32Value)#116 (1) {
298298
["isolate":"V8\Value":private]=>
299299
object(V8\Isolate)#3 (5) {
300300
["snapshot":"V8\Isolate":private]=>
@@ -310,7 +310,7 @@ V8\ObjectValue(V8\Value)->ToInteger():
310310
}
311311
}
312312
V8\ObjectValue(V8\Value)->ToUint32():
313-
object(V8\NumberValue)#116 (1) {
313+
object(V8\Int32Value)#116 (1) {
314314
["isolate":"V8\Value":private]=>
315315
object(V8\Isolate)#3 (5) {
316316
["snapshot":"V8\Isolate":private]=>
@@ -326,7 +326,7 @@ V8\ObjectValue(V8\Value)->ToUint32():
326326
}
327327
}
328328
V8\ObjectValue(V8\Value)->ToInt32():
329-
object(V8\NumberValue)#116 (1) {
329+
object(V8\Int32Value)#116 (1) {
330330
["isolate":"V8\Value":private]=>
331331
object(V8\Isolate)#3 (5) {
332332
["snapshot":"V8\Isolate":private]=>

tests/V8Script_Run.phpt

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

3434
$helper->space();
3535

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

115115
Scalar:
116116
-------
117-
Expected 123.0 value is identical to actual value 123.0
117+
Expected 123 value is identical to actual value 123
118118
Expected value is not identical to actual value
119119

120120

tests/V8SetObject.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ V8\SetObject(V8\Value)->ToObject():
354354
}
355355
}
356356
V8\SetObject(V8\Value)->ToInteger():
357-
object(V8\NumberValue)#120 (1) {
357+
object(V8\Int32Value)#120 (1) {
358358
["isolate":"V8\Value":private]=>
359359
object(V8\Isolate)#3 (5) {
360360
["snapshot":"V8\Isolate":private]=>
@@ -370,7 +370,7 @@ V8\SetObject(V8\Value)->ToInteger():
370370
}
371371
}
372372
V8\SetObject(V8\Value)->ToUint32():
373-
object(V8\NumberValue)#120 (1) {
373+
object(V8\Int32Value)#120 (1) {
374374
["isolate":"V8\Value":private]=>
375375
object(V8\Isolate)#3 (5) {
376376
["snapshot":"V8\Isolate":private]=>
@@ -386,7 +386,7 @@ V8\SetObject(V8\Value)->ToUint32():
386386
}
387387
}
388388
V8\SetObject(V8\Value)->ToInt32():
389-
object(V8\NumberValue)#120 (1) {
389+
object(V8\Int32Value)#120 (1) {
390390
["isolate":"V8\Value":private]=>
391391
object(V8\Isolate)#3 (5) {
392392
["snapshot":"V8\Isolate":private]=>

0 commit comments

Comments
 (0)