Skip to content

Commit e608cb6

Browse files
committed
Fix left-over deprecated API calls.
1 parent 6479923 commit e608cb6

File tree

4 files changed

+28
-15
lines changed

4 files changed

+28
-15
lines changed

v8js_object_export.cc

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,17 @@ static void v8js_invoke_callback(const v8::FunctionCallbackInfo<v8::Value>& info
438438
new_tpl = v8::Local<v8::FunctionTemplate>::New
439439
(isolate, ctx->template_cache.at(ce->name));
440440

441-
result = new_tpl->GetFunction()->NewInstance(argc, argv);
441+
v8::MaybeLocal<v8::Object> maybeResult = new_tpl->GetFunction()->NewInstance(isolate->GetEnteredContext(), argc, argv);
442+
443+
if (!maybeResult.IsEmpty()) {
444+
result = maybeResult.ToLocalChecked();
445+
} else {
446+
result = V8JS_UNDEFINED;
447+
}
442448
} else {
443449
result = cb->Call(self, argc, argv);
444450
}
451+
445452
info.GetReturnValue().Set(result);
446453
}
447454
/* }}} */
@@ -804,7 +811,7 @@ static void v8js_named_property_deleter(v8::Local<v8::String> property, const v8
804811

805812

806813

807-
static v8::Local<v8::Object> v8js_wrap_object(v8::Isolate *isolate, zend_class_entry *ce, zval *value) /* {{{ */
814+
static v8::MaybeLocal<v8::Object> v8js_wrap_object(v8::Isolate *isolate, zend_class_entry *ce, zval *value) /* {{{ */
808815
{
809816
v8js_ctx *ctx = (v8js_ctx *) isolate->GetData(0);
810817
v8::Local<v8::FunctionTemplate> new_tpl;
@@ -903,11 +910,11 @@ static v8::Local<v8::Object> v8js_wrap_object(v8::Isolate *isolate, zend_class_e
903910

904911
// Create v8 wrapper object
905912
v8::Local<v8::Value> external = v8::External::New(isolate, Z_OBJ_P(value));
906-
v8::Local<v8::Object> newobj = new_tpl->GetFunction()->NewInstance(1, &external);
913+
v8::MaybeLocal<v8::Object> newobj = new_tpl->GetFunction()->NewInstance(isolate->GetEnteredContext(), 1, &external);
907914

908-
if (ce == zend_ce_closure) {
915+
if (ce == zend_ce_closure && !newobj.IsEmpty()) {
909916
// free uncached function template when object is freed
910-
ctx->weak_closures[persist_tpl_].Reset(isolate, newobj);
917+
ctx->weak_closures[persist_tpl_].Reset(isolate, newobj.ToLocalChecked());
911918
ctx->weak_closures[persist_tpl_].SetWeak(persist_tpl_, v8js_weak_closure_callback, v8::WeakCallbackType::kParameter);
912919
}
913920

@@ -1025,15 +1032,19 @@ v8::Local<v8::Value> v8js_hash_to_jsobj(zval *value, v8::Isolate *isolate) /* {{
10251032

10261033
/* If it's a PHP object, wrap it */
10271034
if (ce) {
1028-
v8::Local<v8::Value> wrapped_object = v8js_wrap_object(isolate, ce, value);
1035+
v8::MaybeLocal<v8::Object> wrapped_object = v8js_wrap_object(isolate, ce, value);
1036+
1037+
if (wrapped_object.IsEmpty()) {
1038+
return V8JS_UNDEFINED;
1039+
}
10291040

10301041
if (ce == zend_ce_generator) {
10311042
/* Wrap PHP Generator object in a wrapper function that provides
10321043
* ES6 style behaviour. */
1033-
wrapped_object = v8js_wrap_generator(isolate, wrapped_object);
1044+
return v8js_wrap_generator(isolate, wrapped_object.ToLocalChecked());
10341045
}
10351046

1036-
return wrapped_object;
1047+
return wrapped_object.ToLocalChecked();
10371048
}
10381049

10391050
/* Associative PHP arrays cannot be wrapped to JS arrays, convert them to

v8js_timer.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static void v8js_timer_interrupt_handler(v8::Isolate *isolate, void *data) { /*
6767
if (timer_ctx->memory_limit > 0 && hs.used_heap_size() > timer_ctx->memory_limit) {
6868
if (has_sent_notification) {
6969
timer_ctx->killed = true;
70-
v8::V8::TerminateExecution(c->isolate);
70+
c->isolate->TerminateExecution();
7171
c->memory_limit_hit = true;
7272
} else {
7373
// force garbage collection, then check again
@@ -98,7 +98,7 @@ void v8js_timer_thread(zend_v8js_globals *globals) /* {{{ */
9898
}
9999
else if(timer_ctx->time_limit > 0 && now > timer_ctx->time_point) {
100100
timer_ctx->killed = true;
101-
v8::V8::TerminateExecution(c->isolate);
101+
c->isolate->TerminateExecution();
102102
c->time_limit_hit = true;
103103
}
104104
else if (timer_ctx->memory_limit > 0) {

v8js_v8.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void v8js_v8_call(v8js_ctx *c, zval **return_value,
120120
V8JSG(timer_mutex).unlock();
121121

122122
/* Catch JS exceptions */
123-
v8::TryCatch try_catch;
123+
v8::TryCatch try_catch(isolate);
124124

125125
/* Set flags for runtime use */
126126
c->flags = flags;
@@ -246,7 +246,7 @@ void v8js_v8_call(v8js_ctx *c, zval **return_value,
246246

247247
void v8js_terminate_execution(v8::Isolate *isolate) /* {{{ */
248248
{
249-
if(v8::V8::IsExecutionTerminating(isolate)) {
249+
if(isolate->IsExecutionTerminating()) {
250250
/* Execution already terminating, needn't trigger it again and
251251
* especially must not execute the spinning loop (which would cause
252252
* crashes in V8 itself, at least with 4.2 and 4.3 version lines). */
@@ -264,7 +264,7 @@ void v8js_terminate_execution(v8::Isolate *isolate) /* {{{ */
264264

265265
v8::Local<v8::String> source = V8JS_STR("for(;;);");
266266
v8::Local<v8::Script> script = v8::Script::Compile(source);
267-
v8::V8::TerminateExecution(isolate);
267+
isolate->TerminateExecution();
268268
script->Run();
269269
}
270270
/* }}} */
@@ -282,7 +282,9 @@ int v8js_get_properties_hash(v8::Local<v8::Value> jsValue, HashTable *retval, in
282282
v8::Local<v8::String> jsKey = jsKeys->Get(i)->ToString();
283283

284284
/* Skip any prototype properties */
285-
if (!jsObj->HasOwnProperty(jsKey) && !jsObj->HasRealNamedProperty(jsKey) && !jsObj->HasRealNamedCallbackProperty(jsKey)) {
285+
if (!jsObj->HasOwnProperty(isolate->GetEnteredContext(), jsKey).FromMaybe(false)
286+
&& !jsObj->HasRealNamedProperty(jsKey)
287+
&& !jsObj->HasRealNamedCallbackProperty(jsKey)) {
286288
continue;
287289
}
288290

v8js_v8object_class.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ static void v8js_v8object_write_property(zval *object, zval *member, zval *value
175175
}
176176

177177
if (v8obj->IsObject()) {
178-
v8obj->ToObject()->ForceSet(V8JS_SYML(Z_STRVAL_P(member), static_cast<int>(Z_STRLEN_P(member))), zval_to_v8js(value, isolate));
178+
v8obj->ToObject()->CreateDataProperty(v8_context, V8JS_SYML(Z_STRVAL_P(member), static_cast<int>(Z_STRLEN_P(member))), zval_to_v8js(value, isolate));
179179
}
180180
}
181181
/* }}} */

0 commit comments

Comments
 (0)