Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/pipe_wrap.cc')
-rw-r--r--src/pipe_wrap.cc42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc
index b062b40f4f6..f984d3bb3f4 100644
--- a/src/pipe_wrap.cc
+++ b/src/pipe_wrap.cc
@@ -19,12 +19,12 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
-#include <node.h>
-#include <node_buffer.h>
-#include <req_wrap.h>
-#include <handle_wrap.h>
-#include <stream_wrap.h>
-#include <pipe_wrap.h>
+#include "node.h"
+#include "node_buffer.h"
+#include "req_wrap.h"
+#include "handle_wrap.h"
+#include "stream_wrap.h"
+#include "pipe_wrap.h"
#define UNWRAP \
assert(!args.Holder().IsEmpty()); \
@@ -57,6 +57,9 @@ using v8::Boolean;
Persistent<Function> pipeConstructor;
+static Persistent<String> onconnection_sym;
+static Persistent<String> oncomplete_sym;
+
// TODO share with TCPWrap?
typedef class ReqWrap<uv_connect_t> ConnectWrap;
@@ -67,6 +70,13 @@ uv_pipe_t* PipeWrap::UVHandle() {
}
+Local<Object> PipeWrap::Instantiate() {
+ HandleScope scope;
+ assert(!pipeConstructor.IsEmpty());
+ return scope.Close(pipeConstructor->NewInstance());
+}
+
+
PipeWrap* PipeWrap::Unwrap(Local<Object> obj) {
assert(!obj.IsEmpty());
assert(obj->InternalFieldCount() > 0);
@@ -90,9 +100,13 @@ void PipeWrap::Initialize(Handle<Object> target) {
NODE_SET_PROTOTYPE_METHOD(t, "readStart", StreamWrap::ReadStart);
NODE_SET_PROTOTYPE_METHOD(t, "readStop", StreamWrap::ReadStop);
- NODE_SET_PROTOTYPE_METHOD(t, "write", StreamWrap::Write);
NODE_SET_PROTOTYPE_METHOD(t, "shutdown", StreamWrap::Shutdown);
+ NODE_SET_PROTOTYPE_METHOD(t, "writeBuffer", StreamWrap::WriteBuffer);
+ NODE_SET_PROTOTYPE_METHOD(t, "writeAsciiString", StreamWrap::WriteAsciiString);
+ NODE_SET_PROTOTYPE_METHOD(t, "writeUtf8String", StreamWrap::WriteUtf8String);
+ NODE_SET_PROTOTYPE_METHOD(t, "writeUcs2String", StreamWrap::WriteUcs2String);
+
NODE_SET_PROTOTYPE_METHOD(t, "bind", Bind);
NODE_SET_PROTOTYPE_METHOD(t, "listen", Listen);
NODE_SET_PROTOTYPE_METHOD(t, "connect", Connect);
@@ -137,7 +151,7 @@ Handle<Value> PipeWrap::Bind(const Arguments& args) {
UNWRAP
- String::AsciiValue name(args[0]->ToString());
+ String::AsciiValue name(args[0]);
int r = uv_pipe_bind(&wrap->handle_, *name);
@@ -208,7 +222,10 @@ void PipeWrap::OnConnection(uv_stream_t* handle, int status) {
// Successful accept. Call the onconnection callback in JavaScript land.
Local<Value> argv[1] = { client_obj };
- MakeCallback(wrap->object_, "onconnection", 1, argv);
+ if (onconnection_sym.IsEmpty()) {
+ onconnection_sym = NODE_PSYMBOL("onconnection");
+ }
+ MakeCallback(wrap->object_, onconnection_sym, ARRAY_SIZE(argv), argv);
}
// TODO Maybe share this with TCPWrap?
@@ -240,7 +257,10 @@ void PipeWrap::AfterConnect(uv_connect_t* req, int status) {
Local<Value>::New(Boolean::New(writable))
};
- MakeCallback(req_wrap->object_, "oncomplete", 5, argv);
+ if (oncomplete_sym.IsEmpty()) {
+ oncomplete_sym = NODE_PSYMBOL("oncomplete");
+ }
+ MakeCallback(req_wrap->object_, oncomplete_sym, ARRAY_SIZE(argv), argv);
delete req_wrap;
}
@@ -264,7 +284,7 @@ Handle<Value> PipeWrap::Connect(const Arguments& args) {
UNWRAP
- String::AsciiValue name(args[0]->ToString());
+ String::AsciiValue name(args[0]);
ConnectWrap* req_wrap = new ConnectWrap();