mirror of
https://github.com/phpv8/v8js.git
synced 2024-12-22 04:01:51 +00:00
Handle Z_TYPE == IS_REFERENCE well, fixes #246
This commit is contained in:
parent
4161008417
commit
8126fc4928
18
tests/issue_246_001.phpt
Normal file
18
tests/issue_246_001.phpt
Normal file
@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
Test V8::executeString() : Handle Z_TYPE == IS_REFERENCE (issue #246)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . '/skipif.inc');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$v8 = new V8Js();
|
||||
$array = ['lorem' => 'ipsum'];
|
||||
array_walk_recursive($array, function (&$item) {});
|
||||
$v8->some_array = $array;
|
||||
$v8->executeString('var_dump(PHP.some_array.lorem);');
|
||||
?>
|
||||
===EOF===
|
||||
--EXPECT--
|
||||
string(5) "ipsum"
|
||||
===EOF===
|
@ -104,11 +104,16 @@ v8::Handle<v8::Value> zval_to_v8js(zval *value, v8::Isolate *isolate TSRMLS_DC)
|
||||
long v;
|
||||
zend_class_entry *ce;
|
||||
|
||||
if(Z_TYPE_P(value) == IS_INDIRECT)
|
||||
value = Z_INDIRECT_P(value);
|
||||
|
||||
switch (Z_TYPE_P(value))
|
||||
{
|
||||
case IS_INDIRECT:
|
||||
jsValue = zval_to_v8js(Z_INDIRECT_P(value), isolate);
|
||||
break;
|
||||
|
||||
case IS_REFERENCE:
|
||||
jsValue = zval_to_v8js(Z_REFVAL_P(value), isolate);
|
||||
break;
|
||||
|
||||
case IS_ARRAY:
|
||||
jsValue = v8js_hash_to_jsarr(value, isolate TSRMLS_CC);
|
||||
break;
|
||||
@ -163,8 +168,10 @@ v8::Handle<v8::Value> zval_to_v8js(zval *value, v8::Isolate *isolate TSRMLS_DC)
|
||||
case IS_UNDEF:
|
||||
default:
|
||||
/* undefined -> return v8::Value left empty */
|
||||
jsValue = v8::Undefined(isolate);
|
||||
break;
|
||||
}
|
||||
|
||||
return jsValue;
|
||||
}
|
||||
/* }}} */
|
||||
|
Loading…
Reference in New Issue
Block a user