summaryrefslogtreecommitdiff
path: root/src/tty_wrap.cc
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2015-02-22 21:59:07 +0300
committerFedor Indutny <fedor@indutny.com>2015-02-22 22:31:57 +0300
commitb9686233fc0be679d7ba1262b611711629ee334e (patch)
tree9dbf94288a1faeaa956867b3a30f0d257747cd52 /src/tty_wrap.cc
parent97b424365a883f3b8de18b3ec3f256307a92ad09 (diff)
downloadandroid-node-v8-b9686233fc0be679d7ba1262b611711629ee334e.tar.gz
android-node-v8-b9686233fc0be679d7ba1262b611711629ee334e.tar.bz2
android-node-v8-b9686233fc0be679d7ba1262b611711629ee334e.zip
stream_base: introduce StreamBase
StreamBase is an improved way to write C++ streams. The class itself is for separting `StreamWrap` (with the methods like `.writeAsciiString`, `.writeBuffer`, `.writev`, etc) from the `HandleWrap` class, making possible to write abstract C++ streams that are not bound to any uv socket. The following methods are important part of the abstraction (which mimics libuv's stream API): * Events: * `OnAlloc(size_t size, uv_buf_t*)` * `OnRead(ssize_t nread, const uv_buf_t*, uv_handle_type pending)` * `OnAfterWrite(WriteWrap*)` * Wrappers: * `DoShutdown(ShutdownWrap*)` * `DoTryWrite(uv_buf_t** bufs, size_t* count)` * `DoWrite(WriteWrap*, uv_buf_t*, size_t count, uv_stream_t* handle)` * `Error()` * `ClearError()` The implementation should provide all of these methods, thus providing the access to the underlying resource (be it uv handle, TLS socket, or anything else). A C++ stream may consume the input of another stream by replacing the event callbacks and proxying the writes. This kind of API is actually used now for the TLSWrap implementation, making it possible to wrap TLS stream into another TLS stream. Thus legacy API calls are no longer required in `_tls_wrap.js`. PR-URL: https://github.com/iojs/io.js/pull/840 Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Diffstat (limited to 'src/tty_wrap.cc')
-rw-r--r--src/tty_wrap.cc18
1 files changed, 1 insertions, 17 deletions
diff --git a/src/tty_wrap.cc b/src/tty_wrap.cc
index 08c50d911f..186f2f0100 100644
--- a/src/tty_wrap.cc
+++ b/src/tty_wrap.cc
@@ -36,26 +36,10 @@ void TTYWrap::Initialize(Handle<Object> target,
t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "TTY"));
t->InstanceTemplate()->SetInternalFieldCount(1);
- enum PropertyAttribute attributes =
- static_cast<PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
- t->InstanceTemplate()->SetAccessor(env->fd_string(),
- StreamWrap::GetFD,
- nullptr,
- Handle<Value>(),
- v8::DEFAULT,
- attributes);
-
env->SetProtoMethod(t, "close", HandleWrap::Close);
env->SetProtoMethod(t, "unref", HandleWrap::Unref);
- env->SetProtoMethod(t, "readStart", StreamWrap::ReadStart);
- env->SetProtoMethod(t, "readStop", StreamWrap::ReadStop);
-
- env->SetProtoMethod(t, "writeBuffer", StreamWrap::WriteBuffer);
- env->SetProtoMethod(t, "writeAsciiString", StreamWrap::WriteAsciiString);
- env->SetProtoMethod(t, "writeUtf8String", StreamWrap::WriteUtf8String);
- env->SetProtoMethod(t, "writeUcs2String", StreamWrap::WriteUcs2String);
- env->SetProtoMethod(t, "writeBinaryString", StreamWrap::WriteBinaryString);
+ StreamWrap::AddMethods(env, t);
env->SetProtoMethod(t, "getWindowSize", TTYWrap::GetWindowSize);
env->SetProtoMethod(t, "setRawMode", SetRawMode);