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

Merge tag 'upstream/2.5.1'

Upstream version 2.5.1

# gpg: Signature faite le sam. 04 févr. 2017 01:02:16 CET
# gpg:                avec la clef RSA 03C4E7ABB880F524306E48156611C05EDD39F374
# gpg: Bonne signature de « Jérémy Lal <kapouer@melix.org> » [ultime]
# gpg:                 alias « Jérémy Lal <jerry@edagames.com> » [ultime]
# gpg:                 alias « Jérémy Lal <jerry@eda.sarl> » [ultime]
parents b3cbf85f 1d911d88
......@@ -17,6 +17,7 @@ env:
- TRAVIS_NODE_VERSION="4"
- TRAVIS_NODE_VERSION="5"
- TRAVIS_NODE_VERSION="6"
- TRAVIS_NODE_VERSION="7"
notifications:
email:
- rod@vagg.org
......
# NAN ChangeLog
**Version 2.4.0: current Node 6.3.0, Node 12: 0.12.15, Node 10: 0.10.46, iojs: 3.3.1**
**Version 2.5.1: current Node 7.4.0, Node 12: 0.12.18, Node 10: 0.10.48, iojs: 3.3.1**
### 2.5.1 Jan 23 2017
- Bugfix: Fix disappearing handle for private value 6a80995694f162ef63dbc9948fbefd45d4485aa0
- Bugfix: Add missing scopes a93b8bae6bc7d32a170db6e89228b7f60ee57112
- Bugfix: Use string::data instead of string::front in NewOneByteString d5f920371e67e1f3b268295daee6e83af86b6e50
### 2.5.0 Dec 21 2016
- Feature: Support Private accessors a86255cb357e8ad8ccbf1f6a4a901c921e39a178
- Bugfix: Abort in delete operators that shouldn't be called 0fe38215ff8581703967dfd26c12793feb960018
### 2.4.0 Jul 10 2016
......
The MIT License (MIT)
=====================
Copyright (c) 2016 NAN contributors
Copyright (c) 2017 NAN contributors
-----------------------------------
*NAN contributors listed at <https://github.com/nodejs/nan#contributors>*
......
......@@ -29,6 +29,7 @@ LINT_SOURCES = \
nan_object_wrap.h \
nan_persistent_12_inl.h \
nan_persistent_pre_12_inl.h \
nan_private.h \
nan_string_bytes.h \
nan_weak.h \
test/cpp/accessors.cpp \
......@@ -59,6 +60,7 @@ LINT_SOURCES = \
test/cpp/news.cpp \
test/cpp/objectwraphandle.cpp \
test/cpp/persistent.cpp \
test/cpp/private.cpp \
test/cpp/returnemptystring.cpp \
test/cpp/returnnull.cpp \
test/cpp/returnundefined.cpp \
......@@ -99,6 +101,6 @@ $(ADDONS): nan.h nan_new.h nan_implementation_pre_12_inl.h nan_implementation_12
nan_callbacks.h nan_callbacks_12_inl.h nan_callbacks_pre_12_inl.h \
nan_converters.h nan_converters_43_inl.h nan_converters_pre_43_inl.h \
nan_maybe_43_inl.h nan_maybe_pre_43_inl.h \
nan_persistent_12_inl.h nan_persistent_pre_12_inl.h nan_weak.h \
nan_string_bytes.h test/binding.gyp $(SOURCES)
nan_persistent_12_inl.h nan_persistent_pre_12_inl.h nan_private.h \
nan_weak.h nan_string_bytes.h test/binding.gyp $(SOURCES)
cd test/ && ../node_modules/.bin/node-gyp rebuild
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, 4, 5 and 6.**
**A header file filled with macro and utility goodness for making add-on development for Node.js easier across versions 0.8, 0.10, 0.12, 1, 4, 5, 6 and 7.**
***Current version: 2.4.0***
***Current version: 2.5.1***
*(See [CHANGELOG.md](https://github.com/nodejs/nan/blob/master/CHANGELOG.md) for complete ChangeLog)*
......@@ -56,15 +56,15 @@ For a simpler example, see the **[async pi estimation example](https://github.co
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.
Also take a look at our comprehensive **[C++ test suite](https://github.com/nodejs/nan/tree/master/test/cpp)** which has a plethora of code snippets for your pasting pleasure.
<a name="api"></a>
## API
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)
* [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/)
* [Node Add-on Documentation](https://nodejs.org/api/addons.html)
......@@ -117,7 +117,7 @@ The creation of `HandleScope` objects is different across the supported versions
- <a href="doc/scopes.md#api_nan_handle_scope"><b><code>Nan::HandleScope</code></b></a>
- <a href="doc/scopes.md#api_nan_escapable_handle_scope"><b><code>Nan::EscapableHandleScope</code></b></a>
Also see the V8 Embedders Guide section on [Handles and Garbage Collection](https://developers.google.com/v8/embed#handles).
Also see the V8 Embedders Guide section on [Handles and Garbage Collection](https://github.com/v8/v8/wiki/Embedder%27s%20Guide#handles-and-garbage-collection).
### Persistent references
......@@ -192,6 +192,10 @@ The `Nan::MaybeLocal` and `Nan::Maybe` types are monads that encapsulate `v8::Lo
- <a href="doc/maybe_types.md#api_nan_get_start_column"><b><code>Nan::GetStartColumn()</code></b></a>
- <a href="doc/maybe_types.md#api_nan_get_end_column"><b><code>Nan::GetEndColumn()</code></b></a>
- <a href="doc/maybe_types.md#api_nan_clone_element_at"><b><code>Nan::CloneElementAt()</code></b></a>
- <a href="doc/maybe_types.md#api_nan_has_private"><b><code>Nan::HasPrivate()</code></b></a>
- <a href="doc/maybe_types.md#api_nan_get_private"><b><code>Nan::GetPrivate()</code></b></a>
- <a href="doc/maybe_types.md#api_nan_set_private"><b><code>Nan::SetPrivate()</code></b></a>
- <a href="doc/maybe_types.md#api_nan_delete_private"><b><code>Nan::DeletePrivate()</code></b></a>
- <a href="doc/maybe_types.md#api_nan_make_maybe"><b><code>Nan::MakeMaybe()</code></b></a>
### Script
......@@ -244,7 +248,7 @@ NAN's `node::Buffer` helpers exist as the API has changed across supported Node
`Nan::AsyncWorker` and `Nan::AsyncProgressWorker` are helper classes that make working with asynchronous code easier.
- <a href="doc/asyncworker.md#api_nan_async_worker"><b><code>Nan::AsyncWorker</code></b></a>
- <a href="doc/asyncworker.md#api_nan_async_progress_worker"><b><code>Nan::AsyncProgressWorkerBase & Nan::AsyncProgressWorker</code></b></a>
- <a href="doc/asyncworker.md#api_nan_async_progress_worker"><b><code>Nan::AsyncProgressWorkerBase &amp; Nan::AsyncProgressWorker</code></b></a>
- <a href="doc/asyncworker.md#api_nan_async_queue_worker"><b><code>Nan::AsyncQueueWorker</code></b></a>
### Strings & Bytes
......@@ -393,11 +397,11 @@ By making a contribution to this project, I certify that:
<tr><th align="left">Nathan Rajlich</th><td><a href="https://github.com/TooTallNate">GitHub/TooTallNate</a></td><td><a href="http://twitter.com/TooTallNate">Twitter/@TooTallNate</a></td></tr>
<tr><th align="left">Brett Lawson</th><td><a href="https://github.com/brett19">GitHub/brett19</a></td><td><a href="http://twitter.com/brett19x">Twitter/@brett19x</a></td></tr>
<tr><th align="left">Ben Noordhuis</th><td><a href="https://github.com/bnoordhuis">GitHub/bnoordhuis</a></td><td><a href="http://twitter.com/bnoordhuis">Twitter/@bnoordhuis</a></td></tr>
<tr><th align="left">David Siegel</th><td><a href="https://github.com/agnat">GitHub/agnat</a></td><td>-</td></tr>
<tr><th align="left">David Siegel</th><td><a href="https://github.com/agnat">GitHub/agnat</a></td><td><a href="http://twitter.com/agnat">Twitter/@agnat</a></td></tr>
</tbody></table>
## Licence &amp; copyright
Copyright (c) 2016 NAN WG Members / Collaborators (listed above).
Copyright (c) 2017 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.
......@@ -10,6 +10,7 @@ environment:
- nodejs_version: "4"
- nodejs_version: "5"
- nodejs_version: "6"
- nodejs_version: "7"
# Install scripts. (runs after repo cloning)
install:
......
......@@ -3,7 +3,7 @@
`Nan::AsyncWorker` and `Nan::AsyncProgressWorker` are helper classes that make working with asynchronous code easier.
- <a href="#api_nan_async_worker"><b><code>Nan::AsyncWorker</code></b></a>
- <a href="#api_nan_async_progress_worker"><b><code>Nan::AsyncProgressWorker</code></b></a>
- <a href="#api_nan_async_progress_worker"><b><code>Nan::AsyncProgressWorkerBase &amp; Nan::AsyncProgressWorker</code></b></a>
- <a href="#api_nan_async_queue_worker"><b><code>Nan::AsyncQueueWorker</code></b></a>
<a name="api_nan_async_worker"></a>
......@@ -58,7 +58,7 @@ class AsyncWorker {
```
<a name="api_nan_async_progress_worker"></a>
### Nan::AsyncProgressWorkerBase & Nan::AsyncProgressWorker
### Nan::AsyncProgressWorkerBase &amp; Nan::AsyncProgressWorker
`Nan::AsyncProgressWorkerBase` is an _abstract_ class template that extends `Nan::AsyncWorker` and adds additional progress reporting callbacks that can be used during the asynchronous work execution to provide progress data back to JavaScript.
......
......@@ -37,6 +37,10 @@ The `Nan::MaybeLocal` and `Nan::Maybe` types are monads that encapsulate `v8::Lo
- <a href="#api_nan_get_start_column"><b><code>Nan::GetStartColumn()</code></b></a>
- <a href="#api_nan_get_end_column"><b><code>Nan::GetEndColumn()</code></b></a>
- <a href="#api_nan_clone_element_at"><b><code>Nan::CloneElementAt()</code></b></a>
- <a href="#api_nan_has_private"><b><code>Nan::HasPrivate()</code></b></a>
- <a href="#api_nan_get_private"><b><code>Nan::GetPrivate()</code></b></a>
- <a href="#api_nan_set_private"><b><code>Nan::SetPrivate()</code></b></a>
- <a href="#api_nan_delete_private"><b><code>Nan::DeletePrivate()</code></b></a>
- <a href="#api_nan_make_maybe"><b><code>Nan::MakeMaybe()</code></b></a>
<a name="api_nan_maybe_local"></a>
......@@ -492,6 +496,50 @@ Signature:
Nan::MaybeLocal<v8::Object> Nan::CloneElementAt(v8::Local<v8::Array> array, uint32_t index);
```
<a name="api_nan_has_private"></a>
### Nan::HasPrivate()
A helper method for calling [`v8::Object#HasPrivate()`](https://v8docs.nodesource.com/node-7.2/db/d85/classv8_1_1_object.html#af68a0b98066cfdeb8f943e98a40ba08d) in a way compatible across supported versions of V8.
Signature:
```c++
Nan::Maybe<bool> Nan::HasPrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key);
```
<a name="api_nan_get_private"></a>
### Nan::GetPrivate()
A helper method for calling [`v8::Object#GetPrivate()`](https://v8docs.nodesource.com/node-7.2/db/d85/classv8_1_1_object.html#a169f2da506acbec34deadd9149a1925a) in a way compatible across supported versions of V8.
Signature:
```c++
Nan::MaybeLocal<v8::Value> Nan::GetPrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key);
```
<a name="api_nan_set_private"></a>
### Nan::SetPrivate()
A helper method for calling [`v8::Object#SetPrivate()`](https://v8docs.nodesource.com/node-7.2/db/d85/classv8_1_1_object.html#ace1769b0f3b86bfe9fda1010916360ee) in a way compatible across supported versions of V8.
Signature:
```c++
Nan::Maybe<bool> Nan::SetPrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key, v8::Local<v8::Value> value);
```
<a name="api_nan_delete_private"></a>
### Nan::DeletePrivate()
A helper method for calling [`v8::Object#DeletePrivate()`](https://v8docs.nodesource.com/node-7.2/db/d85/classv8_1_1_object.html#a138bb32a304f3982be02ad499693b8fd) in a way compatible across supported versions of V8.
Signature:
```c++
Nan::Maybe<bool> Nan::DeletePrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key);
```
<a name="api_nan_make_maybe"></a>
### Nan::MakeMaybe()
......
......@@ -78,8 +78,8 @@ class MyObject : public Nan::ObjectWrap {
tpl->SetClassName(Nan::New("MyObject").ToLocalChecked());
tpl->InstanceTemplate()->SetInternalFieldCount(1);
SetPrototypeMethod(tpl, "getHandle", GetHandle);
SetPrototypeMethod(tpl, "getValue", GetValue);
Nan::SetPrototypeMethod(tpl, "getHandle", GetHandle);
Nan::SetPrototypeMethod(tpl, "getValue", GetValue);
constructor().Reset(Nan::GetFunction(tpl).ToLocalChecked());
Nan::Set(target, Nan::New("MyObject").ToLocalChecked(),
......
......@@ -9,7 +9,7 @@ The creation of `HandleScope` objects is different across the supported versions
- <a href="#api_nan_handle_scope"><b><code>Nan::HandleScope</code></b></a>
- <a href="#api_nan_escapable_handle_scope"><b><code>Nan::EscapableHandleScope</code></b></a>
Also see the V8 Embedders Guide section on [Handles and Garbage Collection](https://developers.google.com/v8/embed#handles).
Also see the V8 Embedders Guide section on [Handles and Garbage Collection](https://github.com/v8/v8/wiki/Embedder%27s%20Guide#handles-and-garbage-collection).
<a name="api_nan_handle_scope"></a>
### Nan::HandleScope
......
......@@ -147,7 +147,7 @@ Signature:
void Nan::LowMemoryNotification()
```
Calls V8's [`IdleNotification()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#a24647f61d6b41f69668094bdcd6ea91f).
Calls V8's [`LowMemoryNotification()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#a24647f61d6b41f69668094bdcd6ea91f).
<a name="api_nan_context_disposed_notification"></a>
### Nan::ContextDisposedNotification()
......
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2016 NAN contributors
* Copyright (c) 2017 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
......
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2016 NAN contributors
* Copyright (c) 2017 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
......
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2016 NAN contributors
* Copyright (c) 2017 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
......
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2016 NAN contributors
* Copyright (c) 2017 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
......
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2016 NAN contributors
* Copyright (c) 2017 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
......
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2016 NAN contributors
* Copyright (c) 2017 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
......
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2016 NAN contributors
* Copyright (c) 2017 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
......
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2016 NAN contributors
* Copyright (c) 2017 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
......
This diff is collapsed.
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2016 NAN contributors
* Copyright (c) 2017 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
......
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2016 NAN contributors
* Copyright (c) 2017 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
......
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2016 NAN contributors
* Copyright (c) 2017 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
......@@ -45,24 +45,32 @@ class ReturnValue {
// Fast primitive setters
inline void Set(bool value) {
v8::HandleScope scope;
TYPE_CHECK(T, v8::Boolean);
value_->Dispose();
*value_ = v8::Persistent<T>::New(v8::Boolean::New(value));
}
inline void Set(double i) {
v8::HandleScope scope;
TYPE_CHECK(T, v8::Number);
value_->Dispose();
*value_ = v8::Persistent<T>::New(v8::Number::New(i));
}
inline void Set(int32_t i) {
v8::HandleScope scope;
TYPE_CHECK(T, v8::Integer);
value_->Dispose();
*value_ = v8::Persistent<T>::New(v8::Int32::New(i));
}
inline void Set(uint32_t i) {
v8::HandleScope scope;
TYPE_CHECK(T, v8::Integer);
value_->Dispose();
*value_ = v8::Persistent<T>::New(v8::Uint32::NewFromUnsigned(i));
......@@ -70,18 +78,24 @@ class ReturnValue {
// Fast JS primitive setters
inline void SetNull() {
v8::HandleScope scope;
TYPE_CHECK(T, v8::Primitive);
value_->Dispose();
*value_ = v8::Persistent<T>::New(v8::Null());
}
inline void SetUndefined() {
v8::HandleScope scope;
TYPE_CHECK(T, v8::Primitive);
value_->Dispose();
*value_ = v8::Persistent<T>::New(v8::Undefined());
}
inline void SetEmptyString() {
v8::HandleScope scope;
TYPE_CHECK(T, v8::String);
value_->Dispose();
*value_ = v8::Persistent<T>::New(v8::String::Empty());
......
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2016 NAN contributors
* Copyright (c) 2017 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
......
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2016 NAN contributors
* Copyright (c) 2017 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
......@@ -12,7 +12,11 @@
#define X(TYPE) \
imp::ToFactory<v8::TYPE>::return_t \
imp::ToFactory<v8::TYPE>::convert(v8::Local<v8::Value> val) { \
return val->To ## TYPE(GetCurrentContext()); \
v8::Isolate *isolate = v8::Isolate::GetCurrent(); \
v8::EscapableHandleScope scope(isolate); \
return scope.Escape( \
val->To ## TYPE(v8::Isolate::GetCurrent()->GetCurrentContext()) \
.FromMaybe(v8::Local<v8::TYPE>())); \
}
X(Boolean)
......@@ -28,7 +32,9 @@ X(Int32)
#define X(TYPE, NAME) \
imp::ToFactory<TYPE>::return_t \
imp::ToFactory<TYPE>::convert(v8::Local<v8::Value> val) { \
return val->NAME ## Value(GetCurrentContext()); \
v8::Isolate *isolate = v8::Isolate::GetCurrent(); \
v8::HandleScope scope(isolate); \
return val->NAME ## Value(isolate->GetCurrentContext()); \
}
X(bool, Boolean)
......
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2016 NAN contributors
* Copyright (c) 2017 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
......@@ -12,7 +12,7 @@
#define X(TYPE) \
imp::ToFactory<v8::TYPE>::return_t \
imp::ToFactory<v8::TYPE>::convert(v8::Local<v8::Value> val) { \
return MaybeLocal<v8::TYPE>(val->To ## TYPE()); \
return val->To ## TYPE(); \
}
X(Boolean)
......@@ -28,7 +28,7 @@ X(Int32)
#define X(TYPE, NAME) \
imp::ToFactory<TYPE>::return_t \
imp::ToFactory<TYPE>::convert(v8::Local<v8::Value> val) { \
return Just<TYPE>(val->NAME ##Value()); \
return Just(val->NAME ## Value()); \
}
X(bool, Boolean)
......
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2016 NAN contributors
* Copyright (c) 2017 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
......@@ -60,19 +60,15 @@ Factory<v8::Context>::New( v8::ExtensionConfiguration* extensions
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
Factory<v8::Date>::return_t
Factory<v8::Date>::New(double value) {
v8::Local<v8::Date> ret;
if (v8::Date::New(GetCurrentContext(), value).
ToLocal(reinterpret_cast<v8::Local<v8::Value>*>(&ret))) {
return v8::MaybeLocal<v8::Date>(ret);
} else {
return v8::MaybeLocal<v8::Date>(ret);
}
v8::Isolate *isolate = v8::Isolate::GetCurrent();
v8::EscapableHandleScope scope(isolate);
return scope.Escape(v8::Date::New(isolate->GetCurrentContext(), value)
.FromMaybe(v8::Local<v8::Value>()).As<v8::Date>());
}
#else
Factory<v8::Date>::return_t
Factory<v8::Date>::New(double value) {
return Factory<v8::Date>::return_t(
v8::Date::New(v8::Isolate::GetCurrent(), value).As<v8::Date>());
return v8::Date::New(v8::Isolate::GetCurrent(), value).As<v8::Date>();
}
#endif
......@@ -203,14 +199,18 @@ Factory<v8::RegExp>::return_t
Factory<v8::RegExp>::New(
v8::Local<v8::String> pattern
, v8::RegExp::Flags flags) {
return v8::RegExp::New(GetCurrentContext(), pattern, flags);
v8::Isolate *isolate = v8::Isolate::GetCurrent();
v8::EscapableHandleScope scope(isolate);
return scope.Escape(
v8::RegExp::New(isolate->GetCurrentContext(), pattern, flags)
.FromMaybe(v8::Local<v8::RegExp>()));
}
#else
Factory<v8::RegExp>::return_t
Factory<v8::RegExp>::New(
v8::Local<v8::String> pattern
, v8::RegExp::Flags flags) {
return Factory<v8::RegExp>::return_t(v8::RegExp::New(pattern, flags));
return v8::RegExp::New(pattern, flags);
}
#endif
......@@ -220,30 +220,36 @@ Factory<v8::RegExp>::New(
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
Factory<v8::Script>::return_t
Factory<v8::Script>::New( v8::Local<v8::String> source) {
v8::Isolate *isolate = v8::Isolate::GetCurrent();
v8::EscapableHandleScope scope(isolate);
v8::ScriptCompiler::Source src(source);
return v8::ScriptCompiler::Compile(GetCurrentContext(), &src);
return scope.Escape(
v8::ScriptCompiler::Compile(isolate->GetCurrentContext(), &src)
.FromMaybe(v8::Local<v8::Script>()));
}
Factory<v8::Script>::return_t
Factory<v8::Script>::New( v8::Local<v8::String> source
, v8::ScriptOrigin const& origin) {
v8::Isolate *isolate = v8::Isolate::GetCurrent();
v8::EscapableHandleScope scope(isolate);
v8::ScriptCompiler::Source src(source, origin);
return v8::ScriptCompiler::Compile(GetCurrentContext(), &src);
return scope.Escape(
v8::ScriptCompiler::Compile(isolate->GetCurrentContext(), &src)
.FromMaybe(v8::Local<v8::Script>()));
}
#else
Factory<v8::Script>::return_t
Factory<v8::Script>::New( v8::Local<v8::String> source) {
v8::ScriptCompiler::Source src(source);
return Factory<v8::Script>::return_t(
v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &src));
return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &src);
}
Factory<v8::Script>::return_t
Factory<v8::Script>::New( v8::Local<v8::String> source
, v8::ScriptOrigin const& origin) {
v8::ScriptCompiler::Source src(source, origin);
return Factory<v8::Script>::return_t(
v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &src));
return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &src);
}
#endif
......@@ -258,8 +264,7 @@ Factory<v8::Signature>::New(Factory<v8::Signature>::FTH receiver) {
Factory<v8::String>::return_t
Factory<v8::String>::New() {
return Factory<v8::String>::return_t(
v8::String::Empty(v8::Isolate::GetCurrent()));
return v8::String::Empty(v8::Isolate::GetCurrent());
}
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
......@@ -295,46 +300,33 @@ Factory<v8::String>::New(ExternalOneByteStringResource * value) {
#else
Factory<v8::String>::return_t
Factory<v8::String>::New(const char * value, int length) {
return Factory<v8::String>::return_t(
v8::String::NewFromUtf8(
v8::Isolate::GetCurrent()
, value
, v8::String::kNormalString
, length));
return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), value,
v8::String::kNormalString, length);
}
Factory<v8::String>::return_t
Factory<v8::String>::New(
std::string const& value) /* NOLINT(build/include_what_you_use) */ {
assert(value.size() <= INT_MAX && "string too long");
return Factory<v8::String>::return_t(
v8::String::NewFromUtf8(
v8::Isolate::GetCurrent()
, value.data()
, v8::String::kNormalString
, static_cast<int>(value.size())));
return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), value.data(),
v8::String::kNormalString,
static_cast<int>(value.size()));
}
Factory<v8::String>::return_t
Factory<v8::String>::New(const uint16_t * value, int length) {
return Factory<v8::String>::return_t(
v8::String::NewFromTwoByte(
v8::Isolate::GetCurrent()
, value
, v8::String::kNormalString
, length));
return v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), value,
v8::String::kNormalString, length);
}
Factory<v8::String>::return_t
Factory<v8::String>::New(v8::String::ExternalStringResource * value) {
return Factory<v8::String>::return_t(
v8::String::NewExternal(v8::Isolate::GetCurrent(), value));
return v8::String::NewExternal(v8::Isolate::GetCurrent(), value);
}
Factory<v8::String>::return_t
Factory<v8::String>::New(ExternalOneByteStringResource * value) {
return Factory<v8::String>::return_t(
v8::String::NewExternal(v8::Isolate::GetCurrent(), value));
return v8::String::NewExternal(v8::Isolate::GetCurrent(), value);
}
#endif
......@@ -367,16 +359,14 @@ Factory<v8::UnboundScript>::New( v8::Local<v8::String> source
Factory<v8::UnboundScript>::return_t
Factory<v8::UnboundScript>::New(v8::Local<v8::String> source) {
v8::ScriptCompiler::Source src(source);
return Factory<v8::UnboundScript>::return_t(
v8::ScriptCompiler::CompileUnbound(v8::Isolate::GetCurrent(), &src));
return v8::ScriptCompiler::CompileUnbound(v8::Isolate::GetCurrent(), &src);
}
Factory<v8::UnboundScript>::return_t
Factory<v8::UnboundScript>::New( v8::Local<v8::String> source
, v8::ScriptOrigin const& origin) {
v8::ScriptCompiler::Source src(source, origin);
return Factory<v8::UnboundScript>::return_t(
v8::ScriptCompiler::CompileUnbound(v8::Isolate::GetCurrent(), &src));
return v8::ScriptCompiler::CompileUnbound(v8::Isolate::GetCurrent(), &src);
}
#endif
......
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2016 NAN contributors
* Copyright (c) 2017 NAN contributors
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
......@@ -57,7 +57,7 @@ Factory<v8::Context>::New( v8::ExtensionConfiguration* extensions
Factory<v8::Date>::return_t
Factory<v8::Date>::New(double value) {
return Factory<v8::Date>::return_t(v8::Date::New(value).As<v8::Date>());
return v8::Date::New(value).As<v8::Date>();
}
//=== External =================================================================
......@@ -72,10 +72,11 @@ Factory<v8::External>::New(void * value) {
Factory<v8::Function>::return_t
Factory<v8::Function>::New( FunctionCallback callback
, v8::Local<v8::Value> data) {
return Factory<v8::FunctionTemplate>::New( callback
, data
, v8::Local<v8::Signature>()
)->GetFunction();