diff options
author | Jure Triglav <juretriglav@gmail.com> | 2017-12-13 22:35:32 +0000 |
---|---|---|
committer | Anatoli Papirovski <apapirovski@mac.com> | 2017-12-17 12:45:39 -0500 |
commit | efffcc262c77a58ad3c75787497df46863d1b7a6 (patch) | |
tree | 8f8897baa2900df6750b228c1c3791ef8ac89ea2 /src/stream_base-inl.h | |
parent | b2432a7f00fc2e9bd05e97c242871999b983d4f5 (diff) | |
download | android-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/stream_base-inl.h')
-rw-r--r-- | src/stream_base-inl.h | 73 |
1 files changed, 39 insertions, 34 deletions
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()); |