diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-09-07 17:51:33 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-09-07 17:51:33 -0700 |
commit | 52044fd1b158b91304a4641eaf893f9fe225ea67 (patch) | |
tree | 452a1fe2b5650c400386e5be899feb0570ec7c3f /src/node_buffer.cc | |
parent | 638773628cf8568025d51fd9582ed11a5866be28 (diff) | |
parent | fdbfc9ceb7383ab3481b75b3071af67c348875b2 (diff) | |
download | android-node-v8-52044fd1b158b91304a4641eaf893f9fe225ea67.tar.gz android-node-v8-52044fd1b158b91304a4641eaf893f9fe225ea67.tar.bz2 android-node-v8-52044fd1b158b91304a4641eaf893f9fe225ea67.zip |
Merge remote branch 'origin/v0.4'
Conflicts:
lib/net.js
test/simple/test-buffer.js
Diffstat (limited to 'src/node_buffer.cc')
-rw-r--r-- | src/node_buffer.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 7865f0a637..aeede2f09e 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -577,6 +577,10 @@ Handle<Value> Buffer::AsciiWrite(const Arguments &args) { 0, max_length, String::HINT_MANY_WRITES_EXPECTED); + + constructor_template->GetFunction()->Set(chars_written_sym, + Integer::New(written)); + return scope.Close(Integer::New(written)); } @@ -664,6 +668,9 @@ Handle<Value> Buffer::Base64Write(const Arguments &args) { *dst++ = ((c & 0x03) << 6) | (d & 0x3F); } + constructor_template->GetFunction()->Set(chars_written_sym, + Integer::New(s.length())); + return scope.Close(Integer::New(dst - start)); } @@ -689,9 +696,15 @@ Handle<Value> Buffer::BinaryWrite(const Arguments &args) { char *p = (char*)buffer->data_ + offset; - size_t towrite = MIN((unsigned long) s->Length(), buffer->length_ - offset); + size_t max_length = args[2]->IsUndefined() ? buffer->length_ - offset + : args[2]->Uint32Value(); + max_length = MIN(s->Length(), MIN(buffer->length_ - offset, max_length)); + + int written = DecodeWrite(p, max_length, s, BINARY); + + constructor_template->GetFunction()->Set(chars_written_sym, + Integer::New(written)); - int written = DecodeWrite(p, towrite, s, BINARY); return scope.Close(Integer::New(written)); } |