Skip to content

Commit

Permalink
src: cast v8::Object::GetInternalField() return value to v8::Value
Browse files Browse the repository at this point in the history
In preparation of https://chromium-review.googlesource.com/c/v8/v8/+/4707972
which changes the return value to v8::Data.

PR-URL: #48943
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>
  • Loading branch information
joyeecheung authored and RafaelGSS committed Aug 17, 2023
1 parent 7b9adff commit 6c389df
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/base_object-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,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

0 comments on commit 6c389df

Please sign in to comment.