Skip to content

Commit

Permalink
fix when required multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
qqshfox authored and Hanfei Shen committed Jan 20, 2018
1 parent 924437f commit 3288be7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 60 deletions.
54 changes: 0 additions & 54 deletions lib/ref.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,19 +676,6 @@ exports._attach = function _attach (buf, obj) {
buf._refs.push(obj)
}

/**
* Same as `ref.writeObject()`, except that this version does not _attach_ the
* Object to the Buffer, which is potentially unsafe if the garbage collector
* runs.
*
* @param {Buffer} buffer A Buffer instance to write _object_ to.
* @param {Number} offset The offset on the Buffer to start writing at.
* @param {Object} object The Object to be written into _buffer_.
* @api private
*/

exports._writeObject = exports.writeObject

/**
* Writes a pointer to _object_ into _buffer_ at the specified _offset.
*
Expand All @@ -712,19 +699,6 @@ exports.writeObject = function writeObject (buf, offset, obj, persistent) {
exports._attach(buf, obj)
}

/**
* Same as `ref.writePointer()`, except that this version does not attach
* _pointer_ to _buffer_, which is potentially unsafe if the garbage collector
* runs.
*
* @param {Buffer} buffer A Buffer instance to write _pointer to.
* @param {Number} offset The offset on the Buffer to start writing at.
* @param {Buffer} pointer The Buffer instance whose memory address will be written to _buffer_.
* @api private
*/

exports._writePointer = exports.writePointer

/**
* Writes the memory address of _pointer_ to _buffer_ at the specified _offset_.
*
Expand All @@ -748,20 +722,6 @@ exports.writePointer = function writePointer (buf, offset, ptr) {
exports._attach(buf, ptr)
}

/**
* Same as `ref.reinterpret()`, except that this version does not attach
* _buffer_ to the returned Buffer, which is potentially unsafe if the
* garbage collector runs.
*
* @param {Buffer} buffer A Buffer instance to base the returned Buffer off of.
* @param {Number} size The `length` property of the returned Buffer.
* @param {Number} offset The offset of the Buffer to begin from.
* @return {Buffer} A new Buffer instance with the same memory address as _buffer_, and the requested _size_.
* @api private
*/

exports._reinterpret = exports.reinterpret

/**
* Returns a new Buffer instance with the specified _size_, with the same memory
* address as _buffer_.
Expand All @@ -782,20 +742,6 @@ exports.reinterpret = function reinterpret (buffer, size, offset) {
return rtn
}

/**
* Same as `ref.reinterpretUntilZeros()`, except that this version does not
* attach _buffer_ to the returned Buffer, which is potentially unsafe if the
* garbage collector runs.
*
* @param {Buffer} buffer A Buffer instance to base the returned Buffer off of.
* @param {Number} size The number of sequential, aligned `NULL` bytes that are required to terminate the buffer.
* @param {Number} offset The offset of the Buffer to begin from.
* @return {Buffer} A new Buffer instance with the same memory address as _buffer_, and a variable `length` that is terminated by _size_ NUL bytes.
* @api private
*/

exports._reinterpretUntilZeros = exports.reinterpretUntilZeros

/**
* Accepts a `Buffer` instance and a number of `NULL` bytes to read from the
* pointer. This function will scan past the boundary of the Buffer's `length`
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
"dependencies": {
"bindings": "1",
"debug": "2",
"nan": "2"
"nan": "2 <2.8.0"
},
"devDependencies": {
"dox": "0.4.4",
"highlight.js": "1",
"jade": "^0.35.0",
"marked": "^0.3.2",
"mocha": "*",
"mocha": "<4",
"weak": "1"
}
}
8 changes: 4 additions & 4 deletions src/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -646,15 +646,15 @@ NAN_MODULE_INIT(init) {
Nan::SetMethod(target, "hexAddress", HexAddress);
Nan::SetMethod(target, "isNull", IsNull);
Nan::SetMethod(target, "readObject", ReadObject);
Nan::SetMethod(target, "writeObject", WriteObject);
Nan::SetMethod(target, "_writeObject", WriteObject);
Nan::SetMethod(target, "readPointer", ReadPointer);
Nan::SetMethod(target, "writePointer", WritePointer);
Nan::SetMethod(target, "_writePointer", WritePointer);
Nan::SetMethod(target, "readInt64", ReadInt64);
Nan::SetMethod(target, "writeInt64", WriteInt64);
Nan::SetMethod(target, "readUInt64", ReadUInt64);
Nan::SetMethod(target, "writeUInt64", WriteUInt64);
Nan::SetMethod(target, "readCString", ReadCString);
Nan::SetMethod(target, "reinterpret", ReinterpretBuffer);
Nan::SetMethod(target, "reinterpretUntilZeros", ReinterpretBufferUntilZeros);
Nan::SetMethod(target, "_reinterpret", ReinterpretBuffer);
Nan::SetMethod(target, "_reinterpretUntilZeros", ReinterpretBufferUntilZeros);
}
NODE_MODULE(binding, init);

0 comments on commit 3288be7

Please sign in to comment.