summaryrefslogtreecommitdiff
path: root/src/stream_wrap.h
diff options
context:
space:
mode:
authorFedor Indutny <fedor.indutny@gmail.com>2013-04-09 12:56:56 +0400
committerFedor Indutny <fedor.indutny@gmail.com>2013-04-27 21:03:40 +0400
commit60ed2c5434d893fccd3702d288c2ba2ab325805a (patch)
tree02dcb7d7ffe2725f12d591c7a26789c4f048c33f /src/stream_wrap.h
parent21ed8df696833a12d8d12dc4f19b3e99434a50b4 (diff)
downloadnode-new-60ed2c5434d893fccd3702d288c2ba2ab325805a.tar.gz
net: implement ._writev for .cork/uncork() support
Add Writev method to StreamWrap class for writing mixed array of strings and buffers. Expose this method for TCP class.
Diffstat (limited to 'src/stream_wrap.h')
-rw-r--r--src/stream_wrap.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/stream_wrap.h b/src/stream_wrap.h
index 77bd234a9d..84f6acc45f 100644
--- a/src/stream_wrap.h
+++ b/src/stream_wrap.h
@@ -29,10 +29,15 @@
namespace node {
+// Forward declaration
+class WriteWrap;
+
+
+// Important: this should have the same values as in lib/net.js
enum WriteEncoding {
- kAscii,
- kUtf8,
- kUcs2
+ kUtf8 = 0x1,
+ kAscii = 0x2,
+ kUcs2 = 0x3
};
@@ -50,12 +55,24 @@ class StreamWrap : public HandleWrap {
static v8::Handle<v8::Value> ReadStop(const v8::Arguments& args);
static v8::Handle<v8::Value> Shutdown(const v8::Arguments& args);
+ static v8::Handle<v8::Value> Writev(const v8::Arguments& args);
static v8::Handle<v8::Value> WriteBuffer(const v8::Arguments& args);
static v8::Handle<v8::Value> WriteAsciiString(const v8::Arguments& args);
static v8::Handle<v8::Value> WriteUtf8String(const v8::Arguments& args);
static v8::Handle<v8::Value> WriteUcs2String(const v8::Arguments& args);
protected:
+ static size_t WriteBuffer(WriteWrap* req,
+ v8::Handle<v8::Value> val,
+ uv_buf_t* buf);
+ template <enum WriteEncoding encoding>
+ static size_t WriteStringImpl(char* storage,
+ size_t storage_size,
+ v8::Handle<v8::Value> val,
+ uv_buf_t* buf);
+ template <enum WriteEncoding encoding>
+ static size_t GetStringSizeImpl(v8::Handle<v8::Value> val);
+
StreamWrap(v8::Handle<v8::Object> object, uv_stream_t* stream);
virtual void SetHandle(uv_handle_t* h);
void StateChange() { }