diff --git a/tests/function_call.phpt b/tests/function_call.phpt new file mode 100644 index 0000000..a3aa445 --- /dev/null +++ b/tests/function_call.phpt @@ -0,0 +1,26 @@ +--TEST-- +Test V8::executeString() : Call passed-back function (directly) +--SKIPIF-- + +--FILE-- +executeString($JS, 'basic.js'); +echo $exports->hello()."\n"; + +?> +===EOF=== +--EXPECT-- +hello +===EOF=== diff --git a/v8js.cc b/v8js.cc index e48bd11..1c7d09f 100644 --- a/v8js.cc +++ b/v8js.cc @@ -242,9 +242,15 @@ static HashTable *php_v8js_v8_get_debug_info(zval *object, int *is_temp TSRMLS_D static zend_function *php_v8js_v8_get_method(zval **object_ptr, char *method, int method_len ZEND_HASH_KEY_DC TSRMLS_DC) /* {{{ */ { - zend_function *f; - v8::Local jsKey = V8JS_STRL(method, method_len); php_v8js_object *obj = (php_v8js_object *) zend_object_store_get_object(*object_ptr TSRMLS_CC); + zend_function *f; + + v8::Locker locker(obj->isolate); + v8::Isolate::Scope isolate_scope(obj->isolate); + v8::HandleScope local_scope(obj->isolate); + v8::Local temp_context = v8::Context::New(obj->isolate); + v8::Context::Scope temp_scope(temp_context); + v8::Local jsKey = V8JS_STRL(method, method_len); if (!obj->v8obj.IsEmpty() && obj->v8obj->IsObject() && !obj->v8obj->IsFunction()) { v8::Local jsObj = obj->v8obj->ToObject(); @@ -283,6 +289,12 @@ static int php_v8js_v8_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS) / zend_get_parameters_array_ex(argc, argv); } + v8::Locker locker(obj->isolate); + v8::Isolate::Scope isolate_scope(obj->isolate); + v8::HandleScope local_scope(obj->isolate); + v8::Local temp_context = v8::Context::New(obj->isolate); + v8::Context::Scope temp_scope(temp_context); + v8::Local method_name = V8JS_SYML(method, strlen(method)); v8::Local v8obj = obj->v8obj->ToObject(); v8::Local cb;