UNWRAP(StreamWrap)
- bool ipc_pipe = wrap->stream()->type == UV_NAMED_PIPE &&
- reinterpret_cast<uv_pipe_t*>(wrap->stream())->ipc;
int err;
- if (ipc_pipe) {
+ if (wrap->is_named_pipe_ipc()) {
err = uv_read2_start(wrap->stream(), OnAlloc, OnRead2);
} else {
err = uv_read_start(wrap->stream(), OnAlloc, OnRead);
assert(wrap->persistent().IsEmpty() == false);
if (nread > 0) {
- if (wrap->stream()->type == UV_TCP) {
+ if (wrap->is_tcp()) {
NODE_COUNT_NET_BYTES_RECV(nread);
- } else if (wrap->stream()->type == UV_NAMED_PIPE) {
+ } else if (wrap->is_named_pipe()) {
NODE_COUNT_PIPE_BYTES_RECV(nread);
}
}
buf.base = data;
buf.len = data_size;
- bool ipc_pipe = wrap->stream()->type == UV_NAMED_PIPE &&
- reinterpret_cast<uv_pipe_t*>(wrap->stream())->ipc;
-
- if (!ipc_pipe) {
+ if (!wrap->is_named_pipe_ipc()) {
err = wrap->callbacks()->DoWrite(req_wrap,
&buf,
1,
return stream_;
}
+ inline bool is_named_pipe() const {
+ return stream()->type == UV_NAMED_PIPE;
+ }
+
+ inline bool is_named_pipe_ipc() const {
+ return is_named_pipe() &&
+ reinterpret_cast<const uv_pipe_t*>(stream())->ipc != 0;
+ }
+
+ inline bool is_tcp() const {
+ return stream()->type == UV_TCP;
+ }
+
protected:
static size_t WriteBuffer(v8::Handle<v8::Value> val, uv_buf_t* buf);
// Ignore errors, this should be already handled in js
if (!r) {
- if (wrap()->stream()->type == UV_TCP) {
+ if (wrap()->is_tcp()) {
NODE_COUNT_NET_BYTES_SENT(write_size_);
- } else if (wrap()->stream()->type == UV_NAMED_PIPE) {
+ } else if (wrap()->is_named_pipe()) {
NODE_COUNT_PIPE_BYTES_SENT(write_size_);
}
}