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.
Files changed (257) hide show
  1. package/CMakeLists.txt +1 -1
  2. package/ChangeLog.md +18 -0
  3. package/build/qemu/2.1.0/koffi_darwin_arm64.tar.gz +0 -0
  4. package/build/qemu/2.1.0/koffi_darwin_x64.tar.gz +0 -0
  5. package/build/qemu/2.1.0/koffi_freebsd_arm64.tar.gz +0 -0
  6. package/build/qemu/2.1.0/koffi_freebsd_ia32.tar.gz +0 -0
  7. package/build/qemu/2.1.0/koffi_freebsd_x64.tar.gz +0 -0
  8. package/build/qemu/2.1.0/koffi_linux_arm32hf.tar.gz +0 -0
  9. package/build/qemu/2.1.0/koffi_linux_arm64.tar.gz +0 -0
  10. package/build/qemu/2.1.0/koffi_linux_ia32.tar.gz +0 -0
  11. package/build/qemu/2.1.0/koffi_linux_riscv64hf64.tar.gz +0 -0
  12. package/build/qemu/2.1.0/koffi_linux_x64.tar.gz +0 -0
  13. package/build/qemu/2.1.0/koffi_openbsd_ia32.tar.gz +0 -0
  14. package/build/qemu/2.1.0/koffi_openbsd_x64.tar.gz +0 -0
  15. package/build/qemu/2.1.0/koffi_win32_arm64.tar.gz +0 -0
  16. package/build/qemu/2.1.0/koffi_win32_ia32.tar.gz +0 -0
  17. package/build/qemu/2.1.0/koffi_win32_x64.tar.gz +0 -0
  18. package/doc/Makefile +1 -1
  19. package/doc/benchmarks.md +14 -14
  20. package/doc/benchmarks.xlsx +0 -0
  21. package/doc/conf.py +5 -0
  22. package/doc/functions.md +67 -1
  23. package/doc/index.rst +2 -2
  24. package/doc/make.bat +1 -1
  25. package/doc/static/perf_linux_20220812.png +0 -0
  26. package/doc/static/perf_windows_20220812.png +0 -0
  27. package/doc/templates/badges.html +1 -2
  28. package/doc/types.md +112 -159
  29. package/package.json +2 -1
  30. package/qemu/registry/machines.json +2 -2
  31. package/qemu/registry/sha256sum.txt +2 -2
  32. package/src/abi_arm32.cc +224 -150
  33. package/src/abi_arm64.cc +255 -103
  34. package/src/abi_riscv64.cc +144 -88
  35. package/src/abi_x64_sysv.cc +151 -89
  36. package/src/abi_x64_win.cc +150 -88
  37. package/src/abi_x86.cc +198 -115
  38. package/src/call.cc +310 -137
  39. package/src/call.hh +4 -4
  40. package/src/ffi.cc +64 -20
  41. package/src/ffi.hh +12 -0
  42. package/src/util.hh +0 -20
  43. package/test/callbacks.js +3 -3
  44. package/test/misc.c +45 -2
  45. package/test/sync.js +83 -2
  46. package/vendor/libcc/libcc.cc +75 -55
  47. package/vendor/libcc/libcc.hh +306 -255
  48. package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj +226 -0
  49. package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj.filters +10 -0
  50. package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj.user +4 -0
  51. package/vendor/raylib/projects/VS2019-Android/raylib_android.sln +75 -0
  52. package/vendor/raylib/projects/VS2022/examples/audio_module_playing.vcxproj +390 -0
  53. package/vendor/raylib/projects/VS2022/examples/audio_multichannel_sound.vcxproj +390 -0
  54. package/vendor/raylib/projects/VS2022/examples/audio_music_stream.vcxproj +390 -0
  55. package/vendor/raylib/projects/VS2022/examples/audio_raw_stream.vcxproj +390 -0
  56. package/vendor/raylib/projects/VS2022/examples/audio_sound_loading.vcxproj +390 -0
  57. package/vendor/raylib/projects/VS2022/examples/audio_stream_effects.vcxproj +390 -0
  58. package/vendor/raylib/projects/VS2022/examples/core_2d_camera.vcxproj +390 -0
  59. package/vendor/raylib/projects/VS2022/examples/core_2d_camera_mouse_zoom.vcxproj +390 -0
  60. package/vendor/raylib/projects/VS2022/examples/core_2d_camera_platformer.vcxproj +390 -0
  61. package/vendor/raylib/projects/VS2022/examples/core_3d_camera_first_person.vcxproj +390 -0
  62. package/vendor/raylib/projects/VS2022/examples/core_3d_camera_free.vcxproj +390 -0
  63. package/vendor/raylib/projects/VS2022/examples/core_3d_camera_mode.vcxproj +390 -0
  64. package/vendor/raylib/projects/VS2022/examples/core_3d_picking.vcxproj +390 -0
  65. package/vendor/raylib/projects/VS2022/examples/core_basic_screen_manager.vcxproj +390 -0
  66. package/vendor/raylib/projects/VS2022/examples/core_basic_window.vcxproj +390 -0
  67. package/vendor/raylib/projects/VS2022/examples/core_custom_frame_control.vcxproj +390 -0
  68. package/vendor/raylib/projects/VS2022/examples/core_custom_logging.vcxproj +390 -0
  69. package/vendor/raylib/projects/VS2022/examples/core_drop_files.vcxproj +390 -0
  70. package/vendor/raylib/projects/VS2022/examples/core_input_gamepad.vcxproj +387 -0
  71. package/vendor/raylib/projects/VS2022/examples/core_input_gestures.vcxproj +387 -0
  72. package/vendor/raylib/projects/VS2022/examples/core_input_keys.vcxproj +387 -0
  73. package/vendor/raylib/projects/VS2022/examples/core_input_mouse.vcxproj +387 -0
  74. package/vendor/raylib/projects/VS2022/examples/core_input_mouse_wheel.vcxproj +387 -0
  75. package/vendor/raylib/projects/VS2022/examples/core_input_multitouch.vcxproj +387 -0
  76. package/vendor/raylib/projects/VS2022/examples/core_loading_thread.vcxproj +387 -0
  77. package/vendor/raylib/projects/VS2022/examples/core_random_values.vcxproj +387 -0
  78. package/vendor/raylib/projects/VS2022/examples/core_scissor_test.vcxproj +387 -0
  79. package/vendor/raylib/projects/VS2022/examples/core_split_screen.vcxproj +387 -0
  80. package/vendor/raylib/projects/VS2022/examples/core_storage_values.vcxproj +387 -0
  81. package/vendor/raylib/projects/VS2022/examples/core_vr_simulator.vcxproj +387 -0
  82. package/vendor/raylib/projects/VS2022/examples/core_window_flags.vcxproj +387 -0
  83. package/vendor/raylib/projects/VS2022/examples/core_window_letterbox.vcxproj +387 -0
  84. package/vendor/raylib/projects/VS2022/examples/core_window_should_close.vcxproj +390 -0
  85. package/vendor/raylib/projects/VS2022/examples/core_world_screen.vcxproj +387 -0
  86. package/vendor/raylib/projects/VS2022/examples/easings_testbed.vcxproj +387 -0
  87. package/vendor/raylib/projects/VS2022/examples/embedded_files_loading.vcxproj +387 -0
  88. package/vendor/raylib/projects/VS2022/examples/models_animation.vcxproj +387 -0
  89. package/vendor/raylib/projects/VS2022/examples/models_billboard.vcxproj +387 -0
  90. package/vendor/raylib/projects/VS2022/examples/models_box_collisions.vcxproj +387 -0
  91. package/vendor/raylib/projects/VS2022/examples/models_cubicmap.vcxproj +387 -0
  92. package/vendor/raylib/projects/VS2022/examples/models_first_person_maze.vcxproj +387 -0
  93. package/vendor/raylib/projects/VS2022/examples/models_geometric_shapes.vcxproj +387 -0
  94. package/vendor/raylib/projects/VS2022/examples/models_heightmap.vcxproj +387 -0
  95. package/vendor/raylib/projects/VS2022/examples/models_loading.vcxproj +387 -0
  96. package/vendor/raylib/projects/VS2022/examples/models_loading_gltf.vcxproj +387 -0
  97. package/vendor/raylib/projects/VS2022/examples/models_loading_vox.vcxproj +387 -0
  98. package/vendor/raylib/projects/VS2022/examples/models_mesh_generation.vcxproj +387 -0
  99. package/vendor/raylib/projects/VS2022/examples/models_mesh_picking.vcxproj +387 -0
  100. package/vendor/raylib/projects/VS2022/examples/models_orthographic_projection.vcxproj +387 -0
  101. package/vendor/raylib/projects/VS2022/examples/models_rlgl_solar_system.vcxproj +387 -0
  102. package/vendor/raylib/projects/VS2022/examples/models_skybox.vcxproj +387 -0
  103. package/vendor/raylib/projects/VS2022/examples/models_waving_cubes.vcxproj +387 -0
  104. package/vendor/raylib/projects/VS2022/examples/models_yaw_pitch_roll.vcxproj +387 -0
  105. package/vendor/raylib/projects/VS2022/examples/rlgl_compute_shaders.vcxproj +391 -0
  106. package/vendor/raylib/projects/VS2022/examples/rlgl_standalone.vcxproj +391 -0
  107. package/vendor/raylib/projects/VS2022/examples/shaders_basic_lighting.vcxproj +387 -0
  108. package/vendor/raylib/projects/VS2022/examples/shaders_custom_uniform.vcxproj +387 -0
  109. package/vendor/raylib/projects/VS2022/examples/shaders_eratosthenes.vcxproj +387 -0
  110. package/vendor/raylib/projects/VS2022/examples/shaders_fog.vcxproj +387 -0
  111. package/vendor/raylib/projects/VS2022/examples/shaders_hot_reloading.vcxproj +387 -0
  112. package/vendor/raylib/projects/VS2022/examples/shaders_julia_set.vcxproj +387 -0
  113. package/vendor/raylib/projects/VS2022/examples/shaders_mesh_instancing.vcxproj +387 -0
  114. package/vendor/raylib/projects/VS2022/examples/shaders_model_shader.vcxproj +387 -0
  115. package/vendor/raylib/projects/VS2022/examples/shaders_multi_sample2d.vcxproj +387 -0
  116. package/vendor/raylib/projects/VS2022/examples/shaders_palette_switch.vcxproj +387 -0
  117. package/vendor/raylib/projects/VS2022/examples/shaders_postprocessing.vcxproj +387 -0
  118. package/vendor/raylib/projects/VS2022/examples/shaders_raymarching.vcxproj +387 -0
  119. package/vendor/raylib/projects/VS2022/examples/shaders_shapes_textures.vcxproj +387 -0
  120. package/vendor/raylib/projects/VS2022/examples/shaders_simple_mask.vcxproj +387 -0
  121. package/vendor/raylib/projects/VS2022/examples/shaders_spotlight.vcxproj +387 -0
  122. package/vendor/raylib/projects/VS2022/examples/shaders_texture_drawing.vcxproj +387 -0
  123. package/vendor/raylib/projects/VS2022/examples/shaders_texture_waves.vcxproj +387 -0
  124. package/vendor/raylib/projects/VS2022/examples/shapes_basic_shapes.vcxproj +387 -0
  125. package/vendor/raylib/projects/VS2022/examples/shapes_bouncing_ball.vcxproj +387 -0
  126. package/vendor/raylib/projects/VS2022/examples/shapes_collision_area.vcxproj +387 -0
  127. package/vendor/raylib/projects/VS2022/examples/shapes_colors_palette.vcxproj +387 -0
  128. package/vendor/raylib/projects/VS2022/examples/shapes_draw_circle_sector.vcxproj +387 -0
  129. package/vendor/raylib/projects/VS2022/examples/shapes_draw_rectangle_rounded.vcxproj +387 -0
  130. package/vendor/raylib/projects/VS2022/examples/shapes_draw_ring.vcxproj +387 -0
  131. package/vendor/raylib/projects/VS2022/examples/shapes_easings_ball_anim.vcxproj +387 -0
  132. package/vendor/raylib/projects/VS2022/examples/shapes_easings_box_anim.vcxproj +387 -0
  133. package/vendor/raylib/projects/VS2022/examples/shapes_easings_rectangle_array.vcxproj +387 -0
  134. package/vendor/raylib/projects/VS2022/examples/shapes_following_eyes.vcxproj +387 -0
  135. package/vendor/raylib/projects/VS2022/examples/shapes_lines_bezier.vcxproj +387 -0
  136. package/vendor/raylib/projects/VS2022/examples/shapes_logo_raylib.vcxproj +387 -0
  137. package/vendor/raylib/projects/VS2022/examples/shapes_logo_raylib_anim.vcxproj +387 -0
  138. package/vendor/raylib/projects/VS2022/examples/shapes_rectangle_scaling.vcxproj +387 -0
  139. package/vendor/raylib/projects/VS2022/examples/text_codepoints_loading.vcxproj +387 -0
  140. package/vendor/raylib/projects/VS2022/examples/text_draw_3d.vcxproj +387 -0
  141. package/vendor/raylib/projects/VS2022/examples/text_font_filters.vcxproj +387 -0
  142. package/vendor/raylib/projects/VS2022/examples/text_font_loading.vcxproj +387 -0
  143. package/vendor/raylib/projects/VS2022/examples/text_font_sdf.vcxproj +387 -0
  144. package/vendor/raylib/projects/VS2022/examples/text_font_spritefont.vcxproj +387 -0
  145. package/vendor/raylib/projects/VS2022/examples/text_format_text.vcxproj +387 -0
  146. package/vendor/raylib/projects/VS2022/examples/text_input_box.vcxproj +387 -0
  147. package/vendor/raylib/projects/VS2022/examples/text_raylib_fonts.vcxproj +387 -0
  148. package/vendor/raylib/projects/VS2022/examples/text_rectangle_bounds.vcxproj +387 -0
  149. package/vendor/raylib/projects/VS2022/examples/text_unicode.vcxproj +387 -0
  150. package/vendor/raylib/projects/VS2022/examples/text_writing_anim.vcxproj +387 -0
  151. package/vendor/raylib/projects/VS2022/examples/textures_background_scrolling.vcxproj +387 -0
  152. package/vendor/raylib/projects/VS2022/examples/textures_blend_modes.vcxproj +387 -0
  153. package/vendor/raylib/projects/VS2022/examples/textures_bunnymark.vcxproj +387 -0
  154. package/vendor/raylib/projects/VS2022/examples/textures_draw_tiled.vcxproj +387 -0
  155. package/vendor/raylib/projects/VS2022/examples/textures_fog_of_war.vcxproj +387 -0
  156. package/vendor/raylib/projects/VS2022/examples/textures_gif_player.vcxproj +387 -0
  157. package/vendor/raylib/projects/VS2022/examples/textures_image_drawing.vcxproj +387 -0
  158. package/vendor/raylib/projects/VS2022/examples/textures_image_generation.vcxproj +387 -0
  159. package/vendor/raylib/projects/VS2022/examples/textures_image_loading.vcxproj +387 -0
  160. package/vendor/raylib/projects/VS2022/examples/textures_image_processing.vcxproj +387 -0
  161. package/vendor/raylib/projects/VS2022/examples/textures_image_text.vcxproj +387 -0
  162. package/vendor/raylib/projects/VS2022/examples/textures_logo_raylib.vcxproj +387 -0
  163. package/vendor/raylib/projects/VS2022/examples/textures_mouse_painting.vcxproj +387 -0
  164. package/vendor/raylib/projects/VS2022/examples/textures_npatch_drawing.vcxproj +387 -0
  165. package/vendor/raylib/projects/VS2022/examples/textures_particles_blending.vcxproj +387 -0
  166. package/vendor/raylib/projects/VS2022/examples/textures_polygon.vcxproj +387 -0
  167. package/vendor/raylib/projects/VS2022/examples/textures_raw_data.vcxproj +387 -0
  168. package/vendor/raylib/projects/VS2022/examples/textures_sprite_anim.vcxproj +387 -0
  169. package/vendor/raylib/projects/VS2022/examples/textures_sprite_button.vcxproj +387 -0
  170. package/vendor/raylib/projects/VS2022/examples/textures_sprite_explosion.vcxproj +387 -0
  171. package/vendor/raylib/projects/VS2022/examples/textures_srcrec_dstrec.vcxproj +387 -0
  172. package/vendor/raylib/projects/VS2022/examples/textures_to_image.vcxproj +387 -0
  173. package/vendor/raylib/projects/VS2022/raylib/raylib.vcxproj +340 -0
  174. package/vendor/raylib/projects/VS2022/raylib.sln +2347 -0
  175. package/build/qemu/2.1.0-beta.1/koffi_darwin_arm64.tar.gz +0 -0
  176. package/build/qemu/2.1.0-beta.1/koffi_darwin_x64.tar.gz +0 -0
  177. package/build/qemu/2.1.0-beta.1/koffi_freebsd_arm64.tar.gz +0 -0
  178. package/build/qemu/2.1.0-beta.1/koffi_freebsd_ia32.tar.gz +0 -0
  179. package/build/qemu/2.1.0-beta.1/koffi_freebsd_x64.tar.gz +0 -0
  180. package/build/qemu/2.1.0-beta.1/koffi_linux_arm32hf.tar.gz +0 -0
  181. package/build/qemu/2.1.0-beta.1/koffi_linux_arm64.tar.gz +0 -0
  182. package/build/qemu/2.1.0-beta.1/koffi_linux_ia32.tar.gz +0 -0
  183. package/build/qemu/2.1.0-beta.1/koffi_linux_riscv64hf64.tar.gz +0 -0
  184. package/build/qemu/2.1.0-beta.1/koffi_linux_x64.tar.gz +0 -0
  185. package/build/qemu/2.1.0-beta.1/koffi_openbsd_ia32.tar.gz +0 -0
  186. package/build/qemu/2.1.0-beta.1/koffi_openbsd_x64.tar.gz +0 -0
  187. package/build/qemu/2.1.0-beta.1/koffi_win32_arm64.tar.gz +0 -0
  188. package/build/qemu/2.1.0-beta.1/koffi_win32_ia32.tar.gz +0 -0
  189. package/build/qemu/2.1.0-beta.1/koffi_win32_x64.tar.gz +0 -0
  190. package/doc/dist/doctrees/benchmarks.doctree +0 -0
  191. package/doc/dist/doctrees/changes.doctree +0 -0
  192. package/doc/dist/doctrees/contribute.doctree +0 -0
  193. package/doc/dist/doctrees/environment.pickle +0 -0
  194. package/doc/dist/doctrees/functions.doctree +0 -0
  195. package/doc/dist/doctrees/index.doctree +0 -0
  196. package/doc/dist/doctrees/memory.doctree +0 -0
  197. package/doc/dist/doctrees/platforms.doctree +0 -0
  198. package/doc/dist/doctrees/start.doctree +0 -0
  199. package/doc/dist/doctrees/types.doctree +0 -0
  200. package/doc/dist/html/.buildinfo +0 -4
  201. package/doc/dist/html/_sources/benchmarks.md.txt +0 -137
  202. package/doc/dist/html/_sources/changes.md.txt +0 -161
  203. package/doc/dist/html/_sources/contribute.md.txt +0 -127
  204. package/doc/dist/html/_sources/functions.md.txt +0 -355
  205. package/doc/dist/html/_sources/index.rst.txt +0 -39
  206. package/doc/dist/html/_sources/memory.md.txt +0 -32
  207. package/doc/dist/html/_sources/platforms.md.txt +0 -31
  208. package/doc/dist/html/_sources/start.md.txt +0 -100
  209. package/doc/dist/html/_sources/types.md.txt +0 -588
  210. package/doc/dist/html/_static/_sphinx_javascript_frameworks_compat.js +0 -134
  211. package/doc/dist/html/_static/basic.css +0 -932
  212. package/doc/dist/html/_static/bench_linux.png +0 -0
  213. package/doc/dist/html/_static/bench_windows.png +0 -0
  214. package/doc/dist/html/_static/custom.css +0 -22
  215. package/doc/dist/html/_static/debug.css +0 -69
  216. package/doc/dist/html/_static/doctools.js +0 -264
  217. package/doc/dist/html/_static/documentation_options.js +0 -14
  218. package/doc/dist/html/_static/file.png +0 -0
  219. package/doc/dist/html/_static/jquery-3.6.0.js +0 -10881
  220. package/doc/dist/html/_static/jquery.js +0 -2
  221. package/doc/dist/html/_static/language_data.js +0 -199
  222. package/doc/dist/html/_static/minus.png +0 -0
  223. package/doc/dist/html/_static/perf_linux_20220623.png +0 -0
  224. package/doc/dist/html/_static/perf_linux_20220623_2.png +0 -0
  225. package/doc/dist/html/_static/perf_linux_20220627.png +0 -0
  226. package/doc/dist/html/_static/perf_linux_20220628.png +0 -0
  227. package/doc/dist/html/_static/perf_windows_20220623.png +0 -0
  228. package/doc/dist/html/_static/perf_windows_20220623_2.png +0 -0
  229. package/doc/dist/html/_static/perf_windows_20220627.png +0 -0
  230. package/doc/dist/html/_static/perf_windows_20220628.png +0 -0
  231. package/doc/dist/html/_static/plus.png +0 -0
  232. package/doc/dist/html/_static/pygments.css +0 -252
  233. package/doc/dist/html/_static/scripts/furo-extensions.js +0 -0
  234. package/doc/dist/html/_static/scripts/furo.js +0 -3
  235. package/doc/dist/html/_static/scripts/furo.js.LICENSE.txt +0 -7
  236. package/doc/dist/html/_static/scripts/furo.js.map +0 -1
  237. package/doc/dist/html/_static/searchtools.js +0 -531
  238. package/doc/dist/html/_static/skeleton.css +0 -296
  239. package/doc/dist/html/_static/styles/furo-extensions.css +0 -2
  240. package/doc/dist/html/_static/styles/furo-extensions.css.map +0 -1
  241. package/doc/dist/html/_static/styles/furo.css +0 -2
  242. package/doc/dist/html/_static/styles/furo.css.map +0 -1
  243. package/doc/dist/html/_static/underscore-1.13.1.js +0 -2042
  244. package/doc/dist/html/_static/underscore.js +0 -6
  245. package/doc/dist/html/benchmarks.html +0 -572
  246. package/doc/dist/html/changes.html +0 -668
  247. package/doc/dist/html/contribute.html +0 -404
  248. package/doc/dist/html/functions.html +0 -657
  249. package/doc/dist/html/genindex.html +0 -254
  250. package/doc/dist/html/index.html +0 -360
  251. package/doc/dist/html/memory.html +0 -347
  252. package/doc/dist/html/objects.inv +0 -0
  253. package/doc/dist/html/platforms.html +0 -372
  254. package/doc/dist/html/search.html +0 -262
  255. package/doc/dist/html/searchindex.js +0 -1
  256. package/doc/dist/html/start.html +0 -385
  257. package/doc/dist/html/types.html +0 -1097
@@ -216,6 +216,27 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
216
216
  *(uint8_t **)(gpr_ptr++) = return_ptr;
217
217
  }
218
218
 
219
+ #define PUSH_INTEGER(CType) \
220
+ do { \
221
+ if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
222
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
223
+ return false; \
224
+ } \
225
+ \
226
+ CType v = CopyNumber<CType>(value); \
227
+ *((param.gpr_count ? gpr_ptr : args_ptr)++) = (uint64_t)v; \
228
+ } while (false)
229
+ #define PUSH_INTEGER_SWAP(CType) \
230
+ do { \
231
+ if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
232
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
233
+ return false; \
234
+ } \
235
+ \
236
+ CType v = CopyNumber<CType>(value); \
237
+ *((param.gpr_count ? gpr_ptr : args_ptr)++) = (uint64_t)ReverseBytes(v); \
238
+ } while (false)
239
+
219
240
  // Push arguments
220
241
  for (Size i = 0; i < func->parameters.len; i++) {
221
242
  const ParameterInfo &param = func->parameters[i];
@@ -228,77 +249,51 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
228
249
 
229
250
  case PrimitiveKind::Bool: {
230
251
  if (RG_UNLIKELY(!value.IsBoolean())) {
231
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected boolean", GetValueType(instance, value), param.offset + 1);
252
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected boolean", GetValueType(instance, value));
232
253
  return false;
233
254
  }
234
255
 
235
256
  bool b = value.As<Napi::Boolean>();
236
257
  *((param.gpr_count ? gpr_ptr : args_ptr)++) = (uint64_t)b;
237
258
  } break;
238
- case PrimitiveKind::Int8:
239
- case PrimitiveKind::Int16:
240
- case PrimitiveKind::Int32:
241
- case PrimitiveKind::Int64: {
242
- if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
243
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
244
- return false;
245
- }
246
-
247
- int64_t v = CopyNumber<int64_t>(value);
248
- *(int64_t *)((param.gpr_count ? gpr_ptr : args_ptr)++) = v;
249
- } break;
250
- case PrimitiveKind::UInt8:
251
- case PrimitiveKind::UInt16:
252
- case PrimitiveKind::UInt32:
253
- case PrimitiveKind::UInt64: {
254
- if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
255
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
256
- return false;
257
- }
258
-
259
- uint64_t v = CopyNumber<uint64_t>(value);
260
- *((param.gpr_count ? gpr_ptr : args_ptr)++) = v;
261
- } break;
259
+ case PrimitiveKind::Int8: { PUSH_INTEGER(int8_t); } break;
260
+ case PrimitiveKind::UInt8: { PUSH_INTEGER(uint8_t); } break;
261
+ case PrimitiveKind::Int16: { PUSH_INTEGER(int16_t); } break;
262
+ case PrimitiveKind::Int16S: { PUSH_INTEGER_SWAP(int16_t); } break;
263
+ case PrimitiveKind::UInt16: { PUSH_INTEGER(uint16_t); } break;
264
+ case PrimitiveKind::UInt16S: { PUSH_INTEGER_SWAP(uint16_t); } break;
265
+ case PrimitiveKind::Int32: { PUSH_INTEGER(int32_t); } break;
266
+ case PrimitiveKind::Int32S: { PUSH_INTEGER_SWAP(int32_t); } break;
267
+ case PrimitiveKind::UInt32: { PUSH_INTEGER(uint32_t); } break;
268
+ case PrimitiveKind::UInt32S: { PUSH_INTEGER_SWAP(uint32_t); } break;
269
+ case PrimitiveKind::Int64: { PUSH_INTEGER(int64_t); } break;
270
+ case PrimitiveKind::Int64S: { PUSH_INTEGER_SWAP(int64_t); } break;
271
+ case PrimitiveKind::UInt64: { PUSH_INTEGER(uint64_t); } break;
272
+ case PrimitiveKind::UInt64S: { PUSH_INTEGER_SWAP(uint64_t); } break;
262
273
  case PrimitiveKind::String: {
263
274
  const char *str;
264
- if (RG_LIKELY(value.IsString())) {
265
- str = PushString(value);
266
- if (RG_UNLIKELY(!str))
267
- return false;
268
- } else if (IsNullOrUndefined(value)) {
269
- str = nullptr;
270
- } else {
271
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected string", GetValueType(instance, value), param.offset + 1);
275
+ if (RG_UNLIKELY(!PushString(value, &str)))
272
276
  return false;
273
- }
274
277
 
275
278
  *(const char **)((param.gpr_count ? gpr_ptr : args_ptr)++) = str;
276
279
  } break;
277
280
  case PrimitiveKind::String16: {
278
281
  const char16_t *str16;
279
- if (RG_LIKELY(value.IsString())) {
280
- str16 = PushString16(value);
281
- if (RG_UNLIKELY(!str16))
282
- return false;
283
- } else if (IsNullOrUndefined(value)) {
284
- str16 = nullptr;
285
- } else {
286
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected string", GetValueType(instance, value), param.offset + 1);
282
+ if (RG_UNLIKELY(!PushString16(value, &str16)))
287
283
  return false;
288
- }
289
284
 
290
285
  *(const char16_t **)((param.gpr_count ? gpr_ptr : args_ptr)++) = str16;
291
286
  } break;
292
287
  case PrimitiveKind::Pointer: {
293
288
  void *ptr;
294
- if (RG_UNLIKELY(!PushPointer(value, param, &ptr)))
289
+ if (RG_UNLIKELY(!PushPointer(value, param.type, param.directions, &ptr)))
295
290
  return false;
296
291
 
297
292
  *(void **)((param.gpr_count ? gpr_ptr : args_ptr)++) = ptr;
298
293
  } break;
299
294
  case PrimitiveKind::Record: {
300
295
  if (RG_UNLIKELY(!IsObject(value))) {
301
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected object", GetValueType(instance, value), param.offset + 1);
296
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected object", GetValueType(instance, value));
302
297
  return false;
303
298
  }
304
299
 
@@ -347,7 +342,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
347
342
  case PrimitiveKind::Array: { RG_UNREACHABLE(); } break;
348
343
  case PrimitiveKind::Float32: {
349
344
  if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
350
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
345
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
351
346
  return false;
352
347
  }
353
348
 
@@ -366,7 +361,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
366
361
  } break;
367
362
  case PrimitiveKind::Float64: {
368
363
  if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
369
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
364
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
370
365
  return false;
371
366
  }
372
367
 
@@ -394,7 +389,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
394
389
  } else if (IsNullOrUndefined(value)) {
395
390
  ptr = nullptr;
396
391
  } else {
397
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected %3", GetValueType(instance, value), param.offset + 1, param.type->name);
392
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected %2", GetValueType(instance, value), param.type->name);
398
393
  return false;
399
394
  }
400
395
 
@@ -405,6 +400,9 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
405
400
  }
406
401
  }
407
402
 
403
+ #undef PUSH_INTEGER_SWAP
404
+ #undef PUSH_INTEGER
405
+
408
406
  new_sp = mem->stack.end();
409
407
 
410
408
  return true;
@@ -428,11 +426,17 @@ void CallData::Execute()
428
426
  case PrimitiveKind::Int8:
429
427
  case PrimitiveKind::UInt8:
430
428
  case PrimitiveKind::Int16:
429
+ case PrimitiveKind::Int16S:
431
430
  case PrimitiveKind::UInt16:
431
+ case PrimitiveKind::UInt16S:
432
432
  case PrimitiveKind::Int32:
433
+ case PrimitiveKind::Int32S:
433
434
  case PrimitiveKind::UInt32:
435
+ case PrimitiveKind::UInt32S:
434
436
  case PrimitiveKind::Int64:
437
+ case PrimitiveKind::Int64S:
435
438
  case PrimitiveKind::UInt64:
439
+ case PrimitiveKind::UInt64S:
436
440
  case PrimitiveKind::String:
437
441
  case PrimitiveKind::String16:
438
442
  case PrimitiveKind::Pointer:
@@ -478,11 +482,17 @@ Napi::Value CallData::Complete()
478
482
  case PrimitiveKind::Int8: return Napi::Number::New(env, (double)result.i8);
479
483
  case PrimitiveKind::UInt8: return Napi::Number::New(env, (double)result.u8);
480
484
  case PrimitiveKind::Int16: return Napi::Number::New(env, (double)result.i16);
485
+ case PrimitiveKind::Int16S: return Napi::Number::New(env, (double)ReverseBytes(result.i16));
481
486
  case PrimitiveKind::UInt16: return Napi::Number::New(env, (double)result.u16);
487
+ case PrimitiveKind::UInt16S: return Napi::Number::New(env, (double)ReverseBytes(result.u16));
482
488
  case PrimitiveKind::Int32: return Napi::Number::New(env, (double)result.i32);
489
+ case PrimitiveKind::Int32S: return Napi::Number::New(env, (double)ReverseBytes(result.i32));
483
490
  case PrimitiveKind::UInt32: return Napi::Number::New(env, (double)result.u32);
491
+ case PrimitiveKind::UInt32S: return Napi::Number::New(env, (double)ReverseBytes(result.u32));
484
492
  case PrimitiveKind::Int64: return NewBigInt(env, result.i64);
493
+ case PrimitiveKind::Int64S: return NewBigInt(env, ReverseBytes(result.i64));
485
494
  case PrimitiveKind::UInt64: return NewBigInt(env, result.u64);
495
+ case PrimitiveKind::UInt64S: return NewBigInt(env, ReverseBytes(result.u64));
486
496
  case PrimitiveKind::String: return result.ptr ? Napi::String::New(env, (const char *)result.ptr) : env.Null();
487
497
  case PrimitiveKind::String16: return result.ptr ? Napi::String::New(env, (const char16_t *)result.ptr) : env.Null();
488
498
  case PrimitiveKind::Pointer:
@@ -576,36 +586,76 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
576
586
  Napi::Value arg = Napi::Number::New(env, d);
577
587
  arguments.Append(arg);
578
588
  } break;
589
+ case PrimitiveKind::Int16S: {
590
+ int16_t v = *(int16_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
591
+ double d = (double)ReverseBytes(v);
592
+
593
+ Napi::Value arg = Napi::Number::New(env, d);
594
+ arguments.Append(arg);
595
+ } break;
579
596
  case PrimitiveKind::UInt16: {
580
597
  double d = (double)*(uint16_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
581
598
 
582
599
  Napi::Value arg = Napi::Number::New(env, d);
583
600
  arguments.Append(arg);
584
601
  } break;
602
+ case PrimitiveKind::UInt16S: {
603
+ uint16_t v = *(uint16_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
604
+ double d = (double)ReverseBytes(v);
605
+
606
+ Napi::Value arg = Napi::Number::New(env, d);
607
+ arguments.Append(arg);
608
+ } break;
585
609
  case PrimitiveKind::Int32: {
586
610
  double d = (double)*(int32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
587
611
 
588
612
  Napi::Value arg = Napi::Number::New(env, d);
589
613
  arguments.Append(arg);
590
614
  } break;
615
+ case PrimitiveKind::Int32S: {
616
+ int32_t v = *(int32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
617
+ double d = (double)ReverseBytes(v);
618
+
619
+ Napi::Value arg = Napi::Number::New(env, d);
620
+ arguments.Append(arg);
621
+ } break;
591
622
  case PrimitiveKind::UInt32: {
592
623
  double d = (double)*(uint32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
593
624
 
594
625
  Napi::Value arg = Napi::Number::New(env, d);
595
626
  arguments.Append(arg);
596
627
  } break;
628
+ case PrimitiveKind::UInt32S: {
629
+ uint32_t v = *(uint32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
630
+ double d = (double)ReverseBytes(v);
631
+
632
+ Napi::Value arg = Napi::Number::New(env, d);
633
+ arguments.Append(arg);
634
+ } break;
597
635
  case PrimitiveKind::Int64: {
598
636
  int64_t v = *(int64_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
599
637
 
600
638
  Napi::Value arg = NewBigInt(env, v);
601
639
  arguments.Append(arg);
602
640
  } break;
641
+ case PrimitiveKind::Int64S: {
642
+ int64_t v = *(int64_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
643
+
644
+ Napi::Value arg = NewBigInt(env, ReverseBytes(v));
645
+ arguments.Append(arg);
646
+ } break;
603
647
  case PrimitiveKind::UInt64: {
604
648
  uint64_t v = *(uint64_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
605
649
 
606
650
  Napi::Value arg = NewBigInt(env, v);
607
651
  arguments.Append(arg);
608
652
  } break;
653
+ case PrimitiveKind::UInt64S: {
654
+ uint64_t v = *(uint64_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
655
+
656
+ Napi::Value arg = NewBigInt(env, ReverseBytes(v));
657
+ arguments.Append(arg);
658
+ } break;
609
659
  case PrimitiveKind::String: {
610
660
  const char *str = *(const char **)((param.gpr_count ? gpr_ptr : args_ptr)++);
611
661
 
@@ -716,61 +766,64 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
716
766
  if (RG_UNLIKELY(env.IsExceptionPending()))
717
767
  return;
718
768
 
769
+ #define RETURN_INTEGER(CType) \
770
+ do { \
771
+ if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
772
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
773
+ return; \
774
+ } \
775
+ \
776
+ CType v = CopyNumber<CType>(value); \
777
+ out_reg->a0 = (uint64_t)v; \
778
+ } while (false)
779
+ #define RETURN_INTEGER_SWAP(CType) \
780
+ do { \
781
+ if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) { \
782
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value)); \
783
+ return; \
784
+ } \
785
+ \
786
+ CType v = CopyNumber<CType>(value); \
787
+ out_reg->a0 = (uint64_t)ReverseBytes(v); \
788
+ } while (false)
789
+
719
790
  // Convert the result
720
791
  switch (type->primitive) {
721
792
  case PrimitiveKind::Void: {} break;
722
793
  case PrimitiveKind::Bool: {
723
794
  if (RG_UNLIKELY(!value.IsBoolean())) {
724
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected boolean", GetValueType(instance, value));
795
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected boolean", GetValueType(instance, value));
725
796
  return;
726
797
  }
727
798
 
728
799
  bool b = value.As<Napi::Boolean>();
729
800
  out_reg->a0 = (uint64_t)b;
730
801
  } break;
731
- case PrimitiveKind::Int8:
732
- case PrimitiveKind::UInt8:
733
- case PrimitiveKind::Int16:
734
- case PrimitiveKind::UInt16:
735
- case PrimitiveKind::Int32:
736
- case PrimitiveKind::UInt32:
737
- case PrimitiveKind::Int64:
738
- case PrimitiveKind::UInt64: {
739
- if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
740
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
741
- return;
742
- }
743
-
744
- int64_t v = CopyNumber<int64_t>(value);
745
- out_reg->a0 = (uint64_t)v;
746
- } break;
802
+ case PrimitiveKind::Int8: { RETURN_INTEGER(int8_t); } break;
803
+ case PrimitiveKind::UInt8: { RETURN_INTEGER(uint8_t); } break;
804
+ case PrimitiveKind::Int16: { RETURN_INTEGER(int16_t); } break;
805
+ case PrimitiveKind::Int16S: { RETURN_INTEGER_SWAP(int16_t); } break;
806
+ case PrimitiveKind::UInt16: { RETURN_INTEGER(uint16_t); } break;
807
+ case PrimitiveKind::UInt16S: { RETURN_INTEGER_SWAP(uint16_t); } break;
808
+ case PrimitiveKind::Int32: { RETURN_INTEGER(int32_t); } break;
809
+ case PrimitiveKind::Int32S: { RETURN_INTEGER_SWAP(int32_t); } break;
810
+ case PrimitiveKind::UInt32: { RETURN_INTEGER(uint32_t); } break;
811
+ case PrimitiveKind::UInt32S: { RETURN_INTEGER_SWAP(uint32_t); } break;
812
+ case PrimitiveKind::Int64: { RETURN_INTEGER(int64_t); } break;
813
+ case PrimitiveKind::Int64S: { RETURN_INTEGER_SWAP(int64_t); } break;
814
+ case PrimitiveKind::UInt64: { RETURN_INTEGER(uint64_t); } break;
815
+ case PrimitiveKind::UInt64S: { RETURN_INTEGER_SWAP(uint64_t); } break;
747
816
  case PrimitiveKind::String: {
748
817
  const char *str;
749
- if (RG_LIKELY(value.IsString())) {
750
- str = PushString(value);
751
- if (RG_UNLIKELY(!str))
752
- return;
753
- } else if (IsNullOrUndefined(value)) {
754
- str = nullptr;
755
- } else {
756
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected string", GetValueType(instance, value));
818
+ if (RG_UNLIKELY(!PushString(value, &str)))
757
819
  return;
758
- }
759
820
 
760
821
  out_reg->a0 = (uint64_t)str;
761
822
  } break;
762
823
  case PrimitiveKind::String16: {
763
824
  const char16_t *str16;
764
- if (RG_LIKELY(value.IsString())) {
765
- str16 = PushString16(value);
766
- if (RG_UNLIKELY(!str16))
767
- return;
768
- } else if (IsNullOrUndefined(value)) {
769
- str16 = nullptr;
770
- } else {
771
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected string", GetValueType(instance, value));
825
+ if (RG_UNLIKELY(!PushString16(value, &str16)))
772
826
  return;
773
- }
774
827
 
775
828
  out_reg->a0 = (uint64_t)str16;
776
829
  } break;
@@ -789,7 +842,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
789
842
  } else if (IsNullOrUndefined(value)) {
790
843
  ptr = nullptr;
791
844
  } else {
792
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected %2", GetValueType(instance, value), type->name);
845
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected %2", GetValueType(instance, value), type->name);
793
846
  return;
794
847
  }
795
848
 
@@ -797,7 +850,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
797
850
  } break;
798
851
  case PrimitiveKind::Record: {
799
852
  if (RG_UNLIKELY(!IsObject(value))) {
800
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected object", GetValueType(instance, value));
853
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected object", GetValueType(instance, value));
801
854
  return;
802
855
  }
803
856
 
@@ -816,7 +869,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
816
869
  case PrimitiveKind::Array: { RG_UNREACHABLE(); } break;
817
870
  case PrimitiveKind::Float32: {
818
871
  if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
819
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
872
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
820
873
  return;
821
874
  }
822
875
 
@@ -826,7 +879,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
826
879
  } break;
827
880
  case PrimitiveKind::Float64: {
828
881
  if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
829
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
882
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
830
883
  return;
831
884
  }
832
885
 
@@ -847,7 +900,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
847
900
  } else if (IsNullOrUndefined(value)) {
848
901
  ptr = nullptr;
849
902
  } else {
850
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected %2", GetValueType(instance, value), type->name);
903
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected %2", GetValueType(instance, value), type->name);
851
904
  return;
852
905
  }
853
906
 
@@ -857,6 +910,9 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
857
910
  case PrimitiveKind::Prototype: { RG_UNREACHABLE(); } break;
858
911
  }
859
912
 
913
+ #undef RETURN_INTEGER_SWAP
914
+ #undef RETURN_INTEGER
915
+
860
916
  err_guard.Disable();
861
917
  }
862
918