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

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
Backport-PR-URL: https://github.com/nodejs/node/pull/51004
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
This commit is contained in:
Joyee Cheung authored and Richard Lau committed 2024-03-15 17:55:07 +00:00
1 parent 5b5e5192f7
commit ff334cb774
6 files changed
+13 -8

No files matched your search

+2 -1
View File
@@ -127,7 +127,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>
+4 -2
View File
@@ -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();
}
@@ -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));
+1 -1
View File
@@ -438,7 +438,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>();
+1 -1
View File
@@ -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)
+2 -1
View File
@@ -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_)
+3 -2
View File
@@ -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);
}