From 498a4d355f653923436974dd7aadac6c15cce267 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Wed, 2 Aug 2023 04:14:35 +0200 Subject: [PATCH] src: cast v8::Object::GetInternalField() return value to v8::Value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In preparation of https://chromium-review.googlesource.com/c/v8/v8/+/4707972 which changes the return value to v8::Data. PR-URL: https://github.com/nodejs/node/pull/48943 Reviewed-By: Juan José Arboleda Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Tobias Nießen Reviewed-By: Chengzhong Wu Reviewed-By: Stephen Belanger Reviewed-By: Jiawen Geng --- src/base_object-inl.h | 3 ++- src/module_wrap.cc | 6 ++++-- src/node_file.cc | 2 +- src/node_task_queue.cc | 2 +- src/node_zlib.cc | 3 ++- src/stream_base.cc | 5 +++-- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/base_object-inl.h b/src/base_object-inl.h index f003f1390b864f..0148c75427985e 100644 --- a/src/base_object-inl.h +++ b/src/base_object-inl.h @@ -127,7 +127,8 @@ template void BaseObject::InternalFieldGet( v8::Local property, const v8::PropertyCallbackInfo& info) { - info.GetReturnValue().Set(info.This()->GetInternalField(Field)); + info.GetReturnValue().Set( + info.This()->GetInternalField(Field).As()); } template diff --git a/src/module_wrap.cc b/src/module_wrap.cc index 21b9a702aebaf4..2e3d444f64cd15 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -78,7 +78,7 @@ ModuleWrap::~ModuleWrap() { } Local ModuleWrap::context() const { - Local obj = object()->GetInternalField(kContextObjectSlot); + Local obj = object()->GetInternalField(kContextObjectSlot).As(); if (obj.IsEmpty()) return {}; return obj.As()->GetCreationContext().ToLocalChecked(); } @@ -684,7 +684,9 @@ MaybeLocal ModuleWrap::SyntheticModuleEvaluationStepsCallback( TryCatchScope try_catch(env); Local synthetic_evaluation_steps = - obj->object()->GetInternalField(kSyntheticEvaluationStepsSlot) + obj->object() + ->GetInternalField(kSyntheticEvaluationStepsSlot) + .As() .As(); obj->object()->SetInternalField( kSyntheticEvaluationStepsSlot, Undefined(isolate)); diff --git a/src/node_file.cc b/src/node_file.cc index 7f627ac458492c..ebbb67c226775d 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -438,7 +438,7 @@ MaybeLocal FileHandle::ClosePromise() { Local context = env()->context(); Local close_resolver = - object()->GetInternalField(FileHandle::kClosingPromiseSlot); + object()->GetInternalField(FileHandle::kClosingPromiseSlot).As(); if (!close_resolver.IsEmpty() && !close_resolver->IsUndefined()) { CHECK(close_resolver->IsPromise()); return close_resolver.As(); diff --git a/src/node_task_queue.cc b/src/node_task_queue.cc index 5d0e2b0d4c7ba1..1a0cb082a2534f 100644 --- a/src/node_task_queue.cc +++ b/src/node_task_queue.cc @@ -50,7 +50,7 @@ static Maybe 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 promiseWrap = promise->GetInternalField(0); + Local promiseWrap = promise->GetInternalField(0).As(); if (promiseWrap->IsObject()) { Local maybe_async_id; if (!promiseWrap.As()->Get(env->context(), id_symbol) diff --git a/src/node_zlib.cc b/src/node_zlib.cc index fac116f9e6b3e2..0c4ae0fc794347 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -423,7 +423,8 @@ class CompressionStream : public AsyncWrap, public ThreadPoolWork { UpdateWriteResult(); // call the write() cb - Local cb = object()->GetInternalField(kWriteJSCallback); + Local cb = + object()->GetInternalField(kWriteJSCallback).template As(); MakeCallback(cb.As(), 0, nullptr); if (pending_close_) diff --git a/src/stream_base.cc b/src/stream_base.cc index f1769ca52970fe..b9dfc645e2b49c 100644 --- a/src/stream_base.cc +++ b/src/stream_base.cc @@ -470,8 +470,9 @@ MaybeLocal StreamBase::CallJSOnreadMethod(ssize_t nread, AsyncWrap* wrap = GetAsyncWrap(); CHECK_NOT_NULL(wrap); - Local onread = wrap->object()->GetInternalField( - StreamBase::kOnReadFunctionField); + Local onread = wrap->object() + ->GetInternalField(StreamBase::kOnReadFunctionField) + .As(); CHECK(onread->IsFunction()); return wrap->MakeCallback(onread.As(), arraysize(argv), argv); }