Showing with 36 additions and 63 deletions.
  1. +26 −48 src/node_buffer.cc
  2. +10 −15 src/smalloc.cc
@@ -570,54 +570,32 @@ Handle<Value> SetupBufferJS(const Arguments& args) {
bv->Set(String::New("byteLength"),
FunctionTemplate::New(ByteLength)->GetFunction());

proto->Set(String::New("asciiSlice"),
FunctionTemplate::New(AsciiSlice)->GetFunction());
proto->Set(String::New("base64Slice"),
FunctionTemplate::New(Base64Slice)->GetFunction());
proto->Set(String::New("binarySlice"),
FunctionTemplate::New(BinarySlice)->GetFunction());
proto->Set(String::New("hexSlice"),
FunctionTemplate::New(HexSlice)->GetFunction());
proto->Set(String::New("ucs2Slice"),
FunctionTemplate::New(Ucs2Slice)->GetFunction());
proto->Set(String::New("utf8Slice"),
FunctionTemplate::New(Utf8Slice)->GetFunction());

proto->Set(String::New("asciiWrite"),
FunctionTemplate::New(AsciiWrite)->GetFunction());
proto->Set(String::New("base64Write"),
FunctionTemplate::New(Base64Write)->GetFunction());
proto->Set(String::New("binaryWrite"),
FunctionTemplate::New(BinaryWrite)->GetFunction());
proto->Set(String::New("hexWrite"),
FunctionTemplate::New(HexWrite)->GetFunction());
proto->Set(String::New("ucs2Write"),
FunctionTemplate::New(Ucs2Write)->GetFunction());
proto->Set(String::New("utf8Write"),
FunctionTemplate::New(Utf8Write)->GetFunction());

proto->Set(String::New("readDoubleBE"),
FunctionTemplate::New(ReadDoubleBE)->GetFunction());
proto->Set(String::New("readDoubleLE"),
FunctionTemplate::New(ReadDoubleLE)->GetFunction());
proto->Set(String::New("readFloatBE"),
FunctionTemplate::New(ReadFloatBE)->GetFunction());
proto->Set(String::New("readFloatLE"),
FunctionTemplate::New(ReadFloatLE)->GetFunction());

proto->Set(String::New("writeDoubleBE"),
FunctionTemplate::New(WriteDoubleBE)->GetFunction());
proto->Set(String::New("writeDoubleLE"),
FunctionTemplate::New(WriteDoubleLE)->GetFunction());
proto->Set(String::New("writeFloatBE"),
FunctionTemplate::New(WriteFloatBE)->GetFunction());
proto->Set(String::New("writeFloatLE"),
FunctionTemplate::New(WriteFloatLE)->GetFunction());

proto->Set(String::New("copy"),
FunctionTemplate::New(Copy)->GetFunction());
proto->Set(String::New("fill"),
FunctionTemplate::New(Fill)->GetFunction());
NODE_SET_METHOD(proto, "asciiSlice", AsciiSlice);
NODE_SET_METHOD(proto, "base64Slice", Base64Slice);
NODE_SET_METHOD(proto, "binarySlice", BinarySlice);
NODE_SET_METHOD(proto, "hexSlice", HexSlice);
NODE_SET_METHOD(proto, "ucs2Slice", Ucs2Slice);
NODE_SET_METHOD(proto, "utf8Slice", Utf8Slice);

NODE_SET_METHOD(proto, "asciiWrite", AsciiWrite);
NODE_SET_METHOD(proto, "base64Write", Base64Write);
NODE_SET_METHOD(proto, "binaryWrite", BinaryWrite);
NODE_SET_METHOD(proto, "hexWrite", HexWrite);
NODE_SET_METHOD(proto, "ucs2Write", Ucs2Write);
NODE_SET_METHOD(proto, "utf8Write", Utf8Write);

NODE_SET_METHOD(proto, "readDoubleBE", ReadDoubleBE);
NODE_SET_METHOD(proto, "readDoubleLE", ReadDoubleLE);
NODE_SET_METHOD(proto, "readFloatBE", ReadFloatBE);
NODE_SET_METHOD(proto, "readFloatLE", ReadFloatLE);

NODE_SET_METHOD(proto, "writeDoubleBE", WriteDoubleBE);
NODE_SET_METHOD(proto, "writeDoubleLE", WriteDoubleLE);
NODE_SET_METHOD(proto, "writeFloatBE", WriteFloatBE);
NODE_SET_METHOD(proto, "writeFloatLE", WriteFloatLE);

NODE_SET_METHOD(proto, "copy", Copy);
NODE_SET_METHOD(proto, "fill", Fill);

// for backwards compatibility
proto->Set(String::New("offset"), Uint32::New(0, node_isolate), v8::ReadOnly);
@@ -32,7 +32,6 @@
#define ALLOC_ID (0xA10C)

namespace node {

namespace smalloc {

using v8::Arguments;
@@ -246,22 +245,23 @@ void TargetFreeCallback(Isolate* isolate,


class RetainedAllocInfo: public RetainedObjectInfo {
public:
RetainedAllocInfo(Handle<Value> wrapper);
public:
explicit RetainedAllocInfo(Handle<Value> wrapper);

virtual void Dispose();
virtual bool IsEquivalent(RetainedObjectInfo* other);
virtual intptr_t GetHash();
virtual const char* GetLabel();
virtual intptr_t GetSizeInBytes();

private:
static const char label_[];
private:
static const char* label_;
char* data_;
int length_;
};


const char RetainedAllocInfo::label_[] = "smalloc";
const char* RetainedAllocInfo::label_ = "smalloc";


RetainedAllocInfo::RetainedAllocInfo(Handle<Value> wrapper) {
@@ -303,15 +303,11 @@ RetainedObjectInfo* WrapperInfo(uint16_t class_id, Handle<Value> wrapper) {


void Initialize(Handle<Object> exports) {
exports->Set(String::New("copyOnto"),
FunctionTemplate::New(CopyOnto)->GetFunction());
exports->Set(String::New("sliceOnto"),
FunctionTemplate::New(SliceOnto)->GetFunction());
NODE_SET_METHOD(exports, "copyOnto", CopyOnto);
NODE_SET_METHOD(exports, "sliceOnto", SliceOnto);

exports->Set(String::New("alloc"),
FunctionTemplate::New(Alloc)->GetFunction());
exports->Set(String::New("dispose"),
FunctionTemplate::New(AllocDispose)->GetFunction());
NODE_SET_METHOD(exports, "alloc", Alloc);
NODE_SET_METHOD(exports, "dispose", AllocDispose);

exports->Set(String::New("kMaxLength"),
Uint32::New(kMaxLength, node_isolate));
@@ -325,7 +321,6 @@ void Initialize(Handle<Object> exports) {


} // namespace smalloc

} // namespace node

NODE_MODULE(node_smalloc, node::smalloc::Initialize)