node-addon-api 1.7.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.travis.yml +3 -9
- package/CHANGELOG.md +154 -9
- package/README.md +58 -9
- package/benchmark/README.md +47 -0
- package/benchmark/binding.gyp +25 -0
- package/benchmark/function_args.cc +153 -0
- package/benchmark/function_args.js +52 -0
- package/benchmark/index.js +34 -0
- package/benchmark/property_descriptor.cc +60 -0
- package/benchmark/property_descriptor.js +29 -0
- package/common.gypi +21 -0
- package/doc/array_buffer.md +1 -1
- package/doc/async_context.md +10 -0
- package/doc/async_operations.md +1 -1
- package/doc/async_worker.md +56 -26
- package/doc/async_worker_variants.md +456 -0
- package/doc/basic_types.md +8 -0
- package/doc/bigint.md +2 -1
- package/doc/class_property_descriptor.md +5 -6
- package/doc/cmake-js.md +58 -9
- package/doc/creating_a_release.md +5 -5
- package/doc/date.md +68 -0
- package/doc/env.md +14 -0
- package/doc/function.md +108 -1
- package/doc/object.md +74 -1
- package/doc/object_lifetime_management.md +1 -1
- package/doc/object_wrap.md +291 -4
- package/doc/prebuild_tools.md +1 -1
- package/doc/property_descriptor.md +64 -9
- package/doc/setup.md +0 -1
- package/doc/string.md +1 -1
- package/doc/symbol.md +1 -1
- package/doc/threadsafe_function.md +18 -1
- package/doc/value.md +10 -1
- package/except.gypi +16 -0
- package/index.js +5 -42
- package/napi-inl.h +1048 -147
- package/napi.h +424 -49
- package/node_api.gyp +9 -0
- package/noexcept.gypi +16 -0
- package/{src/nothing.c → nothing.c} +0 -0
- package/package.json +244 -47
- package/tools/README.md +4 -4
- package/tools/conversion.js +0 -4
- package/external-napi/node_api.h +0 -7
- package/src/node_api.cc +0 -3655
- package/src/node_api.gyp +0 -21
- package/src/node_api.h +0 -588
- package/src/node_api_types.h +0 -115
- package/src/node_internals.cc +0 -142
- package/src/node_internals.h +0 -157
- package/src/util-inl.h +0 -38
- package/src/util.h +0 -7
package/.travis.yml
CHANGED
|
@@ -12,20 +12,14 @@ env:
|
|
|
12
12
|
# https://github.com/jasongin/nvs/blob/master/doc/CI.md
|
|
13
13
|
- NVS_VERSION=1.4.2
|
|
14
14
|
matrix:
|
|
15
|
-
- NODEJS_VERSION=node/4
|
|
16
|
-
- NODEJS_VERSION=node/6
|
|
17
|
-
- NODEJS_VERSION=node/8
|
|
18
|
-
- NODEJS_VERSION=node/9
|
|
19
15
|
- NODEJS_VERSION=node/10
|
|
20
|
-
- NODEJS_VERSION=
|
|
21
|
-
- NODEJS_VERSION=
|
|
16
|
+
- NODEJS_VERSION=node/12
|
|
17
|
+
- NODEJS_VERSION=node/14
|
|
22
18
|
- NODEJS_VERSION=nightly
|
|
23
|
-
- NODEJS_VERSION=chakracore-nightly
|
|
24
19
|
matrix:
|
|
25
20
|
fast_finish: true
|
|
26
21
|
allow_failures:
|
|
27
22
|
- env: NODEJS_VERSION=nightly
|
|
28
|
-
- env: NODEJS_VERSION=chakracore-nightly
|
|
29
23
|
sudo: false
|
|
30
24
|
cache:
|
|
31
25
|
directories:
|
|
@@ -60,6 +54,6 @@ script:
|
|
|
60
54
|
# Travis CI sets NVM_NODEJS_ORG_MIRROR, but it makes node-gyp fail to download headers for nightly builds.
|
|
61
55
|
- unset NVM_NODEJS_ORG_MIRROR
|
|
62
56
|
|
|
63
|
-
- npm test
|
|
57
|
+
- npm test
|
|
64
58
|
after_success:
|
|
65
59
|
- cpp-coveralls --gcov-options '\-lp' --build-root test/build --exclude test
|
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,161 @@
|
|
|
1
1
|
# node-addon-api Changelog
|
|
2
2
|
|
|
3
|
-
## 2020-
|
|
3
|
+
## 2020-04-30 Version 3.0.0, @NickNaso
|
|
4
4
|
|
|
5
5
|
### Notable changes:
|
|
6
6
|
|
|
7
7
|
#### API
|
|
8
8
|
|
|
9
|
-
-
|
|
9
|
+
- `Napi::Object` added templated property descriptors.
|
|
10
|
+
- `Napi::ObjectWrap` added templated methods.
|
|
11
|
+
- `Napi::ObjectWrap` the wrap is removed only on failure.
|
|
12
|
+
- `Napi::ObjectWrap` the constructor's exceptions are gracefully handled.
|
|
13
|
+
- `Napi::Function` added templated factory functions.
|
|
14
|
+
- Added `Env::RunScript` method to run JavaScript code contained in a string.
|
|
15
|
+
- Added templated version of `Napi::Function`.
|
|
16
|
+
- Added benchmarking framework.
|
|
17
|
+
- Added support for natove addon instance data.
|
|
18
|
+
- Added `Napi::AsyncProgressQueueWorker` api.
|
|
19
|
+
- Changed the guards to `NAPI_VERSION > 5`.
|
|
20
|
+
- Removed N-API implementation (v6.x and v8.x support).
|
|
21
|
+
- `Napi::AsyncWorker::OnWorkComplete` and `Napi::AsyncWorker::OnExecute` methods
|
|
22
|
+
are override-able.
|
|
23
|
+
- Removed erroneous finalizer cleanup in `Napi::ThreadSafeFunction`.
|
|
24
|
+
- Disabled cahcing in `Napi::ArrayBuffer`.
|
|
25
|
+
- Explicitly disallow assign and copy operator.
|
|
26
|
+
- Some minor corrections and improvements.
|
|
10
27
|
|
|
11
|
-
|
|
28
|
+
#### Documentation
|
|
29
|
+
|
|
30
|
+
- Updated documentation for `Napi::Object`.
|
|
31
|
+
- Updated documentation for `Napi::Function`.
|
|
32
|
+
- Updated documentation for `Napi::ObjectWrap`.
|
|
33
|
+
- Added documentation on how to add benchmark.
|
|
34
|
+
- Added documentation for `Napi::AsyncProgressQueueWorker`.
|
|
35
|
+
- Added suggestion about tags to use on NPM.
|
|
36
|
+
- Added reference to N-API badges.
|
|
37
|
+
- Some minor corrections all over the documentation.
|
|
38
|
+
|
|
39
|
+
#### TEST
|
|
40
|
+
|
|
41
|
+
- Updated test cases for `Napi::Object`.
|
|
42
|
+
- Updated test cases for `Napi::Function`.
|
|
43
|
+
- Updated test cases for `Napi::ObjectWrap`.
|
|
44
|
+
- Updated test cases for `Napi::Env`.
|
|
45
|
+
- Added test cases for `Napi::AsyncProgressQueueWorker`.
|
|
46
|
+
- Some minor corrections all over the test suite.
|
|
47
|
+
|
|
48
|
+
### Commits
|
|
49
|
+
|
|
50
|
+
* [[`187318e37f`](https://github.com/nodejs/node-addon-api/commit/187318e37f)] - **doc**: Removed references to Node.js lower than 10.x. (#709) (Nicola Del Gobbo)
|
|
51
|
+
* [[`9c9accfbbe`](https://github.com/nodejs/node-addon-api/commit/9c9accfbbe)] - **src**: add support for addon instance data (Gabriel Schulhof) [#663](https://github.com/nodejs/node-addon-api/pull/663)
|
|
52
|
+
* [[`82a96502a4`](https://github.com/nodejs/node-addon-api/commit/82a96502a4)] - **src**: change guards to NAPI\_VERSION \> 5 (Gabriel Schulhof) [#697](https://github.com/nodejs/node-addon-api/pull/697)
|
|
53
|
+
* [[`a64e8a5641`](https://github.com/nodejs/node-addon-api/commit/a64e8a5641)] - **ci**: move travis from 13 to 14 (#707) (Gabriel Schulhof)
|
|
54
|
+
* [[`4de23c9d6b`](https://github.com/nodejs/node-addon-api/commit/4de23c9d6b)] - **doc**: fix support bigint64/biguint64 guards (Yulong Wang) [#705](https://github.com/nodejs/node-addon-api/pull/705)
|
|
55
|
+
* [[`fedc8195e3`](https://github.com/nodejs/node-addon-api/commit/fedc8195e3)] - **doc**: fix semicolon missing in async\_worker.md (Azlan Mukhtar) [#701](https://github.com/nodejs/node-addon-api/pull/701)
|
|
56
|
+
* [[`cdb662506c`](https://github.com/nodejs/node-addon-api/commit/cdb662506c)] - **doc**: fix typo in bigint.md (#700) (Kelvin)
|
|
57
|
+
* [[`e1a827ae29`](https://github.com/nodejs/node-addon-api/commit/e1a827ae29)] - **src**: fix AsyncProgressQueueWorker compilation (#696) (Gabriel Schulhof) [#696](https://github.com/nodejs/node-addon-api/pull/696)
|
|
58
|
+
* [[`2c3d5df463`](https://github.com/nodejs/node-addon-api/commit/2c3d5df463)] - Merge pull request #692 from kelvinhammond/patch-1 (Nicola Del Gobbo)
|
|
59
|
+
* [[`623e876949`](https://github.com/nodejs/node-addon-api/commit/623e876949)] - Merge pull request #688 from NickNaso/badges (Nicola Del Gobbo)
|
|
60
|
+
* [[`6c97913d1f`](https://github.com/nodejs/node-addon-api/commit/6c97913d1f)] - Fix minor typo in object\_lifetime\_management.md (Kelvin)
|
|
61
|
+
* [[`6b8dd47c55`](https://github.com/nodejs/node-addon-api/commit/6b8dd47c55)] - Added badge section to documentation. (NickNaso)
|
|
62
|
+
* [[`89e62a9154`](https://github.com/nodejs/node-addon-api/commit/89e62a9154)] - **doc**: recommend tags of addon helpers (legendecas) [#683](https://github.com/nodejs/node-addon-api/pull/683)
|
|
63
|
+
* [[`ab018444ae`](https://github.com/nodejs/node-addon-api/commit/ab018444ae)] - **src**: implement AsyncProgressQueueWorker (legendecas) [#585](https://github.com/nodejs/node-addon-api/pull/585)
|
|
64
|
+
* [[`d43da6ac2b`](https://github.com/nodejs/node-addon-api/commit/d43da6ac2b)] - **doc**: add @legendecas to active member list (legendecas)
|
|
65
|
+
* [[`cb498bbe7f`](https://github.com/nodejs/node-addon-api/commit/cb498bbe7f)] - **doc**: Add Napi::BigInt::New() overload for uint64\_t (ikokostya)
|
|
66
|
+
* [[`baaaa8452c`](https://github.com/nodejs/node-addon-api/commit/baaaa8452c)] - **doc**: link threadsafe function from JS function (legendecas)
|
|
67
|
+
* [[`7f56a78ff7`](https://github.com/nodejs/node-addon-api/commit/7f56a78ff7)] - **objectwrap**: remove wrap only on failure (Gabriel Schulhof)
|
|
68
|
+
* [[`4d816183da`](https://github.com/nodejs/node-addon-api/commit/4d816183da)] - **doc**: fix example code (András Timár, Dr) [#657](https://github.com/nodejs/node-addon-api/pull/657)
|
|
69
|
+
* [[`7ac6e21801`](https://github.com/nodejs/node-addon-api/commit/7ac6e21801)] - **gyp**: fix gypfile name in index.js (Anna Henningsen) [#658](https://github.com/nodejs/node-addon-api/pull/658)
|
|
70
|
+
* [[`46484202ca`](https://github.com/nodejs/node-addon-api/commit/46484202ca)] - **test**: user data in function property descriptor (Kevin Eady) [#652](https://github.com/nodejs/node-addon-api/pull/652)
|
|
71
|
+
* [[`0f8d730483`](https://github.com/nodejs/node-addon-api/commit/0f8d730483)] - **doc**: fix syntax error in example (András Timár, Dr) [#650](https://github.com/nodejs/node-addon-api/pull/650)
|
|
72
|
+
* [[`4e885069f1`](https://github.com/nodejs/node-addon-api/commit/4e885069f1)] - **src**: call `napi\_remove\_wrap()` in `ObjectWrap` dtor (Anna Henningsen) [#475](https://github.com/nodejs/node-addon-api/pull/475)
|
|
73
|
+
* [[`2fde5c3ca3`](https://github.com/nodejs/node-addon-api/commit/2fde5c3ca3)] - **test**: update BigInt test for recent change in core (Michael Dawson) [#649](https://github.com/nodejs/node-addon-api/pull/649)
|
|
74
|
+
* [[`e8935bd8d9`](https://github.com/nodejs/node-addon-api/commit/e8935bd8d9)] - **test**: add test for own properties on ObjectWrap (Guenter Sandner) [#645](https://github.com/nodejs/node-addon-api/pull/645)
|
|
75
|
+
* [[`23ff7f0b24`](https://github.com/nodejs/node-addon-api/commit/23ff7f0b24)] - **src**: make OnWorkComplete and OnExecute override-able (legendecas) [#589](https://github.com/nodejs/node-addon-api/pull/589)
|
|
76
|
+
* [[`86384f94d3`](https://github.com/nodejs/node-addon-api/commit/86384f94d3)] - **objectwrap**: gracefully handle constructor exceptions (Gabriel Schulhof)
|
|
77
|
+
* [[`9af69da01f`](https://github.com/nodejs/node-addon-api/commit/9af69da01f)] - remove N-API implementation, v6.x and v8.x support (Gabriel Schulhof) [#643](https://github.com/nodejs/node-addon-api/pull/643)
|
|
78
|
+
* [[`920d544779`](https://github.com/nodejs/node-addon-api/commit/920d544779)] - **benchmark**: add templated version of Function (Gabriel Schulhof) [#637](https://github.com/nodejs/node-addon-api/pull/637)
|
|
79
|
+
* [[`03759f7759`](https://github.com/nodejs/node-addon-api/commit/03759f7759)] - ignore benchmark built archives (legendecas) [#631](https://github.com/nodejs/node-addon-api/pull/631)
|
|
80
|
+
* [[`5eeabb0214`](https://github.com/nodejs/node-addon-api/commit/5eeabb0214)] - **tsfn**: Remove erroneous finalizer cleanup (Kevin Eady) [#636](https://github.com/nodejs/node-addon-api/pull/636)
|
|
81
|
+
* [[`9e0e0f31e4`](https://github.com/nodejs/node-addon-api/commit/9e0e0f31e4)] - **src**: remove unnecessary forward declarations (Gabriel Schulhof) [#633](https://github.com/nodejs/node-addon-api/pull/633)
|
|
82
|
+
* [[`79deefb6f3`](https://github.com/nodejs/node-addon-api/commit/79deefb6f3)] - **src**: explicitly disallow assign and copy (legendecas) [#590](https://github.com/nodejs/node-addon-api/pull/590)
|
|
83
|
+
* [[`af50ac281b`](https://github.com/nodejs/node-addon-api/commit/af50ac281b)] - **error**: do not replace pending exception (Gabriel Schulhof) [#629](https://github.com/nodejs/node-addon-api/pull/629)
|
|
84
|
+
* [[`b72f1d6978`](https://github.com/nodejs/node-addon-api/commit/b72f1d6978)] - Disable caching in ArrayBuffer (Tobias Nießen) [#611](https://github.com/nodejs/node-addon-api/pull/611)
|
|
85
|
+
* [[`0e7483eb7b`](https://github.com/nodejs/node-addon-api/commit/0e7483eb7b)] - Fix code format in tests (Tobias Nießen) [#617](https://github.com/nodejs/node-addon-api/pull/617)
|
|
86
|
+
* [[`6a0646356d`](https://github.com/nodejs/node-addon-api/commit/6a0646356d)] - add benchmarking framework (Gabriel Schulhof) [#623](https://github.com/nodejs/node-addon-api/pull/623)
|
|
87
|
+
* [[`ffc71edd54`](https://github.com/nodejs/node-addon-api/commit/ffc71edd54)] - Add Env::RunScript (Tobias Nießen) [#616](https://github.com/nodejs/node-addon-api/pull/616)
|
|
88
|
+
* [[`a1b106066e`](https://github.com/nodejs/node-addon-api/commit/a1b106066e)] - **src**: add templated function factories (Gabriel Schulhof) [#608](https://github.com/nodejs/node-addon-api/pull/608)
|
|
89
|
+
* [[`c584343217`](https://github.com/nodejs/node-addon-api/commit/c584343217)] - Add GetPropertyNames, HasOwnProperty, Delete (#615) (Tobias Nießen) [#615](https://github.com/nodejs/node-addon-api/pull/615)
|
|
90
|
+
* [[`3acc4b32f5`](https://github.com/nodejs/node-addon-api/commit/3acc4b32f5)] - Fix std::string encoding (#619) (Tobias Nießen) [#619](https://github.com/nodejs/node-addon-api/pull/619)
|
|
91
|
+
* [[`e71d0eadcc`](https://github.com/nodejs/node-addon-api/commit/e71d0eadcc)] - \[doc\] Fixed links to array documentation (#613) (Nicola Del Gobbo)
|
|
92
|
+
* [[`3dfb1f0591`](https://github.com/nodejs/node-addon-api/commit/3dfb1f0591)] - Change "WG" to "team" (Tobias Nießen)
|
|
93
|
+
* [[`ce91e14860`](https://github.com/nodejs/node-addon-api/commit/ce91e14860)] - **objectwrap**: add template methods (Dmitry Ashkadov) [#604](https://github.com/nodejs/node-addon-api/pull/604)
|
|
94
|
+
* [[`cfa71b60f7`](https://github.com/nodejs/node-addon-api/commit/cfa71b60f7)] - **object**: add templated property descriptors (Gabriel Schulhof) [#610](https://github.com/nodejs/node-addon-api/pull/610)
|
|
95
|
+
* [[`734725e971`](https://github.com/nodejs/node-addon-api/commit/734725e971)] - Correctly define copy assignment operators. (Rolf Timmermans)
|
|
96
|
+
|
|
97
|
+
## 2019-11-21 Version 2.0.0, @NickNaso
|
|
98
|
+
|
|
99
|
+
### Notable changes:
|
|
100
|
+
|
|
101
|
+
#### API
|
|
102
|
+
|
|
103
|
+
- Added `Napi::AsyncProgressWorker` api.
|
|
104
|
+
- Added error checking on `Napi::ThreadSafeFunction::GetContext`.
|
|
105
|
+
- Added copy constructor to `Napi::ThreadSafeFunction`.
|
|
106
|
+
- Added `Napi::ThreadSafeFunction::Ref` and `Napi::ThreadSafeFunction::Unref` to `Napi::ThreadSafeFunction`.
|
|
107
|
+
- Added `Napi::Object::AddFinalizer` method.
|
|
108
|
+
- Use `napi_add_finalizer()` to attach data when building against N-API 5.
|
|
109
|
+
- Added `Napi::Date` api.
|
|
110
|
+
- Added `Napi::ObjectWrap::Finalize` method.
|
|
111
|
+
|
|
112
|
+
#### Documentation
|
|
12
113
|
|
|
13
|
-
|
|
114
|
+
- Added documentation for `Napi::AsyncProgressWorker`.
|
|
115
|
+
- Improve `Napi::AsyncWorker` documentation.
|
|
116
|
+
- Added documentation for `Napi::Object::AddFinalizer` method.
|
|
117
|
+
- Improved documentation for `Napi::ThreadSafeFunction`.
|
|
118
|
+
- Improved documentation about the usage of CMake as build tool.
|
|
119
|
+
- Some minor corrections all over the documentation.
|
|
120
|
+
|
|
121
|
+
#### TEST
|
|
122
|
+
|
|
123
|
+
- Added test cases for `Napi::AsyncProgressWorker` api.
|
|
124
|
+
- Added test cases for `Napi::Date` api.
|
|
125
|
+
- Added test cases for new features added to `Napi::ThreadSafeFunction`.
|
|
126
|
+
|
|
127
|
+
### Commits
|
|
128
|
+
|
|
129
|
+
* [[`c881168d49`](https://github.com/nodejs/node-addon-api/commit/c881168d49)] - **tsfn**: add error checking on GetContext (#583) (Kevin Eady) [#583](https://github.com/nodejs/node-addon-api/pull/583)
|
|
130
|
+
* [[`24d75dd82f`](https://github.com/nodejs/node-addon-api/commit/24d75dd82f)] - Merge pull request #588 from NickNaso/add-asyncprogress-worker-readme (Nicola Del Gobbo)
|
|
131
|
+
* [[`aa79e37b62`](https://github.com/nodejs/node-addon-api/commit/aa79e37b62)] - Merge pull request #587 from timrach/patch-1 (Nicola Del Gobbo)
|
|
132
|
+
* [[`df75e08c2b`](https://github.com/nodejs/node-addon-api/commit/df75e08c2b)] - **tsfn**: support direct calls to underlying napi\_tsfn (Kevin Eady) [#58](https://github.com/nodejs/node-addon-api/pull/58)
|
|
133
|
+
* [[`2298dfae58`](https://github.com/nodejs/node-addon-api/commit/2298dfae58)] - **doc**: Added AsyncProgressWorker to readme (NickNaso)
|
|
134
|
+
* [[`b3609d33b6`](https://github.com/nodejs/node-addon-api/commit/b3609d33b6)] - Fix return type and declaration of setter callback (Tim Rach)
|
|
135
|
+
* [[`295e560f55`](https://github.com/nodejs/node-addon-api/commit/295e560f55)] - **test**: improve guards for experimental features (legendecas)
|
|
136
|
+
* [[`2e71842f63`](https://github.com/nodejs/node-addon-api/commit/2e71842f63)] - **tsfn**: Implement copy constructor (Kevin Eady) [#546](https://github.com/nodejs/node-addon-api/pull/546)
|
|
137
|
+
* [[`650562cab9`](https://github.com/nodejs/node-addon-api/commit/650562cab9)] - **src**: implement AsyncProgressWorker (legendecas) [#529](https://github.com/nodejs/node-addon-api/pull/529)
|
|
138
|
+
* [[`bdfd14101f`](https://github.com/nodejs/node-addon-api/commit/bdfd14101f)] - **src**: attach data with napi\_add\_finalizer (Gabriel Schulhof) [#577](https://github.com/nodejs/node-addon-api/pull/577)
|
|
139
|
+
* [[`9e955a802b`](https://github.com/nodejs/node-addon-api/commit/9e955a802b)] - **doc**: change node.js to Node.js per guideline (#579) (Tobias Nießen) [#579](https://github.com/nodejs/node-addon-api/pull/579)
|
|
140
|
+
* [[`b42e21e3a9`](https://github.com/nodejs/node-addon-api/commit/b42e21e3a9)] - **build**: move node/6 to travis allowed failures and add node/13 (#573) (Gabriel Schulhof)
|
|
141
|
+
* [[`8d6132f609`](https://github.com/nodejs/node-addon-api/commit/8d6132f609)] - **doc**: improve AsyncWorker docs (#571) (legendecas) [#571](https://github.com/nodejs/node-addon-api/pull/571)
|
|
142
|
+
* [[`bc8fc23627`](https://github.com/nodejs/node-addon-api/commit/bc8fc23627)] - **test**: do not run TSFN tests on NAPI\_VERSION \< 4 (legendecas) [#576](https://github.com/nodejs/node-addon-api/pull/576)
|
|
143
|
+
* [[`bcc1d58fc4`](https://github.com/nodejs/node-addon-api/commit/bcc1d58fc4)] - implement Object::AddFinalizer (Gabriel Schulhof)
|
|
144
|
+
* [[`e9a4bcd52a`](https://github.com/nodejs/node-addon-api/commit/e9a4bcd52a)] - **doc**: updates Make.js doc to current best practices (Jim Schlight) [#558](https://github.com/nodejs/node-addon-api/pull/558)
|
|
145
|
+
* [[`b513d1aa7a`](https://github.com/nodejs/node-addon-api/commit/b513d1aa7a)] - **doc**: fix return type of ArrayBuffer::Data (Tobias Nießen) [#552](https://github.com/nodejs/node-addon-api/pull/552)
|
|
146
|
+
* [[`34c11cf0a4`](https://github.com/nodejs/node-addon-api/commit/34c11cf0a4)] - **src**: disallow copying, double close of scopes (legendecas) [#566](https://github.com/nodejs/node-addon-api/pull/566)
|
|
147
|
+
* [[`ce139a05e8`](https://github.com/nodejs/node-addon-api/commit/ce139a05e8)] - **src**: make failure of closing scopes fatal (legendecas) [#566](https://github.com/nodejs/node-addon-api/pull/566)
|
|
148
|
+
* [[`740c79823e`](https://github.com/nodejs/node-addon-api/commit/740c79823e)] - **src**: add Env() to AsyncContext (Rolf Timmermans) [#568](https://github.com/nodejs/node-addon-api/pull/568)
|
|
149
|
+
* [[`ea9ce1c801`](https://github.com/nodejs/node-addon-api/commit/ea9ce1c801)] - **tsfn**: add wrappers for Ref and Unref (Kevin Eady) [#561](https://github.com/nodejs/node-addon-api/pull/561)
|
|
150
|
+
* [[`2e1769e1a3`](https://github.com/nodejs/node-addon-api/commit/2e1769e1a3)] - **error**: remove unnecessary if condition (legendecas) [#562](https://github.com/nodejs/node-addon-api/pull/562)
|
|
151
|
+
* [[`828f223a87`](https://github.com/nodejs/node-addon-api/commit/828f223a87)] - **doc**: fix spelling in ObjectWrap doc (#563) (Tobias Nießen) [#563](https://github.com/nodejs/node-addon-api/pull/563)
|
|
152
|
+
* [[`dd9fa8a4a8`](https://github.com/nodejs/node-addon-api/commit/dd9fa8a4a8)] - **doc**: move Arunesh and Taylor to Emeritus (#540) (Michael Dawson) [#540](https://github.com/nodejs/node-addon-api/pull/540)
|
|
153
|
+
* [[`cf8b8415df`](https://github.com/nodejs/node-addon-api/commit/cf8b8415df)] - **doc**: add Kevin to the list of collaborators (#539) (Michael Dawson) [#539](https://github.com/nodejs/node-addon-api/pull/539)
|
|
154
|
+
* [[`5d6aeae7b5`](https://github.com/nodejs/node-addon-api/commit/5d6aeae7b5)] - **build**: enable travis for fast PR check (legendecas)
|
|
155
|
+
* [[`6192e705cd`](https://github.com/nodejs/node-addon-api/commit/6192e705cd)] - **src**: add napi\_date (Mathias Küsel) [#497](https://github.com/nodejs/node-addon-api/pull/497)
|
|
156
|
+
* [[`7b1ee96d52`](https://github.com/nodejs/node-addon-api/commit/7b1ee96d52)] - **doc**: update prebuild\_tools.md (Nurbol Alpysbayev) [#527](https://github.com/nodejs/node-addon-api/pull/527)
|
|
157
|
+
* [[`0b4f3a5b8c`](https://github.com/nodejs/node-addon-api/commit/0b4f3a5b8c)] - **tsfn**: fix crash on releasing tsfn (legendecas) [#532](https://github.com/nodejs/node-addon-api/pull/532)
|
|
158
|
+
* [[`c3c8814d2f`](https://github.com/nodejs/node-addon-api/commit/c3c8814d2f)] - implement virutal ObjectWrap::Finalize (Michael Price) [#515](https://github.com/nodejs/node-addon-api/pull/515)
|
|
14
159
|
|
|
15
160
|
## 2019-07-23 Version 1.7.1, @NickNaso
|
|
16
161
|
|
|
@@ -20,7 +165,7 @@
|
|
|
20
165
|
|
|
21
166
|
- Fixed compilation problems that happen on Node.js with N-API version less than 4.
|
|
22
167
|
|
|
23
|
-
###
|
|
168
|
+
### Commits
|
|
24
169
|
|
|
25
170
|
* [[`c20bcbd069`](https://github.com/nodejs/node-addon-api/commit/c20bcbd069)] - Merge pull request #518 from NickNaso/master (Nicola Del Gobbo)
|
|
26
171
|
* [[`6720d57253`](https://github.com/nodejs/node-addon-api/commit/6720d57253)] - Create the native threadsafe\_function for test only for N-API greater than 3. (NickNaso)
|
|
@@ -48,7 +193,7 @@
|
|
|
48
193
|
- Added test case for bool operator.
|
|
49
194
|
- Fixed test case for `Napi::ObjectWrap`.
|
|
50
195
|
|
|
51
|
-
###
|
|
196
|
+
### Commits
|
|
52
197
|
|
|
53
198
|
* [[`717c9ab163`](https://github.com/nodejs/node-addon-api/commit/717c9ab163)] - **AsyncWorker**: add GetResult() method (Kevin Eady) [#512](https://github.com/nodejs/node-addon-api/pull/512)
|
|
54
199
|
* [[`d9d991bbc9`](https://github.com/nodejs/node-addon-api/commit/d9d991bbc9)] - **doc**: add ThreadSafeFunction to main README (#513) (Kevin Eady) [#513](https://github.com/nodejs/node-addon-api/pull/513)
|
|
@@ -85,7 +230,7 @@
|
|
|
85
230
|
|
|
86
231
|
- Some minor corrections all over the documentation.
|
|
87
232
|
|
|
88
|
-
###
|
|
233
|
+
### Commits
|
|
89
234
|
|
|
90
235
|
* [[`83b41c2fe4`](https://github.com/nodejs/node-addon-api/commit/83b41c2fe4)] - Document adding -fvisibility=hidden flag for macOS users (Nicola Del Gobbo) [#460](https://github.com/nodejs/node-addon-api/pull/460)
|
|
91
236
|
* [[`1ed7ad8769`](https://github.com/nodejs/node-addon-api/commit/1ed7ad8769)] - **doc**: correct return type of Int32Value to int32\_t (Bill Gallafent) [#459](https://github.com/nodejs/node-addon-api/pull/459)
|
|
@@ -134,7 +279,7 @@
|
|
|
134
279
|
- Removed unused member on `Napi::CallbackScope`.
|
|
135
280
|
- Enabled `Napi::CallbackScope` only with N-API v3.
|
|
136
281
|
|
|
137
|
-
###
|
|
282
|
+
### Commits
|
|
138
283
|
|
|
139
284
|
* [[`e7cd292a74`](https://github.com/nodejs/node-addon-api/commit/e7cd292a74)] - **src**: remove unused CallbackScope member (Gabriel Schulhof) [#391](https://github.com/nodejs/node-addon-api/pull/391)
|
|
140
285
|
* [[`d47399fe25`](https://github.com/nodejs/node-addon-api/commit/d47399fe25)] - **src**: guard CallbackScope with N-API v3 (Michael Dawson) [#395](https://github.com/nodejs/node-addon-api/pull/395)
|
|
@@ -159,7 +304,7 @@ associated with a callback in place when making certain N-API calls
|
|
|
159
304
|
- Added tests for `Napi::Array` class.
|
|
160
305
|
- Added tests for `Napi::ArrayBuffer` class.
|
|
161
306
|
|
|
162
|
-
###
|
|
307
|
+
### Commits
|
|
163
308
|
|
|
164
309
|
* [[`8ce605c657`](https://github.com/nodejs/node-addon-api/commit/8ce605c657)] - **build**: avoid using package-lock.json (Jaeseok Yoon) [#359](https://github.com/nodejs/node-addon-api/pull/359)
|
|
165
310
|
* [[`fa3a6150b3`](https://github.com/nodejs/node-addon-api/commit/fa3a6150b3)] - **src**: use MakeCallback() -\> Call() in AsyncWorker (Jinho Bang) [#361](https://github.com/nodejs/node-addon-api/pull/361)
|
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ It is important to remember that *other* Node.js interfaces such as
|
|
|
21
21
|
`libuv` (included in a project via `#include <uv.h>`) are not ABI-stable across
|
|
22
22
|
Node.js major versions. Thus, an addon must use N-API and/or `node-addon-api`
|
|
23
23
|
exclusively and build against a version of Node.js that includes an
|
|
24
|
-
implementation of N-API (meaning
|
|
24
|
+
implementation of N-API (meaning an active LTS version of Node.js) in
|
|
25
25
|
order to benefit from ABI stability across Node.js major versions. Node.js
|
|
26
26
|
provides an [ABI stability guide][] containing a detailed explanation of ABI
|
|
27
27
|
stability in general, and the N-API ABI stability guarantee in particular.
|
|
@@ -42,11 +42,12 @@ to ideas specified in the **ECMA262 Language Specification**.
|
|
|
42
42
|
- **[Examples](#examples)**
|
|
43
43
|
- **[Tests](#tests)**
|
|
44
44
|
- **[More resource and info about native Addons](#resources)**
|
|
45
|
+
- **[Badges](#badges)**
|
|
45
46
|
- **[Code of Conduct](CODE_OF_CONDUCT.md)**
|
|
46
47
|
- **[Contributors](#contributors)**
|
|
47
48
|
- **[License](#license)**
|
|
48
49
|
|
|
49
|
-
## **Current version:
|
|
50
|
+
## **Current version: 3.0.0**
|
|
50
51
|
|
|
51
52
|
(See [CHANGELOG.md](CHANGELOG.md) for complete Changelog)
|
|
52
53
|
|
|
@@ -54,6 +55,13 @@ to ideas specified in the **ECMA262 Language Specification**.
|
|
|
54
55
|
|
|
55
56
|
<a name="setup"></a>
|
|
56
57
|
|
|
58
|
+
node-addon-api is based on [N-API](https://nodejs.org/api/n-api.html) and supports using different N-API versions.
|
|
59
|
+
This allows addons built with it to run with Node.js versions which support the targeted N-API version.
|
|
60
|
+
**However** the node-addon-api support model is to support only the active LTS Node.js versions. This means that
|
|
61
|
+
every year there will be a new major which drops support for the Node.js LTS version which has gone out of service.
|
|
62
|
+
|
|
63
|
+
The oldest Node.js version supported by the current version of node-addon-api is Node.js 10.x.
|
|
64
|
+
|
|
57
65
|
## Setup
|
|
58
66
|
- [Installation and usage](doc/setup.md)
|
|
59
67
|
- [node-gyp](doc/node-gyp.md)
|
|
@@ -75,6 +83,7 @@ The following is the documentation for node-addon-api.
|
|
|
75
83
|
- [String](doc/string.md)
|
|
76
84
|
- [Name](doc/basic_types.md#name)
|
|
77
85
|
- [Number](doc/number.md)
|
|
86
|
+
- [Date](doc/date.md)
|
|
78
87
|
- [BigInt](doc/bigint.md)
|
|
79
88
|
- [Boolean](doc/boolean.md)
|
|
80
89
|
- [Env](doc/env.md)
|
|
@@ -106,6 +115,7 @@ The following is the documentation for node-addon-api.
|
|
|
106
115
|
- [Async Operations](doc/async_operations.md)
|
|
107
116
|
- [AsyncWorker](doc/async_worker.md)
|
|
108
117
|
- [AsyncContext](doc/async_context.md)
|
|
118
|
+
- [AsyncProgressWorker](doc/async_progress_worker.md)
|
|
109
119
|
- [Thread-safe Functions](doc/threadsafe_function.md)
|
|
110
120
|
- [Promises](doc/promises.md)
|
|
111
121
|
- [Version management](doc/version_management.md)
|
|
@@ -158,43 +168,82 @@ npm run-script dev:incremental
|
|
|
158
168
|
|
|
159
169
|
Take a look and get inspired by our **[test suite](https://github.com/nodejs/node-addon-api/tree/master/test)**
|
|
160
170
|
|
|
161
|
-
|
|
171
|
+
### **Benchmarks**
|
|
162
172
|
|
|
163
|
-
|
|
173
|
+
You can run the available benchmarks using the following command:
|
|
164
174
|
|
|
165
|
-
|
|
166
|
-
|
|
175
|
+
```
|
|
176
|
+
npm run-script benchmark
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
See [benchmark/README.md](benchmark/README.md) for more details about running and adding benchmarks.
|
|
180
|
+
|
|
181
|
+
<a name="resources"></a>
|
|
167
182
|
|
|
168
183
|
### **More resource and info about native Addons**
|
|
169
184
|
- **[C++ Addons](https://nodejs.org/dist/latest/docs/api/addons.html)**
|
|
170
185
|
- **[N-API](https://nodejs.org/dist/latest/docs/api/n-api.html)**
|
|
171
186
|
- **[N-API - Next Generation Node API for Native Modules](https://youtu.be/-Oniup60Afs)**
|
|
172
187
|
|
|
188
|
+
As node-addon-api's core mission is to expose the plain C N-API as C++
|
|
189
|
+
wrappers, tools that facilitate n-api/node-addon-api providing more
|
|
190
|
+
convenient patterns on developing a Node.js add-ons with n-api/node-addon-api
|
|
191
|
+
can be published to NPM as standalone packages. It is also recommended to tag
|
|
192
|
+
such packages with `node-addon-api` to provide more visibility to the community.
|
|
193
|
+
|
|
194
|
+
Quick links to NPM searches: [keywords:node-addon-api](https://www.npmjs.com/search?q=keywords%3Anode-addon-api).
|
|
195
|
+
|
|
196
|
+
<a name="badges"></a>
|
|
197
|
+
|
|
198
|
+
### **Badges**
|
|
199
|
+
|
|
200
|
+
The use of badges is recommended to indicate the minimum version of N-API
|
|
201
|
+
required for the module. This helps to determine which Node.js major versions are
|
|
202
|
+
supported. Addon maintainers can consult the [N-API support matrix][] to determine
|
|
203
|
+
which Node.js versions provide a given N-API version. The following badges are
|
|
204
|
+
available:
|
|
205
|
+
|
|
206
|
+

|
|
207
|
+

|
|
208
|
+

|
|
209
|
+

|
|
210
|
+

|
|
211
|
+

|
|
212
|
+

|
|
213
|
+
|
|
214
|
+
## **Contributing**
|
|
215
|
+
|
|
216
|
+
We love contributions from the community to **node-addon-api**!
|
|
217
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for more details on our philosophy around extending this module.
|
|
218
|
+
|
|
173
219
|
<a name="contributors"></a>
|
|
174
220
|
|
|
175
|
-
##
|
|
221
|
+
## Team members
|
|
176
222
|
|
|
177
223
|
### Active
|
|
178
224
|
| Name | GitHub Link |
|
|
179
225
|
| ------------------- | ----------------------------------------------------- |
|
|
180
226
|
| Anna Henningsen | [addaleax](https://github.com/addaleax) |
|
|
181
|
-
|
|
|
227
|
+
| Chengzhong Wu | [legendecas](https://github.com/legendecas) |
|
|
182
228
|
| Gabriel Schulhof | [gabrielschulhof](https://github.com/gabrielschulhof) |
|
|
183
229
|
| Hitesh Kanwathirtha | [digitalinfinity](https://github.com/digitalinfinity) |
|
|
184
230
|
| Jim Schlight | [jschlight](https://github.com/jschlight) |
|
|
185
231
|
| Michael Dawson | [mhdawson](https://github.com/mhdawson) |
|
|
232
|
+
| Kevin Eady | [KevinEady](https://github.com/KevinEady)
|
|
186
233
|
| Nicola Del Gobbo | [NickNaso](https://github.com/NickNaso) |
|
|
187
|
-
| Taylor Woll | [boingoing](https://github.com/boingoing) |
|
|
188
234
|
|
|
189
235
|
### Emeritus
|
|
190
236
|
| Name | GitHub Link |
|
|
191
237
|
| ------------------- | ----------------------------------------------------- |
|
|
238
|
+
| Arunesh Chandra | [aruneshchandra](https://github.com/aruneshchandra) |
|
|
192
239
|
| Benjamin Byholm | [kkoopa](https://github.com/kkoopa) |
|
|
193
240
|
| Jason Ginchereau | [jasongin](https://github.com/jasongin) |
|
|
194
241
|
| Sampson Gao | [sampsongao](https://github.com/sampsongao) |
|
|
242
|
+
| Taylor Woll | [boingoing](https://github.com/boingoing) |
|
|
195
243
|
|
|
196
244
|
<a name="license"></a>
|
|
197
245
|
|
|
198
246
|
Licensed under [MIT](./LICENSE.md)
|
|
199
247
|
|
|
200
248
|
[ABI stability guide]: https://nodejs.org/en/docs/guides/abi-stability/
|
|
249
|
+
[N-API support matrix]: https://nodejs.org/dist/latest/docs/api/n-api.html#n_api_n_api_version_matrix
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Benchmarks
|
|
2
|
+
|
|
3
|
+
## Running the benchmarks
|
|
4
|
+
|
|
5
|
+
From the parent directory, run
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm run-script benchmark
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The above script supports the following arguments:
|
|
12
|
+
|
|
13
|
+
* `--benchmarks=...`: A semicolon-separated list of benchmark names. These names
|
|
14
|
+
will be mapped to file names in this directory by appending `.js`.
|
|
15
|
+
|
|
16
|
+
## Adding benchmarks
|
|
17
|
+
|
|
18
|
+
The steps below should be followed when adding new benchmarks.
|
|
19
|
+
|
|
20
|
+
0. Decide on a name for the benchmark. This name will be used in several places.
|
|
21
|
+
This example will use the name `new_benchmark`.
|
|
22
|
+
|
|
23
|
+
0. Create files `new_benchmark.cc` and `new_benchmark.js` in this directory.
|
|
24
|
+
|
|
25
|
+
0. Copy an existing benchmark in `binding.gyp` and change the target name prefix
|
|
26
|
+
and the source file name to `new_benchmark`. This should result in two new
|
|
27
|
+
targets which look like this:
|
|
28
|
+
|
|
29
|
+
```gyp
|
|
30
|
+
{
|
|
31
|
+
'target_name': 'new_benchmark',
|
|
32
|
+
'sources': [ 'new_benchmark.cc' ],
|
|
33
|
+
'includes': [ '../except.gypi' ],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
'target_name': 'new_benchmark_noexcept',
|
|
37
|
+
'sources': [ 'new_benchmark.cc' ],
|
|
38
|
+
'includes': [ '../noexcept.gypi' ],
|
|
39
|
+
},
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
There should always be a pair of targets: one bearing the name of the
|
|
43
|
+
benchmark and configured with C++ exceptions enabled, and one bearing the
|
|
44
|
+
same name followed by the suffix `_noexcept` and configured with C++
|
|
45
|
+
exceptions disabled. This will ensure that the benchmark can be written to
|
|
46
|
+
cover both the case where C++ exceptions are enabled and the case where they
|
|
47
|
+
are disabled.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
'target_defaults': { 'includes': ['../common.gypi'] },
|
|
3
|
+
'targets': [
|
|
4
|
+
{
|
|
5
|
+
'target_name': 'function_args',
|
|
6
|
+
'sources': [ 'function_args.cc' ],
|
|
7
|
+
'includes': [ '../except.gypi' ],
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
'target_name': 'function_args_noexcept',
|
|
11
|
+
'sources': [ 'function_args.cc' ],
|
|
12
|
+
'includes': [ '../noexcept.gypi' ],
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
'target_name': 'property_descriptor',
|
|
16
|
+
'sources': [ 'property_descriptor.cc' ],
|
|
17
|
+
'includes': [ '../except.gypi' ],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
'target_name': 'property_descriptor_noexcept',
|
|
21
|
+
'sources': [ 'property_descriptor.cc' ],
|
|
22
|
+
'includes': [ '../noexcept.gypi' ],
|
|
23
|
+
},
|
|
24
|
+
]
|
|
25
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#include "napi.h"
|
|
2
|
+
|
|
3
|
+
static napi_value NoArgFunction_Core(napi_env env, napi_callback_info info) {
|
|
4
|
+
(void) env;
|
|
5
|
+
(void) info;
|
|
6
|
+
return nullptr;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
static napi_value OneArgFunction_Core(napi_env env, napi_callback_info info) {
|
|
10
|
+
size_t argc = 1;
|
|
11
|
+
napi_value argv;
|
|
12
|
+
if (napi_get_cb_info(env, info, &argc, &argv, nullptr, nullptr) != napi_ok) {
|
|
13
|
+
return nullptr;
|
|
14
|
+
}
|
|
15
|
+
(void) argv;
|
|
16
|
+
return nullptr;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static napi_value TwoArgFunction_Core(napi_env env, napi_callback_info info) {
|
|
20
|
+
size_t argc = 2;
|
|
21
|
+
napi_value argv[2];
|
|
22
|
+
if (napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr) != napi_ok) {
|
|
23
|
+
return nullptr;
|
|
24
|
+
}
|
|
25
|
+
(void) argv[0];
|
|
26
|
+
(void) argv[1];
|
|
27
|
+
return nullptr;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static napi_value ThreeArgFunction_Core(napi_env env, napi_callback_info info) {
|
|
31
|
+
size_t argc = 3;
|
|
32
|
+
napi_value argv[3];
|
|
33
|
+
if (napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr) != napi_ok) {
|
|
34
|
+
return nullptr;
|
|
35
|
+
}
|
|
36
|
+
(void) argv[0];
|
|
37
|
+
(void) argv[1];
|
|
38
|
+
(void) argv[2];
|
|
39
|
+
return nullptr;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static napi_value FourArgFunction_Core(napi_env env, napi_callback_info info) {
|
|
43
|
+
size_t argc = 4;
|
|
44
|
+
napi_value argv[4];
|
|
45
|
+
if (napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr) != napi_ok) {
|
|
46
|
+
return nullptr;
|
|
47
|
+
}
|
|
48
|
+
(void) argv[0];
|
|
49
|
+
(void) argv[1];
|
|
50
|
+
(void) argv[2];
|
|
51
|
+
(void) argv[3];
|
|
52
|
+
return nullptr;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static void NoArgFunction(const Napi::CallbackInfo& info) {
|
|
56
|
+
(void) info;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static void OneArgFunction(const Napi::CallbackInfo& info) {
|
|
60
|
+
Napi::Value argv0 = info[0]; (void) argv0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static void TwoArgFunction(const Napi::CallbackInfo& info) {
|
|
64
|
+
Napi::Value argv0 = info[0]; (void) argv0;
|
|
65
|
+
Napi::Value argv1 = info[1]; (void) argv1;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
static void ThreeArgFunction(const Napi::CallbackInfo& info) {
|
|
69
|
+
Napi::Value argv0 = info[0]; (void) argv0;
|
|
70
|
+
Napi::Value argv1 = info[1]; (void) argv1;
|
|
71
|
+
Napi::Value argv2 = info[2]; (void) argv2;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static void FourArgFunction(const Napi::CallbackInfo& info) {
|
|
75
|
+
Napi::Value argv0 = info[0]; (void) argv0;
|
|
76
|
+
Napi::Value argv1 = info[1]; (void) argv1;
|
|
77
|
+
Napi::Value argv2 = info[2]; (void) argv2;
|
|
78
|
+
Napi::Value argv3 = info[3]; (void) argv3;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
82
|
+
napi_value no_arg_function, one_arg_function, two_arg_function,
|
|
83
|
+
three_arg_function, four_arg_function;
|
|
84
|
+
napi_status status;
|
|
85
|
+
|
|
86
|
+
status = napi_create_function(env,
|
|
87
|
+
"noArgFunction",
|
|
88
|
+
NAPI_AUTO_LENGTH,
|
|
89
|
+
NoArgFunction_Core,
|
|
90
|
+
nullptr,
|
|
91
|
+
&no_arg_function);
|
|
92
|
+
NAPI_THROW_IF_FAILED(env, status, Napi::Object());
|
|
93
|
+
|
|
94
|
+
status = napi_create_function(env,
|
|
95
|
+
"oneArgFunction",
|
|
96
|
+
NAPI_AUTO_LENGTH,
|
|
97
|
+
OneArgFunction_Core,
|
|
98
|
+
nullptr,
|
|
99
|
+
&one_arg_function);
|
|
100
|
+
NAPI_THROW_IF_FAILED(env, status, Napi::Object());
|
|
101
|
+
|
|
102
|
+
status = napi_create_function(env,
|
|
103
|
+
"twoArgFunction",
|
|
104
|
+
NAPI_AUTO_LENGTH,
|
|
105
|
+
TwoArgFunction_Core,
|
|
106
|
+
nullptr,
|
|
107
|
+
&two_arg_function);
|
|
108
|
+
NAPI_THROW_IF_FAILED(env, status, Napi::Object());
|
|
109
|
+
|
|
110
|
+
status = napi_create_function(env,
|
|
111
|
+
"threeArgFunction",
|
|
112
|
+
NAPI_AUTO_LENGTH,
|
|
113
|
+
ThreeArgFunction_Core,
|
|
114
|
+
nullptr,
|
|
115
|
+
&three_arg_function);
|
|
116
|
+
NAPI_THROW_IF_FAILED(env, status, Napi::Object());
|
|
117
|
+
|
|
118
|
+
status = napi_create_function(env,
|
|
119
|
+
"fourArgFunction",
|
|
120
|
+
NAPI_AUTO_LENGTH,
|
|
121
|
+
FourArgFunction_Core,
|
|
122
|
+
nullptr,
|
|
123
|
+
&four_arg_function);
|
|
124
|
+
NAPI_THROW_IF_FAILED(env, status, Napi::Object());
|
|
125
|
+
|
|
126
|
+
Napi::Object core = Napi::Object::New(env);
|
|
127
|
+
core["noArgFunction"] = Napi::Value(env, no_arg_function);
|
|
128
|
+
core["oneArgFunction"] = Napi::Value(env, one_arg_function);
|
|
129
|
+
core["twoArgFunction"] = Napi::Value(env, two_arg_function);
|
|
130
|
+
core["threeArgFunction"] = Napi::Value(env, three_arg_function);
|
|
131
|
+
core["fourArgFunction"] = Napi::Value(env, four_arg_function);
|
|
132
|
+
exports["core"] = core;
|
|
133
|
+
|
|
134
|
+
Napi::Object cplusplus = Napi::Object::New(env);
|
|
135
|
+
cplusplus["noArgFunction"] = Napi::Function::New(env, NoArgFunction);
|
|
136
|
+
cplusplus["oneArgFunction"] = Napi::Function::New(env, OneArgFunction);
|
|
137
|
+
cplusplus["twoArgFunction"] = Napi::Function::New(env, TwoArgFunction);
|
|
138
|
+
cplusplus["threeArgFunction"] = Napi::Function::New(env, ThreeArgFunction);
|
|
139
|
+
cplusplus["fourArgFunction"] = Napi::Function::New(env, FourArgFunction);
|
|
140
|
+
exports["cplusplus"] = cplusplus;
|
|
141
|
+
|
|
142
|
+
Napi::Object templated = Napi::Object::New(env);
|
|
143
|
+
templated["noArgFunction"] = Napi::Function::New<NoArgFunction>(env);
|
|
144
|
+
templated["oneArgFunction"] = Napi::Function::New<OneArgFunction>(env);
|
|
145
|
+
templated["twoArgFunction"] = Napi::Function::New<TwoArgFunction>(env);
|
|
146
|
+
templated["threeArgFunction"] = Napi::Function::New<ThreeArgFunction>(env);
|
|
147
|
+
templated["fourArgFunction"] = Napi::Function::New<FourArgFunction>(env);
|
|
148
|
+
exports["templated"] = templated;
|
|
149
|
+
|
|
150
|
+
return exports;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
NODE_API_MODULE(NODE_GYP_MODULE_NAME, Init)
|