summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJure Triglav <juretriglav@gmail.com>2017-12-13 22:35:32 +0000
committerAnatoli Papirovski <apapirovski@mac.com>2017-12-17 12:45:39 -0500
commitefffcc262c77a58ad3c75787497df46863d1b7a6 (patch)
tree8f8897baa2900df6750b228c1c3791ef8ac89ea2 /src
parentb2432a7f00fc2e9bd05e97c242871999b983d4f5 (diff)
downloadandroid-node-v8-efffcc262c77a58ad3c75787497df46863d1b7a6.tar.gz
android-node-v8-efffcc262c77a58ad3c75787497df46863d1b7a6.tar.bz2
android-node-v8-efffcc262c77a58ad3c75787497df46863d1b7a6.zip
src: replace SetAccessor w/ SetAccessorProperty
PR-URL: https://github.com/nodejs/node/pull/17665 Fixes: https://github.com/nodejs/node/issues/17636 Refs: https://github.com/nodejs/node/pull/16482 Refs: https://github.com/nodejs/node/pull/16860 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src')
-rw-r--r--src/node_crypto.cc81
-rw-r--r--src/node_crypto.h9
-rw-r--r--src/node_perf.cc64
-rw-r--r--src/stream_base-inl.h73
-rw-r--r--src/stream_base.h9
-rw-r--r--src/udp_wrap.cc23
-rw-r--r--src/udp_wrap.h3
7 files changed, 154 insertions, 108 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index 480be4dd15..8bf9ce4e6f 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -80,7 +80,6 @@ static const int X509_NAME_FLAGS = ASN1_STRFLGS_ESC_CTRL
namespace node {
namespace crypto {
-using v8::AccessorSignature;
using v8::Array;
using v8::Boolean;
using v8::Context;
@@ -103,8 +102,8 @@ using v8::Object;
using v8::ObjectTemplate;
using v8::Persistent;
using v8::PropertyAttribute;
-using v8::PropertyCallbackInfo;
using v8::ReadOnly;
+using v8::Signature;
using v8::String;
using v8::Value;
@@ -544,14 +543,18 @@ void SecureContext::Initialize(Environment* env, Local<Object> target) {
t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kTicketKeyIVIndex"),
Integer::NewFromUnsigned(env->isolate(), kTicketKeyIVIndex));
- t->PrototypeTemplate()->SetAccessor(
+ Local<FunctionTemplate> ctx_getter_templ =
+ FunctionTemplate::New(env->isolate(),
+ CtxGetter,
+ env->as_external(),
+ Signature::New(env->isolate(), t));
+
+
+ t->PrototypeTemplate()->SetAccessorProperty(
FIXED_ONE_BYTE_STRING(env->isolate(), "_external"),
- CtxGetter,
- nullptr,
- env->as_external(),
- DEFAULT,
- static_cast<PropertyAttribute>(ReadOnly | DontDelete),
- AccessorSignature::New(env->isolate(), t));
+ ctx_getter_templ,
+ Local<FunctionTemplate>(),
+ static_cast<PropertyAttribute>(ReadOnly | DontDelete));
target->Set(secureContextString, t->GetFunction());
env->set_secure_context_constructor_template(t);
@@ -1565,8 +1568,7 @@ int SecureContext::TicketCompatibilityCallback(SSL* ssl,
#endif
-void SecureContext::CtxGetter(Local<String> property,
- const PropertyCallbackInfo<Value>& info) {
+void SecureContext::CtxGetter(const FunctionCallbackInfo<Value>& info) {
SecureContext* sc;
ASSIGN_OR_RETURN_UNWRAP(&sc, info.This());
Local<External> ext = External::New(info.GetIsolate(), sc->ctx_);
@@ -1636,14 +1638,17 @@ void SSLWrap<Base>::AddMethods(Environment* env, Local<FunctionTemplate> t) {
env->SetProtoMethod(t, "getALPNNegotiatedProtocol", GetALPNNegotiatedProto);
env->SetProtoMethod(t, "setALPNProtocols", SetALPNProtocols);
- t->PrototypeTemplate()->SetAccessor(
+ Local<FunctionTemplate> ssl_getter_templ =
+ FunctionTemplate::New(env->isolate(),
+ SSLGetter,
+ env->as_external(),
+ Signature::New(env->isolate(), t));
+
+ t->PrototypeTemplate()->SetAccessorProperty(
FIXED_ONE_BYTE_STRING(env->isolate(), "_external"),
- SSLGetter,
- nullptr,
- env->as_external(),
- DEFAULT,
- static_cast<PropertyAttribute>(ReadOnly | DontDelete),
- AccessorSignature::New(env->isolate(), t));
+ ssl_getter_templ,
+ Local<FunctionTemplate>(),
+ static_cast<PropertyAttribute>(ReadOnly | DontDelete));
}
@@ -2804,8 +2809,7 @@ void SSLWrap<Base>::CertCbDone(const FunctionCallbackInfo<Value>& args) {
template <class Base>
-void SSLWrap<Base>::SSLGetter(Local<String> property,
- const PropertyCallbackInfo<Value>& info) {
+void SSLWrap<Base>::SSLGetter(const FunctionCallbackInfo<Value>& info) {
Base* base;
ASSIGN_OR_RETURN_UNWRAP(&base, info.This());
SSL* ssl = base->ssl_;
@@ -4797,14 +4801,17 @@ void DiffieHellman::Initialize(Environment* env, Local<Object> target) {
env->SetProtoMethod(t, "setPublicKey", SetPublicKey);
env->SetProtoMethod(t, "setPrivateKey", SetPrivateKey);
- t->InstanceTemplate()->SetAccessor(
+ Local<FunctionTemplate> verify_error_getter_templ =
+ FunctionTemplate::New(env->isolate(),
+ DiffieHellman::VerifyErrorGetter,
+ env->as_external(),
+ Signature::New(env->isolate(), t));
+
+ t->InstanceTemplate()->SetAccessorProperty(
env->verify_error_string(),
- DiffieHellman::VerifyErrorGetter,
- nullptr,
- env->as_external(),
- DEFAULT,
- attributes,
- AccessorSignature::New(env->isolate(), t));
+ verify_error_getter_templ,
+ Local<FunctionTemplate>(),
+ attributes);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "DiffieHellman"),
t->GetFunction());
@@ -4819,14 +4826,17 @@ void DiffieHellman::Initialize(Environment* env, Local<Object> target) {
env->SetProtoMethod(t2, "getPublicKey", GetPublicKey);
env->SetProtoMethod(t2, "getPrivateKey", GetPrivateKey);
- t2->InstanceTemplate()->SetAccessor(
+ Local<FunctionTemplate> verify_error_getter_templ2 =
+ FunctionTemplate::New(env->isolate(),
+ DiffieHellman::VerifyErrorGetter,
+ env->as_external(),
+ Signature::New(env->isolate(), t2));
+
+ t2->InstanceTemplate()->SetAccessorProperty(
env->verify_error_string(),
- DiffieHellman::VerifyErrorGetter,
- nullptr,
- env->as_external(),
- DEFAULT,
- attributes,
- AccessorSignature::New(env->isolate(), t2));
+ verify_error_getter_templ2,
+ Local<FunctionTemplate>(),
+ attributes);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "DiffieHellmanGroup"),
t2->GetFunction());
@@ -5142,8 +5152,7 @@ void DiffieHellman::SetPrivateKey(const FunctionCallbackInfo<Value>& args) {
}
-void DiffieHellman::VerifyErrorGetter(Local<String> property,
- const PropertyCallbackInfo<Value>& args) {
+void DiffieHellman::VerifyErrorGetter(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(args.GetIsolate());
DiffieHellman* diffieHellman;
diff --git a/src/node_crypto.h b/src/node_crypto.h
index 463be5f072..b866117f84 100644
--- a/src/node_crypto.h
+++ b/src/node_crypto.h
@@ -148,8 +148,7 @@ class SecureContext : public BaseObject {
const v8::FunctionCallbackInfo<v8::Value>& args);
static void EnableTicketKeyCallback(
const v8::FunctionCallbackInfo<v8::Value>& args);
- static void CtxGetter(v8::Local<v8::String> property,
- const v8::PropertyCallbackInfo<v8::Value>& info);
+ static void CtxGetter(const v8::FunctionCallbackInfo<v8::Value>& info);
template <bool primary>
static void GetCertificate(const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -329,8 +328,7 @@ class SSLWrap {
void* arg);
static int TLSExtStatusCallback(SSL* s, void* arg);
static int SSLCertCallback(SSL* s, void* arg);
- static void SSLGetter(v8::Local<v8::String> property,
- const v8::PropertyCallbackInfo<v8::Value>& info);
+ static void SSLGetter(const v8::FunctionCallbackInfo<v8::Value>& info);
void DestroySSL();
void WaitForCertCb(CertCb cb, void* arg);
@@ -684,8 +682,7 @@ class DiffieHellman : public BaseObject {
static void SetPublicKey(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetPrivateKey(const v8::FunctionCallbackInfo<v8::Value>& args);
static void VerifyErrorGetter(
- v8::Local<v8::String> property,
- const v8::PropertyCallbackInfo<v8::Value>& args);
+ const v8::FunctionCallbackInfo<v8::Value>& args);
DiffieHellman(Environment* env, v8::Local<v8::Object> wrap)
: BaseObject(env, wrap),
diff --git a/src/node_perf.cc b/src/node_perf.cc
index 94c3a0f8e0..37256a943c 100644
--- a/src/node_perf.cc
+++ b/src/node_perf.cc
@@ -19,7 +19,7 @@ using v8::Local;
using v8::Name;
using v8::Object;
using v8::ObjectTemplate;
-using v8::PropertyCallbackInfo;
+using v8::Signature;
using v8::String;
using v8::Value;
@@ -120,8 +120,7 @@ void Measure(const FunctionCallbackInfo<Value>& args) {
args.GetReturnValue().Set(obj);
}
-void GetPerformanceEntryName(const Local<String> prop,
- const PropertyCallbackInfo<Value>& info) {
+void GetPerformanceEntryName(const FunctionCallbackInfo<Value>& info) {
Isolate* isolate = info.GetIsolate();
PerformanceEntry* entry;
ASSIGN_OR_RETURN_UNWRAP(&entry, info.Holder());
@@ -129,8 +128,7 @@ void GetPerformanceEntryName(const Local<String> prop,
String::NewFromUtf8(isolate, entry->name().c_str(), String::kNormalString));
}
-void GetPerformanceEntryType(const Local<String> prop,
- const PropertyCallbackInfo<Value>& info) {
+void GetPerformanceEntryType(const FunctionCallbackInfo<Value>& info) {
Isolate* isolate = info.GetIsolate();
PerformanceEntry* entry;
ASSIGN_OR_RETURN_UNWRAP(&entry, info.Holder());
@@ -138,15 +136,13 @@ void GetPerformanceEntryType(const Local<String> prop,
String::NewFromUtf8(isolate, entry->type().c_str(), String::kNormalString));
}
-void GetPerformanceEntryStartTime(const Local<String> prop,
- const PropertyCallbackInfo<Value>& info) {
+void GetPerformanceEntryStartTime(const FunctionCallbackInfo<Value>& info) {
PerformanceEntry* entry;
ASSIGN_OR_RETURN_UNWRAP(&entry, info.Holder());
info.GetReturnValue().Set(entry->startTime());
}
-void GetPerformanceEntryDuration(const Local<String> prop,
- const PropertyCallbackInfo<Value>& info) {
+void GetPerformanceEntryDuration(const FunctionCallbackInfo<Value>& info) {
PerformanceEntry* entry;
ASSIGN_OR_RETURN_UNWRAP(&entry, info.Holder());
info.GetReturnValue().Set(entry->duration());
@@ -336,14 +332,50 @@ void Init(Local<Object> target,
Local<FunctionTemplate> pe = env->NewFunctionTemplate(PerformanceEntry::New);
pe->InstanceTemplate()->SetInternalFieldCount(1);
pe->SetClassName(performanceEntryString);
+
+ Local<Signature> signature = Signature::New(env->isolate(), pe);
+
+ Local<FunctionTemplate> get_performance_entry_name_templ =
+ FunctionTemplate::New(env->isolate(),
+ GetPerformanceEntryName,
+ env->as_external(),
+ signature);
+
+ Local<FunctionTemplate> get_performance_entry_type_templ =
+ FunctionTemplate::New(env->isolate(),
+ GetPerformanceEntryType,
+ env->as_external(),
+ signature);
+
+ Local<FunctionTemplate> get_performance_entry_start_time_templ =
+ FunctionTemplate::New(env->isolate(),
+ GetPerformanceEntryStartTime,
+ env->as_external(),
+ signature);
+
+ Local<FunctionTemplate> get_performance_entry_duration_templ =
+ FunctionTemplate::New(env->isolate(),
+ GetPerformanceEntryDuration,
+ env->as_external(),
+ signature);
+
Local<ObjectTemplate> ot = pe->InstanceTemplate();
- ot->SetAccessor(env->name_string(), GetPerformanceEntryName);
- ot->SetAccessor(FIXED_ONE_BYTE_STRING(isolate, "entryType"),
- GetPerformanceEntryType);
- ot->SetAccessor(FIXED_ONE_BYTE_STRING(isolate, "startTime"),
- GetPerformanceEntryStartTime);
- ot->SetAccessor(FIXED_ONE_BYTE_STRING(isolate, "duration"),
- GetPerformanceEntryDuration);
+ ot->SetAccessorProperty(env->name_string(),
+ get_performance_entry_name_templ,
+ Local<FunctionTemplate>());
+
+ ot->SetAccessorProperty(FIXED_ONE_BYTE_STRING(isolate, "entryType"),
+ get_performance_entry_type_templ,
+ Local<FunctionTemplate>());
+
+ ot->SetAccessorProperty(FIXED_ONE_BYTE_STRING(isolate, "startTime"),
+ get_performance_entry_start_time_templ,
+ Local<FunctionTemplate>());
+
+ ot->SetAccessorProperty(FIXED_ONE_BYTE_STRING(isolate, "duration"),
+ get_performance_entry_duration_templ,
+ Local<FunctionTemplate>());
+
Local<Function> fn = pe->GetFunction();
target->Set(performanceEntryString, fn);
env->set_performance_entry_template(fn);
diff --git a/src/stream_base-inl.h b/src/stream_base-inl.h
index 29739011c6..cc89a11bac 100644
--- a/src/stream_base-inl.h
+++ b/src/stream_base-inl.h
@@ -11,7 +11,7 @@
namespace node {
-using v8::AccessorSignature;
+using v8::Signature;
using v8::External;
using v8::FunctionCallbackInfo;
using v8::FunctionTemplate;
@@ -34,31 +34,41 @@ void StreamBase::AddMethods(Environment* env,
enum PropertyAttribute attributes =
static_cast<PropertyAttribute>(
v8::ReadOnly | v8::DontDelete | v8::DontEnum);
- Local<AccessorSignature> signature =
- AccessorSignature::New(env->isolate(), t);
- t->PrototypeTemplate()->SetAccessor(env->fd_string(),
- GetFD<Base>,
- nullptr,
- env->as_external(),
- v8::DEFAULT,
- attributes,
- signature);
-
- t->PrototypeTemplate()->SetAccessor(env->external_stream_string(),
- GetExternal<Base>,
- nullptr,
- env->as_external(),
- v8::DEFAULT,
- attributes,
- signature);
-
- t->PrototypeTemplate()->SetAccessor(env->bytes_read_string(),
- GetBytesRead<Base>,
- nullptr,
- env->as_external(),
- v8::DEFAULT,
- attributes,
- signature);
+
+ Local<Signature> signature = Signature::New(env->isolate(), t);
+
+ Local<FunctionTemplate> get_fd_templ =
+ FunctionTemplate::New(env->isolate(),
+ GetFD<Base>,
+ env->as_external(),
+ signature);
+
+ Local<FunctionTemplate> get_external_templ =
+ FunctionTemplate::New(env->isolate(),
+ GetExternal<Base>,
+ env->as_external(),
+ signature);
+
+ Local<FunctionTemplate> get_bytes_read_templ =
+ FunctionTemplate::New(env->isolate(),
+ GetBytesRead<Base>,
+ env->as_external(),
+ signature);
+
+ t->PrototypeTemplate()->SetAccessorProperty(env->fd_string(),
+ get_fd_templ,
+ Local<FunctionTemplate>(),
+ attributes);
+
+ t->PrototypeTemplate()->SetAccessorProperty(env->external_stream_string(),
+ get_external_templ,
+ Local<FunctionTemplate>(),
+ attributes);
+
+ t->PrototypeTemplate()->SetAccessorProperty(env->bytes_read_string(),
+ get_bytes_read_templ,
+ Local<FunctionTemplate>(),
+ attributes);
env->SetProtoMethod(t, "readStart", JSMethod<Base, &StreamBase::ReadStart>);
env->SetProtoMethod(t, "readStop", JSMethod<Base, &StreamBase::ReadStop>);
@@ -85,8 +95,7 @@ void StreamBase::AddMethods(Environment* env,
template <class Base>
-void StreamBase::GetFD(Local<String> key,
- const PropertyCallbackInfo<Value>& args) {
+void StreamBase::GetFD(const FunctionCallbackInfo<Value>& args) {
// Mimic implementation of StreamBase::GetFD() and UDPWrap::GetFD().
Base* handle;
ASSIGN_OR_RETURN_UNWRAP(&handle,
@@ -100,10 +109,8 @@ void StreamBase::GetFD(Local<String> key,
args.GetReturnValue().Set(wrap->GetFD());
}
-
template <class Base>
-void StreamBase::GetBytesRead(Local<String> key,
- const PropertyCallbackInfo<Value>& args) {
+void StreamBase::GetBytesRead(const FunctionCallbackInfo<Value>& args) {
// The handle instance hasn't been set. So no bytes could have been read.
Base* handle;
ASSIGN_OR_RETURN_UNWRAP(&handle,
@@ -115,10 +122,8 @@ void StreamBase::GetBytesRead(Local<String> key,
args.GetReturnValue().Set(static_cast<double>(wrap->bytes_read_));
}
-
template <class Base>
-void StreamBase::GetExternal(Local<String> key,
- const PropertyCallbackInfo<Value>& args) {
+void StreamBase::GetExternal(const FunctionCallbackInfo<Value>& args) {
Base* handle;
ASSIGN_OR_RETURN_UNWRAP(&handle, args.This());
diff --git a/src/stream_base.h b/src/stream_base.h
index 345554fa05..d063176b04 100644
--- a/src/stream_base.h
+++ b/src/stream_base.h
@@ -265,16 +265,13 @@ class StreamBase : public StreamResource {
int WriteString(const v8::FunctionCallbackInfo<v8::Value>& args);
template <class Base>
- static void GetFD(v8::Local<v8::String> key,
- const v8::PropertyCallbackInfo<v8::Value>& args);
+ static void GetFD(const v8::FunctionCallbackInfo<v8::Value>& args);
template <class Base>
- static void GetExternal(v8::Local<v8::String> key,
- const v8::PropertyCallbackInfo<v8::Value>& args);
+ static void GetExternal(const v8::FunctionCallbackInfo<v8::Value>& args);
template <class Base>
- static void GetBytesRead(v8::Local<v8::String> key,
- const v8::PropertyCallbackInfo<v8::Value>& args);
+ static void GetBytesRead(const v8::FunctionCallbackInfo<v8::Value>& args);
template <class Base,
int (StreamBase::*Method)(
diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc
index d8665d6789..9d4e7f7ab4 100644
--- a/src/udp_wrap.cc
+++ b/src/udp_wrap.cc
@@ -41,7 +41,7 @@ using v8::Integer;
using v8::Local;
using v8::Object;
using v8::PropertyAttribute;
-using v8::PropertyCallbackInfo;
+using v8::Signature;
using v8::String;
using v8::Uint32;
using v8::Undefined;
@@ -110,12 +110,19 @@ void UDPWrap::Initialize(Local<Object> target,
enum PropertyAttribute attributes =
static_cast<PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
- t->PrototypeTemplate()->SetAccessor(env->fd_string(),
- UDPWrap::GetFD,
- nullptr,
- env->as_external(),
- v8::DEFAULT,
- attributes);
+
+ Local<Signature> signature = Signature::New(env->isolate(), t);
+
+ Local<FunctionTemplate> get_fd_templ =
+ FunctionTemplate::New(env->isolate(),
+ UDPWrap::GetFD,
+ env->as_external(),
+ signature);
+
+ t->PrototypeTemplate()->SetAccessorProperty(env->fd_string(),
+ get_fd_templ,
+ Local<FunctionTemplate>(),
+ attributes);
env->SetProtoMethod(t, "bind", Bind);
env->SetProtoMethod(t, "send", Send);
@@ -163,7 +170,7 @@ void UDPWrap::New(const FunctionCallbackInfo<Value>& args) {
}
-void UDPWrap::GetFD(Local<String>, const PropertyCallbackInfo<Value>& args) {
+void UDPWrap::GetFD(const FunctionCallbackInfo<Value>& args) {
int fd = UV_EBADF;
#if !defined(_WIN32)
UDPWrap* wrap = Unwrap<UDPWrap>(args.This());
diff --git a/src/udp_wrap.h b/src/udp_wrap.h
index 7f0cc96d34..b0f9042051 100644
--- a/src/udp_wrap.h
+++ b/src/udp_wrap.h
@@ -41,8 +41,7 @@ class UDPWrap: public HandleWrap {
static void Initialize(v8::Local<v8::Object> target,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context);
- static void GetFD(v8::Local<v8::String>,
- const v8::PropertyCallbackInfo<v8::Value>&);
+ static void GetFD(const v8::FunctionCallbackInfo<v8::Value>& args);
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Bind(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Send(const v8::FunctionCallbackInfo<v8::Value>& args);