Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions src/node_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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))
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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());
Expand Down Expand Up @@ -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;
}
Expand Down
11 changes: 6 additions & 5 deletions src/uv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()`:
Expand Down
Loading