From 3288be768dbc99a02b0fec4df73843695f5c6d93 Mon Sep 17 00:00:00 2001 From: Hanfei Shen Date: Sat, 20 Jan 2018 18:29:57 +0800 Subject: [PATCH] fix when required multiple times --- lib/ref.js | 54 -------------------------------------------------- package.json | 4 ++-- src/binding.cc | 8 ++++---- 3 files changed, 6 insertions(+), 60 deletions(-) diff --git a/lib/ref.js b/lib/ref.js index 495927b..c64c68f 100644 --- a/lib/ref.js +++ b/lib/ref.js @@ -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. * @@ -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_. * @@ -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_. @@ -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` diff --git a/package.json b/package.json index 45f20b4..0ef2e7c 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/src/binding.cc b/src/binding.cc index 93ea0ad..6649daf 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -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);