'use strict';
-const buffer = process.binding('buffer');
+const binding = process.binding('buffer');
const smalloc = process.binding('smalloc');
const util = require('util');
const alloc = smalloc.alloc;
const truncate = smalloc.truncate;
const sliceOnto = smalloc.sliceOnto;
const kMaxLength = smalloc.kMaxLength;
-var internal = {};
exports.Buffer = Buffer;
exports.SlowBuffer = SlowBuffer;
// add methods to Buffer prototype
-buffer.setupBufferJS(NativeBuffer, internal);
+binding.setupBufferJS(NativeBuffer);
// Static methods
if (a === b)
return 0;
- return internal.compare(a, b);
+ return binding.compare(a, b);
};
ret = str.length >>> 1;
break;
default:
- ret = internal.byteLength(str, enc);
+ ret = binding.byteLength(str, enc);
}
return ret;
};
if (this === b)
return true;
- return internal.compare(this, b) === 0;
+ return binding.compare(this, b) === 0;
};
if (this === b)
return 0;
- return internal.compare(this, b);
+ return binding.compare(this, b);
};
val = code;
}
- internal.fill(this, val, start, end);
+ binding.fill(this, val, start, end);
return this;
};
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 4, this.length);
- return internal.readFloatLE(this, offset);
+ return binding.readFloatLE(this, offset);
};
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 4, this.length);
- return internal.readFloatBE(this, offset);
+ return binding.readFloatBE(this, offset);
};
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 8, this.length);
- return internal.readDoubleLE(this, offset);
+ return binding.readDoubleLE(this, offset);
};
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 8, this.length);
- return internal.readDoubleBE(this, offset);
+ return binding.readDoubleBE(this, offset);
};
offset = offset >>> 0;
if (!noAssert)
checkFloat(this, val, offset, 4);
- internal.writeFloatLE(this, val, offset);
+ binding.writeFloatLE(this, val, offset);
return offset + 4;
};
offset = offset >>> 0;
if (!noAssert)
checkFloat(this, val, offset, 4);
- internal.writeFloatBE(this, val, offset);
+ binding.writeFloatBE(this, val, offset);
return offset + 4;
};
offset = offset >>> 0;
if (!noAssert)
checkFloat(this, val, offset, 8);
- internal.writeDoubleLE(this, val, offset);
+ binding.writeDoubleLE(this, val, offset);
return offset + 8;
};
offset = offset >>> 0;
if (!noAssert)
checkFloat(this, val, offset, 8);
- internal.writeDoubleBE(this, val, offset);
+ binding.writeDoubleBE(this, val, offset);
return offset + 8;
};
proto->ForceSet(env->offset_string(),
Uint32::New(env->isolate(), 0),
v8::ReadOnly);
-
- CHECK(args[1]->IsObject());
-
- Local<Object> internal = args[1].As<Object>();
- ASSERT(internal->IsObject());
-
- env->SetMethod(internal, "byteLength", ByteLength);
- env->SetMethod(internal, "compare", Compare);
- env->SetMethod(internal, "fill", Fill);
-
- env->SetMethod(internal, "readDoubleBE", ReadDoubleBE);
- env->SetMethod(internal, "readDoubleLE", ReadDoubleLE);
- env->SetMethod(internal, "readFloatBE", ReadFloatBE);
- env->SetMethod(internal, "readFloatLE", ReadFloatLE);
-
- env->SetMethod(internal, "writeDoubleBE", WriteDoubleBE);
- env->SetMethod(internal, "writeDoubleLE", WriteDoubleLE);
- env->SetMethod(internal, "writeFloatBE", WriteFloatBE);
- env->SetMethod(internal, "writeFloatLE", WriteFloatLE);
}
Handle<Value> unused,
Handle<Context> context) {
Environment* env = Environment::GetCurrent(context);
- target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "setupBufferJS"),
- env->NewFunctionTemplate(SetupBufferJS)->GetFunction());
+
+ env->SetMethod(target, "setupBufferJS", SetupBufferJS);
+
+ env->SetMethod(target, "byteLength", ByteLength);
+ env->SetMethod(target, "byteLength", ByteLength);
+ env->SetMethod(target, "compare", Compare);
+ env->SetMethod(target, "fill", Fill);
+
+ env->SetMethod(target, "readDoubleBE", ReadDoubleBE);
+ env->SetMethod(target, "readDoubleLE", ReadDoubleLE);
+ env->SetMethod(target, "readFloatBE", ReadFloatBE);
+ env->SetMethod(target, "readFloatLE", ReadFloatLE);
+
+ env->SetMethod(target, "writeDoubleBE", WriteDoubleBE);
+ env->SetMethod(target, "writeDoubleLE", WriteDoubleLE);
+ env->SetMethod(target, "writeFloatBE", WriteFloatBE);
+ env->SetMethod(target, "writeFloatLE", WriteFloatLE);
}