Browse Source

src: replace usage of deprecated ForceSet

PR-URL: https://github.com/nodejs/node/pull/5159
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
process-exit-stdio-flushing
Michaël Zasso 9 years ago
committed by Ali Sheikh
parent
commit
67b5a8a936
  1. 11
      src/node.cc
  2. 6
      src/node.h
  3. 4
      src/node_internals.h

11
src/node.cc

@ -2800,15 +2800,20 @@ void StopProfilerIdleNotifier(const FunctionCallbackInfo<Value>& args) {
#define READONLY_PROPERTY(obj, str, var) \ #define READONLY_PROPERTY(obj, str, var) \
do { \ do { \
obj->ForceSet(OneByteString(env->isolate(), str), var, v8::ReadOnly); \ obj->DefineOwnProperty(env->context(), \
OneByteString(env->isolate(), str), \
var, \
v8::ReadOnly).FromJust(); \
} while (0) } while (0)
#define READONLY_DONT_ENUM_PROPERTY(obj, str, var) \ #define READONLY_DONT_ENUM_PROPERTY(obj, str, var) \
do { \ do { \
obj->ForceSet(OneByteString(env->isolate(), str), \ obj->DefineOwnProperty(env->context(), \
OneByteString(env->isolate(), str), \
var, \ var, \
static_cast<v8::PropertyAttribute>(v8::ReadOnly | \ static_cast<v8::PropertyAttribute>(v8::ReadOnly | \
v8::DontEnum)); \ v8::DontEnum)) \
.FromJust(); \
} while (0) } while (0)

6
src/node.h

@ -225,13 +225,17 @@ NODE_EXTERN void RunAtExit(Environment* env);
#define NODE_DEFINE_CONSTANT(target, constant) \ #define NODE_DEFINE_CONSTANT(target, constant) \
do { \ do { \
v8::Isolate* isolate = target->GetIsolate(); \ v8::Isolate* isolate = target->GetIsolate(); \
v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
v8::Local<v8::String> constant_name = \ v8::Local<v8::String> constant_name = \
v8::String::NewFromUtf8(isolate, #constant); \ v8::String::NewFromUtf8(isolate, #constant); \
v8::Local<v8::Number> constant_value = \ v8::Local<v8::Number> constant_value = \
v8::Number::New(isolate, static_cast<double>(constant)); \ v8::Number::New(isolate, static_cast<double>(constant)); \
v8::PropertyAttribute constant_attributes = \ v8::PropertyAttribute constant_attributes = \
static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete); \ 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) while (0)

4
src/node_internals.h

@ -22,10 +22,10 @@ struct sockaddr;
v8::String::NewFromUtf8(isolate, constant); \ v8::String::NewFromUtf8(isolate, constant); \
v8::PropertyAttribute constant_attributes = \ v8::PropertyAttribute constant_attributes = \
static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete); \ static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete); \
target->ForceSet(isolate->GetCurrentContext(), \ target->DefineOwnProperty(isolate->GetCurrentContext(), \
constant_name, \ constant_name, \
constant_value, \ constant_value, \
constant_attributes); \ constant_attributes).FromJust(); \
} while (0) } while (0)
namespace node { namespace node {

Loading…
Cancel
Save