summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTrevor Norris <trev.norris@gmail.com>2014-09-03 03:36:17 -0700
committerTrevor Norris <trev.norris@gmail.com>2014-09-03 03:36:17 -0700
commita054f8eb29561873f0ae678e579d99f690d3032d (patch)
treea57e623ddd2d8d7b50255dafa3ae78138a2866bb /src
parent81a9739108bd3959b4b1331d3a2833a18bc2b2b4 (diff)
downloadandroid-node-v8-a054f8eb29561873f0ae678e579d99f690d3032d.tar.gz
android-node-v8-a054f8eb29561873f0ae678e579d99f690d3032d.tar.bz2
android-node-v8-a054f8eb29561873f0ae678e579d99f690d3032d.zip
stream_wrap: Add support to write binary strings
node::StringBytes::Write() has appropriate support to write strings with 'binary' encoding. So expose that API through StreamWrap and allow inheriting classes to use it. Signed-off-by: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/pipe_wrap.cc3
-rw-r--r--src/stream_wrap.cc4
-rw-r--r--src/stream_wrap.h2
-rw-r--r--src/tcp_wrap.cc3
-rw-r--r--src/tty_wrap.cc3
5 files changed, 15 insertions, 0 deletions
diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc
index 03156cc8f5..05472de5d9 100644
--- a/src/pipe_wrap.cc
+++ b/src/pipe_wrap.cc
@@ -104,6 +104,9 @@ void PipeWrap::Initialize(Handle<Object> target,
StreamWrap::WriteAsciiString);
NODE_SET_PROTOTYPE_METHOD(t, "writeUtf8String", StreamWrap::WriteUtf8String);
NODE_SET_PROTOTYPE_METHOD(t, "writeUcs2String", StreamWrap::WriteUcs2String);
+ NODE_SET_PROTOTYPE_METHOD(t,
+ "writeBinaryString",
+ StreamWrap::WriteBinaryString);
NODE_SET_PROTOTYPE_METHOD(t, "bind", Bind);
NODE_SET_PROTOTYPE_METHOD(t, "listen", Listen);
diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc
index 5d6435101e..0f4da42ad0 100644
--- a/src/stream_wrap.cc
+++ b/src/stream_wrap.cc
@@ -499,6 +499,10 @@ void StreamWrap::WriteUcs2String(const FunctionCallbackInfo<Value>& args) {
WriteStringImpl<UCS2>(args);
}
+void StreamWrap::WriteBinaryString(const FunctionCallbackInfo<Value>& args) {
+ WriteStringImpl<BINARY>(args);
+}
+
void StreamWrap::SetBlocking(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope scope(env->isolate());
diff --git a/src/stream_wrap.h b/src/stream_wrap.h
index 3a7f6f8638..05b828ef8b 100644
--- a/src/stream_wrap.h
+++ b/src/stream_wrap.h
@@ -125,6 +125,8 @@ class StreamWrap : public HandleWrap {
static void WriteAsciiString(const v8::FunctionCallbackInfo<v8::Value>& args);
static void WriteUtf8String(const v8::FunctionCallbackInfo<v8::Value>& args);
static void WriteUcs2String(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void WriteBinaryString(
+ const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetBlocking(const v8::FunctionCallbackInfo<v8::Value>& args);
diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc
index 702dd4d805..09671d0095 100644
--- a/src/tcp_wrap.cc
+++ b/src/tcp_wrap.cc
@@ -111,6 +111,9 @@ void TCPWrap::Initialize(Handle<Object> target,
StreamWrap::WriteAsciiString);
NODE_SET_PROTOTYPE_METHOD(t, "writeUtf8String", StreamWrap::WriteUtf8String);
NODE_SET_PROTOTYPE_METHOD(t, "writeUcs2String", StreamWrap::WriteUcs2String);
+ NODE_SET_PROTOTYPE_METHOD(t,
+ "writeBinaryString",
+ StreamWrap::WriteBinaryString);
NODE_SET_PROTOTYPE_METHOD(t, "writev", StreamWrap::Writev);
NODE_SET_PROTOTYPE_METHOD(t, "open", Open);
diff --git a/src/tty_wrap.cc b/src/tty_wrap.cc
index dba545b5f4..34ee14dec7 100644
--- a/src/tty_wrap.cc
+++ b/src/tty_wrap.cc
@@ -78,6 +78,9 @@ void TTYWrap::Initialize(Handle<Object> target,
StreamWrap::WriteAsciiString);
NODE_SET_PROTOTYPE_METHOD(t, "writeUtf8String", StreamWrap::WriteUtf8String);
NODE_SET_PROTOTYPE_METHOD(t, "writeUcs2String", StreamWrap::WriteUcs2String);
+ NODE_SET_PROTOTYPE_METHOD(t,
+ "writeBinaryString",
+ StreamWrap::WriteBinaryString);
NODE_SET_PROTOTYPE_METHOD(t, "getWindowSize", TTYWrap::GetWindowSize);
NODE_SET_PROTOTYPE_METHOD(t, "setRawMode", SetRawMode);