Gabriel Schulhof
af62c8fff7
n-api: update reference test
...
Remove the necessity for allocating on the heap, and assert that the
correct pointer gets passed to the finalizer.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/19086
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2018-04-16 17:46:17 -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
Jason Ginchereau
b29eb693a0
n-api: optimize number API performance
...
- Add separate APIs for creating different kinds of numbers,
because creating a V8 number value from an integer is faster
than creating one from a double.
- When getting number values, avoid getting the current context
because the context will not actually be used and is expensive
to obtain.
- When creating values, don't use v8::TryCatch (NAPI_PREAMBLE),
because these functions have no possibility of executing JS code.
Refs: https://github.com/nodejs/node/issues/14379
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/14573
Reviewed-By: Timothy Gu <timothygu99@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2018-04-16 17:46:03 -04:00
Song, Bintao Garfield
3f3eaf9961
test: replace string concat with template literal
...
Replace the string concat at test/addons-napi/test_reference/test.js.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/14269
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2018-04-16 17:46:02 -04:00
Kyle Farnung
cd3015408e
n-api: wrap test macros in do/while
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/14095
Reviewed-By: Jason Ginchereau <jasongin@microsoft.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Timothy Gu <timothygu99@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-04-16 17:46:01 -04:00
Jason Ginchereau
652d3218fe
test: Make N-API weak-ref GC tests asynchronous
...
One of the N-API weak-reference test cases already had to be made
asynchronous to handle different behavior in a newer V8 version:
https://github.com/nodejs/node/pull/12864
When porting N-API to Node-ChakraCore, we found more of the test
cases needed similar treatment:
https://github.com/nodejs/node-chakracore/issues/246 So to make
thes tests more robust (and avoid having differences in the test code
for Node-ChakraCore), I am refactoring the tests in this file to
insert a `setImmedate()` callback before every call to `gc()` and
assertions about the effects of the GC.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/13121
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2018-04-16 17:45:56 -04:00
Michaël Zasso
ce03977f30
test: fix napi test_reference for recent V8
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/12864
Ref: https://github.com/nodejs/node/pull/12551#issuecomment-297949361
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2018-04-16 17:45:53 -04:00
Michael Dawson
1785f3cf44
test: fix warning in n-api reference test
...
Add cast to avoid warning during build of addon.
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/12730
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2018-04-16 17:45:52 -04:00
Jason Ginchereau
bc252509ca
n-api: Reference and external tests
...
- Add a test project to addons-napi that covers the
N-API reference and external APIs
- Fix a bug in napi_typeof that was found by the new tests
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/12551
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:45:51 -04:00
Gabriel Schulhof
5ca8dee8cb
test: remove n-api intermediate files
...
PR-URL: https://github.com/nodejs/node/pull/19375
Reviewed-By: Myles Borins <myles.borins@gmail.com >
2018-03-29 23:25:34 -04:00
Rich Trott
44cc39d278
tools: remove assert.fail() lint rule
...
assert.fail() has been updated to accept a single argument so that is no
longer an error. Remove lint rule that checks for assert.fail() with a
single argument.
Backport-PR-URL: https://github.com/nodejs/node/pull/15479
PR-URL: https://github.com/nodejs/node/pull/12293
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2017-10-25 04:09:42 -04:00