Skip to content

Commit fe151d3

Browse files
targosnodejs-ci
authored andcommitted
src: use non-deprecated GetCreationContext from V8
Fixes: #193
1 parent 03bfe51 commit fe151d3

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

src/api/callback.cc

+6-3
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ MaybeLocal<Value> MakeCallback(Isolate* isolate,
223223
Local<Value> argv[],
224224
async_context asyncContext) {
225225
// Check can_call_into_js() first because calling Get() might do so.
226-
Environment* env = Environment::GetCurrent(recv->CreationContext());
226+
Environment* env =
227+
Environment::GetCurrent(recv->GetCreationContext().ToLocalChecked());
227228
CHECK_NOT_NULL(env);
228229
if (!env->can_call_into_js()) return Local<Value>();
229230

@@ -252,7 +253,8 @@ MaybeLocal<Value> MakeCallback(Isolate* isolate,
252253
//
253254
// Because of the AssignToContext() call in src/node_contextify.cc,
254255
// the two contexts need not be the same.
255-
Environment* env = Environment::GetCurrent(callback->CreationContext());
256+
Environment* env =
257+
Environment::GetCurrent(callback->GetCreationContext().ToLocalChecked());
256258
CHECK_NOT_NULL(env);
257259
Context::Scope context_scope(env->context());
258260
MaybeLocal<Value> ret =
@@ -274,7 +276,8 @@ MaybeLocal<Value> MakeSyncCallback(Isolate* isolate,
274276
Local<Function> callback,
275277
int argc,
276278
Local<Value> argv[]) {
277-
Environment* env = Environment::GetCurrent(callback->CreationContext());
279+
Environment* env =
280+
Environment::GetCurrent(callback->GetCreationContext().ToLocalChecked());
278281
CHECK_NOT_NULL(env);
279282
if (!env->can_call_into_js()) return Local<Value>();
280283

src/async_wrap.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static uint16_t ToAsyncHooksType(PromiseHookType type) {
298298
// Simplified JavaScript hook fast-path for when there is no destroy hook
299299
static void FastPromiseHook(PromiseHookType type, Local<Promise> promise,
300300
Local<Value> parent) {
301-
Local<Context> context = promise->CreationContext();
301+
Local<Context> context = promise->GetCreationContext().ToLocalChecked();
302302
Environment* env = Environment::GetCurrent(context);
303303
if (env == nullptr) return;
304304

@@ -357,7 +357,7 @@ static void FastPromiseHook(PromiseHookType type, Local<Promise> promise,
357357

358358
static void FullPromiseHook(PromiseHookType type, Local<Promise> promise,
359359
Local<Value> parent) {
360-
Local<Context> context = promise->CreationContext();
360+
Local<Context> context = promise->GetCreationContext().ToLocalChecked();
361361

362362
Environment* env = Environment::GetCurrent(context);
363363
if (env == nullptr) return;

src/module_wrap.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ ModuleWrap::~ModuleWrap() {
8383
Local<Context> ModuleWrap::context() const {
8484
Local<Value> obj = object()->GetInternalField(kContextObjectSlot);
8585
if (obj.IsEmpty()) return {};
86-
return obj.As<Object>()->CreationContext();
86+
return obj.As<Object>()->GetCreationContext().ToLocalChecked();
8787
}
8888

8989
ModuleWrap* ModuleWrap::GetFromModule(Environment* env,
@@ -122,7 +122,7 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
122122
Local<Context> context;
123123
ContextifyContext* contextify_context = nullptr;
124124
if (args[1]->IsUndefined()) {
125-
context = that->CreationContext();
125+
context = that->GetCreationContext().ToLocalChecked();
126126
} else {
127127
CHECK(args[1]->IsObject());
128128
contextify_context = ContextifyContext::ContextFromContextifiedSandbox(
@@ -237,7 +237,7 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
237237
obj->object()->SetInternalField(kSyntheticEvaluationStepsSlot, args[3]);
238238
}
239239

240-
// Use the extras object as an object whose CreationContext() will be the
240+
// Use the extras object as an object whose GetCreationContext() will be the
241241
// original `context`, since the `Context` itself strictly speaking cannot
242242
// be stored in an internal field.
243243
obj->object()->SetInternalField(kContextObjectSlot,

src/node_messaging.cc

+8-7
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,8 @@ MaybeLocal<Value> MessagePort::ReceiveMessage(Local<Context> context,
702702
void MessagePort::OnMessage(MessageProcessingMode mode) {
703703
Debug(this, "Running MessagePort::OnMessage()");
704704
HandleScope handle_scope(env()->isolate());
705-
Local<Context> context = object(env()->isolate())->CreationContext();
705+
Local<Context> context =
706+
object(env()->isolate())->GetCreationContext().ToLocalChecked();
706707

707708
size_t processing_limit;
708709
if (mode == MessageProcessingMode::kNormalOperation) {
@@ -815,7 +816,7 @@ Maybe<bool> MessagePort::PostMessage(Environment* env,
815816
const TransferList& transfer_v) {
816817
Isolate* isolate = env->isolate();
817818
Local<Object> obj = object(isolate);
818-
Local<Context> context = obj->CreationContext();
819+
Local<Context> context = obj->GetCreationContext().ToLocalChecked();
819820

820821
std::shared_ptr<Message> msg = std::make_shared<Message>();
821822

@@ -913,7 +914,7 @@ static Maybe<bool> ReadIterable(Environment* env,
913914
void MessagePort::PostMessage(const FunctionCallbackInfo<Value>& args) {
914915
Environment* env = Environment::GetCurrent(args);
915916
Local<Object> obj = args.This();
916-
Local<Context> context = obj->CreationContext();
917+
Local<Context> context = obj->GetCreationContext().ToLocalChecked();
917918

918919
if (args.Length() == 0) {
919920
return THROW_ERR_MISSING_ARGS(env, "Not enough arguments to "
@@ -1021,9 +1022,9 @@ void MessagePort::ReceiveMessage(const FunctionCallbackInfo<Value>& args) {
10211022
return;
10221023
}
10231024

1024-
MaybeLocal<Value> payload =
1025-
port->ReceiveMessage(port->object()->CreationContext(),
1026-
MessageProcessingMode::kForceReadMessages);
1025+
MaybeLocal<Value> payload = port->ReceiveMessage(
1026+
port->object()->GetCreationContext().ToLocalChecked(),
1027+
MessageProcessingMode::kForceReadMessages);
10271028
if (!payload.IsEmpty())
10281029
args.GetReturnValue().Set(payload.ToLocalChecked());
10291030
}
@@ -1382,7 +1383,7 @@ static void MessageChannel(const FunctionCallbackInfo<Value>& args) {
13821383
return;
13831384
}
13841385

1385-
Local<Context> context = args.This()->CreationContext();
1386+
Local<Context> context = args.This()->GetCreationContext().ToLocalChecked();
13861387
Context::Scope context_scope(context);
13871388

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

0 commit comments

Comments
 (0)