fix: update deprecated v8 api usage
This commit is contained in:
parent
f09cb56f19
commit
92cfc4a62d
10 changed files with 117 additions and 94 deletions
|
@ -140,13 +140,16 @@ bool Converter<double>::FromV8(Isolate* isolate,
|
|||
}
|
||||
|
||||
Local<Value> Converter<const char*>::ToV8(Isolate* isolate, const char* val) {
|
||||
return v8::String::NewFromUtf8(isolate, val);
|
||||
return v8::String::NewFromUtf8(isolate, val, v8::NewStringType::kNormal)
|
||||
.ToLocalChecked();
|
||||
}
|
||||
|
||||
Local<Value> Converter<base::StringPiece>::ToV8(Isolate* isolate,
|
||||
const base::StringPiece& val) {
|
||||
return v8::String::NewFromUtf8(isolate, val.data(), v8::String::kNormalString,
|
||||
static_cast<uint32_t>(val.length()));
|
||||
return v8::String::NewFromUtf8(isolate, val.data(),
|
||||
v8::NewStringType::kNormal,
|
||||
static_cast<uint32_t>(val.length()))
|
||||
.ToLocalChecked();
|
||||
}
|
||||
|
||||
Local<Value> Converter<std::string>::ToV8(Isolate* isolate,
|
||||
|
@ -255,8 +258,9 @@ bool Converter<Local<Value>>::FromV8(Isolate* isolate,
|
|||
v8::Local<v8::String> StringToSymbol(v8::Isolate* isolate,
|
||||
const base::StringPiece& val) {
|
||||
return v8::String::NewFromUtf8(isolate, val.data(),
|
||||
v8::String::kInternalizedString,
|
||||
static_cast<uint32_t>(val.length()));
|
||||
v8::NewStringType::kInternalized,
|
||||
static_cast<uint32_t>(val.length()))
|
||||
.ToLocalChecked();
|
||||
}
|
||||
|
||||
} // namespace mate
|
||||
|
|
|
@ -277,7 +277,8 @@ struct Converter<std::map<std::string, T>> {
|
|||
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
v8::Local<v8::Object> dict = val->ToObject(context).ToLocalChecked();
|
||||
v8::Local<v8::Array> keys = dict->GetOwnPropertyNames();
|
||||
v8::Local<v8::Array> keys =
|
||||
dict->GetOwnPropertyNames(context).ToLocalChecked();
|
||||
for (uint32_t i = 0; i < keys->Length(); ++i) {
|
||||
v8::Local<v8::Value> key = keys->Get(i);
|
||||
T value;
|
||||
|
|
|
@ -6,17 +6,13 @@
|
|||
|
||||
namespace mate {
|
||||
|
||||
Promise::Promise()
|
||||
: isolate_(NULL) {
|
||||
}
|
||||
Promise::Promise() : isolate_(NULL) {}
|
||||
|
||||
Promise::Promise(v8::Isolate* isolate)
|
||||
: isolate_(isolate) {
|
||||
Promise::Promise(v8::Isolate* isolate) : isolate_(isolate) {
|
||||
resolver_ = v8::Promise::Resolver::New(isolate);
|
||||
}
|
||||
|
||||
Promise::~Promise() {
|
||||
}
|
||||
Promise::~Promise() {}
|
||||
|
||||
Promise Promise::Create(v8::Isolate* isolate) {
|
||||
return Promise(isolate);
|
||||
|
@ -28,7 +24,10 @@ Promise Promise::Create() {
|
|||
|
||||
void Promise::RejectWithErrorMessage(const std::string& string) {
|
||||
v8::Local<v8::String> error_message =
|
||||
v8::String::NewFromUtf8(isolate(), string.c_str());
|
||||
v8::String::NewFromUtf8(isolate(), string.c_str(),
|
||||
v8::NewStringType::kNormal,
|
||||
static_cast<int>(string.size()))
|
||||
.ToLocalChecked();
|
||||
v8::Local<v8::Value> error = v8::Exception::Error(error_message);
|
||||
resolver_->Reject(mate::ConvertToV8(isolate(), error));
|
||||
}
|
||||
|
@ -38,7 +37,7 @@ v8::Local<v8::Object> Promise::GetHandle() const {
|
|||
}
|
||||
|
||||
v8::Local<v8::Value> Converter<Promise>::ToV8(v8::Isolate* isolate,
|
||||
Promise val) {
|
||||
Promise val) {
|
||||
return val.GetHandle();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue