Skip to content

Commit

Permalink
src: replace usage of deprecated SetAccessor
Browse files Browse the repository at this point in the history
PR-URL: nodejs#5204
Reviewed-By: bnoordhuis - Ben Noordhuis <[email protected]>
Reviewed-By: indutny - Fedor Indutny <[email protected]>
  • Loading branch information
ofrobots authored and Ali Sheikh committed Mar 4, 2016
1 parent cddd534 commit c1649a7
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -2470,15 +2471,15 @@ static void LinkedBinding(const FunctionCallbackInfo<Value>& args) {
args.GetReturnValue().Set(effective_exports);
}

static void ProcessTitleGetter(Local<String> property,
static void ProcessTitleGetter(Local<Name> property,
const PropertyCallbackInfo<Value>& info) {
char buffer[512];
uv_get_process_title(buffer, sizeof(buffer));
info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), buffer));
}


static void ProcessTitleSetter(Local<String> property,
static void ProcessTitleSetter(Local<Name> property,
Local<Value> value,
const PropertyCallbackInfo<void>& info) {
node::Utf8Value title(info.GetIsolate(), value);
Expand Down Expand Up @@ -2707,13 +2708,13 @@ static Local<Object> GetFeatures(Environment* env) {
}


static void DebugPortGetter(Local<String> property,
static void DebugPortGetter(Local<Name> property,
const PropertyCallbackInfo<Value>& info) {
info.GetReturnValue().Set(debug_port);
}


static void DebugPortSetter(Local<String> property,
static void DebugPortSetter(Local<Name> property,
Local<Value> value,
const PropertyCallbackInfo<void>& info) {
debug_port = value->Int32Value();
Expand All @@ -2725,7 +2726,7 @@ static void DebugPause(const FunctionCallbackInfo<Value>& args);
static void DebugEnd(const FunctionCallbackInfo<Value>& args);


void NeedImmediateCallbackGetter(Local<String> property,
void NeedImmediateCallbackGetter(Local<Name> property,
const PropertyCallbackInfo<Value>& info) {
Environment* env = Environment::GetCurrent(info);
const uv_check_t* immediate_check_handle = env->immediate_check_handle();
Expand All @@ -2736,7 +2737,7 @@ void NeedImmediateCallbackGetter(Local<String> property,


static void NeedImmediateCallbackSetter(
Local<String> property,
Local<Name> property,
Local<Value> value,
const PropertyCallbackInfo<void>& info) {
Environment* env = Environment::GetCurrent(info);
Expand Down Expand Up @@ -2820,10 +2821,12 @@ void SetupProcessObject(Environment* env,

Local<Object> 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,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c1649a7

Please sign in to comment.