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.
Files changed (200) hide show
  1. package/ChangeLog.md +11 -4
  2. package/build/qemu/2.1.1/koffi_darwin_arm64.tar.gz +0 -0
  3. package/build/qemu/2.1.1/koffi_darwin_x64.tar.gz +0 -0
  4. package/build/qemu/2.1.1/koffi_freebsd_arm64.tar.gz +0 -0
  5. package/build/qemu/2.1.1/koffi_freebsd_ia32.tar.gz +0 -0
  6. package/build/qemu/2.1.1/koffi_freebsd_x64.tar.gz +0 -0
  7. package/build/qemu/2.1.1/koffi_linux_arm32hf.tar.gz +0 -0
  8. package/build/qemu/2.1.1/koffi_linux_arm64.tar.gz +0 -0
  9. package/build/qemu/2.1.1/koffi_linux_ia32.tar.gz +0 -0
  10. package/build/qemu/2.1.1/koffi_linux_riscv64hf64.tar.gz +0 -0
  11. package/build/qemu/2.1.1/koffi_linux_x64.tar.gz +0 -0
  12. package/build/qemu/2.1.1/koffi_openbsd_ia32.tar.gz +0 -0
  13. package/build/qemu/2.1.1/koffi_openbsd_x64.tar.gz +0 -0
  14. package/build/qemu/2.1.1/koffi_win32_arm64.tar.gz +0 -0
  15. package/build/qemu/2.1.1/koffi_win32_ia32.tar.gz +0 -0
  16. package/build/qemu/2.1.1/koffi_win32_x64.tar.gz +0 -0
  17. package/doc/Makefile +1 -1
  18. package/doc/benchmarks.md +14 -14
  19. package/doc/benchmarks.xlsx +0 -0
  20. package/doc/conf.py +5 -0
  21. package/doc/index.rst +2 -2
  22. package/doc/make.bat +1 -1
  23. package/doc/static/perf_linux_20220812.png +0 -0
  24. package/doc/static/perf_windows_20220812.png +0 -0
  25. package/doc/templates/badges.html +1 -1
  26. package/doc/types.md +12 -12
  27. package/package.json +2 -1
  28. package/qemu/registry/machines.json +2 -2
  29. package/qemu/registry/sha256sum.txt +2 -2
  30. package/src/abi_arm32.cc +158 -248
  31. package/src/abi_arm64.cc +129 -170
  32. package/src/abi_riscv64.cc +92 -140
  33. package/src/abi_x64_sysv.cc +92 -140
  34. package/src/abi_x64_win.cc +92 -140
  35. package/src/abi_x86.cc +144 -212
  36. package/src/call.cc +117 -143
  37. package/src/call.hh +4 -4
  38. package/src/ffi.cc +16 -4
  39. package/src/util.hh +0 -20
  40. package/test/callbacks.js +3 -3
  41. package/test/misc.c +45 -2
  42. package/test/sync.js +83 -2
  43. package/vendor/libcc/libcc.cc +97 -77
  44. package/vendor/libcc/libcc.hh +362 -259
  45. package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj +226 -0
  46. package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj.filters +10 -0
  47. package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj.user +4 -0
  48. package/vendor/raylib/projects/VS2019-Android/raylib_android.sln +75 -0
  49. package/vendor/raylib/projects/VS2022/examples/audio_module_playing.vcxproj +390 -0
  50. package/vendor/raylib/projects/VS2022/examples/audio_multichannel_sound.vcxproj +390 -0
  51. package/vendor/raylib/projects/VS2022/examples/audio_music_stream.vcxproj +390 -0
  52. package/vendor/raylib/projects/VS2022/examples/audio_raw_stream.vcxproj +390 -0
  53. package/vendor/raylib/projects/VS2022/examples/audio_sound_loading.vcxproj +390 -0
  54. package/vendor/raylib/projects/VS2022/examples/audio_stream_effects.vcxproj +390 -0
  55. package/vendor/raylib/projects/VS2022/examples/core_2d_camera.vcxproj +390 -0
  56. package/vendor/raylib/projects/VS2022/examples/core_2d_camera_mouse_zoom.vcxproj +390 -0
  57. package/vendor/raylib/projects/VS2022/examples/core_2d_camera_platformer.vcxproj +390 -0
  58. package/vendor/raylib/projects/VS2022/examples/core_3d_camera_first_person.vcxproj +390 -0
  59. package/vendor/raylib/projects/VS2022/examples/core_3d_camera_free.vcxproj +390 -0
  60. package/vendor/raylib/projects/VS2022/examples/core_3d_camera_mode.vcxproj +390 -0
  61. package/vendor/raylib/projects/VS2022/examples/core_3d_picking.vcxproj +390 -0
  62. package/vendor/raylib/projects/VS2022/examples/core_basic_screen_manager.vcxproj +390 -0
  63. package/vendor/raylib/projects/VS2022/examples/core_basic_window.vcxproj +390 -0
  64. package/vendor/raylib/projects/VS2022/examples/core_custom_frame_control.vcxproj +390 -0
  65. package/vendor/raylib/projects/VS2022/examples/core_custom_logging.vcxproj +390 -0
  66. package/vendor/raylib/projects/VS2022/examples/core_drop_files.vcxproj +390 -0
  67. package/vendor/raylib/projects/VS2022/examples/core_input_gamepad.vcxproj +387 -0
  68. package/vendor/raylib/projects/VS2022/examples/core_input_gestures.vcxproj +387 -0
  69. package/vendor/raylib/projects/VS2022/examples/core_input_keys.vcxproj +387 -0
  70. package/vendor/raylib/projects/VS2022/examples/core_input_mouse.vcxproj +387 -0
  71. package/vendor/raylib/projects/VS2022/examples/core_input_mouse_wheel.vcxproj +387 -0
  72. package/vendor/raylib/projects/VS2022/examples/core_input_multitouch.vcxproj +387 -0
  73. package/vendor/raylib/projects/VS2022/examples/core_loading_thread.vcxproj +387 -0
  74. package/vendor/raylib/projects/VS2022/examples/core_random_values.vcxproj +387 -0
  75. package/vendor/raylib/projects/VS2022/examples/core_scissor_test.vcxproj +387 -0
  76. package/vendor/raylib/projects/VS2022/examples/core_split_screen.vcxproj +387 -0
  77. package/vendor/raylib/projects/VS2022/examples/core_storage_values.vcxproj +387 -0
  78. package/vendor/raylib/projects/VS2022/examples/core_vr_simulator.vcxproj +387 -0
  79. package/vendor/raylib/projects/VS2022/examples/core_window_flags.vcxproj +387 -0
  80. package/vendor/raylib/projects/VS2022/examples/core_window_letterbox.vcxproj +387 -0
  81. package/vendor/raylib/projects/VS2022/examples/core_window_should_close.vcxproj +390 -0
  82. package/vendor/raylib/projects/VS2022/examples/core_world_screen.vcxproj +387 -0
  83. package/vendor/raylib/projects/VS2022/examples/easings_testbed.vcxproj +387 -0
  84. package/vendor/raylib/projects/VS2022/examples/embedded_files_loading.vcxproj +387 -0
  85. package/vendor/raylib/projects/VS2022/examples/models_animation.vcxproj +387 -0
  86. package/vendor/raylib/projects/VS2022/examples/models_billboard.vcxproj +387 -0
  87. package/vendor/raylib/projects/VS2022/examples/models_box_collisions.vcxproj +387 -0
  88. package/vendor/raylib/projects/VS2022/examples/models_cubicmap.vcxproj +387 -0
  89. package/vendor/raylib/projects/VS2022/examples/models_first_person_maze.vcxproj +387 -0
  90. package/vendor/raylib/projects/VS2022/examples/models_geometric_shapes.vcxproj +387 -0
  91. package/vendor/raylib/projects/VS2022/examples/models_heightmap.vcxproj +387 -0
  92. package/vendor/raylib/projects/VS2022/examples/models_loading.vcxproj +387 -0
  93. package/vendor/raylib/projects/VS2022/examples/models_loading_gltf.vcxproj +387 -0
  94. package/vendor/raylib/projects/VS2022/examples/models_loading_vox.vcxproj +387 -0
  95. package/vendor/raylib/projects/VS2022/examples/models_mesh_generation.vcxproj +387 -0
  96. package/vendor/raylib/projects/VS2022/examples/models_mesh_picking.vcxproj +387 -0
  97. package/vendor/raylib/projects/VS2022/examples/models_orthographic_projection.vcxproj +387 -0
  98. package/vendor/raylib/projects/VS2022/examples/models_rlgl_solar_system.vcxproj +387 -0
  99. package/vendor/raylib/projects/VS2022/examples/models_skybox.vcxproj +387 -0
  100. package/vendor/raylib/projects/VS2022/examples/models_waving_cubes.vcxproj +387 -0
  101. package/vendor/raylib/projects/VS2022/examples/models_yaw_pitch_roll.vcxproj +387 -0
  102. package/vendor/raylib/projects/VS2022/examples/rlgl_compute_shaders.vcxproj +391 -0
  103. package/vendor/raylib/projects/VS2022/examples/rlgl_standalone.vcxproj +391 -0
  104. package/vendor/raylib/projects/VS2022/examples/shaders_basic_lighting.vcxproj +387 -0
  105. package/vendor/raylib/projects/VS2022/examples/shaders_custom_uniform.vcxproj +387 -0
  106. package/vendor/raylib/projects/VS2022/examples/shaders_eratosthenes.vcxproj +387 -0
  107. package/vendor/raylib/projects/VS2022/examples/shaders_fog.vcxproj +387 -0
  108. package/vendor/raylib/projects/VS2022/examples/shaders_hot_reloading.vcxproj +387 -0
  109. package/vendor/raylib/projects/VS2022/examples/shaders_julia_set.vcxproj +387 -0
  110. package/vendor/raylib/projects/VS2022/examples/shaders_mesh_instancing.vcxproj +387 -0
  111. package/vendor/raylib/projects/VS2022/examples/shaders_model_shader.vcxproj +387 -0
  112. package/vendor/raylib/projects/VS2022/examples/shaders_multi_sample2d.vcxproj +387 -0
  113. package/vendor/raylib/projects/VS2022/examples/shaders_palette_switch.vcxproj +387 -0
  114. package/vendor/raylib/projects/VS2022/examples/shaders_postprocessing.vcxproj +387 -0
  115. package/vendor/raylib/projects/VS2022/examples/shaders_raymarching.vcxproj +387 -0
  116. package/vendor/raylib/projects/VS2022/examples/shaders_shapes_textures.vcxproj +387 -0
  117. package/vendor/raylib/projects/VS2022/examples/shaders_simple_mask.vcxproj +387 -0
  118. package/vendor/raylib/projects/VS2022/examples/shaders_spotlight.vcxproj +387 -0
  119. package/vendor/raylib/projects/VS2022/examples/shaders_texture_drawing.vcxproj +387 -0
  120. package/vendor/raylib/projects/VS2022/examples/shaders_texture_waves.vcxproj +387 -0
  121. package/vendor/raylib/projects/VS2022/examples/shapes_basic_shapes.vcxproj +387 -0
  122. package/vendor/raylib/projects/VS2022/examples/shapes_bouncing_ball.vcxproj +387 -0
  123. package/vendor/raylib/projects/VS2022/examples/shapes_collision_area.vcxproj +387 -0
  124. package/vendor/raylib/projects/VS2022/examples/shapes_colors_palette.vcxproj +387 -0
  125. package/vendor/raylib/projects/VS2022/examples/shapes_draw_circle_sector.vcxproj +387 -0
  126. package/vendor/raylib/projects/VS2022/examples/shapes_draw_rectangle_rounded.vcxproj +387 -0
  127. package/vendor/raylib/projects/VS2022/examples/shapes_draw_ring.vcxproj +387 -0
  128. package/vendor/raylib/projects/VS2022/examples/shapes_easings_ball_anim.vcxproj +387 -0
  129. package/vendor/raylib/projects/VS2022/examples/shapes_easings_box_anim.vcxproj +387 -0
  130. package/vendor/raylib/projects/VS2022/examples/shapes_easings_rectangle_array.vcxproj +387 -0
  131. package/vendor/raylib/projects/VS2022/examples/shapes_following_eyes.vcxproj +387 -0
  132. package/vendor/raylib/projects/VS2022/examples/shapes_lines_bezier.vcxproj +387 -0
  133. package/vendor/raylib/projects/VS2022/examples/shapes_logo_raylib.vcxproj +387 -0
  134. package/vendor/raylib/projects/VS2022/examples/shapes_logo_raylib_anim.vcxproj +387 -0
  135. package/vendor/raylib/projects/VS2022/examples/shapes_rectangle_scaling.vcxproj +387 -0
  136. package/vendor/raylib/projects/VS2022/examples/text_codepoints_loading.vcxproj +387 -0
  137. package/vendor/raylib/projects/VS2022/examples/text_draw_3d.vcxproj +387 -0
  138. package/vendor/raylib/projects/VS2022/examples/text_font_filters.vcxproj +387 -0
  139. package/vendor/raylib/projects/VS2022/examples/text_font_loading.vcxproj +387 -0
  140. package/vendor/raylib/projects/VS2022/examples/text_font_sdf.vcxproj +387 -0
  141. package/vendor/raylib/projects/VS2022/examples/text_font_spritefont.vcxproj +387 -0
  142. package/vendor/raylib/projects/VS2022/examples/text_format_text.vcxproj +387 -0
  143. package/vendor/raylib/projects/VS2022/examples/text_input_box.vcxproj +387 -0
  144. package/vendor/raylib/projects/VS2022/examples/text_raylib_fonts.vcxproj +387 -0
  145. package/vendor/raylib/projects/VS2022/examples/text_rectangle_bounds.vcxproj +387 -0
  146. package/vendor/raylib/projects/VS2022/examples/text_unicode.vcxproj +387 -0
  147. package/vendor/raylib/projects/VS2022/examples/text_writing_anim.vcxproj +387 -0
  148. package/vendor/raylib/projects/VS2022/examples/textures_background_scrolling.vcxproj +387 -0
  149. package/vendor/raylib/projects/VS2022/examples/textures_blend_modes.vcxproj +387 -0
  150. package/vendor/raylib/projects/VS2022/examples/textures_bunnymark.vcxproj +387 -0
  151. package/vendor/raylib/projects/VS2022/examples/textures_draw_tiled.vcxproj +387 -0
  152. package/vendor/raylib/projects/VS2022/examples/textures_fog_of_war.vcxproj +387 -0
  153. package/vendor/raylib/projects/VS2022/examples/textures_gif_player.vcxproj +387 -0
  154. package/vendor/raylib/projects/VS2022/examples/textures_image_drawing.vcxproj +387 -0
  155. package/vendor/raylib/projects/VS2022/examples/textures_image_generation.vcxproj +387 -0
  156. package/vendor/raylib/projects/VS2022/examples/textures_image_loading.vcxproj +387 -0
  157. package/vendor/raylib/projects/VS2022/examples/textures_image_processing.vcxproj +387 -0
  158. package/vendor/raylib/projects/VS2022/examples/textures_image_text.vcxproj +387 -0
  159. package/vendor/raylib/projects/VS2022/examples/textures_logo_raylib.vcxproj +387 -0
  160. package/vendor/raylib/projects/VS2022/examples/textures_mouse_painting.vcxproj +387 -0
  161. package/vendor/raylib/projects/VS2022/examples/textures_npatch_drawing.vcxproj +387 -0
  162. package/vendor/raylib/projects/VS2022/examples/textures_particles_blending.vcxproj +387 -0
  163. package/vendor/raylib/projects/VS2022/examples/textures_polygon.vcxproj +387 -0
  164. package/vendor/raylib/projects/VS2022/examples/textures_raw_data.vcxproj +387 -0
  165. package/vendor/raylib/projects/VS2022/examples/textures_sprite_anim.vcxproj +387 -0
  166. package/vendor/raylib/projects/VS2022/examples/textures_sprite_button.vcxproj +387 -0
  167. package/vendor/raylib/projects/VS2022/examples/textures_sprite_explosion.vcxproj +387 -0
  168. package/vendor/raylib/projects/VS2022/examples/textures_srcrec_dstrec.vcxproj +387 -0
  169. package/vendor/raylib/projects/VS2022/examples/textures_to_image.vcxproj +387 -0
  170. package/vendor/raylib/projects/VS2022/raylib/raylib.vcxproj +340 -0
  171. package/vendor/raylib/projects/VS2022/raylib.sln +2347 -0
  172. package/build/qemu/2.1.0-beta.2/koffi_darwin_arm64.tar.gz +0 -0
  173. package/build/qemu/2.1.0-beta.2/koffi_darwin_x64.tar.gz +0 -0
  174. package/build/qemu/2.1.0-beta.2/koffi_freebsd_arm64.tar.gz +0 -0
  175. package/build/qemu/2.1.0-beta.2/koffi_freebsd_ia32.tar.gz +0 -0
  176. package/build/qemu/2.1.0-beta.2/koffi_freebsd_x64.tar.gz +0 -0
  177. package/build/qemu/2.1.0-beta.2/koffi_linux_arm32hf.tar.gz +0 -0
  178. package/build/qemu/2.1.0-beta.2/koffi_linux_arm64.tar.gz +0 -0
  179. package/build/qemu/2.1.0-beta.2/koffi_linux_ia32.tar.gz +0 -0
  180. package/build/qemu/2.1.0-beta.2/koffi_linux_riscv64hf64.tar.gz +0 -0
  181. package/build/qemu/2.1.0-beta.2/koffi_linux_x64.tar.gz +0 -0
  182. package/build/qemu/2.1.0-beta.2/koffi_openbsd_ia32.tar.gz +0 -0
  183. package/build/qemu/2.1.0-beta.2/koffi_openbsd_x64.tar.gz +0 -0
  184. package/build/qemu/2.1.0-beta.2/koffi_win32_arm64.tar.gz +0 -0
  185. package/build/qemu/2.1.0-beta.2/koffi_win32_ia32.tar.gz +0 -0
  186. package/build/qemu/2.1.0-beta.2/koffi_win32_x64.tar.gz +0 -0
  187. package/doc/dist/doctrees/benchmarks.doctree +0 -0
  188. package/doc/dist/doctrees/changes.doctree +0 -0
  189. package/doc/dist/doctrees/contribute.doctree +0 -0
  190. package/doc/dist/doctrees/environment.pickle +0 -0
  191. package/doc/dist/doctrees/functions.doctree +0 -0
  192. package/doc/dist/doctrees/index.doctree +0 -0
  193. package/doc/dist/doctrees/memory.doctree +0 -0
  194. package/doc/dist/doctrees/platforms.doctree +0 -0
  195. package/doc/dist/doctrees/start.doctree +0 -0
  196. package/doc/dist/doctrees/types.doctree +0 -0
  197. package/doc/dist/html/_static/perf_linux_20220627.png +0 -0
  198. package/doc/dist/html/_static/perf_linux_20220628.png +0 -0
  199. package/doc/dist/html/_static/perf_windows_20220627.png +0 -0
  200. package/doc/dist/html/_static/perf_windows_20220628.png +0 -0
package/ChangeLog.md CHANGED
@@ -2,21 +2,28 @@
2
2
 
3
3
  ## History
4
4
 
5
- ### Koffi 2.1.0 (in beta)
5
+ ### Koffi 2.1.1
6
+
7
+ **Main fixes:**
8
+
9
+ - Fix potential memory allocation bugs
10
+
11
+ ### Koffi 2.1.0
6
12
 
7
13
  **Main changes:**
8
14
 
9
15
  - Add [koffi.as()](functions.md#polymorphic-parameters) to support polymorphic APIs based on `void *` parameters
10
- - Add [endian-sensitive integer types](types.md#endian-sensitive-types): `intX_le_t`, `intX_be_t`
16
+ - Add [endian-sensitive integer types](types.md#endian-sensitive-types): `intX_le_t`, `intX_be_t`, `uintX_le_t`, `uintX_be_t`
11
17
  - Accept typed arrays for `void *` parameters
12
18
  - Introduce `koffi.opaque()` to replace `koffi.handle()` (which remains supported until Koffi 3.0)
19
+ - Support JS Array and TypedArray to fill struct and array pointer members
13
20
 
14
21
  **Other changes:**
15
22
 
16
23
  - Improve global performance with inlining and unity builds
17
24
  - Add `size_t` primitive type
18
- - Support member-specific alignement value in structs
19
- - Detect impossible parameters and return types (such as non-pointer opaque types)
25
+ - Support member-specific alignement values in structs
26
+ - Detect impossible parameter and return types (such as non-pointer opaque types)
20
27
  - Various documentation fixes and improvements
21
28
 
22
29
  ### Koffi 2.0.1
package/doc/Makefile CHANGED
@@ -6,7 +6,7 @@
6
6
  SPHINXOPTS ?=
7
7
  SPHINXBUILD ?= sphinx-build
8
8
  SOURCEDIR = .
9
- BUILDDIR = dist
9
+ BUILDDIR = ../build/doc
10
10
 
11
11
  # Put it first so that "make" without argument is like "make help".
12
12
  help:
package/doc/benchmarks.md CHANGED
@@ -10,8 +10,8 @@ Here is a quick overview of the execution time of Koffi calls on three benchmark
10
10
 
11
11
  <table style="margin: 0 auto;">
12
12
  <tr>
13
- <td><a href="_static/perf_linux_20220628.png" target="_blank"><img src="_static/perf_linux_20220628.png" alt="Linux x86_64 performance" style="width: 350px;"/></a></td>
14
- <td><a href="_static/perf_windows_20220628.png" target="_blank"><img src="_static/perf_windows_20220628.png" alt="Windows x86_64 performance" style="width: 350px;"/></a></td>
13
+ <td><a href="_static/perf_linux_20220812.png" target="_blank"><img src="_static/perf_linux_20220812.png" alt="Linux x86_64 performance" style="width: 350px;"/></a></td>
14
+ <td><a href="_static/perf_windows_20220812.png" target="_blank"><img src="_static/perf_windows_20220812.png" alt="Windows x86_64 performance" style="width: 350px;"/></a></td>
15
15
  </tr>
16
16
  </table>
17
17
 
@@ -31,9 +31,9 @@ This test is based around repeated calls to a simple standard C function atoi, a
31
31
 
32
32
  Benchmark | Iteration time | Relative performance | Overhead
33
33
  ------------- | -------------- | -------------------- | --------
34
- rand_napi | 644 ns | x1.00 | (ref)
35
- rand_koffi | 950 ns | x0.68 | +48%
36
- rand_node_ffi | 30350 ns | x0.02 | +4613%
34
+ rand_napi | 842 ns | x1.00 | (ref)
35
+ rand_koffi | 1114 ns | x0.76 | +32%
36
+ rand_node_ffi | 44845 ns | x0.02 | +5224%
37
37
 
38
38
  Because rand is a pretty small function, the FFI overhead is clearly visible.
39
39
 
@@ -43,9 +43,9 @@ This test is similar to the rand one, but it is based on atoi, which takes a str
43
43
 
44
44
  Benchmark | Iteration time | Relative performance | Overhead
45
45
  ------------- | -------------- | -------------------- | --------
46
- atoi_napi | 1104 ns | x1.00 | (ref)
47
- atoi_koffi | 1778 ns | x0.62 | +61%
48
- atoi_node_ffi | 125300 ns | x0.009 | +11250%
46
+ atoi_napi | 921 ns | x1.00 | (ref)
47
+ atoi_koffi | 1357 ns | x0.68 | +47%
48
+ atoi_node_ffi | 152550 ns | x0.006 | +16472%
49
49
 
50
50
  Because atoi is a pretty small function, the FFI overhead is clearly visible.
51
51
 
@@ -77,9 +77,9 @@ This test is based around repeated calls to a simple standard C function atoi, a
77
77
 
78
78
  Benchmark | Iteration time | Relative performance | Overhead
79
79
  ------------- | -------------- | -------------------- | --------
80
- rand_napi | 965 ns | x1.00 | (ref)
81
- rand_koffi | 1248 ns | x0.77 | +29%
82
- rand_node_ffi | 41500 ns | x0.02 | +4203%
80
+ rand_napi | 964 ns | x1.00 | (ref)
81
+ rand_koffi | 1274 ns | x0.76 | +32%
82
+ rand_node_ffi | 42300 ns | x0.02 | +4289%
83
83
 
84
84
  Because rand is a pretty small function, the FFI overhead is clearly visible.
85
85
 
@@ -91,9 +91,9 @@ The results below were measured on my x86_64 Windows machine (Intel® Core™ i5
91
91
 
92
92
  Benchmark | Iteration time | Relative performance | Overhead
93
93
  ------------- | -------------- | -------------------- | --------
94
- atoi_napi | 1393 ns | x1.00 | (ref)
95
- atoi_koffi | 2246 ns | x0.62 | +61%
96
- atoi_node_ffi | 157550 ns | x0.009 | +11210%
94
+ atoi_napi | 1415 ns | x1.00 | (ref)
95
+ atoi_koffi | 2193 ns | x0.65 | +55%
96
+ atoi_node_ffi | 168300 ns | x0.008 | +11792%
97
97
 
98
98
  Because atoi is a pretty small function, the FFI overhead is clearly visible.
99
99
 
Binary file
package/doc/conf.py CHANGED
@@ -12,6 +12,7 @@ with open(os.path.dirname(__file__) + '/../package.json') as f:
12
12
 
13
13
  version = config['version']
14
14
  revision = config['version']
15
+ stable = config['stable']
15
16
 
16
17
  # -- General configuration ---------------------------------------------------
17
18
 
@@ -61,6 +62,10 @@ html_sidebars = {
61
62
  ]
62
63
  }
63
64
 
65
+ html_context = {
66
+ "stable": stable
67
+ }
68
+
64
69
  # -- MyST parser options -------------------------------------------------
65
70
 
66
71
  myst_enable_extensions = [
package/doc/index.rst CHANGED
@@ -1,5 +1,5 @@
1
- Koffi |version|
2
- ===============
1
+ Koffi
2
+ =====
3
3
 
4
4
  Overview
5
5
  --------
package/doc/make.bat CHANGED
@@ -8,7 +8,7 @@ if "%SPHINXBUILD%" == "" (
8
8
  set SPHINXBUILD=sphinx-build
9
9
  )
10
10
  set SOURCEDIR=.
11
- set BUILDDIR=dist
11
+ set BUILDDIR=../build/doc
12
12
 
13
13
  %SPHINXBUILD% >NUL 2>NUL
14
14
  if errorlevel 9009 (
@@ -1,4 +1,4 @@
1
1
  <div style="text-align: center; margin-top: 2em;">
2
- <a href="https://www.npmjs.com/package/koffi"><img src="https://img.shields.io/badge/NPM-Koffi-brightgreen" alt="NPM"/></a>
2
+ <a href="https://www.npmjs.com/package/koffi"><img src="https://img.shields.io/badge/NPM-{{ stable }}-brightgreen" alt="NPM"/></a>
3
3
  <a href="https://github.com/Koromix/luigi/tree/master/koffi"><img src="https://img.shields.io/badge/GitHub-Koffi-ff6600" alt="GitHub"/></a>
4
4
  </div>
package/doc/types.md CHANGED
@@ -58,6 +58,8 @@ let struct2 = koffi.struct({ dummy: koffi.types.long });
58
58
 
59
59
  ### Endian-sensitive types
60
60
 
61
+ *New in Koffi 2.1*
62
+
61
63
  Koffi defines a bunch of endian-sensitive types, which can be used when dealing with binary data (network payloads, binary file formats, etc.).
62
64
 
63
65
  JS type | C type | Bytes | Signedness | Endianness
@@ -109,16 +111,6 @@ const A = koffi.struct('A', {
109
111
  });
110
112
  ```
111
113
 
112
- Koffi follows the C and ABI rules regarding struct alignment and padding.
113
-
114
- Once a struct is declared, you can use it by name (with a string, like you can do for primitive types) or through the value returned by the call to `koffi.struct()`. Only the latter is possible when declaring an anonymous struct.
115
-
116
- ```js
117
- // The following two function declarations are equivalent, and declare a function taking an A value and returning A
118
- const Function1 = lib.func('A Function(A value)');
119
- const Function2 = lib.func('Function', A, [A]);
120
- ```
121
-
122
114
  Koffi automatically follows the platform C ABI regarding alignment and padding. However, you can override these rules if needed with:
123
115
 
124
116
  - Pack all members without padding with `koffi.pack()` (instead of `koffi.struct()`)
@@ -131,13 +123,21 @@ const PackedStruct = koffi.pack('PackedStruct', {
131
123
  b: 'int16_t'
132
124
  });
133
125
 
134
- // This one is 18 bytes long, the second member has an alignment requirement of 16 bytes
126
+ // This one is 10 bytes long, the second member has an alignment requirement of 8 bytes
135
127
  const BigStruct = koffi.struct('BigStruct', {
136
128
  a: 'int8_t',
137
- b: [16, 'int16_t']
129
+ b: [8, 'int16_t']
138
130
  })
139
131
  ```
140
132
 
133
+ Once a struct is declared, you can use it by name (with a string, like you can do for primitive types) or through the value returned by the call to `koffi.struct()`. Only the latter is possible when declaring an anonymous struct.
134
+
135
+ ```js
136
+ // The following two function declarations are equivalent, and declare a function taking an A value and returning A
137
+ const Function1 = lib.func('A Function(A value)');
138
+ const Function2 = lib.func('Function', A, [A]);
139
+ ```
140
+
141
141
  ### Opaque types
142
142
 
143
143
  Many C libraries use some kind of object-oriented API, with a pair of functions dedicated to create and delete objects. An obvious example of this can be found in stdio.h, with the opaque `FILE *` pointer. You can open and close files with `fopen()` and `fclose()`, and manipule the opaque pointer with other functions such as `fread()` or `ftell()`.
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "2.1.0-beta.2",
3
+ "version": "2.1.1",
4
+ "stable": "2.1.1",
4
5
  "description": "Fast and simple C FFI (foreign function interface) for Node.js",
5
6
  "keywords": [
6
7
  "foreign",
@@ -178,7 +178,7 @@
178
178
  "qemu": {
179
179
  "binary": "qemu-system-x86_64",
180
180
  "arguments": ["-m", "3G", "-smp", 4, "-rtc", "clock=host,base=localtime", "-bios", "bios.bin", "-hda", "disk.qcow2", "-netdev", "user,id=mynet,hostfwd=tcp::22205-:22", "-device", "e1000,netdev=mynet", "-vga", "std", "-device", "qemu-xhci", "-device", "usb-tablet", "-vnc", "127.0.0.1:15"],
181
- "version": 10,
181
+ "version": 11,
182
182
 
183
183
  "ssh_port": 22205,
184
184
  "vnc_port": 5915,
@@ -227,7 +227,7 @@
227
227
  "Windows x64": {
228
228
  "directory": "C:/Users/windows/Desktop/luigi_x64",
229
229
  "build": {
230
- "Build": "C:\\Node64\\node64.cmd node ../cnoke/cnoke.js -d test --prefer-clang"
230
+ "Build": "C:\\Node64\\node64.cmd node ../cnoke/cnoke.js -d test"
231
231
  },
232
232
  "commands": {
233
233
  "Test Sync": "C:\\Node64\\node64.cmd node test/sync.js",
@@ -1,7 +1,7 @@
1
- 917df3320d778ddbaa5c5c7742bc4046bf803c36ed2b050f30844ed206783469 *qemu/windows_x64/VERSION
1
+ 25d4f2a86deb5e2574bb3210b67bb24fcc4afb19f93a7b65a057daa874a9d18e *qemu/windows_x64/VERSION
2
2
  0a40f87b2a038522e55318a0abde60403bb13a5e81a7a0966a9a736e65d4ae46 *qemu/windows_x64/install.sh
3
3
  f8c9a1638a3fc2cdd214f2cbcad6fee0e3b2c9383942bbd49b3915bb4c3da102 *qemu/windows_x64/bios.bin
4
- 60b1fea3f0ec2c27b410a45b659deb53bb8d5367989207a8850fdfcbc2d83eb1 *qemu/windows_x64/disk.qcow2
4
+ 62a6f3210acf3c9f8d1c5036998da8cecd24e59b75bb2fd6897e990f83546eec *qemu/windows_x64/disk.qcow2
5
5
  1121cfccd5913f0a63fec40a6ffd44ea64f9dc135c66634ba001d10bcf4302a2 *qemu/debian_x64/VERSION
6
6
  ba418d2d602981fe324ae7a1a608b0f2d8d7c6113d03a429cc402e24ddc81311 *qemu/debian_x64/vmlinuz-5.10.0-12-amd64
7
7
  4d44622e8ce058017c08051d694b8e5afe9ff406b6ad91c17ebc4ec43d205c42 *qemu/debian_x64/install.sh