Comparing version 1.3.0 to 1.4.0
# NAN ChangeLog | ||
### Version 1.3.0: current Node unstable: 0.11.13, Node stable: 0.10.30 | ||
**Version 1.4.0: current Node unstable: 0.11.14, Node stable: 0.10.33** | ||
### 1.4.0 Nov 1 2014 | ||
**1.3.0 Aug 2 2014** | ||
- Feature: Cdded NAN_GC_CALLBACK 6a5c245 | ||
- Performance: Removed unnecessary local handle creation 18a7243, 41fe2f8 | ||
- Correctness: Added constness to references in NanHasInstance 02c61cd | ||
- Warnings: Fixed spurious warnings from -Wundef and -Wshadow, 541b122, 99d8cb6 | ||
- Windoze: Shut Visual Studio up when compiling 8d558c1 | ||
- License: Switch to plain MIT from custom hacked MIT license 11de983 | ||
- Build: Added test target to Makefile e232e46 | ||
- Performance: Removed superfluous scope in NanAsyncWorker f4b7821 | ||
- Sugar/Feature: Added NanReturnThis() and NanReturnHolder() shorthands 237a5ff, d697208 | ||
- Feature: Added suitable overload of NanNew for v8::Integer::NewFromUnsigned b27b450" | ||
### 1.3.0 Aug 2 2014 | ||
- Added NanNew<v8::String, std::string>(std::string) | ||
@@ -24,3 +36,3 @@ - Added NanNew<v8::String, std::string&>(std::string&) | ||
**1.2.0 Jun 5 2014** | ||
### 1.2.0 Jun 5 2014 | ||
@@ -33,11 +45,11 @@ - Add NanSetPrototypeTemplate | ||
**1.1.2 May 28 2014** | ||
### 1.1.2 May 28 2014 | ||
- Release to fix more stuff-ups in 1.1.1 | ||
**1.1.1 May 28 2014** | ||
### 1.1.1 May 28 2014 | ||
- Release to fix version mismatch in nan.h and lack of changelog entry for 1.1.0 | ||
**1.1.0 May 25 2014** | ||
### 1.1.0 May 25 2014 | ||
@@ -51,3 +63,3 @@ - Remove nan_isolate, use v8::Isolate::GetCurrent() internally instead | ||
**1.0.0 May 4 2014** | ||
### 1.0.0 May 4 2014 | ||
@@ -76,3 +88,3 @@ - Heavy API changes for V8 3.25 / Node 0.11.13 | ||
**0.8.0 Jan 9 2014** | ||
### 0.8.0 Jan 9 2014 | ||
@@ -82,3 +94,3 @@ - NanDispose -> NanDisposePersistent, deprecate NanDispose | ||
**0.7.1 Jan 9 2014** | ||
### 0.7.1 Jan 9 2014 | ||
@@ -89,3 +101,3 @@ - Fixes to work against debug builds of Node | ||
**0.7.0 Dec 17 2013** | ||
### 0.7.0 Dec 17 2013 | ||
@@ -101,3 +113,3 @@ - New no-arg form of NanCallback() constructor. | ||
**0.6.0 Nov 21 2013** | ||
### 0.6.0 Nov 21 2013 | ||
@@ -107,11 +119,11 @@ - Introduce NanNewLocal<T>(v8::Handle<T> value) for use in place of | ||
**0.5.2 Nov 16 2013** | ||
### 0.5.2 Nov 16 2013 | ||
- Convert SavePersistent and GetFromPersistent in NanAsyncWorker from protected and public | ||
**0.5.1 Nov 12 2013** | ||
### 0.5.1 Nov 12 2013 | ||
- Use node::MakeCallback() instead of direct v8::Function::Call() | ||
**0.5.0 Nov 11 2013** | ||
### 0.5.0 Nov 11 2013 | ||
@@ -122,11 +134,11 @@ - Added @TooTallNate as collaborator | ||
**0.4.4 Nov 2 2013** | ||
### 0.4.4 Nov 2 2013 | ||
- Isolate argument from v8::Persistent::MakeWeak removed for 0.11.8+ | ||
**0.4.3 Nov 2 2013** | ||
### 0.4.3 Nov 2 2013 | ||
- Include node_object_wrap.h, removed from node.h for Node 0.11.8. | ||
**0.4.2 Nov 2 2013** | ||
### 0.4.2 Nov 2 2013 | ||
@@ -136,7 +148,7 @@ - Handle deprecation of v8::Persistent::Dispose(v8::Isolate* isolate)) for | ||
**0.4.1 Sep 16 2013** | ||
### 0.4.1 Sep 16 2013 | ||
- Added explicit `#include <uv.h>` as it was removed from node.h for v0.11.8 | ||
**0.4.0 Sep 2 2013** | ||
### 0.4.0 Sep 2 2013 | ||
@@ -147,3 +159,3 @@ - Added NAN_INLINE and NAN_DEPRECATED and made use of them | ||
**0.3.2 Aug 30 2013** | ||
### 0.3.2 Aug 30 2013 | ||
@@ -153,7 +165,7 @@ - Fix missing scope declaration in GetFromPersistent() and SaveToPersistent | ||
**0.3.1 Aug 20 2013** | ||
### 0.3.1 Aug 20 2013 | ||
- fix "not all control paths return a value" compile warning on some platforms | ||
**0.3.0 Aug 19 2013** | ||
### 0.3.0 Aug 19 2013 | ||
@@ -173,7 +185,7 @@ - Made NAN work with NPM | ||
**0.2.2 Aug 5 2013** | ||
### 0.2.2 Aug 5 2013 | ||
- Fixed usage of undefined variable with node::BASE64 in NanFromV8String() | ||
**0.2.1 Aug 5 2013** | ||
### 0.2.1 Aug 5 2013 | ||
@@ -183,3 +195,3 @@ - Fixed 0.8 breakage, node::BUFFER encoding type not available in 0.8 for | ||
**0.2.0 Aug 5 2013** | ||
### 0.2.0 Aug 5 2013 | ||
@@ -206,3 +218,3 @@ - Added NAN_PROPERTY_GETTER, NAN_PROPERTY_SETTER, NAN_PROPERTY_ENUMERATOR, | ||
**0.1.0 Jul 21 2013** | ||
### 0.1.0 Jul 21 2013 | ||
@@ -209,0 +221,0 @@ - Added `NAN_GETTER`, `NAN_SETTER` |
{ | ||
"name": "nan", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Native Abstractions for Node.js: C++ header for Node 0.8->0.12 compatibility", | ||
@@ -24,4 +24,4 @@ "main": "include_dirs.js", | ||
"bindings": "~1.2.1", | ||
"node-gyp": "~1.0.1", | ||
"tap": "~0.4.12", | ||
"node-gyp": "~1.0.2", | ||
"tap": "~0.4.13", | ||
"xtend": "~4.0.0" | ||
@@ -28,0 +28,0 @@ }, |
190
README.md
@@ -6,7 +6,7 @@ Native Abstractions for Node.js | ||
***Current version: 1.3.0*** | ||
***Current version: 1.4.0*** | ||
*(See [nan.h](https://github.com/rvagg/nan/blob/master/CHANGELOG.md) for complete ChangeLog)* | ||
*(See [CHANGELOG.md](https://github.com/rvagg/nan/blob/master/CHANGELOG.md) for complete ChangeLog)* | ||
[![NPM](https://nodei.co/npm/nan.png?downloads=true)](https://nodei.co/npm/nan/) [![NPM](https://nodei.co/npm-dl/nan.png?months=6)](https://nodei.co/npm/nan/) | ||
[![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/) | ||
@@ -104,2 +104,4 @@ [![Build Status](https://secure.travis-ci.org/rvagg/nan.png)](http://travis-ci.org/rvagg/nan) | ||
For another example, see **[nan-example-eol](https://github.com/CodeCharmLtd/nan-example-eol)**. It shows newline detection implemented as a native addon. | ||
Compare to the current 0.10 version of this example, found in the [node-addon-examples](https://github.com/rvagg/node-addon-examples/tree/master/9_async_work) repository and also a 0.11 version of the same found [here](https://github.com/kkoopa/node-addon-examples/tree/5c01f58fc993377a567812597e54a83af69686d7/9_async_work). | ||
@@ -243,2 +245,3 @@ | ||
* <a href="#api_nan_index_query"><b><code>NAN_INDEX_QUERY</code></b></a> | ||
* <a href="#api_nan_gc_callback"><b><code>NAN_GC_CALLBACK</code></b></a> | ||
* <a href="#api_nan_weak_callback"><b><code>NAN_WEAK_CALLBACK</code></b></a> | ||
@@ -256,2 +259,4 @@ * <a href="#api_nan_deprecated"><b><code>NAN_DEPRECATED</code></b></a> | ||
* <a href="#api_nan_return_empty_string"><b><code>NanReturnEmptyString</code></b></a> | ||
* <a href="#api_nan_return_this"><b><code>NanReturnThis</code></b></a> | ||
* <a href="#api_nan_return_holder"><b><code>NanReturnHolder</code></b></a> | ||
* <a href="#api_nan_scope"><b><code>NanScope</code></b></a> | ||
@@ -406,2 +411,22 @@ * <a href="#api_nan_escapable_scope"><b><code>NanEscapableScope</code></b></a> | ||
<a name="api_nan_gc_callback"></a> | ||
### NAN_GC_CALLBACK(cbname) | ||
Use `NAN_GC_CALLBACK` to declare your callbacks for `NanAddGCEpilogueCallback` and `NanAddGCPrologueCallback`. You get arguments `GCType type` and `GCCallbackFlags flags`. | ||
```c++ | ||
static Persistent<Function> callback; | ||
NAN_GC_CALLBACK(gcPrologueCallback) { | ||
Local<Value> argv[] = {NanNew("prologue")}; | ||
NanMakeCallback(NanGetCurrentContext()->Global(), NanNew(callback), 1, argv); | ||
} | ||
NAN_METHOD(Hook) { | ||
NanScope(); | ||
NanAssignPersistent(callback, args[0].As<Function>()); | ||
NanAddGCPrologueCallback(gcPrologueCallback); | ||
NanReturnValue(args.Holder()); | ||
} | ||
``` | ||
<a name="api_nan_weak_callback"></a> | ||
@@ -542,2 +567,28 @@ ### NAN_WEAK_CALLBACK(cbname) | ||
<a name="api_nan_return_this"></a> | ||
### NanReturnThis() | ||
Use `NanReturnThis` when you want to return `This` from your V8 accessible method: | ||
```c++ | ||
NAN_METHOD(Foo::Baz) { | ||
... | ||
NanReturnThis(); | ||
} | ||
``` | ||
<a name="api_nan_return_holder"></a> | ||
### NanReturnHolder() | ||
Use `NanReturnHolder` when you want to return `Holder` from your V8 accessible method: | ||
```c++ | ||
NAN_METHOD(Foo::Baz) { | ||
... | ||
NanReturnHolder(); | ||
} | ||
``` | ||
<a name="api_nan_scope"></a> | ||
@@ -643,6 +694,6 @@ ### NanScope() | ||
<a name="api_nan_symbol"></a> | ||
### <del>Local<String> NanSymbol(const char *)</del> | ||
### ~~Local<String> NanSymbol(const char *)~~ | ||
Deprecated. Use `NanNew<String>` instead. | ||
<del>Use to create string symbol objects (i.e. `v8::String::NewSymbol(x)`), for getting and setting object properties, or names of objects.</del> | ||
~~Use to create string symbol objects (i.e. `v8::String::NewSymbol(x)`), for getting and setting object properties, or names of objects.~~ | ||
@@ -688,8 +739,8 @@ ```c++ | ||
<a name="api_nan_raw_string"></a> | ||
### <del>void* NanRawString(Handle<Value>, enum Nan::Encoding, size_t *, void *, size_t, int)</del> | ||
### ~~void* NanRawString(Handle<Value>, enum Nan::Encoding, size_t *, void *, size_t, int)~~ | ||
Deprecated. Use something else. | ||
<del>When you want to convert a V8 `String` to a `char*` buffer, use `NanRawString`. You have to supply an encoding as well as a pointer to a variable that will be assigned the number of bytes in the returned string. It is also possible to supply a buffer and its length to the function in order not to have a new buffer allocated. The final argument allows setting `String::WriteOptions`. | ||
Just remember that you'll end up with an object that you'll need to `delete[]` at some point unless you supply your own buffer:</del> | ||
~~When you want to convert a V8 `String` to a `char*` buffer, use `NanRawString`. You have to supply an encoding as well as a pointer to a variable that will be assigned the number of bytes in the returned string. It is also possible to supply a buffer and its length to the function in order not to have a new buffer allocated. The final argument allows setting `String::WriteOptions`. | ||
Just remember that you'll end up with an object that you'll need to `delete[]` at some point unless you supply your own buffer:~~ | ||
@@ -704,8 +755,8 @@ ```c++ | ||
<a name="api_nan_c_string"></a> | ||
### <del>char* NanCString(Handle<Value>, size_t *[, char *, size_t, int])</del> | ||
### ~~char* NanCString(Handle<Value>, size_t *[, char *, size_t, int])~~ | ||
Deprecated. Use `NanUtf8String` instead. | ||
Deprecated. Use `String::Utf8Value` or `NanUtf8String` instead. | ||
<del>When you want to convert a V8 `String` to a null-terminated C `char*` use `NanCString`. The resulting `char*` will be UTF-8-encoded, and you need to supply a pointer to a variable that will be assigned the number of bytes in the returned string. It is also possible to supply a buffer and its length to the function in order not to have a new buffer allocated. The final argument allows optionally setting `String::WriteOptions`, which default to `v8::String::NO_OPTIONS`. | ||
Just remember that you'll end up with an object that you'll need to `delete[]` at some point unless you supply your own buffer:</del> | ||
~~When you want to convert a V8 `String` to a null-terminated C `char*` use `NanCString`. The resulting `char*` will be UTF-8-encoded, and you need to supply a pointer to a variable that will be assigned the number of bytes in the returned string. It is also possible to supply a buffer and its length to the function in order not to have a new buffer allocated. The final argument allows optionally setting `String::WriteOptions`, which default to `v8::String::NO_OPTIONS`. | ||
Just remember that you'll end up with an object that you'll need to `delete[]` at some point unless you supply your own buffer:~~ | ||
@@ -722,3 +773,4 @@ ```c++ | ||
Convert a `String` to zero-terminated, Ascii-encoded `char *`. | ||
Contrary to the name, this is not actually an ASCII string, it is a one-byte string with no particular encoding. Do not use unless you actually need this incorrect legacy behavior. Consider fixing your broken code instead. If you actually have a proper ASCII-string, use UTF-8, which is a proper superset of ASCII. | ||
Convert a `String` to zero-terminated, sort-of Ascii-encoded `char *`. The underlying buffer is freed when the owner object goes out of scope, so make a copy or heap allocation if you need it to stick around. | ||
@@ -732,6 +784,40 @@ ```c++ | ||
####*WRONG*: | ||
the buffer `str` points to has been freed when `baz` was destroyed: | ||
```c++ | ||
static char *str; | ||
NAN_METHOD(bar) { | ||
NanScope(); | ||
NanAsciiString baz(arg[0]); | ||
str = *baz; | ||
NanReturnUndefined(); // baz goes out of scope, freeing str | ||
} | ||
... | ||
printf(str); // use-after-free error | ||
``` | ||
####*RIGHT*: | ||
```c++ | ||
static NanAsciiString *str; | ||
NAN_METHOD(bar) { | ||
NanScope(); | ||
str = new NanAsciiString(arg[0]); | ||
NanReturnUndefined(); | ||
} | ||
... | ||
printf(**str); | ||
``` | ||
<a name="api_nan_utf8_string"></a> | ||
### NanUtf8String | ||
Convert a `String` to zero-terminated, Utf8-encoded `char *`. | ||
Equivalent to `String::Utf8Value`, it only exists for the sake of completeness. | ||
Convert a `String` to zero-terminated, Utf8-encoded `char *`. The underlying buffer is freed when the owner object goes out of scope, so make a copy or heap allocation if you need it to stick around. | ||
@@ -745,6 +831,41 @@ ```c++ | ||
####*WRONG*: | ||
the buffer `str` points to has been freed when `baz` was destroyed: | ||
```c++ | ||
static char *str; | ||
NAN_METHOD(bar) { | ||
NanScope(); | ||
NanUtf8String baz(arg[0]); | ||
str = *baz; | ||
NanReturnUndefined(); // baz goes out of scope, freeing str | ||
} | ||
... | ||
printf(str); // use-after-free error | ||
``` | ||
####*RIGHT*: | ||
```c++ | ||
static NanUtf8String *str; | ||
NAN_METHOD(bar) { | ||
NanScope(); | ||
str = new NanUtf8String(arg[0]); | ||
NanReturnUndefined(); | ||
} | ||
... | ||
printf(**str); | ||
``` | ||
<a name="api_nan_ucs2_string"></a> | ||
### NanUcs2String | ||
Convert a `String` to zero-terminated, Ucs2-encoded `uint16_t *`. | ||
Equivalent to `String::Value`, it only exists for the sake of completeness. | ||
Convert a `String` to zero-terminated, Ucs2-encoded `uint16_t *`. The underlying buffer is freed when the owner object goes out of scope, so make a copy or heap allocation if you need it to stick around. | ||
@@ -758,2 +879,35 @@ ```c++ | ||
####*WRONG*: | ||
the buffer `str` points to has been freed when `baz` was destroyed: | ||
```c++ | ||
static char *str; | ||
NAN_METHOD(bar) { | ||
NanScope(); | ||
NanUcs2String baz(arg[0]); | ||
str = *baz; | ||
NanReturnUndefined(); // baz goes out of scope, freeing str | ||
} | ||
... | ||
printf(str); // use-after-free error | ||
``` | ||
####*RIGHT*: | ||
```c++ | ||
static NanUcs2String *str; | ||
NAN_METHOD(bar) { | ||
NanScope(); | ||
str = new NanUcs2String(arg[0]); | ||
NanReturnUndefined(); | ||
} | ||
... | ||
printf(**str); | ||
``` | ||
<a name="api_nan_boolean_option_value"></a> | ||
@@ -917,3 +1071,3 @@ ### bool NanBooleanOptionValue(Handle<Value>, Handle<String>[, bool]) | ||
Use instead of `node::MakeCallback` to call javascript functions. This is the only proper way of calling functions. | ||
Use instead of `node::MakeCallback` to call javascript functions. This (or `NanCallback`) is the only proper way of calling functions. You must _*never, ever*_ directly use `Function::Call`, it will lead to run-time failures. | ||
@@ -992,3 +1146,3 @@ <a name="api_nan_compile_script"></a> | ||
`NanCallback` also has a `Local<Function> GetCallback()` method that you can use | ||
`NanCallback` also has a `Local<Function> GetFunction()` method that you can use | ||
to fetch a local handle to the underlying callback function, as well as a | ||
@@ -1069,2 +1223,2 @@ `void SetFunction(Handle<Function>)` for setting the callback on the | ||
Native Abstractions for Node.js is licensed under an MIT +no-false-attribs license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details. | ||
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. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
129785
0
1209