0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-22 17:31:53 +00:00

Set Array.prototype on ArrayAccess wrapped object

This commit is contained in:
Stefan Siegl 2014-11-23 23:47:29 +01:00
parent f1dd5ad23b
commit 3f6ea8fcfd
2 changed files with 7 additions and 2 deletions

View File

@ -37,6 +37,7 @@ $js = <<<EOJS
var_dump(PHP.myarr.constructor.name);
var_dump(PHP.myarr.length);
var_dump(PHP.myarr[5]);
var_dump(PHP.myarr.join(', '));
EOJS;
$v8 = new V8Js();
@ -48,7 +49,8 @@ $v8->executeString($js);
--EXPECT--
int(20)
int(14)
string(11) "ArrayAccess"
string(5) "Array"
int(20)
int(14)
string(68) "19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0"
===EOF===

View File

@ -956,10 +956,13 @@ static v8::Handle<v8::Value> php_v8js_array_access_to_jsobj(zval *value, v8::Iso
inst_tpl->SetAccessor(V8JS_STR("length"), php_v8js_array_access_length);
inst_tpl->SetInternalFieldCount(1);
v8::Handle<v8::Object> newobj = inst_tpl->NewInstance();
newobj->SetAlignedPointerInInternalField(0, value);
/* Change prototype of `newobj' to that of Array */
v8::Local<v8::Array> arr = v8::Array::New(isolate);
newobj->SetPrototype(arr->GetPrototype());
return newobj;
}
/* }}} */