| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7c3d6cc commit de61f97
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -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); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -113,12 +113,12 @@ void UDPWrap::Initialize(Local<Object> target, | |||
| 113 | 113 | ||
| 114 | 114 | enum PropertyAttribute attributes = | |
| 115 | 115 | static_cast<PropertyAttribute>(v8::ReadOnly | v8::DontDelete); | |
| 116 | - t->InstanceTemplate()->SetAccessor(env->fd_string(), | ||
| 117 | - UDPWrap::GetFD, | ||
| 118 | - nullptr, | ||
| 119 | - env->as_external(), | ||
| 120 | - v8::DEFAULT, | ||
| 121 | - attributes); | ||
| 116 | + t->PrototypeTemplate()->SetAccessor(env->fd_string(), | ||
| 117 | + UDPWrap::GetFD, | ||
| 118 | + nullptr, | ||
| 119 | + env->as_external(), | ||
| 120 | + v8::DEFAULT, | ||
| 121 | + attributes); | ||
| 122 | 122 | ||
| 123 | 123 | env->SetProtoMethod(t, "bind", Bind); | |
| 124 | 124 | env->SetProtoMethod(t, "send", Send); | |
@@ -169,7 +169,7 @@ void UDPWrap::New(const FunctionCallbackInfo<Value>& args) { | |||
| 169 | 169 | void UDPWrap::GetFD(Local<String>, const PropertyCallbackInfo<Value>& args) { | |
| 170 | 170 | int fd = UV_EBADF; | |
| 171 | 171 | #if !defined(_WIN32) | |
| 172 | - UDPWrap* wrap = Unwrap<UDPWrap>(args.Holder()); | ||
| 172 | + UDPWrap* wrap = Unwrap<UDPWrap>(args.This()); | ||
| 173 | 173 | if (wrap != nullptr) | |
| 174 | 174 | uv_fileno(reinterpret_cast<uv_handle_t*>(&wrap->handle_), &fd); | |
| 175 | 175 | #endif | |
| Back | FazBrowse Home | New Git URL |
0 commit comments