0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-09-19 01:35:18 +00:00

Fix deprecated API calls

This commit is contained in:
Stefan Siegl 2017-04-23 22:50:00 +02:00
parent 338fa52aa9
commit 096454fdf4
No known key found for this signature in database
GPG Key ID: 51575950154839CD
4 changed files with 20 additions and 19 deletions

View File

@ -410,8 +410,7 @@ static PHP_METHOD(V8Js, __construct)
v8::HandleScope handle_scope(isolate);
/* Redirect fatal errors to PHP error handler */
// This needs to be done within the context isolate
v8::V8::SetFatalErrorHandler(v8js_fatal_error_handler);
isolate->SetFatalErrorHandler(v8js_fatal_error_handler);
/* Create global template for global object */
// Now we are using multiple isolates this needs to be created for every context
@ -486,7 +485,7 @@ static PHP_METHOD(V8Js, __construct)
/* Add the PHP object into global object */
php_obj_t->InstanceTemplate()->SetInternalFieldCount(2);
v8::Local<v8::Object> php_obj = php_obj_t->InstanceTemplate()->NewInstance();
V8JS_GLOBAL(isolate)->ForceSet(object_name_js, php_obj, v8::ReadOnly);
V8JS_GLOBAL(isolate)->DefineOwnProperty(context, object_name_js, php_obj, v8::ReadOnly);
/* Export public property values */
HashTable *properties = zend_std_get_properties(getThis());
@ -504,12 +503,12 @@ static PHP_METHOD(V8Js, __construct)
return;
}
v8::Local<v8::Value> key = v8::String::NewFromUtf8(isolate, ZSTR_VAL(member),
v8::Local<v8::Name> key = v8::String::NewFromUtf8(isolate, ZSTR_VAL(member),
v8::String::kInternalizedString, static_cast<int>(ZSTR_LEN(member)));
/* Write value to PHP JS object */
value = OBJ_PROP(Z_OBJ_P(getThis()), property_info->offset);
php_obj->ForceSet(key, zval_to_v8js(value, isolate), v8::ReadOnly);
php_obj->DefineOwnProperty(context, key, zval_to_v8js(value, isolate), v8::ReadOnly);
}
} ZEND_HASH_FOREACH_END();
@ -584,7 +583,7 @@ static PHP_METHOD(V8Js, __construct)
persistent_ft->Reset(isolate, ft);
}
php_obj->ForceSet(method_name, ft->GetFunction());
php_obj->CreateDataProperty(context, method_name, ft->GetFunction());
} ZEND_HASH_FOREACH_END();
}
/* }}} */
@ -616,7 +615,7 @@ static void v8js_compile_script(zval *this_ptr, const zend_string *str, const ze
V8JS_BEGIN_CTX(c, this_ptr)
/* Catch JS exceptions */
v8::TryCatch try_catch;
v8::TryCatch try_catch(isolate);
/* Set script identifier */
if (identifier && ZSTR_LEN(identifier) > std::numeric_limits<int>::max()) {
@ -1289,8 +1288,8 @@ static void v8js_write_property(zval *object, zval *member, zval *value, void **
}
/* Write value to PHP JS object */
v8::Local<v8::Value> key = V8JS_SYML(Z_STRVAL_P(member), static_cast<int>(Z_STRLEN_P(member)));
jsobj->ForceSet(key, zval_to_v8js(value, isolate), v8::ReadOnly);
v8::Local<v8::Name> key = V8JS_SYML(Z_STRVAL_P(member), static_cast<int>(Z_STRLEN_P(member)));
jsobj->DefineOwnProperty(v8_context, key, zval_to_v8js(value, isolate), v8::ReadOnly);
}
/* Write value to PHP object */

View File

@ -44,7 +44,7 @@ void v8js_create_script_exception(zval *return_value, v8::Isolate *isolate, v8::
v8::Local<v8::Message> tc_message = try_catch->Message();
const char *filename_string, *sourceline_string;
char *message_string;
int linenum, start_col, end_col;
int linenum, start_col;
object_init_ex(return_value, php_ce_v8js_script_exception);
@ -70,8 +70,10 @@ void v8js_create_script_exception(zval *return_value, v8::Isolate *isolate, v8::
start_col = tc_message->GetStartColumn();
PHPV8_EXPROP(_long, JsStartColumn, start_col);
end_col = tc_message->GetEndColumn();
PHPV8_EXPROP(_long, JsEndColumn, end_col);
v8::Maybe<int> end_col = tc_message->GetEndColumn(isolate->GetEnteredContext());
if (end_col.IsJust()) {
PHPV8_EXPROP(_long, JsEndColumn, end_col.ToChecked());
}
spprintf(&message_string, 0, "%s:%d: %s", filename_string, linenum, exception_string);

View File

@ -24,7 +24,7 @@ v8::Local<v8::Value> v8js_wrap_generator(v8::Isolate *isolate, v8::Local<v8::Val
assert(!wrapped_object.IsEmpty());
assert(wrapped_object->IsObject());
v8::TryCatch try_catch;
v8::TryCatch try_catch(isolate);
v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, "(\
function(wrapped_object) { \
return (function*() { \

View File

@ -92,7 +92,7 @@ static void v8js_dumper(v8::Isolate *isolate, v8::Local<v8::Value> var, int leve
return;
}
v8::TryCatch try_catch; /* object.toString() can throw an exception */
v8::TryCatch try_catch(isolate); /* object.toString() can throw an exception */
v8::Local<v8::String> details;
if(var->IsRegExp()) {
@ -100,7 +100,7 @@ static void v8js_dumper(v8::Isolate *isolate, v8::Local<v8::Value> var, int leve
details = re->GetSource();
}
else {
details = var->ToDetailString();
details = var->ToDetailString(isolate->GetEnteredContext()).FromMaybe(v8::Local<v8::String>());
if (try_catch.HasCaught()) {
details = V8JS_SYM("<toString threw exception>");
@ -401,18 +401,18 @@ V8JS_METHOD(require)
}
// Create a template for the global object and set the built-in global functions
v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(isolate);
global_template->Set(V8JS_SYM("print"), v8::FunctionTemplate::New(isolate, V8JS_MN(print)), v8::ReadOnly);
global_template->Set(V8JS_SYM("var_dump"), v8::FunctionTemplate::New(isolate, V8JS_MN(var_dump)), v8::ReadOnly);
global_template->Set(V8JS_SYM("sleep"), v8::FunctionTemplate::New(isolate, V8JS_MN(sleep)), v8::ReadOnly);
global_template->Set(V8JS_SYM("require"), v8::FunctionTemplate::New(isolate, V8JS_MN(require), v8::External::New(isolate, c)), v8::ReadOnly);
// Add the exports object in which the module can return its API
v8::Local<v8::ObjectTemplate> exports_template = v8::ObjectTemplate::New();
v8::Local<v8::ObjectTemplate> exports_template = v8::ObjectTemplate::New(isolate);
global_template->Set(V8JS_SYM("exports"), exports_template);
// Add the module object in which the module can have more fine-grained control over what it can return
v8::Local<v8::ObjectTemplate> module_template = v8::ObjectTemplate::New();
v8::Local<v8::ObjectTemplate> module_template = v8::ObjectTemplate::New(isolate);
module_template->Set(V8JS_SYM("id"), V8JS_STR(normalised_module_id));
global_template->Set(V8JS_SYM("module"), module_template);
@ -420,7 +420,7 @@ V8JS_METHOD(require)
v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolate, v8::Context::New(isolate, NULL, global_template));
// Catch JS exceptions
v8::TryCatch try_catch;
v8::TryCatch try_catch(isolate);
v8::Locker locker(isolate);
v8::Isolate::Scope isolate_scope(isolate);