koffi 0.9.0 → 0.9.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 +2 -36
- package/package.json +8 -4
- package/vendor/dragonbox/CMakeLists.txt +123 -0
- package/vendor/dragonbox/LICENSE-Apache2-LLVM +218 -0
- package/vendor/dragonbox/LICENSE-Boost +23 -0
- package/vendor/dragonbox/README.md +277 -0
- package/vendor/dragonbox/cmake/dragonboxConfig.cmake +1 -0
- package/vendor/dragonbox/include/dragonbox/dragonbox.h +2670 -0
- package/vendor/dragonbox/include/dragonbox/dragonbox_to_chars.h +108 -0
- package/vendor/dragonbox/other_files/Dragonbox.pdf +0 -0
- package/vendor/dragonbox/other_files/Dragonbox_old.pdf +0 -0
- package/vendor/dragonbox/other_files/milo_benchmark.png +0 -0
- package/vendor/dragonbox/other_files/unknown_win64_vc2019.html +540 -0
- package/vendor/dragonbox/other_files/unknown_win64_vc2019_randomdigit_time.png +0 -0
- package/vendor/dragonbox/source/dragonbox_to_chars.cpp +303 -0
- package/vendor/dragonbox/subproject/3rdparty/grisu_exact/CMakeLists.txt +24 -0
- package/vendor/dragonbox/subproject/3rdparty/grisu_exact/fp_to_chars.cpp +238 -0
- package/vendor/dragonbox/subproject/3rdparty/grisu_exact/fp_to_chars.h +95 -0
- package/vendor/dragonbox/subproject/3rdparty/grisu_exact/grisu_exact.h +2666 -0
- package/vendor/dragonbox/subproject/3rdparty/ryu/CMakeLists.txt +16 -0
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/common.h +114 -0
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/d2s.c +509 -0
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/d2s_full_table.h +367 -0
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/d2s_intrinsics.h +357 -0
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/digit_table.h +35 -0
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/f2s.c +345 -0
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/f2s_full_table.h +55 -0
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/f2s_intrinsics.h +128 -0
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/ryu.h +46 -0
- package/vendor/dragonbox/subproject/3rdparty/schubfach/CMakeLists.txt +22 -0
- package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_32.cc +699 -0
- package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_32.h +31 -0
- package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_64.cc +1354 -0
- package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_64.h +31 -0
- package/vendor/dragonbox/subproject/3rdparty/shaded_plots/example_shaded_plots.m +68 -0
- package/vendor/dragonbox/subproject/3rdparty/shaded_plots/license.txt +25 -0
- package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_distribution.m +92 -0
- package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_distribution_prctile.m +121 -0
- package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_histogram_shaded.m +99 -0
- package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_shaded.m +93 -0
- package/vendor/dragonbox/subproject/benchmark/CMakeLists.txt +65 -0
- package/vendor/dragonbox/subproject/benchmark/include/benchmark.h +40 -0
- package/vendor/dragonbox/subproject/benchmark/matlab/plot_benchmarks.m +22 -0
- package/vendor/dragonbox/subproject/benchmark/matlab/plot_digit_benchmark.m +78 -0
- package/vendor/dragonbox/subproject/benchmark/matlab/plot_uniform_benchmark.m +95 -0
- package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary32_clang.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary32_msvc.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary64_clang.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary64_msvc.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary32_clang.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary32_msvc.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary64_clang.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary64_msvc.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/source/benchmark.cpp +238 -0
- package/vendor/dragonbox/subproject/benchmark/source/dragonbox.cpp +30 -0
- package/vendor/dragonbox/subproject/benchmark/source/grisu_exact.cpp +36 -0
- package/vendor/dragonbox/subproject/benchmark/source/ryu.cpp +27 -0
- package/vendor/dragonbox/subproject/benchmark/source/schubfach.cpp +31 -0
- package/vendor/dragonbox/subproject/common/CMakeLists.txt +42 -0
- package/vendor/dragonbox/subproject/common/include/best_rational_approx.h +97 -0
- package/vendor/dragonbox/subproject/common/include/big_uint.h +218 -0
- package/vendor/dragonbox/subproject/common/include/continued_fractions.h +174 -0
- package/vendor/dragonbox/subproject/common/include/good_rational_approx.h +267 -0
- package/vendor/dragonbox/subproject/common/include/random_float.h +182 -0
- package/vendor/dragonbox/subproject/common/include/rational_continued_fractions.h +57 -0
- package/vendor/dragonbox/subproject/common/source/big_uint.cpp +602 -0
- package/vendor/dragonbox/subproject/meta/CMakeLists.txt +41 -0
- package/vendor/dragonbox/subproject/meta/results/binary32_generated_cache.txt +82 -0
- package/vendor/dragonbox/subproject/meta/results/binary64_compressed_cache_error_table.txt +10 -0
- package/vendor/dragonbox/subproject/meta/results/binary64_generated_cache.txt +623 -0
- package/vendor/dragonbox/subproject/meta/source/generate_cache.cpp +126 -0
- package/vendor/dragonbox/subproject/meta/source/live_test.cpp +81 -0
- package/vendor/dragonbox/subproject/meta/source/perf_test.cpp +104 -0
- package/vendor/dragonbox/subproject/meta/source/sandbox.cpp +20 -0
- package/vendor/dragonbox/subproject/test/CMakeLists.txt +70 -0
- package/vendor/dragonbox/subproject/test/results/binary32.csv +255 -0
- package/vendor/dragonbox/subproject/test/results/binary64.csv +2047 -0
- package/vendor/dragonbox/subproject/test/results/plot_required_bits.m +18 -0
- package/vendor/dragonbox/subproject/test/source/test_all_shorter_interval_cases.cpp +88 -0
- package/vendor/dragonbox/subproject/test/source/uniform_random_test.cpp +95 -0
- package/vendor/dragonbox/subproject/test/source/verify_cache_precision.cpp +338 -0
- package/vendor/dragonbox/subproject/test/source/verify_compressed_cache.cpp +154 -0
- package/vendor/dragonbox/subproject/test/source/verify_fast_multiplication.cpp +168 -0
- package/vendor/dragonbox/subproject/test/source/verify_log_computation.cpp +251 -0
- package/vendor/dragonbox/subproject/test/source/verify_magic_division.cpp +113 -0
- package/vendor/libcc/libcc.cc +7651 -0
- package/vendor/libcc/libcc.hh +4312 -0
- package/vendor/node-addon-api/CHANGELOG.md +859 -0
- 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/LICENSE.md +13 -0
- package/vendor/node-addon-api/README.md +293 -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/common.gypi +21 -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 +115 -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 +432 -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 +561 -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/except.gypi +25 -0
- package/vendor/node-addon-api/index.js +11 -0
- package/vendor/node-addon-api/napi-inl.deprecated.h +192 -0
- package/vendor/node-addon-api/napi-inl.h +6209 -0
- package/vendor/node-addon-api/napi.h +2983 -0
- package/vendor/node-addon-api/node_api.gyp +9 -0
- package/vendor/node-addon-api/noexcept.gypi +26 -0
- package/vendor/node-addon-api/nothing.c +0 -0
- package/vendor/node-addon-api/package-support.json +21 -0
- package/vendor/node-addon-api/package.json +399 -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 +21 -0
- package/vendor/node-addon-api/test/async_context.js +86 -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 +171 -0
- package/vendor/node-addon-api/test/binding.gyp +117 -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 +113 -0
- package/vendor/node-addon-api/test/common/test_helper.h +61 -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 +94 -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 +295 -0
- package/vendor/node-addon-api/test/function.js +121 -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 +136 -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 +348 -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 +37 -0
- package/vendor/node-addon-api/test/object/set_property.js +29 -0
- package/vendor/node-addon-api/test/object/subscript_operator.cc +42 -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_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/tools/README.md +73 -0
- package/vendor/node-addon-api/tools/check-napi.js +100 -0
- package/vendor/node-addon-api/tools/clang-format.js +68 -0
- package/vendor/node-addon-api/tools/conversion.js +309 -0
- package/vendor/node-addon-api/tools/eslint-format.js +71 -0
- package/build/ALL_BUILD.vcxproj +0 -190
- package/build/ALL_BUILD.vcxproj.filters +0 -8
- package/build/CMakeCache.txt +0 -429
- package/build/CMakeFiles/3.23.0-rc1/CMakeASMCompiler.cmake +0 -20
- package/build/CMakeFiles/3.23.0-rc1/CMakeASM_MASMCompiler.cmake +0 -20
- package/build/CMakeFiles/3.23.0-rc1/CMakeCCompiler.cmake +0 -72
- package/build/CMakeFiles/3.23.0-rc1/CMakeCXXCompiler.cmake +0 -83
- package/build/CMakeFiles/3.23.0-rc1/CMakeDetermineCompilerABI_C.bin +0 -0
- package/build/CMakeFiles/3.23.0-rc1/CMakeDetermineCompilerABI_CXX.bin +0 -0
- package/build/CMakeFiles/3.23.0-rc1/CMakeRCCompiler.cmake +0 -6
- package/build/CMakeFiles/3.23.0-rc1/CMakeSystem.cmake +0 -15
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdC/CMakeCCompilerId.c +0 -828
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdC/CompilerIdC.exe +0 -0
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdC/CompilerIdC.vcxproj +0 -71
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdC/Debug/CMakeCCompilerId.obj +0 -0
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdC/Debug/CompilerIdC.exe.recipe +0 -11
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdC/Debug/CompilerIdC.tlog/CL.command.1.tlog +0 -0
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdC/Debug/CompilerIdC.tlog/CL.read.1.tlog +0 -0
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdC/Debug/CompilerIdC.tlog/CL.write.1.tlog +0 -0
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdC/Debug/CompilerIdC.tlog/CompilerIdC.lastbuildstate +0 -2
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdC/Debug/CompilerIdC.tlog/link.command.1.tlog +0 -0
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdC/Debug/CompilerIdC.tlog/link.read.1.tlog +0 -0
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdC/Debug/CompilerIdC.tlog/link.write.1.tlog +0 -0
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdCXX/CMakeCXXCompilerId.cpp +0 -816
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdCXX/CompilerIdCXX.exe +0 -0
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdCXX/CompilerIdCXX.vcxproj +0 -71
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdCXX/Debug/CMakeCXXCompilerId.obj +0 -0
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdCXX/Debug/CompilerIdCXX.exe.recipe +0 -11
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.command.1.tlog +0 -0
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.read.1.tlog +0 -0
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.write.1.tlog +0 -0
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CompilerIdCXX.lastbuildstate +0 -2
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.command.1.tlog +0 -0
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.read.1.tlog +0 -0
- package/build/CMakeFiles/3.23.0-rc1/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.write.1.tlog +0 -0
- package/build/CMakeFiles/3.23.0-rc1/VCTargetsPath.txt +0 -1
- package/build/CMakeFiles/3.23.0-rc1/VCTargetsPath.vcxproj +0 -31
- package/build/CMakeFiles/3.23.0-rc1/x64/Debug/VCTargetsPath.recipe +0 -11
- package/build/CMakeFiles/3.23.0-rc1/x64/Debug/VCTargetsPath.tlog/VCTargetsPath.lastbuildstate +0 -2
- package/build/CMakeFiles/41bcd16856091d4a38fd1f71fbe2f202/generate.stamp.rule +0 -1
- package/build/CMakeFiles/CMakeError.log +0 -108
- package/build/CMakeFiles/CMakeOutput.log +0 -413
- package/build/CMakeFiles/TargetDirectories.txt +0 -4
- package/build/CMakeFiles/cmake.check_cache +0 -1
- package/build/CMakeFiles/generate.stamp +0 -1
- package/build/CMakeFiles/generate.stamp.depend +0 -28
- package/build/CMakeFiles/generate.stamp.list +0 -1
- package/build/Raylib.dir/Release/Raylib.dll.recipe +0 -14
- package/build/Raylib.dir/Release/Raylib.tlog/CL.command.1.tlog +0 -0
- package/build/Raylib.dir/Release/Raylib.tlog/CL.read.1.tlog +0 -0
- package/build/Raylib.dir/Release/Raylib.tlog/CL.write.1.tlog +0 -0
- package/build/Raylib.dir/Release/Raylib.tlog/CustomBuild.command.1.tlog +0 -10
- package/build/Raylib.dir/Release/Raylib.tlog/CustomBuild.read.1.tlog +0 -27
- package/build/Raylib.dir/Release/Raylib.tlog/CustomBuild.write.1.tlog +0 -2
- package/build/Raylib.dir/Release/Raylib.tlog/Raylib.lastbuildstate +0 -2
- package/build/Raylib.dir/Release/Raylib.tlog/Raylib.write.1u.tlog +0 -0
- package/build/Raylib.dir/Release/Raylib.tlog/link.command.1.tlog +0 -0
- package/build/Raylib.dir/Release/Raylib.tlog/link.read.1.tlog +0 -0
- package/build/Raylib.dir/Release/Raylib.tlog/link.write.1.tlog +0 -0
- package/build/Raylib.dir/Release/raudio.obj +0 -0
- package/build/Raylib.dir/Release/rcore.obj +0 -0
- package/build/Raylib.dir/Release/rglfw.obj +0 -0
- package/build/Raylib.dir/Release/rmodels.obj +0 -0
- package/build/Raylib.dir/Release/rshapes.obj +0 -0
- package/build/Raylib.dir/Release/rtext.obj +0 -0
- package/build/Raylib.dir/Release/rtextures.obj +0 -0
- package/build/Raylib.dir/Release/utils.obj +0 -0
- package/build/Raylib.vcxproj +0 -358
- package/build/Raylib.vcxproj.filters +0 -37
- package/build/Release/Raylib.dll +0 -0
- package/build/Release/Raylib.exp +0 -0
- package/build/Release/Raylib.lib +0 -0
- package/build/Release/koffi.exp +0 -0
- package/build/Release/koffi.lib +0 -0
- package/build/Release/koffi.node +0 -0
- package/build/ZERO_CHECK.vcxproj +0 -176
- package/build/ZERO_CHECK.vcxproj.filters +0 -13
- package/build/cmake_install.cmake +0 -44
- package/build/koffi.dir/Release/call_arm64.obj +0 -0
- package/build/koffi.dir/Release/call_x64_sysv.obj +0 -0
- package/build/koffi.dir/Release/call_x64_win.obj +0 -0
- package/build/koffi.dir/Release/call_x64_win_fwd.obj +0 -0
- package/build/koffi.dir/Release/call_x86.obj +0 -0
- package/build/koffi.dir/Release/ffi.obj +0 -0
- package/build/koffi.dir/Release/koffi.node.recipe +0 -14
- package/build/koffi.dir/Release/koffi.tlog/CL.command.1.tlog +0 -0
- package/build/koffi.dir/Release/koffi.tlog/CL.read.1.tlog +0 -0
- package/build/koffi.dir/Release/koffi.tlog/CL.write.1.tlog +0 -0
- package/build/koffi.dir/Release/koffi.tlog/CustomBuild.command.1.tlog +0 -10
- package/build/koffi.dir/Release/koffi.tlog/CustomBuild.read.1.tlog +0 -27
- package/build/koffi.dir/Release/koffi.tlog/CustomBuild.write.1.tlog +0 -2
- package/build/koffi.dir/Release/koffi.tlog/Masm.read.1u.tlog +0 -0
- package/build/koffi.dir/Release/koffi.tlog/Masm.write.1u.tlog +0 -0
- package/build/koffi.dir/Release/koffi.tlog/koffi.lastbuildstate +0 -2
- package/build/koffi.dir/Release/koffi.tlog/koffi.write.1u.tlog +0 -0
- package/build/koffi.dir/Release/koffi.tlog/link.command.1.tlog +0 -0
- package/build/koffi.dir/Release/koffi.tlog/link.read.1.tlog +0 -0
- package/build/koffi.dir/Release/koffi.tlog/link.write.1.tlog +0 -0
- package/build/koffi.dir/Release/libcc.obj +0 -0
- package/build/koffi.dir/Release/util.obj +0 -0
- package/build/koffi.dir/Release/win_delay_load_hook.obj +0 -0
- package/build/koffi.sln +0 -67
- package/build/koffi.vcxproj +0 -363
- package/build/koffi.vcxproj.filters +0 -40
- package/build/x64/Release/ALL_BUILD/ALL_BUILD.recipe +0 -20
- package/build/x64/Release/ALL_BUILD/ALL_BUILD.tlog/ALL_BUILD.lastbuildstate +0 -2
- package/build/x64/Release/ALL_BUILD/ALL_BUILD.tlog/CustomBuild.command.1.tlog +0 -10
- package/build/x64/Release/ALL_BUILD/ALL_BUILD.tlog/CustomBuild.read.1.tlog +0 -27
- package/build/x64/Release/ALL_BUILD/ALL_BUILD.tlog/CustomBuild.write.1.tlog +0 -2
- package/build/x64/Release/ZERO_CHECK/ZERO_CHECK.recipe +0 -11
- package/build/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.command.1.tlog +0 -10
- package/build/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.read.1.tlog +0 -28
- package/build/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.write.1.tlog +0 -2
- package/build/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/ZERO_CHECK.lastbuildstate +0 -2
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#include "napi.h"
|
|
2
|
+
|
|
3
|
+
using namespace Napi;
|
|
4
|
+
|
|
5
|
+
#if (NAPI_VERSION > 2)
|
|
6
|
+
namespace {
|
|
7
|
+
|
|
8
|
+
static void RunInCallbackScope(const CallbackInfo& info) {
|
|
9
|
+
Function callback = info[0].As<Function>();
|
|
10
|
+
AsyncContext context(info.Env(), "callback_scope_test");
|
|
11
|
+
CallbackScope scope(info.Env(), context);
|
|
12
|
+
callback.Call({});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
} // end anonymous namespace
|
|
16
|
+
|
|
17
|
+
Object InitCallbackScope(Env env) {
|
|
18
|
+
Object exports = Object::New(env);
|
|
19
|
+
exports["runInCallbackScope"] = Function::New(env, RunInCallbackScope);
|
|
20
|
+
return exports;
|
|
21
|
+
}
|
|
22
|
+
#endif
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const assert = require('assert');
|
|
3
|
+
|
|
4
|
+
// we only check async hooks on 8.x an higher were
|
|
5
|
+
// they are closer to working properly
|
|
6
|
+
const nodeVersion = process.versions.node.split('.')[0]
|
|
7
|
+
let async_hooks = undefined;
|
|
8
|
+
function checkAsyncHooks() {
|
|
9
|
+
if (nodeVersion >= 8) {
|
|
10
|
+
if (async_hooks == undefined) {
|
|
11
|
+
async_hooks = require('async_hooks');
|
|
12
|
+
}
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = require('./common').runTest(test);
|
|
19
|
+
|
|
20
|
+
function test(binding) {
|
|
21
|
+
if (!checkAsyncHooks())
|
|
22
|
+
return;
|
|
23
|
+
|
|
24
|
+
let id;
|
|
25
|
+
let insideHook = false;
|
|
26
|
+
const hook = async_hooks.createHook({
|
|
27
|
+
init(asyncId, type, triggerAsyncId, resource) {
|
|
28
|
+
if (id === undefined && type === 'callback_scope_test') {
|
|
29
|
+
id = asyncId;
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
before(asyncId) {
|
|
33
|
+
if (asyncId === id)
|
|
34
|
+
insideHook = true;
|
|
35
|
+
},
|
|
36
|
+
after(asyncId) {
|
|
37
|
+
if (asyncId === id)
|
|
38
|
+
insideHook = false;
|
|
39
|
+
}
|
|
40
|
+
}).enable();
|
|
41
|
+
|
|
42
|
+
return new Promise(resolve => {
|
|
43
|
+
binding.callbackscope.runInCallbackScope(function() {
|
|
44
|
+
assert(insideHook);
|
|
45
|
+
hook.disable();
|
|
46
|
+
resolve();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/* Test helpers ported from test/common/index.js in Node.js project. */
|
|
2
|
+
'use strict';
|
|
3
|
+
const assert = require('assert');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const noop = () => {};
|
|
7
|
+
|
|
8
|
+
const mustCallChecks = [];
|
|
9
|
+
|
|
10
|
+
function runCallChecks(exitCode) {
|
|
11
|
+
if (exitCode !== 0) return;
|
|
12
|
+
|
|
13
|
+
const failed = mustCallChecks.filter(function(context) {
|
|
14
|
+
if ('minimum' in context) {
|
|
15
|
+
context.messageSegment = `at least ${context.minimum}`;
|
|
16
|
+
return context.actual < context.minimum;
|
|
17
|
+
} else {
|
|
18
|
+
context.messageSegment = `exactly ${context.exact}`;
|
|
19
|
+
return context.actual !== context.exact;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
failed.forEach(function(context) {
|
|
24
|
+
console.log('Mismatched %s function calls. Expected %s, actual %d.',
|
|
25
|
+
context.name,
|
|
26
|
+
context.messageSegment,
|
|
27
|
+
context.actual);
|
|
28
|
+
console.log(context.stack.split('\n').slice(2).join('\n'));
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
if (failed.length) process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.mustCall = function(fn, exact) {
|
|
35
|
+
return _mustCallInner(fn, exact, 'exact');
|
|
36
|
+
};
|
|
37
|
+
exports.mustCallAtLeast = function(fn, minimum) {
|
|
38
|
+
return _mustCallInner(fn, minimum, 'minimum');
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
function _mustCallInner(fn, criteria, field) {
|
|
42
|
+
if (typeof fn === 'number') {
|
|
43
|
+
criteria = fn;
|
|
44
|
+
fn = noop;
|
|
45
|
+
} else if (fn === undefined) {
|
|
46
|
+
fn = noop;
|
|
47
|
+
}
|
|
48
|
+
if (criteria === undefined) {
|
|
49
|
+
criteria = 1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (typeof criteria !== 'number')
|
|
53
|
+
throw new TypeError(`Invalid ${field} value: ${criteria}`);
|
|
54
|
+
|
|
55
|
+
const context = {
|
|
56
|
+
[field]: criteria,
|
|
57
|
+
actual: 0,
|
|
58
|
+
stack: (new Error()).stack,
|
|
59
|
+
name: fn.name || '<anonymous>'
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// add the exit listener only once to avoid listener leak warnings
|
|
63
|
+
if (mustCallChecks.length === 0) process.on('exit', runCallChecks);
|
|
64
|
+
|
|
65
|
+
mustCallChecks.push(context);
|
|
66
|
+
|
|
67
|
+
return function() {
|
|
68
|
+
context.actual++;
|
|
69
|
+
return fn.apply(this, arguments);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
exports.mustNotCall = function(msg) {
|
|
74
|
+
return function mustNotCall() {
|
|
75
|
+
assert.fail(msg || 'function should not have been called');
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
exports.runTest = async function(test, buildType, buildPathRoot = process.env.REL_BUILD_PATH || '') {
|
|
80
|
+
buildType = buildType || process.config.target_defaults.default_configuration || 'Release';
|
|
81
|
+
|
|
82
|
+
const bindings = [
|
|
83
|
+
path.join(buildPathRoot, `../build/${buildType}/binding.node`),
|
|
84
|
+
path.join(buildPathRoot, `../build/${buildType}/binding_noexcept.node`),
|
|
85
|
+
path.join(buildPathRoot, `../build/${buildType}/binding_noexcept_maybe.node`),
|
|
86
|
+
].map(it => require.resolve(it));
|
|
87
|
+
|
|
88
|
+
for (const item of bindings) {
|
|
89
|
+
await Promise.resolve(test(require(item)))
|
|
90
|
+
.finally(exports.mustCall());
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
exports.runTestWithBindingPath = async function(test, buildType, buildPathRoot = process.env.REL_BUILD_PATH || '') {
|
|
95
|
+
buildType = buildType || process.config.target_defaults.default_configuration || 'Release';
|
|
96
|
+
|
|
97
|
+
const bindings = [
|
|
98
|
+
path.join(buildPathRoot, `../build/${buildType}/binding.node`),
|
|
99
|
+
path.join(buildPathRoot, `../build/${buildType}/binding_noexcept.node`),
|
|
100
|
+
path.join(buildPathRoot, `../build/${buildType}/binding_noexcept_maybe.node`),
|
|
101
|
+
].map(it => require.resolve(it));
|
|
102
|
+
|
|
103
|
+
for (const item of bindings) {
|
|
104
|
+
await test(item);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
exports.runTestWithBuildType = async function(test, buildType) {
|
|
109
|
+
buildType = buildType || process.config.target_defaults.default_configuration || 'Release';
|
|
110
|
+
|
|
111
|
+
await Promise.resolve(test(buildType))
|
|
112
|
+
.finally(exports.mustCall());
|
|
113
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#include "napi.h"
|
|
3
|
+
|
|
4
|
+
namespace Napi {
|
|
5
|
+
|
|
6
|
+
// Use this when a variable or parameter is unused in order to explicitly
|
|
7
|
+
// silence a compiler warning about that.
|
|
8
|
+
template <typename T>
|
|
9
|
+
inline void USE(T&&) {}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A test helper that converts MaybeOrValue<T> to T by checking that
|
|
13
|
+
* MaybeOrValue is NOT an empty Maybe when NODE_ADDON_API_ENABLE_MAYBE is
|
|
14
|
+
* defined.
|
|
15
|
+
*
|
|
16
|
+
* Do nothing when NODE_ADDON_API_ENABLE_MAYBE is not defined.
|
|
17
|
+
*/
|
|
18
|
+
template <typename T>
|
|
19
|
+
inline T MaybeUnwrap(MaybeOrValue<T> maybe) {
|
|
20
|
+
#if defined(NODE_ADDON_API_ENABLE_MAYBE)
|
|
21
|
+
return maybe.Unwrap();
|
|
22
|
+
#else
|
|
23
|
+
return maybe;
|
|
24
|
+
#endif
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A test helper that converts MaybeOrValue<T> to T by getting the value that
|
|
29
|
+
* wrapped by the Maybe or return the default_value if the Maybe is empty when
|
|
30
|
+
* NODE_ADDON_API_ENABLE_MAYBE is defined.
|
|
31
|
+
*
|
|
32
|
+
* Do nothing when NODE_ADDON_API_ENABLE_MAYBE is not defined.
|
|
33
|
+
*/
|
|
34
|
+
template <typename T>
|
|
35
|
+
inline T MaybeUnwrapOr(MaybeOrValue<T> maybe, const T& default_value) {
|
|
36
|
+
#if defined(NODE_ADDON_API_ENABLE_MAYBE)
|
|
37
|
+
return maybe.UnwrapOr(default_value);
|
|
38
|
+
#else
|
|
39
|
+
USE(default_value);
|
|
40
|
+
return maybe;
|
|
41
|
+
#endif
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A test helper that converts MaybeOrValue<T> to T by getting the value that
|
|
46
|
+
* wrapped by the Maybe or return false if the Maybe is empty when
|
|
47
|
+
* NODE_ADDON_API_ENABLE_MAYBE is defined.
|
|
48
|
+
*
|
|
49
|
+
* Copying the value to out when NODE_ADDON_API_ENABLE_MAYBE is not defined.
|
|
50
|
+
*/
|
|
51
|
+
template <typename T>
|
|
52
|
+
inline bool MaybeUnwrapTo(MaybeOrValue<T> maybe, T* out) {
|
|
53
|
+
#if defined(NODE_ADDON_API_ENABLE_MAYBE)
|
|
54
|
+
return maybe.UnwrapTo(out);
|
|
55
|
+
#else
|
|
56
|
+
*out = maybe;
|
|
57
|
+
return true;
|
|
58
|
+
#endif
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
} // namespace Napi
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#include "napi.h"
|
|
2
|
+
|
|
3
|
+
using namespace Napi;
|
|
4
|
+
|
|
5
|
+
static Value CreateDataView1(const CallbackInfo& info) {
|
|
6
|
+
ArrayBuffer arrayBuffer = info[0].As<ArrayBuffer>();
|
|
7
|
+
return DataView::New(info.Env(), arrayBuffer);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
static Value CreateDataView2(const CallbackInfo& info) {
|
|
11
|
+
ArrayBuffer arrayBuffer = info[0].As<ArrayBuffer>();
|
|
12
|
+
size_t byteOffset = info[1].As<Number>().Uint32Value();
|
|
13
|
+
return DataView::New(info.Env(), arrayBuffer, byteOffset);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static Value CreateDataView3(const CallbackInfo& info) {
|
|
17
|
+
ArrayBuffer arrayBuffer = info[0].As<ArrayBuffer>();
|
|
18
|
+
size_t byteOffset = info[1].As<Number>().Uint32Value();
|
|
19
|
+
size_t byteLength = info[2].As<Number>().Uint32Value();
|
|
20
|
+
return DataView::New(info.Env(), arrayBuffer, byteOffset, byteLength);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static Value GetArrayBuffer(const CallbackInfo& info) {
|
|
24
|
+
return info[0].As<DataView>().ArrayBuffer();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static Value GetByteOffset(const CallbackInfo& info) {
|
|
28
|
+
return Number::New(info.Env(),
|
|
29
|
+
static_cast<double>(info[0].As<DataView>().ByteOffset()));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static Value GetByteLength(const CallbackInfo& info) {
|
|
33
|
+
return Number::New(info.Env(),
|
|
34
|
+
static_cast<double>(info[0].As<DataView>().ByteLength()));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
Object InitDataView(Env env) {
|
|
38
|
+
Object exports = Object::New(env);
|
|
39
|
+
|
|
40
|
+
exports["createDataView1"] = Function::New(env, CreateDataView1);
|
|
41
|
+
exports["createDataView2"] = Function::New(env, CreateDataView2);
|
|
42
|
+
exports["createDataView3"] = Function::New(env, CreateDataView3);
|
|
43
|
+
exports["getArrayBuffer"] = Function::New(env, GetArrayBuffer);
|
|
44
|
+
exports["getByteOffset"] = Function::New(env, GetByteOffset);
|
|
45
|
+
exports["getByteLength"] = Function::New(env, GetByteLength);
|
|
46
|
+
|
|
47
|
+
return exports;
|
|
48
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('assert');
|
|
4
|
+
module.exports = require('../common').runTest(test);
|
|
5
|
+
|
|
6
|
+
function test(binding) {
|
|
7
|
+
function testDataViewCreation(factory, arrayBuffer, offset, length) {
|
|
8
|
+
const view = factory(arrayBuffer, offset, length);
|
|
9
|
+
offset = offset ? offset : 0;
|
|
10
|
+
assert.ok(dataview.getArrayBuffer(view) instanceof ArrayBuffer);
|
|
11
|
+
assert.strictEqual(dataview.getArrayBuffer(view), arrayBuffer);
|
|
12
|
+
assert.strictEqual(dataview.getByteOffset(view), offset);
|
|
13
|
+
assert.strictEqual(dataview.getByteLength(view),
|
|
14
|
+
length ? length : arrayBuffer.byteLength - offset);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function testInvalidRange(factory, arrayBuffer, offset, length) {
|
|
18
|
+
assert.throws(() => {
|
|
19
|
+
factory(arrayBuffer, offset, length);
|
|
20
|
+
}, RangeError);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const dataview = binding.dataview;
|
|
24
|
+
const arrayBuffer = new ArrayBuffer(10);
|
|
25
|
+
|
|
26
|
+
testDataViewCreation(dataview.createDataView1, arrayBuffer);
|
|
27
|
+
testDataViewCreation(dataview.createDataView2, arrayBuffer, 2);
|
|
28
|
+
testDataViewCreation(dataview.createDataView2, arrayBuffer, 10);
|
|
29
|
+
testDataViewCreation(dataview.createDataView3, arrayBuffer, 2, 4);
|
|
30
|
+
testDataViewCreation(dataview.createDataView3, arrayBuffer, 10, 0);
|
|
31
|
+
|
|
32
|
+
testInvalidRange(dataview.createDataView2, arrayBuffer, 11);
|
|
33
|
+
testInvalidRange(dataview.createDataView3, arrayBuffer, 11, 0);
|
|
34
|
+
testInvalidRange(dataview.createDataView3, arrayBuffer, 6, 5);
|
|
35
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#include "napi.h"
|
|
2
|
+
|
|
3
|
+
using namespace Napi;
|
|
4
|
+
|
|
5
|
+
static Value GetFloat32(const CallbackInfo& info) {
|
|
6
|
+
size_t byteOffset = info[1].As<Number>().Uint32Value();
|
|
7
|
+
return Number::New(info.Env(), info[0].As<DataView>().GetFloat32(byteOffset));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
static Value GetFloat64(const CallbackInfo& info) {
|
|
11
|
+
size_t byteOffset = info[1].As<Number>().Uint32Value();
|
|
12
|
+
return Number::New(info.Env(), info[0].As<DataView>().GetFloat64(byteOffset));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static Value GetInt8(const CallbackInfo& info) {
|
|
16
|
+
size_t byteOffset = info[1].As<Number>().Uint32Value();
|
|
17
|
+
return Number::New(info.Env(), info[0].As<DataView>().GetInt8(byteOffset));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static Value GetInt16(const CallbackInfo& info) {
|
|
21
|
+
size_t byteOffset = info[1].As<Number>().Uint32Value();
|
|
22
|
+
return Number::New(info.Env(), info[0].As<DataView>().GetInt16(byteOffset));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static Value GetInt32(const CallbackInfo& info) {
|
|
26
|
+
size_t byteOffset = info[1].As<Number>().Uint32Value();
|
|
27
|
+
return Number::New(info.Env(), info[0].As<DataView>().GetInt32(byteOffset));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static Value GetUint8(const CallbackInfo& info) {
|
|
31
|
+
size_t byteOffset = info[1].As<Number>().Uint32Value();
|
|
32
|
+
return Number::New(info.Env(), info[0].As<DataView>().GetUint8(byteOffset));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static Value GetUint16(const CallbackInfo& info) {
|
|
36
|
+
size_t byteOffset = info[1].As<Number>().Uint32Value();
|
|
37
|
+
return Number::New(info.Env(), info[0].As<DataView>().GetUint16(byteOffset));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static Value GetUint32(const CallbackInfo& info) {
|
|
41
|
+
size_t byteOffset = info[1].As<Number>().Uint32Value();
|
|
42
|
+
return Number::New(info.Env(), info[0].As<DataView>().GetUint32(byteOffset));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static void SetFloat32(const CallbackInfo& info) {
|
|
46
|
+
size_t byteOffset = info[1].As<Number>().Uint32Value();
|
|
47
|
+
auto value = info[2].As<Number>().FloatValue();
|
|
48
|
+
info[0].As<DataView>().SetFloat32(byteOffset, value);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static void SetFloat64(const CallbackInfo& info) {
|
|
52
|
+
size_t byteOffset = info[1].As<Number>().Uint32Value();
|
|
53
|
+
auto value = info[2].As<Number>().DoubleValue();
|
|
54
|
+
info[0].As<DataView>().SetFloat64(byteOffset, value);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static void SetInt8(const CallbackInfo& info) {
|
|
58
|
+
size_t byteOffset = info[1].As<Number>().Uint32Value();
|
|
59
|
+
auto value = info[2].As<Number>().Int32Value();
|
|
60
|
+
info[0].As<DataView>().SetInt8(byteOffset, value);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static void SetInt16(const CallbackInfo& info) {
|
|
64
|
+
size_t byteOffset = info[1].As<Number>().Uint32Value();
|
|
65
|
+
auto value = info[2].As<Number>().Int32Value();
|
|
66
|
+
info[0].As<DataView>().SetInt16(byteOffset, value);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static void SetInt32(const CallbackInfo& info) {
|
|
70
|
+
size_t byteOffset = info[1].As<Number>().Uint32Value();
|
|
71
|
+
auto value = info[2].As<Number>().Int32Value();
|
|
72
|
+
info[0].As<DataView>().SetInt32(byteOffset, value);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static void SetUint8(const CallbackInfo& info) {
|
|
76
|
+
size_t byteOffset = info[1].As<Number>().Uint32Value();
|
|
77
|
+
auto value = info[2].As<Number>().Uint32Value();
|
|
78
|
+
info[0].As<DataView>().SetUint8(byteOffset, value);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static void SetUint16(const CallbackInfo& info) {
|
|
82
|
+
size_t byteOffset = info[1].As<Number>().Uint32Value();
|
|
83
|
+
auto value = info[2].As<Number>().Uint32Value();
|
|
84
|
+
info[0].As<DataView>().SetUint16(byteOffset, value);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static void SetUint32(const CallbackInfo& info) {
|
|
88
|
+
size_t byteOffset = info[1].As<Number>().Uint32Value();
|
|
89
|
+
auto value = info[2].As<Number>().Uint32Value();
|
|
90
|
+
info[0].As<DataView>().SetUint32(byteOffset, value);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
Object InitDataViewReadWrite(Env env) {
|
|
94
|
+
Object exports = Object::New(env);
|
|
95
|
+
|
|
96
|
+
exports["getFloat32"] = Function::New(env, GetFloat32);
|
|
97
|
+
exports["getFloat64"] = Function::New(env, GetFloat64);
|
|
98
|
+
exports["getInt8"] = Function::New(env, GetInt8);
|
|
99
|
+
exports["getInt16"] = Function::New(env, GetInt16);
|
|
100
|
+
exports["getInt32"] = Function::New(env, GetInt32);
|
|
101
|
+
exports["getUint8"] = Function::New(env, GetUint8);
|
|
102
|
+
exports["getUint16"] = Function::New(env, GetUint16);
|
|
103
|
+
exports["getUint32"] = Function::New(env, GetUint32);
|
|
104
|
+
|
|
105
|
+
exports["setFloat32"] = Function::New(env, SetFloat32);
|
|
106
|
+
exports["setFloat64"] = Function::New(env, SetFloat64);
|
|
107
|
+
exports["setInt8"] = Function::New(env, SetInt8);
|
|
108
|
+
exports["setInt16"] = Function::New(env, SetInt16);
|
|
109
|
+
exports["setInt32"] = Function::New(env, SetInt32);
|
|
110
|
+
exports["setUint8"] = Function::New(env, SetUint8);
|
|
111
|
+
exports["setUint16"] = Function::New(env, SetUint16);
|
|
112
|
+
exports["setUint32"] = Function::New(env, SetUint32);
|
|
113
|
+
|
|
114
|
+
return exports;
|
|
115
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('assert');
|
|
4
|
+
|
|
5
|
+
module.exports = require('../common').runTest(test);
|
|
6
|
+
|
|
7
|
+
function test(binding) {
|
|
8
|
+
function expected(type, value) {
|
|
9
|
+
return eval(`(new ${type}Array([${value}]))[0]`);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function nativeReadDataView(dataview, type, offset, value) {
|
|
13
|
+
return eval(`binding.dataview_read_write.get${type}(dataview, offset)`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function nativeWriteDataView(dataview, type, offset, value) {
|
|
17
|
+
eval(`binding.dataview_read_write.set${type}(dataview, offset, value)`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function isLittleEndian() {
|
|
21
|
+
const buffer = new ArrayBuffer(2);
|
|
22
|
+
new DataView(buffer).setInt16(0, 256, true /* littleEndian */);
|
|
23
|
+
return new Int16Array(buffer)[0] === 256;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function jsReadDataView(dataview, type, offset, value) {
|
|
27
|
+
return eval(`dataview.get${type}(offset, isLittleEndian())`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function jsWriteDataView(dataview, type, offset, value) {
|
|
31
|
+
eval(`dataview.set${type}(offset, value, isLittleEndian())`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function testReadData(dataview, type, offset, value) {
|
|
35
|
+
jsWriteDataView(dataview, type, offset, 0);
|
|
36
|
+
assert.strictEqual(jsReadDataView(dataview, type, offset), 0);
|
|
37
|
+
|
|
38
|
+
jsWriteDataView(dataview, type, offset, value);
|
|
39
|
+
assert.strictEqual(
|
|
40
|
+
nativeReadDataView(dataview, type, offset), expected(type, value));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function testWriteData(dataview, type, offset, value) {
|
|
44
|
+
jsWriteDataView(dataview, type, offset, 0);
|
|
45
|
+
assert.strictEqual(jsReadDataView(dataview, type, offset), 0);
|
|
46
|
+
|
|
47
|
+
nativeWriteDataView(dataview, type, offset, value);
|
|
48
|
+
assert.strictEqual(
|
|
49
|
+
jsReadDataView(dataview, type, offset), expected(type, value));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function testInvalidOffset(dataview, type, offset, value) {
|
|
53
|
+
assert.throws(() => {
|
|
54
|
+
nativeReadDataView(dataview, type, offset);
|
|
55
|
+
}, RangeError);
|
|
56
|
+
|
|
57
|
+
assert.throws(() => {
|
|
58
|
+
nativeWriteDataView(dataview, type, offset, value);
|
|
59
|
+
}, RangeError);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const dataview = new DataView(new ArrayBuffer(22));
|
|
63
|
+
|
|
64
|
+
testReadData(dataview, 'Float32', 0, 10.2);
|
|
65
|
+
testReadData(dataview, 'Float64', 4, 20.3);
|
|
66
|
+
testReadData(dataview, 'Int8', 5, 120);
|
|
67
|
+
testReadData(dataview, 'Int16', 7, 15000);
|
|
68
|
+
testReadData(dataview, 'Int32', 11, 200000);
|
|
69
|
+
testReadData(dataview, 'Uint8', 12, 128);
|
|
70
|
+
testReadData(dataview, 'Uint16', 14, 32768);
|
|
71
|
+
testReadData(dataview, 'Uint32', 18, 1000000);
|
|
72
|
+
|
|
73
|
+
testWriteData(dataview, 'Float32', 0, 10.2);
|
|
74
|
+
testWriteData(dataview, 'Float64', 4, 20.3);
|
|
75
|
+
testWriteData(dataview, 'Int8', 5, 120);
|
|
76
|
+
testWriteData(dataview, 'Int16', 7, 15000);
|
|
77
|
+
testWriteData(dataview, 'Int32', 11, 200000);
|
|
78
|
+
testWriteData(dataview, 'Uint8', 12, 128);
|
|
79
|
+
testWriteData(dataview, 'Uint16', 14, 32768);
|
|
80
|
+
testWriteData(dataview, 'Uint32', 18, 1000000);
|
|
81
|
+
|
|
82
|
+
testInvalidOffset(dataview, 'Float32', 22, 10.2);
|
|
83
|
+
testInvalidOffset(dataview, 'Float64', 22, 20.3);
|
|
84
|
+
testInvalidOffset(dataview, 'Int8', 22, 120);
|
|
85
|
+
testInvalidOffset(dataview, 'Int16', 22, 15000);
|
|
86
|
+
testInvalidOffset(dataview, 'Int32', 22, 200000);
|
|
87
|
+
testInvalidOffset(dataview, 'Uint8', 22, 128);
|
|
88
|
+
testInvalidOffset(dataview, 'Uint16', 22, 32768);
|
|
89
|
+
testInvalidOffset(dataview, 'Uint32', 22, 1000000);
|
|
90
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#include "napi.h"
|
|
2
|
+
|
|
3
|
+
using namespace Napi;
|
|
4
|
+
|
|
5
|
+
#if (NAPI_VERSION > 4)
|
|
6
|
+
namespace {
|
|
7
|
+
|
|
8
|
+
Value CreateDate(const CallbackInfo& info) {
|
|
9
|
+
double input = info[0].As<Number>().DoubleValue();
|
|
10
|
+
|
|
11
|
+
return Date::New(info.Env(), input);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
Value IsDate(const CallbackInfo& info) {
|
|
15
|
+
Date input = info[0].As<Date>();
|
|
16
|
+
|
|
17
|
+
return Boolean::New(info.Env(), input.IsDate());
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
Value ValueOf(const CallbackInfo& info) {
|
|
21
|
+
Date input = info[0].As<Date>();
|
|
22
|
+
|
|
23
|
+
return Number::New(info.Env(), input.ValueOf());
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
Value OperatorValue(const CallbackInfo& info) {
|
|
27
|
+
Date input = info[0].As<Date>();
|
|
28
|
+
|
|
29
|
+
return Boolean::New(info.Env(), input.ValueOf() == static_cast<double>(input));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
} // anonymous namespace
|
|
33
|
+
|
|
34
|
+
Object InitDate(Env env) {
|
|
35
|
+
Object exports = Object::New(env);
|
|
36
|
+
exports["CreateDate"] = Function::New(env, CreateDate);
|
|
37
|
+
exports["IsDate"] = Function::New(env, IsDate);
|
|
38
|
+
exports["ValueOf"] = Function::New(env, ValueOf);
|
|
39
|
+
exports["OperatorValue"] = Function::New(env, OperatorValue);
|
|
40
|
+
|
|
41
|
+
return exports;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#endif
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('assert');
|
|
4
|
+
|
|
5
|
+
module.exports = require('./common').runTest(test);
|
|
6
|
+
|
|
7
|
+
function test(binding) {
|
|
8
|
+
const {
|
|
9
|
+
CreateDate,
|
|
10
|
+
IsDate,
|
|
11
|
+
ValueOf,
|
|
12
|
+
OperatorValue,
|
|
13
|
+
} = binding.date;
|
|
14
|
+
assert.deepStrictEqual(CreateDate(0), new Date(0));
|
|
15
|
+
assert.strictEqual(IsDate(new Date(0)), true);
|
|
16
|
+
assert.strictEqual(ValueOf(new Date(42)), 42);
|
|
17
|
+
assert.strictEqual(OperatorValue(new Date(42)), true);
|
|
18
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#include <stdio.h>
|
|
2
|
+
#include "napi.h"
|
|
3
|
+
|
|
4
|
+
using namespace Napi;
|
|
5
|
+
|
|
6
|
+
#if (NAPI_VERSION > 2)
|
|
7
|
+
namespace {
|
|
8
|
+
|
|
9
|
+
static void cleanup(void* arg) {
|
|
10
|
+
printf("static cleanup(%d)\n", *(int*)(arg));
|
|
11
|
+
}
|
|
12
|
+
static void cleanupInt(int* arg) {
|
|
13
|
+
printf("static cleanup(%d)\n", *(arg));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static void cleanupVoid() {
|
|
17
|
+
printf("static cleanup()\n");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static int secret1 = 42;
|
|
21
|
+
static int secret2 = 43;
|
|
22
|
+
|
|
23
|
+
Value AddHooks(const CallbackInfo& info) {
|
|
24
|
+
auto env = info.Env();
|
|
25
|
+
|
|
26
|
+
bool shouldRemove = info[0].As<Boolean>().Value();
|
|
27
|
+
|
|
28
|
+
// hook: void (*)(void *arg), hint: int
|
|
29
|
+
auto hook1 = env.AddCleanupHook(cleanup, &secret1);
|
|
30
|
+
// test using same hook+arg pair
|
|
31
|
+
auto hook1b = env.AddCleanupHook(cleanup, &secret1);
|
|
32
|
+
|
|
33
|
+
// hook: void (*)(int *arg), hint: int
|
|
34
|
+
auto hook2 = env.AddCleanupHook(cleanupInt, &secret2);
|
|
35
|
+
|
|
36
|
+
// hook: void (*)(int *arg), hint: void (default)
|
|
37
|
+
auto hook3 = env.AddCleanupHook(cleanupVoid);
|
|
38
|
+
// test using the same hook
|
|
39
|
+
auto hook3b = env.AddCleanupHook(cleanupVoid);
|
|
40
|
+
|
|
41
|
+
// hook: lambda []void (int *arg)->void, hint: int
|
|
42
|
+
auto hook4 = env.AddCleanupHook(
|
|
43
|
+
[&](int* arg) { printf("lambda cleanup(%d)\n", *arg); }, &secret1);
|
|
44
|
+
|
|
45
|
+
// hook: lambda []void (void *)->void, hint: void
|
|
46
|
+
auto hook5 =
|
|
47
|
+
env.AddCleanupHook([&](void*) { printf("lambda cleanup(void)\n"); },
|
|
48
|
+
static_cast<void*>(nullptr));
|
|
49
|
+
|
|
50
|
+
// hook: lambda []void ()->void, hint: void (default)
|
|
51
|
+
auto hook6 = env.AddCleanupHook([&]() { printf("lambda cleanup()\n"); });
|
|
52
|
+
|
|
53
|
+
if (shouldRemove) {
|
|
54
|
+
hook1.Remove(env);
|
|
55
|
+
hook1b.Remove(env);
|
|
56
|
+
hook2.Remove(env);
|
|
57
|
+
hook3.Remove(env);
|
|
58
|
+
hook3b.Remove(env);
|
|
59
|
+
hook4.Remove(env);
|
|
60
|
+
hook5.Remove(env);
|
|
61
|
+
hook6.Remove(env);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
int added = 0;
|
|
65
|
+
|
|
66
|
+
added += !hook1.IsEmpty();
|
|
67
|
+
added += !hook1b.IsEmpty();
|
|
68
|
+
added += !hook2.IsEmpty();
|
|
69
|
+
added += !hook3.IsEmpty();
|
|
70
|
+
added += !hook3b.IsEmpty();
|
|
71
|
+
added += !hook4.IsEmpty();
|
|
72
|
+
added += !hook5.IsEmpty();
|
|
73
|
+
added += !hook6.IsEmpty();
|
|
74
|
+
|
|
75
|
+
return Number::New(env, added);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
} // anonymous namespace
|
|
79
|
+
|
|
80
|
+
Object InitEnvCleanup(Env env) {
|
|
81
|
+
Object exports = Object::New(env);
|
|
82
|
+
|
|
83
|
+
exports["addHooks"] = Function::New(env, AddHooks);
|
|
84
|
+
|
|
85
|
+
return exports;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
#endif
|