Aaron Kau
d9df8cfe77
n-api: change assert ok check to notStrictEqual.
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/18414
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2018-04-16 17:46:14 -04:00
Rich Trott
eceb70b584
test: refactor addons-napi/test_exception/test.js
...
* provide block scoping to prevent unintended side effects
* remove confusing and unnecessary assertion message
* use consisitent `actual, expected` argument order for assertions
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/18340
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Jon Moss <me@jonathanmoss.me >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-04-16 17:46:14 -04:00
Michael Dawson
74086e19f2
doc: remove uannecessary Require
...
This was the only instance were we said a parameter
was required. It is assumed parameters are required unless
the doc says they are option. Remove `Required` to make
consistent with the rest of the doc
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/18184
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com >
2018-04-16 17:46:14 -04:00
furstenheim
b3806ecd39
test: fixed typos in napi test
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/18148
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Jon Moss <me@jonathanmoss.me >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2018-04-16 17:46:14 -04:00
Jinho Bang
2e24a0bfe7
n-api: throw RangeError napi_create_typedarray()
...
According to the ECMA spec, we should throw a RangeError in the
following cases:
- `(length * elementSize) + offset` > the size of the array passed in
- `offset % elementSize` != `0`
In the current implementation, this check was omitted. So, the following
code will cause a crash.
```
napi_create_typedarray(env, napi_uint16_array, 2 /* length */,
buffer, 1 /* byte_offset */, &output_array);
```
This change fixes the problem and write some related tests.
Refs:
https://tc39.github.io/ecma262/#sec-typedarray-buffer-byteoffset-length
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/18037
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2018-04-16 17:46:14 -04:00
Ali Ijaz Sheikh
fed2136857
doc: napi: make header style consistent
...
Some of the API section headers had emphasis, while others did not.
Use a consistent style (no emphasis) for all of them, as that matches
our other API docs.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/18122
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Kyle Farnung <kfarnung@microsoft.com >
Reviewed-By: Jon Moss <me@jonathanmoss.me >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2018-04-16 17:46:13 -04:00
Ali Ijaz Sheikh
e04386a363
doc: napi: fix unbalanced emphasis
...
Some of the section headers had unbalanced emphasis.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/18122
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Kyle Farnung <kfarnung@microsoft.com >
Reviewed-By: Jon Moss <me@jonathanmoss.me >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2018-04-16 17:46:13 -04:00
Michael Dawson
62427bbed9
n-api: expose n-api version in process.versions
...
Expose n-api version in process.versions so that it is
available for use in javascript by external modules
like node-pre-gyp. It was previously accessible through
a functon available in the N-API.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/18067
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Minwoo Jung <minwoo@nodesource.com >
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com >
Reviewed-By: Tobias Nießn <tniessen@tnie.de >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
2018-04-16 17:46:13 -04:00
Jinho Bang
bb99f31f30
n-api: throw RangeError in napi_create_dataview() with invalid range
...
The API is required that `byte_length + byte_offset` is less than or
equal to the size in bytes of the array passed in. If not, a RangeError
exception is raised[1].
[1] https://nodejs.org/api/n-api.html#n_api_napi_create_dataview
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/17869
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-04-16 17:46:13 -04:00
Michael Dawson
3d8e1aaf48
doc: updates examples to use NULL
...
Examples in the N-API doc used a mix of nullptr and NULL.
We should be consistent and because N-API is a 'C' API I believe
using NULL is better. This will avoid any potential confusion
as to whether N-API can be used with plain C.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/18008
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
2018-04-16 17:46:13 -04:00
Nicholas Drane
a6c277e2eb
test: remove ambiguous error messages from test_error
...
assert.strictEqual accepts 3 arguments, the last of which allows for
user-specified error message to be thrown when the assertion fails.
Unfortunately, this error message is less helpful than the default when
it is vague. This commit removes vague, user-specified error messages,
instead relying on clearer, default error messages.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/17812
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Jon Moss <me@jonathanmoss.me >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2018-04-16 17:46:13 -04:00
alnyan
65ea7abd55
n-api: fix memory leak in napi_async_destroy()
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/17714
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Timothy Gu <timothygu99@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-04-16 17:46:12 -04:00
Rich Trott
412cc17748
test: remove literals that obscure assert messages
...
Remove string literals as messages to `assert.strictEqual()`. They can
be misleading here (where perhaps the reason an assertino failed isn't
that the deleter wasn't called but rather was called too many times.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/17642
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Jon Moss <me@jonathanmoss.me >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2018-04-16 17:46:12 -04:00
babygoat
86ddd03608
test: add unhandled rejection guard
...
Add an unhandled rejection function in
addons-napi/test_promise/test.js. Also, add a
rejection handler to catch the unhandled rejection
after introducing the guard and test the reason
code.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/17275
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2018-04-16 17:46:12 -04:00
Leko
e54b58c024
test: replace assert.throws with common.expectsError
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/17445
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Jon Moss <me@jonathanmoss.me >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-04-16 17:46:12 -04:00
Franziska Hinkelmann
173f29763e
doc: update example in module registration
...
Update return type of `Init` function in documentation to match
`napi_addon_register_func` signature. Return type used to be
`void`, now it is `napi_value`.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/17424
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-04-16 17:46:12 -04:00
Daniel Bevenius
d4284a464b
n-api: use nullptr instead of NULL in node_api.cc
...
This commit changes two checks which use NULL to use nullptr.
I'm not very familiar with N-API but wanted to bring this up in case
it was something that was overlooked.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/17276
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Timothy Gu <timothygu99@gmail.com >
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: Lance Ball <lball@redhat.com >
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: MichaëZasso <targos@protonmail.com >
2018-04-16 17:46:11 -04:00
Rich Trott
c6852126fd
doc: use "JavaScript" instead of "Javascript"
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/17163
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
2018-04-16 17:46:11 -04:00
neta
b20c278a7c
src: add napi_handle_scope_mismatch to msg list
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/17161
Reviewed-By: Timothy Gu <timothygu99@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com >
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
2018-04-16 17:46:11 -04:00
Anna Henningsen
f4391b95ee
n-api: add helper for addons to get the event loop
...
Add a utility functions for addons to use when they need
a reference to the current event loop.
While the libuv API is not directly part of N-API, it
provides a quite stable C API as well, and is tightly
integrated with Node itself.
As a particular use case, without access to the event loop
it is hard to do something interesting from inside a N-API
finalizer function, since calls into JS and therefore virtually
all other N-API functions are not allowed.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/17109
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2018-04-16 17:46:11 -04:00
Michael Dawson
35dc8bab9e
doc: document common pattern for instanceof checks
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/16699
Fixes: https://github.com/nodejs/node/issues/13824
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2018-04-16 17:46:11 -04:00
ka3e
976f32d189
test: refactor addons-napi/test_promise/test.js
...
* remove custom messages for assert that conceal values
* add comment explaining test
* add block scoping
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/16814
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-04-16 17:46:11 -04:00
Swathi Kalahastri
22490dcb91
doc: fix typos in N-API
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/16911
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
2018-04-16 17:46:10 -04:00
Paul Ashfield
2476ab9619
test: improve error emssage reporting in testNapiRun.js
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/16821
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
2018-04-16 17:46:10 -04:00
Vipin Menon
55fabd7337
doc: fix a typo in n-api documentation
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/16879
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2018-04-16 17:46:10 -04:00
Paul Blanche
d4c04e05f7
test: improve assert messages in napi exception test
...
Include unexpected value in assertion messages.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/16820
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2018-04-16 17:46:10 -04:00
Attila Gonda
c14207c77b
test: add detailed message for assertion failure
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/16812
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
2018-04-16 17:46:10 -04:00
John Byrne
d31792fcbe
test: use default assertion messages
...
The string literal messages in addons-napi/test_buffer/test.js are less
helpful than the default messages, so use the default messages.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/16808
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2018-04-16 17:46:10 -04:00
Matthew Cantelon
087d213f67
test: include actual value in assertion message
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/15935
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
2018-04-16 17:46:09 -04:00
Jayson D. Henkel
9cc435dc85
test: improve message for assert.strictEqual()
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/16013
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Evan Lucas <evanlucas@me.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2018-04-16 17:46:09 -04:00
Gabriel Schulhof
3c84db624a
n-api: unexpose symbols and remove EXTERNAL_NAPI
...
* namespaced functions such as v8impl::JsHandleScopeFromV8HandleScope
become part of Node's public symbols unless they are declared static.
* the class uvimpl::Work needs to be enclosed in an anonymous namespace
else it, too becomes part of Node's public symbols.
* remove references to EXTERNAL_NAPI.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/16234
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2018-04-16 17:46:09 -04:00
Anna Henningsen
55aab6bf01
n-api: check against invalid handle scope usage
...
Fixes: https://github.com/nodejs/node/issues/16175
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/16201
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2018-04-16 17:46:09 -04:00
Michael Dawson
169b53e788
n-api: use module name macro
...
Update tests to use module name macro
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/16185
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2018-04-16 17:46:09 -04:00
Michael Dawson
0c67f21bcf
doc: update to use NAPI_AUTO_LENGTH
...
Update so that doc says to use NAPI_AUTO_LENGTH instead
of -1 to indicate null terminate string.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/16187
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2018-04-16 17:46:09 -04:00
Vse Mozhet Byt
5c2bba0931
doc: fix some links
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/16202
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2018-04-16 17:46:08 -04:00
Christina Chan
ebbd07dd27
test: remove redundant error messages
...
Remove redundant error messages for assert.strictEqual()
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/16043
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-04-16 17:46:08 -04:00
Gabriel Schulhof
011b53e28f
n-api,test: use module name macro
...
test_constructor_name.c should use NODE_GYP_MODULE_NAME.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/16146
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Evan Lucas <evanlucas@me.com >
2018-04-16 17:46:08 -04:00
Gabriel Schulhof
32412a8ded
n-api: make changes for source compatibility
...
These changes are necessary in order to retain source compatibility
with older versions of node.
The removal of `module_version` from `napi_module_register()` is
reverted from the flag removal PR, because it should not have been a
part of it.
`CallbackWrapper::NewTarget()` is renamed to
`CallbackWrapper::GetNewTarget()` to distinguish it from V8's native
method, thus allowing for a macro which reduces `NewTarget()` to
`This()` on V8 versions where it was not yet available.
`AsyncResource` is constructed with a C string rather than a V8 string
because the former is available on all versions of node.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/16102
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Jason Ginchereau <jasongin@microsoft.com >
2018-04-16 17:46:08 -04:00
mrgorbo
5bba809e01
test: cleaned up assert messages
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/16032
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Timothy Gu <timothygu99@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-04-16 17:46:08 -04:00
Kinnan Kwok
53bd313739
test: fix race condition in addon test
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/16037
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Evan Lucas <evanlucas@me.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
2018-04-16 17:46:08 -04:00
Emily Ford
37acd806be
test: remove template literal
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/15953
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2018-04-16 17:46:07 -04:00
Michael Dawson
00d094f9c3
n-api: add check for large strings
...
n-api uses size_t for the size of strings when specifying
string lengths. V8 only supports a size of int. Add
a check so that an error will be returned if the user
passes in a string with a size larger than will fit into
an int.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/15611
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com >
2018-04-16 17:46:07 -04:00
rebornix
e9a6dffc65
doc: fix outdated code sample in n-api.md
...
code samples of napi_create_object and napi_property_descriptor were
not updated to latest API.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/15581
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-04-16 17:46:07 -04:00
Sampson Gao
2bc8a59915
n-api: fix warning about size_t compare with int
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/15508
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2018-04-16 17:46:07 -04:00
Vse Mozhet Byt
ca69f1dfe7
doc: fix new nits in links
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/15449
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2018-04-16 17:46:07 -04:00
Gabriel Schulhof
5e29823d1d
n-api: remove n-api module loading flag
...
Remove the command line flag that was needed for N-API module loading.
Re: https://github.com/nodejs/vm/issues/9
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/14902
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Hitesh Kanwathirtha <digitalinfinity@gmail.com >
2018-04-16 17:46:07 -04:00
Sampson Gao
f31b50cfc7
n-api: add optional string length parameters
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/15343
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
2018-04-16 17:46:06 -04:00
Sampson Gao
fe87a5944b
n-api: napi_is_construct_call->napi_get_new_target
...
Remove napi_is_construct_call and introduce napi_get_new_target.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/14698
Reviewed-By: Jason Ginchereau <jasongin@microsoft.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Kyle Farnung <kfarnung@microsoft.com >
2018-04-16 17:46:06 -04:00
Jason Ginchereau
5eadd6249d
n-api: Context for custom async operations
...
- Add napi_async_context opaque pointer type.
(If needed, we could later add APIs for getting the async IDs
out of this context.)
- Add napi_async_init() and napi_async_destroy() APIs.
- Add async_context parameter to napi_make_callback().
- Add code and checks to test_make_callback to validate async context
APIs by checking async hooks are called with correct context.
- Update API documentation.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/15189
Fixes: https://github.com/nodejs/node/issues/13254
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-04-16 17:46:06 -04:00
Taylor Woll
50cb48b55c
n-api: refactor napi_addon_register_func
...
As per discussion in abi-stable-node:
https://github.com/nodejs/abi-stable-node/issues/256 ,
take a refactor to napi_addon_register_func such that
the result from the register function is assigned to
the module exports property. By making this change,
native module can be agnostic about which type of
module the environment supports.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/15088
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: Hitesh Kanwathirtha <digitalinfinity@gmail.com >
2018-04-16 17:46:06 -04:00