1111
1212namespace node {
1313
14- using v8::AccessorSignature ;
14+ using v8::Signature ;
1515using v8::External;
1616using v8::FunctionCallbackInfo;
1717using v8::FunctionTemplate;
@@ -34,31 +34,42 @@ void StreamBase::AddMethods(Environment* env,
3434 enum PropertyAttribute attributes =
3535 static_cast <PropertyAttribute>(
3636 v8::ReadOnly | v8::DontDelete | v8::DontEnum);
37- Local<AccessorSignature> signature =
38- AccessorSignature::New (env->isolate (), t);
39- t->PrototypeTemplate ()->SetAccessor (env->fd_string (),
40- GetFD<Base>,
41- nullptr ,
42- env->as_external (),
43- v8::DEFAULT,
44- attributes,
45- signature);
46-
47- t->PrototypeTemplate ()->SetAccessor (env->external_stream_string (),
48- GetExternal<Base>,
49- nullptr ,
50- env->as_external (),
51- v8::DEFAULT,
52- attributes,
53- signature);
54-
55- t->PrototypeTemplate ()->SetAccessor (env->bytes_read_string (),
56- GetBytesRead<Base>,
57- nullptr ,
58- env->as_external (),
59- v8::DEFAULT,
60- attributes,
61- signature);
37+
38+ Local<Signature> signature =
39+ Signature::New (env->isolate (), t);
40+
41+ Local<FunctionTemplate> get_fd_templ = FunctionTemplate::New (
42+ env->isolate (),
43+ GetFD<Base>,
44+ Local<Value>(),
45+ signature);
46+
47+ Local<FunctionTemplate> get_external_templ = FunctionTemplate::New (
48+ env->isolate (),
49+ GetExternal<Base>,
50+ Local<Value>(),
51+ signature);
52+
53+ Local<FunctionTemplate> get_bytes_read = FunctionTemplate::New (
54+ env->isolate (),
55+ GetBytesRead<Base>,
56+ Local<Value>(),
57+ signature);
58+
59+ t->PrototypeTemplate ()->SetAccessorProperty (env->fd_string (),
60+ get_fd_templ,
61+ Local<FunctionTemplate>(),
62+ attributes);
63+
64+ t->PrototypeTemplate ()->SetAccessorProperty (env->external_stream_string (),
65+ get_external_templ,
66+ Local<FunctionTemplate>(),
67+ attributes);
68+
69+ t->PrototypeTemplate ()->SetAccessorProperty (env->bytes_read_string (),
70+ get_bytes_read,
71+ Local<FunctionTemplate>(),
72+ attributes);
6273
6374 env->SetProtoMethod (t, " readStart" , JSMethod<Base, &StreamBase::ReadStart>);
6475 env->SetProtoMethod (t, " readStop" , JSMethod<Base, &StreamBase::ReadStop>);
@@ -85,8 +96,7 @@ void StreamBase::AddMethods(Environment* env,
8596
8697
8798template <class Base >
88- void StreamBase::GetFD (Local<String> key,
89- const PropertyCallbackInfo<Value>& args) {
99+ void StreamBase::GetFD (const FunctionCallbackInfo<Value>& args) {
90100 // Mimic implementation of StreamBase::GetFD() and UDPWrap::GetFD().
91101 Base* handle;
92102 ASSIGN_OR_RETURN_UNWRAP (&handle,
@@ -100,10 +110,8 @@ void StreamBase::GetFD(Local<String> key,
100110 args.GetReturnValue ().Set (wrap->GetFD ());
101111}
102112
103-
104113template <class Base >
105- void StreamBase::GetBytesRead (Local<String> key,
106- const PropertyCallbackInfo<Value>& args) {
114+ void StreamBase::GetBytesRead (const FunctionCallbackInfo<Value>& args) {
107115 // The handle instance hasn't been set. So no bytes could have been read.
108116 Base* handle;
109117 ASSIGN_OR_RETURN_UNWRAP (&handle,
@@ -115,10 +123,8 @@ void StreamBase::GetBytesRead(Local<String> key,
115123 args.GetReturnValue ().Set (static_cast <double >(wrap->bytes_read_ ));
116124}
117125
118-
119126template <class Base >
120- void StreamBase::GetExternal (Local<String> key,
121- const PropertyCallbackInfo<Value>& args) {
127+ void StreamBase::GetExternal (const FunctionCallbackInfo<Value>& args) {
122128 Base* handle;
123129 ASSIGN_OR_RETURN_UNWRAP (&handle, args.This ());
124130
0 commit comments