Browse Source

src: fix NewInstance deprecation warnings

PR-URL: https://github.com/nodejs/node/pull/4722
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
process-exit-stdio-flushing
Michaël Zasso 9 years ago
committed by Ali Sheikh
parent
commit
ad0ce57432
  1. 3
      src/debug-agent.cc
  2. 6
      src/node.cc
  3. 3
      src/node_contextify.cc
  4. 5
      src/node_file.cc
  5. 4
      src/pipe_wrap.cc
  6. 4
      src/tcp_wrap.cc
  7. 6
      src/tls_wrap.cc
  8. 3
      src/udp_wrap.cc

3
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, "notifyWait", NotifyWait);
NODE_SET_PROTOTYPE_METHOD(t, "sendCommand", SendCommand); 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->SetAlignedPointerInInternalField(0, this);
api->Set(String::NewFromUtf8(isolate, "port"), Integer::New(isolate, port_)); api->Set(String::NewFromUtf8(isolate, "port"), Integer::New(isolate, port_));

6
src/node.cc

@ -2989,7 +2989,8 @@ void SetupProcessObject(Environment* env,
EnvDeleter, EnvDeleter,
EnvEnumerator, EnvEnumerator,
env->as_external()); 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); process->Set(env->env_string(), process_env);
READONLY_PROPERTY(process, "pid", Integer::New(env->isolate(), getpid())); READONLY_PROPERTY(process, "pid", Integer::New(env->isolate(), getpid()));
@ -4142,7 +4143,8 @@ Environment* CreateEnvironment(Isolate* isolate,
Local<FunctionTemplate> process_template = FunctionTemplate::New(isolate); Local<FunctionTemplate> process_template = FunctionTemplate::New(isolate);
process_template->SetClassName(FIXED_ONE_BYTE_STRING(isolate, "process")); 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); env->set_process_object(process_object);
SetupProcessObject(env, argc, argv, exec_argc, exec_argv); SetupProcessObject(env, argc, argv, exec_argc, exec_argv);

3
src/node_contextify.cc

@ -176,7 +176,8 @@ class ContextifyContext {
Local<Value> CreateDataWrapper(Environment* env) { Local<Value> CreateDataWrapper(Environment* env) {
EscapableHandleScope scope(env->isolate()); EscapableHandleScope scope(env->isolate());
Local<Object> wrapper = Local<Object> wrapper =
env->script_data_constructor_function()->NewInstance(); env->script_data_constructor_function()
->NewInstance(env->context()).FromMaybe(Local<Object>());
if (wrapper.IsEmpty()) if (wrapper.IsEmpty())
return scope.Escape(Local<Value>::New(env->isolate(), Local<Value>())); return scope.Escape(Local<Value>::New(env->isolate(), Local<Value>()));

5
src/node_file.cc

@ -442,7 +442,10 @@ Local<Value> BuildStatsObject(Environment* env, const uv_stat_t* s) {
// Call out to JavaScript to create the stats object. // Call out to JavaScript to create the stats object.
Local<Value> stats = 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()) if (stats.IsEmpty())
return handle_scope.Escape(Local<Object>()); return handle_scope.Escape(Local<Object>());

4
src/pipe_wrap.cc

@ -63,8 +63,8 @@ Local<Object> PipeWrap::Instantiate(Environment* env, AsyncWrap* parent) {
Local<Function> constructor = env->pipe_constructor_template()->GetFunction(); Local<Function> constructor = env->pipe_constructor_template()->GetFunction();
CHECK_EQ(false, constructor.IsEmpty()); CHECK_EQ(false, constructor.IsEmpty());
Local<Value> ptr = External::New(env->isolate(), parent); Local<Value> ptr = External::New(env->isolate(), parent);
Local<Object> instance = constructor->NewInstance(1, &ptr); Local<Object> instance =
CHECK_EQ(false, instance.IsEmpty()); constructor->NewInstance(env->context(), 1, &ptr).ToLocalChecked();
return handle_scope.Escape(instance); return handle_scope.Escape(instance);
} }

4
src/tcp_wrap.cc

@ -57,8 +57,8 @@ Local<Object> TCPWrap::Instantiate(Environment* env, AsyncWrap* parent) {
Local<Function> constructor = env->tcp_constructor_template()->GetFunction(); Local<Function> constructor = env->tcp_constructor_template()->GetFunction();
CHECK_EQ(constructor.IsEmpty(), false); CHECK_EQ(constructor.IsEmpty(), false);
Local<Value> ptr = External::New(env->isolate(), parent); Local<Value> ptr = External::New(env->isolate(), parent);
Local<Object> instance = constructor->NewInstance(1, &ptr); Local<Object> instance =
CHECK_EQ(instance.IsEmpty(), false); constructor->NewInstance(env->context(), 1, &ptr).ToLocalChecked();
return handle_scope.Escape(instance); return handle_scope.Escape(instance);
} }

6
src/tls_wrap.cc

@ -36,7 +36,8 @@ TLSWrap::TLSWrap(Environment* env,
StreamBase* stream, StreamBase* stream,
SecureContext* sc) SecureContext* sc)
: AsyncWrap(env, : AsyncWrap(env,
env->tls_wrap_constructor_function()->NewInstance(), env->tls_wrap_constructor_function()
->NewInstance(env->context()).ToLocalChecked(),
AsyncWrap::PROVIDER_TLSWRAP), AsyncWrap::PROVIDER_TLSWRAP),
SSLWrap<TLSWrap>(env, sc, kind), SSLWrap<TLSWrap>(env, sc, kind),
StreamBase(env), StreamBase(env),
@ -289,7 +290,8 @@ void TLSWrap::EncOut() {
CHECK(write_size_ != 0 && count != 0); CHECK(write_size_ != 0 && count != 0);
Local<Object> req_wrap_obj = 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(), WriteWrap* write_req = WriteWrap::New(env(),
req_wrap_obj, req_wrap_obj,
this, this,

3
src/udp_wrap.cc

@ -422,7 +422,8 @@ Local<Object> UDPWrap::Instantiate(Environment* env, AsyncWrap* parent) {
CHECK_EQ(env->udp_constructor_function().IsEmpty(), false); CHECK_EQ(env->udp_constructor_function().IsEmpty(), false);
EscapableHandleScope scope(env->isolate()); EscapableHandleScope scope(env->isolate());
Local<Value> ptr = External::New(env->isolate(), parent); 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());
} }

Loading…
Cancel
Save