0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-11-09 15:18:41 +00:00

Make FLAG_FORCE_ARRAY not affect V8Function objects, #closes 160

This commit is contained in:
Stefan Siegl 2015-08-26 16:05:53 +00:00
parent de0931a90b
commit 53995ac616
2 changed files with 24 additions and 1 deletions

View File

@ -0,0 +1,23 @@
--TEST--
Test V8::executeString() : Issue #160 V8Function affected by V8Js::FLAG_FORCE_ARRAY
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$v8 = new V8Js();
$JS = <<<EOT
(function(foo) { print(foo); });
EOT;
$func = $v8->executeString($JS, 'test', V8Js::FLAG_FORCE_ARRAY);
var_dump($func);
$func("Test-Foo Func Call\n");
?>
===EOF===
--EXPECTF--
object(V8Function)#%d (0) {
}
Test-Foo Func Call
===EOF===

View File

@ -244,7 +244,7 @@ int v8js_to_zval(v8::Handle<v8::Value> jsValue, zval *return_value, int flags, v
RETVAL_ZVAL(object, 1, 0); RETVAL_ZVAL(object, 1, 0);
return SUCCESS; return SUCCESS;
} }
if ((flags & V8JS_FLAG_FORCE_ARRAY) || jsValue->IsArray()) { if ((flags & V8JS_FLAG_FORCE_ARRAY && !jsValue->IsFunction()) || jsValue->IsArray()) {
array_init(return_value); array_init(return_value);
return v8js_get_properties_hash(jsValue, Z_ARRVAL_P(return_value), flags, isolate TSRMLS_CC); return v8js_get_properties_hash(jsValue, Z_ARRVAL_P(return_value), flags, isolate TSRMLS_CC);
} else { } else {