Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: cast v8::Object::GetInternalField() return value to v8::Value #48943

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/base_object-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ template <int Field>
void BaseObject::InternalFieldGet(
v8::Local<v8::String> property,
const v8::PropertyCallbackInfo<v8::Value>& info) {
info.GetReturnValue().Set(info.This()->GetInternalField(Field));
info.GetReturnValue().Set(
info.This()->GetInternalField(Field).As<v8::Value>());
}

template <int Field, bool (v8::Value::* typecheck)() const>
Expand Down
6 changes: 4 additions & 2 deletions src/module_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ ModuleWrap::~ModuleWrap() {
}

Local<Context> ModuleWrap::context() const {
Local<Value> obj = object()->GetInternalField(kContextObjectSlot);
Local<Value> obj = object()->GetInternalField(kContextObjectSlot).As<Value>();
if (obj.IsEmpty()) return {};
return obj.As<Object>()->GetCreationContext().ToLocalChecked();
}
Expand Down Expand Up @@ -684,7 +684,9 @@ MaybeLocal<Value> ModuleWrap::SyntheticModuleEvaluationStepsCallback(

TryCatchScope try_catch(env);
Local<Function> synthetic_evaluation_steps =
obj->object()->GetInternalField(kSyntheticEvaluationStepsSlot)
obj->object()
->GetInternalField(kSyntheticEvaluationStepsSlot)
.As<Value>()
.As<Function>();
obj->object()->SetInternalField(
kSyntheticEvaluationStepsSlot, Undefined(isolate));
Expand Down
2 changes: 1 addition & 1 deletion src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ MaybeLocal<Promise> FileHandle::ClosePromise() {
Local<Context> context = env()->context();

Local<Value> close_resolver =
object()->GetInternalField(FileHandle::kClosingPromiseSlot);
object()->GetInternalField(FileHandle::kClosingPromiseSlot).As<Value>();
if (!close_resolver.IsEmpty() && !close_resolver->IsUndefined()) {
CHECK(close_resolver->IsPromise());
return close_resolver.As<Promise>();
Expand Down
2 changes: 1 addition & 1 deletion src/node_task_queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static Maybe<double> GetAssignedPromiseWrapAsyncId(Environment* env,
// be an object. If it's not, we just ignore it. Ideally v8 would
// have had GetInternalField returning a MaybeLocal but this works
// for now.
Local<Value> promiseWrap = promise->GetInternalField(0);
Local<Value> promiseWrap = promise->GetInternalField(0).As<Value>();
if (promiseWrap->IsObject()) {
Local<Value> maybe_async_id;
if (!promiseWrap.As<Object>()->Get(env->context(), id_symbol)
Expand Down
3 changes: 2 additions & 1 deletion src/node_zlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ class CompressionStream : public AsyncWrap, public ThreadPoolWork {
UpdateWriteResult();

// call the write() cb
Local<Value> cb = object()->GetInternalField(kWriteJSCallback);
Local<Value> cb =
object()->GetInternalField(kWriteJSCallback).template As<Value>();
MakeCallback(cb.As<Function>(), 0, nullptr);

if (pending_close_)
Expand Down
5 changes: 3 additions & 2 deletions src/stream_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,9 @@ MaybeLocal<Value> StreamBase::CallJSOnreadMethod(ssize_t nread,

AsyncWrap* wrap = GetAsyncWrap();
CHECK_NOT_NULL(wrap);
Local<Value> onread = wrap->object()->GetInternalField(
StreamBase::kOnReadFunctionField);
Local<Value> onread = wrap->object()
->GetInternalField(StreamBase::kOnReadFunctionField)
.As<Value>();
CHECK(onread->IsFunction());
return wrap->MakeCallback(onread.As<Function>(), arraysize(argv), argv);
}
Expand Down