koffi 0.9.1 → 0.9.4
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 +3 -3
- 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,268 @@
|
|
|
1
|
+
#include <napi.h>
|
|
2
|
+
#include "test_helper.h"
|
|
3
|
+
|
|
4
|
+
Napi::ObjectReference testStaticContextRef;
|
|
5
|
+
|
|
6
|
+
Napi::Value StaticGetter(const Napi::CallbackInfo& /*info*/) {
|
|
7
|
+
return MaybeUnwrap(testStaticContextRef.Value().Get("value"));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
void StaticSetter(const Napi::CallbackInfo& /*info*/, const Napi::Value& value) {
|
|
11
|
+
testStaticContextRef.Value().Set("value", value);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
Napi::Value TestStaticMethod(const Napi::CallbackInfo& info) {
|
|
15
|
+
std::string str = MaybeUnwrap(info[0].ToString());
|
|
16
|
+
return Napi::String::New(info.Env(), str + " static");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
Napi::Value TestStaticMethodInternal(const Napi::CallbackInfo& info) {
|
|
20
|
+
std::string str = MaybeUnwrap(info[0].ToString());
|
|
21
|
+
return Napi::String::New(info.Env(), str + " static internal");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
class Test : public Napi::ObjectWrap<Test> {
|
|
25
|
+
public:
|
|
26
|
+
Test(const Napi::CallbackInfo& info) :
|
|
27
|
+
Napi::ObjectWrap<Test>(info) {
|
|
28
|
+
|
|
29
|
+
if(info.Length() > 0) {
|
|
30
|
+
finalizeCb_ = Napi::Persistent(info[0].As<Napi::Function>());
|
|
31
|
+
}
|
|
32
|
+
// Create an own instance property.
|
|
33
|
+
info.This().As<Napi::Object>().DefineProperty(
|
|
34
|
+
Napi::PropertyDescriptor::Accessor(info.Env(),
|
|
35
|
+
info.This().As<Napi::Object>(),
|
|
36
|
+
"ownProperty",
|
|
37
|
+
OwnPropertyGetter,
|
|
38
|
+
napi_enumerable, this));
|
|
39
|
+
|
|
40
|
+
// Create an own instance property with a templated function.
|
|
41
|
+
info.This().As<Napi::Object>().DefineProperty(
|
|
42
|
+
Napi::PropertyDescriptor::Accessor<OwnPropertyGetter>("ownPropertyT",
|
|
43
|
+
napi_enumerable, this));
|
|
44
|
+
|
|
45
|
+
bufref_ = Napi::Persistent(Napi::Buffer<uint8_t>::New(
|
|
46
|
+
Env(),
|
|
47
|
+
static_cast<uint8_t*>(malloc(1)),
|
|
48
|
+
1,
|
|
49
|
+
[](Napi::Env, uint8_t* bufaddr) {
|
|
50
|
+
free(bufaddr);
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static Napi::Value OwnPropertyGetter(const Napi::CallbackInfo& info) {
|
|
55
|
+
return static_cast<Test*>(info.Data())->Getter(info);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
void Setter(const Napi::CallbackInfo& /*info*/, const Napi::Value& value) {
|
|
59
|
+
value_ = MaybeUnwrap(value.ToString());
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
Napi::Value Getter(const Napi::CallbackInfo& info) {
|
|
63
|
+
return Napi::String::New(info.Env(), value_);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
Napi::Value TestMethod(const Napi::CallbackInfo& info) {
|
|
67
|
+
std::string str = MaybeUnwrap(info[0].ToString());
|
|
68
|
+
return Napi::String::New(info.Env(), str + " instance");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
Napi::Value TestMethodInternal(const Napi::CallbackInfo& info) {
|
|
72
|
+
std::string str = MaybeUnwrap(info[0].ToString());
|
|
73
|
+
return Napi::String::New(info.Env(), str + " instance internal");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
Napi::Value ToStringTag(const Napi::CallbackInfo& info) {
|
|
77
|
+
return Napi::String::From(info.Env(), "TestTag");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// creates dummy array, returns `([value])[Symbol.iterator]()`
|
|
81
|
+
Napi::Value Iterator(const Napi::CallbackInfo& info) {
|
|
82
|
+
Napi::Array array = Napi::Array::New(info.Env());
|
|
83
|
+
array.Set(array.Length(), Napi::String::From(info.Env(), value_));
|
|
84
|
+
return MaybeUnwrap(
|
|
85
|
+
MaybeUnwrap(array.Get(MaybeUnwrap(
|
|
86
|
+
Napi::Symbol::WellKnown(info.Env(), "iterator"))))
|
|
87
|
+
.As<Napi::Function>()
|
|
88
|
+
.Call(array, {}));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
void TestVoidMethodT(const Napi::CallbackInfo &info) {
|
|
92
|
+
value_ = MaybeUnwrap(info[0].ToString());
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
Napi::Value TestMethodT(const Napi::CallbackInfo &info) {
|
|
96
|
+
return Napi::String::New(info.Env(), value_);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
static Napi::Value TestStaticMethodT(const Napi::CallbackInfo& info) {
|
|
100
|
+
return Napi::String::New(info.Env(), s_staticMethodText);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
static void TestStaticVoidMethodT(const Napi::CallbackInfo& info) {
|
|
104
|
+
s_staticMethodText = MaybeUnwrap(info[0].ToString());
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static void Initialize(Napi::Env env, Napi::Object exports) {
|
|
108
|
+
|
|
109
|
+
Napi::Symbol kTestStaticValueInternal = Napi::Symbol::New(env, "kTestStaticValueInternal");
|
|
110
|
+
Napi::Symbol kTestStaticAccessorInternal = Napi::Symbol::New(env, "kTestStaticAccessorInternal");
|
|
111
|
+
Napi::Symbol kTestStaticAccessorTInternal = Napi::Symbol::New(env, "kTestStaticAccessorTInternal");
|
|
112
|
+
Napi::Symbol kTestStaticMethodInternal = Napi::Symbol::New(env, "kTestStaticMethodInternal");
|
|
113
|
+
Napi::Symbol kTestStaticMethodTInternal = Napi::Symbol::New(env, "kTestStaticMethodTInternal");
|
|
114
|
+
Napi::Symbol kTestStaticVoidMethodTInternal = Napi::Symbol::New(env, "kTestStaticVoidMethodTInternal");
|
|
115
|
+
|
|
116
|
+
Napi::Symbol kTestValueInternal = Napi::Symbol::New(env, "kTestValueInternal");
|
|
117
|
+
Napi::Symbol kTestAccessorInternal = Napi::Symbol::New(env, "kTestAccessorInternal");
|
|
118
|
+
Napi::Symbol kTestAccessorTInternal = Napi::Symbol::New(env, "kTestAccessorTInternal");
|
|
119
|
+
Napi::Symbol kTestMethodInternal = Napi::Symbol::New(env, "kTestMethodInternal");
|
|
120
|
+
Napi::Symbol kTestMethodTInternal = Napi::Symbol::New(env, "kTestMethodTInternal");
|
|
121
|
+
Napi::Symbol kTestVoidMethodTInternal = Napi::Symbol::New(env, "kTestVoidMethodTInternal");
|
|
122
|
+
|
|
123
|
+
exports.Set(
|
|
124
|
+
"Test",
|
|
125
|
+
DefineClass(
|
|
126
|
+
env,
|
|
127
|
+
"Test",
|
|
128
|
+
{
|
|
129
|
+
|
|
130
|
+
// expose symbols for testing
|
|
131
|
+
StaticValue("kTestStaticValueInternal",
|
|
132
|
+
kTestStaticValueInternal),
|
|
133
|
+
StaticValue("kTestStaticAccessorInternal",
|
|
134
|
+
kTestStaticAccessorInternal),
|
|
135
|
+
StaticValue("kTestStaticAccessorTInternal",
|
|
136
|
+
kTestStaticAccessorTInternal),
|
|
137
|
+
StaticValue("kTestStaticMethodInternal",
|
|
138
|
+
kTestStaticMethodInternal),
|
|
139
|
+
StaticValue("kTestStaticMethodTInternal",
|
|
140
|
+
kTestStaticMethodTInternal),
|
|
141
|
+
StaticValue("kTestStaticVoidMethodTInternal",
|
|
142
|
+
kTestStaticVoidMethodTInternal),
|
|
143
|
+
StaticValue("kTestValueInternal", kTestValueInternal),
|
|
144
|
+
StaticValue("kTestAccessorInternal", kTestAccessorInternal),
|
|
145
|
+
StaticValue("kTestAccessorTInternal", kTestAccessorTInternal),
|
|
146
|
+
StaticValue("kTestMethodInternal", kTestMethodInternal),
|
|
147
|
+
StaticValue("kTestMethodTInternal", kTestMethodTInternal),
|
|
148
|
+
StaticValue("kTestVoidMethodTInternal",
|
|
149
|
+
kTestVoidMethodTInternal),
|
|
150
|
+
|
|
151
|
+
// test data
|
|
152
|
+
StaticValue("testStaticValue",
|
|
153
|
+
Napi::String::New(env, "value"),
|
|
154
|
+
napi_enumerable),
|
|
155
|
+
StaticValue(kTestStaticValueInternal,
|
|
156
|
+
Napi::Number::New(env, 5),
|
|
157
|
+
napi_default),
|
|
158
|
+
|
|
159
|
+
StaticAccessor("testStaticGetter",
|
|
160
|
+
&StaticGetter,
|
|
161
|
+
nullptr,
|
|
162
|
+
napi_enumerable),
|
|
163
|
+
StaticAccessor(
|
|
164
|
+
"testStaticSetter", nullptr, &StaticSetter, napi_default),
|
|
165
|
+
StaticAccessor("testStaticGetSet",
|
|
166
|
+
&StaticGetter,
|
|
167
|
+
&StaticSetter,
|
|
168
|
+
napi_enumerable),
|
|
169
|
+
StaticAccessor(kTestStaticAccessorInternal,
|
|
170
|
+
&StaticGetter,
|
|
171
|
+
&StaticSetter,
|
|
172
|
+
napi_enumerable),
|
|
173
|
+
StaticAccessor<&StaticGetter>("testStaticGetterT"),
|
|
174
|
+
StaticAccessor<&StaticGetter, &StaticSetter>(
|
|
175
|
+
"testStaticGetSetT"),
|
|
176
|
+
StaticAccessor<&StaticGetter, &StaticSetter>(
|
|
177
|
+
kTestStaticAccessorTInternal),
|
|
178
|
+
|
|
179
|
+
StaticMethod(
|
|
180
|
+
"testStaticMethod", &TestStaticMethod, napi_enumerable),
|
|
181
|
+
StaticMethod(kTestStaticMethodInternal,
|
|
182
|
+
&TestStaticMethodInternal,
|
|
183
|
+
napi_default),
|
|
184
|
+
StaticMethod<&TestStaticVoidMethodT>("testStaticVoidMethodT"),
|
|
185
|
+
StaticMethod<&TestStaticMethodT>("testStaticMethodT"),
|
|
186
|
+
StaticMethod<&TestStaticVoidMethodT>(
|
|
187
|
+
kTestStaticVoidMethodTInternal),
|
|
188
|
+
StaticMethod<&TestStaticMethodT>(kTestStaticMethodTInternal),
|
|
189
|
+
|
|
190
|
+
InstanceValue("testValue",
|
|
191
|
+
Napi::Boolean::New(env, true),
|
|
192
|
+
napi_enumerable),
|
|
193
|
+
InstanceValue(kTestValueInternal,
|
|
194
|
+
Napi::Boolean::New(env, false),
|
|
195
|
+
napi_enumerable),
|
|
196
|
+
|
|
197
|
+
InstanceAccessor(
|
|
198
|
+
"testGetter", &Test::Getter, nullptr, napi_enumerable),
|
|
199
|
+
InstanceAccessor(
|
|
200
|
+
"testSetter", nullptr, &Test::Setter, napi_default),
|
|
201
|
+
InstanceAccessor("testGetSet",
|
|
202
|
+
&Test::Getter,
|
|
203
|
+
&Test::Setter,
|
|
204
|
+
napi_enumerable),
|
|
205
|
+
InstanceAccessor(kTestAccessorInternal,
|
|
206
|
+
&Test::Getter,
|
|
207
|
+
&Test::Setter,
|
|
208
|
+
napi_enumerable),
|
|
209
|
+
InstanceAccessor<&Test::Getter>("testGetterT"),
|
|
210
|
+
InstanceAccessor<&Test::Getter, &Test::Setter>("testGetSetT"),
|
|
211
|
+
InstanceAccessor<&Test::Getter, &Test::Setter>(
|
|
212
|
+
kTestAccessorInternal),
|
|
213
|
+
|
|
214
|
+
InstanceMethod(
|
|
215
|
+
"testMethod", &Test::TestMethod, napi_enumerable),
|
|
216
|
+
InstanceMethod(kTestMethodInternal,
|
|
217
|
+
&Test::TestMethodInternal,
|
|
218
|
+
napi_default),
|
|
219
|
+
InstanceMethod<&Test::TestMethodT>("testMethodT"),
|
|
220
|
+
InstanceMethod<&Test::TestVoidMethodT>("testVoidMethodT"),
|
|
221
|
+
InstanceMethod<&Test::TestMethodT>(kTestMethodTInternal),
|
|
222
|
+
InstanceMethod<&Test::TestVoidMethodT>(
|
|
223
|
+
kTestVoidMethodTInternal),
|
|
224
|
+
|
|
225
|
+
// conventions
|
|
226
|
+
InstanceAccessor(
|
|
227
|
+
MaybeUnwrap(Napi::Symbol::WellKnown(env, "toStringTag")),
|
|
228
|
+
&Test::ToStringTag,
|
|
229
|
+
nullptr,
|
|
230
|
+
napi_enumerable),
|
|
231
|
+
InstanceMethod(
|
|
232
|
+
MaybeUnwrap(Napi::Symbol::WellKnown(env, "iterator")),
|
|
233
|
+
&Test::Iterator,
|
|
234
|
+
napi_default),
|
|
235
|
+
|
|
236
|
+
}));
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
void Finalize(Napi::Env env) {
|
|
240
|
+
|
|
241
|
+
if(finalizeCb_.IsEmpty()) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
finalizeCb_.Call(env.Global(), {Napi::Boolean::New(env, true)});
|
|
246
|
+
finalizeCb_.Unref();
|
|
247
|
+
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
private:
|
|
251
|
+
std::string value_;
|
|
252
|
+
Napi::FunctionReference finalizeCb_;
|
|
253
|
+
|
|
254
|
+
static std::string s_staticMethodText;
|
|
255
|
+
|
|
256
|
+
Napi::Reference<Napi::Buffer<uint8_t>> bufref_;
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
std::string Test::s_staticMethodText;
|
|
260
|
+
|
|
261
|
+
Napi::Object InitObjectWrap(Napi::Env env) {
|
|
262
|
+
testStaticContextRef = Napi::Persistent(Napi::Object::New(env));
|
|
263
|
+
testStaticContextRef.SuppressDestruct();
|
|
264
|
+
|
|
265
|
+
Napi::Object exports = Napi::Object::New(env);
|
|
266
|
+
Test::Initialize(env, exports);
|
|
267
|
+
return exports;
|
|
268
|
+
}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('assert');
|
|
4
|
+
const testUtil = require('./testUtil');
|
|
5
|
+
|
|
6
|
+
module.exports = require('./common').runTest(test);
|
|
7
|
+
|
|
8
|
+
async function test(binding) {
|
|
9
|
+
const Test = binding.objectwrap.Test;
|
|
10
|
+
|
|
11
|
+
const testValue = (obj, clazz) => {
|
|
12
|
+
assert.strictEqual(obj.testValue, true);
|
|
13
|
+
assert.strictEqual(obj[clazz.kTestValueInternal], false);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const testAccessor = (obj, clazz) => {
|
|
17
|
+
// read-only, write-only
|
|
18
|
+
{
|
|
19
|
+
obj.testSetter = 'instance getter';
|
|
20
|
+
assert.strictEqual(obj.testGetter, 'instance getter');
|
|
21
|
+
assert.strictEqual(obj.testGetterT, 'instance getter');
|
|
22
|
+
|
|
23
|
+
obj.testSetter = 'instance getter 2';
|
|
24
|
+
assert.strictEqual(obj.testGetter, 'instance getter 2');
|
|
25
|
+
assert.strictEqual(obj.testGetterT, 'instance getter 2');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// read write-only
|
|
29
|
+
{
|
|
30
|
+
let error;
|
|
31
|
+
try { const read = obj.testSetter; } catch (e) { error = e; }
|
|
32
|
+
// no error
|
|
33
|
+
assert.strictEqual(error, undefined);
|
|
34
|
+
|
|
35
|
+
// read is undefined
|
|
36
|
+
assert.strictEqual(obj.testSetter, undefined);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// write read-only
|
|
40
|
+
{
|
|
41
|
+
let error;
|
|
42
|
+
try { obj.testGetter = 'write'; } catch (e) { error = e; }
|
|
43
|
+
assert.strictEqual(error.name, 'TypeError');
|
|
44
|
+
|
|
45
|
+
try { obj.testGetterT = 'write'; } catch (e) { error = e; }
|
|
46
|
+
assert.strictEqual(error.name, 'TypeError');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// rw
|
|
50
|
+
{
|
|
51
|
+
obj.testGetSet = 'instance getset';
|
|
52
|
+
assert.strictEqual(obj.testGetSet, 'instance getset');
|
|
53
|
+
|
|
54
|
+
obj.testGetSet = 'instance getset 2';
|
|
55
|
+
assert.strictEqual(obj.testGetSet, 'instance getset 2');
|
|
56
|
+
|
|
57
|
+
obj.testGetSetT = 'instance getset 3';
|
|
58
|
+
assert.strictEqual(obj.testGetSetT, 'instance getset 3');
|
|
59
|
+
|
|
60
|
+
obj.testGetSetT = 'instance getset 4';
|
|
61
|
+
assert.strictEqual(obj.testGetSetT, 'instance getset 4');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// rw symbol
|
|
65
|
+
{
|
|
66
|
+
obj[clazz.kTestAccessorInternal] = 'instance internal getset';
|
|
67
|
+
assert.strictEqual(obj[clazz.kTestAccessorInternal], 'instance internal getset');
|
|
68
|
+
|
|
69
|
+
obj[clazz.kTestAccessorInternal] = 'instance internal getset 2';
|
|
70
|
+
assert.strictEqual(obj[clazz.kTestAccessorInternal], 'instance internal getset 2');
|
|
71
|
+
|
|
72
|
+
obj[clazz.kTestAccessorTInternal] = 'instance internal getset 3';
|
|
73
|
+
assert.strictEqual(obj[clazz.kTestAccessorTInternal], 'instance internal getset 3');
|
|
74
|
+
|
|
75
|
+
obj[clazz.kTestAccessorTInternal] = 'instance internal getset 4';
|
|
76
|
+
assert.strictEqual(obj[clazz.kTestAccessorTInternal], 'instance internal getset 4');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// own property
|
|
80
|
+
{
|
|
81
|
+
obj.testSetter = 'own property value';
|
|
82
|
+
// Make sure the properties are enumerable.
|
|
83
|
+
assert(Object.getOwnPropertyNames(obj).indexOf('ownProperty') >= 0);
|
|
84
|
+
assert(Object.getOwnPropertyNames(obj).indexOf('ownPropertyT') >= 0);
|
|
85
|
+
|
|
86
|
+
// Make sure the properties return the right value.
|
|
87
|
+
assert.strictEqual(obj.ownProperty, 'own property value');
|
|
88
|
+
assert.strictEqual(obj.ownPropertyT, 'own property value');
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const testMethod = (obj, clazz) => {
|
|
93
|
+
assert.strictEqual(obj.testMethod('method'), 'method instance');
|
|
94
|
+
assert.strictEqual(obj[clazz.kTestMethodInternal]('method'), 'method instance internal');
|
|
95
|
+
obj.testVoidMethodT('method<>(const char*)');
|
|
96
|
+
assert.strictEqual(obj.testMethodT(), 'method<>(const char*)');
|
|
97
|
+
obj[clazz.kTestVoidMethodTInternal]('method<>(Symbol)');
|
|
98
|
+
assert.strictEqual(obj[clazz.kTestMethodTInternal](), 'method<>(Symbol)');
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const testEnumerables = (obj, clazz) => {
|
|
102
|
+
// Object.keys: only object without prototype
|
|
103
|
+
assert(Object.keys(obj).length === 2);
|
|
104
|
+
assert(Object.keys(obj).includes('ownProperty'));
|
|
105
|
+
assert(Object.keys(obj).indexOf('ownPropertyT') >= 0);
|
|
106
|
+
|
|
107
|
+
// for..in: object and prototype
|
|
108
|
+
{
|
|
109
|
+
const keys = [];
|
|
110
|
+
for (let key in obj) {
|
|
111
|
+
keys.push(key);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
assert(keys.length == 6);
|
|
115
|
+
// on prototype
|
|
116
|
+
assert(keys.includes("testGetSet"));
|
|
117
|
+
assert(keys.includes("testGetter"));
|
|
118
|
+
assert(keys.includes("testValue"));
|
|
119
|
+
assert(keys.includes("testMethod"));
|
|
120
|
+
// on object only
|
|
121
|
+
assert(keys.includes("ownProperty"));
|
|
122
|
+
assert(keys.includes("ownPropertyT"));
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const testConventions = (obj, clazz) => {
|
|
127
|
+
// test @@toStringTag
|
|
128
|
+
{
|
|
129
|
+
assert.strictEqual(obj[Symbol.toStringTag], 'TestTag');
|
|
130
|
+
assert.strictEqual('' + obj, '[object TestTag]');
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// test @@iterator
|
|
134
|
+
{
|
|
135
|
+
obj.testSetter = 'iterator';
|
|
136
|
+
const values = [];
|
|
137
|
+
|
|
138
|
+
for (let item of obj) {
|
|
139
|
+
values.push(item);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
assert.deepEqual(values, ['iterator']);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const testStaticValue = (clazz) => {
|
|
147
|
+
assert.strictEqual(clazz.testStaticValue, 'value');
|
|
148
|
+
assert.strictEqual(clazz[clazz.kTestStaticValueInternal], 5);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const testStaticAccessor = (clazz) => {
|
|
152
|
+
// read-only, write-only
|
|
153
|
+
{
|
|
154
|
+
const tempObj = {};
|
|
155
|
+
clazz.testStaticSetter = tempObj;
|
|
156
|
+
assert.strictEqual(clazz.testStaticGetter, tempObj);
|
|
157
|
+
assert.strictEqual(clazz.testStaticGetterT, tempObj);
|
|
158
|
+
|
|
159
|
+
const tempArray = [];
|
|
160
|
+
clazz.testStaticSetter = tempArray;
|
|
161
|
+
assert.strictEqual(clazz.testStaticGetter, tempArray);
|
|
162
|
+
assert.strictEqual(clazz.testStaticGetterT, tempArray);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// read write-only
|
|
166
|
+
{
|
|
167
|
+
let error;
|
|
168
|
+
try { const read = clazz.testStaticSetter; } catch (e) { error = e; }
|
|
169
|
+
// no error
|
|
170
|
+
assert.strictEqual(error, undefined);
|
|
171
|
+
|
|
172
|
+
// read is undefined
|
|
173
|
+
assert.strictEqual(clazz.testStaticSetter, undefined);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// write-read-only
|
|
177
|
+
{
|
|
178
|
+
let error;
|
|
179
|
+
try { clazz.testStaticGetter = 'write'; } catch (e) { error = e; }
|
|
180
|
+
assert.strictEqual(error.name, 'TypeError');
|
|
181
|
+
try { clazz.testStaticGetterT = 'write'; } catch (e) { error = e; }
|
|
182
|
+
assert.strictEqual(error.name, 'TypeError');
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// rw
|
|
186
|
+
{
|
|
187
|
+
clazz.testStaticGetSet = 9;
|
|
188
|
+
assert.strictEqual(clazz.testStaticGetSet, 9);
|
|
189
|
+
|
|
190
|
+
clazz.testStaticGetSet = 4;
|
|
191
|
+
assert.strictEqual(clazz.testStaticGetSet, 4);
|
|
192
|
+
|
|
193
|
+
clazz.testStaticGetSetT = -9;
|
|
194
|
+
assert.strictEqual(clazz.testStaticGetSetT, -9);
|
|
195
|
+
|
|
196
|
+
clazz.testStaticGetSetT = -4;
|
|
197
|
+
assert.strictEqual(clazz.testStaticGetSetT, -4);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// rw symbol
|
|
201
|
+
{
|
|
202
|
+
clazz[clazz.kTestStaticAccessorInternal] = 'static internal getset';
|
|
203
|
+
assert.strictEqual(clazz[clazz.kTestStaticAccessorInternal], 'static internal getset');
|
|
204
|
+
clazz[clazz.kTestStaticAccessorTInternal] = 'static internal getset <>';
|
|
205
|
+
assert.strictEqual(clazz[clazz.kTestStaticAccessorTInternal], 'static internal getset <>');
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
const testStaticMethod = (clazz) => {
|
|
210
|
+
assert.strictEqual(clazz.testStaticMethod('method'), 'method static');
|
|
211
|
+
assert.strictEqual(clazz[clazz.kTestStaticMethodInternal]('method'), 'method static internal');
|
|
212
|
+
clazz.testStaticVoidMethodT('static method<>(const char*)');
|
|
213
|
+
assert.strictEqual(clazz.testStaticMethodT(), 'static method<>(const char*)');
|
|
214
|
+
clazz[clazz.kTestStaticVoidMethodTInternal]('static method<>(Symbol)');
|
|
215
|
+
assert.strictEqual(clazz[clazz.kTestStaticMethodTInternal](), 'static method<>(Symbol)');
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
const testStaticEnumerables = (clazz) => {
|
|
219
|
+
// Object.keys
|
|
220
|
+
assert.deepEqual(Object.keys(clazz), [
|
|
221
|
+
'testStaticValue',
|
|
222
|
+
'testStaticGetter',
|
|
223
|
+
'testStaticGetSet',
|
|
224
|
+
'testStaticMethod'
|
|
225
|
+
]);
|
|
226
|
+
|
|
227
|
+
// for..in
|
|
228
|
+
{
|
|
229
|
+
const keys = [];
|
|
230
|
+
for (let key in clazz) {
|
|
231
|
+
keys.push(key);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
assert.deepEqual(keys, [
|
|
235
|
+
'testStaticValue',
|
|
236
|
+
'testStaticGetter',
|
|
237
|
+
'testStaticGetSet',
|
|
238
|
+
'testStaticMethod'
|
|
239
|
+
]);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
async function testFinalize(clazz) {
|
|
244
|
+
let finalizeCalled = false;
|
|
245
|
+
await testUtil.runGCTests([
|
|
246
|
+
'test finalize',
|
|
247
|
+
() => {
|
|
248
|
+
const finalizeCb = function(called) {
|
|
249
|
+
finalizeCalled = called;
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
//Scope Test instance so that it can be gc'd.
|
|
253
|
+
(() => { new Test(finalizeCb); })();
|
|
254
|
+
},
|
|
255
|
+
() => assert.strictEqual(finalizeCalled, true)
|
|
256
|
+
]);
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
const testObj = (obj, clazz) => {
|
|
260
|
+
testValue(obj, clazz);
|
|
261
|
+
testAccessor(obj, clazz);
|
|
262
|
+
testMethod(obj, clazz);
|
|
263
|
+
|
|
264
|
+
testEnumerables(obj, clazz);
|
|
265
|
+
|
|
266
|
+
testConventions(obj, clazz);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
async function testClass(clazz) {
|
|
270
|
+
testStaticValue(clazz);
|
|
271
|
+
testStaticAccessor(clazz);
|
|
272
|
+
testStaticMethod(clazz);
|
|
273
|
+
|
|
274
|
+
testStaticEnumerables(clazz);
|
|
275
|
+
await testFinalize(clazz);
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
// `Test` is needed for accessing exposed symbols
|
|
279
|
+
testObj(new Test(), Test);
|
|
280
|
+
await testClass(Test);
|
|
281
|
+
|
|
282
|
+
// Make sure the C++ object can be garbage collected without issues.
|
|
283
|
+
await testUtil.runGCTests(['one last gc', () => {}, () => {}]);
|
|
284
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#include <napi.h>
|
|
2
|
+
|
|
3
|
+
class ConstructorExceptionTest :
|
|
4
|
+
public Napi::ObjectWrap<ConstructorExceptionTest> {
|
|
5
|
+
public:
|
|
6
|
+
ConstructorExceptionTest(const Napi::CallbackInfo& info) :
|
|
7
|
+
Napi::ObjectWrap<ConstructorExceptionTest>(info) {
|
|
8
|
+
Napi::Error error = Napi::Error::New(info.Env(), "an exception");
|
|
9
|
+
#ifdef NAPI_DISABLE_CPP_EXCEPTIONS
|
|
10
|
+
error.ThrowAsJavaScriptException();
|
|
11
|
+
#else
|
|
12
|
+
throw error;
|
|
13
|
+
#endif // NAPI_DISABLE_CPP_EXCEPTIONS
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static void Initialize(Napi::Env env, Napi::Object exports) {
|
|
17
|
+
const char* name = "ConstructorExceptionTest";
|
|
18
|
+
exports.Set(name, DefineClass(env, name, {}));
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
Napi::Object InitObjectWrapConstructorException(Napi::Env env) {
|
|
23
|
+
Napi::Object exports = Napi::Object::New(env);
|
|
24
|
+
ConstructorExceptionTest::Initialize(env, exports);
|
|
25
|
+
return exports;
|
|
26
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('assert');
|
|
4
|
+
const testUtil = require('./testUtil');
|
|
5
|
+
|
|
6
|
+
function test(binding) {
|
|
7
|
+
return testUtil.runGCTests([
|
|
8
|
+
'objectwrap constructor exception',
|
|
9
|
+
() => {
|
|
10
|
+
const { ConstructorExceptionTest } = binding.objectwrapConstructorException;
|
|
11
|
+
assert.throws(() => (new ConstructorExceptionTest()), /an exception/);
|
|
12
|
+
},
|
|
13
|
+
// Do on gc before returning.
|
|
14
|
+
() => {}
|
|
15
|
+
]);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = require('./common').runTest(test);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#include <napi.h>
|
|
2
|
+
|
|
3
|
+
class TestMIBase {
|
|
4
|
+
public:
|
|
5
|
+
TestMIBase() : test(0) {}
|
|
6
|
+
virtual void dummy() {}
|
|
7
|
+
uint32_t test;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
class TestMI : public TestMIBase, public Napi::ObjectWrap<TestMI> {
|
|
11
|
+
public:
|
|
12
|
+
TestMI(const Napi::CallbackInfo& info) :
|
|
13
|
+
Napi::ObjectWrap<TestMI>(info) {}
|
|
14
|
+
|
|
15
|
+
Napi::Value GetTest(const Napi::CallbackInfo& info) {
|
|
16
|
+
return Napi::Number::New(info.Env(), test);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static void Initialize(Napi::Env env, Napi::Object exports) {
|
|
20
|
+
exports.Set("TestMI", DefineClass(env, "TestMI", {
|
|
21
|
+
InstanceAccessor<&TestMI::GetTest>("test")
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
Napi::Object InitObjectWrapMultipleInheritance(Napi::Env env) {
|
|
27
|
+
Napi::Object exports = Napi::Object::New(env);
|
|
28
|
+
TestMI::Initialize(env, exports);
|
|
29
|
+
return exports;
|
|
30
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('assert');
|
|
4
|
+
|
|
5
|
+
const test = bindingName => {
|
|
6
|
+
const binding = require(bindingName);
|
|
7
|
+
const TestMI = binding.objectwrap_multiple_inheritance.TestMI;
|
|
8
|
+
const testmi = new TestMI();
|
|
9
|
+
|
|
10
|
+
assert.strictEqual(testmi.test, 0);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = require('./common').runTestWithBindingPath(test);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#include <assert.h>
|
|
2
|
+
#include <napi.h>
|
|
3
|
+
|
|
4
|
+
namespace {
|
|
5
|
+
|
|
6
|
+
static int dtor_called = 0;
|
|
7
|
+
|
|
8
|
+
class DtorCounter {
|
|
9
|
+
public:
|
|
10
|
+
~DtorCounter() {
|
|
11
|
+
assert(dtor_called == 0);
|
|
12
|
+
dtor_called++;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
Napi::Value GetDtorCalled(const Napi::CallbackInfo& info) {
|
|
17
|
+
return Napi::Number::New(info.Env(), dtor_called);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class Test : public Napi::ObjectWrap<Test> {
|
|
21
|
+
public:
|
|
22
|
+
Test(const Napi::CallbackInfo& info) : Napi::ObjectWrap<Test>(info) {
|
|
23
|
+
#ifdef NAPI_CPP_EXCEPTIONS
|
|
24
|
+
throw Napi::Error::New(Env(), "Some error");
|
|
25
|
+
#else
|
|
26
|
+
Napi::Error::New(Env(), "Some error").ThrowAsJavaScriptException();
|
|
27
|
+
#endif
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static void Initialize(Napi::Env env, Napi::Object exports) {
|
|
31
|
+
exports.Set("Test", DefineClass(env, "Test", {}));
|
|
32
|
+
exports.Set("getDtorCalled", Napi::Function::New(env, GetDtorCalled));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private:
|
|
36
|
+
DtorCounter dtor_counter_;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
} // anonymous namespace
|
|
40
|
+
|
|
41
|
+
Napi::Object InitObjectWrapRemoveWrap(Napi::Env env) {
|
|
42
|
+
Napi::Object exports = Napi::Object::New(env);
|
|
43
|
+
Test::Initialize(env, exports);
|
|
44
|
+
return exports;
|
|
45
|
+
}
|