Commit 4260d6dc authored by Jérémy Lal's avatar Jérémy Lal

Imported Upstream version 2.2.1

parent afe17280
# NAN ChangeLog
**Version 2.2.0: current Node 5.4.0, Node 12: 0.12.9, Node 10: 0.10.41, iojs: 3.3.1**
**Version 2.2.1: current Node 5.9.1, Node 12: 0.12.12, Node 10: 0.10.43, iojs: 3.3.1**
### 2.2.1 Mar 29 2016
- Bugfix: Use NewFromUnsigned in ReturnValue<T>::Set(uint32_t i) for pre_12 3a18f9bdce29826e0e4c217854bc476918241a58
- Performance: Remove unneeeded nullptr checks b715ef44887931c94f0d1605b3b1a4156eebece9
### 2.2.0 Jan 9 2016
......
......@@ -3,7 +3,7 @@ Native Abstractions for Node.js
**A header file filled with macro and utility goodness for making add-on development for Node.js easier across versions 0.8, 0.10, 0.12, 4 and 5.**
***Current version: 2.2.0***
***Current version: 2.2.1***
*(See [CHANGELOG.md](https://github.com/nodejs/nan/blob/master/CHANGELOG.md) for complete ChangeLog)*
......
......@@ -10,43 +10,43 @@ var addon = require('./build/Release/addon');
var calculations = process.argv[2] || 100000000;
function printResult(type, pi, ms) {
console.log(type, 'method:')
console.log('\tπ ≈ ' + pi
+ ' (' + Math.abs(pi - Math.PI) + ' away from actual)')
console.log('\tTook ' + ms + 'ms');
console.log()
console.log(type, 'method:');
console.log('\tπ ≈ ' + pi +
' (' + Math.abs(pi - Math.PI) + ' away from actual)');
console.log('\tTook ' + ms + 'ms');
console.log();
}
function runSync () {
function runSync() {
var start = Date.now();
// Estimate() will execute in the current thread,
// the next line won't return until it is finished
var result = addon.calculateSync(calculations);
printResult('Sync', result, Date.now() - start)
var result = addon.calculateSync(calculations);
printResult('Sync', result, Date.now() - start);
}
function runAsync () {
function runAsync() {
// how many batches should we split the work in to?
var batches = process.argv[3] || 16;
var ended = 0;
var total = 0;
var start = Date.now();
function done (err, result) {
total += result;
var batches = process.argv[3] || 16;
var ended = 0;
var total = 0;
var start = Date.now();
function done (err, result) {
total += result;
// have all the batches finished executing?
if (++ended == batches) {
printResult('Async', total / batches, Date.now() - start)
}
}
if (++ended === batches) {
printResult('Async', total / batches, Date.now() - start);
}
}
// for each batch of work, request an async Estimate() for
// a portion of the total number of calculations
for (var i = 0; i < batches; i++) {
addon.calculateAsync(calculations / batches, done);
}
for (var i = 0; i < batches; i++) {
addon.calculateAsync(calculations / batches, done);
}
}
runSync()
runAsync()
runSync();
runAsync();
......@@ -12,7 +12,7 @@
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
*
* Version 2.2.0: current Node 5.4.0, Node 12: 0.12.9, Node 10: 0.10.41, iojs: 3.3.1
* Version 2.2.1: current Node 5.9.1, Node 12: 0.12.12, Node 10: 0.10.43, iojs: 3.3.1
*
* See https://github.com/nodejs/nan for the latest update to this file
**********************************************************************************/
......@@ -1501,10 +1501,8 @@ class Callback {
if (!persistentHandle.IsEmpty())
persistentHandle.Reset();
if (callback)
delete callback;
if (errmsg_)
delete[] errmsg_;
delete callback;
delete[] errmsg_;
}
virtual void WorkComplete() {
......@@ -1579,9 +1577,7 @@ class Callback {
}
void SetErrorMessage(const char *msg) {
if (errmsg_) {
delete[] errmsg_;
}
delete[] errmsg_;
size_t size = strlen(msg) + 1;
errmsg_ = new char[size];
......@@ -1615,9 +1611,7 @@ class Callback {
virtual ~AsyncProgressWorker() {
uv_mutex_destroy(&async_lock);
if (asyncdata_) {
delete[] asyncdata_;
}
delete[] asyncdata_;
}
void WorkProgress() {
......@@ -1671,9 +1665,7 @@ class Callback {
asyncsize_ = size;
uv_mutex_unlock(&async_lock);
if (old_data) {
delete[] old_data;
}
delete[] old_data;
uv_async_send(async);
}
......
......@@ -65,7 +65,7 @@ class ReturnValue {
inline void Set(uint32_t i) {
TYPE_CHECK(T, v8::Integer);
value_->Dispose();
*value_ = v8::Persistent<T>::New(v8::Uint32::New(i));
*value_ = v8::Persistent<T>::New(v8::Uint32::NewFromUnsigned(i));
}
// Fast JS primitive setters
......
{
"name": "nan",
"version": "2.2.0",
"version": "2.2.1",
"description": "Native Abstractions for Node.js: C++ header for Node 0.8 -> 4 compatibility",
"main": "include_dirs.js",
"repository": {
......
......@@ -30,6 +30,10 @@ NAN_METHOD(ReturnGlobal) {
info.GetReturnValue().Set(global);
}
NAN_METHOD(ReturnUnsigned) {
info.GetReturnValue().Set(0x80000000u);
}
NAN_MODULE_INIT(Init) {
global.Reset(New(true));
......@@ -45,6 +49,10 @@ NAN_MODULE_INIT(Init) {
, New<v8::String>("q").ToLocalChecked()
, New<v8::FunctionTemplate>(ReturnGlobal)->GetFunction()
);
Set(target
, New<v8::String>("u").ToLocalChecked()
, New<v8::FunctionTemplate>(ReturnUnsigned)->GetFunction()
);
}
NODE_MODULE(returnvalue, Init)
......@@ -11,12 +11,14 @@ const test = require('tap').test
, bindings = require('bindings')({ module_root: testRoot, bindings: 'returnvalue' });
test('returnvalue', function (t) {
t.plan(7);
t.plan(9);
t.type(bindings.r, 'function');
t.type(bindings.p, 'function');
t.type(bindings.q, 'function');
t.type(bindings.u, 'function');
t.equal(bindings.r('a string value'), 'a string value');
t.equal(bindings.r(), 'default');
t.ok(bindings.p());
t.ok(bindings.q());
t.equal(bindings.u(), 0x80000000);
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment