| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,6 +27,7 @@ JSStream::JSStream(Environment* env, Local<Object> obj) | |||
| 27 | 27 | : AsyncWrap(env, obj, AsyncWrap::PROVIDER_JSSTREAM), | |
| 28 | 28 | StreamBase(env) { | |
| 29 | 29 | MakeWeak(); | |
| 30 | + StreamBase::AttachToObject(obj); | ||
| 30 | 31 | } | |
| 31 | 32 | ||
| 32 | 33 | ||
@@ -203,15 +204,16 @@ void JSStream::Initialize(Local<Object> target, | |||
| 203 | 204 | Local<String> jsStreamString = | |
| 204 | 205 | FIXED_ONE_BYTE_STRING(env->isolate(), "JSStream"); | |
| 205 | 206 | t->SetClassName(jsStreamString); | |
| 206 | - t->InstanceTemplate()->SetInternalFieldCount(1); | ||
| 207 | + t->InstanceTemplate() | ||
| 208 | + ->SetInternalFieldCount(StreamBase::kStreamBaseField + 1); | ||
| 207 | 209 | t->Inherit(AsyncWrap::GetConstructorTemplate(env)); | |
| 208 | 210 | ||
| 209 | 211 | env->SetProtoMethod(t, "finishWrite", Finish<WriteWrap>); | |
| 210 | 212 | env->SetProtoMethod(t, "finishShutdown", Finish<ShutdownWrap>); | |
| 211 | 213 | env->SetProtoMethod(t, "readBuffer", ReadBuffer); | |
| 212 | 214 | env->SetProtoMethod(t, "emitEOF", EmitEOF); | |
| 213 | 215 | ||
| 214 | - StreamBase::AddMethods<JSStream>(env, t); | ||
| 216 | + StreamBase::AddMethods(env, t); | ||
| 215 | 217 | target->Set(env->context(), | |
| 216 | 218 | jsStreamString, | |
| 217 | 219 | t->GetFunction(context).ToLocalChecked()).FromJust(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -111,6 +111,7 @@ FileHandle::FileHandle(Environment* env, Local<Object> obj, int fd) | |||
| 111 | 111 | StreamBase(env), | |
| 112 | 112 | fd_(fd) { | |
| 113 | 113 | MakeWeak(); | |
| 114 | + StreamBase::AttachToObject(GetObject()); | ||
| 114 | 115 | } | |
| 115 | 116 | ||
| 116 | 117 | FileHandle* FileHandle::New(Environment* env, int fd, Local<Object> obj) { | |
@@ -2227,11 +2228,11 @@ void Initialize(Local<Object> target, | |||
| 2227 | 2228 | env->SetProtoMethod(fd, "close", FileHandle::Close); | |
| 2228 | 2229 | env->SetProtoMethod(fd, "releaseFD", FileHandle::ReleaseFD); | |
| 2229 | 2230 | Local<ObjectTemplate> fdt = fd->InstanceTemplate(); | |
| 2230 | - fdt->SetInternalFieldCount(1); | ||
| 2231 | + fdt->SetInternalFieldCount(StreamBase::kStreamBaseField + 1); | ||
| 2231 | 2232 | Local<String> handleString = | |
| 2232 | 2233 | FIXED_ONE_BYTE_STRING(isolate, "FileHandle"); | |
| 2233 | 2234 | fd->SetClassName(handleString); | |
| 2234 | - StreamBase::AddMethods<FileHandle>(env, fd); | ||
| 2235 | + StreamBase::AddMethods(env, fd); | ||
| 2235 | 2236 | target | |
| 2236 | 2237 | ->Set(context, handleString, | |
| 2237 | 2238 | fd->GetFunction(env->context()).ToLocalChecked()) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1868,6 +1868,7 @@ Http2Stream::Http2Stream(Http2Session* session, | |||
| 1868 | 1868 | id_(id), | |
| 1869 | 1869 | current_headers_category_(category) { | |
| 1870 | 1870 | MakeWeak(); | |
| 1871 | + StreamBase::AttachToObject(GetObject()); | ||
| 1871 | 1872 | statistics_.start_time = uv_hrtime(); | |
| 1872 | 1873 | ||
| 1873 | 1874 | // Limit the number of header pairs | |
@@ -3009,9 +3010,9 @@ void Initialize(Local<Object> target, | |||
| 3009 | 3010 | env->SetProtoMethod(stream, "rstStream", Http2Stream::RstStream); | |
| 3010 | 3011 | env->SetProtoMethod(stream, "refreshState", Http2Stream::RefreshState); | |
| 3011 | 3012 | stream->Inherit(AsyncWrap::GetConstructorTemplate(env)); | |
| 3012 | - StreamBase::AddMethods<Http2Stream>(env, stream); | ||
| 3013 | + StreamBase::AddMethods(env, stream); | ||
| 3013 | 3014 | Local<ObjectTemplate> streamt = stream->InstanceTemplate(); | |
| 3014 | - streamt->SetInternalFieldCount(1); | ||
| 3015 | + streamt->SetInternalFieldCount(StreamBase::kStreamBaseField + 1); | ||
| 3015 | 3016 | env->set_http2stream_constructor_template(streamt); | |
| 3016 | 3017 | target->Set(context, | |
| 3017 | 3018 | FIXED_ONE_BYTE_STRING(env->isolate(), "Http2Stream"), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -74,7 +74,8 @@ void PipeWrap::Initialize(Local<Object> target, | |||
| 74 | 74 | Local<FunctionTemplate> t = env->NewFunctionTemplate(New); | |
| 75 | 75 | Local<String> pipeString = FIXED_ONE_BYTE_STRING(env->isolate(), "Pipe"); | |
| 76 | 76 | t->SetClassName(pipeString); | |
| 77 | - t->InstanceTemplate()->SetInternalFieldCount(1); | ||
| 77 | + t->InstanceTemplate() | ||
| 78 | + ->SetInternalFieldCount(StreamBase::kStreamBaseField + 1); | ||
| 78 | 79 | ||
| 79 | 80 | t->Inherit(LibuvStreamWrap::GetConstructorTemplate(env)); | |
| 80 | 81 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -273,144 +273,16 @@ inline WriteWrap* StreamBase::CreateWriteWrap( | |||
| 273 | 273 | return new SimpleWriteWrap<AsyncWrap>(this, object); | |
| 274 | 274 | } | |
| 275 | 275 | ||
| 276 | - template <class Base> | ||
| 277 | - void StreamBase::AddMethods(Environment* env, Local<FunctionTemplate> t) { | ||
| 278 | - HandleScope scope(env->isolate()); | ||
| 279 | - | ||
| 280 | - enum PropertyAttribute attributes = | ||
| 281 | - static_cast<PropertyAttribute>( | ||
| 282 | - v8::ReadOnly | v8::DontDelete | v8::DontEnum); | ||
| 283 | - | ||
| 284 | - Local<Signature> signature = Signature::New(env->isolate(), t); | ||
| 285 | - | ||
| 286 | - Local<FunctionTemplate> get_fd_templ = | ||
| 287 | - env->NewFunctionTemplate(GetFD<Base>, | ||
| 288 | - signature, | ||
| 289 | - v8::ConstructorBehavior::kThrow, | ||
| 290 | - v8::SideEffectType::kHasNoSideEffect); | ||
| 291 | - | ||
| 292 | - Local<FunctionTemplate> get_external_templ = | ||
| 293 | - env->NewFunctionTemplate(GetExternal<Base>, | ||
| 294 | - signature, | ||
| 295 | - v8::ConstructorBehavior::kThrow, | ||
| 296 | - v8::SideEffectType::kHasNoSideEffect); | ||
| 297 | - | ||
| 298 | - Local<FunctionTemplate> get_bytes_read_templ = | ||
| 299 | - env->NewFunctionTemplate(GetBytesRead<Base>, | ||
| 300 | - signature, | ||
| 301 | - v8::ConstructorBehavior::kThrow, | ||
| 302 | - v8::SideEffectType::kHasNoSideEffect); | ||
| 303 | - | ||
| 304 | - Local<FunctionTemplate> get_bytes_written_templ = | ||
| 305 | - env->NewFunctionTemplate(GetBytesWritten<Base>, | ||
| 306 | - signature, | ||
| 307 | - v8::ConstructorBehavior::kThrow, | ||
| 308 | - v8::SideEffectType::kHasNoSideEffect); | ||
| 309 | - | ||
| 310 | - t->PrototypeTemplate()->SetAccessorProperty(env->fd_string(), | ||
| 311 | - get_fd_templ, | ||
| 312 | - Local<FunctionTemplate>(), | ||
| 313 | - attributes); | ||
| 314 | - | ||
| 315 | - t->PrototypeTemplate()->SetAccessorProperty(env->external_stream_string(), | ||
| 316 | - get_external_templ, | ||
| 317 | - Local<FunctionTemplate>(), | ||
| 318 | - attributes); | ||
| 319 | - | ||
| 320 | - t->PrototypeTemplate()->SetAccessorProperty(env->bytes_read_string(), | ||
| 321 | - get_bytes_read_templ, | ||
| 322 | - Local<FunctionTemplate>(), | ||
| 323 | - attributes); | ||
| 324 | - | ||
| 325 | - t->PrototypeTemplate()->SetAccessorProperty(env->bytes_written_string(), | ||
| 326 | - get_bytes_written_templ, | ||
| 327 | - Local<FunctionTemplate>(), | ||
| 328 | - attributes); | ||
| 329 | - | ||
| 330 | - env->SetProtoMethod(t, "readStart", JSMethod<Base, &StreamBase::ReadStartJS>); | ||
| 331 | - env->SetProtoMethod(t, "readStop", JSMethod<Base, &StreamBase::ReadStopJS>); | ||
| 332 | - env->SetProtoMethod(t, "shutdown", JSMethod<Base, &StreamBase::Shutdown>); | ||
| 333 | - env->SetProtoMethod(t, "writev", JSMethod<Base, &StreamBase::Writev>); | ||
| 334 | - env->SetProtoMethod(t, | ||
| 335 | - "writeBuffer", | ||
| 336 | - JSMethod<Base, &StreamBase::WriteBuffer>); | ||
| 337 | - env->SetProtoMethod(t, | ||
| 338 | - "writeAsciiString", | ||
| 339 | - JSMethod<Base, &StreamBase::WriteString<ASCII> >); | ||
| 340 | - env->SetProtoMethod(t, | ||
| 341 | - "writeUtf8String", | ||
| 342 | - JSMethod<Base, &StreamBase::WriteString<UTF8> >); | ||
| 343 | - env->SetProtoMethod(t, | ||
| 344 | - "writeUcs2String", | ||
| 345 | - JSMethod<Base, &StreamBase::WriteString<UCS2> >); | ||
| 346 | - env->SetProtoMethod(t, | ||
| 347 | - "writeLatin1String", | ||
| 348 | - JSMethod<Base, &StreamBase::WriteString<LATIN1> >); | ||
| 276 | + inline void StreamBase::AttachToObject(v8::Local<v8::Object> obj) { | ||
| 277 | + obj->SetAlignedPointerInInternalField(kStreamBaseField, this); | ||
| 349 | 278 | } | |
| 350 | 279 | ||
| 280 | + inline StreamBase* StreamBase::FromObject(v8::Local<v8::Object> obj) { | ||
| 281 | + if (obj->GetAlignedPointerFromInternalField(0) == nullptr) | ||
| 282 | + return nullptr; | ||
| 351 | 283 | ||
| 352 | - template <class Base> | ||
| 353 | - void StreamBase::GetFD(const FunctionCallbackInfo<Value>& args) { | ||
| 354 | - // Mimic implementation of StreamBase::GetFD() and UDPWrap::GetFD(). | ||
| 355 | - Base* handle; | ||
| 356 | - ASSIGN_OR_RETURN_UNWRAP(&handle, | ||
| 357 | - args.This(), | ||
| 358 | - args.GetReturnValue().Set(UV_EINVAL)); | ||
| 359 | - | ||
| 360 | - StreamBase* wrap = static_cast<StreamBase*>(handle); | ||
| 361 | - if (!wrap->IsAlive()) | ||
| 362 | - return args.GetReturnValue().Set(UV_EINVAL); | ||
| 363 | - | ||
| 364 | - args.GetReturnValue().Set(wrap->GetFD()); | ||
| 365 | - } | ||
| 366 | - | ||
| 367 | - template <class Base> | ||
| 368 | - void StreamBase::GetBytesRead(const FunctionCallbackInfo<Value>& args) { | ||
| 369 | - Base* handle; | ||
| 370 | - ASSIGN_OR_RETURN_UNWRAP(&handle, | ||
| 371 | - args.This(), | ||
| 372 | - args.GetReturnValue().Set(0)); | ||
| 373 | - | ||
| 374 | - StreamBase* wrap = static_cast<StreamBase*>(handle); | ||
| 375 | - // uint64_t -> double. 53bits is enough for all real cases. | ||
| 376 | - args.GetReturnValue().Set(static_cast<double>(wrap->bytes_read_)); | ||
| 377 | - } | ||
| 378 | - | ||
| 379 | - template <class Base> | ||
| 380 | - void StreamBase::GetBytesWritten(const FunctionCallbackInfo<Value>& args) { | ||
| 381 | - Base* handle; | ||
| 382 | - ASSIGN_OR_RETURN_UNWRAP(&handle, | ||
| 383 | - args.This(), | ||
| 384 | - args.GetReturnValue().Set(0)); | ||
| 385 | - | ||
| 386 | - StreamBase* wrap = static_cast<StreamBase*>(handle); | ||
| 387 | - // uint64_t -> double. 53bits is enough for all real cases. | ||
| 388 | - args.GetReturnValue().Set(static_cast<double>(wrap->bytes_written_)); | ||
| 389 | - } | ||
| 390 | - | ||
| 391 | - template <class Base> | ||
| 392 | - void StreamBase::GetExternal(const FunctionCallbackInfo<Value>& args) { | ||
| 393 | - Base* handle; | ||
| 394 | - ASSIGN_OR_RETURN_UNWRAP(&handle, args.This()); | ||
| 395 | - | ||
| 396 | - StreamBase* wrap = static_cast<StreamBase*>(handle); | ||
| 397 | - Local<External> ext = External::New(args.GetIsolate(), wrap); | ||
| 398 | - args.GetReturnValue().Set(ext); | ||
| 399 | - } | ||
| 400 | - | ||
| 401 | - | ||
| 402 | - template <class Base, | ||
| 403 | - int (StreamBase::*Method)(const FunctionCallbackInfo<Value>& args)> | ||
| 404 | - void StreamBase::JSMethod(const FunctionCallbackInfo<Value>& args) { | ||
| 405 | - Base* handle; | ||
| 406 | - ASSIGN_OR_RETURN_UNWRAP(&handle, args.Holder()); | ||
| 407 | - | ||
| 408 | - StreamBase* wrap = static_cast<StreamBase*>(handle); | ||
| 409 | - if (!wrap->IsAlive()) | ||
| 410 | - return args.GetReturnValue().Set(UV_EINVAL); | ||
| 411 | - | ||
| 412 | - AsyncHooks::DefaultTriggerAsyncIdScope trigger_scope(handle); | ||
| 413 | - args.GetReturnValue().Set((wrap->*Method)(args)); | ||
| 284 | + return static_cast<StreamBase*>( | ||
| 285 | + obj->GetAlignedPointerFromInternalField(kStreamBaseField)); | ||
| 414 | 286 | } | |
| 415 | 287 | ||
| 416 | 288 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -327,6 +327,93 @@ Local<Object> StreamBase::GetObject() { | |||
| 327 | 327 | return GetAsyncWrap()->object(); | |
| 328 | 328 | } | |
| 329 | 329 | ||
| 330 | + void StreamBase::AddMethod(Environment* env, | ||
| 331 | + Local<Signature> signature, | ||
| 332 | + enum PropertyAttribute attributes, | ||
| 333 | + Local<FunctionTemplate> t, | ||
| 334 | + JSMethodFunction* stream_method, | ||
| 335 | + Local<String> string) { | ||
| 336 | + Local<FunctionTemplate> templ = | ||
| 337 | + env->NewFunctionTemplate(stream_method, | ||
| 338 | + signature, | ||
| 339 | + v8::ConstructorBehavior::kThrow, | ||
| 340 | + v8::SideEffectType::kHasNoSideEffect); | ||
| 341 | + t->PrototypeTemplate()->SetAccessorProperty( | ||
| 342 | + string, templ, Local<FunctionTemplate>(), attributes); | ||
| 343 | + } | ||
| 344 | + | ||
| 345 | + void StreamBase::AddMethods(Environment* env, Local<FunctionTemplate> t) { | ||
| 346 | + HandleScope scope(env->isolate()); | ||
| 347 | + | ||
| 348 | + enum PropertyAttribute attributes = static_cast<PropertyAttribute>( | ||
| 349 | + v8::ReadOnly | v8::DontDelete | v8::DontEnum); | ||
| 350 | + Local<Signature> sig = Signature::New(env->isolate(), t); | ||
| 351 | + | ||
| 352 | + AddMethod(env, sig, attributes, t, GetFD, env->fd_string()); | ||
| 353 | + AddMethod( | ||
| 354 | + env, sig, attributes, t, GetExternal, env->external_stream_string()); | ||
| 355 | + AddMethod(env, sig, attributes, t, GetBytesRead, env->bytes_read_string()); | ||
| 356 | + AddMethod( | ||
| 357 | + env, sig, attributes, t, GetBytesWritten, env->bytes_written_string()); | ||
| 358 | + env->SetProtoMethod(t, "readStart", JSMethod<&StreamBase::ReadStartJS>); | ||
| 359 | + env->SetProtoMethod(t, "readStop", JSMethod<&StreamBase::ReadStopJS>); | ||
| 360 | + env->SetProtoMethod(t, "shutdown", JSMethod<&StreamBase::Shutdown>); | ||
| 361 | + env->SetProtoMethod(t, "writev", JSMethod<&StreamBase::Writev>); | ||
| 362 | + env->SetProtoMethod(t, "writeBuffer", JSMethod<&StreamBase::WriteBuffer>); | ||
| 363 | + env->SetProtoMethod( | ||
| 364 | + t, "writeAsciiString", JSMethod<&StreamBase::WriteString<ASCII>>); | ||
| 365 | + env->SetProtoMethod( | ||
| 366 | + t, "writeUtf8String", JSMethod<&StreamBase::WriteString<UTF8>>); | ||
| 367 | + env->SetProtoMethod( | ||
| 368 | + t, "writeUcs2String", JSMethod<&StreamBase::WriteString<UCS2>>); | ||
| 369 | + env->SetProtoMethod( | ||
| 370 | + t, "writeLatin1String", JSMethod<&StreamBase::WriteString<LATIN1>>); | ||
| 371 | + } | ||
| 372 | + | ||
| 373 | + void StreamBase::GetFD(const FunctionCallbackInfo<Value>& args) { | ||
| 374 | + // Mimic implementation of StreamBase::GetFD() and UDPWrap::GetFD(). | ||
| 375 | + StreamBase* wrap = StreamBase::FromObject(args.This().As<Object>()); | ||
| 376 | + if (wrap == nullptr) return args.GetReturnValue().Set(UV_EINVAL); | ||
| 377 | + | ||
| 378 | + if (!wrap->IsAlive()) return args.GetReturnValue().Set(UV_EINVAL); | ||
| 379 | + | ||
| 380 | + args.GetReturnValue().Set(wrap->GetFD()); | ||
| 381 | + } | ||
| 382 | + | ||
| 383 | + void StreamBase::GetBytesRead(const FunctionCallbackInfo<Value>& args) { | ||
| 384 | + StreamBase* wrap = StreamBase::FromObject(args.This().As<Object>()); | ||
| 385 | + if (wrap == nullptr) return args.GetReturnValue().Set(0); | ||
| 386 | + | ||
| 387 | + // uint64_t -> double. 53bits is enough for all real cases. | ||
| 388 | + args.GetReturnValue().Set(static_cast<double>(wrap->bytes_read_)); | ||
| 389 | + } | ||
| 390 | + | ||
| 391 | + void StreamBase::GetBytesWritten(const FunctionCallbackInfo<Value>& args) { | ||
| 392 | + StreamBase* wrap = StreamBase::FromObject(args.This().As<Object>()); | ||
| 393 | + if (wrap == nullptr) return args.GetReturnValue().Set(0); | ||
| 394 | + | ||
| 395 | + // uint64_t -> double. 53bits is enough for all real cases. | ||
| 396 | + args.GetReturnValue().Set(static_cast<double>(wrap->bytes_written_)); | ||
| 397 | + } | ||
| 398 | + | ||
| 399 | + void StreamBase::GetExternal(const FunctionCallbackInfo<Value>& args) { | ||
| 400 | + StreamBase* wrap = StreamBase::FromObject(args.This().As<Object>()); | ||
| 401 | + if (wrap == nullptr) return; | ||
| 402 | + | ||
| 403 | + Local<External> ext = External::New(args.GetIsolate(), wrap); | ||
| 404 | + args.GetReturnValue().Set(ext); | ||
| 405 | + } | ||
| 406 | + | ||
| 407 | + template <int (StreamBase::*Method)(const FunctionCallbackInfo<Value>& args)> | ||
| 408 | + void StreamBase::JSMethod(const FunctionCallbackInfo<Value>& args) { | ||
| 409 | + StreamBase* wrap = StreamBase::FromObject(args.Holder().As<Object>()); | ||
| 410 | + if (wrap == nullptr) return; | ||
| 411 | + | ||
| 412 | + if (!wrap->IsAlive()) return args.GetReturnValue().Set(UV_EINVAL); | ||
| 413 | + | ||
| 414 | + AsyncHooks::DefaultTriggerAsyncIdScope trigger_scope(wrap->GetAsyncWrap()); | ||
| 415 | + args.GetReturnValue().Set((wrap->*Method)(args)); | ||
| 416 | + } | ||
| 330 | 417 | ||
| 331 | 418 | int StreamResource::DoTryWrite(uv_buf_t** bufs, size_t* count) { | |
| 332 | 419 | // No TryWrite by default | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,6 +25,7 @@ struct StreamWriteResult { | |||
| 25 | 25 | size_t bytes; | |
| 26 | 26 | }; | |
| 27 | 27 | ||
| 28 | + using JSMethodFunction = void(const v8::FunctionCallbackInfo<v8::Value>& args); | ||
| 28 | 29 | ||
| 29 | 30 | class StreamReq { | |
| 30 | 31 | public: | |
@@ -259,9 +260,9 @@ class StreamResource { | |||
| 259 | 260 | ||
| 260 | 261 | class StreamBase : public StreamResource { | |
| 261 | 262 | public: | |
| 262 | - template <class Base> | ||
| 263 | - static inline void AddMethods(Environment* env, | ||
| 264 | - v8::Local<v8::FunctionTemplate> target); | ||
| 263 | + static constexpr int kStreamBaseField = 1; | ||
| 264 | + static void AddMethods(Environment* env, | ||
| 265 | + v8::Local<v8::FunctionTemplate> target); | ||
| 265 | 266 | ||
| 266 | 267 | virtual bool IsAlive() = 0; | |
| 267 | 268 | virtual bool IsClosing() = 0; | |
@@ -305,6 +306,8 @@ class StreamBase : public StreamResource { | |||
| 305 | 306 | virtual AsyncWrap* GetAsyncWrap() = 0; | |
| 306 | 307 | virtual v8::Local<v8::Object> GetObject(); | |
| 307 | 308 | ||
| 309 | + static StreamBase* FromObject(v8::Local<v8::Object> obj); | ||
| 310 | + | ||
| 308 | 311 | protected: | |
| 309 | 312 | explicit StreamBase(Environment* env); | |
| 310 | 313 | ||
@@ -317,20 +320,13 @@ class StreamBase : public StreamResource { | |||
| 317 | 320 | template <enum encoding enc> | |
| 318 | 321 | int WriteString(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 319 | 322 | ||
| 320 | - template <class Base> | ||
| 321 | 323 | static void GetFD(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 322 | - | ||
| 323 | - template <class Base> | ||
| 324 | 324 | static void GetExternal(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 325 | - | ||
| 326 | - template <class Base> | ||
| 327 | 325 | static void GetBytesRead(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 328 | - | ||
| 329 | - template <class Base> | ||
| 330 | 326 | static void GetBytesWritten(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 327 | + void AttachToObject(v8::Local<v8::Object> obj); | ||
| 331 | 328 | ||
| 332 | - template <class Base, | ||
| 333 | - int (StreamBase::*Method)( | ||
| 329 | + template <int (StreamBase::*Method)( | ||
| 334 | 330 | const v8::FunctionCallbackInfo<v8::Value>& args)> | |
| 335 | 331 | static void JSMethod(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 336 | 332 | ||
@@ -348,6 +344,12 @@ class StreamBase : public StreamResource { | |||
| 348 | 344 | EmitToJSStreamListener default_listener_; | |
| 349 | 345 | ||
| 350 | 346 | void SetWriteResult(const StreamWriteResult& res); | |
| 347 | + static void AddMethod(Environment* env, | ||
| 348 | + v8::Local<v8::Signature> sig, | ||
| 349 | + enum v8::PropertyAttribute attributes, | ||
| 350 | + v8::Local<v8::FunctionTemplate> t, | ||
| 351 | + JSMethodFunction* stream_method, | ||
| 352 | + v8::Local<v8::String> str); | ||
| 351 | 353 | ||
| 352 | 354 | friend class WriteWrap; | |
| 353 | 355 | friend class ShutdownWrap; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments