mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
src: replace ToLocalChecked uses with ToLocal in node-file
PR-URL: https://github.com/nodejs/node/pull/53869 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
@@ -221,9 +221,15 @@ void FSReqPromise<AliasedBufferT>::Reject(v8::Local<v8::Value> reject) {
|
||||
finished_ = true;
|
||||
v8::HandleScope scope(env()->isolate());
|
||||
InternalCallbackScope callback_scope(this);
|
||||
v8::Local<v8::Value> value =
|
||||
object()->Get(env()->context(),
|
||||
env()->promise_string()).ToLocalChecked();
|
||||
v8::Local<v8::Value> value;
|
||||
if (!object()
|
||||
->Get(env()->context(), env()->promise_string())
|
||||
.ToLocal(&value)) {
|
||||
// If we hit this, getting the value from the object failed and
|
||||
// an error was likely scheduled. We could try to reject the promise
|
||||
// but let's just allow the error to propagate.
|
||||
return;
|
||||
}
|
||||
v8::Local<v8::Promise::Resolver> resolver = value.As<v8::Promise::Resolver>();
|
||||
USE(resolver->Reject(env()->context(), reject).FromJust());
|
||||
}
|
||||
@@ -233,9 +239,13 @@ void FSReqPromise<AliasedBufferT>::Resolve(v8::Local<v8::Value> value) {
|
||||
finished_ = true;
|
||||
v8::HandleScope scope(env()->isolate());
|
||||
InternalCallbackScope callback_scope(this);
|
||||
v8::Local<v8::Value> val =
|
||||
object()->Get(env()->context(),
|
||||
env()->promise_string()).ToLocalChecked();
|
||||
v8::Local<v8::Value> val;
|
||||
if (!object()->Get(env()->context(), env()->promise_string()).ToLocal(&val)) {
|
||||
// If we hit this, getting the value from the object failed and
|
||||
// an error was likely scheduled. We could try to reject the promise
|
||||
// but let's just allow the error to propagate.
|
||||
return;
|
||||
}
|
||||
v8::Local<v8::Promise::Resolver> resolver = val.As<v8::Promise::Resolver>();
|
||||
USE(resolver->Resolve(env()->context(), value).FromJust());
|
||||
}
|
||||
@@ -255,9 +265,13 @@ void FSReqPromise<AliasedBufferT>::ResolveStatFs(const uv_statfs_t* stat) {
|
||||
template <typename AliasedBufferT>
|
||||
void FSReqPromise<AliasedBufferT>::SetReturnValue(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
v8::Local<v8::Value> val =
|
||||
object()->Get(env()->context(),
|
||||
env()->promise_string()).ToLocalChecked();
|
||||
v8::Local<v8::Value> val;
|
||||
if (!object()->Get(env()->context(), env()->promise_string()).ToLocal(&val)) {
|
||||
// If we hit this, getting the value from the object failed and
|
||||
// an error was likely scheduled. We could try to reject the promise
|
||||
// but let's just allow the error to propagate.
|
||||
return;
|
||||
}
|
||||
v8::Local<v8::Promise::Resolver> resolver = val.As<v8::Promise::Resolver>();
|
||||
args.GetReturnValue().Set(resolver->GetPromise());
|
||||
}
|
||||
|
||||
@@ -443,7 +443,8 @@ MaybeLocal<Promise> FileHandle::ClosePromise() {
|
||||
|
||||
auto maybe_resolver = Promise::Resolver::New(context);
|
||||
CHECK(!maybe_resolver.IsEmpty());
|
||||
Local<Promise::Resolver> resolver = maybe_resolver.ToLocalChecked();
|
||||
Local<Promise::Resolver> resolver;
|
||||
if (!maybe_resolver.ToLocal(&resolver)) return {};
|
||||
Local<Promise> promise = resolver.As<Promise>();
|
||||
|
||||
Local<Object> close_req_obj;
|
||||
@@ -850,10 +851,12 @@ void AfterStringPath(uv_fs_t* req) {
|
||||
req->path,
|
||||
req_wrap->encoding(),
|
||||
&error);
|
||||
if (link.IsEmpty())
|
||||
if (link.IsEmpty()) {
|
||||
req_wrap->Reject(error);
|
||||
else
|
||||
req_wrap->Resolve(link.ToLocalChecked());
|
||||
} else {
|
||||
Local<Value> val;
|
||||
if (link.ToLocal(&val)) req_wrap->Resolve(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -870,10 +873,12 @@ void AfterStringPtr(uv_fs_t* req) {
|
||||
static_cast<const char*>(req->ptr),
|
||||
req_wrap->encoding(),
|
||||
&error);
|
||||
if (link.IsEmpty())
|
||||
if (link.IsEmpty()) {
|
||||
req_wrap->Reject(error);
|
||||
else
|
||||
req_wrap->Resolve(link.ToLocalChecked());
|
||||
} else {
|
||||
Local<Value> val;
|
||||
if (link.ToLocal(&val)) req_wrap->Resolve(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2339,7 +2344,8 @@ static void WriteBuffers(const FunctionCallbackInfo<Value>& args) {
|
||||
MaybeStackBuffer<uv_buf_t> iovs(chunks->Length());
|
||||
|
||||
for (uint32_t i = 0; i < iovs.length(); i++) {
|
||||
Local<Value> chunk = chunks->Get(env->context(), i).ToLocalChecked();
|
||||
Local<Value> chunk;
|
||||
if (!chunks->Get(env->context(), i).ToLocal(&chunk)) return;
|
||||
CHECK(Buffer::HasInstance(chunk));
|
||||
iovs[i] = uv_buf_init(Buffer::Data(chunk), Buffer::Length(chunk));
|
||||
}
|
||||
@@ -2679,8 +2685,12 @@ static void ReadFileUtf8(const FunctionCallbackInfo<Value>& args) {
|
||||
}
|
||||
FS_SYNC_TRACE_END(read);
|
||||
|
||||
args.GetReturnValue().Set(
|
||||
ToV8Value(env->context(), result, isolate).ToLocalChecked());
|
||||
Local<Value> val;
|
||||
if (!ToV8Value(env->context(), result, isolate).ToLocal(&val)) {
|
||||
return;
|
||||
}
|
||||
|
||||
args.GetReturnValue().Set(val);
|
||||
}
|
||||
|
||||
// Wrapper for readv(2).
|
||||
@@ -2708,7 +2718,8 @@ static void ReadBuffers(const FunctionCallbackInfo<Value>& args) {
|
||||
|
||||
// Init uv buffers from ArrayBufferViews
|
||||
for (uint32_t i = 0; i < iovs.length(); i++) {
|
||||
Local<Value> buffer = buffers->Get(env->context(), i).ToLocalChecked();
|
||||
Local<Value> buffer;
|
||||
if (!buffers->Get(env->context(), i).ToLocal(&buffer)) return;
|
||||
CHECK(Buffer::HasInstance(buffer));
|
||||
iovs[i] = uv_buf_init(Buffer::Data(buffer), Buffer::Length(buffer));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user