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.
Files changed (186) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE.txt +2 -2
  3. package/README.md +8 -8
  4. package/build/koffi/darwin_arm64/koffi.node +0 -0
  5. package/build/koffi/darwin_x64/koffi.node +0 -0
  6. package/build/koffi/freebsd_arm64/koffi.node +0 -0
  7. package/build/koffi/freebsd_ia32/koffi.node +0 -0
  8. package/build/koffi/freebsd_x64/koffi.node +0 -0
  9. package/build/koffi/linux_arm64/koffi.node +0 -0
  10. package/build/koffi/linux_armhf/koffi.node +0 -0
  11. package/build/koffi/linux_ia32/koffi.node +0 -0
  12. package/build/koffi/linux_loong64/koffi.node +0 -0
  13. package/build/koffi/linux_riscv64d/koffi.node +0 -0
  14. package/build/koffi/linux_x64/koffi.node +0 -0
  15. package/build/koffi/musl_arm64/koffi.node +0 -0
  16. package/build/koffi/musl_x64/koffi.node +0 -0
  17. package/build/koffi/openbsd_ia32/koffi.node +0 -0
  18. package/build/koffi/openbsd_x64/koffi.node +0 -0
  19. package/build/koffi/win32_arm64/koffi.exp +0 -0
  20. package/build/koffi/win32_arm64/koffi.node +0 -0
  21. package/build/koffi/win32_ia32/koffi.exp +0 -0
  22. package/build/koffi/win32_ia32/koffi.node +0 -0
  23. package/build/koffi/win32_x64/koffi.exp +0 -0
  24. package/build/koffi/win32_x64/koffi.node +0 -0
  25. package/doc/assets.ini +3 -3
  26. package/doc/develop.sh +4 -3
  27. package/doc/pages/platforms.md +1 -1
  28. package/doc/static/highlight.js +1 -1
  29. package/doc/static/koffi.css +3 -2
  30. package/doc/static/print.css +1 -1
  31. package/doc/templates/code.html +5 -5
  32. package/doc/templates/page.html +4 -4
  33. package/index.d.ts +228 -145
  34. package/index.js +25 -25
  35. package/indirect.js +25 -5
  36. package/package.json +2 -2
  37. package/src/cnoke/LICENSE.txt +2 -2
  38. package/src/cnoke/README.md +2 -0
  39. package/src/cnoke/assets/FindCNoke.cmake +12 -2
  40. package/src/cnoke/assets/win_delay_hook.c +4 -4
  41. package/src/cnoke/cnoke.js +4 -2
  42. package/src/cnoke/package.json +1 -1
  43. package/src/cnoke/src/builder.js +11 -14
  44. package/src/cnoke/src/index.js +2 -2
  45. package/src/cnoke/src/tools.js +34 -2
  46. package/src/core/{libcc/libcc.cc → base/base.cc} +3174 -1640
  47. package/src/core/{libcc/libcc.hh → base/base.hh} +3066 -2427
  48. package/src/core/{libcc → base}/mimetypes.inc +42 -4
  49. package/src/core/{libcc → base}/mimetypes_gen.py +3 -3
  50. package/src/core/base/unicode.inc +426 -0
  51. package/src/core/base/unicode_gen.py +189 -0
  52. package/src/koffi/CMakeLists.txt +7 -5
  53. package/src/koffi/cmake/raylib.cmake +6 -2
  54. package/src/koffi/cmake/{sqlite.cmake → sqlite3.cmake} +3 -3
  55. package/src/koffi/examples/electron-forge/forge.config.js +23 -3
  56. package/src/koffi/examples/electron-forge/package.json +18 -16
  57. package/src/koffi/src/abi_arm32.cc +7 -7
  58. package/src/koffi/src/abi_arm32_asm.S +2 -2
  59. package/src/koffi/src/abi_arm64.cc +45 -45
  60. package/src/koffi/src/abi_arm64_asm.S +4 -4
  61. package/src/koffi/src/abi_arm64_asm.asm +2 -2
  62. package/src/koffi/src/abi_loong64_asm.S +2 -2
  63. package/src/koffi/src/abi_riscv64.cc +5 -5
  64. package/src/koffi/src/abi_riscv64_asm.S +2 -2
  65. package/src/koffi/src/abi_x64_sysv.cc +3 -3
  66. package/src/koffi/src/abi_x64_sysv_asm.S +5 -5
  67. package/src/koffi/src/abi_x64_win.cc +3 -3
  68. package/src/koffi/src/abi_x64_win_asm.asm +2 -2
  69. package/src/koffi/src/abi_x86.cc +8 -8
  70. package/src/koffi/src/abi_x86_asm.S +2 -2
  71. package/src/koffi/src/abi_x86_asm.asm +2 -2
  72. package/src/koffi/src/call.cc +12 -12
  73. package/src/koffi/src/call.hh +8 -8
  74. package/src/koffi/src/errno.inc +152 -152
  75. package/src/koffi/src/ffi.cc +44 -39
  76. package/src/koffi/src/ffi.hh +6 -6
  77. package/src/koffi/src/init.js +1 -1
  78. package/src/koffi/src/parser.cc +5 -5
  79. package/src/koffi/src/parser.hh +3 -3
  80. package/src/koffi/src/trampolines/armasm.inc +2 -2
  81. package/src/koffi/src/trampolines/gnu.inc +2 -2
  82. package/src/koffi/src/trampolines/masm32.inc +2 -2
  83. package/src/koffi/src/trampolines/masm64.inc +2 -2
  84. package/src/koffi/src/trampolines/prototypes.inc +2 -2
  85. package/src/koffi/src/util.cc +9 -9
  86. package/src/koffi/src/util.hh +3 -3
  87. package/src/koffi/src/win32.cc +5 -5
  88. package/src/koffi/src/win32.hh +9 -9
  89. package/vendor/node-addon-api/CHANGELOG.md +97 -2
  90. package/vendor/node-addon-api/CONTRIBUTING.md +117 -7
  91. package/vendor/node-addon-api/README.md +25 -249
  92. package/vendor/node-addon-api/common.gypi +1 -0
  93. package/vendor/node-addon-api/doc/README.md +145 -0
  94. package/vendor/node-addon-api/doc/array_buffer.md +15 -15
  95. package/vendor/node-addon-api/doc/basic_env.md +200 -0
  96. package/vendor/node-addon-api/doc/buffer.md +24 -26
  97. package/vendor/node-addon-api/doc/cmake-js.md +19 -0
  98. package/vendor/node-addon-api/doc/{creating_a_release.md → contributing/creating_a_release.md} +16 -4
  99. package/vendor/node-addon-api/doc/env.md +11 -131
  100. package/vendor/node-addon-api/doc/error_handling.md +12 -0
  101. package/vendor/node-addon-api/doc/external.md +13 -4
  102. package/vendor/node-addon-api/doc/finalization.md +153 -0
  103. package/vendor/node-addon-api/doc/memory_management.md +1 -1
  104. package/vendor/node-addon-api/doc/object_wrap.md +19 -3
  105. package/vendor/node-addon-api/doc/promises.md +51 -0
  106. package/vendor/node-addon-api/doc/setup.md +29 -6
  107. package/vendor/node-addon-api/doc/value.md +13 -0
  108. package/vendor/node-addon-api/doc/version_management.md +2 -2
  109. package/vendor/node-addon-api/eslint.config.js +5 -0
  110. package/vendor/node-addon-api/index.js +2 -0
  111. package/vendor/node-addon-api/napi-inl.h +592 -166
  112. package/vendor/node-addon-api/napi.h +167 -59
  113. package/vendor/node-addon-api/node_addon_api.gyp +10 -0
  114. package/vendor/node-addon-api/noexcept.gypi +1 -1
  115. package/vendor/node-addon-api/package.json +10 -13
  116. package/vendor/node-addon-api/release-please-config.json +15 -0
  117. package/vendor/node-addon-api/test/addon_build/tpl/binding.gyp +2 -1
  118. package/vendor/node-addon-api/test/array_buffer.js +1 -1
  119. package/vendor/node-addon-api/test/async_context.js +2 -2
  120. package/vendor/node-addon-api/test/async_progress_queue_worker.js +3 -3
  121. package/vendor/node-addon-api/test/async_progress_worker.js +3 -3
  122. package/vendor/node-addon-api/test/async_worker.cc +15 -13
  123. package/vendor/node-addon-api/test/async_worker.js +5 -5
  124. package/vendor/node-addon-api/test/basic_types/value.cc +6 -0
  125. package/vendor/node-addon-api/test/basic_types/value.js +17 -0
  126. package/vendor/node-addon-api/test/binding.cc +8 -0
  127. package/vendor/node-addon-api/test/binding.gyp +23 -1
  128. package/vendor/node-addon-api/test/buffer.js +1 -2
  129. package/vendor/node-addon-api/test/common/index.js +1 -1
  130. package/vendor/node-addon-api/test/except_all.cc +22 -0
  131. package/vendor/node-addon-api/test/except_all.js +14 -0
  132. package/vendor/node-addon-api/test/exports.js +19 -0
  133. package/vendor/node-addon-api/test/finalizer_order.cc +152 -0
  134. package/vendor/node-addon-api/test/finalizer_order.js +98 -0
  135. package/vendor/node-addon-api/test/function.js +2 -2
  136. package/vendor/node-addon-api/test/function_reference.js +2 -2
  137. package/vendor/node-addon-api/test/globalObject/global_object_delete_property.cc +4 -4
  138. package/vendor/node-addon-api/test/globalObject/global_object_get_property.cc +4 -4
  139. package/vendor/node-addon-api/test/globalObject/global_object_has_own_property.cc +3 -3
  140. package/vendor/node-addon-api/test/globalObject/global_object_set_property.cc +5 -5
  141. package/vendor/node-addon-api/test/name.cc +10 -8
  142. package/vendor/node-addon-api/test/object/delete_property.cc +5 -5
  143. package/vendor/node-addon-api/test/object/get_property.cc +5 -5
  144. package/vendor/node-addon-api/test/object/has_own_property.cc +4 -4
  145. package/vendor/node-addon-api/test/object/has_property.cc +5 -5
  146. package/vendor/node-addon-api/test/object/object.cc +1 -1
  147. package/vendor/node-addon-api/test/object/set_property.cc +5 -5
  148. package/vendor/node-addon-api/test/object/subscript_operator.cc +3 -3
  149. package/vendor/node-addon-api/test/object_reference.cc +18 -18
  150. package/vendor/node-addon-api/test/promise.cc +75 -0
  151. package/vendor/node-addon-api/test/promise.js +23 -0
  152. package/vendor/node-addon-api/test/require_basic_finalizers/index.js +38 -0
  153. package/vendor/node-addon-api/test/require_basic_finalizers/tpl/addon.cc +12 -0
  154. package/vendor/node-addon-api/test/require_basic_finalizers/tpl/binding.gyp +48 -0
  155. package/vendor/node-addon-api/test/require_basic_finalizers/tpl/index.js +3 -0
  156. package/vendor/node-addon-api/test/require_basic_finalizers/tpl/package.json +11 -0
  157. package/vendor/node-addon-api/test/run_script.cc +1 -1
  158. package/vendor/node-addon-api/test/type_taggable.cc +1 -1
  159. package/vendor/node-addon-api/test/type_taggable.js +3 -4
  160. package/vendor/node-addon-api/test/typedarray.cc +28 -24
  161. package/vendor/node-addon-api/tools/conversion.js +1 -1
  162. package/vendor/node-api-headers/CHANGELOG.md +29 -0
  163. package/vendor/node-api-headers/CREATING_A_RELEASE.md +12 -2
  164. package/vendor/node-api-headers/def/js_native_api.def +6 -1
  165. package/vendor/node-api-headers/def/node_api.def +7 -1
  166. package/vendor/node-api-headers/include/js_native_api.h +56 -24
  167. package/vendor/node-api-headers/include/js_native_api_types.h +27 -0
  168. package/vendor/node-api-headers/include/node_api.h +38 -29
  169. package/vendor/node-api-headers/lib/parse-utils.js +92 -0
  170. package/vendor/node-api-headers/package.json +7 -7
  171. package/vendor/node-api-headers/release-please-config.json +12 -0
  172. package/vendor/node-api-headers/scripts/update-headers.js +63 -12
  173. package/vendor/node-api-headers/scripts/write-symbols.js +1 -1
  174. package/vendor/node-api-headers/symbols.js +17 -1
  175. package/vendor/node-api-headers/test/parse-utils.js +21 -0
  176. package/doc/flat/flat.css +0 -27
  177. package/doc/flat/normal.css +0 -429
  178. package/doc/flat/print.css +0 -29
  179. package/doc/flat/reset.css +0 -41
  180. package/doc/flat/small.css +0 -104
  181. package/doc/flat/static.js +0 -161
  182. package/src/core/libcc/brotli.cc +0 -186
  183. package/src/core/libcc/lz4.cc +0 -197
  184. package/src/core/libcc/miniz.cc +0 -353
  185. package/vendor/node-addon-api/tools/eslint-format.js +0 -79
  186. /package/vendor/node-api-headers/{scripts → lib}/clang-utils.js +0 -0
@@ -1,7 +1,7 @@
1
- // Copyright 2023 Niels Martignène <niels.martignene@protonmail.com>
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/libcc/libcc.hh"
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
- memcpy_safe(args_ptr, regs, param.type->size);
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
- memcpy_safe(regs, args_ptr, param.type->size);
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 2023 Niels Martignène <niels.martignene@protonmail.com>
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 2023 Niels Martignène <niels.martignene@protonmail.com>
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/libcc/libcc.hh"
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 2023 Niels Martignène <niels.martignene@protonmail.com>
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
- #ifdef __APPLE__
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
- #ifdef __linux__
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
- #ifdef __linux__
228
+ #if defined(__linux__)
229
229
  call *RelayCallback@GOTPCREL(%rip)
230
230
  #else
231
231
  call SYMBOL(RelayCallback)
@@ -1,7 +1,7 @@
1
- // Copyright 2023 Niels Martignène <niels.martignene@protonmail.com>
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/libcc/libcc.hh"
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 2023 Niels Martignène <niels.martignene@protonmail.com>
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 2023 Niels Martignène <niels.martignene@protonmail.com>
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/libcc/libcc.hh"
24
+ #include "src/core/base/base.hh"
25
25
  #include "ffi.hh"
26
26
  #include "call.hh"
27
27
  #include "util.hh"
28
- #ifdef _WIN32
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
- #ifndef _WIN32
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
- #ifdef _WIN32
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
- #ifdef _WIN32
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
- #ifdef _WIN32
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 2023 Niels Martignène <niels.martignene@protonmail.com>
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 2023 Niels Martignène <niels.martignene@protonmail.com>
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 2023 Niels Martignène <niels.martignene@protonmail.com>
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/libcc/libcc.hh"
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
- memcpy_safe(origin, buffer.ptr, (size_t)buffer.len);
1003
- memset_safe(origin + buffer.len, 0, (size_t)(size - buffer.len));
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
- memset_safe(origin + encoded, 0, type->size - encoded);
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
- memset_safe(ptr, 0, size);
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
- memset_safe(ptr, 0, type->size);
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(stderr, "%!..+---- %1 (%2) ----%!0", func->name, CallConventionNames[(int)func->convention]);
1344
+ PrintLn(StdErr, "%!..+---- %1 (%2) ----%!0", func->name, CallConventionNames[(int)func->convention]);
1345
1345
 
1346
1346
  if (func->parameters.len) {
1347
- PrintLn(stderr, "Parameters:");
1347
+ PrintLn(StdErr, "Parameters:");
1348
1348
  for (Size i = 0; i < func->parameters.len; i++) {
1349
1349
  const ParameterInfo &param = func->parameters[i];
1350
- PrintLn(stderr, " %1 = %2 (%3)", i, param.type->name, FmtMemSize(param.type->size));
1350
+ PrintLn(StdErr, " %1 = %2 (%3)", i, param.type->name, FmtMemSize(param.type->size));
1351
1351
  }
1352
1352
  }
1353
- PrintLn(stderr, "Return: %1 (%2)", func->ret.type->name, FmtMemSize(func->ret.type->size));
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);
@@ -1,7 +1,7 @@
1
- // Copyright 2023 Niels Martignène <niels.martignene@protonmail.com>
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/libcc/libcc.hh"
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
- #ifdef UNITY_BUILD
96
- #ifdef _MSC_VER
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
- #ifdef RG_DEBUG
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
- #ifdef RG_DEBUG
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
- #ifdef RG_DEBUG
182
+ #if defined(RG_DEBUG)
183
183
  int flags = (int)AllocFlag::Zero;
184
184
  #else
185
185
  int flags = 0;