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_arm32.cc
CHANGED
|
@@ -275,6 +275,65 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
275
275
|
*(uint8_t **)(gpr_ptr++) = return_ptr;
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
+
#define PUSH_INTEGER_32(CType) \
|
|
279
|
+
do { \
|
|
280
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
281
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
282
|
+
return false; \
|
|
283
|
+
} \
|
|
284
|
+
\
|
|
285
|
+
CType v = CopyNumber<CType>(value); \
|
|
286
|
+
*((param.gpr_count ? gpr_ptr : args_ptr)++) = (uint32_t)v; \
|
|
287
|
+
} while (false)
|
|
288
|
+
#define PUSH_INTEGER_32_SWAP(CType) \
|
|
289
|
+
do { \
|
|
290
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
291
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
292
|
+
return false; \
|
|
293
|
+
} \
|
|
294
|
+
\
|
|
295
|
+
CType v = CopyNumber<CType>(value); \
|
|
296
|
+
*((param.gpr_count ? gpr_ptr : args_ptr)++) = (uint32_t)ReverseBytes(v); \
|
|
297
|
+
} while (false)
|
|
298
|
+
#define PUSH_INTEGER_64(CType) \
|
|
299
|
+
do { \
|
|
300
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
301
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
302
|
+
return false; \
|
|
303
|
+
} \
|
|
304
|
+
\
|
|
305
|
+
CType v = CopyNumber<CType>(value); \
|
|
306
|
+
\
|
|
307
|
+
if (RG_LIKELY(param.gpr_count)) { \
|
|
308
|
+
gpr_ptr = AlignUp(gpr_ptr, 8); \
|
|
309
|
+
*(uint64_t *)gpr_ptr = (uint64_t)v; \
|
|
310
|
+
gpr_ptr += param.gpr_count; \
|
|
311
|
+
} else { \
|
|
312
|
+
args_ptr = AlignUp(args_ptr, 8); \
|
|
313
|
+
*(uint64_t *)args_ptr = (uint64_t)v; \
|
|
314
|
+
args_ptr += 2; \
|
|
315
|
+
} \
|
|
316
|
+
} while (false)
|
|
317
|
+
#define PUSH_INTEGER_64_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
|
+
\
|
|
326
|
+
if (RG_LIKELY(param.gpr_count)) { \
|
|
327
|
+
gpr_ptr = AlignUp(gpr_ptr, 8); \
|
|
328
|
+
*(uint64_t *)gpr_ptr = (uint64_t)ReverseBytes(v); \
|
|
329
|
+
gpr_ptr += param.gpr_count; \
|
|
330
|
+
} else { \
|
|
331
|
+
args_ptr = AlignUp(args_ptr, 8); \
|
|
332
|
+
*(uint64_t *)args_ptr = (uint64_t)ReverseBytes(v); \
|
|
333
|
+
args_ptr += 2; \
|
|
334
|
+
} \
|
|
335
|
+
} while (false)
|
|
336
|
+
|
|
278
337
|
// Push arguments
|
|
279
338
|
for (Size i = 0; i < func->parameters.len; i++) {
|
|
280
339
|
const ParameterInfo ¶m = func->parameters[i];
|
|
@@ -287,167 +346,51 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
287
346
|
|
|
288
347
|
case PrimitiveKind::Bool: {
|
|
289
348
|
if (RG_UNLIKELY(!value.IsBoolean())) {
|
|
290
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
349
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected boolean", GetValueType(instance, value));
|
|
291
350
|
return false;
|
|
292
351
|
}
|
|
293
352
|
|
|
294
353
|
bool b = value.As<Napi::Boolean>();
|
|
295
354
|
*((param.gpr_count ? gpr_ptr : args_ptr)++) = (uint32_t)b;
|
|
296
355
|
} break;
|
|
297
|
-
case PrimitiveKind::Int8:
|
|
298
|
-
case PrimitiveKind::UInt8:
|
|
299
|
-
case PrimitiveKind::Int16:
|
|
300
|
-
case PrimitiveKind::
|
|
301
|
-
case PrimitiveKind::
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
} break;
|
|
310
|
-
case PrimitiveKind::
|
|
311
|
-
case PrimitiveKind::UInt16S:
|
|
312
|
-
case PrimitiveKind::Int32S: {
|
|
313
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
314
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
315
|
-
return false;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
int32_t v = ReverseBytes(CopyNumber<int32_t>(value));
|
|
319
|
-
*(int32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++) = v;
|
|
320
|
-
} break;
|
|
321
|
-
case PrimitiveKind::UInt32: {
|
|
322
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
323
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
324
|
-
return false;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
uint32_t v = CopyNumber<uint32_t>(value);
|
|
328
|
-
*((param.gpr_count ? gpr_ptr : args_ptr)++) = v;
|
|
329
|
-
} break;
|
|
330
|
-
case PrimitiveKind::UInt32S: {
|
|
331
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
332
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
333
|
-
return false;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
uint32_t v = ReverseBytes(CopyNumber<uint32_t>(value));
|
|
337
|
-
*((param.gpr_count ? gpr_ptr : args_ptr)++) = v;
|
|
338
|
-
} break;
|
|
339
|
-
case PrimitiveKind::Int64: {
|
|
340
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
341
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
342
|
-
return false;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
int64_t v = CopyNumber<int64_t>(value);
|
|
346
|
-
|
|
347
|
-
if (RG_LIKELY(param.gpr_count)) {
|
|
348
|
-
gpr_ptr = AlignUp(gpr_ptr, 8);
|
|
349
|
-
*(int64_t *)gpr_ptr = v;
|
|
350
|
-
gpr_ptr += param.gpr_count;
|
|
351
|
-
} else {
|
|
352
|
-
args_ptr = AlignUp(args_ptr, 8);
|
|
353
|
-
*(int64_t *)args_ptr = v;
|
|
354
|
-
args_ptr += 2;
|
|
355
|
-
}
|
|
356
|
-
} break;
|
|
357
|
-
case PrimitiveKind::Int64S: {
|
|
358
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
359
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
360
|
-
return false;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
int64_t v = ReverseBytes(CopyNumber<int64_t>(value));
|
|
364
|
-
|
|
365
|
-
if (RG_LIKELY(param.gpr_count)) {
|
|
366
|
-
gpr_ptr = AlignUp(gpr_ptr, 8);
|
|
367
|
-
*(int64_t *)gpr_ptr = v;
|
|
368
|
-
gpr_ptr += param.gpr_count;
|
|
369
|
-
} else {
|
|
370
|
-
args_ptr = AlignUp(args_ptr, 8);
|
|
371
|
-
*(int64_t *)args_ptr = v;
|
|
372
|
-
args_ptr += 2;
|
|
373
|
-
}
|
|
374
|
-
} break;
|
|
375
|
-
case PrimitiveKind::UInt64: {
|
|
376
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
377
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
378
|
-
return false;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
uint64_t v = CopyNumber<uint64_t>(value);
|
|
382
|
-
|
|
383
|
-
if (RG_LIKELY(param.gpr_count)) {
|
|
384
|
-
gpr_ptr = AlignUp(gpr_ptr, 8);
|
|
385
|
-
*(uint64_t *)gpr_ptr = v;
|
|
386
|
-
gpr_ptr += param.gpr_count;
|
|
387
|
-
} else {
|
|
388
|
-
args_ptr = AlignUp(args_ptr, 8);
|
|
389
|
-
*(uint64_t *)args_ptr = v;
|
|
390
|
-
args_ptr += 2;
|
|
391
|
-
}
|
|
392
|
-
} break;
|
|
393
|
-
case PrimitiveKind::UInt64S: {
|
|
394
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
395
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
396
|
-
return false;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
uint64_t v = ReverseBytes(CopyNumber<uint64_t>(value));
|
|
400
|
-
|
|
401
|
-
if (RG_LIKELY(param.gpr_count)) {
|
|
402
|
-
gpr_ptr = AlignUp(gpr_ptr, 8);
|
|
403
|
-
*(uint64_t *)gpr_ptr = v;
|
|
404
|
-
gpr_ptr += param.gpr_count;
|
|
405
|
-
} else {
|
|
406
|
-
args_ptr = AlignUp(args_ptr, 8);
|
|
407
|
-
*(uint64_t *)args_ptr = v;
|
|
408
|
-
args_ptr += 2;
|
|
409
|
-
}
|
|
410
|
-
} break;
|
|
356
|
+
case PrimitiveKind::Int8: { PUSH_INTEGER_32(int8_t); } break;
|
|
357
|
+
case PrimitiveKind::UInt8: { PUSH_INTEGER_32(uint8_t); } break;
|
|
358
|
+
case PrimitiveKind::Int16: { PUSH_INTEGER_32(int16_t); } break;
|
|
359
|
+
case PrimitiveKind::Int16S: { PUSH_INTEGER_32_SWAP(int16_t); } break;
|
|
360
|
+
case PrimitiveKind::UInt16: { PUSH_INTEGER_32(uint16_t); } break;
|
|
361
|
+
case PrimitiveKind::UInt16S: { PUSH_INTEGER_32_SWAP(uint16_t); } break;
|
|
362
|
+
case PrimitiveKind::Int32: { PUSH_INTEGER_32(int32_t); } break;
|
|
363
|
+
case PrimitiveKind::Int32S: { PUSH_INTEGER_32_SWAP(int32_t); } break;
|
|
364
|
+
case PrimitiveKind::UInt32: { PUSH_INTEGER_32(uint32_t); } break;
|
|
365
|
+
case PrimitiveKind::UInt32S: { PUSH_INTEGER_32_SWAP(uint32_t); } break;
|
|
366
|
+
case PrimitiveKind::Int64: { PUSH_INTEGER_64(int64_t); } break;
|
|
367
|
+
case PrimitiveKind::Int64S: { PUSH_INTEGER_64_SWAP(int64_t); } break;
|
|
368
|
+
case PrimitiveKind::UInt64: { PUSH_INTEGER_64(uint64_t); } break;
|
|
369
|
+
case PrimitiveKind::UInt64S: { PUSH_INTEGER_64_SWAP(uint64_t); } break;
|
|
411
370
|
case PrimitiveKind::String: {
|
|
412
371
|
const char *str;
|
|
413
|
-
if (
|
|
414
|
-
str = PushString(value);
|
|
415
|
-
if (RG_UNLIKELY(!str))
|
|
416
|
-
return false;
|
|
417
|
-
} else if (IsNullOrUndefined(value)) {
|
|
418
|
-
str = nullptr;
|
|
419
|
-
} else {
|
|
420
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected string", GetValueType(instance, value), param.offset + 1);
|
|
372
|
+
if (RG_UNLIKELY(!PushString(value, &str)))
|
|
421
373
|
return false;
|
|
422
|
-
}
|
|
423
374
|
|
|
424
375
|
*(const char **)((param.gpr_count ? gpr_ptr : args_ptr)++) = str;
|
|
425
376
|
} break;
|
|
426
377
|
case PrimitiveKind::String16: {
|
|
427
378
|
const char16_t *str16;
|
|
428
|
-
if (
|
|
429
|
-
str16 = PushString16(value);
|
|
430
|
-
if (RG_UNLIKELY(!str16))
|
|
431
|
-
return false;
|
|
432
|
-
} else if (IsNullOrUndefined(value)) {
|
|
433
|
-
str16 = nullptr;
|
|
434
|
-
} else {
|
|
435
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected string", GetValueType(instance, value), param.offset + 1);
|
|
379
|
+
if (RG_UNLIKELY(!PushString16(value, &str16)))
|
|
436
380
|
return false;
|
|
437
|
-
}
|
|
438
381
|
|
|
439
382
|
*(const char16_t **)((param.gpr_count ? gpr_ptr : args_ptr)++) = str16;
|
|
440
383
|
} break;
|
|
441
384
|
case PrimitiveKind::Pointer: {
|
|
442
385
|
void *ptr;
|
|
443
|
-
if (RG_UNLIKELY(!PushPointer(value, param, &ptr)))
|
|
386
|
+
if (RG_UNLIKELY(!PushPointer(value, param.type, param.directions, &ptr)))
|
|
444
387
|
return false;
|
|
445
388
|
|
|
446
389
|
*(void **)((param.gpr_count ? gpr_ptr : args_ptr)++) = ptr;
|
|
447
390
|
} break;
|
|
448
391
|
case PrimitiveKind::Record: {
|
|
449
392
|
if (RG_UNLIKELY(!IsObject(value))) {
|
|
450
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
393
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected object", GetValueType(instance, value));
|
|
451
394
|
return false;
|
|
452
395
|
}
|
|
453
396
|
|
|
@@ -480,7 +423,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
480
423
|
case PrimitiveKind::Array: { RG_UNREACHABLE(); } break;
|
|
481
424
|
case PrimitiveKind::Float32: {
|
|
482
425
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
483
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
426
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
|
|
484
427
|
return false;
|
|
485
428
|
}
|
|
486
429
|
|
|
@@ -496,7 +439,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
496
439
|
} break;
|
|
497
440
|
case PrimitiveKind::Float64: {
|
|
498
441
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
499
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
442
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
|
|
500
443
|
return false;
|
|
501
444
|
}
|
|
502
445
|
|
|
@@ -529,7 +472,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
529
472
|
} else if (IsNullOrUndefined(value)) {
|
|
530
473
|
ptr = nullptr;
|
|
531
474
|
} else {
|
|
532
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
475
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected %2", GetValueType(instance, value), param.type->name);
|
|
533
476
|
return false;
|
|
534
477
|
}
|
|
535
478
|
|
|
@@ -540,6 +483,11 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
540
483
|
}
|
|
541
484
|
}
|
|
542
485
|
|
|
486
|
+
#undef PUSH_INTEGER_64_SWAP
|
|
487
|
+
#undef PUSH_INTEGER_64
|
|
488
|
+
#undef PUSH_INTEGER_32_SWAP
|
|
489
|
+
#undef PUSH_INTEGER_32
|
|
490
|
+
|
|
543
491
|
new_sp = mem->stack.end();
|
|
544
492
|
|
|
545
493
|
return true;
|
|
@@ -919,131 +867,88 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
919
867
|
if (RG_UNLIKELY(env.IsExceptionPending()))
|
|
920
868
|
return;
|
|
921
869
|
|
|
870
|
+
#define RETURN_INTEGER_32(CType) \
|
|
871
|
+
do { \
|
|
872
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
873
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value)); \
|
|
874
|
+
return; \
|
|
875
|
+
} \
|
|
876
|
+
\
|
|
877
|
+
CType v = CopyNumber<CType>(value); \
|
|
878
|
+
out_reg->r0 = (uint32_t)v; \
|
|
879
|
+
} while (false)
|
|
880
|
+
#define RETURN_INTEGER_32_SWAP(CType) \
|
|
881
|
+
do { \
|
|
882
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
883
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
884
|
+
return; \
|
|
885
|
+
} \
|
|
886
|
+
\
|
|
887
|
+
CType v = CopyNumber<CType>(value); \
|
|
888
|
+
out_reg->r0 = (uint32_t)ReverseBytes(v); \
|
|
889
|
+
} while (false)
|
|
890
|
+
#define RETURN_INTEGER_64(CType) \
|
|
891
|
+
do { \
|
|
892
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
893
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
894
|
+
return; \
|
|
895
|
+
} \
|
|
896
|
+
\
|
|
897
|
+
CType v = CopyNumber<CType>(value); \
|
|
898
|
+
\
|
|
899
|
+
out_reg->r0 = (uint32_t)((uint64_t)v >> 32); \
|
|
900
|
+
out_reg->r1 = (uint32_t)((uint64_t)v & 0xFFFFFFFFu); \
|
|
901
|
+
} while (false)
|
|
902
|
+
#define RETURN_INTEGER_64_SWAP(CType) \
|
|
903
|
+
do { \
|
|
904
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
|
|
905
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
|
|
906
|
+
return; \
|
|
907
|
+
} \
|
|
908
|
+
\
|
|
909
|
+
CType v = ReverseBytes(CopyNumber<CType>(value)); \
|
|
910
|
+
\
|
|
911
|
+
out_reg->r0 = (uint32_t)((uint64_t)v >> 32); \
|
|
912
|
+
out_reg->r1 = (uint32_t)((uint64_t)v & 0xFFFFFFFFu); \
|
|
913
|
+
} while (false)
|
|
914
|
+
|
|
922
915
|
// Convert the result
|
|
923
916
|
switch (type->primitive) {
|
|
924
917
|
case PrimitiveKind::Void: {} break;
|
|
925
918
|
case PrimitiveKind::Bool: {
|
|
926
919
|
if (RG_UNLIKELY(!value.IsBoolean())) {
|
|
927
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
920
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected boolean", GetValueType(instance, value));
|
|
928
921
|
return;
|
|
929
922
|
}
|
|
930
923
|
|
|
931
924
|
bool b = value.As<Napi::Boolean>();
|
|
932
925
|
out_reg->r0 = (uint32_t)b;
|
|
933
926
|
} break;
|
|
934
|
-
case PrimitiveKind::Int8:
|
|
935
|
-
case PrimitiveKind::UInt8:
|
|
936
|
-
case PrimitiveKind::Int16:
|
|
937
|
-
case PrimitiveKind::
|
|
938
|
-
case PrimitiveKind::
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
} break;
|
|
947
|
-
case PrimitiveKind::
|
|
948
|
-
case PrimitiveKind::UInt16S:
|
|
949
|
-
case PrimitiveKind::Int32S: {
|
|
950
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
951
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
952
|
-
return;
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
int32_t v = CopyNumber<int32_t>(value);
|
|
956
|
-
out_reg->r0 = (uint32_t)ReverseBytes(v);
|
|
957
|
-
} break;
|
|
958
|
-
case PrimitiveKind::UInt32: {
|
|
959
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
960
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
961
|
-
return;
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
uint32_t v = CopyNumber<uint32_t>(value);
|
|
965
|
-
out_reg->r0 = v;
|
|
966
|
-
} break;
|
|
967
|
-
case PrimitiveKind::UInt32S: {
|
|
968
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
969
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
970
|
-
return;
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
uint32_t v = CopyNumber<uint32_t>(value);
|
|
974
|
-
out_reg->r0 = ReverseBytes(v);
|
|
975
|
-
} break;
|
|
976
|
-
case PrimitiveKind::Int64: {
|
|
977
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
978
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
979
|
-
return;
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
int64_t v = CopyNumber<int64_t>(value);
|
|
983
|
-
|
|
984
|
-
out_reg->r0 = (uint32_t)(v >> 32);
|
|
985
|
-
out_reg->r1 = (uint32_t)((uint64_t)v & 0xFFFFFFFFu);
|
|
986
|
-
} break;
|
|
987
|
-
case PrimitiveKind::Int64S: {
|
|
988
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
989
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
990
|
-
return;
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
int64_t v = ReverseBytes(CopyNumber<int64_t>(value));
|
|
994
|
-
|
|
995
|
-
out_reg->r0 = (uint32_t)(v >> 32);
|
|
996
|
-
out_reg->r1 = (uint32_t)((uint64_t)v & 0xFFFFFFFFu);
|
|
997
|
-
} break;
|
|
998
|
-
case PrimitiveKind::UInt64: {
|
|
999
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
1000
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
1001
|
-
return;
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
uint64_t v = CopyNumber<uint64_t>(value);
|
|
1005
|
-
|
|
1006
|
-
out_reg->r0 = (uint32_t)(v >> 32);
|
|
1007
|
-
out_reg->r1 = (uint32_t)((uint64_t)v & 0xFFFFFFFFu);
|
|
1008
|
-
} break;
|
|
1009
|
-
case PrimitiveKind::UInt64S: {
|
|
1010
|
-
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
1011
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
1012
|
-
return;
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
uint64_t v = ReverseBytes(CopyNumber<uint64_t>(value));
|
|
1016
|
-
|
|
1017
|
-
out_reg->r0 = (uint32_t)(v >> 32);
|
|
1018
|
-
out_reg->r1 = (uint32_t)((uint64_t)v & 0xFFFFFFFFu);
|
|
1019
|
-
} break;
|
|
927
|
+
case PrimitiveKind::Int8: { RETURN_INTEGER_32(int8_t); } break;
|
|
928
|
+
case PrimitiveKind::UInt8: { RETURN_INTEGER_32(uint8_t); } break;
|
|
929
|
+
case PrimitiveKind::Int16: { RETURN_INTEGER_32(int16_t); } break;
|
|
930
|
+
case PrimitiveKind::Int16S: { RETURN_INTEGER_32_SWAP(int16_t); } break;
|
|
931
|
+
case PrimitiveKind::UInt16: { RETURN_INTEGER_32(uint16_t); } break;
|
|
932
|
+
case PrimitiveKind::UInt16S: { RETURN_INTEGER_32_SWAP(uint16_t); } break;
|
|
933
|
+
case PrimitiveKind::Int32: { RETURN_INTEGER_32(int32_t); } break;
|
|
934
|
+
case PrimitiveKind::Int32S: { RETURN_INTEGER_32_SWAP(int32_t); } break;
|
|
935
|
+
case PrimitiveKind::UInt32: { RETURN_INTEGER_32(uint32_t); } break;
|
|
936
|
+
case PrimitiveKind::UInt32S: { RETURN_INTEGER_32_SWAP(uint32_t); } break;
|
|
937
|
+
case PrimitiveKind::Int64: { RETURN_INTEGER_64(int64_t); } break;
|
|
938
|
+
case PrimitiveKind::Int64S: { RETURN_INTEGER_64_SWAP(int64_t); } break;
|
|
939
|
+
case PrimitiveKind::UInt64: { RETURN_INTEGER_64(uint64_t); } break;
|
|
940
|
+
case PrimitiveKind::UInt64S: { RETURN_INTEGER_64_SWAP(uint64_t); } break;
|
|
1020
941
|
case PrimitiveKind::String: {
|
|
1021
942
|
const char *str;
|
|
1022
|
-
if (
|
|
1023
|
-
str = PushString(value);
|
|
1024
|
-
if (RG_UNLIKELY(!str))
|
|
1025
|
-
return;
|
|
1026
|
-
} else if (IsNullOrUndefined(value)) {
|
|
1027
|
-
str = nullptr;
|
|
1028
|
-
} else {
|
|
1029
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected string", GetValueType(instance, value));
|
|
943
|
+
if (RG_UNLIKELY(!PushString(value, &str)))
|
|
1030
944
|
return;
|
|
1031
|
-
}
|
|
1032
945
|
|
|
1033
946
|
out_reg->r0 = (uint32_t)str;
|
|
1034
947
|
} break;
|
|
1035
948
|
case PrimitiveKind::String16: {
|
|
1036
949
|
const char16_t *str16;
|
|
1037
|
-
if (
|
|
1038
|
-
str16 = PushString16(value);
|
|
1039
|
-
if (RG_UNLIKELY(!str16))
|
|
1040
|
-
return;
|
|
1041
|
-
} else if (IsNullOrUndefined(value)) {
|
|
1042
|
-
str16 = nullptr;
|
|
1043
|
-
} else {
|
|
1044
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected string", GetValueType(instance, value));
|
|
950
|
+
if (RG_UNLIKELY(!PushString16(value, &str16)))
|
|
1045
951
|
return;
|
|
1046
|
-
}
|
|
1047
952
|
|
|
1048
953
|
out_reg->r0 = (uint32_t)str16;
|
|
1049
954
|
} break;
|
|
@@ -1062,7 +967,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
1062
967
|
} else if (IsNullOrUndefined(value)) {
|
|
1063
968
|
ptr = nullptr;
|
|
1064
969
|
} else {
|
|
1065
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
970
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected %2", GetValueType(instance, value), type->name);
|
|
1066
971
|
return;
|
|
1067
972
|
}
|
|
1068
973
|
|
|
@@ -1070,7 +975,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
1070
975
|
} break;
|
|
1071
976
|
case PrimitiveKind::Record: {
|
|
1072
977
|
if (RG_UNLIKELY(!IsObject(value))) {
|
|
1073
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
978
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected object", GetValueType(instance, value));
|
|
1074
979
|
return;
|
|
1075
980
|
}
|
|
1076
981
|
|
|
@@ -1089,7 +994,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
1089
994
|
case PrimitiveKind::Array: { RG_UNREACHABLE(); } break;
|
|
1090
995
|
case PrimitiveKind::Float32: {
|
|
1091
996
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
1092
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
997
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
|
|
1093
998
|
return;
|
|
1094
999
|
}
|
|
1095
1000
|
|
|
@@ -1102,7 +1007,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
1102
1007
|
} break;
|
|
1103
1008
|
case PrimitiveKind::Float64: {
|
|
1104
1009
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
1105
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
1010
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
|
|
1106
1011
|
return;
|
|
1107
1012
|
}
|
|
1108
1013
|
|
|
@@ -1127,7 +1032,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
1127
1032
|
} else if (IsNullOrUndefined(value)) {
|
|
1128
1033
|
ptr = nullptr;
|
|
1129
1034
|
} else {
|
|
1130
|
-
ThrowError<Napi::TypeError>(env, "Unexpected %1 value
|
|
1035
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected %2", GetValueType(instance, value), type->name);
|
|
1131
1036
|
return;
|
|
1132
1037
|
}
|
|
1133
1038
|
|
|
@@ -1137,6 +1042,11 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
1137
1042
|
case PrimitiveKind::Prototype: { RG_UNREACHABLE(); } break;
|
|
1138
1043
|
}
|
|
1139
1044
|
|
|
1045
|
+
#undef RETURN_INTEGER_64_SWAP
|
|
1046
|
+
#undef RETURN_INTEGER_64
|
|
1047
|
+
#undef RETURN_INTEGER_32_SWAP
|
|
1048
|
+
#undef RETURN_INTEGER_32
|
|
1049
|
+
|
|
1140
1050
|
err_guard.Disable();
|
|
1141
1051
|
}
|
|
1142
1052
|
|