koffi 2.3.16 → 2.3.18

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 (82) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/build/2.3.18/koffi_darwin_arm64/koffi.node +0 -0
  3. package/build/2.3.18/koffi_darwin_x64/koffi.node +0 -0
  4. package/build/2.3.18/koffi_freebsd_arm64/koffi.node +0 -0
  5. package/build/2.3.18/koffi_freebsd_ia32/koffi.node +0 -0
  6. package/build/2.3.18/koffi_freebsd_x64/koffi.node +0 -0
  7. package/build/2.3.18/koffi_linux_arm32hf/koffi.node +0 -0
  8. package/build/2.3.18/koffi_linux_arm64/koffi.node +0 -0
  9. package/build/2.3.18/koffi_linux_ia32/koffi.node +0 -0
  10. package/build/2.3.18/koffi_linux_riscv64hf64/koffi.node +0 -0
  11. package/build/2.3.18/koffi_linux_x64/koffi.node +0 -0
  12. package/build/2.3.18/koffi_openbsd_ia32/koffi.node +0 -0
  13. package/build/2.3.18/koffi_openbsd_x64/koffi.node +0 -0
  14. package/build/2.3.18/koffi_win32_arm64/koffi.node +0 -0
  15. package/build/2.3.18/koffi_win32_ia32/koffi.node +0 -0
  16. package/build/2.3.18/koffi_win32_x64/koffi.node +0 -0
  17. package/package.json +2 -2
  18. package/src/koffi/src/call.cc +121 -24
  19. package/src/koffi/src/call.hh +13 -0
  20. package/src/koffi/src/ffi.cc +14 -11
  21. package/src/koffi/src/ffi.hh +2 -0
  22. package/src/koffi/src/util.cc +1 -1
  23. package/src/koffi/src/util.hh +2 -0
  24. package/vendor/node-addon-api/CHANGELOG.md +41 -0
  25. package/vendor/node-addon-api/README.md +1 -1
  26. package/vendor/node-addon-api/doc/array_buffer.md +10 -0
  27. package/vendor/node-addon-api/doc/buffer.md +97 -0
  28. package/vendor/node-addon-api/doc/env.md +2 -2
  29. package/vendor/node-addon-api/doc/external.md +2 -2
  30. package/vendor/node-addon-api/doc/external_buffer.md +18 -0
  31. package/vendor/node-addon-api/doc/hierarchy.md +4 -2
  32. package/vendor/node-addon-api/doc/object.md +2 -29
  33. package/vendor/node-addon-api/doc/type_taggable.md +40 -0
  34. package/vendor/node-addon-api/doc/value.md +7 -1
  35. package/vendor/node-addon-api/napi-inl.h +317 -22
  36. package/vendor/node-addon-api/napi.h +84 -7
  37. package/vendor/node-addon-api/package.json +9 -1
  38. package/vendor/node-addon-api/test/async_progress_worker.cc +15 -3
  39. package/vendor/node-addon-api/test/binding.cc +4 -2
  40. package/vendor/node-addon-api/test/binding.gyp +11 -1
  41. package/vendor/node-addon-api/test/buffer.cc +13 -19
  42. package/vendor/node-addon-api/test/buffer.h +26 -0
  43. package/vendor/node-addon-api/test/buffer.js +82 -0
  44. package/vendor/node-addon-api/test/buffer_new_or_copy-inl.h +68 -0
  45. package/vendor/node-addon-api/test/buffer_no_external.cc +24 -0
  46. package/vendor/node-addon-api/test/error.cc +101 -0
  47. package/vendor/node-addon-api/test/error.js +15 -1
  48. package/vendor/node-addon-api/test/index.js +1 -1
  49. package/vendor/node-addon-api/test/object_reference.cc +220 -22
  50. package/vendor/node-addon-api/test/object_reference.js +83 -80
  51. package/vendor/node-addon-api/test/objectwrap.cc +23 -3
  52. package/vendor/node-addon-api/test/objectwrap.js +14 -2
  53. package/vendor/node-addon-api/test/reference.cc +55 -1
  54. package/vendor/node-addon-api/test/reference.js +7 -1
  55. package/vendor/node-addon-api/test/type_taggable.cc +66 -0
  56. package/vendor/node-addon-api/test/type_taggable.js +60 -0
  57. package/vendor/node-addon-api/test/value_type_cast.cc +60 -0
  58. package/vendor/node-addon-api/test/value_type_cast.js +106 -0
  59. package/vendor/node-addon-api/tools/eslint-format.js +2 -2
  60. package/build/2.3.16/koffi_darwin_arm64/koffi.node +0 -0
  61. package/build/2.3.16/koffi_darwin_x64/koffi.node +0 -0
  62. package/build/2.3.16/koffi_freebsd_arm64/koffi.node +0 -0
  63. package/build/2.3.16/koffi_freebsd_ia32/koffi.node +0 -0
  64. package/build/2.3.16/koffi_freebsd_x64/koffi.node +0 -0
  65. package/build/2.3.16/koffi_linux_arm32hf/koffi.node +0 -0
  66. package/build/2.3.16/koffi_linux_arm64/koffi.node +0 -0
  67. package/build/2.3.16/koffi_linux_ia32/koffi.node +0 -0
  68. package/build/2.3.16/koffi_linux_riscv64hf64/koffi.node +0 -0
  69. package/build/2.3.16/koffi_linux_x64/koffi.node +0 -0
  70. package/build/2.3.16/koffi_openbsd_ia32/koffi.node +0 -0
  71. package/build/2.3.16/koffi_openbsd_x64/koffi.node +0 -0
  72. package/build/2.3.16/koffi_win32_arm64/koffi.node +0 -0
  73. package/build/2.3.16/koffi_win32_ia32/koffi.node +0 -0
  74. package/build/2.3.16/koffi_win32_x64/koffi.node +0 -0
  75. package/vendor/node-addon-api/test/object/object_type_tag.cc +0 -39
  76. package/vendor/node-addon-api/test/object/object_type_tag.js +0 -55
  77. /package/build/{2.3.16 → 2.3.18}/koffi_win32_arm64/koffi.exp +0 -0
  78. /package/build/{2.3.16 → 2.3.18}/koffi_win32_arm64/koffi.lib +0 -0
  79. /package/build/{2.3.16 → 2.3.18}/koffi_win32_ia32/koffi.exp +0 -0
  80. /package/build/{2.3.16 → 2.3.18}/koffi_win32_ia32/koffi.lib +0 -0
  81. /package/build/{2.3.16 → 2.3.18}/koffi_win32_x64/koffi.exp +0 -0
  82. /package/build/{2.3.16 → 2.3.18}/koffi_win32_x64/koffi.lib +0 -0
@@ -138,7 +138,7 @@ template <typename Hook>
138
138
  CleanupHook<Hook> AddCleanupHook(Hook hook);
139
139
  ```
140
140
 
141
- - `[in] hook`: A function to call when the environment exists. Accepts a
141
+ - `[in] hook`: A function to call when the environment exits. Accepts a
142
142
  function of the form `void ()`.
143
143
 
144
144
  Registers `hook` as a function to be run once the current Node.js environment
@@ -156,7 +156,7 @@ template <typename Hook, typename Arg>
156
156
  CleanupHook<Hook, Arg> AddCleanupHook(Hook hook, Arg* arg);
157
157
  ```
158
158
 
159
- - `[in] hook`: A function to call when the environment exists. Accepts a
159
+ - `[in] hook`: A function to call when the environment exits. Accepts a
160
160
  function of the form `void (Arg* arg)`.
161
161
  - `[in] arg`: A pointer to data that will be passed as the argument to `hook`.
162
162
 
@@ -1,6 +1,6 @@
1
1
  # External (template)
2
2
 
3
- Class `Napi::External<T>` inherits from class [`Napi::Value`][].
3
+ Class `Napi::External<T>` inherits from class [`Napi::TypeTaggable`][].
4
4
 
5
5
  The `Napi::External` template class implements the ability to create a `Napi::Value` object with arbitrary C++ data. It is the user's responsibility to manage the memory for the arbitrary C++ data.
6
6
 
@@ -67,4 +67,4 @@ T* Napi::External::Data() const;
67
67
 
68
68
  Returns a pointer to the arbitrary C++ data held by the `Napi::External` object.
69
69
 
70
- [`Napi::Value`]: ./value.md
70
+ [`Napi::TypeTaggable`]: ./type_taggable.md
@@ -0,0 +1,18 @@
1
+ # External Buffer
2
+
3
+ **Some runtimes other than Node.js have dropped support for external buffers**.
4
+ On runtimes other than Node.js, node-api methods may return
5
+ `napi_no_external_buffers_allowed` to indicate that external
6
+ buffers are not supported. One such runtime is Electron as
7
+ described in this issue
8
+ [electron/issues/35801](https://github.com/electron/electron/issues/35801).
9
+
10
+ In order to maintain broadest compatibility with all runtimes,
11
+ you may define `NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED` in your addon before
12
+ includes for the node-api and node-addon-api headers. Doing so will hide the
13
+ functions that create external buffers. This will ensure a compilation error
14
+ occurs if you accidentally use one of these methods.
15
+
16
+ In node-addon-api, the `Napi::Buffer::NewOrCopy` provides a convenient way to
17
+ create an external buffer, or allocate a new buffer and copy the data when the
18
+ external buffer is not supported.
@@ -20,7 +20,7 @@
20
20
  | [`Napi::Env`][] | |
21
21
  | [`Napi::Error`][] | [`Napi::ObjectReference`][], [`std::exception`][] |
22
22
  | [`Napi::EscapableHandleScope`][] | |
23
- | [`Napi::External`][] | [`Napi::Value`][] |
23
+ | [`Napi::External`][] | [`Napi::TypeTaggable`][] |
24
24
  | [`Napi::Function`][] | [`Napi::Object`][] |
25
25
  | [`Napi::FunctionReference`][] | [`Napi::Reference<Napi::Function>`][] |
26
26
  | [`Napi::HandleScope`][] | |
@@ -28,7 +28,7 @@
28
28
  | [`Napi::MemoryManagement`][] | |
29
29
  | [`Napi::Name`][] | [`Napi::Value`][] |
30
30
  | [`Napi::Number`][] | [`Napi::Value`][] |
31
- | [`Napi::Object`][] | [`Napi::Value`][] |
31
+ | [`Napi::Object`][] | [`Napi::TypeTaggable`][] |
32
32
  | [`Napi::ObjectReference`][] | [`Napi::Reference<Napi::Object>`][] |
33
33
  | [`Napi::ObjectWrap`][] | [`Napi::InstanceWrap`][], [`Napi::Reference<Napi::Object>`][] |
34
34
  | [`Napi::Promise`][] | [`Napi::Object`][] |
@@ -38,6 +38,7 @@
38
38
  | [`Napi::String`][] | [`Napi::Name`][] |
39
39
  | [`Napi::Symbol`][] | [`Napi::Name`][] |
40
40
  | [`Napi::ThreadSafeFunction`][] | |
41
+ | [`Napi::TypeTaggable`][] | [`Napi::Value][] |
41
42
  | [`Napi::TypeError`][] | [`Napi::Error`][] |
42
43
  | [`Napi::TypedArray`][] | [`Napi::Object`][] |
43
44
  | [`Napi::TypedArrayOf`][] | [`Napi::TypedArray`][] |
@@ -83,6 +84,7 @@
83
84
  [`Napi::Symbol`]: ./symbol.md
84
85
  [`Napi::ThreadSafeFunction`]: ./threadsafe_function.md
85
86
  [`Napi::TypeError`]: ./type_error.md
87
+ [`Napi::TypeTaggable`]: ./type_taggable.md
86
88
  [`Napi::TypedArray`]: ./typed_array.md
87
89
  [`Napi::TypedArrayOf`]: ./typed_array_of.md
88
90
  [`Napi::Uint8Array`]: ./typed_array_of.md
@@ -1,6 +1,6 @@
1
1
  # Object
2
2
 
3
- Class `Napi::Object` inherits from class [`Napi::Value`][].
3
+ Class `Napi::Object` inherits from class [`Napi::TypeTaggable`][].
4
4
 
5
5
  The `Napi::Object` class corresponds to a JavaScript object. It is extended by the following node-addon-api classes that you may use when working with more specific types:
6
6
 
@@ -241,33 +241,6 @@ from being added to it and marking all existing properties as non-configurable.
241
241
  Values of present properties can still be changed as long as they are
242
242
  writable.
243
243
 
244
- ### TypeTag()
245
-
246
- ```cpp
247
- void Napi::Object::TypeTag(const napi_type_tag* type_tag) const;
248
- ```
249
-
250
- - `[in] type_tag`: The tag with which this object is to be marked.
251
-
252
- The `Napi::Object::TypeTag()` method associates the value of the `type_tag`
253
- pointer with this JavaScript object. `Napi::Object::CheckTypeTag()` can then be
254
- used to compare the tag that was attached to this object with one owned by the
255
- addon to ensure that this object has the right type.
256
-
257
- ### CheckTypeTag()
258
-
259
- ```cpp
260
- bool Napi::Object::CheckTypeTag(const napi_type_tag* type_tag) const;
261
- ```
262
-
263
- - `[in] type_tag`: The tag with which to compare any tag found on this object.
264
-
265
- The `Napi::Object::CheckTypeTag()` method compares the pointer given as
266
- `type_tag` with any that can be found on this JavaScript object. If no tag is
267
- found on this object or, if a tag is found but it does not match `type_tag`,
268
- then the return value is `false`. If a tag is found and it matches `type_tag`,
269
- then the return value is `true`.
270
-
271
244
  ### operator\[\]()
272
245
 
273
246
  ```cpp
@@ -434,5 +407,5 @@ void Increment(const CallbackInfo& info) {
434
407
  }
435
408
  ```
436
409
 
437
- [`Napi::Value`]: ./value.md
410
+ [`Napi::TypeTaggable`]: ./type_taggable.md
438
411
  [`Napi::Value::From`]: ./value.md#from
@@ -0,0 +1,40 @@
1
+ # TypeTaggable
2
+
3
+ Class `Napi::TypeTaggable` inherits from class [`Napi::Value`][].
4
+
5
+ The `Napi::TypeTaggable` class is the base class for [`Napi::Object`][] and
6
+ [`Napi::External`][]. It adds type-tagging capabilities to both. It is an
7
+ abstract-only base class.
8
+
9
+ ### TypeTag()
10
+
11
+ ```cpp
12
+ void Napi::TypeTaggable::TypeTag(const napi_type_tag* type_tag) const;
13
+ ```
14
+
15
+ - `[in] type_tag`: The tag with which this object or external is to be marked.
16
+
17
+ The `Napi::TypeTaggable::TypeTag()` method associates the value of the
18
+ `type_tag` pointer with this JavaScript object or external.
19
+ `Napi::TypeTaggable::CheckTypeTag()` can then be used to compare the tag that
20
+ was attached with one owned by the add-on to ensure that this object or external
21
+ has the right type.
22
+
23
+ ### CheckTypeTag()
24
+
25
+ ```cpp
26
+ bool Napi::TypeTaggable::CheckTypeTag(const napi_type_tag* type_tag) const;
27
+ ```
28
+
29
+ - `[in] type_tag`: The tag with which to compare any tag found on this object or
30
+ external.
31
+
32
+ The `Napi::TypeTaggable::CheckTypeTag()` method compares the pointer given as
33
+ `type_tag` with any that can be found on this JavaScript object or external. If
34
+ no tag is found or if a tag is found but it does not match `type_tag`, then the
35
+ return value is `false`. If a tag is found and it matches `type_tag`, then the
36
+ return value is `true`.
37
+
38
+ [`Napi::Value`]: ./value.md
39
+ [`Napi::Object`]: ./object.md
40
+ [`Napi::External`]: ./external.md
@@ -78,7 +78,13 @@ Casts to another type of `Napi::Value`, when the actual type is known or
78
78
  assumed.
79
79
 
80
80
  This conversion does not coerce the type. Calling any methods inappropriate for
81
- the actual value type will throw `Napi::Error`.
81
+ the actual value type will throw `Napi::Error`. When C++ exceptions are
82
+ disabled, the thrown error will not be reflected before control returns to
83
+ JavaScript.
84
+
85
+ In order to enforce expected type, use `Napi::Value::Is*()` methods to check
86
+ the type before calling `Napi::Value::As()`, or compile with definition
87
+ `NODE_ADDON_API_ENABLE_TYPE_CHECK_ON_AS` to enforce type checks.
82
88
 
83
89
  ### Env
84
90