src: replace Environment::GetCurrent with args.GetIsolate

PR-URL: https://github.com/nodejs/node/pull/60256
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: theanarkh <theratliter@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Bryan English <bryan@bryanenglish.com>
This commit is contained in:
Sohyeon Kim 2025-10-18 16:56:36 +09:00 committed by GitHub
parent c2d44174b2
commit 4d1dece375
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 22 deletions

View File

@ -53,8 +53,8 @@ CHAR_TEST(16, IsUnicodeSurrogateTrail, (ch & 0x400) != 0)
static void GetOwnNonIndexProperties(
const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
Local<Context> context = env->context();
Isolate* isolate = args.GetIsolate();
Local<Context> context = isolate->GetCurrentContext();
CHECK(args[0]->IsObject());
CHECK(args[1]->IsUint32());
@ -168,7 +168,7 @@ static void PreviewEntries(const FunctionCallbackInfo<Value>& args) {
if (!args[0]->IsObject())
return;
Environment* env = Environment::GetCurrent(args);
Isolate* isolate = args.GetIsolate();
bool is_key_value;
Local<Array> entries;
if (!args[0].As<Object>()->PreviewEntries(&is_key_value).ToLocal(&entries))
@ -177,12 +177,8 @@ static void PreviewEntries(const FunctionCallbackInfo<Value>& args) {
if (args.Length() == 1)
return args.GetReturnValue().Set(entries);
Local<Value> ret[] = {
entries,
Boolean::New(env->isolate(), is_key_value)
};
return args.GetReturnValue().Set(
Array::New(env->isolate(), ret, arraysize(ret)));
Local<Value> ret[] = {entries, Boolean::New(isolate, is_key_value)};
return args.GetReturnValue().Set(Array::New(isolate, ret, arraysize(ret)));
}
static void Sleep(const FunctionCallbackInfo<Value>& args) {
@ -222,9 +218,10 @@ static uint32_t GetUVHandleTypeCode(const uv_handle_type type) {
}
static void GuessHandleType(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
Isolate* isolate = args.GetIsolate();
Local<Context> context = isolate->GetCurrentContext();
int fd;
if (!args[0]->Int32Value(env->context()).To(&fd)) return;
if (!args[0]->Int32Value(context).To(&fd)) return;
CHECK_GE(fd, 0);
uv_handle_type t = uv_guess_handle(fd);
@ -239,10 +236,12 @@ static uint32_t FastGuessHandleType(Local<Value> receiver, const uint32_t fd) {
CFunction fast_guess_handle_type_(CFunction::Make(FastGuessHandleType));
static void ParseEnv(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
Isolate* isolate = args.GetIsolate();
Local<Context> context = isolate->GetCurrentContext();
Environment* env = Environment::GetCurrent(context);
CHECK_EQ(args.Length(), 1); // content
CHECK(args[0]->IsString());
Utf8Value content(env->isolate(), args[0]);
Utf8Value content(isolate, args[0]);
Dotenv dotenv{};
dotenv.ParseContent(content.ToStringView());
Local<Object> obj;
@ -252,8 +251,9 @@ static void ParseEnv(const FunctionCallbackInfo<Value>& args) {
}
static void GetCallSites(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
Isolate* isolate = env->isolate();
Isolate* isolate = args.GetIsolate();
Local<Context> context = isolate->GetCurrentContext();
Environment* env = Environment::GetCurrent(context);
CHECK_EQ(args.Length(), 1);
CHECK(args[0]->IsNumber());
@ -306,8 +306,7 @@ static void GetCallSites(const FunctionCallbackInfo<Value>& args) {
};
Local<Object> callsite;
if (!NewDictionaryInstanceNullProto(
env->context(), callsite_template, values)
if (!NewDictionaryInstanceNullProto(context, callsite_template, values)
.ToLocal(&callsite)) {
return;
}

View File

@ -68,7 +68,9 @@ void GetErrMessage(const FunctionCallbackInfo<Value>& args) {
}
void ErrName(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
Isolate* isolate = args.GetIsolate();
Local<Context> context = isolate->GetCurrentContext();
Environment* env = Environment::GetCurrent(context);
if (env->options()->pending_deprecation && env->EmitErrNameWarning()) {
if (ProcessEmitDeprecationWarning(
env,
@ -82,13 +84,12 @@ void ErrName(const FunctionCallbackInfo<Value>& args) {
CHECK_LT(err, 0);
char name[50];
uv_err_name_r(err, name, sizeof(name));
args.GetReturnValue().Set(OneByteString(env->isolate(), name));
args.GetReturnValue().Set(OneByteString(isolate, name));
}
void GetErrMap(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
Isolate* isolate = env->isolate();
Local<Context> context = env->context();
Isolate* isolate = args.GetIsolate();
Local<Context> context = isolate->GetCurrentContext();
// This can't return a SafeMap, because the uv binding can be referenced
// by user code by using `process.binding('uv').getErrorMap()`: