...
 
Commits (3)
......@@ -6,4 +6,5 @@ examples/
appveyor.yml
Makefile
cpplint.py
nan-*.tgz
doc/.build.sh
......@@ -12,7 +12,6 @@ addons:
- g++-4.8
env:
matrix:
- TRAVIS_NODE_VERSION="0.8"
- TRAVIS_NODE_VERSION="0.10"
- TRAVIS_NODE_VERSION="0.12"
- TRAVIS_NODE_VERSION="4"
......@@ -22,6 +21,7 @@ env:
- TRAVIS_NODE_VERSION="8"
- TRAVIS_NODE_VERSION="9"
- TRAVIS_NODE_VERSION="10"
- TRAVIS_NODE_VERSION="11"
matrix:
exclude:
- os: osx
......
# NAN ChangeLog
**Version 2.11.1: current Node 10.11.0, Node 0.12: 0.12.18, Node 0.10: 0.10.48, iojs: 3.3.1**
**Version 2.12.1: current Node 11.4.0, Node 0.12: 0.12.18, Node 0.10: 0.10.48, iojs: 3.3.1**
### 2.12.1 Dec 18 2018
- Bugfix: Fix build breakage with Node.js 10.0.0-10.9.0. (#833) 625e90e8fef8d39ffa7247250a76a100b2487474
### 2.12.0 Dec 16 2018
- Bugfix: Add scope.Escape() to Call() (#817) 2e5ed4fc3a8ac80a6ef1f2a55099ab3ac8800dc6
- Bugfix: Fix Node.js v10.12.0 deprecation warnings. 509859cc23b1770376b56550a027840a2ce0f73d
- Feature: Allow SetWeak() for non-object persistent handles. (#824) e6ef6a48e7e671fe3e4b7dddaa8912a3f8262ecd
### 2.11.1 Sep 29 2018
- Fix: adapt to V8 7.0 24a22c3b25eeeec2016c6ec239bdd6169e985447
- Fix: adapt to V8 7.0 24a22c3b25eeeec2016c6ec239bdd6169e985447
### 2.11.0 Aug 25 2018
......
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, 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10.**
**A header file filled with macro and utility goodness for making add-on development for Node.js easier across versions 0.8, 0.10, 0.12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 and 11.**
***Current version: 2.11.1***
***Current version: 2.12.1***
*(See [CHANGELOG.md](https://github.com/nodejs/nan/blob/master/CHANGELOG.md) for complete ChangeLog)*
[![NPM](https://nodei.co/npm/nan.png?downloads=true&downloadRank=true)](https://nodei.co/npm/nan/) [![NPM](https://nodei.co/npm-dl/nan.png?months=6&height=3)](https://nodei.co/npm/nan/)
[![Build Status](https://api.travis-ci.org/nodejs/nan.svg?branch=master)](http://travis-ci.org/nodejs/nan)
[![Build Status](https://api.travis-ci.org/nodejs/nan.svg?branch=master)](https://travis-ci.org/nodejs/nan)
[![Build status](https://ci.appveyor.com/api/projects/status/kh73pbm9dsju7fgh)](https://ci.appveyor.com/project/RodVagg/nan)
Thanks to the crazy changes in V8 (and some in Node core), keeping native addons compiling happily across versions, particularly 0.10 to 0.12 to 4.0, is a minor nightmare. The goal of this project is to store all logic necessary to develop native Node.js addons without having to inspect `NODE_MODULE_VERSION` and get yourself into a macro-tangle.
......@@ -70,7 +70,7 @@ Additional to the NAN documentation below, please consult:
* [The V8 Getting Started * Guide](https://github.com/v8/v8/wiki/Getting%20Started%20with%20Embedding)
* [The V8 Embedders * Guide](https://github.com/v8/v8/wiki/Embedder%27s%20Guide)
* [V8 API Documentation](http://v8docs.nodesource.com/)
* [V8 API Documentation](https://v8docs.nodesource.com/)
* [Node Add-on Documentation](https://nodejs.org/api/addons.html)
<!-- START API -->
......@@ -219,7 +219,7 @@ The _JSON_ object provides the c++ versions of the methods offered by the `JSON`
- <a href="doc/json.md#api_nan_json_parse"><b><code>Nan::JSON.Parse</code></b></a>
- <a href="doc/json.md#api_nan_json_stringify"><b><code>Nan::JSON.Stringify</code></b></a>
Refer to the V8 JSON object in the [V8 documentation](https://v8docs.nodesource.com/node-7.4/da/d6f/classv8_1_1_j_s_o_n.html) for more information about these methods and their arguments.
Refer to the V8 JSON object in the [V8 documentation](https://v8docs.nodesource.com/node-8.11/da/d6f/classv8_1_1_j_s_o_n.html) for more information about these methods and their arguments.
### Errors
......@@ -400,7 +400,7 @@ For the current list of WG members / Collaborators, see the project [README.md](
### Consensus Seeking Process
The WG follows a [Consensus Seeking](http://en.wikipedia.org/wiki/Consensus-seeking_decision-making) decision making model.
The WG follows a [Consensus Seeking](https://en.wikipedia.org/wiki/Consensus-seeking_decision-making) decision making model.
Modifications of the contents of the NAN repository are made on a collaborative basis. Anybody with a GitHub account may propose a modification via pull request and it will be considered by the WG. All pull requests must be reviewed and accepted by a WG member with sufficient expertise who is able to take full responsibility for the change. In the case of pull requests proposed by an existing WG member, an additional WG member is required for sign-off. Consensus should be sought if additional WG members participate and there is disagreement around a particular modification.
......
......@@ -14,6 +14,7 @@ environment:
- nodejs_version: "8"
- nodejs_version: "9"
- nodejs_version: "10"
- nodejs_version: "11"
# Install scripts. (runs after repo cloning)
install:
......
node-nan (2.12.1-1) unstable; urgency=medium
* New upstream version 2.12.1
-- Jérémy Lal <kapouer@melix.org> Wed, 02 Jan 2019 15:59:33 +0100
node-nan (2.11.1-1) unstable; urgency=medium
* New upstream version 2.11.1
......
......@@ -143,4 +143,4 @@ Definition:
void AsyncQueueWorker(AsyncWorker *);
```
[AsyncResource]: "node_misc.html#api_nan_asyncresource"
[AsyncResource]: node_misc.md#api_nan_asyncresource
......@@ -24,7 +24,7 @@ Also consult the V8 Embedders Guide section on [Exceptions](https://developers.g
<a name="api_nan_error"></a>
### Nan::Error()
Create a new Error object using the [v8::Exception](https://v8docs.nodesource.com/io.js-3.3/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
Create a new Error object using the [v8::Exception](https://v8docs.nodesource.com/node-8.11/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
Note that an Error object is simply a specialized form of `v8::Value`.
......@@ -39,7 +39,7 @@ v8::Local<v8::Value> Nan::Error(v8::Local<v8::String> msg);
<a name="api_nan_range_error"></a>
### Nan::RangeError()
Create a new RangeError object using the [v8::Exception](https://v8docs.nodesource.com/io.js-3.3/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
Create a new RangeError object using the [v8::Exception](https://v8docs.nodesource.com/node-8.11/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
Note that an RangeError object is simply a specialized form of `v8::Value`.
......@@ -54,7 +54,7 @@ v8::Local<v8::Value> Nan::RangeError(v8::Local<v8::String> msg);
<a name="api_nan_reference_error"></a>
### Nan::ReferenceError()
Create a new ReferenceError object using the [v8::Exception](https://v8docs.nodesource.com/io.js-3.3/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
Create a new ReferenceError object using the [v8::Exception](https://v8docs.nodesource.com/node-8.11/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
Note that an ReferenceError object is simply a specialized form of `v8::Value`.
......@@ -69,7 +69,7 @@ v8::Local<v8::Value> Nan::ReferenceError(v8::Local<v8::String> msg);
<a name="api_nan_syntax_error"></a>
### Nan::SyntaxError()
Create a new SyntaxError object using the [v8::Exception](https://v8docs.nodesource.com/io.js-3.3/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
Create a new SyntaxError object using the [v8::Exception](https://v8docs.nodesource.com/node-8.11/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
Note that an SyntaxError object is simply a specialized form of `v8::Value`.
......@@ -84,7 +84,7 @@ v8::Local<v8::Value> Nan::SyntaxError(v8::Local<v8::String> msg);
<a name="api_nan_type_error"></a>
### Nan::TypeError()
Create a new TypeError object using the [v8::Exception](https://v8docs.nodesource.com/io.js-3.3/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
Create a new TypeError object using the [v8::Exception](https://v8docs.nodesource.com/node-8.11/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
Note that an TypeError object is simply a specialized form of `v8::Value`.
......@@ -194,7 +194,7 @@ v8::Local<v8::Value> Nan::ErrnoException(int errorno,
<a name="api_nan_try_catch"></a>
### Nan::TryCatch
A simple wrapper around [`v8::TryCatch`](https://v8docs.nodesource.com/io.js-3.3/d4/dc6/classv8_1_1_try_catch.html) compatible with all supported versions of V8. Can be used as a direct replacement in most cases. See also [`Nan::FatalException()`](#api_nan_fatal_exception) for an internal use compatible with `node::FatalException`.
A simple wrapper around [`v8::TryCatch`](https://v8docs.nodesource.com/node-8.11/d4/dc6/classv8_1_1_try_catch.html) compatible with all supported versions of V8. Can be used as a direct replacement in most cases. See also [`Nan::FatalException()`](#api_nan_fatal_exception) for an internal use compatible with `node::FatalException`.
Signature:
......
......@@ -5,13 +5,13 @@ The _JSON_ object provides the c++ versions of the methods offered by the `JSON`
- <a href="#api_nan_json_parse"><b><code>Nan::JSON.Parse</code></b></a>
- <a href="#api_nan_json_stringify"><b><code>Nan::JSON.Stringify</code></b></a>
Refer to the V8 JSON object in the [V8 documentation](https://v8docs.nodesource.com/node-7.4/da/d6f/classv8_1_1_j_s_o_n.html) for more information about these methods and their arguments.
Refer to the V8 JSON object in the [V8 documentation](https://v8docs.nodesource.com/node-8.11/da/d6f/classv8_1_1_j_s_o_n.html) for more information about these methods and their arguments.
<a name="api_nan_json_parse"></a>
### Nan::JSON.Parse
A simple wrapper around [`v8::JSON::Parse`](https://v8docs.nodesource.com/node-7.4/da/d6f/classv8_1_1_j_s_o_n.html#a936310d2540fb630ed37d3ee3ffe4504).
A simple wrapper around [`v8::JSON::Parse`](https://v8docs.nodesource.com/node-8.11/da/d6f/classv8_1_1_j_s_o_n.html#a936310d2540fb630ed37d3ee3ffe4504).
Definition:
......@@ -37,7 +37,7 @@ if (!result.IsEmpty()) {
### Nan::JSON.Stringify
A simple wrapper around [`v8::JSON::Stringify`](https://v8docs.nodesource.com/node-7.4/da/d6f/classv8_1_1_j_s_o_n.html#a44b255c3531489ce43f6110209138860).
A simple wrapper around [`v8::JSON::Stringify`](https://v8docs.nodesource.com/node-8.11/da/d6f/classv8_1_1_j_s_o_n.html#a44b255c3531489ce43f6110209138860).
Definition:
......
This diff is collapsed.
......@@ -37,7 +37,7 @@ In order to expose functionality to JavaScript via a template, you must provide
<a name="api_nan_function_callback_info"></a>
### Nan::FunctionCallbackInfo
`Nan::FunctionCallbackInfo` should be used in place of [`v8::FunctionCallbackInfo`](https://v8docs.nodesource.com/node-8.0/dd/d0d/classv8_1_1_function_callback_info.html), even with older versions of Node where `v8::FunctionCallbackInfo` does not exist.
`Nan::FunctionCallbackInfo` should be used in place of [`v8::FunctionCallbackInfo`](https://v8docs.nodesource.com/node-8.11/dd/d0d/classv8_1_1_function_callback_info.html), even with older versions of Node where `v8::FunctionCallbackInfo` does not exist.
Definition:
......@@ -56,14 +56,14 @@ template<typename T> class FunctionCallbackInfo {
};
```
See the [`v8::FunctionCallbackInfo`](https://v8docs.nodesource.com/node-8.0/dd/d0d/classv8_1_1_function_callback_info.html) documentation for usage details on these. See [`Nan::ReturnValue`](#api_nan_return_value) for further information on how to set a return value from methods.
See the [`v8::FunctionCallbackInfo`](https://v8docs.nodesource.com/node-8.11/dd/d0d/classv8_1_1_function_callback_info.html) documentation for usage details on these. See [`Nan::ReturnValue`](#api_nan_return_value) for further information on how to set a return value from methods.
**Note:** `FunctionCallbackInfo::Callee` is removed in Node.js after `10.0.0` because it is was deprecated in V8. Consider using `info.Data()` to pass any information you need.
<a name="api_nan_property_callback_info"></a>
### Nan::PropertyCallbackInfo
`Nan::PropertyCallbackInfo` should be used in place of [`v8::PropertyCallbackInfo`](https://v8docs.nodesource.com/node-8.0/d7/dc5/classv8_1_1_property_callback_info.html), even with older versions of Node where `v8::PropertyCallbackInfo` does not exist.
`Nan::PropertyCallbackInfo` should be used in place of [`v8::PropertyCallbackInfo`](https://v8docs.nodesource.com/node-8.11/d7/dc5/classv8_1_1_property_callback_info.html), even with older versions of Node where `v8::PropertyCallbackInfo` does not exist.
Definition:
......@@ -78,12 +78,12 @@ template<typename T> class PropertyCallbackInfo : public PropertyCallbackInfoBas
};
```
See the [`v8::PropertyCallbackInfo`](https://v8docs.nodesource.com/node-8.0/d7/dc5/classv8_1_1_property_callback_info.html) documentation for usage details on these. See [`Nan::ReturnValue`](#api_nan_return_value) for further information on how to set a return value from property accessor methods.
See the [`v8::PropertyCallbackInfo`](https://v8docs.nodesource.com/node-8.11/d7/dc5/classv8_1_1_property_callback_info.html) documentation for usage details on these. See [`Nan::ReturnValue`](#api_nan_return_value) for further information on how to set a return value from property accessor methods.
<a name="api_nan_return_value"></a>
### Nan::ReturnValue
`Nan::ReturnValue` is used in place of [`v8::ReturnValue`](https://v8docs.nodesource.com/node-8.0/da/da7/classv8_1_1_return_value.html) on both [`Nan::FunctionCallbackInfo`](#api_nan_function_callback_info) and [`Nan::PropertyCallbackInfo`](#api_nan_property_callback_info) as the return type of `GetReturnValue()`.
`Nan::ReturnValue` is used in place of [`v8::ReturnValue`](https://v8docs.nodesource.com/node-8.11/da/da7/classv8_1_1_return_value.html) on both [`Nan::FunctionCallbackInfo`](#api_nan_function_callback_info) and [`Nan::PropertyCallbackInfo`](#api_nan_property_callback_info) as the return type of `GetReturnValue()`.
Example usage:
......@@ -118,7 +118,7 @@ template<typename T> class ReturnValue {
};
```
See the documentation on [`v8::ReturnValue`](https://v8docs.nodesource.com/node-8.0/da/da7/classv8_1_1_return_value.html) for further information on this.
See the documentation on [`v8::ReturnValue`](https://v8docs.nodesource.com/node-8.11/da/da7/classv8_1_1_return_value.html) for further information on this.
<a name="api_nan_method"></a>
### Method declaration
......@@ -522,7 +522,7 @@ bool SetAccessor(v8::Local<v8::Object> obj,
v8::PropertyAttribute attribute = v8::None)
```
See the V8 [`ObjectTemplate#SetAccessor()`](https://v8docs.nodesource.com/node-8.0/db/d5f/classv8_1_1_object_template.html#aca0ed196f8a9adb1f68b1aadb6c9cd77) and [`Object#SetAccessor()`](https://v8docs.nodesource.com/node-8.0/db/d85/classv8_1_1_object.html#a3f9dee085f5ec346465f1dc924325043) for further information about how to use `Nan::SetAccessor()`.
See the V8 [`ObjectTemplate#SetAccessor()`](https://v8docs.nodesource.com/node-8.11/db/d5f/classv8_1_1_object_template.html#aca0ed196f8a9adb1f68b1aadb6c9cd77) and [`Object#SetAccessor()`](https://v8docs.nodesource.com/node-8.11/db/d85/classv8_1_1_object.html#ae91b3b56b357f285288c89fbddc46d1b) for further information about how to use `Nan::SetAccessor()`.
<a name="api_nan_set_named_property_handler"></a>
### Nan::SetNamedPropertyHandler()
......@@ -547,7 +547,7 @@ void SetNamedPropertyHandler(v8::Local<v8::ObjectTemplate> tpl,
v8::Local<v8::Value> data = v8::Local<v8::Value>())
```
See the V8 [`ObjectTemplate#SetNamedPropertyHandler()`](https://v8docs.nodesource.com/io.js-3.3/db/d5f/classv8_1_1_object_template.html#a34d1cc45b642cd131706663801aadd76) for further information about how to use `Nan::SetNamedPropertyHandler()`.
See the V8 [`ObjectTemplate#SetNamedPropertyHandler()`](https://v8docs.nodesource.com/node-8.11/db/d5f/classv8_1_1_object_template.html#a33b3ebd7de641f6cc6414b7de01fc1c7) for further information about how to use `Nan::SetNamedPropertyHandler()`.
<a name="api_nan_set_indexed_property_handler"></a>
### Nan::SetIndexedPropertyHandler()
......@@ -572,7 +572,7 @@ void SetIndexedPropertyHandler(v8::Local<v8::ObjectTemplate> tpl,
v8::Local<v8::Value> data = v8::Local<v8::Value>())
```
See the V8 [`ObjectTemplate#SetIndexedPropertyHandler()`](https://v8docs.nodesource.com/node-8.0/db/d5f/classv8_1_1_object_template.html#ac89f06d634add0e890452033f7d17ff1) for further information about how to use `Nan::SetIndexedPropertyHandler()`.
See the V8 [`ObjectTemplate#SetIndexedPropertyHandler()`](https://v8docs.nodesource.com/node-8.11/db/d5f/classv8_1_1_object_template.html#ac89f06d634add0e890452033f7d17ff1) for further information about how to use `Nan::SetIndexedPropertyHandler()`.
<a name="api_nan_set_template"></a>
### Nan::SetTemplate()
......@@ -591,7 +591,7 @@ void Nan::SetTemplate(v8::Local<v8::Template> templ,
v8::PropertyAttribute attributes)
```
Calls the `Template`'s [`Set()`](https://v8docs.nodesource.com/node-8.0/db/df7/classv8_1_1_template.html#ae3fbaff137557aa6a0233bc7e52214ac).
Calls the `Template`'s [`Set()`](https://v8docs.nodesource.com/node-8.11/db/df7/classv8_1_1_template.html#ae3fbaff137557aa6a0233bc7e52214ac).
<a name="api_nan_set_prototype_template"></a>
### Nan::SetPrototypeTemplate()
......@@ -610,7 +610,7 @@ void Nan::SetPrototypeTemplate(v8::Local<v8::FunctionTemplate> templ,
v8::PropertyAttribute attributes)
```
Calls the `FunctionTemplate`'s _PrototypeTemplate's_ [`Set()`](https://v8docs.nodesource.com/io.js-3.3/db/df7/classv8_1_1_template.html#a2db6a56597bf23c59659c0659e564ddf).
Calls the `FunctionTemplate`'s _PrototypeTemplate's_ [`Set()`](https://v8docs.nodesource.com/node-8.11/db/df7/classv8_1_1_template.html#a2db6a56597bf23c59659c0659e564ddf).
<a name="api_nan_set_instance_template"></a>
### Nan::SetInstanceTemplate()
......@@ -629,7 +629,7 @@ void Nan::SetInstanceTemplate(v8::Local<v8::FunctionTemplate> templ,
v8::PropertyAttribute attributes)
```
Calls the `FunctionTemplate`'s _InstanceTemplate's_ [`Set()`](https://v8docs.nodesource.com/io.js-3.3/db/df7/classv8_1_1_template.html#a2db6a56597bf23c59659c0659e564ddf).
Calls the `FunctionTemplate`'s _InstanceTemplate's_ [`Set()`](https://v8docs.nodesource.com/node-8.11/db/df7/classv8_1_1_template.html#a2db6a56597bf23c59659c0659e564ddf).
<a name="api_nan_set_call_handler"></a>
### Nan::SetCallHandler()
......@@ -643,7 +643,7 @@ Signature:
void Nan::SetCallHandler(v8::Local<v8::FunctionTemplate> templ, Nan::FunctionCallback callback, v8::Local<v8::Value> data = v8::Local<v8::Value>())
```
Calls the `FunctionTemplate`'s [`SetCallHandler()`](https://v8docs.nodesource.com/node-8.0/d8/d83/classv8_1_1_function_template.html#a2d3845db66392074c5a018a66efbfada).
Calls the `FunctionTemplate`'s [`SetCallHandler()`](https://v8docs.nodesource.com/node-8.11/d8/d83/classv8_1_1_function_template.html#ab7574b298db3c27fbc2ed465c08ea2f8).
<a name="api_nan_set_call_as_function_handler"></a>
### Nan::SetCallAsFunctionHandler()
......@@ -657,5 +657,5 @@ Signature:
void Nan::SetCallAsFunctionHandler(v8::Local<v8::ObjectTemplate> templ, Nan::FunctionCallback callback, v8::Local<v8::Value> data = v8::Local<v8::Value>())
```
Calls the `ObjectTemplate`'s [`SetCallAsFunctionHandler()`](https://v8docs.nodesource.com/node-8.0/db/d5f/classv8_1_1_object_template.html#a5e9612fc80bf6db8f2da199b9b0bd04e).
Calls the `ObjectTemplate`'s [`SetCallAsFunctionHandler()`](https://v8docs.nodesource.com/node-8.11/db/d5f/classv8_1_1_object_template.html#a5e9612fc80bf6db8f2da199b9b0bd04e).
......@@ -15,7 +15,7 @@ NAN provides a `Nan::New()` helper for the creation of new JavaScript objects in
`Nan::New()` should be used to instantiate new JavaScript objects.
Refer to the specific V8 type in the [V8 documentation](https://v8docs.nodesource.com/io.js-3.3/d1/d83/classv8_1_1_data.html) for information on the types of arguments required for instantiation.
Refer to the specific V8 type in the [V8 documentation](https://v8docs.nodesource.com/node-8.11/d1/d83/classv8_1_1_data.html) for information on the types of arguments required for instantiation.
Signatures:
......@@ -75,7 +75,7 @@ v8::Local<v8::String> Nan::New<T>(Nan::ExternalOneByteStringResource * value);
v8::Local<v8::RegExp> Nan::New<T>(v8::Local<v8::String> pattern, v8::RegExp::Flags flags);
```
Note that `Nan::ExternalOneByteStringResource` maps to [`v8::String::ExternalOneByteStringResource`](https://v8docs.nodesource.com/io.js-3.3/d9/db3/classv8_1_1_string_1_1_external_one_byte_string_resource.html), and `v8::String::ExternalAsciiStringResource` in older versions of V8.
Note that `Nan::ExternalOneByteStringResource` maps to [`v8::String::ExternalOneByteStringResource`](https://v8docs.nodesource.com/node-8.11/d9/db3/classv8_1_1_string_1_1_external_one_byte_string_resource.html), and `v8::String::ExternalAsciiStringResource` in older versions of V8.
<a name="api_nan_undefined"></a>
......@@ -125,7 +125,7 @@ v8::Local<v8::Boolean> Nan::False()
<a name="api_nan_empty_string"></a>
### Nan::EmptyString()
Call [`v8::String::Empty`](https://v8docs.nodesource.com/io.js-3.3/d2/db3/classv8_1_1_string.html#a7c1bc8886115d7ee46f1d571dd6ebc6d) to reference the empty string in a way that is compatible across all supported versions of V8.
Call [`v8::String::Empty`](https://v8docs.nodesource.com/node-8.11/d2/db3/classv8_1_1_string.html#a7c1bc8886115d7ee46f1d571dd6ebc6d) to reference the empty string in a way that is compatible across all supported versions of V8.
Signature:
......@@ -137,7 +137,7 @@ v8::Local<v8::String> Nan::EmptyString()
<a name="api_nan_new_one_byte_string"></a>
### Nan::NewOneByteString()
An implementation of [`v8::String::NewFromOneByte()`](https://v8docs.nodesource.com/io.js-3.3/d2/db3/classv8_1_1_string.html#a5264d50b96d2c896ce525a734dc10f09) provided for consistent availability and API across supported versions of V8. Allocates a new string from Latin-1 data.
An implementation of [`v8::String::NewFromOneByte()`](https://v8docs.nodesource.com/node-8.11/d2/db3/classv8_1_1_string.html#a5264d50b96d2c896ce525a734dc10f09) provided for consistent availability and API across supported versions of V8. Allocates a new string from Latin-1 data.
Signature:
......
......@@ -94,7 +94,7 @@ template<typename T> class PersistentBase {
};
```
See the V8 documentation for [`PersistentBase`](https://v8docs.nodesource.com/io.js-3.3/d4/dca/classv8_1_1_persistent_base.html) for further information.
See the V8 documentation for [`PersistentBase`](https://v8docs.nodesource.com/node-8.11/d4/dca/classv8_1_1_persistent_base.html) for further information.
**Tip:** To get a `v8::Local` reference to the original object back from a `PersistentBase` or `Persistent` object:
......@@ -126,7 +126,7 @@ template<typename T> class NonCopyablePersistentTraits {
};
```
See the V8 documentation for [`NonCopyablePersistentTraits`](https://v8docs.nodesource.com/io.js-3.3/de/d73/classv8_1_1_non_copyable_persistent_traits.html) for further information.
See the V8 documentation for [`NonCopyablePersistentTraits`](https://v8docs.nodesource.com/node-8.11/de/d73/classv8_1_1_non_copyable_persistent_traits.html) for further information.
<a name="api_nan_copyable_persistent_traits"></a>
### Nan::CopyablePersistentTraits & v8::CopyablePersistentTraits
......@@ -151,7 +151,7 @@ class CopyablePersistentTraits {
};
```
See the V8 documentation for [`CopyablePersistentTraits`](https://v8docs.nodesource.com/io.js-3.3/da/d5c/structv8_1_1_copyable_persistent_traits.html) for further information.
See the V8 documentation for [`CopyablePersistentTraits`](https://v8docs.nodesource.com/node-8.11/da/d5c/structv8_1_1_copyable_persistent_traits.html) for further information.
<a name="api_nan_persistent"></a>
### Nan::Persistent
......@@ -204,7 +204,7 @@ template<typename T, typename M> class Persistent : public PersistentBase<T> {
};
```
See the V8 documentation for [`Persistent`](https://v8docs.nodesource.com/io.js-3.3/d2/d78/classv8_1_1_persistent.html) for further information.
See the V8 documentation for [`Persistent`](https://v8docs.nodesource.com/node-8.11/d2/d78/classv8_1_1_persistent.html) for further information.
<a name="api_nan_global"></a>
### Nan::Global
......@@ -238,7 +238,7 @@ template<typename T> class Global : public PersistentBase<T> {
};
```
See the V8 documentation for [`Global`](https://v8docs.nodesource.com/io.js-3.3/d5/d40/classv8_1_1_global.html) for further information.
See the V8 documentation for [`Global`](https://v8docs.nodesource.com/node-8.11/d5/d40/classv8_1_1_global.html) for further information.
<a name="api_nan_weak_callback_info"></a>
### Nan::WeakCallbackInfo
......@@ -279,7 +279,7 @@ int *data = new int(0);
obj.SetWeak(data, callback, WeakCallbackType::kParameter);
```
See the V8 documentation for [`WeakCallbackInfo`](https://v8docs.nodesource.com/io.js-3.3/d8/d06/classv8_1_1_weak_callback_info.html) for further information.
See the V8 documentation for [`WeakCallbackInfo`](https://v8docs.nodesource.com/node-8.11/d8/d06/classv8_1_1_weak_callback_info.html) for further information.
<a name="api_nan_weak_callback_type"></a>
### Nan::WeakCallbackType
......
......@@ -14,7 +14,7 @@ Also see the V8 Embedders Guide section on [Handles and Garbage Collection](http
<a name="api_nan_handle_scope"></a>
### Nan::HandleScope
A simple wrapper around [`v8::HandleScope`](https://v8docs.nodesource.com/io.js-3.3/d3/d95/classv8_1_1_handle_scope.html).
A simple wrapper around [`v8::HandleScope`](https://v8docs.nodesource.com/node-8.11/d3/d95/classv8_1_1_handle_scope.html).
Definition:
......
......@@ -9,7 +9,7 @@ NAN provides a `v8::Script` helpers as the API has changed over the supported ve
<a name="api_nan_compile_script"></a>
### Nan::CompileScript()
A wrapper around [`v8::Script::Compile()`](https://v8docs.nodesource.com/io.js-3.3/da/da5/classv8_1_1_script_compiler.html#a93f5072a0db55d881b969e9fc98e564b).
A wrapper around [`v8::ScriptCompiler::Compile()`](https://v8docs.nodesource.com/node-8.11/da/da5/classv8_1_1_script_compiler.html#a93f5072a0db55d881b969e9fc98e564b).
Note that `Nan::BoundScript` is an alias for `v8::Script`.
......
......@@ -48,7 +48,7 @@ Signature:
void Nan::AddGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback, v8::GCType gc_type_filter = v8::kGCTypeAll)
```
Calls V8's [`AddGCEpilogueCallback()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#a90d1860babc76059c62514b422f56960).
Calls V8's [`AddGCEpilogueCallback()`](https://v8docs.nodesource.com/node-8.11/d5/dda/classv8_1_1_isolate.html#a580f976e4290cead62c2fc4dd396be3e).
<a name="api_nan_remove_gc_epilogue_callback"></a>
### Nan::RemoveGCEpilogueCallback()
......@@ -59,7 +59,7 @@ Signature:
void Nan::RemoveGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback)
```
Calls V8's [`RemoveGCEpilogueCallback()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#a05c60859fd4b8e96bfcd451281ed6c7c).
Calls V8's [`RemoveGCEpilogueCallback()`](https://v8docs.nodesource.com/node-8.11/d5/dda/classv8_1_1_isolate.html#adca9294555a3908e9f23c7bb0f0f284c).
<a name="api_nan_add_gc_prologue_callback"></a>
### Nan::AddGCPrologueCallback()
......@@ -70,7 +70,7 @@ Signature:
void Nan::AddGCPrologueCallback(v8::Isolate::GCPrologueCallback, v8::GCType gc_type_filter callback)
```
Calls V8's [`AddGCPrologueCallback()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#ab4b87b8f9f8e5bf95eba4009357e001f).
Calls V8's [`AddGCPrologueCallback()`](https://v8docs.nodesource.com/node-8.11/d5/dda/classv8_1_1_isolate.html#a6dbef303603ebdb03da6998794ea05b8).
<a name="api_nan_remove_gc_prologue_callback"></a>
### Nan::RemoveGCPrologueCallback()
......@@ -81,7 +81,7 @@ Signature:
void Nan::RemoveGCPrologueCallback(v8::Isolate::GCPrologueCallback callback)
```
Calls V8's [`RemoveGCEpilogueCallback()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#a9f6c51932811593f81ff30b949124186).
Calls V8's [`RemoveGCPrologueCallback()`](https://v8docs.nodesource.com/node-8.11/d5/dda/classv8_1_1_isolate.html#a5f72c7cda21415ce062bbe5c58abe09e).
<a name="api_nan_get_heap_statistics"></a>
### Nan::GetHeapStatistics()
......@@ -92,7 +92,7 @@ Signature:
void Nan::GetHeapStatistics(v8::HeapStatistics *heap_statistics)
```
Calls V8's [`GetHeapStatistics()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#a5593ac74687b713095c38987e5950b34).
Calls V8's [`GetHeapStatistics()`](https://v8docs.nodesource.com/node-8.11/d5/dda/classv8_1_1_isolate.html#a5593ac74687b713095c38987e5950b34).
<a name="api_nan_set_counter_function"></a>
### Nan::SetCounterFunction()
......@@ -103,7 +103,7 @@ Signature:
void Nan::SetCounterFunction(v8::CounterLookupCallback cb)
```
Calls V8's [`SetCounterFunction()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#a045d7754e62fa0ec72ae6c259b29af94).
Calls V8's [`SetCounterFunction()`](https://v8docs.nodesource.com/node-8.11/d5/dda/classv8_1_1_isolate.html#a045d7754e62fa0ec72ae6c259b29af94).
<a name="api_nan_set_create_histogram_function"></a>
### Nan::SetCreateHistogramFunction()
......@@ -114,7 +114,7 @@ Signature:
void Nan::SetCreateHistogramFunction(v8::CreateHistogramCallback cb)
```
Calls V8's [`SetCreateHistogramFunction()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#a542d67e85089cb3f92aadf032f99e732).
Calls V8's [`SetCreateHistogramFunction()`](https://v8docs.nodesource.com/node-8.11/d5/dda/classv8_1_1_isolate.html#a542d67e85089cb3f92aadf032f99e732).
<a name="api_nan_set_add_histogram_sample_function"></a>
### Nan::SetAddHistogramSampleFunction()
......@@ -125,7 +125,7 @@ Signature:
void Nan::SetAddHistogramSampleFunction(v8::AddHistogramSampleCallback cb)
```
Calls V8's [`SetAddHistogramSampleFunction()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#aeb420b690bc2c216882d6fdd00ddd3ea).
Calls V8's [`SetAddHistogramSampleFunction()`](https://v8docs.nodesource.com/node-8.11/d5/dda/classv8_1_1_isolate.html#aeb420b690bc2c216882d6fdd00ddd3ea).
<a name="api_nan_idle_notification"></a>
### Nan::IdleNotification()
......@@ -133,10 +133,10 @@ Calls V8's [`SetAddHistogramSampleFunction()`](https://v8docs.nodesource.com/io.
Signature:
```c++
void Nan::IdleNotification(v8::HeapStatistics *heap_statistics)
bool Nan::IdleNotification(int idle_time_in_ms)
```
Calls V8's [`IdleNotification()` or `IdleNotificationDeadline()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#ad6a2a02657f5425ad460060652a5a118) depending on V8 version.
Calls V8's [`IdleNotification()` or `IdleNotificationDeadline()`](https://v8docs.nodesource.com/node-8.11/d5/dda/classv8_1_1_isolate.html#ad6a2a02657f5425ad460060652a5a118) depending on V8 version.
<a name="api_nan_low_memory_notification"></a>
### Nan::LowMemoryNotification()
......@@ -147,7 +147,7 @@ Signature:
void Nan::LowMemoryNotification()
```
Calls V8's [`LowMemoryNotification()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#a24647f61d6b41f69668094bdcd6ea91f).
Calls V8's [`LowMemoryNotification()`](https://v8docs.nodesource.com/node-8.11/d5/dda/classv8_1_1_isolate.html#a24647f61d6b41f69668094bdcd6ea91f).
<a name="api_nan_context_disposed_notification"></a>
### Nan::ContextDisposedNotification()
......@@ -158,7 +158,7 @@ Signature:
void Nan::ContextDisposedNotification()
```
Calls V8's [`ContextDisposedNotification()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#ad7f5dc559866343fe6cd8db1f134d48b).
Calls V8's [`ContextDisposedNotification()`](https://v8docs.nodesource.com/node-8.11/d5/dda/classv8_1_1_isolate.html#ad7f5dc559866343fe6cd8db1f134d48b).
<a name="api_nan_get_internal_field_pointer"></a>
### Nan::GetInternalFieldPointer()
......@@ -171,7 +171,7 @@ Signature:
void* Nan::GetInternalFieldPointer(v8::Local<v8::Object> object, int index)
```
Calls the Object's [`GetAlignedPointerFromInternalField()` or `GetPointerFromInternalField()`](https://v8docs.nodesource.com/io.js-3.3/db/d85/classv8_1_1_object.html#ab3c57184263cf29963ef0017bec82281) depending on the version of V8.
Calls the Object's [`GetAlignedPointerFromInternalField()` or `GetPointerFromInternalField()`](https://v8docs.nodesource.com/node-8.11/db/d85/classv8_1_1_object.html#a580ea84afb26c005d6762eeb9e3c308f) depending on the version of V8.
<a name="api_nan_set_internal_field_pointer"></a>
### Nan::SetInternalFieldPointer()
......@@ -184,7 +184,7 @@ Signature:
void Nan::SetInternalFieldPointer(v8::Local<v8::Object> object, int index, void* value)
```
Calls the Object's [`SetAlignedPointerInInternalField()` or `SetPointerInInternalField()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#ad7f5dc559866343fe6cd8db1f134d48b) depending on the version of V8.
Calls the Object's [`SetAlignedPointerInInternalField()` or `SetPointerInInternalField()`](https://v8docs.nodesource.com/node-8.11/db/d85/classv8_1_1_object.html#ab3c57184263cf29963ef0017bec82281) depending on the version of V8.
<a name="api_nan_adjust_external_memory"></a>
### Nan::AdjustExternalMemory()
......@@ -195,5 +195,5 @@ Signature:
int Nan::AdjustExternalMemory(int bytesChange)
```
Calls V8's [`AdjustAmountOfExternalAllocatedMemory()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#ae1a59cac60409d3922582c4af675473e).
Calls V8's [`AdjustAmountOfExternalAllocatedMemory()`](https://v8docs.nodesource.com/node-8.11/d5/dda/classv8_1_1_isolate.html#ae1a59cac60409d3922582c4af675473e).
......@@ -12,7 +12,7 @@
Converts an object to a UTF-8-encoded character array. If conversion to a string fails (e.g. due to an exception in the toString() method of the object) then the length() method returns 0 and the * operator returns NULL. The underlying memory used for this object is managed by the object.
An implementation of [`v8::String::Utf8Value`](https://v8docs.nodesource.com/io.js-3.3/d4/d1b/classv8_1_1_string_1_1_utf8_value.html) that is consistent across all supported versions of V8.
An implementation of [`v8::String::Utf8Value`](https://v8docs.nodesource.com/node-8.11/d4/d1b/classv8_1_1_string_1_1_utf8_value.html) that is consistent across all supported versions of V8.
Definition:
......@@ -31,7 +31,7 @@ class Nan::Utf8String {
<a name="api_nan_get_current_context"></a>
### Nan::GetCurrentContext()
A call to [`v8::Isolate::GetCurrent()->GetCurrentContext()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#a81c7a1ed7001ae2a65e89107f75fd053) that works across all supported versions of V8.
A call to [`v8::Isolate::GetCurrent()->GetCurrentContext()`](https://v8docs.nodesource.com/node-8.11/d5/dda/classv8_1_1_isolate.html#a81c7a1ed7001ae2a65e89107f75fd053) that works across all supported versions of V8.
Signature:
......@@ -42,7 +42,7 @@ v8::Local<v8::Context> Nan::GetCurrentContext()
<a name="api_nan_set_isolate_data"></a>
### Nan::SetIsolateData()
A helper to provide a consistent API to [`v8::Isolate#SetData()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#a7acadfe7965997e9c386a05f098fbe36).
A helper to provide a consistent API to [`v8::Isolate#SetData()`](https://v8docs.nodesource.com/node-8.11/d5/dda/classv8_1_1_isolate.html#a7acadfe7965997e9c386a05f098fbe36).
Signature:
......@@ -54,7 +54,7 @@ void Nan::SetIsolateData(v8::Isolate *isolate, T *data)
<a name="api_nan_get_isolate_data"></a>
### Nan::GetIsolateData()
A helper to provide a consistent API to [`v8::Isolate#GetData()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#aabd223436bc1100a787dadaa024c6257).
A helper to provide a consistent API to [`v8::Isolate#GetData()`](https://v8docs.nodesource.com/node-8.11/d5/dda/classv8_1_1_isolate.html#aabd223436bc1100a787dadaa024c6257).
Signature:
......
......@@ -13,7 +13,7 @@
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
*
* Version 2.11.1: current Node 10.11.0, Node 12: 0.12.18, Node 10: 0.10.48, iojs: 3.3.1
* Version 2.12.1: current Node 11.4.0, Node 12: 0.12.18, Node 10: 0.10.48, iojs: 3.3.1
*
* See https://github.com/nodejs/nan for the latest update to this file
**********************************************************************************/
......@@ -37,6 +37,7 @@
#define NODE_8_0_MODULE_VERSION 57
#define NODE_9_0_MODULE_VERSION 59
#define NODE_10_0_MODULE_VERSION 64
#define NODE_11_0_MODULE_VERSION 67
#ifdef _MSC_VER
# define NAN_HAS_CPLUSPLUS_11 (_MSC_VER >= 1800)
......@@ -1060,8 +1061,10 @@ class Utf8String {
length_(0), str_(str_st_) {
HandleScope scope;
if (!from.IsEmpty()) {
#if V8_MAJOR_VERSION >= 7
v8::Local<v8::String> string = from->ToString(v8::Isolate::GetCurrent());
#if NODE_MAJOR_VERSION >= 10
v8::Local<v8::Context> context = GetCurrentContext();
v8::Local<v8::String> string =
from->ToString(context).FromMaybe(v8::Local<v8::String>());
#else
v8::Local<v8::String> string = from->ToString();
#endif
......@@ -1074,11 +1077,27 @@ class Utf8String {
}
const int flags =
v8::String::NO_NULL_TERMINATION | imp::kReplaceInvalidUtf8;
#if V8_MAJOR_VERSION >= 7
#if NODE_MAJOR_VERSION >= 11
length_ = string->WriteUtf8(v8::Isolate::GetCurrent(), str_, static_cast<int>(len), 0, flags);
#else
// See https://github.com/nodejs/nan/issues/832.
// Disable the warning as there is no way around it.
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4996)
#endif
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
length_ = string->WriteUtf8(str_, static_cast<int>(len), 0, flags);
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif // NODE_MAJOR_VERSION < 11
str_[length_] = '\0';
}
}
......@@ -1658,9 +1677,9 @@ class Callback {
v8::EscapableHandleScope scope(isolate);
# if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
AsyncResource async("nan:Callback:Call");
return Call_(isolate, isolate->GetCurrentContext()->Global(), argc, argv,
&async)
.FromMaybe(v8::Local<v8::Value>());
return scope.Escape(Call_(isolate, isolate->GetCurrentContext()->Global(),
argc, argv, &async)
.FromMaybe(v8::Local<v8::Value>()));
# else
return scope.Escape(
Call_(isolate, isolate->GetCurrentContext()->Global(), argc, argv));
......@@ -1852,36 +1871,41 @@ inline MaybeLocal<v8::Value> Call(
inline void SaveToPersistent(
const char *key, const v8::Local<v8::Value> &value) {
HandleScope scope;
New(persistentHandle)->Set(New(key).ToLocalChecked(), value);
Set(New(persistentHandle), New(key).ToLocalChecked(), value).FromJust();
}
inline void SaveToPersistent(
const v8::Local<v8::String> &key, const v8::Local<v8::Value> &value) {
HandleScope scope;
New(persistentHandle)->Set(key, value);
Set(New(persistentHandle), key, value).FromJust();
}
inline void SaveToPersistent(
uint32_t index, const v8::Local<v8::Value> &value) {
HandleScope scope;
New(persistentHandle)->Set(index, value);
Set(New(persistentHandle), index, value).FromJust();
}
inline v8::Local<v8::Value> GetFromPersistent(const char *key) const {
EscapableHandleScope scope;
return scope.Escape(
New(persistentHandle)->Get(New(key).ToLocalChecked()));
Get(New(persistentHandle), New(key).ToLocalChecked())
.FromMaybe(v8::Local<v8::Value>()));
}
inline v8::Local<v8::Value>
GetFromPersistent(const v8::Local<v8::String> &key) const {
EscapableHandleScope scope;
return scope.Escape(New(persistentHandle)->Get(key));
return scope.Escape(
Get(New(persistentHandle), key)
.FromMaybe(v8::Local<v8::Value>()));
}
inline v8::Local<v8::Value> GetFromPersistent(uint32_t index) const {
EscapableHandleScope scope;
return scope.Escape(New(persistentHandle)->Get(index));
return scope.Escape(
Get(New(persistentHandle), index)
.FromMaybe(v8::Local<v8::Value>()));
}
virtual void Execute() = 0;
......@@ -2375,7 +2399,7 @@ SetMethodAux(T recv,
v8::Local<v8::String> name,
v8::Local<v8::FunctionTemplate> tpl,
...) {
recv->Set(name, GetFunction(tpl).ToLocalChecked());
Set(recv, name, GetFunction(tpl).ToLocalChecked());
}
} // end of namespace imp
......
......@@ -100,9 +100,17 @@ Factory<v8::Function>::New( FunctionCallback callback
obj->SetInternalField(imp::kDataIndex, val);
}
return scope.Escape(v8::Function::New( isolate
, imp::FunctionCallbackWrapper
, obj));
#if NODE_MAJOR_VERSION >= 10
v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::Local<v8::Function> function =
v8::Function::New(context, imp::FunctionCallbackWrapper, obj)
.ToLocalChecked();
#else
v8::Local<v8::Function> function =
v8::Function::New(isolate, imp::FunctionCallbackWrapper, obj);
#endif
return scope.Escape(function);
}
//=== Function Template ========================================================
......@@ -332,12 +340,25 @@ Factory<v8::String>::New(ExternalOneByteStringResource * value) {
//=== String Object ============================================================
// See https://github.com/nodejs/nan/pull/811#discussion_r224594980.
// Disable the warning as there is no way around it.
// TODO(bnoordhuis) Use isolate-based version in Node.js v12.
Factory<v8::StringObject>::return_t
Factory<v8::StringObject>::New(v8::Local<v8::String> value) {
#if V8_MAJOR_VERSION >= 7
return v8::StringObject::New(v8::Isolate::GetCurrent(), value).As<v8::StringObject>();
#else
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4996)
#endif
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
return v8::StringObject::New(value).As<v8::StringObject>();
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#ifdef _MSC_VER
#pragma warning(pop)
#endif
}
......
......@@ -64,7 +64,10 @@ class ObjectWrap {
inline void MakeWeak() {
persistent().v8::PersistentBase<v8::Object>::SetWeak(
this, WeakCallback, v8::WeakCallbackType::kParameter);
#if NODE_MAJOR_VERSION < 10
// FIXME(bnoordhuis) Probably superfluous in older Node.js versions too.
persistent().MarkIndependent();
#endif
}
#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
......
......@@ -270,12 +270,13 @@ inline void Persistent<T, M>::SetWeak(
, WeakCallbackInfo<P>::template invokeparameter<true>
, type);
} else {
v8::Local<T>* self = reinterpret_cast<v8::Local<T>*>(this);
assert((*self)->IsObject());
int count = (*self)->InternalFieldCount();
v8::Local<v8::Value>* self_v(reinterpret_cast<v8::Local<v8::Value>*>(this));
assert((*self_v)->IsObject());
v8::Local<v8::Object> self((*self_v).As<v8::Object>());
int count = self->InternalFieldCount();
void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
internal_fields[i] = (*self)->GetAlignedPointerFromInternalField(i);
internal_fields[i] = self->GetAlignedPointerFromInternalField(i);
}
wcbd = new WeakCallbackInfo<P>(
reinterpret_cast<Persistent<v8::Value>*>(this)
......@@ -283,7 +284,7 @@ inline void Persistent<T, M>::SetWeak(
, 0
, internal_fields[0]
, internal_fields[1]);
(*self)->SetAlignedPointerInInternalField(0, wcbd);
self->SetAlignedPointerInInternalField(0, wcbd);
v8::PersistentBase<T>::SetWeak(
static_cast<WeakCallbackInfo<P>*>(0)
, WeakCallbackInfo<P>::template invoketwofield<true>
......@@ -307,12 +308,13 @@ inline void Persistent<T, M>::SetWeak(
wcbd
, WeakCallbackInfo<P>::invokeparameter);
} else {
v8::Local<T>* self = reinterpret_cast<v8::Local<T>*>(this);
assert((*self)->IsObject());
int count = (*self)->InternalFieldCount();
v8::Local<v8::Value>* self_v(reinterpret_cast<v8::Local<v8::Value>*>(this));
assert((*self_v)->IsObject());
v8::Local<v8::Object> self((*self_v).As<v8::Object>());
int count = self->InternalFieldCount();
void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
internal_fields[i] = (*self)->GetAlignedPointerFromInternalField(i);
internal_fields[i] = self->GetAlignedPointerFromInternalField(i);
}
wcbd = new WeakCallbackInfo<P>(
reinterpret_cast<Persistent<v8::Value>*>(this)
......@@ -320,7 +322,7 @@ inline void Persistent<T, M>::SetWeak(
, 0
, internal_fields[0]
, internal_fields[1]);
(*self)->SetAlignedPointerInInternalField(0, wcbd);
self->SetAlignedPointerInInternalField(0, wcbd);
v8::PersistentBase<T>::SetPhantom(
static_cast<WeakCallbackInfo<P>*>(0)
, WeakCallbackInfo<P>::invoketwofield
......@@ -345,12 +347,13 @@ inline void Persistent<T, M>::SetWeak(
wcbd
, WeakCallbackInfo<P>::invokeparameter);
} else {
v8::Local<T>* self = reinterpret_cast<v8::Local<T>*>(this);
assert((*self)->IsObject());
int count = (*self)->InternalFieldCount();
v8::Local<v8::Value>* self_v(reinterpret_cast<v8::Local<v8::Value>*>(this));
assert((*self_v)->IsObject());
v8::Local<v8::Object> self((*self_v).As<v8::Object>());
int count = self->InternalFieldCount();
void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
internal_fields[i] = (*self)->GetAlignedPointerFromInternalField(i);
internal_fields[i] = self->GetAlignedPointerFromInternalField(i);
}
wcbd = new WeakCallbackInfo<P>(
reinterpret_cast<Persistent<v8::Value>*>(this)
......@@ -358,7 +361,7 @@ inline void Persistent<T, M>::SetWeak(
, 0
, internal_fields[0]
, internal_fields[1]);
(*self)->SetAlignedPointerInInternalField(0, wcbd);
self->SetAlignedPointerInInternalField(0, wcbd);
v8::PersistentBase<T>::SetPhantom(
WeakCallbackInfo<P>::invoketwofield
, 0
......@@ -380,12 +383,13 @@ inline void Persistent<T, M>::SetWeak(
, parameter);
v8::PersistentBase<T>::SetWeak(wcbd, WeakCallbackInfo<P>::invoke);
} else {
v8::Local<T>* self = reinterpret_cast<v8::Local<T>*>(this);
assert((*self)->IsObject());
int count = (*self)->InternalFieldCount();
v8::Local<v8::Value>* self_v(reinterpret_cast<v8::Local<v8::Value>*>(this));
assert((*self_v)->IsObject());
v8::Local<v8::Object> self((*self_v).As<v8::Object>());
int count = self->InternalFieldCount();
void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
internal_fields[i] = (*self)->GetAlignedPointerFromInternalField(i);
internal_fields[i] = self->GetAlignedPointerFromInternalField(i);
}
wcbd = new WeakCallbackInfo<P>(
reinterpret_cast<Persistent<v8::Value>*>(this)
......@@ -411,12 +415,13 @@ inline void PersistentBase<T>::SetWeak(
, parameter);
persistent.MakeWeak(wcbd, WeakCallbackInfo<P>::invoke);
} else {
v8::Local<T>* self = reinterpret_cast<v8::Local<T>*>(this);
assert((*self)->IsObject());
int count = (*self)->InternalFieldCount();
v8::Local<v8::Value>* self_v(reinterpret_cast<v8::Local<v8::Value>*>(this));
assert((*self_v)->IsObject());
v8::Local<v8::Object> self((*self_v).As<v8::Object>());
int count = self->InternalFieldCount();
void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
internal_fields[i] = (*self)->GetPointerFromInternalField(i);
internal_fields[i] = self->GetPointerFromInternalField(i);
}
wcbd = new WeakCallbackInfo<P>(
reinterpret_cast<Persistent<v8::Value>*>(this)
......
{
"name": "nan",
"version": "2.11.1",
"description": "Native Abstractions for Node.js: C++ header for Node 0.8 -> 10 compatibility",
"version": "2.12.1",
"description": "Native Abstractions for Node.js: C++ header for Node 0.8 -> 11 compatibility",
"main": "include_dirs.js",
"repository": {
"type": "git",
......
......@@ -61,7 +61,8 @@ NAN_MODULE_INIT(SetterGetter::Init) {
);
v8::Local<v8::Function> createnew =
Nan::New<v8::FunctionTemplate>(CreateNew)->GetFunction();
Nan::GetFunction(
Nan::New<v8::FunctionTemplate>(CreateNew)).ToLocalChecked();
Set(target, Nan::New<v8::String>("create").ToLocalChecked(), createnew);
}
......@@ -70,7 +71,8 @@ v8::Local<v8::Value> SetterGetter::NewInstance () {
v8::Local<v8::FunctionTemplate> constructorHandle =
Nan::New(settergetter_constructor);
v8::Local<v8::Object> instance =
Nan::NewInstance(constructorHandle->GetFunction()).ToLocalChecked();
Nan::NewInstance(
Nan::GetFunction(constructorHandle).ToLocalChecked()).ToLocalChecked();
return scope.Escape(instance);
}
......
......@@ -49,7 +49,8 @@ NAN_MODULE_INIT(SetterGetter::Init) {
tpl->InstanceTemplate()->SetInternalFieldCount(1);
SetPrototypeMethod(tpl, "log", SetterGetter::Log);
v8::Local<v8::Function> createnew =
Nan::New<v8::FunctionTemplate>(CreateNew)->GetFunction();
Nan::GetFunction(Nan::New<v8::FunctionTemplate>(CreateNew))
.ToLocalChecked();
Set(target, Nan::New<v8::String>("create").ToLocalChecked(), createnew);
}
......@@ -58,7 +59,8 @@ v8::Local<v8::Value> SetterGetter::NewInstance () {
v8::Local<v8::FunctionTemplate> constructorHandle =
Nan::New(settergetter_constructor);
v8::Local<v8::Object> instance =
Nan::NewInstance(constructorHandle->GetFunction()).ToLocalChecked();
Nan::NewInstance(Nan::GetFunction(constructorHandle).ToLocalChecked())
.ToLocalChecked();
SetAccessor(
instance
, Nan::New("prop1").ToLocalChecked()
......
......@@ -55,7 +55,7 @@ NAN_METHOD(DoProgress) {
NAN_MODULE_INIT(Init) {
Set(target
, New<v8::String>("doProgress").ToLocalChecked()
, New<v8::FunctionTemplate>(DoProgress)->GetFunction());
, GetFunction(New<v8::FunctionTemplate>(DoProgress)).ToLocalChecked());
}
NODE_MODULE(asyncprogressqueueworker, Init)
......@@ -74,7 +74,7 @@ NAN_METHOD(DoProgress) {
NAN_MODULE_INIT(Init) {
Set(target
, New<v8::String>("doProgress").ToLocalChecked()
, New<v8::FunctionTemplate>(DoProgress)->GetFunction());
, GetFunction(New<v8::FunctionTemplate>(DoProgress)).ToLocalChecked());
}
NODE_MODULE(asyncprogressqueueworkerstream, Init)
......@@ -61,7 +61,7 @@ NAN_METHOD(DoProgress) {
NAN_MODULE_INIT(Init) {
Set(target
, New<v8::String>("a").ToLocalChecked()
, New<v8::FunctionTemplate>(DoProgress)->GetFunction());
, GetFunction(New<v8::FunctionTemplate>(DoProgress)).ToLocalChecked());
}
NODE_MODULE(asyncprogressworker, Init)
......@@ -59,7 +59,7 @@ NAN_METHOD(DoProgress) {
NAN_MODULE_INIT(Init) {
Set(target
, New<v8::String>("a").ToLocalChecked()
, New<v8::FunctionTemplate>(DoProgress)->GetFunction());
, GetFunction(New<v8::FunctionTemplate>(DoProgress)).ToLocalChecked());
}
NODE_MODULE(asyncprogressworkersignal, Init)
......@@ -81,7 +81,7 @@ NAN_METHOD(DoProgress) {
NAN_MODULE_INIT(Init) {
Set(target
, New<v8::String>("a").ToLocalChecked()
, New<v8::FunctionTemplate>(DoProgress)->GetFunction());
, GetFunction(New<v8::FunctionTemplate>(DoProgress)).ToLocalChecked());
}
NODE_MODULE(asyncprogressworkerstream, Init)
......@@ -36,7 +36,7 @@ NAN_METHOD(DoSleep) {
NAN_MODULE_INIT(Init) {
Set(target
, New<v8::String>("a").ToLocalChecked()
, New<v8::FunctionTemplate>(DoSleep)->GetFunction());
, GetFunction(New<v8::FunctionTemplate>(DoSleep)).ToLocalChecked());
}
NODE_MODULE(asyncworker, Init)
......@@ -29,7 +29,7 @@ NAN_METHOD(Work) {
NAN_MODULE_INIT(Init) {
Set(target
, New("a").ToLocalChecked()
, New<v8::FunctionTemplate>(Work)->GetFunction());
, GetFunction(New<v8::FunctionTemplate>(Work)).ToLocalChecked());
}
NODE_MODULE(asyncworkererror, Init)
......@@ -56,19 +56,19 @@ NAN_MODULE_INIT(Init) {
}
Set(target
, New<v8::String>("new1").ToLocalChecked()
, New<v8::FunctionTemplate>(New1)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(New1)).ToLocalChecked()
);
Set(target
, New<v8::String>("new2").ToLocalChecked()
, New<v8::FunctionTemplate>(New2)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(New2)).ToLocalChecked()
);
Set(target
, New<v8::String>("new3").ToLocalChecked()
, New<v8::FunctionTemplate>(New3)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(New3)).ToLocalChecked()
);
Set(target
, New<v8::String>("copy").ToLocalChecked()
, New<v8::FunctionTemplate>(Copy)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(Copy)).ToLocalChecked()
);
}
......
......@@ -61,7 +61,7 @@ NAN_METHOD(DoSleep) {
NAN_MODULE_INIT(Init) {
Set(target
, New<v8::String>("a").ToLocalChecked()
, New<v8::FunctionTemplate>(DoSleep)->GetFunction());
, GetFunction(New<v8::FunctionTemplate>(DoSleep)).ToLocalChecked());
}
NODE_MODULE(bufferworkerpersistent, Init)
......@@ -75,63 +75,63 @@ NAN_METHOD(Int32Value) {
NAN_MODULE_INIT(Init) {
Set(target
, New<v8::String>("toBoolean").ToLocalChecked()
, New<v8::FunctionTemplate>(ToBoolean)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(ToBoolean)).ToLocalChecked()
);
Set(target
, New<v8::String>("toNumber").ToLocalChecked()
, New<v8::FunctionTemplate>(ToNumber)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(ToNumber)).ToLocalChecked()
);
Set(target
, New<v8::String>("toString").ToLocalChecked()
, New<v8::FunctionTemplate>(ToString)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(ToString)).ToLocalChecked()
);
Set(target
, New<v8::String>("toDetailString").ToLocalChecked()
, New<v8::FunctionTemplate>(ToDetailString)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(ToDetailString)).ToLocalChecked()
);
Set(target
, New<v8::String>("toFunction").ToLocalChecked()
, New<v8::FunctionTemplate>(ToFunction)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(ToFunction)).ToLocalChecked()
);
Set(target
, New<v8::String>("toObject").ToLocalChecked()
, New<v8::FunctionTemplate>(ToObject)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(ToObject)).ToLocalChecked()
);
Set(target
, New<v8::String>("toInteger").ToLocalChecked()
, New<v8::FunctionTemplate>(ToInteger)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(ToInteger)).ToLocalChecked()
);
Set(target
, New<v8::String>("toUint32").ToLocalChecked()
, New<v8::FunctionTemplate>(ToUint32)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(ToUint32)).ToLocalChecked()
);
Set(target
, New<v8::String>("toInt32").ToLocalChecked()
, New<v8::FunctionTemplate>(ToInt32)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(ToInt32)).ToLocalChecked()
);
Set(target
, New<v8::String>("toArrayIndex").ToLocalChecked()
, New<v8::FunctionTemplate>(ToArrayIndex)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(ToArrayIndex)).ToLocalChecked()
);
Set(target
, New<v8::String>("booleanValue").ToLocalChecked()
, New<v8::FunctionTemplate>(BooleanValue)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(BooleanValue)).ToLocalChecked()
);
Set(target
, New<v8::String>("numberValue").ToLocalChecked()
, New<v8::FunctionTemplate>(NumberValue)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(NumberValue)).ToLocalChecked()
);
Set(target
, New<v8::String>("integerValue").ToLocalChecked()
, New<v8::FunctionTemplate>(IntegerValue)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(IntegerValue)).ToLocalChecked()
);
Set(target
, New<v8::String>("uint32Value").ToLocalChecked()
, New<v8::FunctionTemplate>(Uint32Value)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(Uint32Value)).ToLocalChecked()
);
Set(target
, New<v8::String>("int32Value").ToLocalChecked()
, New<v8::FunctionTemplate>(Int32Value)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(Int32Value)).ToLocalChecked()
);
}
......
......@@ -45,7 +45,7 @@ X(TypeError)
Nan::Set( \
target \
, Nan::New(#NAME).ToLocalChecked() \
, Nan::New<v8::FunctionTemplate>(NAME)->GetFunction());
, Nan::GetFunction(New<v8::FunctionTemplate>(NAME)).ToLocalChecked());
NAN_MODULE_INIT(Init) {
......
......@@ -36,11 +36,11 @@ NAN_METHOD(Check) {
NAN_MODULE_INIT(Init) {
Set(target
, New<v8::String>("hook").ToLocalChecked()
, New<v8::FunctionTemplate>(Hook)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(Hook)).ToLocalChecked()
);
Set(target
, New<v8::String>("check").ToLocalChecked()
, New<v8::FunctionTemplate>(Check)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(Check)).ToLocalChecked()
);
}
......
......@@ -50,7 +50,8 @@ NAN_MODULE_INIT(IndexedInterceptor::Init) {
, IndexedInterceptor::PropertyEnumerator);
v8::Local<v8::Function> createnew =
Nan::New<v8::FunctionTemplate>(CreateNew)->GetFunction();
Nan::GetFunction(Nan::New<v8::FunctionTemplate>(CreateNew))
.ToLocalChecked();
Set(target, Nan::New("create").ToLocalChecked(), createnew);
}
......@@ -59,7 +60,8 @@ v8::Local<v8::Value> IndexedInterceptor::NewInstance () {
v8::Local<v8::FunctionTemplate> constructorHandle =
Nan::New(indexedinterceptors_constructor);
v8::Local<v8::Object> instance =
Nan::NewInstance(constructorHandle->GetFunction()).ToLocalChecked();
Nan::NewInstance(Nan::GetFunction(constructorHandle).ToLocalChecked())
.ToLocalChecked();
return scope.Escape(instance);
}
......
......@@ -31,7 +31,7 @@ NAN_METHOD(SetAndGet) {
NAN_MODULE_INIT(Init) {
Set(target
, New<v8::String>("setAndGet").ToLocalChecked()
, New<v8::FunctionTemplate>(SetAndGet)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(SetAndGet)).ToLocalChecked()
);
}
......
......@@ -27,7 +27,7 @@ NAN_METHOD(Parse) {
NAN_MODULE_INIT(Init) {
Nan::Set(target
, Nan::New<v8::String>("parse").ToLocalChecked()
, Nan::New<v8::FunctionTemplate>(Parse)->GetFunction()
, Nan::GetFunction(Nan::New<v8::FunctionTemplate>(Parse)).ToLocalChecked()
);
}
......
......@@ -64,7 +64,8 @@ NAN_METHOD(Stringify) {
NAN_MODULE_INIT(Init) {
Nan::Set(target
, Nan::New<v8::String>("stringify").ToLocalChecked()
, Nan::New<v8::FunctionTemplate>(Stringify)->GetFunction()
, Nan::GetFunction(Nan::New<v8::FunctionTemplate>(Stringify))
.ToLocalChecked()
);
}
......
......@@ -42,8 +42,9 @@ NAN_MODULE_INIT(MyObject::Init) {
SetPrototypeMethod(tpl, "call_emit", CallEmit);
constructor.Reset(tpl->GetFunction());
Set(target, Nan::New("MyObject").ToLocalChecked(), tpl->GetFunction());
v8::Local<v8::Function> function = GetFunction(tpl).ToLocalChecked();
constructor.Reset(function);
Set(target, Nan::New("MyObject").ToLocalChecked(), function);
}
NAN_METHOD(MyObject::New) {
......
......@@ -68,36 +68,35 @@ NAN_METHOD(NewExternalAsciiStringResource) {
NAN_MODULE_INIT(Init) {
Set(target
, New("newNumber").ToLocalChecked()
, New<v8::FunctionTemplate>(NewNumber)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(NewNumber)).ToLocalChecked()
);
Set(target
, New("newNegativeInteger").ToLocalChecked()
, New<v8::FunctionTemplate>(NewNegativeInteger)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(NewNegativeInteger)).ToLocalChecked()
);
Set(target
, New("newPositiveInteger").ToLocalChecked()
, New<v8::FunctionTemplate>(NewPositiveInteger)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(NewPositiveInteger)).ToLocalChecked()
);
Set(target
, New("newUtf8String").ToLocalChecked()
, New<v8::FunctionTemplate>(NewUtf8String)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(NewUtf8String)).ToLocalChecked()
);
Set(target
, New("newLatin1String").ToLocalChecked()
, New<v8::FunctionTemplate>(NewLatin1String)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(NewLatin1String)).ToLocalChecked()
);
Set(target
, New("newUcs2String").ToLocalChecked()
, New<v8::FunctionTemplate>(NewUcs2String)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(NewUcs2String)).ToLocalChecked()
);
Set(target
, New("newExternalStringResource").ToLocalChecked()
, New<v8::FunctionTemplate>(NewExternalStringResource)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(NewExternalStringResource)).ToLocalChecked()
);
Set(target
, New("newExternalAsciiStringResource").ToLocalChecked()
, New<v8::FunctionTemplate>(NewExternalAsciiStringResource)
->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(NewExternalAsciiStringResource)).ToLocalChecked()
);
}
......
......@@ -14,7 +14,7 @@ using namespace Nan; // NOLINT(build/namespaces)
NAN_MODULE_INIT(Init) {
Set(target
, New<v8::String>("r").ToLocalChecked()
, New<v8::FunctionTemplate>(ReturnString)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(ReturnString)).ToLocalChecked()
);
}
......
......@@ -50,7 +50,8 @@ NAN_MODULE_INIT(NamedInterceptor::Init) {
, NamedInterceptor::PropertyEnumerator);
v8::Local<v8::Function> createnew =
Nan::New<v8::FunctionTemplate>(CreateNew)->GetFunction();
Nan::GetFunction(Nan::New<v8::FunctionTemplate>(CreateNew))
.ToLocalChecked();
Set(target, Nan::New("create").ToLocalChecked(), createnew);
}
......@@ -59,7 +60,8 @@ v8::Local<v8::Value> NamedInterceptor::NewInstance () {
v8::Local<v8::FunctionTemplate> constructorHandle =
Nan::New(namedinterceptors_constructor);
v8::Local<v8::Object> instance =
Nan::NewInstance(constructorHandle->GetFunction()).ToLocalChecked();
Nan::NewInstance(GetFunction(constructorHandle).ToLocalChecked())
.ToLocalChecked();
return scope.Escape(instance);
}
......
......@@ -37,7 +37,7 @@ NAN_METHOD(CompareCallbacks) {
NAN_METHOD(CallDirect) {
Callback cb(To<v8::Function>(info[0]).ToLocalChecked());
(*cb)->Call(GetCurrentContext()->Global(), 0, NULL);
Call(*cb, GetCurrentContext()->Global(), 0, NULL);
}
NAN_METHOD(CallAsFunction) {
......@@ -57,38 +57,54 @@ NAN_METHOD(ResetSet) {
info.GetReturnValue().Set(callback.IsEmpty());
}
NAN_METHOD(CallRetval) {
AsyncResource resource("nan:test.nancallback");
Callback callback(To<v8::Function>(info[0]).ToLocalChecked());
v8::Local<v8::Value> result =
callback.Call(0, NULL, &resource).ToLocalChecked();
if (result->IsNumber()) {
info.GetReturnValue().Set(Nan::True());
} else {
info.GetReturnValue().Set(Nan::False());
}
}
NAN_MODULE_INIT(Init) {
Set(target
, New<v8::String>("globalContext").ToLocalChecked()
, New<v8::FunctionTemplate>(GlobalContext)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(GlobalContext)).ToLocalChecked()
);
Set(target
, New<v8::String>("specificContext").ToLocalChecked()
, New<v8::FunctionTemplate>(SpecificContext)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(SpecificContext)).ToLocalChecked()
);
Set(target
, New<v8::String>("customReceiver").ToLocalChecked()
, New<v8::FunctionTemplate>(CustomReceiver)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(CustomReceiver)).ToLocalChecked()
);
Set(target
, New<v8::String>("compareCallbacks").ToLocalChecked()
, New<v8::FunctionTemplate>(CompareCallbacks)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(CompareCallbacks)).ToLocalChecked()
);
Set(target
, New<v8::String>("callDirect").ToLocalChecked()
, New<v8::FunctionTemplate>(CallDirect)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(CallDirect)).ToLocalChecked()
);
Set(target
, New<v8::String>("callAsFunction").ToLocalChecked()
, New<v8::FunctionTemplate>(CallAsFunction)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(CallAsFunction)).ToLocalChecked()
);
Set(target
, New<v8::String>("resetUnset").ToLocalChecked()
, New<v8::FunctionTemplate>(ResetUnset)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(ResetUnset)).ToLocalChecked()
);
Set(target
, New<v8::String>("resetSet").ToLocalChecked()
, New<v8::FunctionTemplate>(ResetSet)->GetFunction()
, GetFunction(New<v8::FunctionTemplate>(ResetSet)).ToLocalChecked()
);