mirror of https://gitee.com/bigwinds/arangodb
fix Buffer array access
This commit is contained in:
parent
8f0b512794
commit
e69e49f145
|
@ -163,8 +163,25 @@ global.DEFINE_MODULE('buffer', (function () {
|
|||
|
||||
// Buffer
|
||||
function Buffer (subject, encoding, offset) {
|
||||
var handler = {
|
||||
get: function(target, name) {
|
||||
if (name === '__buffer__') { return true; }
|
||||
if (typeof name === 'string' && name.match(/^\d+$/)) {
|
||||
return target.parent[name];
|
||||
}
|
||||
return target[name];
|
||||
},
|
||||
set: function(target, name, value) {
|
||||
if (typeof name === 'string' && name.match(/^\d+$/)) {
|
||||
target.parent[name] = value;
|
||||
} else {
|
||||
target[name] = value;
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!(this instanceof Buffer)) {
|
||||
return new Buffer(subject, encoding, offset);
|
||||
var b = new Buffer(subject, encoding, offset);
|
||||
return new Proxy(b, handler);
|
||||
}
|
||||
|
||||
var type;
|
||||
|
@ -234,6 +251,7 @@ global.DEFINE_MODULE('buffer', (function () {
|
|||
}
|
||||
|
||||
|
||||
return new Proxy(this, handler);
|
||||
// SlowBuffer.makeFastBuffer(this.parent, this, this.offset, this.length)
|
||||
}
|
||||
|
||||
|
@ -246,6 +264,8 @@ global.DEFINE_MODULE('buffer', (function () {
|
|||
exports.SlowBuffer = SlowBuffer;
|
||||
exports.Buffer = Buffer;
|
||||
|
||||
Buffer.prototype.__buffer__ = true;
|
||||
|
||||
Buffer.isEncoding = function (encoding) {
|
||||
switch (encoding && encoding.toLowerCase()) {
|
||||
case 'hex':
|
||||
|
|
|
@ -761,6 +761,10 @@ bool V8Buffer::hasInstance(v8::Isolate* isolate, v8::Handle<v8::Value> val) {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (obj->Has(TRI_V8_ASCII_STRING("__buffer__"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return strcmp(*v8::String::Utf8Value(obj->GetConstructorName()), "Buffer") ==
|
||||
0;
|
||||
}
|
||||
|
@ -1701,7 +1705,7 @@ void TRI_InitV8Buffer(v8::Isolate* isolate, v8::Handle<v8::Context> context) {
|
|||
|
||||
TRI_V8_AddMethod(isolate, ft, TRI_V8_ASCII_STRING("byteLength"),
|
||||
JS_ByteLength);
|
||||
|
||||
|
||||
// create the exports
|
||||
v8::Handle<v8::Object> exports = v8::Object::New(isolate);
|
||||
|
||||
|
|
Loading…
Reference in New Issue