Skip to content

Commit

Permalink
src: replace usage of deprecated ForceSet
Browse files Browse the repository at this point in the history
PR-URL: #5159
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
targos authored and Ali Sheikh committed Mar 4, 2016
1 parent f8e8075 commit 67b5a8a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
15 changes: 10 additions & 5 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2800,15 +2800,20 @@ void StopProfilerIdleNotifier(const FunctionCallbackInfo<Value>& args) {

#define READONLY_PROPERTY(obj, str, var) \
do { \
obj->ForceSet(OneByteString(env->isolate(), str), var, v8::ReadOnly); \
obj->DefineOwnProperty(env->context(), \
OneByteString(env->isolate(), str), \
var, \
v8::ReadOnly).FromJust(); \
} while (0)

#define READONLY_DONT_ENUM_PROPERTY(obj, str, var) \
do { \
obj->ForceSet(OneByteString(env->isolate(), str), \
var, \
static_cast<v8::PropertyAttribute>(v8::ReadOnly | \
v8::DontEnum)); \
obj->DefineOwnProperty(env->context(), \
OneByteString(env->isolate(), str), \
var, \
static_cast<v8::PropertyAttribute>(v8::ReadOnly | \
v8::DontEnum)) \
.FromJust(); \
} while (0)


Expand Down
6 changes: 5 additions & 1 deletion src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,17 @@ NODE_EXTERN void RunAtExit(Environment* env);
#define NODE_DEFINE_CONSTANT(target, constant) \
do { \
v8::Isolate* isolate = target->GetIsolate(); \
v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
v8::Local<v8::String> constant_name = \
v8::String::NewFromUtf8(isolate, #constant); \
v8::Local<v8::Number> constant_value = \
v8::Number::New(isolate, static_cast<double>(constant)); \
v8::PropertyAttribute constant_attributes = \
static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete); \
(target)->ForceSet(constant_name, constant_value, constant_attributes); \
(target)->DefineOwnProperty(context, \
constant_name, \
constant_value, \
constant_attributes).FromJust(); \
} \
while (0)

Expand Down
8 changes: 4 additions & 4 deletions src/node_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ struct sockaddr;
v8::String::NewFromUtf8(isolate, constant); \
v8::PropertyAttribute constant_attributes = \
static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete); \
target->ForceSet(isolate->GetCurrentContext(), \
constant_name, \
constant_value, \
constant_attributes); \
target->DefineOwnProperty(isolate->GetCurrentContext(), \
constant_name, \
constant_value, \
constant_attributes).FromJust(); \
} while (0)

namespace node {
Expand Down

0 comments on commit 67b5a8a

Please sign in to comment.