Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
src: replace usage of deprecated SetAccessor
  • Loading branch information
ofrobots committed Feb 18, 2016
commit 23589acb1c97e6199a83e46789ebe04ec3bf99ca
44 changes: 26 additions & 18 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,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 @@ -2467,15 +2468,15 @@ static void LinkedBinding(const FunctionCallbackInfo<Value>& args) {
args.GetReturnValue().Set(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 @@ -2704,13 +2705,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 @@ -2722,7 +2723,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 @@ -2733,7 +2734,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 @@ -2822,10 +2823,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 @@ -2989,10 +2992,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 @@ -3067,10 +3072,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