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
@@ -169,11 +169,17 @@ static Size ClassifyType(const TypeInfo *type, Size offset, Span<RegisterClass>
169
169
  case PrimitiveKind::Int8:
170
170
  case PrimitiveKind::UInt8:
171
171
  case PrimitiveKind::Int16:
172
+ case PrimitiveKind::Int16S:
172
173
  case PrimitiveKind::UInt16:
174
+ case PrimitiveKind::UInt16S:
173
175
  case PrimitiveKind::Int32:
176
+ case PrimitiveKind::Int32S:
174
177
  case PrimitiveKind::UInt32:
178
+ case PrimitiveKind::UInt32S:
175
179
  case PrimitiveKind::Int64:
180
+ case PrimitiveKind::Int64S:
176
181
  case PrimitiveKind::UInt64:
182
+ case PrimitiveKind::UInt64S:
177
183
  case PrimitiveKind::String:
178
184
  case PrimitiveKind::String16:
179
185
  case PrimitiveKind::Pointer:
@@ -298,6 +304,27 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
298
304
  *(uint8_t **)(gpr_ptr++) = return_ptr;
299
305
  }
300
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
+
301
328
  // Push arguments
302
329
  for (Size i = 0; i < func->parameters.len; i++) {
303
330
  const ParameterInfo &param = func->parameters[i];
@@ -310,77 +337,51 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
310
337
 
311
338
  case PrimitiveKind::Bool: {
312
339
  if (RG_UNLIKELY(!value.IsBoolean())) {
313
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argmument %2, expected boolean", GetValueType(instance, value), param.offset + 1);
340
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argmument %2, expected boolean", GetValueType(instance, value));
314
341
  return false;
315
342
  }
316
343
 
317
344
  bool b = value.As<Napi::Boolean>();
318
345
  *((param.gpr_count ? gpr_ptr : args_ptr)++) = (uint64_t)b;
319
346
  } break;
320
- case PrimitiveKind::Int8:
321
- case PrimitiveKind::UInt8:
322
- case PrimitiveKind::Int16:
323
- case PrimitiveKind::UInt16:
324
- case PrimitiveKind::Int32:
325
- case PrimitiveKind::UInt32:
326
- case PrimitiveKind::Int64: {
327
- if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
328
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
329
- return false;
330
- }
331
-
332
- int64_t v = CopyNumber<int64_t>(value);
333
- *(int64_t *)((param.gpr_count ? gpr_ptr : args_ptr)++) = v;
334
- } break;
335
- case PrimitiveKind::UInt64: {
336
- if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
337
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
338
- return false;
339
- }
340
-
341
- uint64_t v = CopyNumber<uint64_t>(value);
342
- *((param.gpr_count ? gpr_ptr : args_ptr)++) = v;
343
- } 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;
344
361
  case PrimitiveKind::String: {
345
362
  const char *str;
346
- if (RG_LIKELY(value.IsString())) {
347
- str = PushString(value);
348
- if (RG_UNLIKELY(!str))
349
- return false;
350
- } else if (IsNullOrUndefined(value)) {
351
- str = nullptr;
352
- } else {
353
- 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)))
354
364
  return false;
355
- }
356
365
 
357
366
  *(const char **)((param.gpr_count ? gpr_ptr : args_ptr)++) = str;
358
367
  } break;
359
368
  case PrimitiveKind::String16: {
360
369
  const char16_t *str16;
361
- if (RG_LIKELY(value.IsString())) {
362
- str16 = PushString16(value);
363
- if (RG_UNLIKELY(!str16))
364
- return false;
365
- } else if (IsNullOrUndefined(value)) {
366
- str16 = nullptr;
367
- } else {
368
- 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)))
369
371
  return false;
370
- }
371
372
 
372
373
  *(const char16_t **)((param.gpr_count ? gpr_ptr : args_ptr)++) = str16;
373
374
  } break;
374
375
  case PrimitiveKind::Pointer: {
375
376
  void *ptr;
376
- if (RG_UNLIKELY(!PushPointer(value, param, &ptr)))
377
+ if (RG_UNLIKELY(!PushPointer(value, param.type, param.directions, &ptr)))
377
378
  return false;
378
379
 
379
380
  *(void **)((param.gpr_count ? gpr_ptr : args_ptr)++) = ptr;
380
381
  } break;
381
382
  case PrimitiveKind::Record: {
382
383
  if (RG_UNLIKELY(!IsObject(value))) {
383
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected object", GetValueType(instance, value), param.offset + 1);
384
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected object", GetValueType(instance, value));
384
385
  return false;
385
386
  }
386
387
 
@@ -419,7 +420,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
419
420
  case PrimitiveKind::Array: { RG_UNREACHABLE(); } break;
420
421
  case PrimitiveKind::Float32: {
421
422
  if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
422
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
423
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
423
424
  return false;
424
425
  }
425
426
 
@@ -431,7 +432,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
431
432
  } break;
432
433
  case PrimitiveKind::Float64: {
433
434
  if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
434
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
435
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
435
436
  return false;
436
437
  }
437
438
 
@@ -452,7 +453,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
452
453
  } else if (IsNullOrUndefined(value)) {
453
454
  ptr = nullptr;
454
455
  } else {
455
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected %3", GetValueType(instance, value), param.offset + 1, param.type->name);
456
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected %2", GetValueType(instance, value), param.type->name);
456
457
  return false;
457
458
  }
458
459
 
@@ -463,6 +464,9 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
463
464
  }
464
465
  }
465
466
 
467
+ #undef PUSH_INTEGER_SWAP
468
+ #undef PUSH_INTEGER
469
+
466
470
  new_sp = mem->stack.end();
467
471
 
468
472
  return true;
@@ -486,11 +490,17 @@ void CallData::Execute()
486
490
  case PrimitiveKind::Int8:
487
491
  case PrimitiveKind::UInt8:
488
492
  case PrimitiveKind::Int16:
493
+ case PrimitiveKind::Int16S:
489
494
  case PrimitiveKind::UInt16:
495
+ case PrimitiveKind::UInt16S:
490
496
  case PrimitiveKind::Int32:
497
+ case PrimitiveKind::Int32S:
491
498
  case PrimitiveKind::UInt32:
492
- case PrimitiveKind::Int64:
499
+ case PrimitiveKind::UInt32S:
500
+ case PrimitiveKind::Int64:
501
+ case PrimitiveKind::Int64S:
493
502
  case PrimitiveKind::UInt64:
503
+ case PrimitiveKind::UInt64S:
494
504
  case PrimitiveKind::String:
495
505
  case PrimitiveKind::String16:
496
506
  case PrimitiveKind::Pointer:
@@ -536,11 +546,17 @@ Napi::Value CallData::Complete()
536
546
  case PrimitiveKind::Int8: return Napi::Number::New(env, (double)result.i8);
537
547
  case PrimitiveKind::UInt8: return Napi::Number::New(env, (double)result.u8);
538
548
  case PrimitiveKind::Int16: return Napi::Number::New(env, (double)result.i16);
549
+ case PrimitiveKind::Int16S: return Napi::Number::New(env, (double)ReverseBytes(result.i16));
539
550
  case PrimitiveKind::UInt16: return Napi::Number::New(env, (double)result.u16);
551
+ case PrimitiveKind::UInt16S: return Napi::Number::New(env, (double)ReverseBytes(result.u16));
540
552
  case PrimitiveKind::Int32: return Napi::Number::New(env, (double)result.i32);
553
+ case PrimitiveKind::Int32S: return Napi::Number::New(env, (double)ReverseBytes(result.i32));
541
554
  case PrimitiveKind::UInt32: return Napi::Number::New(env, (double)result.u32);
555
+ case PrimitiveKind::UInt32S: return Napi::Number::New(env, (double)ReverseBytes(result.u32));
542
556
  case PrimitiveKind::Int64: return NewBigInt(env, result.i64);
557
+ case PrimitiveKind::Int64S: return NewBigInt(env, ReverseBytes(result.i64));
543
558
  case PrimitiveKind::UInt64: return NewBigInt(env, result.u64);
559
+ case PrimitiveKind::UInt64S: return NewBigInt(env, ReverseBytes(result.u64));
544
560
  case PrimitiveKind::String: return result.ptr ? Napi::String::New(env, (const char *)result.ptr) : env.Null();
545
561
  case PrimitiveKind::String16: return result.ptr ? Napi::String::New(env, (const char16_t *)result.ptr) : env.Null();
546
562
  case PrimitiveKind::Pointer:
@@ -629,36 +645,76 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
629
645
  Napi::Value arg = Napi::Number::New(env, d);
630
646
  arguments.Append(arg);
631
647
  } break;
648
+ case PrimitiveKind::Int16S: {
649
+ int16_t v = *(int16_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
650
+ double d = (double)ReverseBytes(v);
651
+
652
+ Napi::Value arg = Napi::Number::New(env, d);
653
+ arguments.Append(arg);
654
+ } break;
632
655
  case PrimitiveKind::UInt16: {
633
656
  double d = (double)*(uint16_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
634
657
 
635
658
  Napi::Value arg = Napi::Number::New(env, d);
636
659
  arguments.Append(arg);
637
660
  } break;
661
+ case PrimitiveKind::UInt16S: {
662
+ uint16_t v = *(uint16_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
663
+ double d = (double)ReverseBytes(v);
664
+
665
+ Napi::Value arg = Napi::Number::New(env, d);
666
+ arguments.Append(arg);
667
+ } break;
638
668
  case PrimitiveKind::Int32: {
639
669
  double d = (double)*(int32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
640
670
 
641
671
  Napi::Value arg = Napi::Number::New(env, d);
642
672
  arguments.Append(arg);
643
673
  } break;
674
+ case PrimitiveKind::Int32S: {
675
+ int32_t v = *(int32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
676
+ double d = (double)ReverseBytes(v);
677
+
678
+ Napi::Value arg = Napi::Number::New(env, d);
679
+ arguments.Append(arg);
680
+ } break;
644
681
  case PrimitiveKind::UInt32: {
645
682
  double d = (double)*(uint32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
646
683
 
647
684
  Napi::Value arg = Napi::Number::New(env, d);
648
685
  arguments.Append(arg);
649
686
  } break;
687
+ case PrimitiveKind::UInt32S: {
688
+ uint32_t v = *(uint32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
689
+ double d = (double)ReverseBytes(v);
690
+
691
+ Napi::Value arg = Napi::Number::New(env, d);
692
+ arguments.Append(arg);
693
+ } break;
650
694
  case PrimitiveKind::Int64: {
651
695
  int64_t v = *(int64_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
652
696
 
653
697
  Napi::Value arg = NewBigInt(env, v);
654
698
  arguments.Append(arg);
655
699
  } break;
700
+ case PrimitiveKind::Int64S: {
701
+ int64_t v = *(int64_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
702
+
703
+ Napi::Value arg = NewBigInt(env, ReverseBytes(v));
704
+ arguments.Append(arg);
705
+ } break;
656
706
  case PrimitiveKind::UInt64: {
657
707
  uint64_t v = *(uint64_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
658
708
 
659
709
  Napi::Value arg = NewBigInt(env, v);
660
710
  arguments.Append(arg);
661
711
  } break;
712
+ case PrimitiveKind::UInt64S: {
713
+ uint64_t v = *(uint64_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
714
+
715
+ Napi::Value arg = NewBigInt(env, ReverseBytes(v));
716
+ arguments.Append(arg);
717
+ } break;
662
718
  case PrimitiveKind::String: {
663
719
  const char *str = *(const char **)((param.gpr_count ? gpr_ptr : args_ptr)++);
664
720
 
@@ -758,61 +814,64 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
758
814
  if (RG_UNLIKELY(env.IsExceptionPending()))
759
815
  return;
760
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
+
761
838
  // Convert the result
762
839
  switch (type->primitive) {
763
840
  case PrimitiveKind::Void: {} break;
764
841
  case PrimitiveKind::Bool: {
765
842
  if (RG_UNLIKELY(!value.IsBoolean())) {
766
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected boolean", GetValueType(instance, value));
843
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected boolean", GetValueType(instance, value));
767
844
  return;
768
845
  }
769
846
 
770
847
  bool b = value.As<Napi::Boolean>();
771
848
  out_reg->rax = (uint64_t)b;
772
849
  } break;
773
- case PrimitiveKind::Int8:
774
- case PrimitiveKind::UInt8:
775
- case PrimitiveKind::Int16:
776
- case PrimitiveKind::UInt16:
777
- case PrimitiveKind::Int32:
778
- case PrimitiveKind::UInt32:
779
- case PrimitiveKind::Int64:
780
- case PrimitiveKind::UInt64: {
781
- if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
782
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
783
- return;
784
- }
785
-
786
- int64_t v = CopyNumber<int64_t>(value);
787
- out_reg->rax = (uint64_t)v;
788
- } 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;
789
864
  case PrimitiveKind::String: {
790
865
  const char *str;
791
- if (RG_LIKELY(value.IsString())) {
792
- str = PushString(value);
793
- if (RG_UNLIKELY(!str))
794
- return;
795
- } else if (IsNullOrUndefined(value)) {
796
- str = nullptr;
797
- } else {
798
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected string", GetValueType(instance, value));
866
+ if (RG_UNLIKELY(!PushString(value, &str)))
799
867
  return;
800
- }
801
868
 
802
869
  out_reg->rax = (uint64_t)str;
803
870
  } break;
804
871
  case PrimitiveKind::String16: {
805
872
  const char16_t *str16;
806
- if (RG_LIKELY(value.IsString())) {
807
- str16 = PushString16(value);
808
- if (RG_UNLIKELY(!str16))
809
- return;
810
- } else if (IsNullOrUndefined(value)) {
811
- str16 = nullptr;
812
- } else {
813
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected string", GetValueType(instance, value));
873
+ if (RG_UNLIKELY(!PushString16(value, &str16)))
814
874
  return;
815
- }
816
875
 
817
876
  out_reg->rax = (uint64_t)str16;
818
877
  } break;
@@ -831,7 +890,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
831
890
  } else if (IsNullOrUndefined(value)) {
832
891
  ptr = nullptr;
833
892
  } else {
834
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected %2", GetValueType(instance, value), type->name);
893
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected %2", GetValueType(instance, value), type->name);
835
894
  return;
836
895
  }
837
896
 
@@ -839,7 +898,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
839
898
  } break;
840
899
  case PrimitiveKind::Record: {
841
900
  if (RG_UNLIKELY(!IsObject(value))) {
842
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected object", GetValueType(instance, value));
901
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected object", GetValueType(instance, value));
843
902
  return;
844
903
  }
845
904
 
@@ -874,7 +933,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
874
933
  case PrimitiveKind::Array: { RG_UNREACHABLE(); } break;
875
934
  case PrimitiveKind::Float32: {
876
935
  if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
877
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
936
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
878
937
  return;
879
938
  }
880
939
 
@@ -885,7 +944,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
885
944
  } break;
886
945
  case PrimitiveKind::Float64: {
887
946
  if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
888
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
947
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected number", GetValueType(instance, value));
889
948
  return;
890
949
  }
891
950
 
@@ -906,7 +965,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
906
965
  } else if (IsNullOrUndefined(value)) {
907
966
  ptr = nullptr;
908
967
  } else {
909
- ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected %2", GetValueType(instance, value), type->name);
968
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value, expected %2", GetValueType(instance, value), type->name);
910
969
  return;
911
970
  }
912
971
 
@@ -916,6 +975,9 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
916
975
  case PrimitiveKind::Prototype: { RG_UNREACHABLE(); } break;
917
976
  }
918
977
 
978
+ #undef RETURN_INTEGER_SWAP
979
+ #undef RETURN_INTEGER
980
+
919
981
  err_guard.Disable();
920
982
  }
921
983