Skip to content

Commit 81238bb

Browse files
committed
src: replace usage of deprecated SetAccessor
PR-URL: nodejs#5204 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com>
1 parent e837823 commit 81238bb

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

src/node.cc

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ using v8::Local;
117117
using v8::Locker;
118118
using v8::MaybeLocal;
119119
using v8::Message;
120+
using v8::Name;
120121
using v8::Number;
121122
using v8::Object;
122123
using v8::ObjectTemplate;
@@ -2470,15 +2471,15 @@ static void LinkedBinding(const FunctionCallbackInfo<Value>& args) {
24702471
args.GetReturnValue().Set(effective_exports);
24712472
}
24722473

2473-
static void ProcessTitleGetter(Local<String> property,
2474+
static void ProcessTitleGetter(Local<Name> property,
24742475
const PropertyCallbackInfo<Value>& info) {
24752476
char buffer[512];
24762477
uv_get_process_title(buffer, sizeof(buffer));
24772478
info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), buffer));
24782479
}
24792480

24802481

2481-
static void ProcessTitleSetter(Local<String> property,
2482+
static void ProcessTitleSetter(Local<Name> property,
24822483
Local<Value> value,
24832484
const PropertyCallbackInfo<void>& info) {
24842485
node::Utf8Value title(info.GetIsolate(), value);
@@ -2707,13 +2708,13 @@ static Local<Object> GetFeatures(Environment* env) {
27072708
}
27082709

27092710

2710-
static void DebugPortGetter(Local<String> property,
2711+
static void DebugPortGetter(Local<Name> property,
27112712
const PropertyCallbackInfo<Value>& info) {
27122713
info.GetReturnValue().Set(debug_port);
27132714
}
27142715

27152716

2716-
static void DebugPortSetter(Local<String> property,
2717+
static void DebugPortSetter(Local<Name> property,
27172718
Local<Value> value,
27182719
const PropertyCallbackInfo<void>& info) {
27192720
debug_port = value->Int32Value();
@@ -2725,7 +2726,7 @@ static void DebugPause(const FunctionCallbackInfo<Value>& args);
27252726
static void DebugEnd(const FunctionCallbackInfo<Value>& args);
27262727

27272728

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

27372738

27382739
static void NeedImmediateCallbackSetter(
2739-
Local<String> property,
2740+
Local<Name> property,
27402741
Local<Value> value,
27412742
const PropertyCallbackInfo<void>& info) {
27422743
Environment* env = Environment::GetCurrent(info);
@@ -2820,10 +2821,12 @@ void SetupProcessObject(Environment* env,
28202821

28212822
Local<Object> process = env->process_object();
28222823

2823-
process->SetAccessor(env->title_string(),
2824-
ProcessTitleGetter,
2825-
ProcessTitleSetter,
2826-
env->as_external());
2824+
auto maybe = process->SetAccessor(env->context(),
2825+
env->title_string(),
2826+
ProcessTitleGetter,
2827+
ProcessTitleSetter,
2828+
env->as_external());
2829+
CHECK(maybe.FromJust());
28272830

28282831
// process.version
28292832
READONLY_PROPERTY(process,
@@ -2986,10 +2989,12 @@ void SetupProcessObject(Environment* env,
29862989

29872990
READONLY_PROPERTY(process, "pid", Integer::New(env->isolate(), getpid()));
29882991
READONLY_PROPERTY(process, "features", GetFeatures(env));
2989-
process->SetAccessor(env->need_imm_cb_string(),
2990-
NeedImmediateCallbackGetter,
2991-
NeedImmediateCallbackSetter,
2992-
env->as_external());
2992+
maybe = process->SetAccessor(env->context(),
2993+
env->need_imm_cb_string(),
2994+
NeedImmediateCallbackGetter,
2995+
NeedImmediateCallbackSetter,
2996+
env->as_external());
2997+
CHECK(maybe.FromJust());
29932998

29942999
// -e, --eval
29953000
if (eval_string) {
@@ -3074,10 +3079,13 @@ void SetupProcessObject(Environment* env,
30743079
process->Set(env->exec_path_string(), exec_path_value);
30753080
delete[] exec_path;
30763081

3077-
process->SetAccessor(env->debug_port_string(),
3078-
DebugPortGetter,
3079-
DebugPortSetter,
3080-
env->as_external());
3082+
maybe = process->SetAccessor(env->context(),
3083+
env->debug_port_string(),
3084+
DebugPortGetter,
3085+
DebugPortSetter,
3086+
env->as_external());
3087+
CHECK(maybe.FromJust());
3088+
30813089

30823090
// define various internal methods
30833091
env->SetMethod(process,

0 commit comments

Comments
 (0)