koffi 1.0.5 → 1.1.0-beta.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.
Files changed (268) hide show
  1. package/README.md +46 -21
  2. package/build/qemu/1.1.0-beta.0/koffi_darwin_x64.tar.gz +0 -0
  3. package/build/qemu/1.1.0-beta.0/koffi_freebsd_arm64.tar.gz +0 -0
  4. package/build/qemu/1.1.0-beta.0/koffi_freebsd_ia32.tar.gz +0 -0
  5. package/build/qemu/1.1.0-beta.0/koffi_freebsd_x64.tar.gz +0 -0
  6. package/build/qemu/1.1.0-beta.0/koffi_linux_arm.tar.gz +0 -0
  7. package/build/qemu/1.1.0-beta.0/koffi_linux_arm64.tar.gz +0 -0
  8. package/build/qemu/1.1.0-beta.0/koffi_linux_ia32.tar.gz +0 -0
  9. package/build/qemu/1.1.0-beta.0/koffi_linux_x64.tar.gz +0 -0
  10. package/build/qemu/1.1.0-beta.0/koffi_win32_ia32.tar.gz +0 -0
  11. package/build/qemu/1.1.0-beta.0/koffi_win32_x64.tar.gz +0 -0
  12. package/package.json +1 -1
  13. package/qemu/qemu.js +11 -5
  14. package/qemu/registry/machines.json +20 -10
  15. package/src/abi_arm32.cc +13 -6
  16. package/src/abi_arm64.cc +13 -6
  17. package/src/abi_x64_sysv.cc +13 -6
  18. package/src/abi_x64_win.cc +13 -6
  19. package/src/abi_x86.cc +13 -6
  20. package/src/call.cc +25 -26
  21. package/src/call.hh +27 -41
  22. package/src/ffi.cc +152 -17
  23. package/src/ffi.hh +24 -10
  24. package/test/misc.c +2 -2
  25. package/build/qemu/1.0.5/koffi_darwin_x64.tar.gz +0 -0
  26. package/build/qemu/1.0.5/koffi_freebsd_arm64.tar.gz +0 -0
  27. package/build/qemu/1.0.5/koffi_freebsd_ia32.tar.gz +0 -0
  28. package/build/qemu/1.0.5/koffi_freebsd_x64.tar.gz +0 -0
  29. package/build/qemu/1.0.5/koffi_linux_arm.tar.gz +0 -0
  30. package/build/qemu/1.0.5/koffi_linux_arm64.tar.gz +0 -0
  31. package/build/qemu/1.0.5/koffi_linux_ia32.tar.gz +0 -0
  32. package/build/qemu/1.0.5/koffi_linux_x64.tar.gz +0 -0
  33. package/build/qemu/1.0.5/koffi_win32_ia32.tar.gz +0 -0
  34. package/build/qemu/1.0.5/koffi_win32_x64.tar.gz +0 -0
  35. package/test/misc.js +0 -227
  36. package/vendor/node-addon-api/CODE_OF_CONDUCT.md +0 -4
  37. package/vendor/node-addon-api/CONTRIBUTING.md +0 -93
  38. package/vendor/node-addon-api/appveyor.yml +0 -37
  39. package/vendor/node-addon-api/benchmark/README.md +0 -47
  40. package/vendor/node-addon-api/benchmark/binding.gyp +0 -25
  41. package/vendor/node-addon-api/benchmark/function_args.cc +0 -217
  42. package/vendor/node-addon-api/benchmark/function_args.js +0 -60
  43. package/vendor/node-addon-api/benchmark/index.js +0 -34
  44. package/vendor/node-addon-api/benchmark/property_descriptor.cc +0 -91
  45. package/vendor/node-addon-api/benchmark/property_descriptor.js +0 -37
  46. package/vendor/node-addon-api/doc/addon.md +0 -163
  47. package/vendor/node-addon-api/doc/array.md +0 -81
  48. package/vendor/node-addon-api/doc/array_buffer.md +0 -155
  49. package/vendor/node-addon-api/doc/async_context.md +0 -86
  50. package/vendor/node-addon-api/doc/async_operations.md +0 -31
  51. package/vendor/node-addon-api/doc/async_worker.md +0 -427
  52. package/vendor/node-addon-api/doc/async_worker_variants.md +0 -557
  53. package/vendor/node-addon-api/doc/bigint.md +0 -97
  54. package/vendor/node-addon-api/doc/boolean.md +0 -68
  55. package/vendor/node-addon-api/doc/buffer.md +0 -150
  56. package/vendor/node-addon-api/doc/callback_scope.md +0 -54
  57. package/vendor/node-addon-api/doc/callbackinfo.md +0 -97
  58. package/vendor/node-addon-api/doc/checker-tool.md +0 -32
  59. package/vendor/node-addon-api/doc/class_property_descriptor.md +0 -123
  60. package/vendor/node-addon-api/doc/cmake-js.md +0 -68
  61. package/vendor/node-addon-api/doc/conversion-tool.md +0 -28
  62. package/vendor/node-addon-api/doc/creating_a_release.md +0 -62
  63. package/vendor/node-addon-api/doc/dataview.md +0 -248
  64. package/vendor/node-addon-api/doc/date.md +0 -68
  65. package/vendor/node-addon-api/doc/env.md +0 -196
  66. package/vendor/node-addon-api/doc/error.md +0 -120
  67. package/vendor/node-addon-api/doc/error_handling.md +0 -254
  68. package/vendor/node-addon-api/doc/escapable_handle_scope.md +0 -80
  69. package/vendor/node-addon-api/doc/external.md +0 -63
  70. package/vendor/node-addon-api/doc/function.md +0 -402
  71. package/vendor/node-addon-api/doc/function_reference.md +0 -238
  72. package/vendor/node-addon-api/doc/generator.md +0 -13
  73. package/vendor/node-addon-api/doc/handle_scope.md +0 -63
  74. package/vendor/node-addon-api/doc/hierarchy.md +0 -91
  75. package/vendor/node-addon-api/doc/instance_wrap.md +0 -408
  76. package/vendor/node-addon-api/doc/maybe.md +0 -76
  77. package/vendor/node-addon-api/doc/memory_management.md +0 -27
  78. package/vendor/node-addon-api/doc/name.md +0 -29
  79. package/vendor/node-addon-api/doc/node-gyp.md +0 -82
  80. package/vendor/node-addon-api/doc/number.md +0 -163
  81. package/vendor/node-addon-api/doc/object.md +0 -411
  82. package/vendor/node-addon-api/doc/object_lifetime_management.md +0 -83
  83. package/vendor/node-addon-api/doc/object_reference.md +0 -117
  84. package/vendor/node-addon-api/doc/object_wrap.md +0 -588
  85. package/vendor/node-addon-api/doc/prebuild_tools.md +0 -16
  86. package/vendor/node-addon-api/doc/promises.md +0 -79
  87. package/vendor/node-addon-api/doc/property_descriptor.md +0 -286
  88. package/vendor/node-addon-api/doc/propertylvalue.md +0 -50
  89. package/vendor/node-addon-api/doc/range_error.md +0 -59
  90. package/vendor/node-addon-api/doc/reference.md +0 -113
  91. package/vendor/node-addon-api/doc/setup.md +0 -110
  92. package/vendor/node-addon-api/doc/string.md +0 -93
  93. package/vendor/node-addon-api/doc/symbol.md +0 -61
  94. package/vendor/node-addon-api/doc/threadsafe.md +0 -121
  95. package/vendor/node-addon-api/doc/threadsafe_function.md +0 -290
  96. package/vendor/node-addon-api/doc/type_error.md +0 -59
  97. package/vendor/node-addon-api/doc/typed_array.md +0 -78
  98. package/vendor/node-addon-api/doc/typed_array_of.md +0 -137
  99. package/vendor/node-addon-api/doc/typed_threadsafe_function.md +0 -306
  100. package/vendor/node-addon-api/doc/value.md +0 -340
  101. package/vendor/node-addon-api/doc/version_management.md +0 -43
  102. package/vendor/node-addon-api/package.json +0 -415
  103. package/vendor/node-addon-api/test/README.md +0 -91
  104. package/vendor/node-addon-api/test/addon.cc +0 -36
  105. package/vendor/node-addon-api/test/addon.js +0 -11
  106. package/vendor/node-addon-api/test/addon_build/index.js +0 -49
  107. package/vendor/node-addon-api/test/addon_build/tpl/addon.cc +0 -17
  108. package/vendor/node-addon-api/test/addon_build/tpl/binding.gyp +0 -62
  109. package/vendor/node-addon-api/test/addon_build/tpl/index.js +0 -9
  110. package/vendor/node-addon-api/test/addon_build/tpl/package.json +0 -11
  111. package/vendor/node-addon-api/test/addon_data.cc +0 -99
  112. package/vendor/node-addon-api/test/addon_data.js +0 -46
  113. package/vendor/node-addon-api/test/array_buffer.cc +0 -243
  114. package/vendor/node-addon-api/test/array_buffer.js +0 -69
  115. package/vendor/node-addon-api/test/async_context.cc +0 -36
  116. package/vendor/node-addon-api/test/async_context.js +0 -122
  117. package/vendor/node-addon-api/test/async_progress_queue_worker.cc +0 -83
  118. package/vendor/node-addon-api/test/async_progress_queue_worker.js +0 -46
  119. package/vendor/node-addon-api/test/async_progress_worker.cc +0 -134
  120. package/vendor/node-addon-api/test/async_progress_worker.js +0 -61
  121. package/vendor/node-addon-api/test/async_worker.cc +0 -106
  122. package/vendor/node-addon-api/test/async_worker.js +0 -179
  123. package/vendor/node-addon-api/test/async_worker_nocallback.js +0 -13
  124. package/vendor/node-addon-api/test/async_worker_persistent.cc +0 -63
  125. package/vendor/node-addon-api/test/async_worker_persistent.js +0 -24
  126. package/vendor/node-addon-api/test/basic_types/array.cc +0 -40
  127. package/vendor/node-addon-api/test/basic_types/array.js +0 -35
  128. package/vendor/node-addon-api/test/basic_types/boolean.cc +0 -38
  129. package/vendor/node-addon-api/test/basic_types/boolean.js +0 -35
  130. package/vendor/node-addon-api/test/basic_types/number.cc +0 -99
  131. package/vendor/node-addon-api/test/basic_types/number.js +0 -114
  132. package/vendor/node-addon-api/test/basic_types/value.cc +0 -120
  133. package/vendor/node-addon-api/test/basic_types/value.js +0 -133
  134. package/vendor/node-addon-api/test/bigint.cc +0 -91
  135. package/vendor/node-addon-api/test/bigint.js +0 -53
  136. package/vendor/node-addon-api/test/binding-swallowexcept.cc +0 -12
  137. package/vendor/node-addon-api/test/binding.cc +0 -173
  138. package/vendor/node-addon-api/test/binding.gyp +0 -124
  139. package/vendor/node-addon-api/test/buffer.cc +0 -183
  140. package/vendor/node-addon-api/test/buffer.js +0 -69
  141. package/vendor/node-addon-api/test/callbackscope.cc +0 -22
  142. package/vendor/node-addon-api/test/callbackscope.js +0 -49
  143. package/vendor/node-addon-api/test/common/index.js +0 -114
  144. package/vendor/node-addon-api/test/common/test_helper.h +0 -71
  145. package/vendor/node-addon-api/test/dataview/dataview.cc +0 -48
  146. package/vendor/node-addon-api/test/dataview/dataview.js +0 -35
  147. package/vendor/node-addon-api/test/dataview/dataview_read_write.cc +0 -115
  148. package/vendor/node-addon-api/test/dataview/dataview_read_write.js +0 -90
  149. package/vendor/node-addon-api/test/date.cc +0 -44
  150. package/vendor/node-addon-api/test/date.js +0 -18
  151. package/vendor/node-addon-api/test/env_cleanup.cc +0 -88
  152. package/vendor/node-addon-api/test/env_cleanup.js +0 -56
  153. package/vendor/node-addon-api/test/error.cc +0 -287
  154. package/vendor/node-addon-api/test/error.js +0 -81
  155. package/vendor/node-addon-api/test/error_handling_for_primitives.cc +0 -13
  156. package/vendor/node-addon-api/test/error_handling_for_primitives.js +0 -29
  157. package/vendor/node-addon-api/test/error_terminating_environment.js +0 -95
  158. package/vendor/node-addon-api/test/external.cc +0 -81
  159. package/vendor/node-addon-api/test/external.js +0 -88
  160. package/vendor/node-addon-api/test/function.cc +0 -324
  161. package/vendor/node-addon-api/test/function.js +0 -133
  162. package/vendor/node-addon-api/test/function_reference.cc +0 -202
  163. package/vendor/node-addon-api/test/function_reference.js +0 -157
  164. package/vendor/node-addon-api/test/globalObject/global_object.cc +0 -61
  165. package/vendor/node-addon-api/test/globalObject/global_object_delete_property.cc +0 -31
  166. package/vendor/node-addon-api/test/globalObject/global_object_delete_property.js +0 -61
  167. package/vendor/node-addon-api/test/globalObject/global_object_get_property.cc +0 -40
  168. package/vendor/node-addon-api/test/globalObject/global_object_get_property.js +0 -57
  169. package/vendor/node-addon-api/test/globalObject/global_object_has_own_property.cc +0 -28
  170. package/vendor/node-addon-api/test/globalObject/global_object_has_own_property.js +0 -48
  171. package/vendor/node-addon-api/test/globalObject/global_object_set_property.cc +0 -31
  172. package/vendor/node-addon-api/test/globalObject/global_object_set_property.js +0 -58
  173. package/vendor/node-addon-api/test/handlescope.cc +0 -60
  174. package/vendor/node-addon-api/test/handlescope.js +0 -14
  175. package/vendor/node-addon-api/test/index.js +0 -159
  176. package/vendor/node-addon-api/test/maybe/check.cc +0 -23
  177. package/vendor/node-addon-api/test/maybe/index.js +0 -38
  178. package/vendor/node-addon-api/test/memory_management.cc +0 -17
  179. package/vendor/node-addon-api/test/memory_management.js +0 -9
  180. package/vendor/node-addon-api/test/movable_callbacks.cc +0 -23
  181. package/vendor/node-addon-api/test/movable_callbacks.js +0 -21
  182. package/vendor/node-addon-api/test/name.cc +0 -108
  183. package/vendor/node-addon-api/test/name.js +0 -59
  184. package/vendor/node-addon-api/test/napi_child.js +0 -14
  185. package/vendor/node-addon-api/test/object/delete_property.cc +0 -38
  186. package/vendor/node-addon-api/test/object/delete_property.js +0 -41
  187. package/vendor/node-addon-api/test/object/finalizer.cc +0 -29
  188. package/vendor/node-addon-api/test/object/finalizer.js +0 -28
  189. package/vendor/node-addon-api/test/object/get_property.cc +0 -34
  190. package/vendor/node-addon-api/test/object/get_property.js +0 -40
  191. package/vendor/node-addon-api/test/object/has_own_property.cc +0 -34
  192. package/vendor/node-addon-api/test/object/has_own_property.js +0 -34
  193. package/vendor/node-addon-api/test/object/has_property.cc +0 -38
  194. package/vendor/node-addon-api/test/object/has_property.js +0 -37
  195. package/vendor/node-addon-api/test/object/object.cc +0 -350
  196. package/vendor/node-addon-api/test/object/object.js +0 -217
  197. package/vendor/node-addon-api/test/object/object_deprecated.cc +0 -66
  198. package/vendor/node-addon-api/test/object/object_deprecated.js +0 -47
  199. package/vendor/node-addon-api/test/object/object_freeze_seal.cc +0 -25
  200. package/vendor/node-addon-api/test/object/object_freeze_seal.js +0 -61
  201. package/vendor/node-addon-api/test/object/set_property.cc +0 -45
  202. package/vendor/node-addon-api/test/object/set_property.js +0 -30
  203. package/vendor/node-addon-api/test/object/subscript_operator.cc +0 -58
  204. package/vendor/node-addon-api/test/object/subscript_operator.js +0 -17
  205. package/vendor/node-addon-api/test/object_reference.cc +0 -219
  206. package/vendor/node-addon-api/test/object_reference.js +0 -259
  207. package/vendor/node-addon-api/test/objectwrap.cc +0 -268
  208. package/vendor/node-addon-api/test/objectwrap.js +0 -284
  209. package/vendor/node-addon-api/test/objectwrap_constructor_exception.cc +0 -26
  210. package/vendor/node-addon-api/test/objectwrap_constructor_exception.js +0 -18
  211. package/vendor/node-addon-api/test/objectwrap_function.cc +0 -45
  212. package/vendor/node-addon-api/test/objectwrap_function.js +0 -22
  213. package/vendor/node-addon-api/test/objectwrap_multiple_inheritance.cc +0 -30
  214. package/vendor/node-addon-api/test/objectwrap_multiple_inheritance.js +0 -13
  215. package/vendor/node-addon-api/test/objectwrap_removewrap.cc +0 -45
  216. package/vendor/node-addon-api/test/objectwrap_removewrap.js +0 -40
  217. package/vendor/node-addon-api/test/objectwrap_worker_thread.js +0 -19
  218. package/vendor/node-addon-api/test/promise.cc +0 -29
  219. package/vendor/node-addon-api/test/promise.js +0 -18
  220. package/vendor/node-addon-api/test/reference.cc +0 -24
  221. package/vendor/node-addon-api/test/reference.js +0 -14
  222. package/vendor/node-addon-api/test/run_script.cc +0 -56
  223. package/vendor/node-addon-api/test/run_script.js +0 -45
  224. package/vendor/node-addon-api/test/symbol.cc +0 -79
  225. package/vendor/node-addon-api/test/symbol.js +0 -73
  226. package/vendor/node-addon-api/test/testUtil.js +0 -54
  227. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function.cc +0 -195
  228. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function.js +0 -188
  229. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ctx.cc +0 -63
  230. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ctx.js +0 -12
  231. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_existing_tsfn.cc +0 -115
  232. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_existing_tsfn.js +0 -14
  233. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ptr.cc +0 -26
  234. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ptr.js +0 -7
  235. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_sum.cc +0 -225
  236. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_sum.js +0 -59
  237. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_unref.cc +0 -42
  238. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_unref.js +0 -53
  239. package/vendor/node-addon-api/test/thunking_manual.cc +0 -140
  240. package/vendor/node-addon-api/test/thunking_manual.js +0 -17
  241. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function.cc +0 -215
  242. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function.js +0 -188
  243. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ctx.cc +0 -68
  244. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ctx.js +0 -12
  245. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_existing_tsfn.cc +0 -127
  246. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_existing_tsfn.js +0 -14
  247. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ptr.cc +0 -28
  248. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ptr.js +0 -7
  249. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_sum.cc +0 -237
  250. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_sum.js +0 -59
  251. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_unref.cc +0 -53
  252. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_unref.js +0 -53
  253. package/vendor/node-addon-api/test/typedarray-bigint.js +0 -58
  254. package/vendor/node-addon-api/test/typedarray.cc +0 -216
  255. package/vendor/node-addon-api/test/typedarray.js +0 -69
  256. package/vendor/node-addon-api/test/version_management.cc +0 -27
  257. package/vendor/node-addon-api/test/version_management.js +0 -31
  258. package/vendor/node-addon-api/unit-test/README.md +0 -28
  259. package/vendor/node-addon-api/unit-test/binding-file-template.js +0 -39
  260. package/vendor/node-addon-api/unit-test/binding.gyp +0 -72
  261. package/vendor/node-addon-api/unit-test/exceptions.js +0 -32
  262. package/vendor/node-addon-api/unit-test/generate-binding-cc.js +0 -61
  263. package/vendor/node-addon-api/unit-test/injectTestParams.js +0 -101
  264. package/vendor/node-addon-api/unit-test/listOfTestModules.js +0 -88
  265. package/vendor/node-addon-api/unit-test/matchModules.js +0 -65
  266. package/vendor/node-addon-api/unit-test/setup.js +0 -13
  267. package/vendor/node-addon-api/unit-test/spawnTask.js +0 -26
  268. package/vendor/node-addon-api/unit-test/test.js +0 -30
@@ -1,68 +0,0 @@
1
- # Boolean
2
-
3
- Class `Napi::Boolean` inherits from class [`Napi::Value`][].
4
-
5
- `Napi::Boolean` class is a representation of the JavaScript `Boolean` object. The
6
- `Napi::Boolean` class inherits its behavior from the `Napi::Value` class
7
- (for more info see: [`Napi::Value`](value.md)).
8
-
9
- ## Methods
10
-
11
- ### Constructor
12
-
13
- Creates a new empty instance of an `Napi::Boolean` object.
14
-
15
- ```cpp
16
- Napi::Boolean::Boolean();
17
- ```
18
-
19
- Returns a new _empty_ `Napi::Boolean` object.
20
-
21
- ### Constructor
22
-
23
- Creates a new instance of the `Napi::Boolean` object.
24
-
25
- ```cpp
26
- Napi::Boolean(napi_env env, napi_value value);
27
- ```
28
-
29
- - `[in] env`: The `napi_env` environment in which to construct the `Napi::Boolean` object.
30
- - `[in] value`: The `napi_value` which is a handle for a JavaScript `Boolean`.
31
-
32
- Returns a non-empty `Napi::Boolean` object.
33
-
34
- ### New
35
-
36
- Initializes a new instance of the `Napi::Boolean` object.
37
-
38
- ```cpp
39
- Napi::Boolean Napi::Boolean::New(napi_env env, bool value);
40
- ```
41
- - `[in] env`: The `napi_env` environment in which to construct the `Napi::Boolean` object.
42
- - `[in] value`: The primitive boolean value (`true` or `false`).
43
-
44
- Returns a new instance of the `Napi::Boolean` object.
45
-
46
- ### Value
47
-
48
- Converts a `Napi::Boolean` value to a boolean primitive.
49
-
50
- ```cpp
51
- bool Napi::Boolean::Value() const;
52
- ```
53
-
54
- Returns the boolean primitive type of the corresponding `Napi::Boolean` object.
55
-
56
- ## Operators
57
-
58
- ### operator bool
59
-
60
- Converts a `Napi::Boolean` value to a boolean primitive.
61
-
62
- ```cpp
63
- Napi::Boolean::operator bool() const;
64
- ```
65
-
66
- Returns the boolean primitive type of the corresponding `Napi::Boolean` object.
67
-
68
- [`Napi::Value`]: ./value.md
@@ -1,150 +0,0 @@
1
- # Buffer
2
-
3
- Class `Napi::Buffer` inherits from class [`Napi::Uint8Array`][].
4
-
5
- The `Napi::Buffer` class creates a projection of raw data that can be consumed by
6
- script.
7
-
8
- ## Methods
9
-
10
- ### New
11
-
12
- Allocates a new `Napi::Buffer` object with a given length.
13
-
14
- ```cpp
15
- static Napi::Buffer<T> Napi::Buffer::New(napi_env env, size_t length);
16
- ```
17
-
18
- - `[in] env`: The environment in which to create the `Napi::Buffer` object.
19
- - `[in] length`: The number of `T` elements to allocate.
20
-
21
- Returns a new `Napi::Buffer` object.
22
-
23
- ### New
24
-
25
- Wraps the provided external data into a new `Napi::Buffer` object.
26
-
27
- The `Napi::Buffer` object does not assume ownership for the data and expects it to be
28
- valid for the lifetime of the object. Since the `Napi::Buffer` is subject to garbage
29
- collection this overload is only suitable for data which is static and never
30
- needs to be freed.
31
- This factory method will not provide the caller with an opportunity to free the
32
- data when the `Napi::Buffer` gets garbage-collected. If you need to free the
33
- data retained by the `Napi::Buffer` object please use other variants of the
34
- `Napi::Buffer::New` factory method that accept `Napi::Finalizer`, which is a
35
- function that will be invoked when the `Napi::Buffer` object has been
36
- destroyed.
37
-
38
- ```cpp
39
- static Napi::Buffer<T> Napi::Buffer::New(napi_env env, T* data, size_t length);
40
- ```
41
-
42
- - `[in] env`: The environment in which to create the `Napi::Buffer` object.
43
- - `[in] data`: The pointer to the external data to expose.
44
- - `[in] length`: The number of `T` elements in the external data.
45
-
46
- Returns a new `Napi::Buffer` object.
47
-
48
- ### New
49
-
50
- Wraps the provided external data into a new `Napi::Buffer` object.
51
-
52
- The `Napi::Buffer` object does not assume ownership for the data and expects it
53
- to be valid for the lifetime of the object. The data can only be freed once the
54
- `finalizeCallback` is invoked to indicate that the `Napi::Buffer` has been released.
55
-
56
- ```cpp
57
- template <typename Finalizer>
58
- static Napi::Buffer<T> Napi::Buffer::New(napi_env env,
59
- T* data,
60
- size_t length,
61
- Finalizer finalizeCallback);
62
- ```
63
-
64
- - `[in] env`: The environment in which to create the `Napi::Buffer` object.
65
- - `[in] data`: The pointer to the external data to expose.
66
- - `[in] length`: The number of `T` elements in the external data.
67
- - `[in] finalizeCallback`: The function to be called when the `Napi::Buffer` is
68
- destroyed. It must implement `operator()`, accept an Napi::Env, a `T*` (which is the
69
- external data pointer), and return `void`.
70
-
71
- Returns a new `Napi::Buffer` object.
72
-
73
- ### New
74
-
75
- Wraps the provided external data into a new `Napi::Buffer` object.
76
-
77
- The `Napi::Buffer` object does not assume ownership for the data and expects it to be
78
- valid for the lifetime of the object. The data can only be freed once the
79
- `finalizeCallback` is invoked to indicate that the `Napi::Buffer` has been released.
80
-
81
- ```cpp
82
- template <typename Finalizer, typename Hint>
83
- static Napi::Buffer<T> Napi::Buffer::New(napi_env env,
84
- T* data,
85
- size_t length,
86
- Finalizer finalizeCallback,
87
- Hint* finalizeHint);
88
- ```
89
-
90
- - `[in] env`: The environment in which to create the `Napi::Buffer` object.
91
- - `[in] data`: The pointer to the external data to expose.
92
- - `[in] length`: The number of `T` elements in the external data.
93
- - `[in] finalizeCallback`: The function to be called when the `Napi::Buffer` is
94
- destroyed. It must implement `operator()`, accept an Napi::Env, a `T*` (which is the
95
- external data pointer) and `Hint*`, and return `void`.
96
- - `[in] finalizeHint`: The hint to be passed as the second parameter of the
97
- finalize callback.
98
-
99
- Returns a new `Napi::Buffer` object.
100
-
101
- ### Copy
102
-
103
- Allocates a new `Napi::Buffer` object and copies the provided external data into it.
104
-
105
- ```cpp
106
- static Napi::Buffer<T> Napi::Buffer::Copy(napi_env env, const T* data, size_t length);
107
- ```
108
-
109
- - `[in] env`: The environment in which to create the `Napi::Buffer` object.
110
- - `[in] data`: The pointer to the external data to copy.
111
- - `[in] length`: The number of `T` elements in the external data.
112
-
113
- Returns a new `Napi::Buffer` object containing a copy of the data.
114
-
115
- ### Constructor
116
-
117
- Initializes an empty instance of the `Napi::Buffer` class.
118
-
119
- ```cpp
120
- Napi::Buffer::Buffer();
121
- ```
122
-
123
- ### Constructor
124
-
125
- Initializes the `Napi::Buffer` object using an existing Uint8Array.
126
-
127
- ```cpp
128
- Napi::Buffer::Buffer(napi_env env, napi_value value);
129
- ```
130
-
131
- - `[in] env`: The environment in which to create the `Napi::Buffer` object.
132
- - `[in] value`: The Uint8Array reference to wrap.
133
-
134
- ### Data
135
-
136
- ```cpp
137
- T* Napi::Buffer::Data() const;
138
- ```
139
-
140
- Returns a pointer the external data.
141
-
142
- ### Length
143
-
144
- ```cpp
145
- size_t Napi::Buffer::Length() const;
146
- ```
147
-
148
- Returns the number of `T` elements in the external data.
149
-
150
- [`Napi::Uint8Array`]: ./typed_array_of.md
@@ -1,54 +0,0 @@
1
- # CallbackScope
2
-
3
- There are cases (for example, resolving promises) where it is necessary to have
4
- the equivalent of the scope associated with a callback in place when making
5
- certain Node-API calls.
6
-
7
- ## Methods
8
-
9
- ### Constructor
10
-
11
- Creates a new callback scope on the stack.
12
-
13
- ```cpp
14
- Napi::CallbackScope::CallbackScope(napi_env env, napi_callback_scope scope);
15
- ```
16
-
17
- - `[in] env`: The environment in which to create the `Napi::CallbackScope`.
18
- - `[in] scope`: The pre-existing `napi_callback_scope` or `Napi::CallbackScope`.
19
-
20
- ### Constructor
21
-
22
- Creates a new callback scope on the stack.
23
-
24
- ```cpp
25
- Napi::CallbackScope::CallbackScope(napi_env env, napi_async_context context);
26
- ```
27
-
28
- - `[in] env`: The environment in which to create the `Napi::CallbackScope`.
29
- - `[in] async_context`: The pre-existing `napi_async_context` or `Napi::AsyncContext`.
30
-
31
- ### Destructor
32
-
33
- Deletes the instance of `Napi::CallbackScope` object.
34
-
35
- ```cpp
36
- virtual Napi::CallbackScope::~CallbackScope();
37
- ```
38
-
39
- ### Env
40
-
41
- ```cpp
42
- Napi::Env Napi::CallbackScope::Env() const;
43
- ```
44
-
45
- Returns the `Napi::Env` associated with the `Napi::CallbackScope`.
46
-
47
- ## Operator
48
-
49
- ```cpp
50
- Napi::CallbackScope::operator napi_callback_scope() const;
51
- ```
52
-
53
- Returns the Node-API `napi_callback_scope` wrapped by the `Napi::CallbackScope`
54
- object. This can be used to mix usage of the C Node-API and node-addon-api.
@@ -1,97 +0,0 @@
1
- # CallbackInfo
2
-
3
- The object representing the components of the JavaScript request being made.
4
-
5
- The `Napi::CallbackInfo` object is usually created and passed by the Node.js runtime or node-addon-api infrastructure.
6
-
7
- The `Napi::CallbackInfo` object contains the arguments passed by the caller. The number of arguments is returned by the `Length` method. Each individual argument can be accessed using the `operator[]` method.
8
-
9
- The `SetData` and `Data` methods are used to set and retrieve the data pointer contained in the `Napi::CallbackInfo` object.
10
-
11
- ## Methods
12
-
13
- ### Constructor
14
-
15
- ```cpp
16
- Napi::CallbackInfo::CallbackInfo(napi_env env, napi_callback_info info);
17
- ```
18
-
19
- - `[in] env`: The `napi_env` environment in which to construct the `Napi::CallbackInfo` object.
20
- - `[in] info`: The `napi_callback_info` data structure from which to construct the `Napi::CallbackInfo` object.
21
-
22
- ### Env
23
-
24
- ```cpp
25
- Napi::Env Napi::CallbackInfo::Env() const;
26
- ```
27
-
28
- Returns the `Env` object in which the request is being made.
29
-
30
- ### NewTarget
31
-
32
- ```cpp
33
- Napi::Value Napi::CallbackInfo::NewTarget() const;
34
- ```
35
-
36
- Returns the `new.target` value of the constructor call. If the function that was invoked (and for which the `Napi::NCallbackInfo` was passed) is not a constructor call, a call to `IsEmpty()` on the returned value returns true.
37
-
38
- ### IsConstructCall
39
-
40
- ```cpp
41
- bool Napi::CallbackInfo::IsConstructCall() const;
42
- ```
43
-
44
- Returns a `bool` indicating if the function that was invoked (and for which the `Napi::CallbackInfo` was passed) is a constructor call.
45
-
46
- ### Length
47
-
48
- ```cpp
49
- size_t Napi::CallbackInfo::Length() const;
50
- ```
51
-
52
- Returns the number of arguments passed in the `Napi::CallbackInfo` object.
53
-
54
- ### operator []
55
-
56
- ```cpp
57
- const Napi::Value operator [](size_t index) const;
58
- ```
59
-
60
- - `[in] index`: The zero-based index of the requested argument.
61
-
62
- Returns a `Napi::Value` object containing the requested argument.
63
-
64
- ### This
65
-
66
- ```cpp
67
- Napi::Value Napi::CallbackInfo::This() const;
68
- ```
69
-
70
- Returns the JavaScript `this` value for the call
71
-
72
- ### Data
73
-
74
- ```cpp
75
- void* Napi::CallbackInfo::Data() const;
76
- ```
77
-
78
- Returns the data pointer for the callback.
79
-
80
- ### SetData
81
-
82
- ```cpp
83
- void Napi::CallbackInfo::SetData(void* data);
84
- ```
85
-
86
- - `[in] data`: The new data pointer to associate with this `Napi::CallbackInfo` object.
87
-
88
- Returns `void`.
89
-
90
- ### Not documented here
91
-
92
- ```cpp
93
- Napi::CallbackInfo::~CallbackInfo();
94
- // Disallow copying to prevent multiple free of _dynamicArgs
95
- Napi::CallbackInfo::CallbackInfo(CallbackInfo const &) = delete;
96
- void Napi::CallbackInfo::operator=(CallbackInfo const &) = delete;
97
- ```
@@ -1,32 +0,0 @@
1
- # Checker Tool
2
-
3
- **node-addon-api** provides a [checker tool][] that will inspect a given
4
- directory tree, identifying all Node.js native addons therein, and further
5
- indicating for each addon whether it is an Node-API addon.
6
-
7
- ## To use the checker tool:
8
-
9
- 1. Install the application with `npm install`.
10
-
11
- 2. If the application does not depend on **node-addon-api**, copy the
12
- checker tool into the application's directory.
13
-
14
- 3. If the application does not depend on **node-addon-api**, run the checker
15
- tool from the application's directory:
16
-
17
- ```sh
18
- node ./check-napi.js
19
- ```
20
-
21
- Otherwise, the checker tool can be run from the application's
22
- `node_modules/` subdirectory:
23
-
24
- ```sh
25
- node ./node_modules/node-addon-api/tools/check-napi.js
26
- ```
27
-
28
- The tool accepts the root directory from which to start checking for Node.js
29
- native addons as a single optional command line parameter. If omitted it will
30
- start checking from the current directory (`.`).
31
-
32
- [checker tool]: ../tools/check-napi.js
@@ -1,123 +0,0 @@
1
- # Class property and descriptor
2
-
3
- Property descriptor for use with `Napi::ObjectWrap<T>` and
4
- `Napi::InstanceWrap<T>`. This is different from the standalone
5
- `Napi::PropertyDescriptor` because it is specific to each
6
- `Napi::ObjectWrap<T>` and `Napi::InstanceWrap<T>` subclasses.
7
- This prevents using descriptors from a different class when defining a new
8
- class (preventing the callbacks from having incorrect `this` pointers).
9
-
10
- `Napi::ClassPropertyDescriptor` is a helper class created with
11
- `Napi::ObjectWrap<T>` and `Napi::InstanceWrap<T>`. For more reference about it
12
- see:
13
-
14
- - [InstanceWrap](./instance_wrap.md)
15
- - [ObjectWrap](./object_wrap.md)
16
-
17
- ## Example
18
-
19
- ```cpp
20
- #include <napi.h>
21
-
22
- class Example : public Napi::ObjectWrap<Example> {
23
- public:
24
- static Napi::Object Init(Napi::Env env, Napi::Object exports);
25
- Example(const Napi::CallbackInfo &info);
26
-
27
- private:
28
- double _value;
29
- Napi::Value GetValue(const Napi::CallbackInfo &info);
30
- void SetValue(const Napi::CallbackInfo &info, const Napi::Value &value);
31
- };
32
-
33
- Napi::Object Example::Init(Napi::Env env, Napi::Object exports) {
34
- Napi::Function func = DefineClass(env, "Example", {
35
- // Register a class instance accessor with getter and setter functions.
36
- InstanceAccessor<&Example::GetValue, &Example::SetValue>("value"),
37
- // We can also register a readonly accessor by omitting the setter.
38
- InstanceAccessor<&Example::GetValue>("readOnlyProp")
39
- });
40
-
41
- Napi::FunctionReference *constructor = new Napi::FunctionReference();
42
- *constructor = Napi::Persistent(func);
43
- env.SetInstanceData(constructor);
44
- exports.Set("Example", func);
45
-
46
- return exports;
47
- }
48
-
49
- Example::Example(const Napi::CallbackInfo &info) : Napi::ObjectWrap<Example>(info) {
50
- Napi::Env env = info.Env();
51
- // ...
52
- Napi::Number value = info[0].As<Napi::Number>();
53
- this->_value = value.DoubleValue();
54
- }
55
-
56
- Napi::Value Example::GetValue(const Napi::CallbackInfo &info) {
57
- Napi::Env env = info.Env();
58
- return Napi::Number::New(env, this->_value);
59
- }
60
-
61
- void Example::SetValue(const Napi::CallbackInfo &info, const Napi::Value &value) {
62
- Napi::Env env = info.Env();
63
- // ...
64
- Napi::Number arg = value.As<Napi::Number>();
65
- this->_value = arg.DoubleValue();
66
- }
67
-
68
- // Initialize native add-on
69
- Napi::Object Init (Napi::Env env, Napi::Object exports) {
70
- Example::Init(env, exports);
71
- return exports;
72
- }
73
-
74
- // Register and initialize native add-on
75
- NODE_API_MODULE(NODE_GYP_MODULE_NAME, Init)
76
- ```
77
-
78
- The above code can be used from JavaScript as follows:
79
-
80
- ```js
81
- 'use strict';
82
-
83
- const { Example } = require('bindings')('addon');
84
-
85
- const example = new Example(11);
86
- console.log(example.value);
87
- // It prints 11
88
- example.value = 19;
89
- console.log(example.value);
90
- // It prints 19
91
- example.readOnlyProp = 500;
92
- console.log(example.readOnlyProp);
93
- // Unchanged. It prints 19
94
- ```
95
-
96
- ## Methods
97
-
98
- ### Constructor
99
-
100
- Creates new instance of `Napi::ClassPropertyDescriptor` descriptor object.
101
-
102
- ```cpp
103
- Napi::ClassPropertyDescriptor(napi_property_descriptor desc) : _desc(desc) {}
104
- ```
105
-
106
- - `[in] desc`: The `napi_property_descriptor`
107
-
108
- Returns new instance of `Napi::ClassPropertyDescriptor` that is used as property descriptor
109
- inside the `Napi::ObjectWrap<T>` class.
110
-
111
- ### Operator
112
-
113
- ```cpp
114
- operator napi_property_descriptor&() { return _desc; }
115
- ```
116
-
117
- Returns the original Node-API `napi_property_descriptor` wrapped inside the `Napi::ClassPropertyDescriptor`
118
-
119
- ```cpp
120
- operator const napi_property_descriptor&() const { return _desc; }
121
- ```
122
-
123
- Returns the original Node-API `napi_property_descriptor` wrapped inside the `Napi::ClassPropertyDescriptor`
@@ -1,68 +0,0 @@
1
- # CMake.js
2
-
3
- [**CMake.js**](https://github.com/cmake-js/cmake-js) is a build tool that allow native addon developers to compile their
4
- C or C++ code into executable form. It works like **[node-gyp](node-gyp.md)** but
5
- instead of Google's [**gyp**](https://gyp.gsrc.io) tool it is based on the [**CMake**](https://cmake.org) build system.
6
-
7
- ## Quick Start
8
-
9
- ### Install CMake
10
-
11
- CMake.js requires that CMake be installed. Installers for a variety of platforms can be found on the [CMake website](https://cmake.org).
12
-
13
- ### Install CMake.js
14
-
15
- For developers, CMake.js is typically installed as a global package:
16
-
17
- ```bash
18
- npm install -g cmake-js
19
- cmake-js --help
20
- ```
21
-
22
- > For *users* of your native addon, CMake.js should be configured as a dependency in your `package.json` as described in the [CMake.js documentation](https://github.com/cmake-js/cmake-js).
23
-
24
- ### CMakeLists.txt
25
-
26
- Your project will require a `CMakeLists.txt` file. The [CMake.js README file](https://github.com/cmake-js/cmake-js#usage) shows what's necessary.
27
-
28
- ### NAPI_VERSION
29
-
30
- When building Node-API addons, it's crucial to specify the Node-API version your code is designed to work with. With CMake.js, this information is specified in the `CMakeLists.txt` file:
31
-
32
- ```
33
- add_definitions(-DNAPI_VERSION=3)
34
- ```
35
-
36
- Since Node-API is ABI-stable, your Node-API addon will work, without recompilation, with the Node-API version you specify in `NAPI_VERSION` and all subsequent Node-API versions.
37
-
38
- In the absence of a need for features available only in a specific Node-API version, version 3 is a good choice as it is the version of Node-API that was active when Node-API left experimental status.
39
-
40
- ### NAPI_EXPERIMENTAL
41
-
42
- The following line in the `CMakeLists.txt` file will enable Node-API experimental features if your code requires them:
43
-
44
- ```
45
- add_definitions(-DNAPI_EXPERIMENTAL)
46
- ```
47
-
48
- ### node-addon-api
49
-
50
- If your Node-API native add-on uses the optional [**node-addon-api**](https://github.com/nodejs/node-addon-api#node-addon-api-module) C++ wrapper, the `CMakeLists.txt` file requires additional configuration information as described on the [CMake.js README file](https://github.com/cmake-js/cmake-js#n-api-and-node-addon-api).
51
-
52
- ## Example
53
-
54
- A working example of an Node-API native addon built using CMake.js can be found on the [node-addon-examples repository](https://github.com/nodejs/node-addon-examples/tree/HEAD/build_with_cmake#building-n-api-addons-using-cmakejs).
55
-
56
- ## **CMake** Reference
57
-
58
- - [Installation](https://github.com/cmake-js/cmake-js#installation)
59
- - [How to use](https://github.com/cmake-js/cmake-js#usage)
60
- - [Using Node-API and node-addon-api](https://github.com/cmake-js/cmake-js#n-api-and-node-addon-api)
61
- - [Tutorials](https://github.com/cmake-js/cmake-js#tutorials)
62
- - [Use case in the works - ArrayFire.js](https://github.com/cmake-js/cmake-js#use-case-in-the-works---arrayfirejs)
63
-
64
- Sometimes finding the right settings is not easy so to accomplish at most
65
- complicated task please refer to:
66
-
67
- - [CMake documentation](https://cmake.org/)
68
- - [CMake.js wiki](https://github.com/cmake-js/cmake-js/wiki)
@@ -1,28 +0,0 @@
1
- # Conversion Tool
2
-
3
- To make the migration to **node-addon-api** easier, we have provided a script to
4
- help complete some tasks.
5
-
6
- ## To use the conversion script:
7
-
8
- 1. Go to your module directory
9
-
10
- ```
11
- cd [module_path]
12
- ```
13
-
14
- 2. Install node-addon-api module
15
-
16
- ```
17
- npm install node-addon-api
18
- ```
19
- 3. Run node-addon-api conversion script
20
-
21
- ```
22
- node ./node_modules/node-addon-api/tools/conversion.js ./
23
- ```
24
-
25
- 4. While this script makes conversion easier, it still cannot fully convert
26
- the module. The next step is to try to build the module and complete the
27
- remaining conversions necessary to allow it to compile and pass all of the
28
- module's tests.
@@ -1,62 +0,0 @@
1
- # Creating a release
2
-
3
- Only collaborators in npm for **node-addon-api** can create releases.
4
- If you want to be able to do releases ask one of the existing
5
- collaborators to add you. If necessary you can ask the build
6
- Working Group who manages the Node.js npm user to add you if
7
- there are no other active collaborators.
8
-
9
- ## Prerequisites
10
-
11
- Before to start creating a new release check if you have installed the following
12
- tools:
13
-
14
- * [Changelog maker](https://www.npmjs.com/package/changelog-maker)
15
-
16
- If not please follow the instruction reported in the tool's documentation to
17
- install it.
18
-
19
- ## Publish new release
20
-
21
- These are the steps to follow to create a new release:
22
-
23
- * Open an issue in the **node-addon-api** repo documenting the intent to create a
24
- new release. Give people some time to comment or suggest PRs that should land first.
25
-
26
- * Validate all tests pass by running `npm test` on the `main` branch.
27
-
28
- * Update the version in **package.json** appropriately.
29
-
30
- * Update the [README.md](https://github.com/nodejs/node-addon-api/blob/main/README.md)
31
- to show the new version as the latest.
32
-
33
- * Generate the changelog for the new version using **changelog maker** tool. From
34
- the route folder of the repo launch the following command:
35
-
36
- ```bash
37
- > changelog-maker
38
- ```
39
- * Use the output generated by **changelog maker** to update the [CHANGELOG.md](https://github.com/nodejs/node-addon-api/blob/main/CHANGELOG.md)
40
- following the style used in publishing the previous release.
41
-
42
- * Add any new contributors to the "contributors" section in the package.json
43
-
44
- * Validate all tests pass by running `npm test` on the `main` branch.
45
-
46
- * Use **[CI](https://ci.nodejs.org/view/x%20-%20Abi%20stable%20module%20API/job/node-test-node-addon-api-new/)**
47
- to validate tests pass (note there are still some issues on SmartOS and
48
- Windows in the testing).
49
-
50
- * Do a clean checkout of node-addon-api.
51
-
52
- * Login and then run `npm publish`.
53
-
54
- * Create a release in Github (look at existing releases for an example).
55
-
56
- * Validate that you can run `npm install node-addon-api` successfully
57
- and that the correct version is installed.
58
-
59
- * Comment on the issue opened in the first step that the release has been created
60
- and close the issue.
61
-
62
- * Tweet that the release has been created.