|
|
@ -376,6 +376,27 @@ Handle<Value> Buffer::Base64Slice(const Arguments &args) { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// buffer.fill(value, start, end);
|
|
|
|
Handle<Value> Buffer::Fill(const Arguments &args) { |
|
|
|
HandleScope scope; |
|
|
|
|
|
|
|
if (!args[0]->IsInt32()) { |
|
|
|
return ThrowException(Exception::Error(String::New( |
|
|
|
"value is not a number"))); |
|
|
|
} |
|
|
|
int value = (char)args[0]->Int32Value(); |
|
|
|
|
|
|
|
Buffer *parent = ObjectWrap::Unwrap<Buffer>(args.This()); |
|
|
|
SLICE_ARGS(args[1], args[2]) |
|
|
|
|
|
|
|
memset( (void*)(parent->data_ + start), |
|
|
|
value, |
|
|
|
end - start); |
|
|
|
|
|
|
|
return Undefined(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// var bytesCopied = buffer.copy(target, targetStart, sourceStart, sourceEnd);
|
|
|
|
Handle<Value> Buffer::Copy(const Arguments &args) { |
|
|
|
HandleScope scope; |
|
|
@ -734,6 +755,7 @@ void Buffer::Initialize(Handle<Object> target) { |
|
|
|
NODE_SET_PROTOTYPE_METHOD(constructor_template, "binaryWrite", Buffer::BinaryWrite); |
|
|
|
NODE_SET_PROTOTYPE_METHOD(constructor_template, "base64Write", Buffer::Base64Write); |
|
|
|
NODE_SET_PROTOTYPE_METHOD(constructor_template, "ucs2Write", Buffer::Ucs2Write); |
|
|
|
NODE_SET_PROTOTYPE_METHOD(constructor_template, "fill", Buffer::Fill); |
|
|
|
NODE_SET_PROTOTYPE_METHOD(constructor_template, "copy", Buffer::Copy); |
|
|
|
|
|
|
|
NODE_SET_METHOD(constructor_template->GetFunction(), |
|
|
|