mirror of https://github.com/nodejs/node.git
StreamWrap::WriteBuffer: remove superfluous arguments
parent
0e57aafbb1
commit
726ebad9bc
|
@ -249,23 +249,12 @@ Handle<Value> StreamWrap::WriteBuffer(const Arguments& args) {
|
||||||
|
|
||||||
UNWRAP
|
UNWRAP
|
||||||
|
|
||||||
bool ipc_pipe = wrap->stream_->type == UV_NAMED_PIPE &&
|
|
||||||
((uv_pipe_t*)wrap->stream_)->ipc;
|
|
||||||
|
|
||||||
// The first argument is a buffer.
|
// The first argument is a buffer.
|
||||||
assert(Buffer::HasInstance(args[0]));
|
assert(args.Length() >= 1 && Buffer::HasInstance(args[0]));
|
||||||
Local<Object> buffer_obj = args[0]->ToObject();
|
Local<Object> buffer_obj = args[0]->ToObject();
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
size_t length = Buffer::Length(buffer_obj);
|
size_t length = Buffer::Length(buffer_obj);
|
||||||
|
|
||||||
if (args.Length() > 1) {
|
|
||||||
offset = args[1]->IntegerValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.Length() > 2) {
|
|
||||||
length = args[2]->IntegerValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (length > INT_MAX) {
|
if (length > INT_MAX) {
|
||||||
uv_err_t err;
|
uv_err_t err;
|
||||||
err.code = UV_ENOBUFS;
|
err.code = UV_ENOBUFS;
|
||||||
|
@ -282,28 +271,11 @@ Handle<Value> StreamWrap::WriteBuffer(const Arguments& args) {
|
||||||
buf.base = Buffer::Data(buffer_obj) + offset;
|
buf.base = Buffer::Data(buffer_obj) + offset;
|
||||||
buf.len = length;
|
buf.len = length;
|
||||||
|
|
||||||
int r;
|
int r = uv_write(&req_wrap->req_,
|
||||||
|
wrap->stream_,
|
||||||
if (!ipc_pipe) {
|
&buf,
|
||||||
r = uv_write(&req_wrap->req_, wrap->stream_, &buf, 1, StreamWrap::AfterWrite);
|
1,
|
||||||
} else {
|
StreamWrap::AfterWrite);
|
||||||
uv_stream_t* send_stream = NULL;
|
|
||||||
|
|
||||||
if (args[3]->IsObject()) {
|
|
||||||
Local<Object> send_stream_obj = args[3]->ToObject();
|
|
||||||
assert(send_stream_obj->InternalFieldCount() > 0);
|
|
||||||
StreamWrap* send_stream_wrap = static_cast<StreamWrap*>(
|
|
||||||
send_stream_obj->GetPointerFromInternalField(0));
|
|
||||||
send_stream = send_stream_wrap->GetStream();
|
|
||||||
}
|
|
||||||
|
|
||||||
r = uv_write2(&req_wrap->req_,
|
|
||||||
wrap->stream_,
|
|
||||||
&buf,
|
|
||||||
1,
|
|
||||||
send_stream,
|
|
||||||
StreamWrap::AfterWrite);
|
|
||||||
}
|
|
||||||
|
|
||||||
req_wrap->Dispatched();
|
req_wrap->Dispatched();
|
||||||
req_wrap->object_->Set(bytes_sym, Number::New((uint32_t) length));
|
req_wrap->object_->Set(bytes_sym, Number::New((uint32_t) length));
|
||||||
|
|
Loading…
Reference in New Issue