From 67b5a8a9365869009a94dbccc1fedb30a2d8c63a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Mon, 8 Feb 2016 22:05:38 +0100 Subject: [PATCH] src: replace usage of deprecated ForceSet PR-URL: https://github.com/nodejs/node/pull/5159 Reviewed-By: Ben Noordhuis --- src/node.cc | 15 ++++++++++----- src/node.h | 6 +++++- src/node_internals.h | 8 ++++---- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/node.cc b/src/node.cc index 0fe14791bfe3cd..fdc7c1972a8d1d 100644 --- a/src/node.cc +++ b/src/node.cc @@ -2800,15 +2800,20 @@ void StopProfilerIdleNotifier(const FunctionCallbackInfo& 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::ReadOnly | \ - v8::DontEnum)); \ + obj->DefineOwnProperty(env->context(), \ + OneByteString(env->isolate(), str), \ + var, \ + static_cast(v8::ReadOnly | \ + v8::DontEnum)) \ + .FromJust(); \ } while (0) diff --git a/src/node.h b/src/node.h index fcbb45085c5439..59df8e18b4f626 100644 --- a/src/node.h +++ b/src/node.h @@ -225,13 +225,17 @@ NODE_EXTERN void RunAtExit(Environment* env); #define NODE_DEFINE_CONSTANT(target, constant) \ do { \ v8::Isolate* isolate = target->GetIsolate(); \ + v8::Local context = isolate->GetCurrentContext(); \ v8::Local constant_name = \ v8::String::NewFromUtf8(isolate, #constant); \ v8::Local constant_value = \ v8::Number::New(isolate, static_cast(constant)); \ v8::PropertyAttribute constant_attributes = \ static_cast(v8::ReadOnly | v8::DontDelete); \ - (target)->ForceSet(constant_name, constant_value, constant_attributes); \ + (target)->DefineOwnProperty(context, \ + constant_name, \ + constant_value, \ + constant_attributes).FromJust(); \ } \ while (0) diff --git a/src/node_internals.h b/src/node_internals.h index 6a918764948793..24072e0717dadd 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -22,10 +22,10 @@ struct sockaddr; v8::String::NewFromUtf8(isolate, constant); \ v8::PropertyAttribute constant_attributes = \ static_cast(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 {