Skip to content

Commit

Permalink
src: fix NewInstance deprecation warnings
Browse files Browse the repository at this point in the history
PR-URL: #4722
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
  • Loading branch information
targos authored and Ali Sheikh committed Mar 4, 2016
1 parent 67b5a8a commit ad0ce57
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/debug-agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ void Agent::InitAdaptor(Environment* env) {
NODE_SET_PROTOTYPE_METHOD(t, "notifyWait", NotifyWait);
NODE_SET_PROTOTYPE_METHOD(t, "sendCommand", SendCommand);

Local<Object> api = t->GetFunction()->NewInstance();
Local<Object> api =
t->GetFunction()->NewInstance(env->context()).ToLocalChecked();
api->SetAlignedPointerInInternalField(0, this);

api->Set(String::NewFromUtf8(isolate, "port"), Integer::New(isolate, port_));
Expand Down
6 changes: 4 additions & 2 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2989,7 +2989,8 @@ void SetupProcessObject(Environment* env,
EnvDeleter,
EnvEnumerator,
env->as_external());
Local<Object> process_env = process_env_template->NewInstance();
Local<Object> process_env =
process_env_template->NewInstance(env->context()).ToLocalChecked();
process->Set(env->env_string(), process_env);

READONLY_PROPERTY(process, "pid", Integer::New(env->isolate(), getpid()));
Expand Down Expand Up @@ -4142,7 +4143,8 @@ Environment* CreateEnvironment(Isolate* isolate,
Local<FunctionTemplate> process_template = FunctionTemplate::New(isolate);
process_template->SetClassName(FIXED_ONE_BYTE_STRING(isolate, "process"));

Local<Object> process_object = process_template->GetFunction()->NewInstance();
Local<Object> process_object =
process_template->GetFunction()->NewInstance(context).ToLocalChecked();
env->set_process_object(process_object);

SetupProcessObject(env, argc, argv, exec_argc, exec_argv);
Expand Down
3 changes: 2 additions & 1 deletion src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ class ContextifyContext {
Local<Value> CreateDataWrapper(Environment* env) {
EscapableHandleScope scope(env->isolate());
Local<Object> wrapper =
env->script_data_constructor_function()->NewInstance();
env->script_data_constructor_function()
->NewInstance(env->context()).FromMaybe(Local<Object>());
if (wrapper.IsEmpty())
return scope.Escape(Local<Value>::New(env->isolate(), Local<Value>()));

Expand Down
5 changes: 4 additions & 1 deletion src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,10 @@ Local<Value> BuildStatsObject(Environment* env, const uv_stat_t* s) {

// Call out to JavaScript to create the stats object.
Local<Value> stats =
env->fs_stats_constructor_function()->NewInstance(ARRAY_SIZE(argv), argv);
env->fs_stats_constructor_function()->NewInstance(
env->context(),
ARRAY_SIZE(argv),
argv).FromMaybe(Local<Value>());

if (stats.IsEmpty())
return handle_scope.Escape(Local<Object>());
Expand Down
4 changes: 2 additions & 2 deletions src/pipe_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ Local<Object> PipeWrap::Instantiate(Environment* env, AsyncWrap* parent) {
Local<Function> constructor = env->pipe_constructor_template()->GetFunction();
CHECK_EQ(false, constructor.IsEmpty());
Local<Value> ptr = External::New(env->isolate(), parent);
Local<Object> instance = constructor->NewInstance(1, &ptr);
CHECK_EQ(false, instance.IsEmpty());
Local<Object> instance =
constructor->NewInstance(env->context(), 1, &ptr).ToLocalChecked();
return handle_scope.Escape(instance);
}

Expand Down
4 changes: 2 additions & 2 deletions src/tcp_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ Local<Object> TCPWrap::Instantiate(Environment* env, AsyncWrap* parent) {
Local<Function> constructor = env->tcp_constructor_template()->GetFunction();
CHECK_EQ(constructor.IsEmpty(), false);
Local<Value> ptr = External::New(env->isolate(), parent);
Local<Object> instance = constructor->NewInstance(1, &ptr);
CHECK_EQ(instance.IsEmpty(), false);
Local<Object> instance =
constructor->NewInstance(env->context(), 1, &ptr).ToLocalChecked();
return handle_scope.Escape(instance);
}

Expand Down
6 changes: 4 additions & 2 deletions src/tls_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ TLSWrap::TLSWrap(Environment* env,
StreamBase* stream,
SecureContext* sc)
: AsyncWrap(env,
env->tls_wrap_constructor_function()->NewInstance(),
env->tls_wrap_constructor_function()
->NewInstance(env->context()).ToLocalChecked(),
AsyncWrap::PROVIDER_TLSWRAP),
SSLWrap<TLSWrap>(env, sc, kind),
StreamBase(env),
Expand Down Expand Up @@ -289,7 +290,8 @@ void TLSWrap::EncOut() {
CHECK(write_size_ != 0 && count != 0);

Local<Object> req_wrap_obj =
env()->write_wrap_constructor_function()->NewInstance();
env()->write_wrap_constructor_function()
->NewInstance(env()->context()).ToLocalChecked();
WriteWrap* write_req = WriteWrap::New(env(),
req_wrap_obj,
this,
Expand Down
3 changes: 2 additions & 1 deletion src/udp_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ Local<Object> UDPWrap::Instantiate(Environment* env, AsyncWrap* parent) {
CHECK_EQ(env->udp_constructor_function().IsEmpty(), false);
EscapableHandleScope scope(env->isolate());
Local<Value> ptr = External::New(env->isolate(), parent);
return scope.Escape(env->udp_constructor_function()->NewInstance(1, &ptr));
return scope.Escape(env->udp_constructor_function()
->NewInstance(env->context(), 1, &ptr).ToLocalChecked());
}


Expand Down

0 comments on commit ad0ce57

Please sign in to comment.