@@ -30,26 +30,26 @@ void StreamBase::AddMethods(Environment* env,
30
30
31
31
enum PropertyAttribute attributes =
32
32
static_cast <PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
33
- t->InstanceTemplate ()->SetAccessor (env->fd_string (),
34
- GetFD<Base>,
35
- nullptr ,
36
- env->as_external (),
37
- v8::DEFAULT,
38
- attributes);
39
-
40
- t->InstanceTemplate ()->SetAccessor (env->external_stream_string (),
41
- GetExternal<Base>,
42
- nullptr ,
43
- env->as_external (),
44
- v8::DEFAULT,
45
- attributes);
46
-
47
- t->InstanceTemplate ()->SetAccessor (env->bytes_read_string (),
48
- GetBytesRead<Base>,
49
- nullptr ,
50
- env->as_external (),
51
- v8::DEFAULT,
52
- attributes);
33
+ t->PrototypeTemplate ()->SetAccessor (env->fd_string (),
34
+ GetFD<Base>,
35
+ nullptr ,
36
+ env->as_external (),
37
+ v8::DEFAULT,
38
+ attributes);
39
+
40
+ t->PrototypeTemplate ()->SetAccessor (env->external_stream_string (),
41
+ GetExternal<Base>,
42
+ nullptr ,
43
+ env->as_external (),
44
+ v8::DEFAULT,
45
+ attributes);
46
+
47
+ t->PrototypeTemplate ()->SetAccessor (env->bytes_read_string (),
48
+ GetBytesRead<Base>,
49
+ nullptr ,
50
+ env->as_external (),
51
+ v8::DEFAULT,
52
+ attributes);
53
53
54
54
env->SetProtoMethod (t, " readStart" , JSMethod<Base, &StreamBase::ReadStart>);
55
55
env->SetProtoMethod (t, " readStop" , JSMethod<Base, &StreamBase::ReadStop>);
@@ -78,11 +78,10 @@ void StreamBase::AddMethods(Environment* env,
78
78
template <class Base >
79
79
void StreamBase::GetFD (Local<String> key,
80
80
const PropertyCallbackInfo<Value>& args) {
81
- Base* handle = Unwrap<Base>(args.Holder ());
82
-
83
81
// Mimic implementation of StreamBase::GetFD() and UDPWrap::GetFD().
82
+ Base* handle;
84
83
ASSIGN_OR_RETURN_UNWRAP (&handle,
85
- args.Holder (),
84
+ args.This (),
86
85
args.GetReturnValue ().Set (UV_EINVAL));
87
86
88
87
StreamBase* wrap = static_cast <StreamBase*>(handle);
@@ -96,11 +95,10 @@ void StreamBase::GetFD(Local<String> key,
96
95
template <class Base >
97
96
void StreamBase::GetBytesRead (Local<String> key,
98
97
const PropertyCallbackInfo<Value>& args) {
99
- Base* handle = Unwrap<Base>(args.Holder ());
100
-
101
98
// The handle instance hasn't been set. So no bytes could have been read.
99
+ Base* handle;
102
100
ASSIGN_OR_RETURN_UNWRAP (&handle,
103
- args.Holder (),
101
+ args.This (),
104
102
args.GetReturnValue ().Set (0 ));
105
103
106
104
StreamBase* wrap = static_cast <StreamBase*>(handle);
@@ -112,9 +110,8 @@ void StreamBase::GetBytesRead(Local<String> key,
112
110
template <class Base >
113
111
void StreamBase::GetExternal (Local<String> key,
114
112
const PropertyCallbackInfo<Value>& args) {
115
- Base* handle = Unwrap<Base>(args.Holder ());
116
-
117
- ASSIGN_OR_RETURN_UNWRAP (&handle, args.Holder ());
113
+ Base* handle;
114
+ ASSIGN_OR_RETURN_UNWRAP (&handle, args.This ());
118
115
119
116
StreamBase* wrap = static_cast <StreamBase*>(handle);
120
117
Local<External> ext = External::New (args.GetIsolate (), wrap);
@@ -125,8 +122,7 @@ void StreamBase::GetExternal(Local<String> key,
125
122
template <class Base ,
126
123
int (StreamBase::*Method)(const FunctionCallbackInfo<Value>& args)>
127
124
void StreamBase::JSMethod(const FunctionCallbackInfo<Value>& args) {
128
- Base* handle = Unwrap<Base>(args.Holder ());
129
-
125
+ Base* handle;
130
126
ASSIGN_OR_RETURN_UNWRAP (&handle, args.Holder ());
131
127
132
128
StreamBase* wrap = static_cast <StreamBase*>(handle);
0 commit comments