From c1649a7e4e01bcae2f9efb84e121f51a79b5ebaa Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Fri, 12 Feb 2016 13:58:26 +0500 Subject: [PATCH] src: replace usage of deprecated SetAccessor PR-URL: https://github.com/nodejs/node/pull/5204 Reviewed-By: bnoordhuis - Ben Noordhuis Reviewed-By: indutny - Fedor Indutny --- src/node.cc | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/node.cc b/src/node.cc index 756d03dc96..0fe14791bf 100644 --- a/src/node.cc +++ b/src/node.cc @@ -117,6 +117,7 @@ using v8::Local; using v8::Locker; using v8::MaybeLocal; using v8::Message; +using v8::Name; using v8::Number; using v8::Object; using v8::ObjectTemplate; @@ -2470,7 +2471,7 @@ static void LinkedBinding(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(effective_exports); } -static void ProcessTitleGetter(Local property, +static void ProcessTitleGetter(Local property, const PropertyCallbackInfo& info) { char buffer[512]; uv_get_process_title(buffer, sizeof(buffer)); @@ -2478,7 +2479,7 @@ static void ProcessTitleGetter(Local property, } -static void ProcessTitleSetter(Local property, +static void ProcessTitleSetter(Local property, Local value, const PropertyCallbackInfo& info) { node::Utf8Value title(info.GetIsolate(), value); @@ -2707,13 +2708,13 @@ static Local GetFeatures(Environment* env) { } -static void DebugPortGetter(Local property, +static void DebugPortGetter(Local property, const PropertyCallbackInfo& info) { info.GetReturnValue().Set(debug_port); } -static void DebugPortSetter(Local property, +static void DebugPortSetter(Local property, Local value, const PropertyCallbackInfo& info) { debug_port = value->Int32Value(); @@ -2725,7 +2726,7 @@ static void DebugPause(const FunctionCallbackInfo& args); static void DebugEnd(const FunctionCallbackInfo& args); -void NeedImmediateCallbackGetter(Local property, +void NeedImmediateCallbackGetter(Local property, const PropertyCallbackInfo& info) { Environment* env = Environment::GetCurrent(info); const uv_check_t* immediate_check_handle = env->immediate_check_handle(); @@ -2736,7 +2737,7 @@ void NeedImmediateCallbackGetter(Local property, static void NeedImmediateCallbackSetter( - Local property, + Local property, Local value, const PropertyCallbackInfo& info) { Environment* env = Environment::GetCurrent(info); @@ -2820,10 +2821,12 @@ void SetupProcessObject(Environment* env, Local process = env->process_object(); - process->SetAccessor(env->title_string(), - ProcessTitleGetter, - ProcessTitleSetter, - env->as_external()); + auto maybe = process->SetAccessor(env->context(), + env->title_string(), + ProcessTitleGetter, + ProcessTitleSetter, + env->as_external()); + CHECK(maybe.FromJust()); // process.version READONLY_PROPERTY(process, @@ -2986,10 +2989,12 @@ void SetupProcessObject(Environment* env, READONLY_PROPERTY(process, "pid", Integer::New(env->isolate(), getpid())); READONLY_PROPERTY(process, "features", GetFeatures(env)); - process->SetAccessor(env->need_imm_cb_string(), - NeedImmediateCallbackGetter, - NeedImmediateCallbackSetter, - env->as_external()); + maybe = process->SetAccessor(env->context(), + env->need_imm_cb_string(), + NeedImmediateCallbackGetter, + NeedImmediateCallbackSetter, + env->as_external()); + CHECK(maybe.FromJust()); // -e, --eval if (eval_string) { @@ -3074,10 +3079,13 @@ void SetupProcessObject(Environment* env, process->Set(env->exec_path_string(), exec_path_value); delete[] exec_path; - process->SetAccessor(env->debug_port_string(), - DebugPortGetter, - DebugPortSetter, - env->as_external()); + maybe = process->SetAccessor(env->context(), + env->debug_port_string(), + DebugPortGetter, + DebugPortSetter, + env->as_external()); + CHECK(maybe.FromJust()); + // define various internal methods env->SetMethod(process,