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