[Pkg-javascript-commits] [node-nan] 01/06: Imported Upstream version 2.2.1
Jérémy Lal
kapouer at moszumanska.debian.org
Thu Mar 31 12:20:23 UTC 2016
This is an automated email from the git hooks/post-receive script.
kapouer pushed a commit to branch master
in repository node-nan.
commit 4260d6dcae9d493381bc5a0c7e15d4d299816431
Author: Jérémy Lal <kapouer at melix.org>
Date: Thu Mar 31 13:48:37 2016 +0200
Imported Upstream version 2.2.1
---
CHANGELOG.md | 7 +++++-
README.md | 2 +-
examples/async_pi_estimate/addon.js | 50 ++++++++++++++++++-------------------
nan.h | 20 +++++----------
nan_callbacks_pre_12_inl.h | 2 +-
package.json | 2 +-
test/cpp/returnvalue.cpp | 8 ++++++
test/js/returnvalue-test.js | 4 ++-
8 files changed, 51 insertions(+), 44 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dc730cf..ebefd8b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,11 @@
# 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
diff --git a/README.md b/README.md
index 9a5f398..f167b78 100644
--- a/README.md
+++ b/README.md
@@ -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)*
diff --git a/examples/async_pi_estimate/addon.js b/examples/async_pi_estimate/addon.js
index cd4ba95..43b4c20 100644
--- a/examples/async_pi_estimate/addon.js
+++ b/examples/async_pi_estimate/addon.js
@@ -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();
diff --git a/nan.h b/nan.h
index 2bbdb47..1d564b5 100644
--- a/nan.h
+++ b/nan.h
@@ -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);
}
diff --git a/nan_callbacks_pre_12_inl.h b/nan_callbacks_pre_12_inl.h
index 9a486aa..3604cc5 100644
--- a/nan_callbacks_pre_12_inl.h
+++ b/nan_callbacks_pre_12_inl.h
@@ -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
diff --git a/package.json b/package.json
index 01d9bdc..37f8a89 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"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": {
diff --git a/test/cpp/returnvalue.cpp b/test/cpp/returnvalue.cpp
index afecece..cdab14b 100644
--- a/test/cpp/returnvalue.cpp
+++ b/test/cpp/returnvalue.cpp
@@ -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)
diff --git a/test/js/returnvalue-test.js b/test/js/returnvalue-test.js
index bd551e9..d3a110a 100644
--- a/test/js/returnvalue-test.js
+++ b/test/js/returnvalue-test.js
@@ -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);
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-nan.git
More information about the Pkg-javascript-commits
mailing list