Skip to content

Commit 29b8157

Browse files
anonrigRafaelGSS
authored andcommitted
src: refactor GetCreationContext calls
PR-URL: #51287 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent f00f120 commit 29b8157

File tree

5 files changed

+12
-14
lines changed

5 files changed

+12
-14
lines changed

src/api/callback.cc

+3-4
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,7 @@ MaybeLocal<Value> MakeCallback(Isolate* isolate,
248248
Local<Value> argv[],
249249
async_context asyncContext) {
250250
// Check can_call_into_js() first because calling Get() might do so.
251-
Environment* env =
252-
Environment::GetCurrent(recv->GetCreationContext().ToLocalChecked());
251+
Environment* env = Environment::GetCurrent(recv->GetCreationContextChecked());
253252
CHECK_NOT_NULL(env);
254253
if (!env->can_call_into_js()) return Local<Value>();
255254

@@ -279,7 +278,7 @@ MaybeLocal<Value> MakeCallback(Isolate* isolate,
279278
// Because of the AssignToContext() call in src/node_contextify.cc,
280279
// the two contexts need not be the same.
281280
Environment* env =
282-
Environment::GetCurrent(callback->GetCreationContext().ToLocalChecked());
281+
Environment::GetCurrent(callback->GetCreationContextChecked());
283282
CHECK_NOT_NULL(env);
284283
Context::Scope context_scope(env->context());
285284
MaybeLocal<Value> ret =
@@ -302,7 +301,7 @@ MaybeLocal<Value> MakeSyncCallback(Isolate* isolate,
302301
int argc,
303302
Local<Value> argv[]) {
304303
Environment* env =
305-
Environment::GetCurrent(callback->GetCreationContext().ToLocalChecked());
304+
Environment::GetCurrent(callback->GetCreationContextChecked());
306305
CHECK_NOT_NULL(env);
307306
if (!env->can_call_into_js()) return Local<Value>();
308307

src/base_object-inl.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ v8::Local<v8::Object> BaseObject::object() const {
5555
v8::Local<v8::Object> BaseObject::object(v8::Isolate* isolate) const {
5656
v8::Local<v8::Object> handle = object();
5757

58-
DCHECK_EQ(handle->GetCreationContext().ToLocalChecked()->GetIsolate(),
59-
isolate);
58+
DCHECK_EQ(handle->GetCreationContextChecked()->GetIsolate(), isolate);
6059
DCHECK_EQ(env()->isolate(), isolate);
6160

6261
return handle;

src/module_wrap.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Local<Context> ModuleWrap::context() const {
8989
// If this fails, there is likely a bug e.g. ModuleWrap::context() is accessed
9090
// before the ModuleWrap constructor completes.
9191
CHECK(obj->IsObject());
92-
return obj.As<Object>()->GetCreationContext().ToLocalChecked();
92+
return obj.As<Object>()->GetCreationContextChecked();
9393
}
9494

9595
ModuleWrap* ModuleWrap::GetFromModule(Environment* env,

src/node_messaging.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ void MessagePort::OnMessage(MessageProcessingMode mode) {
800800

801801
HandleScope handle_scope(env()->isolate());
802802
Local<Context> context =
803-
object(env()->isolate())->GetCreationContext().ToLocalChecked();
803+
object(env()->isolate())->GetCreationContextChecked();
804804

805805
size_t processing_limit;
806806
if (mode == MessageProcessingMode::kNormalOperation) {
@@ -1057,7 +1057,7 @@ bool GetTransferList(Environment* env,
10571057
void MessagePort::PostMessage(const FunctionCallbackInfo<Value>& args) {
10581058
Environment* env = Environment::GetCurrent(args);
10591059
Local<Object> obj = args.This();
1060-
Local<Context> context = obj->GetCreationContext().ToLocalChecked();
1060+
Local<Context> context = obj->GetCreationContextChecked();
10611061

10621062
if (args.Length() == 0) {
10631063
return THROW_ERR_MISSING_ARGS(env, "Not enough arguments to "
@@ -1143,9 +1143,9 @@ void MessagePort::ReceiveMessage(const FunctionCallbackInfo<Value>& args) {
11431143
return;
11441144
}
11451145

1146-
MaybeLocal<Value> payload = port->ReceiveMessage(
1147-
port->object()->GetCreationContext().ToLocalChecked(),
1148-
MessageProcessingMode::kForceReadMessages);
1146+
MaybeLocal<Value> payload =
1147+
port->ReceiveMessage(port->object()->GetCreationContextChecked(),
1148+
MessageProcessingMode::kForceReadMessages);
11491149
if (!payload.IsEmpty())
11501150
args.GetReturnValue().Set(payload.ToLocalChecked());
11511151
}
@@ -1610,7 +1610,7 @@ static void MessageChannel(const FunctionCallbackInfo<Value>& args) {
16101610
return;
16111611
}
16121612

1613-
Local<Context> context = args.This()->GetCreationContext().ToLocalChecked();
1613+
Local<Context> context = args.This()->GetCreationContextChecked();
16141614
Context::Scope context_scope(context);
16151615

16161616
MessagePort* port1 = MessagePort::New(env, context);

src/node_worker.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ void GetEnvMessagePort(const FunctionCallbackInfo<Value>& args) {
907907
Local<Object> port = env->message_port();
908908
CHECK_IMPLIES(!env->is_main_thread(), !port.IsEmpty());
909909
if (!port.IsEmpty()) {
910-
CHECK_EQ(port->GetCreationContext().ToLocalChecked()->GetIsolate(),
910+
CHECK_EQ(port->GetCreationContextChecked()->GetIsolate(),
911911
args.GetIsolate());
912912
args.GetReturnValue().Set(port);
913913
}

0 commit comments

Comments
 (0)