From ad0ce574320966ab2c7410a2c2ec8530e2bae500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 26 Jan 2016 09:41:29 +0100 Subject: [PATCH] src: fix NewInstance deprecation warnings PR-URL: https://github.com/nodejs/node/pull/4722 Reviewed-By: Ben Noordhuis Reviewed-By: Ali Ijaz Sheikh --- src/debug-agent.cc | 3 ++- src/node.cc | 6 ++++-- src/node_contextify.cc | 3 ++- src/node_file.cc | 5 ++++- src/pipe_wrap.cc | 4 ++-- src/tcp_wrap.cc | 4 ++-- src/tls_wrap.cc | 6 ++++-- src/udp_wrap.cc | 3 ++- 8 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/debug-agent.cc b/src/debug-agent.cc index 5fcc7ebb2e..2e51c89c98 100644 --- a/src/debug-agent.cc +++ b/src/debug-agent.cc @@ -216,7 +216,8 @@ void Agent::InitAdaptor(Environment* env) { NODE_SET_PROTOTYPE_METHOD(t, "notifyWait", NotifyWait); NODE_SET_PROTOTYPE_METHOD(t, "sendCommand", SendCommand); - Local api = t->GetFunction()->NewInstance(); + Local api = + t->GetFunction()->NewInstance(env->context()).ToLocalChecked(); api->SetAlignedPointerInInternalField(0, this); api->Set(String::NewFromUtf8(isolate, "port"), Integer::New(isolate, port_)); diff --git a/src/node.cc b/src/node.cc index fdc7c1972a..c71e35a45d 100644 --- a/src/node.cc +++ b/src/node.cc @@ -2989,7 +2989,8 @@ void SetupProcessObject(Environment* env, EnvDeleter, EnvEnumerator, env->as_external()); - Local process_env = process_env_template->NewInstance(); + Local 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())); @@ -4142,7 +4143,8 @@ Environment* CreateEnvironment(Isolate* isolate, Local process_template = FunctionTemplate::New(isolate); process_template->SetClassName(FIXED_ONE_BYTE_STRING(isolate, "process")); - Local process_object = process_template->GetFunction()->NewInstance(); + Local process_object = + process_template->GetFunction()->NewInstance(context).ToLocalChecked(); env->set_process_object(process_object); SetupProcessObject(env, argc, argv, exec_argc, exec_argv); diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 5d86515b1b..6e04d5836f 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -176,7 +176,8 @@ class ContextifyContext { Local CreateDataWrapper(Environment* env) { EscapableHandleScope scope(env->isolate()); Local wrapper = - env->script_data_constructor_function()->NewInstance(); + env->script_data_constructor_function() + ->NewInstance(env->context()).FromMaybe(Local()); if (wrapper.IsEmpty()) return scope.Escape(Local::New(env->isolate(), Local())); diff --git a/src/node_file.cc b/src/node_file.cc index 57e5168ab2..1a318ce075 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -442,7 +442,10 @@ Local BuildStatsObject(Environment* env, const uv_stat_t* s) { // Call out to JavaScript to create the stats object. Local 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()); if (stats.IsEmpty()) return handle_scope.Escape(Local()); diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index 84164723e9..1cb6f67086 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -63,8 +63,8 @@ Local PipeWrap::Instantiate(Environment* env, AsyncWrap* parent) { Local constructor = env->pipe_constructor_template()->GetFunction(); CHECK_EQ(false, constructor.IsEmpty()); Local ptr = External::New(env->isolate(), parent); - Local instance = constructor->NewInstance(1, &ptr); - CHECK_EQ(false, instance.IsEmpty()); + Local instance = + constructor->NewInstance(env->context(), 1, &ptr).ToLocalChecked(); return handle_scope.Escape(instance); } diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index 3f3e6a0ad4..5e08f689b4 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -57,8 +57,8 @@ Local TCPWrap::Instantiate(Environment* env, AsyncWrap* parent) { Local constructor = env->tcp_constructor_template()->GetFunction(); CHECK_EQ(constructor.IsEmpty(), false); Local ptr = External::New(env->isolate(), parent); - Local instance = constructor->NewInstance(1, &ptr); - CHECK_EQ(instance.IsEmpty(), false); + Local instance = + constructor->NewInstance(env->context(), 1, &ptr).ToLocalChecked(); return handle_scope.Escape(instance); } diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index 85730b3493..2885ef900a 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -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(env, sc, kind), StreamBase(env), @@ -289,7 +290,8 @@ void TLSWrap::EncOut() { CHECK(write_size_ != 0 && count != 0); Local 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, diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index 1faf45a95d..075800d3a7 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -422,7 +422,8 @@ Local UDPWrap::Instantiate(Environment* env, AsyncWrap* parent) { CHECK_EQ(env->udp_constructor_function().IsEmpty(), false); EscapableHandleScope scope(env->isolate()); Local 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()); }