koffi 1.1.0-beta.0 → 1.1.0-beta.3
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/CMakeLists.txt +4 -0
- package/README.md +16 -11
- package/build/qemu/1.1.0-beta.3/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.3/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.3/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.3/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.3/koffi_linux_arm.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.3/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.3/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.3/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.3/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.3/koffi_win32_x64.tar.gz +0 -0
- package/package.json +1 -1
- package/qemu/qemu.js +1 -0
- package/src/abi_arm32.cc +27 -45
- package/src/abi_arm64.cc +58 -132
- package/src/abi_x64_sysv.cc +24 -7
- package/src/abi_x64_win.cc +3 -0
- package/src/abi_x86.cc +3 -0
- package/src/call.cc +540 -33
- package/src/call.hh +5 -3
- package/src/ffi.cc +69 -4
- package/src/ffi.hh +3 -1
- package/src/parser.cc +7 -2
- package/src/util.cc +72 -0
- package/src/util.hh +2 -0
- package/test/misc.c +14 -8
- package/vendor/node-addon-api/CODE_OF_CONDUCT.md +4 -0
- package/vendor/node-addon-api/CONTRIBUTING.md +93 -0
- package/vendor/node-addon-api/appveyor.yml +37 -0
- package/vendor/node-addon-api/benchmark/README.md +47 -0
- package/vendor/node-addon-api/benchmark/binding.gyp +25 -0
- package/vendor/node-addon-api/benchmark/function_args.cc +217 -0
- package/vendor/node-addon-api/benchmark/function_args.js +60 -0
- package/vendor/node-addon-api/benchmark/index.js +34 -0
- package/vendor/node-addon-api/benchmark/property_descriptor.cc +91 -0
- package/vendor/node-addon-api/benchmark/property_descriptor.js +37 -0
- package/vendor/node-addon-api/doc/addon.md +163 -0
- package/vendor/node-addon-api/doc/array.md +81 -0
- package/vendor/node-addon-api/doc/array_buffer.md +155 -0
- package/vendor/node-addon-api/doc/async_context.md +86 -0
- package/vendor/node-addon-api/doc/async_operations.md +31 -0
- package/vendor/node-addon-api/doc/async_worker.md +427 -0
- package/vendor/node-addon-api/doc/async_worker_variants.md +557 -0
- package/vendor/node-addon-api/doc/bigint.md +97 -0
- package/vendor/node-addon-api/doc/boolean.md +68 -0
- package/vendor/node-addon-api/doc/buffer.md +150 -0
- package/vendor/node-addon-api/doc/callback_scope.md +54 -0
- package/vendor/node-addon-api/doc/callbackinfo.md +97 -0
- package/vendor/node-addon-api/doc/checker-tool.md +32 -0
- package/vendor/node-addon-api/doc/class_property_descriptor.md +123 -0
- package/vendor/node-addon-api/doc/cmake-js.md +68 -0
- package/vendor/node-addon-api/doc/conversion-tool.md +28 -0
- package/vendor/node-addon-api/doc/creating_a_release.md +62 -0
- package/vendor/node-addon-api/doc/dataview.md +248 -0
- package/vendor/node-addon-api/doc/date.md +68 -0
- package/vendor/node-addon-api/doc/env.md +196 -0
- package/vendor/node-addon-api/doc/error.md +120 -0
- package/vendor/node-addon-api/doc/error_handling.md +254 -0
- package/vendor/node-addon-api/doc/escapable_handle_scope.md +80 -0
- package/vendor/node-addon-api/doc/external.md +63 -0
- package/vendor/node-addon-api/doc/function.md +402 -0
- package/vendor/node-addon-api/doc/function_reference.md +238 -0
- package/vendor/node-addon-api/doc/generator.md +13 -0
- package/vendor/node-addon-api/doc/handle_scope.md +63 -0
- package/vendor/node-addon-api/doc/hierarchy.md +91 -0
- package/vendor/node-addon-api/doc/instance_wrap.md +408 -0
- package/vendor/node-addon-api/doc/maybe.md +76 -0
- package/vendor/node-addon-api/doc/memory_management.md +27 -0
- package/vendor/node-addon-api/doc/name.md +29 -0
- package/vendor/node-addon-api/doc/node-gyp.md +82 -0
- package/vendor/node-addon-api/doc/number.md +163 -0
- package/vendor/node-addon-api/doc/object.md +411 -0
- package/vendor/node-addon-api/doc/object_lifetime_management.md +83 -0
- package/vendor/node-addon-api/doc/object_reference.md +117 -0
- package/vendor/node-addon-api/doc/object_wrap.md +588 -0
- package/vendor/node-addon-api/doc/prebuild_tools.md +16 -0
- package/vendor/node-addon-api/doc/promises.md +79 -0
- package/vendor/node-addon-api/doc/property_descriptor.md +286 -0
- package/vendor/node-addon-api/doc/propertylvalue.md +50 -0
- package/vendor/node-addon-api/doc/range_error.md +59 -0
- package/vendor/node-addon-api/doc/reference.md +113 -0
- package/vendor/node-addon-api/doc/setup.md +110 -0
- package/vendor/node-addon-api/doc/string.md +93 -0
- package/vendor/node-addon-api/doc/symbol.md +61 -0
- package/vendor/node-addon-api/doc/threadsafe.md +121 -0
- package/vendor/node-addon-api/doc/threadsafe_function.md +290 -0
- package/vendor/node-addon-api/doc/type_error.md +59 -0
- package/vendor/node-addon-api/doc/typed_array.md +78 -0
- package/vendor/node-addon-api/doc/typed_array_of.md +137 -0
- package/vendor/node-addon-api/doc/typed_threadsafe_function.md +306 -0
- package/vendor/node-addon-api/doc/value.md +340 -0
- package/vendor/node-addon-api/doc/version_management.md +43 -0
- package/vendor/node-addon-api/package.json +415 -0
- package/vendor/node-addon-api/test/README.md +91 -0
- package/vendor/node-addon-api/test/addon.cc +36 -0
- package/vendor/node-addon-api/test/addon.js +11 -0
- package/vendor/node-addon-api/test/addon_build/index.js +49 -0
- package/vendor/node-addon-api/test/addon_build/tpl/addon.cc +17 -0
- package/vendor/node-addon-api/test/addon_build/tpl/binding.gyp +62 -0
- package/vendor/node-addon-api/test/addon_build/tpl/index.js +9 -0
- package/vendor/node-addon-api/test/addon_build/tpl/package.json +11 -0
- package/vendor/node-addon-api/test/addon_data.cc +99 -0
- package/vendor/node-addon-api/test/addon_data.js +46 -0
- package/vendor/node-addon-api/test/array_buffer.cc +243 -0
- package/vendor/node-addon-api/test/array_buffer.js +69 -0
- package/vendor/node-addon-api/test/async_context.cc +36 -0
- package/vendor/node-addon-api/test/async_context.js +122 -0
- package/vendor/node-addon-api/test/async_progress_queue_worker.cc +83 -0
- package/vendor/node-addon-api/test/async_progress_queue_worker.js +46 -0
- package/vendor/node-addon-api/test/async_progress_worker.cc +134 -0
- package/vendor/node-addon-api/test/async_progress_worker.js +61 -0
- package/vendor/node-addon-api/test/async_worker.cc +106 -0
- package/vendor/node-addon-api/test/async_worker.js +179 -0
- package/vendor/node-addon-api/test/async_worker_nocallback.js +13 -0
- package/vendor/node-addon-api/test/async_worker_persistent.cc +63 -0
- package/vendor/node-addon-api/test/async_worker_persistent.js +24 -0
- package/vendor/node-addon-api/test/basic_types/array.cc +40 -0
- package/vendor/node-addon-api/test/basic_types/array.js +35 -0
- package/vendor/node-addon-api/test/basic_types/boolean.cc +38 -0
- package/vendor/node-addon-api/test/basic_types/boolean.js +35 -0
- package/vendor/node-addon-api/test/basic_types/number.cc +99 -0
- package/vendor/node-addon-api/test/basic_types/number.js +114 -0
- package/vendor/node-addon-api/test/basic_types/value.cc +120 -0
- package/vendor/node-addon-api/test/basic_types/value.js +133 -0
- package/vendor/node-addon-api/test/bigint.cc +91 -0
- package/vendor/node-addon-api/test/bigint.js +53 -0
- package/vendor/node-addon-api/test/binding-swallowexcept.cc +12 -0
- package/vendor/node-addon-api/test/binding.cc +173 -0
- package/vendor/node-addon-api/test/binding.gyp +124 -0
- package/vendor/node-addon-api/test/buffer.cc +183 -0
- package/vendor/node-addon-api/test/buffer.js +69 -0
- package/vendor/node-addon-api/test/callbackscope.cc +22 -0
- package/vendor/node-addon-api/test/callbackscope.js +49 -0
- package/vendor/node-addon-api/test/common/index.js +114 -0
- package/vendor/node-addon-api/test/common/test_helper.h +71 -0
- package/vendor/node-addon-api/test/dataview/dataview.cc +48 -0
- package/vendor/node-addon-api/test/dataview/dataview.js +35 -0
- package/vendor/node-addon-api/test/dataview/dataview_read_write.cc +115 -0
- package/vendor/node-addon-api/test/dataview/dataview_read_write.js +90 -0
- package/vendor/node-addon-api/test/date.cc +44 -0
- package/vendor/node-addon-api/test/date.js +18 -0
- package/vendor/node-addon-api/test/env_cleanup.cc +88 -0
- package/vendor/node-addon-api/test/env_cleanup.js +56 -0
- package/vendor/node-addon-api/test/error.cc +287 -0
- package/vendor/node-addon-api/test/error.js +81 -0
- package/vendor/node-addon-api/test/error_handling_for_primitives.cc +13 -0
- package/vendor/node-addon-api/test/error_handling_for_primitives.js +29 -0
- package/vendor/node-addon-api/test/error_terminating_environment.js +95 -0
- package/vendor/node-addon-api/test/external.cc +81 -0
- package/vendor/node-addon-api/test/external.js +88 -0
- package/vendor/node-addon-api/test/function.cc +324 -0
- package/vendor/node-addon-api/test/function.js +133 -0
- package/vendor/node-addon-api/test/function_reference.cc +202 -0
- package/vendor/node-addon-api/test/function_reference.js +157 -0
- package/vendor/node-addon-api/test/globalObject/global_object.cc +61 -0
- package/vendor/node-addon-api/test/globalObject/global_object_delete_property.cc +31 -0
- package/vendor/node-addon-api/test/globalObject/global_object_delete_property.js +61 -0
- package/vendor/node-addon-api/test/globalObject/global_object_get_property.cc +40 -0
- package/vendor/node-addon-api/test/globalObject/global_object_get_property.js +57 -0
- package/vendor/node-addon-api/test/globalObject/global_object_has_own_property.cc +28 -0
- package/vendor/node-addon-api/test/globalObject/global_object_has_own_property.js +48 -0
- package/vendor/node-addon-api/test/globalObject/global_object_set_property.cc +31 -0
- package/vendor/node-addon-api/test/globalObject/global_object_set_property.js +58 -0
- package/vendor/node-addon-api/test/handlescope.cc +60 -0
- package/vendor/node-addon-api/test/handlescope.js +14 -0
- package/vendor/node-addon-api/test/index.js +159 -0
- package/vendor/node-addon-api/test/maybe/check.cc +23 -0
- package/vendor/node-addon-api/test/maybe/index.js +38 -0
- package/vendor/node-addon-api/test/memory_management.cc +17 -0
- package/vendor/node-addon-api/test/memory_management.js +9 -0
- package/vendor/node-addon-api/test/movable_callbacks.cc +23 -0
- package/vendor/node-addon-api/test/movable_callbacks.js +21 -0
- package/vendor/node-addon-api/test/name.cc +108 -0
- package/vendor/node-addon-api/test/name.js +59 -0
- package/vendor/node-addon-api/test/napi_child.js +14 -0
- package/vendor/node-addon-api/test/object/delete_property.cc +38 -0
- package/vendor/node-addon-api/test/object/delete_property.js +41 -0
- package/vendor/node-addon-api/test/object/finalizer.cc +29 -0
- package/vendor/node-addon-api/test/object/finalizer.js +28 -0
- package/vendor/node-addon-api/test/object/get_property.cc +34 -0
- package/vendor/node-addon-api/test/object/get_property.js +40 -0
- package/vendor/node-addon-api/test/object/has_own_property.cc +34 -0
- package/vendor/node-addon-api/test/object/has_own_property.js +34 -0
- package/vendor/node-addon-api/test/object/has_property.cc +38 -0
- package/vendor/node-addon-api/test/object/has_property.js +37 -0
- package/vendor/node-addon-api/test/object/object.cc +350 -0
- package/vendor/node-addon-api/test/object/object.js +217 -0
- package/vendor/node-addon-api/test/object/object_deprecated.cc +66 -0
- package/vendor/node-addon-api/test/object/object_deprecated.js +47 -0
- package/vendor/node-addon-api/test/object/object_freeze_seal.cc +25 -0
- package/vendor/node-addon-api/test/object/object_freeze_seal.js +61 -0
- package/vendor/node-addon-api/test/object/set_property.cc +45 -0
- package/vendor/node-addon-api/test/object/set_property.js +30 -0
- package/vendor/node-addon-api/test/object/subscript_operator.cc +58 -0
- package/vendor/node-addon-api/test/object/subscript_operator.js +17 -0
- package/vendor/node-addon-api/test/object_reference.cc +219 -0
- package/vendor/node-addon-api/test/object_reference.js +259 -0
- package/vendor/node-addon-api/test/objectwrap.cc +268 -0
- package/vendor/node-addon-api/test/objectwrap.js +284 -0
- package/vendor/node-addon-api/test/objectwrap_constructor_exception.cc +26 -0
- package/vendor/node-addon-api/test/objectwrap_constructor_exception.js +18 -0
- package/vendor/node-addon-api/test/objectwrap_function.cc +45 -0
- package/vendor/node-addon-api/test/objectwrap_function.js +22 -0
- package/vendor/node-addon-api/test/objectwrap_multiple_inheritance.cc +30 -0
- package/vendor/node-addon-api/test/objectwrap_multiple_inheritance.js +13 -0
- package/vendor/node-addon-api/test/objectwrap_removewrap.cc +45 -0
- package/vendor/node-addon-api/test/objectwrap_removewrap.js +40 -0
- package/vendor/node-addon-api/test/objectwrap_worker_thread.js +19 -0
- package/vendor/node-addon-api/test/promise.cc +29 -0
- package/vendor/node-addon-api/test/promise.js +18 -0
- package/vendor/node-addon-api/test/reference.cc +24 -0
- package/vendor/node-addon-api/test/reference.js +14 -0
- package/vendor/node-addon-api/test/run_script.cc +56 -0
- package/vendor/node-addon-api/test/run_script.js +45 -0
- package/vendor/node-addon-api/test/symbol.cc +79 -0
- package/vendor/node-addon-api/test/symbol.js +73 -0
- package/vendor/node-addon-api/test/testUtil.js +54 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function.cc +195 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function.js +188 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ctx.cc +63 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ctx.js +12 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_existing_tsfn.cc +115 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_existing_tsfn.js +14 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ptr.cc +26 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ptr.js +7 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_sum.cc +225 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_sum.js +59 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_unref.cc +42 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_unref.js +53 -0
- package/vendor/node-addon-api/test/thunking_manual.cc +140 -0
- package/vendor/node-addon-api/test/thunking_manual.js +17 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function.cc +215 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function.js +188 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ctx.cc +68 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ctx.js +12 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_existing_tsfn.cc +127 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_existing_tsfn.js +14 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ptr.cc +28 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ptr.js +7 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_sum.cc +237 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_sum.js +59 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_unref.cc +53 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_unref.js +53 -0
- package/vendor/node-addon-api/test/typedarray-bigint.js +58 -0
- package/vendor/node-addon-api/test/typedarray.cc +216 -0
- package/vendor/node-addon-api/test/typedarray.js +69 -0
- package/vendor/node-addon-api/test/version_management.cc +27 -0
- package/vendor/node-addon-api/test/version_management.js +31 -0
- package/vendor/node-addon-api/unit-test/README.md +28 -0
- package/vendor/node-addon-api/unit-test/binding-file-template.js +39 -0
- package/vendor/node-addon-api/unit-test/binding.gyp +72 -0
- package/vendor/node-addon-api/unit-test/exceptions.js +32 -0
- package/vendor/node-addon-api/unit-test/generate-binding-cc.js +61 -0
- package/vendor/node-addon-api/unit-test/injectTestParams.js +101 -0
- package/vendor/node-addon-api/unit-test/listOfTestModules.js +88 -0
- package/vendor/node-addon-api/unit-test/matchModules.js +65 -0
- package/vendor/node-addon-api/unit-test/setup.js +13 -0
- package/vendor/node-addon-api/unit-test/spawnTask.js +26 -0
- package/vendor/node-addon-api/unit-test/test.js +30 -0
- package/build/qemu/1.1.0-beta.0/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.0/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.0/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.0/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.0/koffi_linux_arm.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.0/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.0/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.0/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.0/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.0/koffi_win32_x64.tar.gz +0 -0
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
# Value
|
|
2
|
+
|
|
3
|
+
`Napi::Value` is the C++ manifestation of a JavaScript value. It is the base
|
|
4
|
+
class upon which other JavaScript values such as `Napi::Number`,
|
|
5
|
+
`Napi::Boolean`, `Napi::String`, and `Napi::Object` are based. It represents a
|
|
6
|
+
JavaScript value of an unknown type. It is a thin wrapper around the Node-API
|
|
7
|
+
datatype `napi_value`. Methods on this class can be used to check the JavaScript
|
|
8
|
+
type of the underlying Node-API `napi_value` and also to convert to C++ types.
|
|
9
|
+
|
|
10
|
+
## Constructors
|
|
11
|
+
|
|
12
|
+
### Empty Constructor
|
|
13
|
+
|
|
14
|
+
```cpp
|
|
15
|
+
Napi::Value::Value();
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Creates a new *empty* `Napi::Value` instance.
|
|
19
|
+
|
|
20
|
+
### Constructor
|
|
21
|
+
|
|
22
|
+
```cpp
|
|
23
|
+
Napi::Value::Value(napi_env env, napi_value value);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
- `[in] env`: The `napi_env` environment in which to construct the `Napi::Value`
|
|
27
|
+
object.
|
|
28
|
+
- `[in] value`: The C++ primitive from which to instantiate the `Napi::Value`.
|
|
29
|
+
value` may be any of:
|
|
30
|
+
- `bool`
|
|
31
|
+
- Any integer type
|
|
32
|
+
- Any floating point type
|
|
33
|
+
- `const char*` (encoded using UTF-8, null-terminated)
|
|
34
|
+
- `const char16_t*` (encoded using UTF-16-LE, null-terminated)
|
|
35
|
+
- `std::string` (encoded using UTF-8)
|
|
36
|
+
- `std::u16string`
|
|
37
|
+
- `Napi::Value`
|
|
38
|
+
- `napi_value`
|
|
39
|
+
|
|
40
|
+
## Operators
|
|
41
|
+
|
|
42
|
+
### operator napi_value
|
|
43
|
+
|
|
44
|
+
```cpp
|
|
45
|
+
Napi::Value::operator napi_value() const;
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Returns the underlying Node-API `napi_value`. If the instance is _empty_, this
|
|
49
|
+
returns `nullptr`.
|
|
50
|
+
|
|
51
|
+
### operator ==
|
|
52
|
+
|
|
53
|
+
```cpp
|
|
54
|
+
bool Napi::Value::operator ==(const Napi::Value& other) const;
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Returns `true` if this value strictly equals another value, or `false`
|
|
58
|
+
otherwise.
|
|
59
|
+
|
|
60
|
+
### operator !=
|
|
61
|
+
|
|
62
|
+
```cpp
|
|
63
|
+
bool Napi::Value::operator !=(const Napi::Value& other) const;
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Returns `false` if this value strictly equals another value, or `true`
|
|
67
|
+
otherwise.
|
|
68
|
+
|
|
69
|
+
## Methods
|
|
70
|
+
|
|
71
|
+
### As
|
|
72
|
+
|
|
73
|
+
```cpp
|
|
74
|
+
template <typename T> T Napi::Value::As() const;
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Casts to another type of `Napi::Value`, when the actual type is known or
|
|
78
|
+
assumed.
|
|
79
|
+
|
|
80
|
+
This conversion does not coerce the type. Calling any methods inappropriate for
|
|
81
|
+
the actual value type will throw `Napi::Error`.
|
|
82
|
+
|
|
83
|
+
### Env
|
|
84
|
+
|
|
85
|
+
```cpp
|
|
86
|
+
Napi::Env Napi::Value::Env() const;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Returns the `Napi::Env` environment this value is associated with. See
|
|
90
|
+
[`Napi::Env`](env.md) for more details about environments.
|
|
91
|
+
|
|
92
|
+
### From
|
|
93
|
+
|
|
94
|
+
```cpp
|
|
95
|
+
template <typename T>
|
|
96
|
+
static Napi::Value Napi::Value::From(napi_env env, const T& value);
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
- `[in] env`: The `napi_env` environment in which to create the `Napi::Value`
|
|
100
|
+
object.
|
|
101
|
+
- `[in] value`: The Node-API primitive value from which to create the `Napi::Value`
|
|
102
|
+
object.
|
|
103
|
+
|
|
104
|
+
Returns a `Napi::Value` object from an Node-API primitive value.
|
|
105
|
+
|
|
106
|
+
This method is used to convert from a C++ type to a JavaScript value.
|
|
107
|
+
Here, `value` may be any of:
|
|
108
|
+
- `bool` - returns a `Napi::Boolean`.
|
|
109
|
+
- Any integer type - returns a `Napi::Number`.
|
|
110
|
+
- Any floating point type - returns a `Napi::Number`.
|
|
111
|
+
- `const char*` (encoded using UTF-8, null-terminated) - returns a
|
|
112
|
+
`Napi::String`.
|
|
113
|
+
- `const char16_t*` (encoded using UTF-16-LE, null-terminated) - returns a
|
|
114
|
+
`Napi::String`.
|
|
115
|
+
- `std::string` (encoded using UTF-8) - returns a `Napi::String`.
|
|
116
|
+
- `std::u16string` - returns a `Napi::String`.
|
|
117
|
+
- `Napi::Value` - returns a `Napi::Value`.
|
|
118
|
+
- `Napi_value` - returns a `Napi::Value`.
|
|
119
|
+
|
|
120
|
+
### IsArray
|
|
121
|
+
|
|
122
|
+
```cpp
|
|
123
|
+
bool Napi::Value::IsArray() const;
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Returns `true` if the underlying value is a JavaScript `Napi::Array` or `false`
|
|
127
|
+
otherwise.
|
|
128
|
+
|
|
129
|
+
### IsArrayBuffer
|
|
130
|
+
|
|
131
|
+
```cpp
|
|
132
|
+
bool Napi::Value::IsArrayBuffer() const;
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Returns `true` if the underlying value is a JavaScript `Napi::ArrayBuffer` or
|
|
136
|
+
`false` otherwise.
|
|
137
|
+
|
|
138
|
+
### IsBoolean
|
|
139
|
+
|
|
140
|
+
```cpp
|
|
141
|
+
bool Napi::Value::IsBoolean() const;
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Returns `true` if the underlying value is a JavaScript `true` or JavaScript
|
|
145
|
+
`false`, or `false` if the value is not a `Napi::Boolean` value in JavaScript.
|
|
146
|
+
|
|
147
|
+
### IsBuffer
|
|
148
|
+
|
|
149
|
+
```cpp
|
|
150
|
+
bool Napi::Value::IsBuffer() const;
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Returns `true` if the underlying value is a Node.js `Napi::Buffer` or `false`
|
|
154
|
+
otherwise.
|
|
155
|
+
|
|
156
|
+
### IsDataView
|
|
157
|
+
```cpp
|
|
158
|
+
bool Napi::Value::IsDataView() const;
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Returns `true` if the underlying value is a JavaScript `Napi::DataView` or
|
|
162
|
+
`false` otherwise.
|
|
163
|
+
|
|
164
|
+
### IsDate
|
|
165
|
+
|
|
166
|
+
```cpp
|
|
167
|
+
bool Napi::Value::IsDate() const;
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Returns `true` if the underlying value is a JavaScript `Date` or `false`
|
|
171
|
+
otherwise.
|
|
172
|
+
|
|
173
|
+
### IsEmpty
|
|
174
|
+
|
|
175
|
+
```cpp
|
|
176
|
+
bool Napi::Value::IsEmpty() const;
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Returns `true` if the value is uninitialized.
|
|
180
|
+
|
|
181
|
+
An empty `Napi::Value` is invalid, and most attempts to perform an operation on
|
|
182
|
+
an empty `Napi::Value` will result in an exception. An empty `Napi::Value` is
|
|
183
|
+
distinct from JavaScript `null` or `undefined`, which are valid values.
|
|
184
|
+
|
|
185
|
+
When C++ exceptions are disabled at compile time, a method with a `Napi::Value`
|
|
186
|
+
return type may return an empty `Napi::Value` to indicate a pending exception.
|
|
187
|
+
Thus, when C++ exceptions are not being used, callers should check the result of
|
|
188
|
+
`Env::IsExceptionPending` before attempting to use the value.
|
|
189
|
+
|
|
190
|
+
### IsExternal
|
|
191
|
+
```cpp
|
|
192
|
+
bool Napi::Value::IsExternal() const;
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Returns `true` if the underlying value is a Node-API external object or `false`
|
|
196
|
+
otherwise.
|
|
197
|
+
|
|
198
|
+
### IsFunction
|
|
199
|
+
|
|
200
|
+
```cpp
|
|
201
|
+
bool Napi::Value::IsFunction() const;
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Returns `true` if the underlying value is a JavaScript `Napi::Function` or
|
|
205
|
+
`false` otherwise.
|
|
206
|
+
|
|
207
|
+
### IsNull
|
|
208
|
+
|
|
209
|
+
```cpp
|
|
210
|
+
bool Napi::Value::IsNull() const;
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Returns `true` if the underlying value is a JavaScript `null` or `false`
|
|
214
|
+
otherwise.
|
|
215
|
+
|
|
216
|
+
### IsNumber
|
|
217
|
+
|
|
218
|
+
```cpp
|
|
219
|
+
bool Napi::Value::IsNumber() const;
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Returns `true` if the underlying value is a JavaScript `Napi::Number` or `false`
|
|
223
|
+
otherwise.
|
|
224
|
+
|
|
225
|
+
### IsObject
|
|
226
|
+
|
|
227
|
+
```cpp
|
|
228
|
+
bool Napi::Value::IsObject() const;
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Returns `true` if the underlying value is a JavaScript `Napi::Object` or `false`
|
|
232
|
+
otherwise.
|
|
233
|
+
|
|
234
|
+
### IsPromise
|
|
235
|
+
|
|
236
|
+
```cpp
|
|
237
|
+
bool Napi::Value::IsPromise() const;
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Returns `true` if the underlying value is a JavaScript `Napi::Promise` or
|
|
241
|
+
`false` otherwise.
|
|
242
|
+
|
|
243
|
+
### IsString
|
|
244
|
+
|
|
245
|
+
```cpp
|
|
246
|
+
bool Napi::Value::IsString() const;
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Returns `true` if the underlying value is a JavaScript `Napi::String` or `false`
|
|
250
|
+
otherwise.
|
|
251
|
+
|
|
252
|
+
### IsSymbol
|
|
253
|
+
|
|
254
|
+
```cpp
|
|
255
|
+
bool Napi::Value::IsSymbol() const;
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Returns `true` if the underlying value is a JavaScript `Napi::Symbol` or `false`
|
|
259
|
+
otherwise.
|
|
260
|
+
|
|
261
|
+
### IsTypedArray
|
|
262
|
+
|
|
263
|
+
```cpp
|
|
264
|
+
bool Napi::Value::IsTypedArray() const;
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Returns `true` if the underlying value is a JavaScript `Napi::TypedArray` or
|
|
268
|
+
`false` otherwise.
|
|
269
|
+
|
|
270
|
+
### IsUndefined
|
|
271
|
+
|
|
272
|
+
```cpp
|
|
273
|
+
bool Napi::Value::IsUndefined() const;
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Returns `true` if the underlying value is a JavaScript `undefined` or `false`
|
|
277
|
+
otherwise.
|
|
278
|
+
|
|
279
|
+
### StrictEquals
|
|
280
|
+
|
|
281
|
+
```cpp
|
|
282
|
+
bool Napi::Value::StrictEquals(const Napi::Value& other) const;
|
|
283
|
+
```
|
|
284
|
+
- `[in] other`: The `Napi::Value` object to be compared.
|
|
285
|
+
|
|
286
|
+
Returns a `bool` indicating if this `Napi::Value` strictly equals another
|
|
287
|
+
`Napi::Value`.
|
|
288
|
+
|
|
289
|
+
### ToBoolean
|
|
290
|
+
|
|
291
|
+
```cpp
|
|
292
|
+
Napi::Boolean Napi::Value::ToBoolean() const;
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
Returns a `Napi::Boolean` representing the `Napi::Value`.
|
|
296
|
+
|
|
297
|
+
This is a wrapper around `napi_coerce_to_boolean`. This will throw a JavaScript
|
|
298
|
+
exception if the coercion fails. If C++ exceptions are not being used, callers
|
|
299
|
+
should check the result of `Env::IsExceptionPending` before attempting to use
|
|
300
|
+
the returned value.
|
|
301
|
+
|
|
302
|
+
### ToNumber
|
|
303
|
+
|
|
304
|
+
```cpp
|
|
305
|
+
Napi::Number Napi::Value::ToNumber() const;
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
Returns the `Napi::Value` coerced to a JavaScript number.
|
|
309
|
+
|
|
310
|
+
### ToObject
|
|
311
|
+
|
|
312
|
+
```cpp
|
|
313
|
+
Napi::Object Napi::Value::ToObject() const;
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
Returns the `Napi::Value` coerced to a JavaScript object.
|
|
317
|
+
|
|
318
|
+
### ToString
|
|
319
|
+
|
|
320
|
+
```cpp
|
|
321
|
+
Napi::String Napi::Value::ToString() const;
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Returns the `Napi::Value` coerced to a JavaScript string.
|
|
325
|
+
|
|
326
|
+
### Type
|
|
327
|
+
|
|
328
|
+
```cpp
|
|
329
|
+
napi_valuetype Napi::Value::Type() const;
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
Returns the `napi_valuetype` type of the `Napi::Value`.
|
|
333
|
+
|
|
334
|
+
[`Napi::Boolean`]: ./boolean.md
|
|
335
|
+
[`Napi::BigInt`]: ./bigint.md
|
|
336
|
+
[`Napi::Date`]: ./date.md
|
|
337
|
+
[`Napi::External`]: ./external.md
|
|
338
|
+
[`Napi::Name`]: ./name.md
|
|
339
|
+
[`Napi::Number`]: ./number.md
|
|
340
|
+
[`Napi::Object`]: ./object.md
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# VersionManagement
|
|
2
|
+
|
|
3
|
+
The `Napi::VersionManagement` class contains methods that allow information
|
|
4
|
+
to be retrieved about the version of Node-API and Node.js. In some cases it is
|
|
5
|
+
important to make decisions based on different versions of the system.
|
|
6
|
+
|
|
7
|
+
## Methods
|
|
8
|
+
|
|
9
|
+
### GetNapiVersion
|
|
10
|
+
|
|
11
|
+
Retrieves the highest Node-API version supported by Node.js runtime.
|
|
12
|
+
|
|
13
|
+
```cpp
|
|
14
|
+
static uint32_t Napi::VersionManagement::GetNapiVersion(Env env);
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
- `[in] env`: The environment in which the API is invoked under.
|
|
18
|
+
|
|
19
|
+
Returns the highest Node-API version supported by Node.js runtime.
|
|
20
|
+
|
|
21
|
+
### GetNodeVersion
|
|
22
|
+
|
|
23
|
+
Retrieves information about Node.js version present on the system. All the
|
|
24
|
+
information is stored in the `napi_node_version` structure that is defined as
|
|
25
|
+
shown below:
|
|
26
|
+
|
|
27
|
+
```cpp
|
|
28
|
+
typedef struct {
|
|
29
|
+
uint32_t major;
|
|
30
|
+
uint32_t minor;
|
|
31
|
+
uint32_t patch;
|
|
32
|
+
const char* release;
|
|
33
|
+
} napi_node_version;
|
|
34
|
+
````
|
|
35
|
+
|
|
36
|
+
```cpp
|
|
37
|
+
static const napi_node_version* Napi::VersionManagement::GetNodeVersion(Env env);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- `[in] env`: The environment in which the API is invoked under.
|
|
41
|
+
|
|
42
|
+
Returns the structure a pointer to the structure `napi_node_version` populated by
|
|
43
|
+
the version information of Node.js runtime.
|