koffi 2.1.0-beta.2 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog.md +11 -4
- package/build/qemu/2.1.1/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_win32_x64.tar.gz +0 -0
- package/doc/Makefile +1 -1
- package/doc/benchmarks.md +14 -14
- package/doc/benchmarks.xlsx +0 -0
- package/doc/conf.py +5 -0
- package/doc/index.rst +2 -2
- package/doc/make.bat +1 -1
- package/doc/static/perf_linux_20220812.png +0 -0
- package/doc/static/perf_windows_20220812.png +0 -0
- package/doc/templates/badges.html +1 -1
- package/doc/types.md +12 -12
- package/package.json +2 -1
- package/qemu/registry/machines.json +2 -2
- package/qemu/registry/sha256sum.txt +2 -2
- package/src/abi_arm32.cc +158 -248
- package/src/abi_arm64.cc +129 -170
- package/src/abi_riscv64.cc +92 -140
- package/src/abi_x64_sysv.cc +92 -140
- package/src/abi_x64_win.cc +92 -140
- package/src/abi_x86.cc +144 -212
- package/src/call.cc +117 -143
- package/src/call.hh +4 -4
- package/src/ffi.cc +16 -4
- package/src/util.hh +0 -20
- package/test/callbacks.js +3 -3
- package/test/misc.c +45 -2
- package/test/sync.js +83 -2
- package/vendor/libcc/libcc.cc +97 -77
- package/vendor/libcc/libcc.hh +362 -259
- package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj +226 -0
- package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj.filters +10 -0
- package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj.user +4 -0
- package/vendor/raylib/projects/VS2019-Android/raylib_android.sln +75 -0
- package/vendor/raylib/projects/VS2022/examples/audio_module_playing.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/audio_multichannel_sound.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/audio_music_stream.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/audio_raw_stream.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/audio_sound_loading.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/audio_stream_effects.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_2d_camera.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_2d_camera_mouse_zoom.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_2d_camera_platformer.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_3d_camera_first_person.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_3d_camera_free.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_3d_camera_mode.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_3d_picking.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_basic_screen_manager.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_basic_window.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_custom_frame_control.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_custom_logging.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_drop_files.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_input_gamepad.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_input_gestures.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_input_keys.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_input_mouse.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_input_mouse_wheel.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_input_multitouch.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_loading_thread.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_random_values.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_scissor_test.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_split_screen.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_storage_values.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_vr_simulator.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_window_flags.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_window_letterbox.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/core_window_should_close.vcxproj +390 -0
- package/vendor/raylib/projects/VS2022/examples/core_world_screen.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/easings_testbed.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/embedded_files_loading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_animation.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_billboard.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_box_collisions.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_cubicmap.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_first_person_maze.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_geometric_shapes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_heightmap.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_loading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_loading_gltf.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_loading_vox.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_mesh_generation.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_mesh_picking.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_orthographic_projection.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_rlgl_solar_system.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_skybox.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_waving_cubes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/models_yaw_pitch_roll.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/rlgl_compute_shaders.vcxproj +391 -0
- package/vendor/raylib/projects/VS2022/examples/rlgl_standalone.vcxproj +391 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_basic_lighting.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_custom_uniform.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_eratosthenes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_fog.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_hot_reloading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_julia_set.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_mesh_instancing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_model_shader.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_multi_sample2d.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_palette_switch.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_postprocessing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_raymarching.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_shapes_textures.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_simple_mask.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_spotlight.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_texture_drawing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shaders_texture_waves.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_basic_shapes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_bouncing_ball.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_collision_area.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_colors_palette.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_draw_circle_sector.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_draw_rectangle_rounded.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_draw_ring.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_easings_ball_anim.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_easings_box_anim.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_easings_rectangle_array.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_following_eyes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_lines_bezier.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_logo_raylib.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_logo_raylib_anim.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/shapes_rectangle_scaling.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_codepoints_loading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_draw_3d.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_font_filters.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_font_loading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_font_sdf.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_font_spritefont.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_format_text.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_input_box.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_raylib_fonts.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_rectangle_bounds.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_unicode.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/text_writing_anim.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_background_scrolling.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_blend_modes.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_bunnymark.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_draw_tiled.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_fog_of_war.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_gif_player.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_image_drawing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_image_generation.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_image_loading.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_image_processing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_image_text.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_logo_raylib.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_mouse_painting.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_npatch_drawing.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_particles_blending.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_polygon.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_raw_data.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_sprite_anim.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_sprite_button.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_sprite_explosion.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_srcrec_dstrec.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/examples/textures_to_image.vcxproj +387 -0
- package/vendor/raylib/projects/VS2022/raylib/raylib.vcxproj +340 -0
- package/vendor/raylib/projects/VS2022/raylib.sln +2347 -0
- package/build/qemu/2.1.0-beta.2/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_win32_x64.tar.gz +0 -0
- package/doc/dist/doctrees/benchmarks.doctree +0 -0
- package/doc/dist/doctrees/changes.doctree +0 -0
- package/doc/dist/doctrees/contribute.doctree +0 -0
- package/doc/dist/doctrees/environment.pickle +0 -0
- package/doc/dist/doctrees/functions.doctree +0 -0
- package/doc/dist/doctrees/index.doctree +0 -0
- package/doc/dist/doctrees/memory.doctree +0 -0
- package/doc/dist/doctrees/platforms.doctree +0 -0
- package/doc/dist/doctrees/start.doctree +0 -0
- package/doc/dist/doctrees/types.doctree +0 -0
- package/doc/dist/html/_static/perf_linux_20220627.png +0 -0
- package/doc/dist/html/_static/perf_linux_20220628.png +0 -0
- package/doc/dist/html/_static/perf_windows_20220627.png +0 -0
- package/doc/dist/html/_static/perf_windows_20220628.png +0 -0
package/ChangeLog.md
CHANGED
|
@@ -2,21 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
## History
|
|
4
4
|
|
|
5
|
-
### Koffi 2.1.
|
|
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
|
|
19
|
-
- Detect impossible
|
|
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
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/doc/Makefile
CHANGED
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/
|
|
14
|
-
<td><a href="_static/
|
|
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 |
|
|
35
|
-
rand_koffi |
|
|
36
|
-
rand_node_ffi |
|
|
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 |
|
|
47
|
-
atoi_koffi |
|
|
48
|
-
atoi_node_ffi |
|
|
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 |
|
|
81
|
-
rand_koffi |
|
|
82
|
-
rand_node_ffi |
|
|
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 |
|
|
95
|
-
atoi_koffi |
|
|
96
|
-
atoi_node_ffi |
|
|
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
|
|
package/doc/benchmarks.xlsx
CHANGED
|
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
package/doc/make.bat
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -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-
|
|
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
|
|
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: [
|
|
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
|
@@ -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":
|
|
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
|
|
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
|
-
|
|
1
|
+
25d4f2a86deb5e2574bb3210b67bb24fcc4afb19f93a7b65a057daa874a9d18e *qemu/windows_x64/VERSION
|
|
2
2
|
0a40f87b2a038522e55318a0abde60403bb13a5e81a7a0966a9a736e65d4ae46 *qemu/windows_x64/install.sh
|
|
3
3
|
f8c9a1638a3fc2cdd214f2cbcad6fee0e3b2c9383942bbd49b3915bb4c3da102 *qemu/windows_x64/bios.bin
|
|
4
|
-
|
|
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
|