koffi 0.9.34 → 0.9.37
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 -1
- package/README.md +16 -13
- package/package.json +5 -4
- package/src/call_arm32.cc +6 -2
- package/src/call_arm64.cc +6 -2
- package/src/call_x64_sysv.cc +6 -2
- package/src/call_x64_win.cc +6 -2
- package/src/call_x86.cc +7 -3
- package/src/ffi.cc +77 -59
- package/src/ffi.hh +2 -2
- package/src/parser.cc +246 -0
- package/src/parser.hh +63 -0
- package/src/util.cc +23 -0
- package/src/util.hh +3 -0
- package/test/registry/machines.json +70 -0
- package/test/test.js +116 -7
- package/test/tests/misc.js +16 -16
- package/test/tests/raylib.js +8 -8
- package/test/tests/sqlite.js +9 -9
- package/vendor/node-addon-api/CODE_OF_CONDUCT.md +4 -0
- package/vendor/node-addon-api/CONTRIBUTING.md +93 -0
- package/vendor/node-addon-api/appveyor.yml +37 -0
- package/vendor/node-addon-api/benchmark/README.md +47 -0
- package/vendor/node-addon-api/benchmark/binding.gyp +25 -0
- package/vendor/node-addon-api/benchmark/function_args.cc +217 -0
- package/vendor/node-addon-api/benchmark/function_args.js +60 -0
- package/vendor/node-addon-api/benchmark/index.js +34 -0
- package/vendor/node-addon-api/benchmark/property_descriptor.cc +91 -0
- package/vendor/node-addon-api/benchmark/property_descriptor.js +37 -0
- package/vendor/node-addon-api/doc/addon.md +163 -0
- package/vendor/node-addon-api/doc/array.md +81 -0
- package/vendor/node-addon-api/doc/array_buffer.md +155 -0
- package/vendor/node-addon-api/doc/async_context.md +86 -0
- package/vendor/node-addon-api/doc/async_operations.md +31 -0
- package/vendor/node-addon-api/doc/async_worker.md +427 -0
- package/vendor/node-addon-api/doc/async_worker_variants.md +557 -0
- package/vendor/node-addon-api/doc/bigint.md +97 -0
- package/vendor/node-addon-api/doc/boolean.md +68 -0
- package/vendor/node-addon-api/doc/buffer.md +150 -0
- package/vendor/node-addon-api/doc/callback_scope.md +54 -0
- package/vendor/node-addon-api/doc/callbackinfo.md +97 -0
- package/vendor/node-addon-api/doc/checker-tool.md +32 -0
- package/vendor/node-addon-api/doc/class_property_descriptor.md +123 -0
- package/vendor/node-addon-api/doc/cmake-js.md +68 -0
- package/vendor/node-addon-api/doc/conversion-tool.md +28 -0
- package/vendor/node-addon-api/doc/creating_a_release.md +62 -0
- package/vendor/node-addon-api/doc/dataview.md +248 -0
- package/vendor/node-addon-api/doc/date.md +68 -0
- package/vendor/node-addon-api/doc/env.md +196 -0
- package/vendor/node-addon-api/doc/error.md +120 -0
- package/vendor/node-addon-api/doc/error_handling.md +254 -0
- package/vendor/node-addon-api/doc/escapable_handle_scope.md +80 -0
- package/vendor/node-addon-api/doc/external.md +63 -0
- package/vendor/node-addon-api/doc/function.md +402 -0
- package/vendor/node-addon-api/doc/function_reference.md +238 -0
- package/vendor/node-addon-api/doc/generator.md +13 -0
- package/vendor/node-addon-api/doc/handle_scope.md +63 -0
- package/vendor/node-addon-api/doc/hierarchy.md +91 -0
- package/vendor/node-addon-api/doc/instance_wrap.md +408 -0
- package/vendor/node-addon-api/doc/maybe.md +76 -0
- package/vendor/node-addon-api/doc/memory_management.md +27 -0
- package/vendor/node-addon-api/doc/name.md +29 -0
- package/vendor/node-addon-api/doc/node-gyp.md +82 -0
- package/vendor/node-addon-api/doc/number.md +163 -0
- package/vendor/node-addon-api/doc/object.md +411 -0
- package/vendor/node-addon-api/doc/object_lifetime_management.md +83 -0
- package/vendor/node-addon-api/doc/object_reference.md +117 -0
- package/vendor/node-addon-api/doc/object_wrap.md +588 -0
- package/vendor/node-addon-api/doc/prebuild_tools.md +16 -0
- package/vendor/node-addon-api/doc/promises.md +79 -0
- package/vendor/node-addon-api/doc/property_descriptor.md +286 -0
- package/vendor/node-addon-api/doc/propertylvalue.md +50 -0
- package/vendor/node-addon-api/doc/range_error.md +59 -0
- package/vendor/node-addon-api/doc/reference.md +113 -0
- package/vendor/node-addon-api/doc/setup.md +110 -0
- package/vendor/node-addon-api/doc/string.md +93 -0
- package/vendor/node-addon-api/doc/symbol.md +61 -0
- package/vendor/node-addon-api/doc/threadsafe.md +121 -0
- package/vendor/node-addon-api/doc/threadsafe_function.md +290 -0
- package/vendor/node-addon-api/doc/type_error.md +59 -0
- package/vendor/node-addon-api/doc/typed_array.md +78 -0
- package/vendor/node-addon-api/doc/typed_array_of.md +137 -0
- package/vendor/node-addon-api/doc/typed_threadsafe_function.md +306 -0
- package/vendor/node-addon-api/doc/value.md +340 -0
- package/vendor/node-addon-api/doc/version_management.md +43 -0
- package/vendor/node-addon-api/package.json +415 -0
- package/vendor/node-addon-api/test/README.md +91 -0
- package/vendor/node-addon-api/test/addon.cc +36 -0
- package/vendor/node-addon-api/test/addon.js +11 -0
- package/vendor/node-addon-api/test/addon_build/index.js +49 -0
- package/vendor/node-addon-api/test/addon_build/tpl/addon.cc +17 -0
- package/vendor/node-addon-api/test/addon_build/tpl/binding.gyp +62 -0
- package/vendor/node-addon-api/test/addon_build/tpl/index.js +9 -0
- package/vendor/node-addon-api/test/addon_build/tpl/package.json +11 -0
- package/vendor/node-addon-api/test/addon_data.cc +99 -0
- package/vendor/node-addon-api/test/addon_data.js +46 -0
- package/vendor/node-addon-api/test/array_buffer.cc +243 -0
- package/vendor/node-addon-api/test/array_buffer.js +69 -0
- package/vendor/node-addon-api/test/async_context.cc +36 -0
- package/vendor/node-addon-api/test/async_context.js +122 -0
- package/vendor/node-addon-api/test/async_progress_queue_worker.cc +83 -0
- package/vendor/node-addon-api/test/async_progress_queue_worker.js +46 -0
- package/vendor/node-addon-api/test/async_progress_worker.cc +134 -0
- package/vendor/node-addon-api/test/async_progress_worker.js +61 -0
- package/vendor/node-addon-api/test/async_worker.cc +106 -0
- package/vendor/node-addon-api/test/async_worker.js +179 -0
- package/vendor/node-addon-api/test/async_worker_nocallback.js +13 -0
- package/vendor/node-addon-api/test/async_worker_persistent.cc +63 -0
- package/vendor/node-addon-api/test/async_worker_persistent.js +24 -0
- package/vendor/node-addon-api/test/basic_types/array.cc +40 -0
- package/vendor/node-addon-api/test/basic_types/array.js +35 -0
- package/vendor/node-addon-api/test/basic_types/boolean.cc +38 -0
- package/vendor/node-addon-api/test/basic_types/boolean.js +35 -0
- package/vendor/node-addon-api/test/basic_types/number.cc +99 -0
- package/vendor/node-addon-api/test/basic_types/number.js +114 -0
- package/vendor/node-addon-api/test/basic_types/value.cc +120 -0
- package/vendor/node-addon-api/test/basic_types/value.js +133 -0
- package/vendor/node-addon-api/test/bigint.cc +91 -0
- package/vendor/node-addon-api/test/bigint.js +53 -0
- package/vendor/node-addon-api/test/binding-swallowexcept.cc +12 -0
- package/vendor/node-addon-api/test/binding.cc +173 -0
- package/vendor/node-addon-api/test/binding.gyp +124 -0
- package/vendor/node-addon-api/test/buffer.cc +183 -0
- package/vendor/node-addon-api/test/buffer.js +69 -0
- package/vendor/node-addon-api/test/callbackscope.cc +22 -0
- package/vendor/node-addon-api/test/callbackscope.js +49 -0
- package/vendor/node-addon-api/test/common/index.js +114 -0
- package/vendor/node-addon-api/test/common/test_helper.h +71 -0
- package/vendor/node-addon-api/test/dataview/dataview.cc +48 -0
- package/vendor/node-addon-api/test/dataview/dataview.js +35 -0
- package/vendor/node-addon-api/test/dataview/dataview_read_write.cc +115 -0
- package/vendor/node-addon-api/test/dataview/dataview_read_write.js +90 -0
- package/vendor/node-addon-api/test/date.cc +44 -0
- package/vendor/node-addon-api/test/date.js +18 -0
- package/vendor/node-addon-api/test/env_cleanup.cc +88 -0
- package/vendor/node-addon-api/test/env_cleanup.js +56 -0
- package/vendor/node-addon-api/test/error.cc +287 -0
- package/vendor/node-addon-api/test/error.js +81 -0
- package/vendor/node-addon-api/test/error_handling_for_primitives.cc +13 -0
- package/vendor/node-addon-api/test/error_handling_for_primitives.js +29 -0
- package/vendor/node-addon-api/test/error_terminating_environment.js +95 -0
- package/vendor/node-addon-api/test/external.cc +81 -0
- package/vendor/node-addon-api/test/external.js +88 -0
- package/vendor/node-addon-api/test/function.cc +324 -0
- package/vendor/node-addon-api/test/function.js +133 -0
- package/vendor/node-addon-api/test/function_reference.cc +202 -0
- package/vendor/node-addon-api/test/function_reference.js +157 -0
- package/vendor/node-addon-api/test/globalObject/global_object.cc +61 -0
- package/vendor/node-addon-api/test/globalObject/global_object_delete_property.cc +31 -0
- package/vendor/node-addon-api/test/globalObject/global_object_delete_property.js +61 -0
- package/vendor/node-addon-api/test/globalObject/global_object_get_property.cc +40 -0
- package/vendor/node-addon-api/test/globalObject/global_object_get_property.js +57 -0
- package/vendor/node-addon-api/test/globalObject/global_object_has_own_property.cc +28 -0
- package/vendor/node-addon-api/test/globalObject/global_object_has_own_property.js +48 -0
- package/vendor/node-addon-api/test/globalObject/global_object_set_property.cc +31 -0
- package/vendor/node-addon-api/test/globalObject/global_object_set_property.js +58 -0
- package/vendor/node-addon-api/test/handlescope.cc +60 -0
- package/vendor/node-addon-api/test/handlescope.js +14 -0
- package/vendor/node-addon-api/test/index.js +159 -0
- package/vendor/node-addon-api/test/maybe/check.cc +23 -0
- package/vendor/node-addon-api/test/maybe/index.js +38 -0
- package/vendor/node-addon-api/test/memory_management.cc +17 -0
- package/vendor/node-addon-api/test/memory_management.js +9 -0
- package/vendor/node-addon-api/test/movable_callbacks.cc +23 -0
- package/vendor/node-addon-api/test/movable_callbacks.js +21 -0
- package/vendor/node-addon-api/test/name.cc +108 -0
- package/vendor/node-addon-api/test/name.js +59 -0
- package/vendor/node-addon-api/test/napi_child.js +14 -0
- package/vendor/node-addon-api/test/object/delete_property.cc +38 -0
- package/vendor/node-addon-api/test/object/delete_property.js +41 -0
- package/vendor/node-addon-api/test/object/finalizer.cc +29 -0
- package/vendor/node-addon-api/test/object/finalizer.js +28 -0
- package/vendor/node-addon-api/test/object/get_property.cc +34 -0
- package/vendor/node-addon-api/test/object/get_property.js +40 -0
- package/vendor/node-addon-api/test/object/has_own_property.cc +34 -0
- package/vendor/node-addon-api/test/object/has_own_property.js +34 -0
- package/vendor/node-addon-api/test/object/has_property.cc +38 -0
- package/vendor/node-addon-api/test/object/has_property.js +37 -0
- package/vendor/node-addon-api/test/object/object.cc +350 -0
- package/vendor/node-addon-api/test/object/object.js +217 -0
- package/vendor/node-addon-api/test/object/object_deprecated.cc +66 -0
- package/vendor/node-addon-api/test/object/object_deprecated.js +47 -0
- package/vendor/node-addon-api/test/object/object_freeze_seal.cc +25 -0
- package/vendor/node-addon-api/test/object/object_freeze_seal.js +61 -0
- package/vendor/node-addon-api/test/object/set_property.cc +45 -0
- package/vendor/node-addon-api/test/object/set_property.js +30 -0
- package/vendor/node-addon-api/test/object/subscript_operator.cc +58 -0
- package/vendor/node-addon-api/test/object/subscript_operator.js +17 -0
- package/vendor/node-addon-api/test/object_reference.cc +219 -0
- package/vendor/node-addon-api/test/object_reference.js +259 -0
- package/vendor/node-addon-api/test/objectwrap.cc +268 -0
- package/vendor/node-addon-api/test/objectwrap.js +284 -0
- package/vendor/node-addon-api/test/objectwrap_constructor_exception.cc +26 -0
- package/vendor/node-addon-api/test/objectwrap_constructor_exception.js +18 -0
- package/vendor/node-addon-api/test/objectwrap_function.cc +45 -0
- package/vendor/node-addon-api/test/objectwrap_function.js +22 -0
- package/vendor/node-addon-api/test/objectwrap_multiple_inheritance.cc +30 -0
- package/vendor/node-addon-api/test/objectwrap_multiple_inheritance.js +13 -0
- package/vendor/node-addon-api/test/objectwrap_removewrap.cc +45 -0
- package/vendor/node-addon-api/test/objectwrap_removewrap.js +40 -0
- package/vendor/node-addon-api/test/objectwrap_worker_thread.js +19 -0
- package/vendor/node-addon-api/test/promise.cc +29 -0
- package/vendor/node-addon-api/test/promise.js +18 -0
- package/vendor/node-addon-api/test/reference.cc +24 -0
- package/vendor/node-addon-api/test/reference.js +14 -0
- package/vendor/node-addon-api/test/run_script.cc +56 -0
- package/vendor/node-addon-api/test/run_script.js +45 -0
- package/vendor/node-addon-api/test/symbol.cc +79 -0
- package/vendor/node-addon-api/test/symbol.js +73 -0
- package/vendor/node-addon-api/test/testUtil.js +54 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function.cc +195 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function.js +188 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ctx.cc +63 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ctx.js +12 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_existing_tsfn.cc +115 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_existing_tsfn.js +14 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ptr.cc +26 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ptr.js +7 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_sum.cc +225 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_sum.js +59 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_unref.cc +42 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_unref.js +53 -0
- package/vendor/node-addon-api/test/thunking_manual.cc +140 -0
- package/vendor/node-addon-api/test/thunking_manual.js +17 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function.cc +215 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function.js +188 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ctx.cc +68 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ctx.js +12 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_existing_tsfn.cc +127 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_existing_tsfn.js +14 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ptr.cc +28 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ptr.js +7 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_sum.cc +237 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_sum.js +59 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_unref.cc +53 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_unref.js +53 -0
- package/vendor/node-addon-api/test/typedarray-bigint.js +58 -0
- package/vendor/node-addon-api/test/typedarray.cc +216 -0
- package/vendor/node-addon-api/test/typedarray.js +69 -0
- package/vendor/node-addon-api/test/version_management.cc +27 -0
- package/vendor/node-addon-api/test/version_management.js +31 -0
- package/vendor/node-addon-api/unit-test/README.md +28 -0
- package/vendor/node-addon-api/unit-test/binding-file-template.js +39 -0
- package/vendor/node-addon-api/unit-test/binding.gyp +72 -0
- package/vendor/node-addon-api/unit-test/exceptions.js +32 -0
- package/vendor/node-addon-api/unit-test/generate-binding-cc.js +61 -0
- package/vendor/node-addon-api/unit-test/injectTestParams.js +101 -0
- package/vendor/node-addon-api/unit-test/listOfTestModules.js +88 -0
- package/vendor/node-addon-api/unit-test/matchModules.js +65 -0
- package/vendor/node-addon-api/unit-test/setup.js +13 -0
- package/vendor/node-addon-api/unit-test/spawnTask.js +26 -0
- package/vendor/node-addon-api/unit-test/test.js +30 -0
- package/vendor/raylib/projects/VS2019/examples/audio_module_playing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/audio_multichannel_sound.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/audio_music_stream.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/audio_raw_stream.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/audio_sound_loading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_2d_camera.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_2d_camera_platformer.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_3d_camera_first_person.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_3d_camera_free.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_3d_camera_mode.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_3d_picking.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_basic_window.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_custom_logging.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_drop_files.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_input_gamepad.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_input_gestures.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_input_keys.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_input_mouse.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_input_mouse_wheel.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_input_multitouch.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_loading_thread.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_quat_conversion.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_random_values.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_scissor_test.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_split_screen.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_storage_values.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_vr_simulator.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_window_flags.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_window_letterbox.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/core_world_screen.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/easings_testbed.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/embedded_files_loading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/models_animation.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/models_billboard.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/models_box_collisions.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/models_cubicmap.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/models_first_person_maze.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/models_geometric_shapes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/models_heightmap.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/models_loading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/models_loading_gltf.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/models_loading_vox.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/models_mesh_generation.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/models_mesh_picking.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/models_orthographic_projection.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/models_rlgl_solar_system.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/models_skybox.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/models_waving_cubes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/models_yaw_pitch_roll.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/physics_demo.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/physics_friction.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/physics_movement.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/physics_restitution.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/physics_shatter.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/raudio_standalone.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/rlgl_standalone.vcxproj +391 -0
- package/vendor/raylib/projects/VS2019/examples/shaders_basic_lighting.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shaders_custom_uniform.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shaders_eratosthenes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shaders_fog.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shaders_hot_reloading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shaders_julia_set.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shaders_mesh_instancing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shaders_model_shader.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shaders_multi_sample2d.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shaders_palette_switch.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shaders_postprocessing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shaders_raymarching.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shaders_shapes_textures.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shaders_simple_mask.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shaders_spotlight.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shaders_texture_drawing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shaders_texture_waves.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shapes_basic_shapes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shapes_bouncing_ball.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shapes_collision_area.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shapes_colors_palette.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shapes_draw_circle_sector.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shapes_draw_rectangle_rounded.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shapes_draw_ring.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shapes_easings_ball_anim.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shapes_easings_box_anim.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shapes_easings_rectangle_array.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shapes_following_eyes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shapes_lines_bezier.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shapes_logo_raylib.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shapes_logo_raylib_anim.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/shapes_rectangle_scaling.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/text_font_filters.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/text_font_loading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/text_font_sdf.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/text_font_spritefont.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/text_format_text.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/text_input_box.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/text_raylib_fonts.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/text_rectangle_bounds.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/text_unicode.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/text_writing_anim.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/textures_background_scrolling.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/textures_blend_modes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/textures_bunnymark.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/textures_draw_tiled.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/textures_image_drawing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/textures_image_generation.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/textures_image_loading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/textures_image_processing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/textures_image_text.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/textures_logo_raylib.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/textures_mouse_painting.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/textures_npatch_drawing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/textures_particles_blending.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/textures_raw_data.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/textures_rectangle.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/textures_sprite_button.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/textures_sprite_explosion.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/textures_srcrec_dstrec.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/examples/textures_to_image.vcxproj +387 -0
- package/vendor/raylib/projects/VS2019/raylib/raylib.vcxproj +341 -0
- package/vendor/raylib/projects/VS2019/raylib.sln +2274 -0
- package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj +226 -0
- package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj.filters +10 -0
- package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj.user +4 -0
- package/vendor/raylib/projects/VS2019-Android/raylib_android.sln +75 -0
|
@@ -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,45 @@
|
|
|
1
|
+
#include <napi.h>
|
|
2
|
+
#include <unordered_map>
|
|
3
|
+
#include "test_helper.h"
|
|
4
|
+
|
|
5
|
+
class FunctionTest : public Napi::ObjectWrap<FunctionTest> {
|
|
6
|
+
public:
|
|
7
|
+
FunctionTest(const Napi::CallbackInfo& info)
|
|
8
|
+
: Napi::ObjectWrap<FunctionTest>(info) {}
|
|
9
|
+
|
|
10
|
+
static Napi::Value OnCalledAsFunction(const Napi::CallbackInfo& info) {
|
|
11
|
+
// If called with a "true" argument, throw an exeption to test the handling.
|
|
12
|
+
if (!info[0].IsUndefined() && MaybeUnwrap(info[0].ToBoolean())) {
|
|
13
|
+
NAPI_THROW(Napi::Error::New(info.Env(), "an exception"), Napi::Value());
|
|
14
|
+
}
|
|
15
|
+
// Otherwise, act as a factory.
|
|
16
|
+
std::vector<napi_value> args;
|
|
17
|
+
for (size_t i = 0; i < info.Length(); i++) args.push_back(info[i]);
|
|
18
|
+
return MaybeUnwrap(GetConstructor(info.Env()).New(args));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Constructor-per-env map in a static member because env.SetInstanceData()
|
|
22
|
+
// would interfere with Napi::Addon<T>
|
|
23
|
+
static std::unordered_map<napi_env, Napi::FunctionReference> constructors;
|
|
24
|
+
|
|
25
|
+
static void Initialize(Napi::Env env, Napi::Object exports) {
|
|
26
|
+
const char* name = "FunctionTest";
|
|
27
|
+
Napi::Function func = DefineClass(env, name, {});
|
|
28
|
+
constructors[env] = Napi::Persistent(func);
|
|
29
|
+
env.AddCleanupHook([env] { constructors.erase(env); });
|
|
30
|
+
exports.Set(name, func);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static Napi::Function GetConstructor(Napi::Env env) {
|
|
34
|
+
return constructors[env].Value();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
std::unordered_map<napi_env, Napi::FunctionReference>
|
|
39
|
+
FunctionTest::constructors;
|
|
40
|
+
|
|
41
|
+
Napi::Object InitObjectWrapFunction(Napi::Env env) {
|
|
42
|
+
Napi::Object exports = Napi::Object::New(env);
|
|
43
|
+
FunctionTest::Initialize(env, exports);
|
|
44
|
+
return exports;
|
|
45
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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 function',
|
|
9
|
+
() => {
|
|
10
|
+
const { FunctionTest } = binding.objectwrap_function;
|
|
11
|
+
const newConstructed = new FunctionTest();
|
|
12
|
+
const functionConstructed = FunctionTest();
|
|
13
|
+
assert(newConstructed instanceof FunctionTest);
|
|
14
|
+
assert(functionConstructed instanceof FunctionTest);
|
|
15
|
+
assert.throws(() => (FunctionTest(true)), /an exception/);
|
|
16
|
+
},
|
|
17
|
+
// Do on gc before returning.
|
|
18
|
+
() => {}
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
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
|
+
}
|