Skip to content

Commit df8396a

Browse files
KimSH39aduh95
authored andcommitted
src: replace Environment::GetCurrent with args.GetIsolate
PR-URL: #60256 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: theanarkh <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Bryan English <[email protected]>
1 parent e3c3b48 commit df8396a

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

src/node_util.cc

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ CHAR_TEST(16, IsUnicodeSurrogateTrail, (ch & 0x400) != 0)
5353

5454
static void GetOwnNonIndexProperties(
5555
const FunctionCallbackInfo<Value>& args) {
56-
Environment* env = Environment::GetCurrent(args);
57-
Local<Context> context = env->context();
56+
Isolate* isolate = args.GetIsolate();
57+
Local<Context> context = isolate->GetCurrentContext();
5858

5959
CHECK(args[0]->IsObject());
6060
CHECK(args[1]->IsUint32());
@@ -168,7 +168,7 @@ static void PreviewEntries(const FunctionCallbackInfo<Value>& args) {
168168
if (!args[0]->IsObject())
169169
return;
170170

171-
Environment* env = Environment::GetCurrent(args);
171+
Isolate* isolate = args.GetIsolate();
172172
bool is_key_value;
173173
Local<Array> entries;
174174
if (!args[0].As<Object>()->PreviewEntries(&is_key_value).ToLocal(&entries))
@@ -177,12 +177,8 @@ static void PreviewEntries(const FunctionCallbackInfo<Value>& args) {
177177
if (args.Length() == 1)
178178
return args.GetReturnValue().Set(entries);
179179

180-
Local<Value> ret[] = {
181-
entries,
182-
Boolean::New(env->isolate(), is_key_value)
183-
};
184-
return args.GetReturnValue().Set(
185-
Array::New(env->isolate(), ret, arraysize(ret)));
180+
Local<Value> ret[] = {entries, Boolean::New(isolate, is_key_value)};
181+
return args.GetReturnValue().Set(Array::New(isolate, ret, arraysize(ret)));
186182
}
187183

188184
static void Sleep(const FunctionCallbackInfo<Value>& args) {
@@ -222,9 +218,10 @@ static uint32_t GetUVHandleTypeCode(const uv_handle_type type) {
222218
}
223219

224220
static void GuessHandleType(const FunctionCallbackInfo<Value>& args) {
225-
Environment* env = Environment::GetCurrent(args);
221+
Isolate* isolate = args.GetIsolate();
222+
Local<Context> context = isolate->GetCurrentContext();
226223
int fd;
227-
if (!args[0]->Int32Value(env->context()).To(&fd)) return;
224+
if (!args[0]->Int32Value(context).To(&fd)) return;
228225
CHECK_GE(fd, 0);
229226

230227
uv_handle_type t = uv_guess_handle(fd);
@@ -239,10 +236,12 @@ static uint32_t FastGuessHandleType(Local<Value> receiver, const uint32_t fd) {
239236
CFunction fast_guess_handle_type_(CFunction::Make(FastGuessHandleType));
240237

241238
static void ParseEnv(const FunctionCallbackInfo<Value>& args) {
242-
Environment* env = Environment::GetCurrent(args);
239+
Isolate* isolate = args.GetIsolate();
240+
Local<Context> context = isolate->GetCurrentContext();
241+
Environment* env = Environment::GetCurrent(context);
243242
CHECK_EQ(args.Length(), 1); // content
244243
CHECK(args[0]->IsString());
245-
Utf8Value content(env->isolate(), args[0]);
244+
Utf8Value content(isolate, args[0]);
246245
Dotenv dotenv{};
247246
dotenv.ParseContent(content.ToStringView());
248247
Local<Object> obj;
@@ -252,8 +251,9 @@ static void ParseEnv(const FunctionCallbackInfo<Value>& args) {
252251
}
253252

254253
static void GetCallSites(const FunctionCallbackInfo<Value>& args) {
255-
Environment* env = Environment::GetCurrent(args);
256-
Isolate* isolate = env->isolate();
254+
Isolate* isolate = args.GetIsolate();
255+
Local<Context> context = isolate->GetCurrentContext();
256+
Environment* env = Environment::GetCurrent(context);
257257

258258
CHECK_EQ(args.Length(), 1);
259259
CHECK(args[0]->IsNumber());
@@ -306,8 +306,7 @@ static void GetCallSites(const FunctionCallbackInfo<Value>& args) {
306306
};
307307

308308
Local<Object> callsite;
309-
if (!NewDictionaryInstanceNullProto(
310-
env->context(), callsite_template, values)
309+
if (!NewDictionaryInstanceNullProto(context, callsite_template, values)
311310
.ToLocal(&callsite)) {
312311
return;
313312
}

src/uv.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ void GetErrMessage(const FunctionCallbackInfo<Value>& args) {
6868
}
6969

7070
void ErrName(const FunctionCallbackInfo<Value>& args) {
71-
Environment* env = Environment::GetCurrent(args);
71+
Isolate* isolate = args.GetIsolate();
72+
Local<Context> context = isolate->GetCurrentContext();
73+
Environment* env = Environment::GetCurrent(context);
7274
if (env->options()->pending_deprecation && env->EmitErrNameWarning()) {
7375
if (ProcessEmitDeprecationWarning(
7476
env,
@@ -82,13 +84,12 @@ void ErrName(const FunctionCallbackInfo<Value>& args) {
8284
CHECK_LT(err, 0);
8385
char name[50];
8486
uv_err_name_r(err, name, sizeof(name));
85-
args.GetReturnValue().Set(OneByteString(env->isolate(), name));
87+
args.GetReturnValue().Set(OneByteString(isolate, name));
8688
}
8789

8890
void GetErrMap(const FunctionCallbackInfo<Value>& args) {
89-
Environment* env = Environment::GetCurrent(args);
90-
Isolate* isolate = env->isolate();
91-
Local<Context> context = env->context();
91+
Isolate* isolate = args.GetIsolate();
92+
Local<Context> context = isolate->GetCurrentContext();
9293

9394
// This can't return a SafeMap, because the uv binding can be referenced
9495
// by user code by using `process.binding('uv').getErrorMap()`:

0 commit comments

Comments
 (0)