Commit afe17280 authored by Jérémy Lal's avatar Jérémy Lal

Imported Upstream version 2.2.0

parent 0f957b0b
......@@ -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@vagg.org
......
# 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
......
The MIT License (MIT)
=====================
Copyright (c) 2015 NAN contributors
Copyright (c) 2016 NAN contributors
-----------------------------------
*NAN contributors listed at <https://github.com/nodejs/nan#contributors>*
......
......@@ -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 \
......
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 &amp; 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.
......@@ -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:
......
#!/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
......@@ -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()
......
......@@ -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>
......
## 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()
......
## 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));
```
......@@ -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>
......
/*********************************************************************
* 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>
********************************************************************/
......
/*********************************************************************
* 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>
********************************************************************/
......
/*********************************************************************
* 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>
********************************************************************/
......
/*********************************************************************
* 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>
********************************************************************/
......
/*********************************************************************
* 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>
********************************************************************/
......
/*********************************************************************
* 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>
********************************************************************/
......
/*********************************************************************
* 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>
********************************************************************/
......
/*********************************************************************
* 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>
********************************************************************/
......
/*********************************************************************
* 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);
}