Skip to content

Commit b2d8ef1

Browse files
committed
src: replace usage of deprecated ForceSet
PR-URL: #5159 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent e4ad3ab commit b2d8ef1

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

src/node.cc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,15 +2788,20 @@ void StopProfilerIdleNotifier(const FunctionCallbackInfo<Value>& args) {
27882788

27892789
#define READONLY_PROPERTY(obj, str, var) \
27902790
do { \
2791-
obj->ForceSet(OneByteString(env->isolate(), str), var, v8::ReadOnly); \
2791+
obj->DefineOwnProperty(env->context(), \
2792+
OneByteString(env->isolate(), str), \
2793+
var, \
2794+
v8::ReadOnly).FromJust(); \
27922795
} while (0)
27932796

27942797
#define READONLY_DONT_ENUM_PROPERTY(obj, str, var) \
27952798
do { \
2796-
obj->ForceSet(OneByteString(env->isolate(), str), \
2797-
var, \
2798-
static_cast<v8::PropertyAttribute>(v8::ReadOnly | \
2799-
v8::DontEnum)); \
2799+
obj->DefineOwnProperty(env->context(), \
2800+
OneByteString(env->isolate(), str), \
2801+
var, \
2802+
static_cast<v8::PropertyAttribute>(v8::ReadOnly | \
2803+
v8::DontEnum)) \
2804+
.FromJust(); \
28002805
} while (0)
28012806

28022807

src/node.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,17 @@ NODE_EXTERN void RunAtExit(Environment* env);
221221
#define NODE_DEFINE_CONSTANT(target, constant) \
222222
do { \
223223
v8::Isolate* isolate = target->GetIsolate(); \
224+
v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
224225
v8::Local<v8::String> constant_name = \
225226
v8::String::NewFromUtf8(isolate, #constant); \
226227
v8::Local<v8::Number> constant_value = \
227228
v8::Number::New(isolate, static_cast<double>(constant)); \
228229
v8::PropertyAttribute constant_attributes = \
229230
static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete); \
230-
(target)->ForceSet(constant_name, constant_value, constant_attributes); \
231+
(target)->DefineOwnProperty(context, \
232+
constant_name, \
233+
constant_value, \
234+
constant_attributes).FromJust(); \
231235
} \
232236
while (0)
233237

src/node_internals.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ struct sockaddr;
2222
v8::String::NewFromUtf8(isolate, constant); \
2323
v8::PropertyAttribute constant_attributes = \
2424
static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete); \
25-
target->ForceSet(isolate->GetCurrentContext(), \
26-
constant_name, \
27-
constant_value, \
28-
constant_attributes); \
25+
target->DefineOwnProperty(isolate->GetCurrentContext(), \
26+
constant_name, \
27+
constant_value, \
28+
constant_attributes).FromJust(); \
2929
} while (0)
3030

3131
namespace node {

0 commit comments

Comments
 (0)