migrate to non-deprecated v8 functions
https://bugs.chromium.org/p/v8/issues/detail?id=8238
https://bugs.chromium.org/p/v8/issues/detail?id=7295
1352273
This commit is contained in:
parent
7d5cd2051a
commit
d01db5a656
26 changed files with 94 additions and 46 deletions
|
@ -43,16 +43,19 @@ void CallTranslater(v8::Local<v8::External> external,
|
|||
mate::Arguments* args) {
|
||||
// Whether the callback should only be called for once.
|
||||
v8::Isolate* isolate = args->isolate();
|
||||
bool one_time = state->Has(mate::StringToSymbol(isolate, "oneTime"));
|
||||
auto context = isolate->GetCurrentContext();
|
||||
bool one_time =
|
||||
state->Has(context, mate::StringToSymbol(isolate, "oneTime")).ToChecked();
|
||||
|
||||
// Check if the callback has already been called.
|
||||
if (one_time) {
|
||||
auto called_symbol = mate::StringToSymbol(isolate, "called");
|
||||
if (state->Has(called_symbol)) {
|
||||
if (state->Has(context, called_symbol).ToChecked()) {
|
||||
args->ThrowError("callback can only be called for once");
|
||||
return;
|
||||
} else {
|
||||
state->Set(called_symbol, v8::Boolean::New(isolate, true));
|
||||
state->Set(context, called_symbol, v8::Boolean::New(isolate, true))
|
||||
.ToChecked();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,9 +133,10 @@ v8::Local<v8::Value> CreateFunctionFromTranslater(v8::Isolate* isolate,
|
|||
Dictionary state = mate::Dictionary::CreateEmpty(isolate);
|
||||
if (one_time)
|
||||
state.Set("oneTime", true);
|
||||
return BindFunctionWith(isolate, isolate->GetCurrentContext(),
|
||||
call_translater->GetFunction(),
|
||||
holder->handle.Get(isolate), state.GetHandle());
|
||||
auto context = isolate->GetCurrentContext();
|
||||
return BindFunctionWith(
|
||||
isolate, context, call_translater->GetFunction(context).ToLocalChecked(),
|
||||
holder->handle.Get(isolate), state.GetHandle());
|
||||
}
|
||||
|
||||
// func.bind(func, arg1).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue