koffi 2.1.0-beta.1 → 2.1.0
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 +1 -1
- package/ChangeLog.md +18 -0
- package/build/qemu/2.1.0/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_win32_x64.tar.gz +0 -0
- package/doc/Makefile +1 -1
- package/doc/benchmarks.md +14 -14
- package/doc/benchmarks.xlsx +0 -0
- package/doc/conf.py +5 -0
- package/doc/functions.md +67 -1
- package/doc/index.rst +2 -2
- package/doc/make.bat +1 -1
- package/doc/static/perf_linux_20220812.png +0 -0
- package/doc/static/perf_windows_20220812.png +0 -0
- package/doc/templates/badges.html +1 -2
- package/doc/types.md +112 -159
- package/package.json +2 -1
- package/qemu/registry/machines.json +2 -2
- package/qemu/registry/sha256sum.txt +2 -2
- package/src/abi_arm32.cc +224 -150
- package/src/abi_arm64.cc +255 -103
- package/src/abi_riscv64.cc +144 -88
- package/src/abi_x64_sysv.cc +151 -89
- package/src/abi_x64_win.cc +150 -88
- package/src/abi_x86.cc +198 -115
- package/src/call.cc +310 -137
- package/src/call.hh +4 -4
- package/src/ffi.cc +64 -20
- package/src/ffi.hh +12 -0
- package/src/util.hh +0 -20
- package/test/callbacks.js +3 -3
- package/test/misc.c +45 -2
- package/test/sync.js +83 -2
- package/vendor/libcc/libcc.cc +75 -55
- package/vendor/libcc/libcc.hh +306 -255
- 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
- package/vendor/raylib/projects/VS2022/examples/audio_module_playing.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/audio_multichannel_sound.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/audio_music_stream.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/audio_raw_stream.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/audio_sound_loading.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/audio_stream_effects.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_2d_camera.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_2d_camera_mouse_zoom.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_2d_camera_platformer.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_3d_camera_first_person.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_3d_camera_free.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_3d_camera_mode.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_3d_picking.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_basic_screen_manager.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_basic_window.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_custom_frame_control.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_custom_logging.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_drop_files.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_input_gamepad.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_input_gestures.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_input_keys.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_input_mouse.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_input_mouse_wheel.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_input_multitouch.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_loading_thread.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_random_values.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_scissor_test.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_split_screen.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_storage_values.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_vr_simulator.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_window_flags.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_window_letterbox.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_window_should_close.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_world_screen.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/easings_testbed.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/embedded_files_loading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_animation.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_billboard.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_box_collisions.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_cubicmap.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_first_person_maze.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_geometric_shapes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_heightmap.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_loading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_loading_gltf.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_loading_vox.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_mesh_generation.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_mesh_picking.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_orthographic_projection.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_rlgl_solar_system.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_skybox.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_waving_cubes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_yaw_pitch_roll.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/rlgl_compute_shaders.vcxproj +391 -0
- package/vendor/raylib/projects/VS2022/examples/rlgl_standalone.vcxproj +391 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_basic_lighting.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_custom_uniform.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_eratosthenes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_fog.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_hot_reloading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_julia_set.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_mesh_instancing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_model_shader.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_multi_sample2d.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_palette_switch.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_postprocessing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_raymarching.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_shapes_textures.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_simple_mask.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_spotlight.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_texture_drawing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_texture_waves.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_basic_shapes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_bouncing_ball.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_collision_area.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_colors_palette.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_draw_circle_sector.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_draw_rectangle_rounded.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_draw_ring.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_easings_ball_anim.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_easings_box_anim.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_easings_rectangle_array.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_following_eyes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_lines_bezier.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_logo_raylib.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_logo_raylib_anim.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_rectangle_scaling.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_codepoints_loading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_draw_3d.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_font_filters.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_font_loading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_font_sdf.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_font_spritefont.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_format_text.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_input_box.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_raylib_fonts.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_rectangle_bounds.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_unicode.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_writing_anim.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_background_scrolling.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_blend_modes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_bunnymark.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_draw_tiled.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_fog_of_war.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_gif_player.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_image_drawing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_image_generation.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_image_loading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_image_processing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_image_text.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_logo_raylib.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_mouse_painting.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_npatch_drawing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_particles_blending.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_polygon.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_raw_data.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_sprite_anim.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_sprite_button.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_sprite_explosion.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_srcrec_dstrec.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_to_image.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/raylib/raylib.vcxproj +340 -0
- package/vendor/raylib/projects/VS2022/raylib.sln +2347 -0
- package/build/qemu/2.1.0-beta.1/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_win32_x64.tar.gz +0 -0
- package/doc/dist/doctrees/benchmarks.doctree +0 -0
- package/doc/dist/doctrees/changes.doctree +0 -0
- package/doc/dist/doctrees/contribute.doctree +0 -0
- package/doc/dist/doctrees/environment.pickle +0 -0
- package/doc/dist/doctrees/functions.doctree +0 -0
- package/doc/dist/doctrees/index.doctree +0 -0
- package/doc/dist/doctrees/memory.doctree +0 -0
- package/doc/dist/doctrees/platforms.doctree +0 -0
- package/doc/dist/doctrees/start.doctree +0 -0
- package/doc/dist/doctrees/types.doctree +0 -0
- package/doc/dist/html/.buildinfo +0 -4
- package/doc/dist/html/_sources/benchmarks.md.txt +0 -137
- package/doc/dist/html/_sources/changes.md.txt +0 -161
- package/doc/dist/html/_sources/contribute.md.txt +0 -127
- package/doc/dist/html/_sources/functions.md.txt +0 -355
- package/doc/dist/html/_sources/index.rst.txt +0 -39
- package/doc/dist/html/_sources/memory.md.txt +0 -32
- package/doc/dist/html/_sources/platforms.md.txt +0 -31
- package/doc/dist/html/_sources/start.md.txt +0 -100
- package/doc/dist/html/_sources/types.md.txt +0 -588
- package/doc/dist/html/_static/_sphinx_javascript_frameworks_compat.js +0 -134
- package/doc/dist/html/_static/basic.css +0 -932
- package/doc/dist/html/_static/bench_linux.png +0 -0
- package/doc/dist/html/_static/bench_windows.png +0 -0
- package/doc/dist/html/_static/custom.css +0 -22
- package/doc/dist/html/_static/debug.css +0 -69
- package/doc/dist/html/_static/doctools.js +0 -264
- package/doc/dist/html/_static/documentation_options.js +0 -14
- package/doc/dist/html/_static/file.png +0 -0
- package/doc/dist/html/_static/jquery-3.6.0.js +0 -10881
- package/doc/dist/html/_static/jquery.js +0 -2
- package/doc/dist/html/_static/language_data.js +0 -199
- package/doc/dist/html/_static/minus.png +0 -0
- package/doc/dist/html/_static/perf_linux_20220623.png +0 -0
- package/doc/dist/html/_static/perf_linux_20220623_2.png +0 -0
- package/doc/dist/html/_static/perf_linux_20220627.png +0 -0
- package/doc/dist/html/_static/perf_linux_20220628.png +0 -0
- package/doc/dist/html/_static/perf_windows_20220623.png +0 -0
- package/doc/dist/html/_static/perf_windows_20220623_2.png +0 -0
- package/doc/dist/html/_static/perf_windows_20220627.png +0 -0
- package/doc/dist/html/_static/perf_windows_20220628.png +0 -0
- package/doc/dist/html/_static/plus.png +0 -0
- package/doc/dist/html/_static/pygments.css +0 -252
- package/doc/dist/html/_static/scripts/furo-extensions.js +0 -0
- package/doc/dist/html/_static/scripts/furo.js +0 -3
- package/doc/dist/html/_static/scripts/furo.js.LICENSE.txt +0 -7
- package/doc/dist/html/_static/scripts/furo.js.map +0 -1
- package/doc/dist/html/_static/searchtools.js +0 -531
- package/doc/dist/html/_static/skeleton.css +0 -296
- package/doc/dist/html/_static/styles/furo-extensions.css +0 -2
- package/doc/dist/html/_static/styles/furo-extensions.css.map +0 -1
- package/doc/dist/html/_static/styles/furo.css +0 -2
- package/doc/dist/html/_static/styles/furo.css.map +0 -1
- package/doc/dist/html/_static/underscore-1.13.1.js +0 -2042
- package/doc/dist/html/_static/underscore.js +0 -6
- package/doc/dist/html/benchmarks.html +0 -572
- package/doc/dist/html/changes.html +0 -668
- package/doc/dist/html/contribute.html +0 -404
- package/doc/dist/html/functions.html +0 -657
- package/doc/dist/html/genindex.html +0 -254
- package/doc/dist/html/index.html +0 -360
- package/doc/dist/html/memory.html +0 -347
- package/doc/dist/html/objects.inv +0 -0
- package/doc/dist/html/platforms.html +0 -372
- package/doc/dist/html/search.html +0 -262
- package/doc/dist/html/searchindex.js +0 -1
- package/doc/dist/html/start.html +0 -385
- package/doc/dist/html/types.html +0 -1097
package/src/abi_arm64.cc
CHANGED
|
@@ -151,11 +151,17 @@ bool AnalyseFunction(Napi::Env, InstanceData *, FunctionInfo *func)
|
|
|
151
151
|
case PrimitiveKind::Int8:
|
|
152
152
|
case PrimitiveKind::UInt8:
|
|
153
153
|
case PrimitiveKind::Int16:
|
|
154
|
+
case PrimitiveKind::Int16S:
|
|
154
155
|
case PrimitiveKind::UInt16:
|
|
156
|
+
case PrimitiveKind::UInt16S:
|
|
155
157
|
case PrimitiveKind::Int32:
|
|
158
|
+
case PrimitiveKind::Int32S:
|
|
156
159
|
case PrimitiveKind::UInt32:
|
|
160
|
+
case PrimitiveKind::UInt32S:
|
|
157
161
|
case PrimitiveKind::Int64:
|
|
162
|
+
case PrimitiveKind::Int64S:
|
|
158
163
|
case PrimitiveKind::UInt64:
|
|
164
|
+
case PrimitiveKind::UInt64S:
|
|
159
165
|
case PrimitiveKind::String:
|
|
160
166
|
case PrimitiveKind::String16:
|
|
161
167
|
case PrimitiveKind::Pointer:
|
|
@@ -259,6 +265,64 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
259
265
|
gpr_ptr[8] = (uint64_t)return_ptr;
|
|
260
266
|
}
|
|
261
267
|
|
|
268
|
+
#ifdef __APPLE__
|
|
269
|
+
#define PUSH_INTEGER(CType) \
|
|
270
|
+
do { \
|
|
271
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
272
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
273
|
+
return false; \
|
|
274
|
+
} \
|
|
275
|
+
\
|
|
276
|
+
CType v = CopyNumber<CType>(value); \
|
|
277
|
+
\
|
|
278
|
+
if (RG_LIKELY(param.gpr_count)) { \
|
|
279
|
+
*(gpr_ptr++) = (uint64_t)v; \
|
|
280
|
+
} else { \
|
|
281
|
+
args_ptr = AlignUp(args_ptr, param.type->align); \
|
|
282
|
+
*args_ptr = (uint64_t)v; \
|
|
283
|
+
args_ptr = (uint64_t *)((uint8_t *)args_ptr + param.type->size); \
|
|
284
|
+
} \
|
|
285
|
+
} while (false)
|
|
286
|
+
#define PUSH_INTEGER_SWAP(CType) \
|
|
287
|
+
do { \
|
|
288
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
289
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
290
|
+
return false; \
|
|
291
|
+
} \
|
|
292
|
+
\
|
|
293
|
+
CType v = CopyNumber<CType>(value); \
|
|
294
|
+
\
|
|
295
|
+
if (RG_LIKELY(param.gpr_count)) { \
|
|
296
|
+
*(gpr_ptr++) = (uint64_t)ReverseBytes(v); \
|
|
297
|
+
} else { \
|
|
298
|
+
args_ptr = AlignUp(args_ptr, param.type->align); \
|
|
299
|
+
*args_ptr = (uint64_t)ReverseBytes(v); \
|
|
300
|
+
args_ptr = (uint64_t *)((uint8_t *)args_ptr + param.type->size); \
|
|
301
|
+
} \
|
|
302
|
+
} while (false)
|
|
303
|
+
#else
|
|
304
|
+
#define PUSH_INTEGER(CType) \
|
|
305
|
+
do { \
|
|
306
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
307
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
308
|
+
return false; \
|
|
309
|
+
} \
|
|
310
|
+
\
|
|
311
|
+
CType v = CopyNumber<CType>(value); \
|
|
312
|
+
*((param.gpr_count ? gpr_ptr : args_ptr)++) = (uint64_t)v; \
|
|
313
|
+
} while (false)
|
|
314
|
+
#define PUSH_INTEGER_SWAP(CType) \
|
|
315
|
+
do { \
|
|
316
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
317
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
318
|
+
return false; \
|
|
319
|
+
} \
|
|
320
|
+
\
|
|
321
|
+
CType v = CopyNumber<CType>(value); \
|
|
322
|
+
*((param.gpr_count ? gpr_ptr : args_ptr)++) = (uint64_t)ReverseBytes(v); \
|
|
323
|
+
} while (false)
|
|
324
|
+
#endif
|
|
325
|
+
|
|
262
326
|
// Push arguments
|
|
263
327
|
for (Size i = 0; i < func->parameters.len; i++) {
|
|
264
328
|
const ParameterInfo ¶m = func->parameters[i];
|
|
@@ -271,7 +335,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
271
335
|
|
|
272
336
|
case PrimitiveKind::Bool: {
|
|
273
337
|
if (RG_UNLIKELY(!value.IsBoolean())) {
|
|
274
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
338
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected boolean", GetValueType(instance, value));
|
|
275
339
|
return false;
|
|
276
340
|
}
|
|
277
341
|
|
|
@@ -288,57 +352,24 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
288
352
|
*((param.gpr_count ? gpr_ptr : args_ptr)++) = (uint64_t)b;
|
|
289
353
|
#endif
|
|
290
354
|
} break;
|
|
291
|
-
case PrimitiveKind::Int8:
|
|
292
|
-
case PrimitiveKind::UInt8:
|
|
293
|
-
case PrimitiveKind::Int16:
|
|
294
|
-
case PrimitiveKind::
|
|
295
|
-
case PrimitiveKind::
|
|
296
|
-
case PrimitiveKind::
|
|
297
|
-
case PrimitiveKind::
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
#ifdef __APPLE__
|
|
306
|
-
if (RG_LIKELY(param.gpr_count)) {
|
|
307
|
-
*(int64_t *)(gpr_ptr++) = v;
|
|
308
|
-
} else {
|
|
309
|
-
args_ptr = AlignUp(args_ptr, param.type->align);
|
|
310
|
-
*(int64_t *)args_ptr = v;
|
|
311
|
-
args_ptr = (uint64_t *)((uint8_t *)args_ptr + param.type->size);
|
|
312
|
-
}
|
|
313
|
-
#else
|
|
314
|
-
*(int64_t *)((param.gpr_count ? gpr_ptr : args_ptr)++) = v;
|
|
315
|
-
#endif
|
|
316
|
-
} break;
|
|
317
|
-
case PrimitiveKind::UInt64: {
|
|
318
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
319
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
320
|
-
return false;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
uint64_t v = CopyNumber<uint64_t>(value);
|
|
324
|
-
|
|
325
|
-
#ifdef __APPLE__
|
|
326
|
-
args_ptr = param.gpr_count ? args_ptr : AlignUp(args_ptr, 8);
|
|
327
|
-
#endif
|
|
328
|
-
*((param.gpr_count ? gpr_ptr : args_ptr)++) = v;
|
|
329
|
-
} break;
|
|
355
|
+
case PrimitiveKind::Int8: { PUSH_INTEGER(int8_t); } break;
|
|
356
|
+
case PrimitiveKind::UInt8: { PUSH_INTEGER(uint8_t); } break;
|
|
357
|
+
case PrimitiveKind::Int16: { PUSH_INTEGER(int16_t); } break;
|
|
358
|
+
case PrimitiveKind::Int16S: { PUSH_INTEGER_SWAP(int16_t); } break;
|
|
359
|
+
case PrimitiveKind::UInt16: { PUSH_INTEGER(uint16_t); } break;
|
|
360
|
+
case PrimitiveKind::UInt16S: { PUSH_INTEGER_SWAP(uint16_t); } break;
|
|
361
|
+
case PrimitiveKind::Int32: { PUSH_INTEGER(int32_t); } break;
|
|
362
|
+
case PrimitiveKind::Int32S: { PUSH_INTEGER_SWAP(int32_t); } break;
|
|
363
|
+
case PrimitiveKind::UInt32: { PUSH_INTEGER(uint32_t); } break;
|
|
364
|
+
case PrimitiveKind::UInt32S: { PUSH_INTEGER_SWAP(uint32_t); } break;
|
|
365
|
+
case PrimitiveKind::Int64: { PUSH_INTEGER(int64_t); } break;
|
|
366
|
+
case PrimitiveKind::Int64S: { PUSH_INTEGER_SWAP(int64_t); } break;
|
|
367
|
+
case PrimitiveKind::UInt64: { PUSH_INTEGER(uint64_t); } break;
|
|
368
|
+
case PrimitiveKind::UInt64S: { PUSH_INTEGER_SWAP(uint64_t); } break;
|
|
330
369
|
case PrimitiveKind::String: {
|
|
331
370
|
const char *str;
|
|
332
|
-
if (
|
|
333
|
-
str = PushString(value);
|
|
334
|
-
if (RG_UNLIKELY(!str))
|
|
335
|
-
return false;
|
|
336
|
-
} else if (IsNullOrUndefined(value)) {
|
|
337
|
-
str = nullptr;
|
|
338
|
-
} else {
|
|
339
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected string", GetValueType(instance, value), param.offset + 1);
|
|
371
|
+
if (RG_UNLIKELY(!PushString(value, &str)))
|
|
340
372
|
return false;
|
|
341
|
-
}
|
|
342
373
|
|
|
343
374
|
#ifdef __APPLE__
|
|
344
375
|
args_ptr = param.gpr_count ? args_ptr : AlignUp(args_ptr, 8);
|
|
@@ -347,16 +378,8 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
347
378
|
} break;
|
|
348
379
|
case PrimitiveKind::String16: {
|
|
349
380
|
const char16_t *str16;
|
|
350
|
-
if (
|
|
351
|
-
str16 = PushString16(value);
|
|
352
|
-
if (RG_UNLIKELY(!str16))
|
|
353
|
-
return false;
|
|
354
|
-
} else if (IsNullOrUndefined(value)) {
|
|
355
|
-
str16 = nullptr;
|
|
356
|
-
} else {
|
|
357
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected string", GetValueType(instance, value), param.offset + 1);
|
|
381
|
+
if (RG_UNLIKELY(!PushString16(value, &str16)))
|
|
358
382
|
return false;
|
|
359
|
-
}
|
|
360
383
|
|
|
361
384
|
#ifdef __APPLE__
|
|
362
385
|
args_ptr = param.gpr_count ? args_ptr : AlignUp(args_ptr, 8);
|
|
@@ -365,7 +388,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
365
388
|
} break;
|
|
366
389
|
case PrimitiveKind::Pointer: {
|
|
367
390
|
void *ptr;
|
|
368
|
-
if (RG_UNLIKELY(!PushPointer(value, param, &ptr)))
|
|
391
|
+
if (RG_UNLIKELY(!PushPointer(value, param.type, param.directions, &ptr)))
|
|
369
392
|
return false;
|
|
370
393
|
|
|
371
394
|
#ifdef __APPLE__
|
|
@@ -375,7 +398,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
375
398
|
} break;
|
|
376
399
|
case PrimitiveKind::Record: {
|
|
377
400
|
if (RG_UNLIKELY(!IsObject(value))) {
|
|
378
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
401
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected object", GetValueType(instance, value));
|
|
379
402
|
return false;
|
|
380
403
|
}
|
|
381
404
|
|
|
@@ -422,7 +445,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
422
445
|
case PrimitiveKind::Array: { RG_UNREACHABLE(); } break;
|
|
423
446
|
case PrimitiveKind::Float32: {
|
|
424
447
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
425
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
448
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
|
|
426
449
|
return false;
|
|
427
450
|
}
|
|
428
451
|
|
|
@@ -449,7 +472,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
449
472
|
} break;
|
|
450
473
|
case PrimitiveKind::Float64: {
|
|
451
474
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
452
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
475
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
|
|
453
476
|
return false;
|
|
454
477
|
}
|
|
455
478
|
|
|
@@ -482,7 +505,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
482
505
|
} else if (IsNullOrUndefined(value)) {
|
|
483
506
|
ptr = nullptr;
|
|
484
507
|
} else {
|
|
485
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
508
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected %2", GetValueType(instance, value), param.type->name);
|
|
486
509
|
return false;
|
|
487
510
|
}
|
|
488
511
|
|
|
@@ -496,6 +519,9 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
496
519
|
}
|
|
497
520
|
}
|
|
498
521
|
|
|
522
|
+
#undef PUSH_INTEGER_SWAP
|
|
523
|
+
#undef PUSH_INTEGER
|
|
524
|
+
|
|
499
525
|
new_sp = mem->stack.end();
|
|
500
526
|
|
|
501
527
|
return true;
|
|
@@ -519,11 +545,17 @@ void CallData::Execute()
|
|
|
519
545
|
case PrimitiveKind::Int8:
|
|
520
546
|
case PrimitiveKind::UInt8:
|
|
521
547
|
case PrimitiveKind::Int16:
|
|
548
|
+
case PrimitiveKind::Int16S:
|
|
522
549
|
case PrimitiveKind::UInt16:
|
|
550
|
+
case PrimitiveKind::UInt16S:
|
|
523
551
|
case PrimitiveKind::Int32:
|
|
552
|
+
case PrimitiveKind::Int32S:
|
|
524
553
|
case PrimitiveKind::UInt32:
|
|
554
|
+
case PrimitiveKind::UInt32S:
|
|
525
555
|
case PrimitiveKind::Int64:
|
|
556
|
+
case PrimitiveKind::Int64S:
|
|
526
557
|
case PrimitiveKind::UInt64:
|
|
558
|
+
case PrimitiveKind::UInt64S:
|
|
527
559
|
case PrimitiveKind::String:
|
|
528
560
|
case PrimitiveKind::String16:
|
|
529
561
|
case PrimitiveKind::Pointer:
|
|
@@ -565,11 +597,17 @@ Napi::Value CallData::Complete()
|
|
|
565
597
|
case PrimitiveKind::Int8: return Napi::Number::New(env, (double)result.i8);
|
|
566
598
|
case PrimitiveKind::UInt8: return Napi::Number::New(env, (double)result.u8);
|
|
567
599
|
case PrimitiveKind::Int16: return Napi::Number::New(env, (double)result.i16);
|
|
600
|
+
case PrimitiveKind::Int16S: return Napi::Number::New(env, (double)ReverseBytes(result.i16));
|
|
568
601
|
case PrimitiveKind::UInt16: return Napi::Number::New(env, (double)result.u16);
|
|
602
|
+
case PrimitiveKind::UInt16S: return Napi::Number::New(env, (double)ReverseBytes(result.u16));
|
|
569
603
|
case PrimitiveKind::Int32: return Napi::Number::New(env, (double)result.i32);
|
|
604
|
+
case PrimitiveKind::Int32S: return Napi::Number::New(env, (double)ReverseBytes(result.i32));
|
|
570
605
|
case PrimitiveKind::UInt32: return Napi::Number::New(env, (double)result.u32);
|
|
606
|
+
case PrimitiveKind::UInt32S: return Napi::Number::New(env, (double)ReverseBytes(result.u32));
|
|
571
607
|
case PrimitiveKind::Int64: return NewBigInt(env, result.i64);
|
|
608
|
+
case PrimitiveKind::Int64S: return NewBigInt(env, ReverseBytes(result.i64));
|
|
572
609
|
case PrimitiveKind::UInt64: return NewBigInt(env, result.u64);
|
|
610
|
+
case PrimitiveKind::UInt64S: return NewBigInt(env, ReverseBytes(result.u64));
|
|
573
611
|
case PrimitiveKind::String: return result.ptr ? Napi::String::New(env, (const char *)result.ptr) : env.Null();
|
|
574
612
|
case PrimitiveKind::String16: return result.ptr ? Napi::String::New(env, (const char16_t *)result.ptr) : env.Null();
|
|
575
613
|
case PrimitiveKind::Pointer:
|
|
@@ -703,6 +741,28 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
703
741
|
Napi::Value arg = Napi::Number::New(env, d);
|
|
704
742
|
arguments.Append(arg);
|
|
705
743
|
} break;
|
|
744
|
+
case PrimitiveKind::Int16S: {
|
|
745
|
+
#ifdef __APPLE__
|
|
746
|
+
double d;
|
|
747
|
+
if (param.gpr_count) {
|
|
748
|
+
int16_t v = *(int16_t *)(gpr_ptr++);
|
|
749
|
+
d = (double)ReverseBytes(v);
|
|
750
|
+
} else {
|
|
751
|
+
args_ptr = AlignUp(args_ptr, 2);
|
|
752
|
+
|
|
753
|
+
int16_t v = *(int16_t *)args_ptr;
|
|
754
|
+
d = (double)ReverseBytes(v);
|
|
755
|
+
|
|
756
|
+
args_ptr = (uint64_t *)((uint8_t *)args_ptr + 2);
|
|
757
|
+
}
|
|
758
|
+
#else
|
|
759
|
+
int16_t v = *(int16_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
760
|
+
double d = (double)ReverseBytes(v);
|
|
761
|
+
#endif
|
|
762
|
+
|
|
763
|
+
Napi::Value arg = Napi::Number::New(env, d);
|
|
764
|
+
arguments.Append(arg);
|
|
765
|
+
} break;
|
|
706
766
|
case PrimitiveKind::UInt16: {
|
|
707
767
|
#ifdef __APPLE__
|
|
708
768
|
double d;
|
|
@@ -720,6 +780,28 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
720
780
|
Napi::Value arg = Napi::Number::New(env, d);
|
|
721
781
|
arguments.Append(arg);
|
|
722
782
|
} break;
|
|
783
|
+
case PrimitiveKind::UInt16S: {
|
|
784
|
+
#ifdef __APPLE__
|
|
785
|
+
double d;
|
|
786
|
+
if (param.gpr_count) {
|
|
787
|
+
uint16_t v = *(uint16_t *)(gpr_ptr++);
|
|
788
|
+
d = (double)ReverseBytes(v);
|
|
789
|
+
} else {
|
|
790
|
+
args_ptr = AlignUp(args_ptr, 2);
|
|
791
|
+
|
|
792
|
+
uint16_t v = *(uint16_t *)args_ptr;
|
|
793
|
+
d = (double)ReverseBytes(v);
|
|
794
|
+
|
|
795
|
+
args_ptr = (uint64_t *)((uint8_t *)args_ptr + 2);
|
|
796
|
+
}
|
|
797
|
+
#else
|
|
798
|
+
uint16_t v = *(uint16_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
799
|
+
double d = (double)ReverseBytes(v);
|
|
800
|
+
#endif
|
|
801
|
+
|
|
802
|
+
Napi::Value arg = Napi::Number::New(env, d);
|
|
803
|
+
arguments.Append(arg);
|
|
804
|
+
} break;
|
|
723
805
|
case PrimitiveKind::Int32: {
|
|
724
806
|
#ifdef __APPLE__
|
|
725
807
|
double d;
|
|
@@ -737,6 +819,28 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
737
819
|
Napi::Value arg = Napi::Number::New(env, d);
|
|
738
820
|
arguments.Append(arg);
|
|
739
821
|
} break;
|
|
822
|
+
case PrimitiveKind::Int32S: {
|
|
823
|
+
#ifdef __APPLE__
|
|
824
|
+
double d;
|
|
825
|
+
if (param.gpr_count) {
|
|
826
|
+
int32_t v = *(int32_t *)(gpr_ptr++);
|
|
827
|
+
d = (double)ReverseBytes(v);
|
|
828
|
+
} else {
|
|
829
|
+
args_ptr = AlignUp(args_ptr, 4);
|
|
830
|
+
|
|
831
|
+
int32_t v = *(int32_t *)args_ptr;
|
|
832
|
+
d = (double)ReverseBytes(v);
|
|
833
|
+
|
|
834
|
+
args_ptr = (uint64_t *)((uint8_t *)args_ptr + 4);
|
|
835
|
+
}
|
|
836
|
+
#else
|
|
837
|
+
int32_t v = *(int32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
838
|
+
double d = (double)ReverseBytes(v);
|
|
839
|
+
#endif
|
|
840
|
+
|
|
841
|
+
Napi::Value arg = Napi::Number::New(env, d);
|
|
842
|
+
arguments.Append(arg);
|
|
843
|
+
} break;
|
|
740
844
|
case PrimitiveKind::UInt32: {
|
|
741
845
|
#ifdef __APPLE__
|
|
742
846
|
double d;
|
|
@@ -754,6 +858,28 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
754
858
|
Napi::Value arg = Napi::Number::New(env, d);
|
|
755
859
|
arguments.Append(arg);
|
|
756
860
|
} break;
|
|
861
|
+
case PrimitiveKind::UInt32S: {
|
|
862
|
+
#ifdef __APPLE__
|
|
863
|
+
double d;
|
|
864
|
+
if (param.gpr_count) {
|
|
865
|
+
uint32_t v = *(uint32_t *)(gpr_ptr++);
|
|
866
|
+
d = (double)ReverseBytes(v);
|
|
867
|
+
} else {
|
|
868
|
+
args_ptr = AlignUp(args_ptr, 4);
|
|
869
|
+
|
|
870
|
+
uint32_t v = *(uint32_t *)args_ptr;
|
|
871
|
+
d = (double)ReverseBytes(v);
|
|
872
|
+
|
|
873
|
+
args_ptr = (uint64_t *)((uint8_t *)args_ptr + 4);
|
|
874
|
+
}
|
|
875
|
+
#else
|
|
876
|
+
uint32_t v = *(uint32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
877
|
+
double d = (double)ReverseBytes(v);
|
|
878
|
+
#endif
|
|
879
|
+
|
|
880
|
+
Napi::Value arg = Napi::Number::New(env, d);
|
|
881
|
+
arguments.Append(arg);
|
|
882
|
+
} break;
|
|
757
883
|
case PrimitiveKind::Int64: {
|
|
758
884
|
#ifdef __APPLE__
|
|
759
885
|
args_ptr = AlignUp(args_ptr, 8);
|
|
@@ -764,6 +890,16 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
764
890
|
Napi::Value arg = NewBigInt(env, v);
|
|
765
891
|
arguments.Append(arg);
|
|
766
892
|
} break;
|
|
893
|
+
case PrimitiveKind::Int64S: {
|
|
894
|
+
#ifdef __APPLE__
|
|
895
|
+
args_ptr = AlignUp(args_ptr, 8);
|
|
896
|
+
#endif
|
|
897
|
+
|
|
898
|
+
int64_t v = *(int64_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
899
|
+
|
|
900
|
+
Napi::Value arg = NewBigInt(env, ReverseBytes(v));
|
|
901
|
+
arguments.Append(arg);
|
|
902
|
+
} break;
|
|
767
903
|
case PrimitiveKind::UInt64: {
|
|
768
904
|
#ifdef __APPLE__
|
|
769
905
|
args_ptr = AlignUp(args_ptr, 8);
|
|
@@ -774,6 +910,16 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
774
910
|
Napi::Value arg = NewBigInt(env, v);
|
|
775
911
|
arguments.Append(arg);
|
|
776
912
|
} break;
|
|
913
|
+
case PrimitiveKind::UInt64S: {
|
|
914
|
+
#ifdef __APPLE__
|
|
915
|
+
args_ptr = AlignUp(args_ptr, 8);
|
|
916
|
+
#endif
|
|
917
|
+
|
|
918
|
+
uint64_t v = *(uint64_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
919
|
+
|
|
920
|
+
Napi::Value arg = NewBigInt(env, ReverseBytes(v));
|
|
921
|
+
arguments.Append(arg);
|
|
922
|
+
} break;
|
|
777
923
|
case PrimitiveKind::String: {
|
|
778
924
|
#ifdef __APPLE__
|
|
779
925
|
args_ptr = AlignUp(args_ptr, 8);
|
|
@@ -912,61 +1058,64 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
912
1058
|
if (RG_UNLIKELY(env.IsExceptionPending()))
|
|
913
1059
|
return;
|
|
914
1060
|
|
|
1061
|
+
#define RETURN_INTEGER(CType) \
|
|
1062
|
+
do { \
|
|
1063
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
1064
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
1065
|
+
return; \
|
|
1066
|
+
} \
|
|
1067
|
+
\
|
|
1068
|
+
CType v = CopyNumber<CType>(value); \
|
|
1069
|
+
out_reg->x0 = (uint64_t)v; \
|
|
1070
|
+
} while (false)
|
|
1071
|
+
#define RETURN_INTEGER_SWAP(CType) \
|
|
1072
|
+
do { \
|
|
1073
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
1074
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
1075
|
+
return; \
|
|
1076
|
+
} \
|
|
1077
|
+
\
|
|
1078
|
+
CType v = CopyNumber<CType>(value); \
|
|
1079
|
+
out_reg->x0 = (uint64_t)ReverseBytes(v); \
|
|
1080
|
+
} while (false)
|
|
1081
|
+
|
|
915
1082
|
// Convert the result
|
|
916
1083
|
switch (type->primitive) {
|
|
917
1084
|
case PrimitiveKind::Void: {} break;
|
|
918
1085
|
case PrimitiveKind::Bool: {
|
|
919
1086
|
if (RG_UNLIKELY(!value.IsBoolean())) {
|
|
920
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
1087
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected boolean", GetValueType(instance, value));
|
|
921
1088
|
return;
|
|
922
1089
|
}
|
|
923
1090
|
|
|
924
1091
|
bool b = value.As<Napi::Boolean>();
|
|
925
1092
|
out_reg->x0 = (uint64_t)b;
|
|
926
1093
|
} break;
|
|
927
|
-
case PrimitiveKind::Int8:
|
|
928
|
-
case PrimitiveKind::UInt8:
|
|
929
|
-
case PrimitiveKind::Int16:
|
|
930
|
-
case PrimitiveKind::
|
|
931
|
-
case PrimitiveKind::
|
|
932
|
-
case PrimitiveKind::
|
|
933
|
-
case PrimitiveKind::
|
|
934
|
-
case PrimitiveKind::
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
out_reg->x0 = (uint64_t)v;
|
|
942
|
-
} break;
|
|
1094
|
+
case PrimitiveKind::Int8: { RETURN_INTEGER(int8_t); } break;
|
|
1095
|
+
case PrimitiveKind::UInt8: { RETURN_INTEGER(uint8_t); } break;
|
|
1096
|
+
case PrimitiveKind::Int16: { RETURN_INTEGER(int16_t); } break;
|
|
1097
|
+
case PrimitiveKind::Int16S: { RETURN_INTEGER_SWAP(int16_t); } break;
|
|
1098
|
+
case PrimitiveKind::UInt16: { RETURN_INTEGER(uint16_t); } break;
|
|
1099
|
+
case PrimitiveKind::UInt16S: { RETURN_INTEGER_SWAP(uint16_t); } break;
|
|
1100
|
+
case PrimitiveKind::Int32: { RETURN_INTEGER(int32_t); } break;
|
|
1101
|
+
case PrimitiveKind::Int32S: { RETURN_INTEGER_SWAP(int32_t); } break;
|
|
1102
|
+
case PrimitiveKind::UInt32: { RETURN_INTEGER(uint32_t); } break;
|
|
1103
|
+
case PrimitiveKind::UInt32S: { RETURN_INTEGER_SWAP(uint32_t); } break;
|
|
1104
|
+
case PrimitiveKind::Int64: { RETURN_INTEGER(int64_t); } break;
|
|
1105
|
+
case PrimitiveKind::Int64S: { RETURN_INTEGER_SWAP(int64_t); } break;
|
|
1106
|
+
case PrimitiveKind::UInt64: { RETURN_INTEGER(uint64_t); } break;
|
|
1107
|
+
case PrimitiveKind::UInt64S: { RETURN_INTEGER_SWAP(uint64_t); } break;
|
|
943
1108
|
case PrimitiveKind::String: {
|
|
944
1109
|
const char *str;
|
|
945
|
-
if (
|
|
946
|
-
str = PushString(value);
|
|
947
|
-
if (RG_UNLIKELY(!str))
|
|
948
|
-
return;
|
|
949
|
-
} else if (IsNullOrUndefined(value)) {
|
|
950
|
-
str = nullptr;
|
|
951
|
-
} else {
|
|
952
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected string", GetValueType(instance, value));
|
|
1110
|
+
if (RG_UNLIKELY(!PushString(value, &str)))
|
|
953
1111
|
return;
|
|
954
|
-
}
|
|
955
1112
|
|
|
956
1113
|
out_reg->x0 = (uint64_t)str;
|
|
957
1114
|
} break;
|
|
958
1115
|
case PrimitiveKind::String16: {
|
|
959
1116
|
const char16_t *str16;
|
|
960
|
-
if (
|
|
961
|
-
str16 = PushString16(value);
|
|
962
|
-
if (RG_UNLIKELY(!str16))
|
|
963
|
-
return;
|
|
964
|
-
} else if (IsNullOrUndefined(value)) {
|
|
965
|
-
str16 = nullptr;
|
|
966
|
-
} else {
|
|
967
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected string", GetValueType(instance, value));
|
|
1117
|
+
if (RG_UNLIKELY(!PushString16(value, &str16)))
|
|
968
1118
|
return;
|
|
969
|
-
}
|
|
970
1119
|
|
|
971
1120
|
out_reg->x0 = (uint64_t)str16;
|
|
972
1121
|
} break;
|
|
@@ -985,7 +1134,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
985
1134
|
} else if (IsNullOrUndefined(value)) {
|
|
986
1135
|
ptr = nullptr;
|
|
987
1136
|
} else {
|
|
988
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
1137
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected %2", GetValueType(instance, value), type->name);
|
|
989
1138
|
return;
|
|
990
1139
|
}
|
|
991
1140
|
|
|
@@ -993,7 +1142,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
993
1142
|
} break;
|
|
994
1143
|
case PrimitiveKind::Record: {
|
|
995
1144
|
if (RG_UNLIKELY(!IsObject(value))) {
|
|
996
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
1145
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected object", GetValueType(instance, value));
|
|
997
1146
|
return;
|
|
998
1147
|
}
|
|
999
1148
|
|
|
@@ -1012,7 +1161,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
1012
1161
|
case PrimitiveKind::Array: { RG_UNREACHABLE(); } break;
|
|
1013
1162
|
case PrimitiveKind::Float32: {
|
|
1014
1163
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
1015
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
1164
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
|
|
1016
1165
|
return;
|
|
1017
1166
|
}
|
|
1018
1167
|
|
|
@@ -1023,7 +1172,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
1023
1172
|
} break;
|
|
1024
1173
|
case PrimitiveKind::Float64: {
|
|
1025
1174
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
1026
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
1175
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
|
|
1027
1176
|
return;
|
|
1028
1177
|
}
|
|
1029
1178
|
|
|
@@ -1044,7 +1193,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
1044
1193
|
} else if (IsNullOrUndefined(value)) {
|
|
1045
1194
|
ptr = nullptr;
|
|
1046
1195
|
} else {
|
|
1047
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
1196
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected %2", GetValueType(instance, value), type->name);
|
|
1048
1197
|
return;
|
|
1049
1198
|
}
|
|
1050
1199
|
|
|
@@ -1054,6 +1203,9 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
1054
1203
|
case PrimitiveKind::Prototype: { RG_UNREACHABLE(); } break;
|
|
1055
1204
|
}
|
|
1056
1205
|
|
|
1206
|
+
#undef RETURN_INTEGER_SWAP
|
|
1207
|
+
#undef RETURN_INTEGER
|
|
1208
|
+
|
|
1057
1209
|
err_guard.Disable();
|
|
1058
1210
|
}
|
|
1059
1211
|
|