koffi 2.1.0-beta.2 → 2.1.1
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/ChangeLog.md +11 -4
- package/build/qemu/2.1.1/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/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/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 -1
- package/doc/types.md +12 -12
- package/package.json +2 -1
- package/qemu/registry/machines.json +2 -2
- package/qemu/registry/sha256sum.txt +2 -2
- package/src/abi_arm32.cc +158 -248
- package/src/abi_arm64.cc +129 -170
- package/src/abi_riscv64.cc +92 -140
- package/src/abi_x64_sysv.cc +92 -140
- package/src/abi_x64_win.cc +92 -140
- package/src/abi_x86.cc +144 -212
- package/src/call.cc +117 -143
- package/src/call.hh +4 -4
- package/src/ffi.cc +16 -4
- 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 +97 -77
- package/vendor/libcc/libcc.hh +362 -259
- 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.2/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/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/_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_20220627.png +0 -0
- package/doc/dist/html/_static/perf_windows_20220628.png +0 -0
package/src/abi_x64_sysv.cc
CHANGED
|
@@ -304,6 +304,27 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
304
304
|
*(uint8_t **)(gpr_ptr++) = return_ptr;
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
+
#define PUSH_INTEGER(CType) \
|
|
308
|
+
do { \
|
|
309
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
310
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
311
|
+
return false; \
|
|
312
|
+
} \
|
|
313
|
+
\
|
|
314
|
+
CType v = CopyNumber<CType>(value); \
|
|
315
|
+
*((param.gpr_count ? gpr_ptr : args_ptr)++) = (uint64_t)v; \
|
|
316
|
+
} while (false)
|
|
317
|
+
#define PUSH_INTEGER_SWAP(CType) \
|
|
318
|
+
do { \
|
|
319
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
320
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
321
|
+
return false; \
|
|
322
|
+
} \
|
|
323
|
+
\
|
|
324
|
+
CType v = CopyNumber<CType>(value); \
|
|
325
|
+
*((param.gpr_count ? gpr_ptr : args_ptr)++) = (uint64_t)ReverseBytes(v); \
|
|
326
|
+
} while (false)
|
|
327
|
+
|
|
307
328
|
// Push arguments
|
|
308
329
|
for (Size i = 0; i < func->parameters.len; i++) {
|
|
309
330
|
const ParameterInfo ¶m = func->parameters[i];
|
|
@@ -316,99 +337,51 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
316
337
|
|
|
317
338
|
case PrimitiveKind::Bool: {
|
|
318
339
|
if (RG_UNLIKELY(!value.IsBoolean())) {
|
|
319
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argmument %2, expected boolean", GetValueType(instance, value)
|
|
340
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argmument %2, expected boolean", GetValueType(instance, value));
|
|
320
341
|
return false;
|
|
321
342
|
}
|
|
322
343
|
|
|
323
344
|
bool b = value.As<Napi::Boolean>();
|
|
324
345
|
*((param.gpr_count ? gpr_ptr : args_ptr)++) = (uint64_t)b;
|
|
325
346
|
} break;
|
|
326
|
-
case PrimitiveKind::Int8:
|
|
327
|
-
case PrimitiveKind::UInt8:
|
|
328
|
-
case PrimitiveKind::Int16:
|
|
329
|
-
case PrimitiveKind::
|
|
330
|
-
case PrimitiveKind::
|
|
331
|
-
case PrimitiveKind::
|
|
332
|
-
case PrimitiveKind::
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
} break;
|
|
341
|
-
case PrimitiveKind::Int16S:
|
|
342
|
-
case PrimitiveKind::UInt16S:
|
|
343
|
-
case PrimitiveKind::Int32S:
|
|
344
|
-
case PrimitiveKind::UInt32S:
|
|
345
|
-
case PrimitiveKind::Int64S: {
|
|
346
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
347
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
348
|
-
return false;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
int64_t v = CopyNumber<int64_t>(value);
|
|
352
|
-
*(int64_t *)((param.gpr_count ? gpr_ptr : args_ptr)++) = ReverseBytes(v);
|
|
353
|
-
} break;
|
|
354
|
-
case PrimitiveKind::UInt64: {
|
|
355
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
356
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
357
|
-
return false;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
uint64_t v = CopyNumber<uint64_t>(value);
|
|
361
|
-
*((param.gpr_count ? gpr_ptr : args_ptr)++) = v;
|
|
362
|
-
} break;
|
|
363
|
-
case PrimitiveKind::UInt64S: {
|
|
364
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
365
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
366
|
-
return false;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
uint64_t v = CopyNumber<uint64_t>(value);
|
|
370
|
-
*((param.gpr_count ? gpr_ptr : args_ptr)++) = ReverseBytes(v);
|
|
371
|
-
} break;
|
|
347
|
+
case PrimitiveKind::Int8: { PUSH_INTEGER(int8_t); } break;
|
|
348
|
+
case PrimitiveKind::UInt8: { PUSH_INTEGER(uint8_t); } break;
|
|
349
|
+
case PrimitiveKind::Int16: { PUSH_INTEGER(int16_t); } break;
|
|
350
|
+
case PrimitiveKind::Int16S: { PUSH_INTEGER_SWAP(int16_t); } break;
|
|
351
|
+
case PrimitiveKind::UInt16: { PUSH_INTEGER(uint16_t); } break;
|
|
352
|
+
case PrimitiveKind::UInt16S: { PUSH_INTEGER_SWAP(uint16_t); } break;
|
|
353
|
+
case PrimitiveKind::Int32: { PUSH_INTEGER(int32_t); } break;
|
|
354
|
+
case PrimitiveKind::Int32S: { PUSH_INTEGER_SWAP(int32_t); } break;
|
|
355
|
+
case PrimitiveKind::UInt32: { PUSH_INTEGER(uint32_t); } break;
|
|
356
|
+
case PrimitiveKind::UInt32S: { PUSH_INTEGER_SWAP(uint32_t); } break;
|
|
357
|
+
case PrimitiveKind::Int64: { PUSH_INTEGER(int64_t); } break;
|
|
358
|
+
case PrimitiveKind::Int64S: { PUSH_INTEGER_SWAP(int64_t); } break;
|
|
359
|
+
case PrimitiveKind::UInt64: { PUSH_INTEGER(uint64_t); } break;
|
|
360
|
+
case PrimitiveKind::UInt64S: { PUSH_INTEGER_SWAP(uint64_t); } break;
|
|
372
361
|
case PrimitiveKind::String: {
|
|
373
362
|
const char *str;
|
|
374
|
-
if (
|
|
375
|
-
str = PushString(value);
|
|
376
|
-
if (RG_UNLIKELY(!str))
|
|
377
|
-
return false;
|
|
378
|
-
} else if (IsNullOrUndefined(value)) {
|
|
379
|
-
str = nullptr;
|
|
380
|
-
} else {
|
|
381
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected string", GetValueType(instance, value), param.offset + 1);
|
|
363
|
+
if (RG_UNLIKELY(!PushString(value, &str)))
|
|
382
364
|
return false;
|
|
383
|
-
}
|
|
384
365
|
|
|
385
366
|
*(const char **)((param.gpr_count ? gpr_ptr : args_ptr)++) = str;
|
|
386
367
|
} break;
|
|
387
368
|
case PrimitiveKind::String16: {
|
|
388
369
|
const char16_t *str16;
|
|
389
|
-
if (
|
|
390
|
-
str16 = PushString16(value);
|
|
391
|
-
if (RG_UNLIKELY(!str16))
|
|
392
|
-
return false;
|
|
393
|
-
} else if (IsNullOrUndefined(value)) {
|
|
394
|
-
str16 = nullptr;
|
|
395
|
-
} else {
|
|
396
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected string", GetValueType(instance, value), param.offset + 1);
|
|
370
|
+
if (RG_UNLIKELY(!PushString16(value, &str16)))
|
|
397
371
|
return false;
|
|
398
|
-
}
|
|
399
372
|
|
|
400
373
|
*(const char16_t **)((param.gpr_count ? gpr_ptr : args_ptr)++) = str16;
|
|
401
374
|
} break;
|
|
402
375
|
case PrimitiveKind::Pointer: {
|
|
403
376
|
void *ptr;
|
|
404
|
-
if (RG_UNLIKELY(!PushPointer(value, param, &ptr)))
|
|
377
|
+
if (RG_UNLIKELY(!PushPointer(value, param.type, param.directions, &ptr)))
|
|
405
378
|
return false;
|
|
406
379
|
|
|
407
380
|
*(void **)((param.gpr_count ? gpr_ptr : args_ptr)++) = ptr;
|
|
408
381
|
} break;
|
|
409
382
|
case PrimitiveKind::Record: {
|
|
410
383
|
if (RG_UNLIKELY(!IsObject(value))) {
|
|
411
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
384
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected object", GetValueType(instance, value));
|
|
412
385
|
return false;
|
|
413
386
|
}
|
|
414
387
|
|
|
@@ -447,7 +420,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
447
420
|
case PrimitiveKind::Array: { RG_UNREACHABLE(); } break;
|
|
448
421
|
case PrimitiveKind::Float32: {
|
|
449
422
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
450
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
423
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
|
|
451
424
|
return false;
|
|
452
425
|
}
|
|
453
426
|
|
|
@@ -459,7 +432,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
459
432
|
} break;
|
|
460
433
|
case PrimitiveKind::Float64: {
|
|
461
434
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
462
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
435
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
|
|
463
436
|
return false;
|
|
464
437
|
}
|
|
465
438
|
|
|
@@ -480,7 +453,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
480
453
|
} else if (IsNullOrUndefined(value)) {
|
|
481
454
|
ptr = nullptr;
|
|
482
455
|
} else {
|
|
483
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
456
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected %2", GetValueType(instance, value), param.type->name);
|
|
484
457
|
return false;
|
|
485
458
|
}
|
|
486
459
|
|
|
@@ -491,6 +464,9 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
491
464
|
}
|
|
492
465
|
}
|
|
493
466
|
|
|
467
|
+
#undef PUSH_INTEGER_SWAP
|
|
468
|
+
#undef PUSH_INTEGER
|
|
469
|
+
|
|
494
470
|
new_sp = mem->stack.end();
|
|
495
471
|
|
|
496
472
|
return true;
|
|
@@ -838,91 +814,64 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
838
814
|
if (RG_UNLIKELY(env.IsExceptionPending()))
|
|
839
815
|
return;
|
|
840
816
|
|
|
817
|
+
#define RETURN_INTEGER(CType) \
|
|
818
|
+
do { \
|
|
819
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
820
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
821
|
+
return; \
|
|
822
|
+
} \
|
|
823
|
+
\
|
|
824
|
+
CType v = CopyNumber<CType>(value); \
|
|
825
|
+
out_reg->rax = (uint64_t)v; \
|
|
826
|
+
} while (false)
|
|
827
|
+
#define RETURN_INTEGER_SWAP(CType) \
|
|
828
|
+
do { \
|
|
829
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
830
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
831
|
+
return; \
|
|
832
|
+
} \
|
|
833
|
+
\
|
|
834
|
+
CType v = CopyNumber<CType>(value); \
|
|
835
|
+
out_reg->rax = (uint64_t)ReverseBytes(v); \
|
|
836
|
+
} while (false)
|
|
837
|
+
|
|
841
838
|
// Convert the result
|
|
842
839
|
switch (type->primitive) {
|
|
843
840
|
case PrimitiveKind::Void: {} break;
|
|
844
841
|
case PrimitiveKind::Bool: {
|
|
845
842
|
if (RG_UNLIKELY(!value.IsBoolean())) {
|
|
846
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
843
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected boolean", GetValueType(instance, value));
|
|
847
844
|
return;
|
|
848
845
|
}
|
|
849
846
|
|
|
850
847
|
bool b = value.As<Napi::Boolean>();
|
|
851
848
|
out_reg->rax = (uint64_t)b;
|
|
852
849
|
} break;
|
|
853
|
-
case PrimitiveKind::Int8:
|
|
854
|
-
case PrimitiveKind::UInt8:
|
|
855
|
-
case PrimitiveKind::Int16:
|
|
856
|
-
case PrimitiveKind::
|
|
857
|
-
case PrimitiveKind::
|
|
858
|
-
case PrimitiveKind::
|
|
859
|
-
case PrimitiveKind::
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
} break;
|
|
868
|
-
case PrimitiveKind::Int16S:
|
|
869
|
-
case PrimitiveKind::UInt16S:
|
|
870
|
-
case PrimitiveKind::Int32S:
|
|
871
|
-
case PrimitiveKind::UInt32S:
|
|
872
|
-
case PrimitiveKind::Int64S: {
|
|
873
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
874
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
875
|
-
return;
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
int64_t v = CopyNumber<int64_t>(value);
|
|
879
|
-
out_reg->rax = (uint64_t)ReverseBytes(v);
|
|
880
|
-
} break;
|
|
881
|
-
case PrimitiveKind::UInt64: {
|
|
882
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
883
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
884
|
-
return;
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
uint64_t v = CopyNumber<uint64_t>(value);
|
|
888
|
-
out_reg->rax = v;
|
|
889
|
-
} break;
|
|
890
|
-
case PrimitiveKind::UInt64S: {
|
|
891
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
892
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
893
|
-
return;
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
uint64_t v = CopyNumber<uint64_t>(value);
|
|
897
|
-
out_reg->rax = ReverseBytes(v);
|
|
898
|
-
} break;
|
|
850
|
+
case PrimitiveKind::Int8: { RETURN_INTEGER(int8_t); } break;
|
|
851
|
+
case PrimitiveKind::UInt8: { RETURN_INTEGER(uint8_t); } break;
|
|
852
|
+
case PrimitiveKind::Int16: { RETURN_INTEGER(int16_t); } break;
|
|
853
|
+
case PrimitiveKind::Int16S: { RETURN_INTEGER_SWAP(int16_t); } break;
|
|
854
|
+
case PrimitiveKind::UInt16: { RETURN_INTEGER(uint16_t); } break;
|
|
855
|
+
case PrimitiveKind::UInt16S: { RETURN_INTEGER_SWAP(uint16_t); } break;
|
|
856
|
+
case PrimitiveKind::Int32: { RETURN_INTEGER(int32_t); } break;
|
|
857
|
+
case PrimitiveKind::Int32S: { RETURN_INTEGER_SWAP(int32_t); } break;
|
|
858
|
+
case PrimitiveKind::UInt32: { RETURN_INTEGER(uint32_t); } break;
|
|
859
|
+
case PrimitiveKind::UInt32S: { RETURN_INTEGER_SWAP(uint32_t); } break;
|
|
860
|
+
case PrimitiveKind::Int64: { RETURN_INTEGER(int64_t); } break;
|
|
861
|
+
case PrimitiveKind::Int64S: { RETURN_INTEGER_SWAP(int64_t); } break;
|
|
862
|
+
case PrimitiveKind::UInt64: { RETURN_INTEGER(uint64_t); } break;
|
|
863
|
+
case PrimitiveKind::UInt64S: { RETURN_INTEGER_SWAP(uint64_t); } break;
|
|
899
864
|
case PrimitiveKind::String: {
|
|
900
865
|
const char *str;
|
|
901
|
-
if (
|
|
902
|
-
str = PushString(value);
|
|
903
|
-
if (RG_UNLIKELY(!str))
|
|
904
|
-
return;
|
|
905
|
-
} else if (IsNullOrUndefined(value)) {
|
|
906
|
-
str = nullptr;
|
|
907
|
-
} else {
|
|
908
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected string", GetValueType(instance, value));
|
|
866
|
+
if (RG_UNLIKELY(!PushString(value, &str)))
|
|
909
867
|
return;
|
|
910
|
-
}
|
|
911
868
|
|
|
912
869
|
out_reg->rax = (uint64_t)str;
|
|
913
870
|
} break;
|
|
914
871
|
case PrimitiveKind::String16: {
|
|
915
872
|
const char16_t *str16;
|
|
916
|
-
if (
|
|
917
|
-
str16 = PushString16(value);
|
|
918
|
-
if (RG_UNLIKELY(!str16))
|
|
919
|
-
return;
|
|
920
|
-
} else if (IsNullOrUndefined(value)) {
|
|
921
|
-
str16 = nullptr;
|
|
922
|
-
} else {
|
|
923
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected string", GetValueType(instance, value));
|
|
873
|
+
if (RG_UNLIKELY(!PushString16(value, &str16)))
|
|
924
874
|
return;
|
|
925
|
-
}
|
|
926
875
|
|
|
927
876
|
out_reg->rax = (uint64_t)str16;
|
|
928
877
|
} break;
|
|
@@ -941,7 +890,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
941
890
|
} else if (IsNullOrUndefined(value)) {
|
|
942
891
|
ptr = nullptr;
|
|
943
892
|
} else {
|
|
944
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
893
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected %2", GetValueType(instance, value), type->name);
|
|
945
894
|
return;
|
|
946
895
|
}
|
|
947
896
|
|
|
@@ -949,7 +898,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
949
898
|
} break;
|
|
950
899
|
case PrimitiveKind::Record: {
|
|
951
900
|
if (RG_UNLIKELY(!IsObject(value))) {
|
|
952
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
901
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected object", GetValueType(instance, value));
|
|
953
902
|
return;
|
|
954
903
|
}
|
|
955
904
|
|
|
@@ -984,7 +933,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
984
933
|
case PrimitiveKind::Array: { RG_UNREACHABLE(); } break;
|
|
985
934
|
case PrimitiveKind::Float32: {
|
|
986
935
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
987
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
936
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
|
|
988
937
|
return;
|
|
989
938
|
}
|
|
990
939
|
|
|
@@ -995,7 +944,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
995
944
|
} break;
|
|
996
945
|
case PrimitiveKind::Float64: {
|
|
997
946
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
998
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
947
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
|
|
999
948
|
return;
|
|
1000
949
|
}
|
|
1001
950
|
|
|
@@ -1016,7 +965,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
1016
965
|
} else if (IsNullOrUndefined(value)) {
|
|
1017
966
|
ptr = nullptr;
|
|
1018
967
|
} else {
|
|
1019
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
968
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected %2", GetValueType(instance, value), type->name);
|
|
1020
969
|
return;
|
|
1021
970
|
}
|
|
1022
971
|
|
|
@@ -1026,6 +975,9 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
1026
975
|
case PrimitiveKind::Prototype: { RG_UNREACHABLE(); } break;
|
|
1027
976
|
}
|
|
1028
977
|
|
|
978
|
+
#undef RETURN_INTEGER_SWAP
|
|
979
|
+
#undef RETURN_INTEGER
|
|
980
|
+
|
|
1029
981
|
err_guard.Disable();
|
|
1030
982
|
}
|
|
1031
983
|
|