11
11
12
12
namespace node {
13
13
14
- using v8::AccessorSignature ;
14
+ using v8::Signature ;
15
15
using v8::External;
16
16
using v8::FunctionCallbackInfo;
17
17
using v8::FunctionTemplate;
@@ -34,31 +34,42 @@ void StreamBase::AddMethods(Environment* env,
34
34
enum PropertyAttribute attributes =
35
35
static_cast <PropertyAttribute>(
36
36
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);
62
73
63
74
env->SetProtoMethod (t, " readStart" , JSMethod<Base, &StreamBase::ReadStart>);
64
75
env->SetProtoMethod (t, " readStop" , JSMethod<Base, &StreamBase::ReadStop>);
@@ -85,8 +96,7 @@ void StreamBase::AddMethods(Environment* env,
85
96
86
97
87
98
template <class Base >
88
- void StreamBase::GetFD (Local<String> key,
89
- const PropertyCallbackInfo<Value>& args) {
99
+ void StreamBase::GetFD (const FunctionCallbackInfo<Value>& args) {
90
100
// Mimic implementation of StreamBase::GetFD() and UDPWrap::GetFD().
91
101
Base* handle;
92
102
ASSIGN_OR_RETURN_UNWRAP (&handle,
@@ -100,10 +110,8 @@ void StreamBase::GetFD(Local<String> key,
100
110
args.GetReturnValue ().Set (wrap->GetFD ());
101
111
}
102
112
103
-
104
113
template <class Base >
105
- void StreamBase::GetBytesRead (Local<String> key,
106
- const PropertyCallbackInfo<Value>& args) {
114
+ void StreamBase::GetBytesRead (const FunctionCallbackInfo<Value>& args) {
107
115
// The handle instance hasn't been set. So no bytes could have been read.
108
116
Base* handle;
109
117
ASSIGN_OR_RETURN_UNWRAP (&handle,
@@ -115,10 +123,8 @@ void StreamBase::GetBytesRead(Local<String> key,
115
123
args.GetReturnValue ().Set (static_cast <double >(wrap->bytes_read_ ));
116
124
}
117
125
118
-
119
126
template <class Base >
120
- void StreamBase::GetExternal (Local<String> key,
121
- const PropertyCallbackInfo<Value>& args) {
127
+ void StreamBase::GetExternal (const FunctionCallbackInfo<Value>& args) {
122
128
Base* handle;
123
129
ASSIGN_OR_RETURN_UNWRAP (&handle, args.This ());
124
130
0 commit comments