[Pkg-javascript-commits] [node-nan] 01/04: Imported Upstream version 2.2.0
Jérémy Lal
kapouer at moszumanska.debian.org
Sun Jan 10 22:36:15 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 afe1728034c2f200aa9e11be4aaa386be3fd1b70
Author: Jérémy Lal <kapouer at melix.org>
Date: Sun Jan 10 23:32:54 2016 +0100
Imported Upstream version 2.2.0
---
.travis.yml | 1 +
CHANGELOG.md | 9 +-
LICENSE.md | 2 +-
Makefile | 2 +-
README.md | 27 +++-
appveyor.yml | 1 +
doc/.build.sh | 35 ++---
doc/maybe_types.md | 12 ++
doc/methods.md | 3 +-
doc/node_misc.md | 51 -------
doc/object_wrappers.md | 263 +++++++++++++++++++++++++++++++++
doc/v8_misc.md | 2 +-
examples/async_pi_estimate/addon.cc | 2 +-
examples/async_pi_estimate/addon.js | 2 +-
examples/async_pi_estimate/async.cc | 2 +-
examples/async_pi_estimate/async.h | 2 +-
examples/async_pi_estimate/pi_est.cc | 2 +-
examples/async_pi_estimate/pi_est.h | 2 +-
examples/async_pi_estimate/sync.cc | 2 +-
examples/async_pi_estimate/sync.h | 2 +-
nan.h | 30 ++--
nan_callbacks.h | 2 +-
nan_callbacks_12_inl.h | 2 +-
nan_callbacks_pre_12_inl.h | 2 +-
nan_converters.h | 2 +-
nan_converters_43_inl.h | 2 +-
nan_converters_pre_43_inl.h | 2 +-
nan_implementation_12_inl.h | 2 +-
nan_implementation_pre_12_inl.h | 2 +-
nan_maybe_43_inl.h | 17 ++-
nan_maybe_pre_43_inl.h | 10 +-
nan_new.h | 2 +-
nan_object_wrap.h | 2 +-
nan_persistent_12_inl.h | 2 +-
nan_persistent_pre_12_inl.h | 4 +-
nan_typedarray_contents.h | 12 +-
nan_weak.h | 2 +-
package.json | 2 +-
test/cpp/accessors.cpp | 16 +-
test/cpp/accessors2.cpp | 10 +-
test/cpp/asyncprogressworker.cpp | 2 +-
test/cpp/asyncworker.cpp | 2 +-
test/cpp/asyncworkererror.cpp | 2 +-
test/cpp/buffer.cpp | 2 +-
test/cpp/bufferworkerpersistent.cpp | 2 +-
test/cpp/converters.cpp | 2 +-
test/cpp/error.cpp | 2 +-
test/cpp/gc.cpp | 2 +-
test/cpp/indexedinterceptors.cpp | 8 +-
test/cpp/isolatedata.cpp | 2 +-
test/cpp/makecallback.cpp | 2 +-
test/cpp/morenews.cpp | 2 +-
test/cpp/multifile1.cpp | 2 +-
test/cpp/multifile2.cpp | 2 +-
test/cpp/multifile2.h | 2 +-
test/cpp/namedinterceptors.cpp | 8 +-
test/cpp/nancallback.cpp | 2 +-
test/cpp/nannew.cpp | 4 +-
test/cpp/news.cpp | 2 +-
test/cpp/objectwraphandle.cpp | 14 +-
test/cpp/persistent.cpp | 34 +++--
test/cpp/returnemptystring.cpp | 2 +-
test/cpp/returnnull.cpp | 2 +-
test/cpp/returnundefined.cpp | 2 +-
test/cpp/returnvalue.cpp | 2 +-
test/cpp/setcallhandler.cpp | 2 +-
test/cpp/settemplate.cpp | 2 +-
test/cpp/strings.cpp | 2 +-
test/cpp/symbols.cpp | 2 +-
test/cpp/threadlocal.cpp | 2 +-
test/cpp/trycatch.cpp | 2 +-
test/cpp/typedarrays.cpp | 2 +-
test/cpp/weak.cpp | 2 +-
test/cpp/weak2.cpp | 2 +-
test/cpp/wrappedobjectfactory.cpp | 25 +++-
test/js/accessors-test.js | 9 +-
test/js/accessors2-test.js | 2 +-
test/js/asyncprogressworker-test.js | 2 +-
test/js/asyncworker-test.js | 2 +-
test/js/asyncworkererror-test.js | 2 +-
test/js/buffer-test.js | 2 +-
test/js/bufferworkerpersistent-test.js | 2 +-
test/js/converters-test.js | 2 +-
test/js/error-test.js | 2 +-
test/js/gc-test.js | 2 +-
test/js/indexedinterceptors-test.js | 2 +-
test/js/isolatedata-test.js | 2 +-
test/js/makecallback-test.js | 2 +-
test/js/morenews-test.js | 2 +-
test/js/multifile-test.js | 2 +-
test/js/namedinterceptors-test.js | 2 +-
test/js/nancallback-test.js | 2 +-
test/js/nannew-test.js | 2 +-
test/js/news-test.js | 2 +-
test/js/objectwraphandle-test.js | 14 +-
test/js/persistent-test.js | 24 ++-
test/js/returnemptystring-test.js | 2 +-
test/js/returnnull-test.js | 2 +-
test/js/returnundefined-test.js | 2 +-
test/js/returnvalue-test.js | 2 +-
test/js/setcallhandler-test.js | 2 +-
test/js/settemplate-test.js | 2 +-
test/js/strings-test.js | 2 +-
test/js/symbols-test.js | 2 +-
test/js/threadlocal-test.js | 2 +-
test/js/trycatch-test.js | 2 +-
test/js/typedarrays-test.js | 8 +
test/js/weak-test.js | 2 +-
test/js/weak2-test.js | 2 +-
test/js/wrappedobjectfactory-test.js | 2 +-
tools/1to2.js | 4 +-
111 files changed, 568 insertions(+), 253 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 958e1c0..ac80b6d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,6 +16,7 @@ env:
- TRAVIS_NODE_VERSION="0.12"
- TRAVIS_NODE_VERSION="iojs-3"
- TRAVIS_NODE_VERSION="4"
+ - TRAVIS_NODE_VERSION="5"
notifications:
email:
- rod at vagg.org
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8d3c618..dc730cf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,13 @@
# NAN ChangeLog
-**Version 2.1.0: current Node 4.1.2, Node 12: 0.12.7, Node 10: 0.10.40, iojs: 3.3.1**
+**Version 2.2.0: current Node 5.4.0, Node 12: 0.12.9, Node 10: 0.10.41, iojs: 3.3.1**
+
+### 2.2.0 Jan 9 2016
+
+ - Feature: Add Function::Call wrapper 4c157474dacf284d125c324177b45aa5dabc08c6
+ - Feature: Rename GC*logueCallback to GCCallback for > 4.0 3603435109f981606d300eb88004ca101283acec
+ - Bugfix: Fix Global::Pass for old versions 367e82a60fbaa52716232cc89db1cc3f685d77d9
+ - Bugfix: Remove weird MaybeLocal wrapping of what already is a MaybeLocal 23b4590db10c2ba66aee2338aebe9751c4cb190b
### 2.1.0 Oct 8 2015
diff --git a/LICENSE.md b/LICENSE.md
index 77666cd..e4fc412 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,7 +1,7 @@
The MIT License (MIT)
=====================
-Copyright (c) 2015 NAN contributors
+Copyright (c) 2016 NAN contributors
-----------------------------------
*NAN contributors listed at <https://github.com/nodejs/nan#contributors>*
diff --git a/Makefile b/Makefile
index 8bdd09c..9729d4d 100644
--- a/Makefile
+++ b/Makefile
@@ -83,7 +83,7 @@ test: $(ADDONS)
npm test
forcetest:
- cd test/ && node-gyp rebuild && cd ..
+ cd test && ../node_modules/.bin/node-gyp rebuild && cd ..
npm test
docs: README.md doc/.build.sh doc/asyncworker.md doc/buffers.md doc/callback.md \
diff --git a/README.md b/README.md
index 7167ae3..9a5f398 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 and 4.**
+**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.1.0***
+***Current version: 2.2.0***
*(See [CHANGELOG.md](https://github.com/nodejs/nan/blob/master/CHANGELOG.md) for complete ChangeLog)*
@@ -48,11 +48,15 @@ This works like a `-I<path-to-NAN>` when compiling your addon.
<a name="example"></a>
## Example
-Just getting started with Nan? Refer to a [quick-start **Nan** Boilerplate](https://github.com/fcanas/node-native-boilerplate) for a ready-to-go project that utilizes basic Nan functionality.
+Just getting started with Nan? Take a look at the **[Node Add-on Examples](https://github.com/nodejs/node-addon-examples)**.
+
+Refer to a [quick-start **Nan** Boilerplate](https://github.com/fcanas/node-native-boilerplate) for a ready-to-go project that utilizes basic Nan functionality.
For a simpler example, see the **[async pi estimation example](https://github.com/nodejs/nan/tree/master/examples/async_pi_estimate)** in the examples directory for full code and an explanation of what this Monte Carlo Pi estimation example does. Below are just some parts of the full example that illustrate the use of **NAN**.
-For another example, see **[nan-example-eol](https://github.com/CodeCharmLtd/nan-example-eol)**. It shows newline detection implemented as a native addon.
+Yet another example is **[nan-example-eol](https://github.com/CodeCharmLtd/nan-example-eol)**. It shows newline detection implemented as a native addon.
+
+Also take a look at our comprehensive **[C++ test suite](https://github.com/nodejs/nan/tree/master/test/cpp)** which has a plehora of code snippets for your pasting pleasure.
<a name="api"></a>
## API
@@ -62,6 +66,7 @@ Additional to the NAN documentation below, please consult:
* [The V8 Getting Started Guide](https://developers.google.com/v8/get_started)
* [The V8 Embedders Guide](https://developers.google.com/v8/embed)
* [V8 API Documentation](http://v8docs.nodesource.com/)
+* [Node Add-on Documentation](https://nodejs.org/api/addons.html)
<!-- START API -->
@@ -91,9 +96,10 @@ In order to expose functionality to JavaScript via a template, you must provide
- <a href="doc/methods.md#api_nan_index_query"><b>Index query declaration</b></a>
* Method and template helpers
- <a href="doc/methods.md#api_nan_set_method"><b><code>Nan::SetMethod()</code></b></a>
+ - <a href="doc/methods.md#api_nan_set_prototype_method"><b><code>Nan::SetPrototypeMethod()</code></b></a>
+ - <a href="doc/methods.md#api_nan_set_accessor"><b><code>Nan::SetAccessor()</code></b></a>
- <a href="doc/methods.md#api_nan_set_named_property_handler"><b><code>Nan::SetNamedPropertyHandler()</code></b></a>
- <a href="doc/methods.md#api_nan_set_indexed_property_handler"><b><code>Nan::SetIndexedPropertyHandler()</code></b></a>
- - <a href="doc/methods.md#api_nan_set_prototype_method"><b><code>Nan::SetPrototypeMethod()</code></b></a>
- <a href="doc/methods.md#api_nan_set_template"><b><code>Nan::SetTemplate()</code></b></a>
- <a href="doc/methods.md#api_nan_set_prototype_template"><b><code>Nan::SetPrototypeTemplate()</code></b></a>
- <a href="doc/methods.md#api_nan_set_instance_template"><b><code>Nan::SetInstanceTemplate()</code></b></a>
@@ -157,6 +163,7 @@ The `Nan::MaybeLocal` and `Nan::Maybe` types are monads that encapsulate `v8::Lo
- <a href="doc/maybe_types.md#api_nan_nothing"><b><code>Nan::Nothing</code></b></a>
- <a href="doc/maybe_types.md#api_nan_just"><b><code>Nan::Just</code></b></a>
* **Maybe Helpers**
+ - <a href="doc/maybe_types.md#api_nan_call"><b><code>Nan::Call()</code></b></a>
- <a href="doc/maybe_types.md#api_nan_to_detail_string"><b><code>Nan::ToDetailString()</code></b></a>
- <a href="doc/maybe_types.md#api_nan_to_array_index"><b><code>Nan::ToArrayIndex()</code></b></a>
- <a href="doc/maybe_types.md#api_nan_equals"><b><code>Nan::Equals()</code></b></a>
@@ -250,6 +257,13 @@ Miscellaneous string & byte encoding and decoding functionality provided for com
- <a href="doc/string_bytes.md#api_nan_decode_write"><b><code>Nan::DecodeWrite()</code></b></a>
+### Object Wrappers
+
+The `ObjectWrap` class can be used to make wrapped C++ objects and a factory of wrapped objects.
+
+ - <a href="doc/object_wrappers.md#api_nan_object_wrap"><b><code>Nan::ObjectWrap</code></b></a>
+
+
### V8 internals
The hooks to access V8 internals—including GC and statistics—are different across the supported versions of V8, therefore NAN provides its own hooks that call the appropriate V8 methods.
@@ -283,7 +297,6 @@ The hooks to access V8 internals—including GC and statistics—are different a
### Miscellaneous Node Helpers
- <a href="doc/node_misc.md#api_nan_make_callback"><b><code>Nan::MakeCallback()</code></b></a>
- - <a href="doc/node_misc.md#api_nan_object_wrap"><b><code>Nan::ObjectWrap</code></b></a>
- <a href="doc/node_misc.md#api_nan_module_init"><b><code>NAN_MODULE_INIT()</code></b></a>
- <a href="doc/node_misc.md#api_nan_export"><b><code>Nan::Export()</code></b></a>
@@ -366,6 +379,6 @@ By making a contribution to this project, I certify that:
## Licence & copyright
-Copyright (c) 2015 NAN WG Members / Collaborators (listed above).
+Copyright (c) 2016 NAN WG Members / Collaborators (listed above).
Native Abstractions for Node.js is licensed under an MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.
diff --git a/appveyor.yml b/appveyor.yml
index 694f84e..055379f 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -9,6 +9,7 @@ environment:
- nodejs_version: "0.12"
- nodejs_version: "3"
- nodejs_version: "4"
+ - nodejs_version: "5"
# Install scripts. (runs after repo cloning)
install:
diff --git a/doc/.build.sh b/doc/.build.sh
index 75a975a..72cd743 100755
--- a/doc/.build.sh
+++ b/doc/.build.sh
@@ -1,21 +1,22 @@
#!/usr/bin/env bash
-files=" \
- methods.md \
- scopes.md \
- persistent.md \
- new.md \
- converters.md \
- maybe_types.md \
- script.md \
- errors.md \
- buffers.md \
- callback.md \
- asyncworker.md \
- string_bytes.md \
- v8_internals.md \
- v8_misc.md \
- node_misc.md \
+files=" \
+ methods.md \
+ scopes.md \
+ persistent.md \
+ new.md \
+ converters.md \
+ maybe_types.md \
+ script.md \
+ errors.md \
+ buffers.md \
+ callback.md \
+ asyncworker.md \
+ string_bytes.md \
+ object_wrappers.md \
+ v8_internals.md \
+ v8_misc.md \
+ node_misc.md \
"
__dirname=$(dirname "${BASH_SOURCE[0]}")
@@ -35,4 +36,4 @@ $head
$apidocs
$tail
-EOF
\ No newline at end of file
+EOF
diff --git a/doc/maybe_types.md b/doc/maybe_types.md
index d2e5b7d..9ca9cee 100644
--- a/doc/maybe_types.md
+++ b/doc/maybe_types.md
@@ -8,6 +8,7 @@ The `Nan::MaybeLocal` and `Nan::Maybe` types are monads that encapsulate `v8::Lo
- <a href="#api_nan_nothing"><b><code>Nan::Nothing</code></b></a>
- <a href="#api_nan_just"><b><code>Nan::Just</code></b></a>
* **Maybe Helpers**
+ - <a href="#api_nan_call"><b><code>Nan::Call()</code></b></a>
- <a href="#api_nan_to_detail_string"><b><code>Nan::ToDetailString()</code></b></a>
- <a href="#api_nan_to_array_index"><b><code>Nan::ToArrayIndex()</code></b></a>
- <a href="#api_nan_equals"><b><code>Nan::Equals()</code></b></a>
@@ -113,6 +114,17 @@ Construct a `Nan::Maybe` type representing _just_ a value.
template<typename T> Nan::Maybe<T> Nan::Just(const T &t);
```
+<a name="api_nan_call"></a>
+### Nan::Call()
+
+A helper method for calling [`v8::Function#Call()`](https://v8docs.nodesource.com/io.js-3.0/d5/d54/classv8_1_1_function.html#a468a89f737af0612db10132799c827c0) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::MaybeLocal<v8::Value> Nan::Call(v8::Local<v8::Function> fun, v8::Local<v8::Object> recv, int argc, v8::Local<v8::Value> argv[]);
+```
+
<a name="api_nan_to_detail_string"></a>
### Nan::ToDetailString()
diff --git a/doc/methods.md b/doc/methods.md
index 068feed..90aa46a 100644
--- a/doc/methods.md
+++ b/doc/methods.md
@@ -24,9 +24,10 @@ In order to expose functionality to JavaScript via a template, you must provide
- <a href="#api_nan_index_query"><b>Index query declaration</b></a>
* Method and template helpers
- <a href="#api_nan_set_method"><b><code>Nan::SetMethod()</code></b></a>
+ - <a href="#api_nan_set_prototype_method"><b><code>Nan::SetPrototypeMethod()</code></b></a>
+ - <a href="#api_nan_set_accessor"><b><code>Nan::SetAccessor()</code></b></a>
- <a href="#api_nan_set_named_property_handler"><b><code>Nan::SetNamedPropertyHandler()</code></b></a>
- <a href="#api_nan_set_indexed_property_handler"><b><code>Nan::SetIndexedPropertyHandler()</code></b></a>
- - <a href="#api_nan_set_prototype_method"><b><code>Nan::SetPrototypeMethod()</code></b></a>
- <a href="#api_nan_set_template"><b><code>Nan::SetTemplate()</code></b></a>
- <a href="#api_nan_set_prototype_template"><b><code>Nan::SetPrototypeTemplate()</code></b></a>
- <a href="#api_nan_set_instance_template"><b><code>Nan::SetInstanceTemplate()</code></b></a>
diff --git a/doc/node_misc.md b/doc/node_misc.md
index 33e9046..8aa080f 100644
--- a/doc/node_misc.md
+++ b/doc/node_misc.md
@@ -1,7 +1,6 @@
## Miscellaneous Node Helpers
- <a href="#api_nan_make_callback"><b><code>Nan::MakeCallback()</code></b></a>
- - <a href="#api_nan_object_wrap"><b><code>Nan::ObjectWrap</code></b></a>
- <a href="#api_nan_module_init"><b><code>NAN_MODULE_INIT()</code></b></a>
- <a href="#api_nan_export"><b><code>Nan::Export()</code></b></a>
@@ -31,56 +30,6 @@ v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object> target,
```
-<a name="api_nan_object_wrap"></a>
-### Nan::ObjectWrap()
-
-A reimplementation of `node::ObjectWrap` that adds some API not present in older versions of Node. Should be preferred over `node::ObjectWrap` in all cases for consistency.
-
-See the Node documentation on [Wrapping C++ Objects](https://nodejs.org/api/addons.html#addons_wrapping_c_objects) for more details.
-
-Definition:
-
-```c++
-class ObjectWrap {
- public:
- ObjectWrap();
-
- virtual ~ObjectWrap();
-
- template <class T>
- static inline T* Unwrap(v8::Local<v8::Object> handle);
-
- inline v8::Local<v8::Object> handle();
-
- inline Nan::Persistent<v8::Object>& persistent();
-
- protected:
- inline void Wrap(v8::Local<v8::Object> handle);
-
- inline void MakeWeak();
-
- /* Ref() marks the object as being attached to an event loop.
- * Refed objects will not be garbage collected, even if
- * all references are lost.
- */
- virtual void Ref();
-
- /* Unref() marks an object as detached from the event loop. This is its
- * default state. When an object with a "weak" reference changes from
- * attached to detached state it will be freed. Be careful not to access
- * the object after making this call as it might be gone!
- * (A "weak reference" means an object that only has a
- * persistant handle.)
- *
- * DO NOT CALL THIS FROM DESTRUCTOR
- */
- virtual void Unref();
-
- int refs_; // ro
-};
-```
-
-
<a name="api_nan_module_init"></a>
### NAN_MODULE_INIT()
diff --git a/doc/object_wrappers.md b/doc/object_wrappers.md
new file mode 100644
index 0000000..27b0636
--- /dev/null
+++ b/doc/object_wrappers.md
@@ -0,0 +1,263 @@
+## Object Wrappers
+
+The `ObjectWrap` class can be used to make wrapped C++ objects and a factory of wrapped objects.
+
+ - <a href="#api_nan_object_wrap"><b><code>Nan::ObjectWrap</code></b></a>
+
+
+<a name="api_nan_object_wrap"></a>
+### Nan::ObjectWrap()
+
+A reimplementation of `node::ObjectWrap` that adds some API not present in older versions of Node. Should be preferred over `node::ObjectWrap` in all cases for consistency.
+
+Definition:
+
+```c++
+class ObjectWrap {
+ public:
+ ObjectWrap();
+
+ virtual ~ObjectWrap();
+
+ template <class T>
+ static inline T* Unwrap(v8::Local<v8::Object> handle);
+
+ inline v8::Local<v8::Object> handle();
+
+ inline Nan::Persistent<v8::Object>& persistent();
+
+ protected:
+ inline void Wrap(v8::Local<v8::Object> handle);
+
+ inline void MakeWeak();
+
+ /* Ref() marks the object as being attached to an event loop.
+ * Refed objects will not be garbage collected, even if
+ * all references are lost.
+ */
+ virtual void Ref();
+
+ /* Unref() marks an object as detached from the event loop. This is its
+ * default state. When an object with a "weak" reference changes from
+ * attached to detached state it will be freed. Be careful not to access
+ * the object after making this call as it might be gone!
+ * (A "weak reference" means an object that only has a
+ * persistant handle.)
+ *
+ * DO NOT CALL THIS FROM DESTRUCTOR
+ */
+ virtual void Unref();
+
+ int refs_; // ro
+};
+```
+
+See the Node documentation on [Wrapping C++ Objects](https://nodejs.org/api/addons.html#addons_wrapping_c_objects) for more details.
+
+### This vs. Holder
+
+When calling `Unwrap`, it is important that the argument is indeed some JavaScript object which got wrapped by a `Wrap` call for this class or any derived class.
+The `Signature` installed by [`Nan::SetPrototypeMethod()`](methods.md#api_nan_set_prototype_method) does ensure that `info.Holder()` is just such an instance.
+In Node 0.12 and later, `info.This()` will also be of such a type, since otherwise the invocation will get rejected.
+However, in Node 0.10 and before it was possible to invoke a method on a JavaScript object which just had the extension type in its prototype chain.
+In such a situation, calling `Unwrap` on `info.This()` will likely lead to a failed assertion causing a crash, but could lead to even more serious corruption.
+
+On the other hand, calling `Unwrap` in an [accessor](methods.md#api_nan_set_accessor) should not use `Holder()` if the accessor is defined on the prototype.
+So either define your accessors on the instance template,
+or use `This()` after verifying that it is indeed a valid object.
+
+### Examples
+
+#### Basic
+
+```c++
+class MyObject : public Nan::ObjectWrap {
+ public:
+ static NAN_MODULE_INIT(Init) {
+ v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
+ tpl->SetClassName(Nan::New("MyObject").ToLocalChecked());
+ tpl->InstanceTemplate()->SetInternalFieldCount(1);
+
+ SetPrototypeMethod(tpl, "getHandle", GetHandle);
+ SetPrototypeMethod(tpl, "getValue", GetValue);
+
+ constructor().Reset(Nan::GetFunction(tpl).ToLocalChecked());
+ Nan::Set(target, Nan::New("MyObject").ToLocalChecked(),
+ Nan::GetFunction(tpl).ToLocalChecked());
+ }
+
+ private:
+ explicit MyObject(double value = 0) : value_(value) {}
+ ~MyObject() {}
+
+ static NAN_METHOD(New) {
+ if (info.IsConstructCall()) {
+ double value = info[0]->IsUndefined() ? 0 : Nan::To<double>(info[0]).FromJust();
+ MyObject *obj = new MyObject(value);
+ obj->Wrap(info.This());
+ info.GetReturnValue().Set(info.This());
+ } else {
+ const int argc = 1;
+ v8::Local<v8::Value> argv[argc] = {info[0]};
+ v8::Local<v8::Function> cons = Nan::New(constructor());
+ info.GetReturnValue().Set(cons->NewInstance(argc, argv));
+ }
+ }
+
+ static NAN_METHOD(GetHandle) {
+ MyObject* obj = Nan::ObjectWrap::Unwrap<MyObject>(info.Holder());
+ info.GetReturnValue().Set(obj->handle());
+ }
+
+ static NAN_METHOD(GetValue) {
+ MyObject* obj = Nan::ObjectWrap::Unwrap<MyObject>(info.Holder());
+ info.GetReturnValue().Set(obj->value_);
+ }
+
+ static inline Nan::Persistent<v8::Function> & constructor() {
+ static Nan::Persistent<v8::Function> my_constructor;
+ return my_constructor;
+ }
+
+ double value_;
+};
+
+NODE_MODULE(objectwrapper, MyObject::Init)
+```
+
+To use in Javascript:
+
+```Javascript
+var objectwrapper = require('bindings')('objectwrapper');
+
+var obj = new objectwrapper.MyObject(5);
+console.log('Should be 5: ' + obj.getValue());
+```
+
+#### Factory of wrapped objects
+
+```c++
+class MyFactoryObject : public Nan::ObjectWrap {
+ public:
+ static NAN_MODULE_INIT(Init) {
+ v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
+ tpl->InstanceTemplate()->SetInternalFieldCount(1);
+
+ Nan::SetPrototypeMethod(tpl, "getValue", GetValue);
+
+ constructor().Reset(Nan::GetFunction(tpl).ToLocalChecked());
+ }
+
+ static NAN_METHOD(NewInstance) {
+ v8::Local<v8::Function> cons = Nan::New(constructor());
+ double value = info[0]->IsNumber() ? Nan::To<double>(info[0]).FromJust() : 0;
+ const int argc = 1;
+ v8::Local<v8::Value> argv[1] = {Nan::New(value)};
+ info.GetReturnValue().Set(Nan::NewInstance(cons, argc, argv).ToLocalChecked());
+ }
+
+ // Needed for the next example:
+ inline double value() const {
+ return value_;
+ }
+
+ private:
+ explicit MyFactoryObject(double value = 0) : value_(value) {}
+ ~MyFactoryObject() {}
+
+ static NAN_METHOD(New) {
+ if (info.IsConstructCall()) {
+ double value = info[0]->IsNumber() ? Nan::To<double>(info[0]).FromJust() : 0;
+ MyFactoryObject * obj = new MyFactoryObject(value);
+ obj->Wrap(info.This());
+ info.GetReturnValue().Set(info.This());
+ } else {
+ const int argc = 1;
+ v8::Local<v8::Value> argv[argc] = {info[0]};
+ v8::Local<v8::Function> cons = Nan::New(constructor());
+ info.GetReturnValue().Set(Nan::NewInstance(cons, argc, argv).ToLocalChecked());
+ }
+ }
+
+ static NAN_METHOD(GetValue) {
+ MyFactoryObject* obj = ObjectWrap::Unwrap<MyFactoryObject>(info.Holder());
+ info.GetReturnValue().Set(obj->value_);
+ }
+
+ static inline Nan::Persistent<v8::Function> & constructor() {
+ static Nan::Persistent<v8::Function> my_constructor;
+ return my_constructor;
+ }
+
+ double value_;
+};
+
+NAN_MODULE_INIT(Init) {
+ MyFactoryObject::Init(target);
+ Nan::Set(target,
+ Nan::New<v8::String>("newFactoryObjectInstance").ToLocalChecked(),
+ Nan::GetFunction(
+ Nan::New<v8::FunctionTemplate>(MyFactoryObject::NewInstance)).ToLocalChecked()
+ );
+}
+
+NODE_MODULE(wrappedobjectfactory, Init)
+```
+
+To use in Javascript:
+
+```Javascript
+var wrappedobjectfactory = require('bindings')('wrappedobjectfactory');
+
+var obj = wrappedobjectfactory.newFactoryObjectInstance(10);
+console.log('Should be 10: ' + obj.getValue());
+```
+
+#### Passing wrapped objects around
+
+Use the `MyFactoryObject` class above along with the following:
+
+```c++
+static NAN_METHOD(Sum) {
+ Nan::MaybeLocal<v8::Object> maybe1 = Nan::To<v8::Object>(info[0]);
+ Nan::MaybeLocal<v8::Object> maybe2 = Nan::To<v8::Object>(info[1]);
+
+ // Quick check:
+ if (maybe1.IsEmpty() || maybe2.IsEmpty()) {
+ // return value is undefined by default
+ return;
+ }
+
+ MyFactoryObject* obj1 =
+ Nan::ObjectWrap::Unwrap<MyFactoryObject>(maybe1.ToLocalChecked());
+ MyFactoryObject* obj2 =
+ Nan::ObjectWrap::Unwrap<MyFactoryObject>(maybe2.ToLocalChecked());
+
+ info.GetReturnValue().Set(Nan::New<v8::Number>(obj1->value() + obj2->value()));
+}
+
+NAN_MODULE_INIT(Init) {
+ MyFactoryObject::Init(target);
+ Nan::Set(target,
+ Nan::New<v8::String>("newFactoryObjectInstance").ToLocalChecked(),
+ Nan::GetFunction(
+ Nan::New<v8::FunctionTemplate>(MyFactoryObject::NewInstance)).ToLocalChecked()
+ );
+ Nan::Set(target,
+ Nan::New<v8::String>("sum").ToLocalChecked(),
+ Nan::GetFunction(Nan::New<v8::FunctionTemplate>(Sum)).ToLocalChecked()
+ );
+}
+
+NODE_MODULE(myaddon, Init)
+```
+
+To use in Javascript:
+
+```Javascript
+var myaddon = require('bindings')('myaddon');
+
+var obj1 = myaddon.newFactoryObjectInstance(5);
+var obj2 = myaddon.newFactoryObjectInstance(10);
+console.log('sum of object values: ' + myaddon.sum(obj1, obj2));
+```
diff --git a/doc/v8_misc.md b/doc/v8_misc.md
index 653ef61..64f736d 100644
--- a/doc/v8_misc.md
+++ b/doc/v8_misc.md
@@ -4,7 +4,7 @@
- <a href="#api_nan_get_current_context"><b><code>Nan::GetCurrentContext()</code></b></a>
- <a href="#api_nan_set_isolate_data"><b><code>Nan::SetIsolateData()</code></b></a>
- <a href="#api_nan_get_isolate_data"><b><code>Nan::GetIsolateData()</code></b></a>
- - <a href="#api_nan_typedarray_contents"><b><code>Nan::TypedArrayContents<T></code></b></a>
+ - <a href="#api_nan_typedarray_contents"><b><code>Nan::TypedArrayContents</code></b></a>
<a name="api_nan_utf8_string"></a>
diff --git a/examples/async_pi_estimate/addon.cc b/examples/async_pi_estimate/addon.cc
index 34b2c07..295e8f6 100644
--- a/examples/async_pi_estimate/addon.cc
+++ b/examples/async_pi_estimate/addon.cc
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/examples/async_pi_estimate/addon.js b/examples/async_pi_estimate/addon.js
index 2d84c9d..cd4ba95 100644
--- a/examples/async_pi_estimate/addon.js
+++ b/examples/async_pi_estimate/addon.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/examples/async_pi_estimate/async.cc b/examples/async_pi_estimate/async.cc
index 80a599a..170f99c 100644
--- a/examples/async_pi_estimate/async.cc
+++ b/examples/async_pi_estimate/async.cc
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/examples/async_pi_estimate/async.h b/examples/async_pi_estimate/async.h
index ad3e889..ce1588b 100644
--- a/examples/async_pi_estimate/async.h
+++ b/examples/async_pi_estimate/async.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/examples/async_pi_estimate/pi_est.cc b/examples/async_pi_estimate/pi_est.cc
index 1cb0054..1bf3f23 100644
--- a/examples/async_pi_estimate/pi_est.cc
+++ b/examples/async_pi_estimate/pi_est.cc
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/examples/async_pi_estimate/pi_est.h b/examples/async_pi_estimate/pi_est.h
index 778ddd8..12a5387 100644
--- a/examples/async_pi_estimate/pi_est.h
+++ b/examples/async_pi_estimate/pi_est.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/examples/async_pi_estimate/sync.cc b/examples/async_pi_estimate/sync.cc
index 3dae9fd..115bd6a 100644
--- a/examples/async_pi_estimate/sync.cc
+++ b/examples/async_pi_estimate/sync.cc
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/examples/async_pi_estimate/sync.h b/examples/async_pi_estimate/sync.h
index 282d540..453484a 100644
--- a/examples/async_pi_estimate/sync.h
+++ b/examples/async_pi_estimate/sync.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/nan.h b/nan.h
index a5cd895..2bbdb47 100644
--- a/nan.h
+++ b/nan.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors:
+ * Copyright (c) 2016 NAN contributors:
* - Rod Vagg <https://github.com/rvagg>
* - Benjamin Byholm <https://github.com/kkoopa>
* - Trevor Norris <https://github.com/trevnorris>
@@ -12,7 +12,7 @@
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
*
- * Version 2.1.0: current Node 4.1.2, Node 12: 0.12.7, Node 10: 0.10.40, iojs: 3.3.1
+ * Version 2.2.0: current Node 5.4.0, Node 12: 0.12.9, Node 10: 0.10.41, iojs: 3.3.1
*
* See https://github.com/nodejs/nan for the latest update to this file
**********************************************************************************/
@@ -37,7 +37,7 @@
# define NAN_HAS_CPLUSPLUS_11 (__cplusplus >= 201103L)
#endif
-#if NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION && ! NAN_HAS_CPLUSPLUS_11
+#if NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION && !NAN_HAS_CPLUSPLUS_11
# error This version of node/NAN/v8 requires a C++11 compiler
#endif
@@ -100,7 +100,7 @@ namespace Nan {
# define NAN_DEPRECATED
#endif
-#if __cplusplus >= 201103L
+#if NAN_HAS_CPLUSPLUS_11
# define NAN_DISALLOW_ASSIGN(CLASS) void operator=(const CLASS&) = delete;
# define NAN_DISALLOW_COPY(CLASS) CLASS(const CLASS&) = delete;
# define NAN_DISALLOW_MOVE(CLASS) \
@@ -598,25 +598,33 @@ class TryCatch {
# define NAN_GC_CALLBACK(name) \
void name(v8::Isolate *isolate, v8::GCType type, v8::GCCallbackFlags flags)
+#if NODE_MODULE_VERSION <= NODE_4_0_MODULE_VERSION
+ typedef v8::Isolate::GCEpilogueCallback GCEpilogueCallback;
+ typedef v8::Isolate::GCPrologueCallback GCPrologueCallback;
+#else
+ typedef v8::Isolate::GCCallback GCEpilogueCallback;
+ typedef v8::Isolate::GCCallback GCPrologueCallback;
+#endif
+
NAN_INLINE void AddGCEpilogueCallback(
- v8::Isolate::GCEpilogueCallback callback
+ GCEpilogueCallback callback
, v8::GCType gc_type_filter = v8::kGCTypeAll) {
v8::Isolate::GetCurrent()->AddGCEpilogueCallback(callback, gc_type_filter);
}
NAN_INLINE void RemoveGCEpilogueCallback(
- v8::Isolate::GCEpilogueCallback callback) {
+ GCEpilogueCallback callback) {
v8::Isolate::GetCurrent()->RemoveGCEpilogueCallback(callback);
}
NAN_INLINE void AddGCPrologueCallback(
- v8::Isolate::GCPrologueCallback callback
+ GCPrologueCallback callback
, v8::GCType gc_type_filter = v8::kGCTypeAll) {
v8::Isolate::GetCurrent()->AddGCPrologueCallback(callback, gc_type_filter);
}
NAN_INLINE void RemoveGCPrologueCallback(
- v8::Isolate::GCPrologueCallback callback) {
+ GCPrologueCallback callback) {
v8::Isolate::GetCurrent()->RemoveGCPrologueCallback(callback);
}
@@ -1050,8 +1058,8 @@ class Utf8String {
// arbitrary buffer lengths requires
// NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION
assert(length <= imp::kMaxLength && "too large buffer");
- return MaybeLocal<v8::Object>(
- scope.Escape(New(node::Buffer::New(data, length, callback, hint)->handle_)));
+ return MaybeLocal<v8::Object>(scope.Escape(
+ New(node::Buffer::New(data, length, callback, hint)->handle_)));
}
NAN_INLINE MaybeLocal<v8::Object> CopyBuffer(
@@ -1704,7 +1712,7 @@ NAN_INLINE void AsyncQueueWorker (AsyncWorker* worker) {
uv_default_loop()
, &worker->request
, AsyncExecute
- , (uv_after_work_cb)AsyncExecuteComplete
+ , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
);
}
diff --git a/nan_callbacks.h b/nan_callbacks.h
index c87aec8..851509f 100644
--- a/nan_callbacks.h
+++ b/nan_callbacks.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/nan_callbacks_12_inl.h b/nan_callbacks_12_inl.h
index b20d68f..bea12c7 100644
--- a/nan_callbacks_12_inl.h
+++ b/nan_callbacks_12_inl.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/nan_callbacks_pre_12_inl.h b/nan_callbacks_pre_12_inl.h
index 9a01443..9a486aa 100644
--- a/nan_callbacks_pre_12_inl.h
+++ b/nan_callbacks_pre_12_inl.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/nan_converters.h b/nan_converters.h
index 6f08e68..533e97e 100644
--- a/nan_converters.h
+++ b/nan_converters.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/nan_converters_43_inl.h b/nan_converters_43_inl.h
index 596b8f1..e2eb032 100644
--- a/nan_converters_43_inl.h
+++ b/nan_converters_43_inl.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/nan_converters_pre_43_inl.h b/nan_converters_pre_43_inl.h
index 4fe2eb9..177a74a 100644
--- a/nan_converters_pre_43_inl.h
+++ b/nan_converters_pre_43_inl.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/nan_implementation_12_inl.h b/nan_implementation_12_inl.h
index a140f85..cb1e765 100644
--- a/nan_implementation_12_inl.h
+++ b/nan_implementation_12_inl.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/nan_implementation_pre_12_inl.h b/nan_implementation_pre_12_inl.h
index 15a815c..f6642ee 100644
--- a/nan_implementation_pre_12_inl.h
+++ b/nan_implementation_pre_12_inl.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/nan_maybe_43_inl.h b/nan_maybe_43_inl.h
index e06c8d2..b4f9235 100644
--- a/nan_maybe_43_inl.h
+++ b/nan_maybe_43_inl.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
@@ -44,7 +44,7 @@ Maybe<bool> Equals(v8::Local<v8::Value> a, v8::Local<v8::Value>(b)) {
NAN_INLINE
MaybeLocal<v8::Object> NewInstance(v8::Local<v8::Function> h) {
- return MaybeLocal<v8::Object>(h->NewInstance(GetCurrentContext()));
+ return h->NewInstance(GetCurrentContext());
}
NAN_INLINE
@@ -52,13 +52,12 @@ MaybeLocal<v8::Object> NewInstance(
v8::Local<v8::Function> h
, int argc
, v8::Local<v8::Value> argv[]) {
- return MaybeLocal<v8::Object>(h->NewInstance(GetCurrentContext(),
- argc, argv));
+ return h->NewInstance(GetCurrentContext(), argc, argv);
}
NAN_INLINE
MaybeLocal<v8::Object> NewInstance(v8::Local<v8::ObjectTemplate> h) {
- return MaybeLocal<v8::Object>(h->NewInstance(GetCurrentContext()));
+ return h->NewInstance(GetCurrentContext());
}
@@ -221,4 +220,12 @@ NAN_INLINE MaybeLocal<v8::Object> CloneElementAt(
return array->CloneElementAt(GetCurrentContext(), index);
}
+NAN_INLINE MaybeLocal<v8::Value> Call(
+ v8::Local<v8::Function> fun
+ , v8::Local<v8::Object> recv
+ , int argc
+ , v8::Local<v8::Value> argv[]) {
+ return fun->Call(GetCurrentContext(), recv, argc, argv);
+}
+
#endif // NAN_MAYBE_43_INL_H_
diff --git a/nan_maybe_pre_43_inl.h b/nan_maybe_pre_43_inl.h
index 0857347..3b79341 100644
--- a/nan_maybe_pre_43_inl.h
+++ b/nan_maybe_pre_43_inl.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
@@ -292,4 +292,12 @@ NAN_INLINE MaybeLocal<v8::Object> CloneElementAt(
return MaybeLocal<v8::Object>(array->CloneElementAt(index));
}
+NAN_INLINE MaybeLocal<v8::Value> Call(
+ v8::Local<v8::Function> fun
+ , v8::Local<v8::Object> recv
+ , int argc
+ , v8::Local<v8::Value> argv[]) {
+ return MaybeLocal<v8::Value>(fun->Call(recv, argc, argv));
+}
+
#endif // NAN_MAYBE_PRE_43_INL_H_
diff --git a/nan_new.h b/nan_new.h
index c6c4236..6c7d19f 100644
--- a/nan_new.h
+++ b/nan_new.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/nan_object_wrap.h b/nan_object_wrap.h
index 0685b02..632d519 100644
--- a/nan_object_wrap.h
+++ b/nan_object_wrap.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/nan_persistent_12_inl.h b/nan_persistent_12_inl.h
index f1fa193..0d56f53 100644
--- a/nan_persistent_12_inl.h
+++ b/nan_persistent_12_inl.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/nan_persistent_pre_12_inl.h b/nan_persistent_pre_12_inl.h
index 8212f58..fb19aa4 100644
--- a/nan_persistent_pre_12_inl.h
+++ b/nan_persistent_pre_12_inl.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
@@ -210,7 +210,7 @@ class Global : public PersistentBase<T> {
* Move constructor.
*/
NAN_INLINE Global(RValue rvalue)
- : PersistentBase<T>(rvalue.object.persistent) {
+ : PersistentBase<T>(rvalue.object->persistent) {
rvalue.object->Reset();
}
NAN_INLINE ~Global() { this->Reset(); }
diff --git a/nan_typedarray_contents.h b/nan_typedarray_contents.h
index 114eed4..6a7f8b5 100644
--- a/nan_typedarray_contents.h
+++ b/nan_typedarray_contents.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
@@ -57,19 +57,19 @@ class TypedArrayContents {
#endif
-#if defined(_MSC_VER) || defined(__GNUC__)
+#if defined(_MSC_VER) && _MSC_VER >= 1900 || __cplusplus >= 201103L
+ assert(reinterpret_cast<uintptr_t>(data) % alignof (T) == 0);
+#elif defined(_MSC_VER) && _MSC_VER >= 1600 || defined(__GNUC__)
assert(reinterpret_cast<uintptr_t>(data) % __alignof(T) == 0);
-#elif __cplusplus >= 201103L
- assert(reinterpret_cast<uintptr_t>(data) % alignof(T) == 0);
#else
- assert(reinterpret_cast<uintptr_t>(data) % sizeof(T) == 0);
+ assert(reinterpret_cast<uintptr_t>(data) % sizeof (T) == 0);
#endif
length_ = length;
data_ = static_cast<T*>(data);
}
- NAN_INLINE size_t length() const { return length_; }
+ NAN_INLINE size_t length() const { return length_; }
NAN_INLINE T* operator*() { return data_; }
NAN_INLINE const T* operator*() const { return data_; }
diff --git a/nan_weak.h b/nan_weak.h
index 0ea7235..ed3f92e 100644
--- a/nan_weak.h
+++ b/nan_weak.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/package.json b/package.json
index 19515ce..01d9bdc 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "nan",
- "version": "2.1.0",
+ "version": "2.2.0",
"description": "Native Abstractions for Node.js: C++ header for Node 0.8 -> 4 compatibility",
"main": "include_dirs.js",
"repository": {
diff --git a/test/cpp/accessors.cpp b/test/cpp/accessors.cpp
index 123cfd0..4364c87 100644
--- a/test/cpp/accessors.cpp
+++ b/test/cpp/accessors.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
@@ -48,13 +48,13 @@ NAN_MODULE_INIT(SetterGetter::Init) {
tpl->SetClassName(Nan::New<v8::String>("SetterGetter").ToLocalChecked());
tpl->InstanceTemplate()->SetInternalFieldCount(1);
SetPrototypeMethod(tpl, "log", SetterGetter::Log);
- v8::Local<v8::ObjectTemplate> proto = tpl->PrototypeTemplate();
+ v8::Local<v8::ObjectTemplate> itpl = tpl->InstanceTemplate();
SetAccessor(
- proto
+ itpl
, Nan::New("prop1").ToLocalChecked()
, SetterGetter::GetProp1);
SetAccessor(
- proto
+ itpl
, Nan::New<v8::String>("prop2").ToLocalChecked()
, SetterGetter::GetProp2
, SetterGetter::SetProp2
@@ -88,7 +88,7 @@ NAN_METHOD(SetterGetter::New) {
NAN_GETTER(SetterGetter::GetProp1) {
SetterGetter* settergetter =
- ObjectWrap::Unwrap<SetterGetter>(info.This());
+ ObjectWrap::Unwrap<SetterGetter>(info.Holder());
assert(strlen(settergetter->log) < sizeof (settergetter->log));
strncat(
settergetter->log
@@ -110,7 +110,7 @@ NAN_GETTER(SetterGetter::GetProp1) {
NAN_GETTER(SetterGetter::GetProp2) {
SetterGetter* settergetter =
- ObjectWrap::Unwrap<SetterGetter>(info.This());
+ ObjectWrap::Unwrap<SetterGetter>(info.Holder());
assert(strlen(settergetter->log) < sizeof (settergetter->log));
strncat(
settergetter->log
@@ -132,7 +132,7 @@ NAN_GETTER(SetterGetter::GetProp2) {
NAN_SETTER(SetterGetter::SetProp2) {
SetterGetter* settergetter =
- ObjectWrap::Unwrap<SetterGetter>(info.This());
+ ObjectWrap::Unwrap<SetterGetter>(info.Holder());
strncpy(
settergetter->prop2
, *Utf8String(value)
@@ -157,7 +157,7 @@ NAN_SETTER(SetterGetter::SetProp2) {
NAN_METHOD(SetterGetter::Log) {
SetterGetter* settergetter =
- ObjectWrap::Unwrap<SetterGetter>(info.This());
+ ObjectWrap::Unwrap<SetterGetter>(info.Holder());
info.GetReturnValue().Set(Nan::New(settergetter->log).ToLocalChecked());
}
diff --git a/test/cpp/accessors2.cpp b/test/cpp/accessors2.cpp
index 23cc367..bdd3093 100644
--- a/test/cpp/accessors2.cpp
+++ b/test/cpp/accessors2.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
@@ -86,7 +86,7 @@ NAN_METHOD(SetterGetter::New) {
NAN_GETTER(SetterGetter::GetProp1) {
SetterGetter* settergetter =
- ObjectWrap::Unwrap<SetterGetter>(info.This());
+ ObjectWrap::Unwrap<SetterGetter>(info.Holder());
assert(strlen(settergetter->log) < sizeof (settergetter->log));
strncat(
settergetter->log
@@ -108,7 +108,7 @@ NAN_GETTER(SetterGetter::GetProp1) {
NAN_GETTER(SetterGetter::GetProp2) {
SetterGetter* settergetter =
- ObjectWrap::Unwrap<SetterGetter>(info.This());
+ ObjectWrap::Unwrap<SetterGetter>(info.Holder());
assert(strlen(settergetter->log) < sizeof (settergetter->log));
strncat(
settergetter->log
@@ -130,7 +130,7 @@ NAN_GETTER(SetterGetter::GetProp2) {
NAN_SETTER(SetterGetter::SetProp2) {
SetterGetter* settergetter =
- ObjectWrap::Unwrap<SetterGetter>(info.This());
+ ObjectWrap::Unwrap<SetterGetter>(info.Holder());
strncpy(
settergetter->prop2
, *v8::String::Utf8Value(value)
@@ -155,7 +155,7 @@ NAN_SETTER(SetterGetter::SetProp2) {
NAN_METHOD(SetterGetter::Log) {
SetterGetter* settergetter =
- ObjectWrap::Unwrap<SetterGetter>(info.This());
+ ObjectWrap::Unwrap<SetterGetter>(info.Holder());
info.GetReturnValue().Set(Nan::New(settergetter->log).ToLocalChecked());
}
diff --git a/test/cpp/asyncprogressworker.cpp b/test/cpp/asyncprogressworker.cpp
index 7df6e4c..46ad0b7 100644
--- a/test/cpp/asyncprogressworker.cpp
+++ b/test/cpp/asyncprogressworker.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/asyncworker.cpp b/test/cpp/asyncworker.cpp
index 2876a64..ab0e642 100644
--- a/test/cpp/asyncworker.cpp
+++ b/test/cpp/asyncworker.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/asyncworkererror.cpp b/test/cpp/asyncworkererror.cpp
index ea026ff..372174a 100644
--- a/test/cpp/asyncworkererror.cpp
+++ b/test/cpp/asyncworkererror.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/buffer.cpp b/test/cpp/buffer.cpp
index 26b2a18..21c856c 100644
--- a/test/cpp/buffer.cpp
+++ b/test/cpp/buffer.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/bufferworkerpersistent.cpp b/test/cpp/bufferworkerpersistent.cpp
index 38849cf..8900bec 100644
--- a/test/cpp/bufferworkerpersistent.cpp
+++ b/test/cpp/bufferworkerpersistent.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/converters.cpp b/test/cpp/converters.cpp
index fcb5389..36631a0 100644
--- a/test/cpp/converters.cpp
+++ b/test/cpp/converters.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/error.cpp b/test/cpp/error.cpp
index 652c2cf..cba3b31 100644
--- a/test/cpp/error.cpp
+++ b/test/cpp/error.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/gc.cpp b/test/cpp/gc.cpp
index 67b6b8b..c6e6886 100644
--- a/test/cpp/gc.cpp
+++ b/test/cpp/gc.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/indexedinterceptors.cpp b/test/cpp/indexedinterceptors.cpp
index ee01909..ca66aa0 100644
--- a/test/cpp/indexedinterceptors.cpp
+++ b/test/cpp/indexedinterceptors.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
@@ -72,7 +72,7 @@ NAN_METHOD(IndexedInterceptor::New) {
NAN_INDEX_GETTER(IndexedInterceptor::PropertyGetter) {
IndexedInterceptor* interceptor =
- ObjectWrap::Unwrap<IndexedInterceptor>(info.This());
+ ObjectWrap::Unwrap<IndexedInterceptor>(info.Holder());
if (index == 0) {
info.GetReturnValue().Set(Nan::New(interceptor->buf).ToLocalChecked());
} else {
@@ -82,7 +82,7 @@ NAN_INDEX_GETTER(IndexedInterceptor::PropertyGetter) {
NAN_INDEX_SETTER(IndexedInterceptor::PropertySetter) {
IndexedInterceptor* interceptor =
- ObjectWrap::Unwrap<IndexedInterceptor>(info.This());
+ ObjectWrap::Unwrap<IndexedInterceptor>(info.Holder());
if (index == 0) {
std::strncpy(
interceptor->buf
@@ -102,7 +102,7 @@ NAN_INDEX_ENUMERATOR(IndexedInterceptor::PropertyEnumerator) {
NAN_INDEX_DELETER(IndexedInterceptor::PropertyDeleter) {
IndexedInterceptor* interceptor =
- ObjectWrap::Unwrap<IndexedInterceptor>(info.This());
+ ObjectWrap::Unwrap<IndexedInterceptor>(info.Holder());
std::strncpy(interceptor->buf, "goober", sizeof (interceptor->buf));
info.GetReturnValue().Set(True());
}
diff --git a/test/cpp/isolatedata.cpp b/test/cpp/isolatedata.cpp
index 7005ae1..bc2f090 100644
--- a/test/cpp/isolatedata.cpp
+++ b/test/cpp/isolatedata.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/makecallback.cpp b/test/cpp/makecallback.cpp
index 7bcfe1a..2206bcd 100644
--- a/test/cpp/makecallback.cpp
+++ b/test/cpp/makecallback.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/morenews.cpp b/test/cpp/morenews.cpp
index 9cb8291..0ea410f 100644
--- a/test/cpp/morenews.cpp
+++ b/test/cpp/morenews.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/multifile1.cpp b/test/cpp/multifile1.cpp
index 59da9d5..ccc822b 100644
--- a/test/cpp/multifile1.cpp
+++ b/test/cpp/multifile1.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/multifile2.cpp b/test/cpp/multifile2.cpp
index e779ac1..999c0eb 100644
--- a/test/cpp/multifile2.cpp
+++ b/test/cpp/multifile2.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/multifile2.h b/test/cpp/multifile2.h
index 49f8b42..7c464a3 100644
--- a/test/cpp/multifile2.h
+++ b/test/cpp/multifile2.h
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/namedinterceptors.cpp b/test/cpp/namedinterceptors.cpp
index eea991b..e308ef6 100644
--- a/test/cpp/namedinterceptors.cpp
+++ b/test/cpp/namedinterceptors.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
@@ -72,7 +72,7 @@ NAN_METHOD(NamedInterceptor::New) {
NAN_PROPERTY_GETTER(NamedInterceptor::PropertyGetter) {
NamedInterceptor* interceptor =
- ObjectWrap::Unwrap<NamedInterceptor>(info.This());
+ ObjectWrap::Unwrap<NamedInterceptor>(info.Holder());
if (!std::strcmp(*v8::String::Utf8Value(property), "prop")) {
info.GetReturnValue().Set(Nan::New(interceptor->buf).ToLocalChecked());
} else {
@@ -82,7 +82,7 @@ NAN_PROPERTY_GETTER(NamedInterceptor::PropertyGetter) {
NAN_PROPERTY_SETTER(NamedInterceptor::PropertySetter) {
NamedInterceptor* interceptor =
- ObjectWrap::Unwrap<NamedInterceptor>(info.This());
+ ObjectWrap::Unwrap<NamedInterceptor>(info.Holder());
if (!std::strcmp(*v8::String::Utf8Value(property), "prop")) {
std::strncpy(
interceptor->buf
@@ -102,7 +102,7 @@ NAN_PROPERTY_ENUMERATOR(NamedInterceptor::PropertyEnumerator) {
NAN_PROPERTY_DELETER(NamedInterceptor::PropertyDeleter) {
NamedInterceptor* interceptor =
- ObjectWrap::Unwrap<NamedInterceptor>(info.This());
+ ObjectWrap::Unwrap<NamedInterceptor>(info.Holder());
std::strncpy(interceptor->buf, "goober", sizeof (interceptor->buf));
info.GetReturnValue().Set(True());
}
diff --git a/test/cpp/nancallback.cpp b/test/cpp/nancallback.cpp
index 85a40cc..048f3fa 100644
--- a/test/cpp/nancallback.cpp
+++ b/test/cpp/nancallback.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/nannew.cpp b/test/cpp/nannew.cpp
index 3934588..4999b71 100644
--- a/test/cpp/nannew.cpp
+++ b/test/cpp/nannew.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
@@ -319,7 +319,7 @@ NAN_METHOD(testString) {
t.ok(_( stringMatches( New("Hello World", 4).ToLocalChecked(), "Hell")));
t.ok(_( assertType<String>( New("plonk.", 4).ToLocalChecked())));
- const uint16_t *widestring = reinterpret_cast<const uint16_t *>("H\0e\0l\0l\0o\0");
+ const uint16_t widestring[] = {'H', 'e', 'l', 'l', 'o', '\0'};
t.ok(_( stringMatches( New(widestring, 4).ToLocalChecked(), "Hell")));
t.ok(_( assertType<String>( New(widestring, 4).ToLocalChecked())));
diff --git a/test/cpp/news.cpp b/test/cpp/news.cpp
index 11bdf91..962bc95 100644
--- a/test/cpp/news.cpp
+++ b/test/cpp/news.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/objectwraphandle.cpp b/test/cpp/objectwraphandle.cpp
index ca8a07a..586caab 100644
--- a/test/cpp/objectwraphandle.cpp
+++ b/test/cpp/objectwraphandle.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
@@ -20,8 +20,9 @@ class MyObject : public ObjectWrap {
SetPrototypeMethod(tpl, "getHandle", GetHandle);
SetPrototypeMethod(tpl, "getValue", GetValue);
- constructor().Reset(tpl->GetFunction());
- Set(target, Nan::New("MyObject").ToLocalChecked(), tpl->GetFunction());
+ constructor().Reset(Nan::GetFunction(tpl).ToLocalChecked());
+ Set(target, Nan::New("MyObject").ToLocalChecked(),
+ Nan::GetFunction(tpl).ToLocalChecked());
}
private:
@@ -30,7 +31,8 @@ class MyObject : public ObjectWrap {
static NAN_METHOD(New) {
if (info.IsConstructCall()) {
- double value = info[0]->IsUndefined() ? 0 : info[0]->NumberValue();
+ double value =
+ info[0]->IsUndefined() ? 0 : Nan::To<double>(info[0]).FromJust();
MyObject *obj = new MyObject(value);
obj->Wrap(info.This());
info.GetReturnValue().Set(info.This());
@@ -43,12 +45,12 @@ class MyObject : public ObjectWrap {
}
static NAN_METHOD(GetHandle) {
- MyObject* obj = ObjectWrap::Unwrap<MyObject>(info.This());
+ MyObject* obj = ObjectWrap::Unwrap<MyObject>(info.Holder());
info.GetReturnValue().Set(obj->handle());
}
static NAN_METHOD(GetValue) {
- MyObject* obj = ObjectWrap::Unwrap<MyObject>(info.This());
+ MyObject* obj = ObjectWrap::Unwrap<MyObject>(info.Holder());
info.GetReturnValue().Set(obj->value_);
}
diff --git a/test/cpp/persistent.cpp b/test/cpp/persistent.cpp
index 7a333b3..e28b17c 100644
--- a/test/cpp/persistent.cpp
+++ b/test/cpp/persistent.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
@@ -15,7 +15,6 @@ static Persistent<v8::String> persistentTest1;
NAN_METHOD(Save1) {
persistentTest1.Reset(info[0].As<v8::String>());
- info.GetReturnValue().SetUndefined();
}
NAN_METHOD(Get1) {
@@ -24,7 +23,6 @@ NAN_METHOD(Get1) {
NAN_METHOD(Dispose1) {
persistentTest1.Reset();
- info.GetReturnValue().SetUndefined();
}
NAN_METHOD(ToPersistentAndBackAgain) {
@@ -39,8 +37,8 @@ NAN_METHOD(PersistentToPersistent) {
Persistent<v8::String> persistent(info[0].As<v8::String>());
persistentTest1.Reset(persistent);
persistent.Reset();
+ info.GetReturnValue().Set(New(persistentTest1));
persistentTest1.Reset();
- info.GetReturnValue().SetUndefined();
}
NAN_METHOD(CopyablePersistent) {
@@ -49,30 +47,46 @@ NAN_METHOD(CopyablePersistent) {
info.GetReturnValue().Set(New(p));
}
+template<typename T> Global<T> passer(v8::Local<T> handle) {
+ return Global<T>(handle).Pass();
+}
+
+NAN_METHOD(PassGlobal) {
+ info.GetReturnValue().Set(passer(New(42)));
+}
+
NAN_MODULE_INIT(Init) {
Set(target
, New<v8::String>("save1").ToLocalChecked()
- , New<v8::FunctionTemplate>(Save1)->GetFunction()
+ , GetFunction(New<v8::FunctionTemplate>(Save1)).ToLocalChecked()
);
Set(target
, New<v8::String>("get1").ToLocalChecked()
- , New<v8::FunctionTemplate>(Get1)->GetFunction()
+ , GetFunction(New<v8::FunctionTemplate>(Get1)).ToLocalChecked()
);
Set(target
, New<v8::String>("dispose1").ToLocalChecked()
- , New<v8::FunctionTemplate>(Dispose1)->GetFunction()
+ , GetFunction(New<v8::FunctionTemplate>(Dispose1)).ToLocalChecked()
);
Set(target
, New<v8::String>("toPersistentAndBackAgain").ToLocalChecked()
- , New<v8::FunctionTemplate>(ToPersistentAndBackAgain)->GetFunction()
+ , GetFunction(New<v8::FunctionTemplate>(ToPersistentAndBackAgain))
+ .ToLocalChecked()
);
Set(target
, New<v8::String>("persistentToPersistent").ToLocalChecked()
- , New<v8::FunctionTemplate>(PersistentToPersistent)->GetFunction()
+ , GetFunction(New<v8::FunctionTemplate>(PersistentToPersistent))
+ .ToLocalChecked()
);
Set(target
, New<v8::String>("copyablePersistent").ToLocalChecked()
- , New<v8::FunctionTemplate>(CopyablePersistent)->GetFunction()
+ , GetFunction(New<v8::FunctionTemplate>(CopyablePersistent))
+ .ToLocalChecked()
+ );
+ Set(target
+ , New<v8::String>("passGlobal").ToLocalChecked()
+ , GetFunction(New<v8::FunctionTemplate>(PassGlobal))
+ .ToLocalChecked()
);
}
diff --git a/test/cpp/returnemptystring.cpp b/test/cpp/returnemptystring.cpp
index 734c3c8..9842315 100644
--- a/test/cpp/returnemptystring.cpp
+++ b/test/cpp/returnemptystring.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/returnnull.cpp b/test/cpp/returnnull.cpp
index f5869b1..3ec691f 100644
--- a/test/cpp/returnnull.cpp
+++ b/test/cpp/returnnull.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/returnundefined.cpp b/test/cpp/returnundefined.cpp
index 4c921d3..c98f8a7 100644
--- a/test/cpp/returnundefined.cpp
+++ b/test/cpp/returnundefined.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/returnvalue.cpp b/test/cpp/returnvalue.cpp
index 9763fa7..afecece 100644
--- a/test/cpp/returnvalue.cpp
+++ b/test/cpp/returnvalue.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/setcallhandler.cpp b/test/cpp/setcallhandler.cpp
index c0d1f60..3b5e246 100644
--- a/test/cpp/setcallhandler.cpp
+++ b/test/cpp/setcallhandler.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/settemplate.cpp b/test/cpp/settemplate.cpp
index 40c5933..a1d49e9 100644
--- a/test/cpp/settemplate.cpp
+++ b/test/cpp/settemplate.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/strings.cpp b/test/cpp/strings.cpp
index 5c6517f..7c7bdb3 100644
--- a/test/cpp/strings.cpp
+++ b/test/cpp/strings.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/symbols.cpp b/test/cpp/symbols.cpp
index a2ddd41..bf323a0 100644
--- a/test/cpp/symbols.cpp
+++ b/test/cpp/symbols.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/threadlocal.cpp b/test/cpp/threadlocal.cpp
index b6ece4e..b071552 100644
--- a/test/cpp/threadlocal.cpp
+++ b/test/cpp/threadlocal.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/trycatch.cpp b/test/cpp/trycatch.cpp
index 3318e07..f164719 100644
--- a/test/cpp/trycatch.cpp
+++ b/test/cpp/trycatch.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/typedarrays.cpp b/test/cpp/typedarrays.cpp
index 0923347..6b9eef6 100644
--- a/test/cpp/typedarrays.cpp
+++ b/test/cpp/typedarrays.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/weak.cpp b/test/cpp/weak.cpp
index cfdf236..fcf7960 100644
--- a/test/cpp/weak.cpp
+++ b/test/cpp/weak.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/weak2.cpp b/test/cpp/weak2.cpp
index 9e4d277..098e336 100644
--- a/test/cpp/weak2.cpp
+++ b/test/cpp/weak2.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/cpp/wrappedobjectfactory.cpp b/test/cpp/wrappedobjectfactory.cpp
index 9833b4f..3e511c6 100644
--- a/test/cpp/wrappedobjectfactory.cpp
+++ b/test/cpp/wrappedobjectfactory.cpp
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
@@ -23,7 +23,8 @@ class InnerObject : public ObjectWrap {
constructor().Reset(GetFunction(tpl).ToLocalChecked());
}
- static v8::Local<v8::Object> NewInstance(int argc, v8::Local<v8::Value> argv[]) {
+ static
+ v8::Local<v8::Object> NewInstance(int argc, v8::Local<v8::Value> argv[]) {
v8::Local<v8::Function> cons = Nan::New(constructor());
return Nan::NewInstance(cons, argc, argv).ToLocalChecked();
}
@@ -42,12 +43,13 @@ class InnerObject : public ObjectWrap {
const int argc = 1;
v8::Local<v8::Value> argv[argc] = {info[0]};
v8::Local<v8::Function> cons = Nan::New(constructor());
- info.GetReturnValue().Set(Nan::NewInstance(cons, argc, argv).ToLocalChecked());
+ info.GetReturnValue().Set(
+ Nan::NewInstance(cons, argc, argv).ToLocalChecked());
}
}
static NAN_METHOD(GetValue) {
- InnerObject* obj = ObjectWrap::Unwrap<InnerObject>(info.This());
+ InnerObject* obj = ObjectWrap::Unwrap<InnerObject>(info.Holder());
info.GetReturnValue().Set(obj->value_);
}
@@ -76,7 +78,8 @@ class MyObject : public ObjectWrap {
double value = info[0]->IsNumber() ? To<double>(info[0]).FromJust() : 0;
const int argc = 1;
v8::Local<v8::Value> argv[1] = {Nan::New(value)};
- info.GetReturnValue().Set(Nan::NewInstance(cons, argc, argv).ToLocalChecked());
+ info.GetReturnValue().Set(
+ Nan::NewInstance(cons, argc, argv).ToLocalChecked());
}
private:
@@ -93,12 +96,13 @@ class MyObject : public ObjectWrap {
const int argc = 1;
v8::Local<v8::Value> argv[argc] = {info[0]};
v8::Local<v8::Function> cons = Nan::New(constructor());
- info.GetReturnValue().Set(Nan::NewInstance(cons, argc, argv).ToLocalChecked());
+ info.GetReturnValue().Set(
+ Nan::NewInstance(cons, argc, argv).ToLocalChecked());
}
}
static NAN_METHOD(GetValue) {
- MyObject* obj = ObjectWrap::Unwrap<MyObject>(info.This());
+ MyObject* obj = ObjectWrap::Unwrap<MyObject>(info.Holder());
info.GetReturnValue().Set(obj->value_);
}
@@ -117,11 +121,16 @@ class MyObject : public ObjectWrap {
};
NAN_MODULE_INIT(Init) {
+ Nan::HandleScope scope;
+
InnerObject::Init(target);
MyObject::Init(target);
+ v8::Local<v8::FunctionTemplate> tpl =
+ New<v8::FunctionTemplate>(MyObject::NewInstance);
+
Set(target
, New<v8::String>("newFactoryObjectInstance").ToLocalChecked()
- , GetFunction(New<v8::FunctionTemplate>(MyObject::NewInstance)).ToLocalChecked()
+ , GetFunction(tpl).ToLocalChecked()
);
}
diff --git a/test/js/accessors-test.js b/test/js/accessors-test.js
index 7650681..0ddc51e 100644
--- a/test/js/accessors-test.js
+++ b/test/js/accessors-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
@@ -11,7 +11,7 @@ const test = require('tap').test
, bindings = require('bindings')({ module_root: testRoot, bindings: 'accessors' });
test('accessors', function (t) {
- t.plan(4)
+ t.plan(7)
var settergetter = bindings.create()
t.equal(settergetter.prop1, 'this is property 1')
t.ok(settergetter.prop2 === '')
@@ -24,4 +24,9 @@ test('accessors', function (t) {
'Prop2:SETTER(setting a value)\n' +
'Prop2:GETTER(setting a value)\n'
)
+ var derived = Object.create(settergetter)
+ t.equal(derived.prop1, 'this is property 1')
+ derived.prop2 = 'setting a new value'
+ t.equal(derived.prop2, 'setting a new value')
+ t.equal(settergetter.prop2, 'setting a new value')
})
diff --git a/test/js/accessors2-test.js b/test/js/accessors2-test.js
index 8fdb5b8..7869dea 100644
--- a/test/js/accessors2-test.js
+++ b/test/js/accessors2-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/asyncprogressworker-test.js b/test/js/asyncprogressworker-test.js
index 654595f..16df7c2 100644
--- a/test/js/asyncprogressworker-test.js
+++ b/test/js/asyncprogressworker-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/asyncworker-test.js b/test/js/asyncworker-test.js
index 51cea0c..39e18c0 100644
--- a/test/js/asyncworker-test.js
+++ b/test/js/asyncworker-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/asyncworkererror-test.js b/test/js/asyncworkererror-test.js
index 5ec4bc8..3adb2e1 100644
--- a/test/js/asyncworkererror-test.js
+++ b/test/js/asyncworkererror-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/buffer-test.js b/test/js/buffer-test.js
index 2c64856..a9dfce2 100644
--- a/test/js/buffer-test.js
+++ b/test/js/buffer-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/bufferworkerpersistent-test.js b/test/js/bufferworkerpersistent-test.js
index a6f4b17..e12fc82 100644
--- a/test/js/bufferworkerpersistent-test.js
+++ b/test/js/bufferworkerpersistent-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/converters-test.js b/test/js/converters-test.js
index ac9aaec..7d32c21 100644
--- a/test/js/converters-test.js
+++ b/test/js/converters-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/error-test.js b/test/js/error-test.js
index 1d2e009..98774b0 100644
--- a/test/js/error-test.js
+++ b/test/js/error-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/gc-test.js b/test/js/gc-test.js
index 90d03e8..57ec184 100644
--- a/test/js/gc-test.js
+++ b/test/js/gc-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/indexedinterceptors-test.js b/test/js/indexedinterceptors-test.js
index 2c07ebc..5a5a471 100644
--- a/test/js/indexedinterceptors-test.js
+++ b/test/js/indexedinterceptors-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/isolatedata-test.js b/test/js/isolatedata-test.js
index e131f3c..0673df0 100644
--- a/test/js/isolatedata-test.js
+++ b/test/js/isolatedata-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/makecallback-test.js b/test/js/makecallback-test.js
index d014882..bc94fb6 100644
--- a/test/js/makecallback-test.js
+++ b/test/js/makecallback-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/morenews-test.js b/test/js/morenews-test.js
index 54dea2d..675b0ea 100644
--- a/test/js/morenews-test.js
+++ b/test/js/morenews-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/multifile-test.js b/test/js/multifile-test.js
index 3d0c96e..f5e1047 100644
--- a/test/js/multifile-test.js
+++ b/test/js/multifile-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/namedinterceptors-test.js b/test/js/namedinterceptors-test.js
index 8c548f6..55a917d 100644
--- a/test/js/namedinterceptors-test.js
+++ b/test/js/namedinterceptors-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/nancallback-test.js b/test/js/nancallback-test.js
index f766f2e..9728d19 100644
--- a/test/js/nancallback-test.js
+++ b/test/js/nancallback-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/nannew-test.js b/test/js/nannew-test.js
index 87b8dbc..4b87f7b 100644
--- a/test/js/nannew-test.js
+++ b/test/js/nannew-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/news-test.js b/test/js/news-test.js
index 1062430..a6cbd05 100644
--- a/test/js/news-test.js
+++ b/test/js/news-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/objectwraphandle-test.js b/test/js/objectwraphandle-test.js
index d4c3913..5082705 100644
--- a/test/js/objectwraphandle-test.js
+++ b/test/js/objectwraphandle-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
@@ -11,7 +11,7 @@ const test = require('tap').test
, bindings = require('bindings')({ module_root: testRoot, bindings: 'objectwraphandle' });
test('objectwraphandle', function (t) {
- t.plan(5);
+ t.plan(7);
t.type(bindings.MyObject, 'function');
@@ -21,4 +21,14 @@ test('objectwraphandle', function (t) {
t.type(obj.getValue, 'function');
t.type(obj.getHandle(), 'object');
t.type(obj.getValue(), 'number');
+
+ var derived = Object.create(obj);
+ t.type(derived, bindings.MyObject);
+ try {
+ // In Node 0.10 this call is valid:
+ t.equal(derived.getValue(), 10);
+ } catch (err) {
+ // In Node >= 0.12 it throws instead:
+ t.type(err, TypeError);
+ }
});
diff --git a/test/js/persistent-test.js b/test/js/persistent-test.js
index d910507..b7dd33f 100644
--- a/test/js/persistent-test.js
+++ b/test/js/persistent-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
@@ -11,7 +11,7 @@ const test = require('tap').test
, bindings = require('bindings')({ module_root: testRoot, bindings: 'persistent' });
test('persistent', function (t) {
- t.plan(14);
+ t.plan(15);
var persistent = bindings;
t.type(persistent.save1, 'function');
@@ -20,26 +20,22 @@ test('persistent', function (t) {
t.type(persistent.toPersistentAndBackAgain, 'function');
t.type(persistent.persistentToPersistent, 'function');
t.type(persistent.copyablePersistent, 'function');
+ t.type(persistent.passGlobal, 'function');
+
t.deepEqual(persistent.toPersistentAndBackAgain({ x: 42 }), { x: 42 });
- t.ok(persistent.persistentToPersistent('any string') || true);
+ t.equal(persistent.persistentToPersistent('any string'), 'any string');
persistent.save1('a string to save');
t.equal(persistent.get1(), 'a string to save');
+ t.equal(persistent.copyablePersistent(), 'a string to save');
+
+ t.equal(persistent.passGlobal(), 42, 'pass global');
+
setTimeout(function () {
t.equal(persistent.get1(), 'a string to save');
- }, 25);
- setTimeout(function () {
- t.equal(persistent.get1(), 'a string to save');
- }, 50);
- setTimeout(function () {
- t.equal(persistent.copyablePersistent(), 'a string to save');
- }, 75);
- setTimeout(function () {
persistent.dispose1();
- }, 75);
- setTimeout(function () {
t.ok(persistent.get1() === undefined, 'no more persistent');
t.ok(persistent.copyablePersistent() === undefined, 'no more persistent');
- }, 100);
+ }, 25);
});
diff --git a/test/js/returnemptystring-test.js b/test/js/returnemptystring-test.js
index 9dbb042..2d47be9 100644
--- a/test/js/returnemptystring-test.js
+++ b/test/js/returnemptystring-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/returnnull-test.js b/test/js/returnnull-test.js
index 4c75933..fd1a415 100644
--- a/test/js/returnnull-test.js
+++ b/test/js/returnnull-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/returnundefined-test.js b/test/js/returnundefined-test.js
index b260d2b..8911af5 100644
--- a/test/js/returnundefined-test.js
+++ b/test/js/returnundefined-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/returnvalue-test.js b/test/js/returnvalue-test.js
index 1b818f6..bd551e9 100644
--- a/test/js/returnvalue-test.js
+++ b/test/js/returnvalue-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/setcallhandler-test.js b/test/js/setcallhandler-test.js
index d39ab47..e4f1418 100644
--- a/test/js/setcallhandler-test.js
+++ b/test/js/setcallhandler-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/settemplate-test.js b/test/js/settemplate-test.js
index e1e215b..9ead91e 100644
--- a/test/js/settemplate-test.js
+++ b/test/js/settemplate-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/strings-test.js b/test/js/strings-test.js
index c0f5c59..aa3467d 100644
--- a/test/js/strings-test.js
+++ b/test/js/strings-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/symbols-test.js b/test/js/symbols-test.js
index fd7edef..d22af35 100644
--- a/test/js/symbols-test.js
+++ b/test/js/symbols-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/threadlocal-test.js b/test/js/threadlocal-test.js
index 554111c..a8c1385 100644
--- a/test/js/threadlocal-test.js
+++ b/test/js/threadlocal-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/trycatch-test.js b/test/js/trycatch-test.js
index 0a90fab..67c501d 100644
--- a/test/js/trycatch-test.js
+++ b/test/js/trycatch-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/typedarrays-test.js b/test/js/typedarrays-test.js
index 0b02b5c..debef10 100644
--- a/test/js/typedarrays-test.js
+++ b/test/js/typedarrays-test.js
@@ -1,3 +1,11 @@
+/*********************************************************************
+ * 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: 'typedarrays' });
diff --git a/test/js/weak-test.js b/test/js/weak-test.js
index 6e40499..5c91590 100644
--- a/test/js/weak-test.js
+++ b/test/js/weak-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/weak2-test.js b/test/js/weak2-test.js
index dff05b6..5658fa1 100644
--- a/test/js/weak2-test.js
+++ b/test/js/weak2-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/test/js/wrappedobjectfactory-test.js b/test/js/wrappedobjectfactory-test.js
index 6b8eafa..75e9179 100644
--- a/test/js/wrappedobjectfactory-test.js
+++ b/test/js/wrappedobjectfactory-test.js
@@ -1,7 +1,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
diff --git a/tools/1to2.js b/tools/1to2.js
index 3c29575..b7498e4 100755
--- a/tools/1to2.js
+++ b/tools/1to2.js
@@ -2,7 +2,7 @@
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
- * Copyright (c) 2015 NAN contributors
+ * Copyright (c) 2016 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
@@ -17,7 +17,7 @@ var commander = require('commander'),
length,
i;
-fs.readFile('package.json', 'utf8', function (err, data) {
+fs.readFile(__dirname + '/package.json', 'utf8', function (err, data) {
if (err) {
throw err;
}
--
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