koffi 2.12.1 → 2.12.3
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 +21 -0
- package/LICENSE.txt +2 -2
- package/README.md +8 -8
- package/build/koffi/darwin_arm64/koffi.node +0 -0
- package/build/koffi/darwin_x64/koffi.node +0 -0
- package/build/koffi/freebsd_arm64/koffi.node +0 -0
- package/build/koffi/freebsd_ia32/koffi.node +0 -0
- package/build/koffi/freebsd_x64/koffi.node +0 -0
- package/build/koffi/linux_arm64/koffi.node +0 -0
- package/build/koffi/linux_armhf/koffi.node +0 -0
- package/build/koffi/linux_ia32/koffi.node +0 -0
- package/build/koffi/linux_loong64/koffi.node +0 -0
- package/build/koffi/linux_riscv64d/koffi.node +0 -0
- package/build/koffi/linux_x64/koffi.node +0 -0
- package/build/koffi/musl_arm64/koffi.node +0 -0
- package/build/koffi/musl_x64/koffi.node +0 -0
- package/build/koffi/openbsd_ia32/koffi.node +0 -0
- package/build/koffi/openbsd_x64/koffi.node +0 -0
- package/build/koffi/win32_arm64/koffi.exp +0 -0
- package/build/koffi/win32_arm64/koffi.node +0 -0
- package/build/koffi/win32_ia32/koffi.exp +0 -0
- package/build/koffi/win32_ia32/koffi.node +0 -0
- package/build/koffi/win32_x64/koffi.exp +0 -0
- package/build/koffi/win32_x64/koffi.node +0 -0
- package/doc/assets.ini +3 -3
- package/doc/develop.sh +4 -3
- package/doc/pages/platforms.md +1 -1
- package/doc/static/highlight.js +1 -1
- package/doc/static/koffi.css +3 -2
- package/doc/static/print.css +1 -1
- package/doc/templates/code.html +5 -5
- package/doc/templates/page.html +4 -4
- package/index.d.ts +228 -145
- package/index.js +25 -25
- package/indirect.js +25 -5
- package/package.json +2 -2
- package/src/cnoke/LICENSE.txt +2 -2
- package/src/cnoke/README.md +2 -0
- package/src/cnoke/assets/FindCNoke.cmake +12 -2
- package/src/cnoke/assets/win_delay_hook.c +4 -4
- package/src/cnoke/cnoke.js +4 -2
- package/src/cnoke/package.json +1 -1
- package/src/cnoke/src/builder.js +11 -14
- package/src/cnoke/src/index.js +2 -2
- package/src/cnoke/src/tools.js +34 -2
- package/src/core/{libcc/libcc.cc → base/base.cc} +3174 -1640
- package/src/core/{libcc/libcc.hh → base/base.hh} +3066 -2427
- package/src/core/{libcc → base}/mimetypes.inc +42 -4
- package/src/core/{libcc → base}/mimetypes_gen.py +3 -3
- package/src/core/base/unicode.inc +426 -0
- package/src/core/base/unicode_gen.py +189 -0
- package/src/koffi/CMakeLists.txt +7 -5
- package/src/koffi/cmake/raylib.cmake +6 -2
- package/src/koffi/cmake/{sqlite.cmake → sqlite3.cmake} +3 -3
- package/src/koffi/examples/electron-forge/forge.config.js +23 -3
- package/src/koffi/examples/electron-forge/package.json +18 -16
- package/src/koffi/src/abi_arm32.cc +7 -7
- package/src/koffi/src/abi_arm32_asm.S +2 -2
- package/src/koffi/src/abi_arm64.cc +45 -45
- package/src/koffi/src/abi_arm64_asm.S +4 -4
- package/src/koffi/src/abi_arm64_asm.asm +2 -2
- package/src/koffi/src/abi_loong64_asm.S +2 -2
- package/src/koffi/src/abi_riscv64.cc +5 -5
- package/src/koffi/src/abi_riscv64_asm.S +2 -2
- package/src/koffi/src/abi_x64_sysv.cc +3 -3
- package/src/koffi/src/abi_x64_sysv_asm.S +5 -5
- package/src/koffi/src/abi_x64_win.cc +3 -3
- package/src/koffi/src/abi_x64_win_asm.asm +2 -2
- package/src/koffi/src/abi_x86.cc +8 -8
- package/src/koffi/src/abi_x86_asm.S +2 -2
- package/src/koffi/src/abi_x86_asm.asm +2 -2
- package/src/koffi/src/call.cc +12 -12
- package/src/koffi/src/call.hh +8 -8
- package/src/koffi/src/errno.inc +152 -152
- package/src/koffi/src/ffi.cc +44 -39
- package/src/koffi/src/ffi.hh +6 -6
- package/src/koffi/src/init.js +1 -1
- package/src/koffi/src/parser.cc +5 -5
- package/src/koffi/src/parser.hh +3 -3
- package/src/koffi/src/trampolines/armasm.inc +2 -2
- package/src/koffi/src/trampolines/gnu.inc +2 -2
- package/src/koffi/src/trampolines/masm32.inc +2 -2
- package/src/koffi/src/trampolines/masm64.inc +2 -2
- package/src/koffi/src/trampolines/prototypes.inc +2 -2
- package/src/koffi/src/util.cc +9 -9
- package/src/koffi/src/util.hh +3 -3
- package/src/koffi/src/win32.cc +5 -5
- package/src/koffi/src/win32.hh +9 -9
- package/vendor/node-addon-api/CHANGELOG.md +97 -2
- package/vendor/node-addon-api/CONTRIBUTING.md +117 -7
- package/vendor/node-addon-api/README.md +25 -249
- package/vendor/node-addon-api/common.gypi +1 -0
- package/vendor/node-addon-api/doc/README.md +145 -0
- package/vendor/node-addon-api/doc/array_buffer.md +15 -15
- package/vendor/node-addon-api/doc/basic_env.md +200 -0
- package/vendor/node-addon-api/doc/buffer.md +24 -26
- package/vendor/node-addon-api/doc/cmake-js.md +19 -0
- package/vendor/node-addon-api/doc/{creating_a_release.md → contributing/creating_a_release.md} +16 -4
- package/vendor/node-addon-api/doc/env.md +11 -131
- package/vendor/node-addon-api/doc/error_handling.md +12 -0
- package/vendor/node-addon-api/doc/external.md +13 -4
- package/vendor/node-addon-api/doc/finalization.md +153 -0
- package/vendor/node-addon-api/doc/memory_management.md +1 -1
- package/vendor/node-addon-api/doc/object_wrap.md +19 -3
- package/vendor/node-addon-api/doc/promises.md +51 -0
- package/vendor/node-addon-api/doc/setup.md +29 -6
- package/vendor/node-addon-api/doc/value.md +13 -0
- package/vendor/node-addon-api/doc/version_management.md +2 -2
- package/vendor/node-addon-api/eslint.config.js +5 -0
- package/vendor/node-addon-api/index.js +2 -0
- package/vendor/node-addon-api/napi-inl.h +592 -166
- package/vendor/node-addon-api/napi.h +167 -59
- package/vendor/node-addon-api/node_addon_api.gyp +10 -0
- package/vendor/node-addon-api/noexcept.gypi +1 -1
- package/vendor/node-addon-api/package.json +10 -13
- package/vendor/node-addon-api/release-please-config.json +15 -0
- package/vendor/node-addon-api/test/addon_build/tpl/binding.gyp +2 -1
- package/vendor/node-addon-api/test/array_buffer.js +1 -1
- package/vendor/node-addon-api/test/async_context.js +2 -2
- package/vendor/node-addon-api/test/async_progress_queue_worker.js +3 -3
- package/vendor/node-addon-api/test/async_progress_worker.js +3 -3
- package/vendor/node-addon-api/test/async_worker.cc +15 -13
- package/vendor/node-addon-api/test/async_worker.js +5 -5
- package/vendor/node-addon-api/test/basic_types/value.cc +6 -0
- package/vendor/node-addon-api/test/basic_types/value.js +17 -0
- package/vendor/node-addon-api/test/binding.cc +8 -0
- package/vendor/node-addon-api/test/binding.gyp +23 -1
- package/vendor/node-addon-api/test/buffer.js +1 -2
- package/vendor/node-addon-api/test/common/index.js +1 -1
- package/vendor/node-addon-api/test/except_all.cc +22 -0
- package/vendor/node-addon-api/test/except_all.js +14 -0
- package/vendor/node-addon-api/test/exports.js +19 -0
- package/vendor/node-addon-api/test/finalizer_order.cc +152 -0
- package/vendor/node-addon-api/test/finalizer_order.js +98 -0
- package/vendor/node-addon-api/test/function.js +2 -2
- package/vendor/node-addon-api/test/function_reference.js +2 -2
- package/vendor/node-addon-api/test/globalObject/global_object_delete_property.cc +4 -4
- package/vendor/node-addon-api/test/globalObject/global_object_get_property.cc +4 -4
- package/vendor/node-addon-api/test/globalObject/global_object_has_own_property.cc +3 -3
- package/vendor/node-addon-api/test/globalObject/global_object_set_property.cc +5 -5
- package/vendor/node-addon-api/test/name.cc +10 -8
- package/vendor/node-addon-api/test/object/delete_property.cc +5 -5
- package/vendor/node-addon-api/test/object/get_property.cc +5 -5
- package/vendor/node-addon-api/test/object/has_own_property.cc +4 -4
- package/vendor/node-addon-api/test/object/has_property.cc +5 -5
- package/vendor/node-addon-api/test/object/object.cc +1 -1
- package/vendor/node-addon-api/test/object/set_property.cc +5 -5
- package/vendor/node-addon-api/test/object/subscript_operator.cc +3 -3
- package/vendor/node-addon-api/test/object_reference.cc +18 -18
- package/vendor/node-addon-api/test/promise.cc +75 -0
- package/vendor/node-addon-api/test/promise.js +23 -0
- package/vendor/node-addon-api/test/require_basic_finalizers/index.js +38 -0
- package/vendor/node-addon-api/test/require_basic_finalizers/tpl/addon.cc +12 -0
- package/vendor/node-addon-api/test/require_basic_finalizers/tpl/binding.gyp +48 -0
- package/vendor/node-addon-api/test/require_basic_finalizers/tpl/index.js +3 -0
- package/vendor/node-addon-api/test/require_basic_finalizers/tpl/package.json +11 -0
- package/vendor/node-addon-api/test/run_script.cc +1 -1
- package/vendor/node-addon-api/test/type_taggable.cc +1 -1
- package/vendor/node-addon-api/test/type_taggable.js +3 -4
- package/vendor/node-addon-api/test/typedarray.cc +28 -24
- package/vendor/node-addon-api/tools/conversion.js +1 -1
- package/vendor/node-api-headers/CHANGELOG.md +29 -0
- package/vendor/node-api-headers/CREATING_A_RELEASE.md +12 -2
- package/vendor/node-api-headers/def/js_native_api.def +6 -1
- package/vendor/node-api-headers/def/node_api.def +7 -1
- package/vendor/node-api-headers/include/js_native_api.h +56 -24
- package/vendor/node-api-headers/include/js_native_api_types.h +27 -0
- package/vendor/node-api-headers/include/node_api.h +38 -29
- package/vendor/node-api-headers/lib/parse-utils.js +92 -0
- package/vendor/node-api-headers/package.json +7 -7
- package/vendor/node-api-headers/release-please-config.json +12 -0
- package/vendor/node-api-headers/scripts/update-headers.js +63 -12
- package/vendor/node-api-headers/scripts/write-symbols.js +1 -1
- package/vendor/node-api-headers/symbols.js +17 -1
- package/vendor/node-api-headers/test/parse-utils.js +21 -0
- package/doc/flat/flat.css +0 -27
- package/doc/flat/normal.css +0 -429
- package/doc/flat/print.css +0 -29
- package/doc/flat/reset.css +0 -41
- package/doc/flat/small.css +0 -104
- package/doc/flat/static.js +0 -161
- package/src/core/libcc/brotli.cc +0 -186
- package/src/core/libcc/lz4.cc +0 -197
- package/src/core/libcc/miniz.cc +0 -353
- package/vendor/node-addon-api/tools/eslint-format.js +0 -79
- /package/vendor/node-api-headers/{scripts → lib}/clang-utils.js +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
|
|
2
2
|
//
|
|
3
3
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
-
// this software and associated documentation files (the “Software”), to deal in
|
|
4
|
+
// this software and associated documentation files (the “Software”), to deal in
|
|
5
5
|
// the Software without restriction, including without limitation the rights to use,
|
|
6
6
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
7
7
|
// Software, and to permit persons to whom the Software is furnished to do so,
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
#if __riscv_xlen == 64 || defined(__loongarch64)
|
|
23
23
|
|
|
24
|
-
#include "src/core/
|
|
24
|
+
#include "src/core/base/base.hh"
|
|
25
25
|
#include "ffi.hh"
|
|
26
26
|
#include "call.hh"
|
|
27
27
|
#include "util.hh"
|
|
@@ -305,7 +305,7 @@ bool CallData::Prepare(const FunctionInfo *func, const Napi::CallbackInfo &info)
|
|
|
305
305
|
} else {
|
|
306
306
|
RG_ASSERT(param.type->align <= 8);
|
|
307
307
|
|
|
308
|
-
|
|
308
|
+
MemCpy(args_ptr, regs, param.type->size);
|
|
309
309
|
args_ptr += (param.type->size + 7) / 8;
|
|
310
310
|
}
|
|
311
311
|
} else {
|
|
@@ -690,7 +690,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, bool switch_
|
|
|
690
690
|
} else {
|
|
691
691
|
RG_ASSERT(param.type->align <= 8);
|
|
692
692
|
|
|
693
|
-
|
|
693
|
+
MemCpy(regs, args_ptr, param.type->size);
|
|
694
694
|
args_ptr += (param.type->size + 7) / 8;
|
|
695
695
|
}
|
|
696
696
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# Copyright
|
|
1
|
+
# Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
|
|
2
2
|
#
|
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
-
# this software and associated documentation files (the “Software”), to deal in
|
|
4
|
+
# this software and associated documentation files (the “Software”), to deal in
|
|
5
5
|
# the Software without restriction, including without limitation the rights to use,
|
|
6
6
|
# copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
7
7
|
# Software, and to permit persons to whom the Software is furnished to do so,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
|
|
2
2
|
//
|
|
3
3
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
-
// this software and associated documentation files (the “Software”), to deal in
|
|
4
|
+
// this software and associated documentation files (the “Software”), to deal in
|
|
5
5
|
// the Software without restriction, including without limitation the rights to use,
|
|
6
6
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
7
7
|
// Software, and to permit persons to whom the Software is furnished to do so,
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
#if defined(__x86_64__) && !defined(_WIN32)
|
|
23
23
|
|
|
24
|
-
#include "src/core/
|
|
24
|
+
#include "src/core/base/base.hh"
|
|
25
25
|
#include "ffi.hh"
|
|
26
26
|
#include "call.hh"
|
|
27
27
|
#include "util.hh"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# Copyright
|
|
1
|
+
# Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
|
|
2
2
|
#
|
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
-
# this software and associated documentation files (the “Software”), to deal in
|
|
4
|
+
# this software and associated documentation files (the “Software”), to deal in
|
|
5
5
|
# the Software without restriction, including without limitation the rights to use,
|
|
6
6
|
# copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
7
7
|
# Software, and to permit persons to whom the Software is furnished to do so,
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
20
20
|
# OTHER DEALINGS IN THE SOFTWARE.
|
|
21
21
|
|
|
22
|
-
#
|
|
22
|
+
#if defined(__APPLE__)
|
|
23
23
|
#define SYMBOL(Symbol) _ ## Symbol
|
|
24
24
|
#else
|
|
25
25
|
#define SYMBOL(Symbol) Symbol
|
|
@@ -187,7 +187,7 @@ SYMBOL(ForwardCallXDD):
|
|
|
187
187
|
movq %rsp, %rsi
|
|
188
188
|
leaq 160(%rsp), %rdx
|
|
189
189
|
leaq 112(%rsp), %rcx
|
|
190
|
-
#
|
|
190
|
+
#if defined(__linux__)
|
|
191
191
|
call *RelayCallback@GOTPCREL(%rip)
|
|
192
192
|
#else
|
|
193
193
|
call SYMBOL(RelayCallback)
|
|
@@ -225,7 +225,7 @@ SYMBOL(ForwardCallXDD):
|
|
|
225
225
|
movq %rsp, %rsi
|
|
226
226
|
leaq 160(%rsp), %rdx
|
|
227
227
|
leaq 112(%rsp), %rcx
|
|
228
|
-
#
|
|
228
|
+
#if defined(__linux__)
|
|
229
229
|
call *RelayCallback@GOTPCREL(%rip)
|
|
230
230
|
#else
|
|
231
231
|
call SYMBOL(RelayCallback)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
|
|
2
2
|
//
|
|
3
3
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
-
// this software and associated documentation files (the “Software”), to deal in
|
|
4
|
+
// this software and associated documentation files (the “Software”), to deal in
|
|
5
5
|
// the Software without restriction, including without limitation the rights to use,
|
|
6
6
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
7
7
|
// Software, and to permit persons to whom the Software is furnished to do so,
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
#if defined(_WIN32) && (defined(__x86_64__) || defined(_M_AMD64))
|
|
23
23
|
|
|
24
|
-
#include "src/core/
|
|
24
|
+
#include "src/core/base/base.hh"
|
|
25
25
|
#include "ffi.hh"
|
|
26
26
|
#include "call.hh"
|
|
27
27
|
#include "util.hh"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
; Copyright
|
|
1
|
+
; Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
|
|
2
2
|
;
|
|
3
3
|
; Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
-
; this software and associated documentation files (the “Software”), to deal in
|
|
4
|
+
; this software and associated documentation files (the “Software”), to deal in
|
|
5
5
|
; the Software without restriction, including without limitation the rights to use,
|
|
6
6
|
; copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
7
7
|
; Software, and to permit persons to whom the Software is furnished to do so,
|
package/src/koffi/src/abi_x86.cc
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
|
|
2
2
|
//
|
|
3
3
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
-
// this software and associated documentation files (the “Software”), to deal in
|
|
4
|
+
// this software and associated documentation files (the “Software”), to deal in
|
|
5
5
|
// the Software without restriction, including without limitation the rights to use,
|
|
6
6
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
7
7
|
// Software, and to permit persons to whom the Software is furnished to do so,
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
|
|
22
22
|
#if defined(__i386__) || defined(_M_IX86)
|
|
23
23
|
|
|
24
|
-
#include "src/core/
|
|
24
|
+
#include "src/core/base/base.hh"
|
|
25
25
|
#include "ffi.hh"
|
|
26
26
|
#include "call.hh"
|
|
27
27
|
#include "util.hh"
|
|
28
|
-
#
|
|
28
|
+
#if defined(_WIN32)
|
|
29
29
|
#include "win32.hh"
|
|
30
30
|
#endif
|
|
31
31
|
|
|
@@ -89,7 +89,7 @@ bool AnalyseFunction(Napi::Env env, InstanceData *instance, FunctionInfo *func)
|
|
|
89
89
|
#endif
|
|
90
90
|
#endif
|
|
91
91
|
}
|
|
92
|
-
#
|
|
92
|
+
#if !defined(_WIN32)
|
|
93
93
|
if (fast && !func->ret.trivial) {
|
|
94
94
|
func->ret.fast = 1;
|
|
95
95
|
fast--;
|
|
@@ -316,7 +316,7 @@ bool CallData::Prepare(const FunctionInfo *func, const Napi::CallbackInfo &info)
|
|
|
316
316
|
|
|
317
317
|
void CallData::Execute(const FunctionInfo *func, void *native)
|
|
318
318
|
{
|
|
319
|
-
#
|
|
319
|
+
#if defined(_WIN32)
|
|
320
320
|
TEB *teb = GetTEB();
|
|
321
321
|
|
|
322
322
|
// Restore previous stack limits at the end
|
|
@@ -468,7 +468,7 @@ void CallData::Relay(Size idx, uint8_t *, uint8_t *caller_sp, bool switch_stack,
|
|
|
468
468
|
if (env.IsExceptionPending()) [[unlikely]]
|
|
469
469
|
return;
|
|
470
470
|
|
|
471
|
-
#
|
|
471
|
+
#if defined(_WIN32)
|
|
472
472
|
TEB *teb = GetTEB();
|
|
473
473
|
|
|
474
474
|
// Restore previous stack limits at the end
|
|
@@ -499,7 +499,7 @@ void CallData::Relay(Size idx, uint8_t *, uint8_t *caller_sp, bool switch_stack,
|
|
|
499
499
|
if (proto->convention == CallConvention::Stdcall) {
|
|
500
500
|
out_reg->ret_pop = (int)proto->args_size;
|
|
501
501
|
} else {
|
|
502
|
-
#
|
|
502
|
+
#if defined(_WIN32)
|
|
503
503
|
out_reg->ret_pop = 0;
|
|
504
504
|
#else
|
|
505
505
|
out_reg->ret_pop = return_ptr ? 4 : 0;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# Copyright
|
|
1
|
+
# Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
|
|
2
2
|
#
|
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
-
# this software and associated documentation files (the “Software”), to deal in
|
|
4
|
+
# this software and associated documentation files (the “Software”), to deal in
|
|
5
5
|
# the Software without restriction, including without limitation the rights to use,
|
|
6
6
|
# copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
7
7
|
# Software, and to permit persons to whom the Software is furnished to do so,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
; Copyright
|
|
1
|
+
; Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
|
|
2
2
|
;
|
|
3
3
|
; Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
-
; this software and associated documentation files (the “Software”), to deal in
|
|
4
|
+
; this software and associated documentation files (the “Software”), to deal in
|
|
5
5
|
; the Software without restriction, including without limitation the rights to use,
|
|
6
6
|
; copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
7
7
|
; Software, and to permit persons to whom the Software is furnished to do so,
|
package/src/koffi/src/call.cc
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
|
|
2
2
|
//
|
|
3
3
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
-
// this software and associated documentation files (the “Software”), to deal in
|
|
4
|
+
// this software and associated documentation files (the “Software”), to deal in
|
|
5
5
|
// the Software without restriction, including without limitation the rights to use,
|
|
6
6
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
7
7
|
// Software, and to permit persons to whom the Software is furnished to do so,
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
20
20
|
// OTHER DEALINGS IN THE SOFTWARE.
|
|
21
21
|
|
|
22
|
-
#include "src/core/
|
|
22
|
+
#include "src/core/base/base.hh"
|
|
23
23
|
#include "call.hh"
|
|
24
24
|
#include "ffi.hh"
|
|
25
25
|
#include "util.hh"
|
|
@@ -999,8 +999,8 @@ void CallData::PushBuffer(Span<const uint8_t> buffer, Size size, const TypeInfo
|
|
|
999
999
|
buffer.len = std::min(buffer.len, size);
|
|
1000
1000
|
|
|
1001
1001
|
// Go fast brrrrrrr :)
|
|
1002
|
-
|
|
1003
|
-
|
|
1002
|
+
MemCpy(origin, buffer.ptr, (size_t)buffer.len);
|
|
1003
|
+
MemSet(origin + buffer.len, 0, (size_t)(size - buffer.len));
|
|
1004
1004
|
|
|
1005
1005
|
#define SWAP(CType) \
|
|
1006
1006
|
do { \
|
|
@@ -1052,7 +1052,7 @@ bool CallData::PushStringArray(Napi::Value obj, const TypeInfo *type, uint8_t *o
|
|
|
1052
1052
|
} break;
|
|
1053
1053
|
}
|
|
1054
1054
|
|
|
1055
|
-
|
|
1055
|
+
MemSet(origin + encoded, 0, type->size - encoded);
|
|
1056
1056
|
|
|
1057
1057
|
return true;
|
|
1058
1058
|
}
|
|
@@ -1127,7 +1127,7 @@ bool CallData::PushPointer(Napi::Value value, const TypeInfo *type, int directio
|
|
|
1127
1127
|
if (!PushNormalArray(array, len, type, ptr))
|
|
1128
1128
|
return false;
|
|
1129
1129
|
} else {
|
|
1130
|
-
|
|
1130
|
+
MemSet(ptr, 0, size);
|
|
1131
1131
|
}
|
|
1132
1132
|
|
|
1133
1133
|
out_kind = OutArgument::Kind::Array;
|
|
@@ -1157,7 +1157,7 @@ bool CallData::PushPointer(Napi::Value value, const TypeInfo *type, int directio
|
|
|
1157
1157
|
if (!PushObject(obj, type->ref.type, ptr))
|
|
1158
1158
|
return false;
|
|
1159
1159
|
} else {
|
|
1160
|
-
|
|
1160
|
+
MemSet(ptr, 0, type->size);
|
|
1161
1161
|
}
|
|
1162
1162
|
|
|
1163
1163
|
out_kind = OutArgument::Kind::Object;
|
|
@@ -1341,16 +1341,16 @@ void *CallData::ReserveTrampoline(const FunctionInfo *proto, Napi::Function func
|
|
|
1341
1341
|
|
|
1342
1342
|
void CallData::DumpForward(const FunctionInfo *func) const
|
|
1343
1343
|
{
|
|
1344
|
-
PrintLn(
|
|
1344
|
+
PrintLn(StdErr, "%!..+---- %1 (%2) ----%!0", func->name, CallConventionNames[(int)func->convention]);
|
|
1345
1345
|
|
|
1346
1346
|
if (func->parameters.len) {
|
|
1347
|
-
PrintLn(
|
|
1347
|
+
PrintLn(StdErr, "Parameters:");
|
|
1348
1348
|
for (Size i = 0; i < func->parameters.len; i++) {
|
|
1349
1349
|
const ParameterInfo ¶m = func->parameters[i];
|
|
1350
|
-
PrintLn(
|
|
1350
|
+
PrintLn(StdErr, " %1 = %2 (%3)", i, param.type->name, FmtMemSize(param.type->size));
|
|
1351
1351
|
}
|
|
1352
1352
|
}
|
|
1353
|
-
PrintLn(
|
|
1353
|
+
PrintLn(StdErr, "Return: %1 (%2)", func->ret.type->name, FmtMemSize(func->ret.type->size));
|
|
1354
1354
|
|
|
1355
1355
|
Span<const uint8_t> stack = MakeSpan(mem->stack.end(), old_stack_mem.end() - mem->stack.end());
|
|
1356
1356
|
Span<const uint8_t> heap = MakeSpan(old_heap_mem.ptr, mem->heap.ptr - old_heap_mem.ptr);
|
package/src/koffi/src/call.hh
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
|
|
2
2
|
//
|
|
3
3
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
-
// this software and associated documentation files (the “Software”), to deal in
|
|
4
|
+
// this software and associated documentation files (the “Software”), to deal in
|
|
5
5
|
// the Software without restriction, including without limitation the rights to use,
|
|
6
6
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
7
7
|
// Software, and to permit persons to whom the Software is furnished to do so,
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
#pragma once
|
|
23
23
|
|
|
24
|
-
#include "src/core/
|
|
24
|
+
#include "src/core/base/base.hh"
|
|
25
25
|
#include "ffi.hh"
|
|
26
26
|
#include "util.hh"
|
|
27
27
|
|
|
@@ -92,8 +92,8 @@ public:
|
|
|
92
92
|
|
|
93
93
|
void Dispose();
|
|
94
94
|
|
|
95
|
-
#
|
|
96
|
-
#
|
|
95
|
+
#if defined(UNITY_BUILD)
|
|
96
|
+
#if defined(_MSC_VER)
|
|
97
97
|
#define INLINE_IF_UNITY __forceinline
|
|
98
98
|
#else
|
|
99
99
|
#define INLINE_IF_UNITY __attribute__((always_inline)) inline
|
|
@@ -153,7 +153,7 @@ inline bool CallData::AllocStack(Size size, Size align, T **out_ptr)
|
|
|
153
153
|
return false;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
#
|
|
156
|
+
#if defined(RG_DEBUG)
|
|
157
157
|
memset(ptr, 0, delta);
|
|
158
158
|
#endif
|
|
159
159
|
|
|
@@ -170,7 +170,7 @@ inline T *CallData::AllocHeap(Size size, Size align)
|
|
|
170
170
|
Size delta = size + (ptr - mem->heap.ptr);
|
|
171
171
|
|
|
172
172
|
if (size < 4096 && delta <= mem->heap.len) [[likely]] {
|
|
173
|
-
#
|
|
173
|
+
#if defined(RG_DEBUG)
|
|
174
174
|
memset(mem->heap.ptr, 0, (size_t)delta);
|
|
175
175
|
#endif
|
|
176
176
|
|
|
@@ -179,7 +179,7 @@ inline T *CallData::AllocHeap(Size size, Size align)
|
|
|
179
179
|
|
|
180
180
|
return ptr;
|
|
181
181
|
} else {
|
|
182
|
-
#
|
|
182
|
+
#if defined(RG_DEBUG)
|
|
183
183
|
int flags = (int)AllocFlag::Zero;
|
|
184
184
|
#else
|
|
185
185
|
int flags = 0;
|