[Pkg-javascript-commits] [node-nan] 01/05: Imported Upstream version 2.3.0

Jérémy Lal kapouer at moszumanska.debian.org
Wed Apr 27 18:55:08 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 17debd72811e27c88aee52f5b9606e3465147852
Author: Jérémy Lal <kapouer at melix.org>
Date:   Wed Apr 27 17:00:58 2016 +0200

    Imported Upstream version 2.3.0
---
 CHANGELOG.md                              |  7 +++-
 Makefile                                  |  1 +
 README.md                                 | 31 ++++++++++++---
 doc/asyncworker.md                        |  1 +
 nan.h                                     | 13 ++++---
 package.json                              |  4 +-
 test/binding.gyp                          |  4 ++
 test/cpp/asyncprogressworkersignal.cpp    | 64 +++++++++++++++++++++++++++++++
 test/js/asyncprogressworkersignal-test.js | 23 +++++++++++
 9 files changed, 134 insertions(+), 14 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index ebefd8b..a5379d2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,11 @@
 # NAN ChangeLog
 
-**Version 2.2.1: current Node 5.9.1, Node 12: 0.12.12, Node 10: 0.10.43, iojs: 3.3.1**
+**Version 2.3.0: current Node 6.0.0, Node 12: 0.12.13, Node 10: 0.10.44, iojs: 3.3.1**
+
+### 2.3.0 Apr 27 2016
+
+  - Feature: added Signal() for invoking async callbacks without sending data from AsyncProgressWorker d8adba45f20e077d00561b20199133620c990b38
+  - Bugfix: Don't use deprecated v8::Template::Set() 00dacf0a4b86027415867fa7f1059acc499dcece
 
 ### 2.2.1 Mar 29 2016
 
diff --git a/Makefile b/Makefile
index 9729d4d..a4f6830 100644
--- a/Makefile
+++ b/Makefile
@@ -35,6 +35,7 @@ LINT_SOURCES = \
 	test/cpp/accessors2.cpp \
 	test/cpp/asyncworker.cpp \
 	test/cpp/asyncprogressworker.cpp \
+	test/cpp/asyncprogressworkersignal.cpp \
 	test/cpp/asyncworkererror.cpp \
 	test/cpp/buffer.cpp \
 	test/cpp/bufferworkerpersistent.cpp \
diff --git a/README.md b/README.md
index f167b78..c609299 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,9 @@
 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.**
+**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, 1, 4, 5 and 6.**
 
-***Current version: 2.2.1***
+***Current version: 2.3.0***
 
 *(See [CHANGELOG.md](https://github.com/nodejs/nan/blob/master/CHANGELOG.md) for complete ChangeLog)*
 
@@ -356,13 +356,32 @@ Modifications of the contents of the NAN repository are made on a collaborative
 
 If a change proposal cannot reach a consensus, a WG member can call for a vote amongst the members of the WG. Simple majority wins.
 
-### Developer's Certificate of Origin 1.0
+<a id="developers-certificate-of-origin"></a>
+## Developer's Certificate of Origin 1.1
 
 By making a contribution to this project, I certify that:
 
-* (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or
-* (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or
-* (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.
+* (a) The contribution was created in whole or in part by me and I
+  have the right to submit it under the open source license
+  indicated in the file; or
+
+* (b) The contribution is based upon previous work that, to the best
+  of my knowledge, is covered under an appropriate open source
+  license and I have the right under that license to submit that
+  work with modifications, whether created in whole or in part
+  by me, under the same open source license (unless I am
+  permitted to submit under a different license), as indicated
+  in the file; or
+
+* (c) The contribution was provided directly to me by some other
+  person who certified (a), (b) or (c) and I have not modified
+  it.
+
+* (d) I understand and agree that this project and the contribution
+  are public and that a record of the contribution (including all
+  personal information I submit with it, including my sign-off) is
+  maintained indefinitely and may be redistributed consistent with
+  this project or the open source license(s) involved.
 
 <a name="collaborators"></a>
 ### WG Members / Collaborators
diff --git a/doc/asyncworker.md b/doc/asyncworker.md
index 1f445b4..4b88211 100644
--- a/doc/asyncworker.md
+++ b/doc/asyncworker.md
@@ -75,6 +75,7 @@ class AsyncProgressWorker : public AsyncWorker {
 
   class ExecutionProgress {
    public:
+    void Signal() const;
     void Send(const char* data, size_t size) const;
   };
 
diff --git a/nan.h b/nan.h
index 1d564b5..2747635 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.1: current Node 5.9.1, Node 12: 0.12.12, Node 10: 0.10.43, iojs: 3.3.1
+ * Version 2.3.0: current Node 6.0.0, Node 12: 0.12.13, Node 10: 0.10.44, iojs: 3.3.1
  *
  * See https://github.com/nodejs/nan for the latest update to this file
  **********************************************************************************/
@@ -1631,6 +1631,9 @@ class Callback {
   class ExecutionProgress {
     friend class AsyncProgressWorker;
    public:
+    void Signal() const {
+        uv_async_send(that_->async);
+    }
     // You could do fancy generics with templates here.
     void Send(const char* data, size_t size) const {
         that_->SendProgress_(data, size);
@@ -1864,13 +1867,13 @@ NAN_INLINE void SetPrototypeMethod(
     v8::Local<v8::FunctionTemplate> recv
   , const char* name, FunctionCallback callback) {
   HandleScope scope;
-  v8::Local<v8::Function> fn = GetFunction(New<v8::FunctionTemplate>(
+  v8::Local<v8::FunctionTemplate> t = New<v8::FunctionTemplate>(
       callback
     , v8::Local<v8::Value>()
-    , New<v8::Signature>(recv))).ToLocalChecked();
+    , New<v8::Signature>(recv));
   v8::Local<v8::String> fn_name = New(name).ToLocalChecked();
-  recv->PrototypeTemplate()->Set(fn_name, fn);
-  fn->SetName(fn_name);
+  recv->PrototypeTemplate()->Set(fn_name, t);
+  t->SetClassName(fn_name);
 }
 
 //=== Accessors and Such =======================================================
diff --git a/package.json b/package.json
index 37f8a89..814eafa 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "nan",
-  "version": "2.2.1",
-  "description": "Native Abstractions for Node.js: C++ header for Node 0.8 -> 4 compatibility",
+  "version": "2.3.0",
+  "description": "Native Abstractions for Node.js: C++ header for Node 0.8 -> 6 compatibility",
   "main": "include_dirs.js",
   "repository": {
     "type": "git",
diff --git a/test/binding.gyp b/test/binding.gyp
index 278666a..afc2882 100644
--- a/test/binding.gyp
+++ b/test/binding.gyp
@@ -98,6 +98,10 @@
       , "sources"     : [ "cpp/asyncprogressworker.cpp" ]
     }
     , {
+        "target_name" : "asyncprogressworkersignal"
+      , "sources"     : ["cpp/asyncprogressworkersignal.cpp"]
+    }
+    , {
         "target_name" : "nancallback"
       , "sources"     : [ "cpp/nancallback.cpp" ]
     }
diff --git a/test/cpp/asyncprogressworkersignal.cpp b/test/cpp/asyncprogressworkersignal.cpp
new file mode 100644
index 0000000..b0b12fd
--- /dev/null
+++ b/test/cpp/asyncprogressworkersignal.cpp
@@ -0,0 +1,64 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2016 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+#ifndef _WIN32
+#include <unistd.h>
+#define Sleep(x) usleep((x)*1000)
+#endif
+#include <nan.h>
+
+using namespace Nan;  // NOLINT(build/namespaces)
+
+class ProgressWorker : public AsyncProgressWorker {
+ public:
+  ProgressWorker(
+      Callback *callback
+    , Callback *progress
+    , int milliseconds
+    , int iters)
+    : AsyncProgressWorker(callback), progress(progress)
+    , milliseconds(milliseconds), iters(iters) {}
+  ~ProgressWorker() {}
+
+  void Execute (const AsyncProgressWorker::ExecutionProgress& progress) {
+    for (int i = 0; i < iters; ++i) {
+      progress.Signal();
+      Sleep(milliseconds);
+    }
+  }
+
+  void HandleProgressCallback(const char *data, size_t size) {
+    HandleScope scope;
+
+    v8::Local<v8::Value> arg = New<v8::Boolean>(data == NULL && size == 0);
+    progress->Call(1, &arg);
+  }
+
+ private:
+  Callback *progress;
+  int milliseconds;
+  int iters;
+};
+
+NAN_METHOD(DoProgress) {
+  Callback *progress = new Callback(info[2].As<v8::Function>());
+  Callback *callback = new Callback(info[3].As<v8::Function>());
+  AsyncQueueWorker(new ProgressWorker(
+      callback
+    , progress
+    , To<uint32_t>(info[0]).FromJust()
+    , To<uint32_t>(info[1]).FromJust()));
+}
+
+NAN_MODULE_INIT(Init) {
+  Set(target
+    , New<v8::String>("a").ToLocalChecked()
+    , New<v8::FunctionTemplate>(DoProgress)->GetFunction());
+}
+
+NODE_MODULE(asyncprogressworkersignal, Init)
diff --git a/test/js/asyncprogressworkersignal-test.js b/test/js/asyncprogressworkersignal-test.js
new file mode 100644
index 0000000..493ce5b
--- /dev/null
+++ b/test/js/asyncprogressworkersignal-test.js
@@ -0,0 +1,23 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2016 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+const test     = require('tap').test
+    , testRoot = require('path').resolve(__dirname, '..')
+    , bindings = require('bindings')({ module_root: testRoot, bindings: 'asyncprogressworkersignal' });
+
+test('asyncprogressworkersignal', function (t) {
+  var worker = bindings.a
+    , progressed = 0
+  worker(100, 5, function(i) {
+    t.ok(i === true, 'data being left at NULL');
+    progressed++;
+  }, function () {
+    t.ok(progressed === 5, 'got all progress updates')
+    t.end()
+  })
+})

-- 
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