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,
@@ -19,21 +19,21 @@
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 "ffi.hh"
24
24
  #include "call.hh"
25
25
  #include "parser.hh"
26
26
  #include "util.hh"
27
- #ifdef _WIN32
27
+ #if defined(_WIN32)
28
28
  #include "win32.hh"
29
29
  #endif
30
30
  #include "errno.inc"
31
31
 
32
- #ifdef _WIN32
33
- #ifndef NOMINMAX
32
+ #if defined(_WIN32)
33
+ #if !defined(NOMINMAX)
34
34
  #define NOMINMAX
35
35
  #endif
36
- #ifndef WIN32_LEAN_AND_MEAN
36
+ #if !defined(WIN32_LEAN_AND_MEAN)
37
37
  #define WIN32_LEAN_AND_MEAN
38
38
  #endif
39
39
  #include <windows.h>
@@ -42,7 +42,7 @@
42
42
  #include <dlfcn.h>
43
43
  #include <unistd.h>
44
44
  #include <sys/mman.h>
45
- #ifndef MAP_STACK
45
+ #if !defined(MAP_STACK)
46
46
  #define MAP_STACK 0
47
47
  #endif
48
48
  #endif
@@ -54,7 +54,7 @@ namespace RG {
54
54
 
55
55
  SharedData shared;
56
56
 
57
- static RG_THREAD_LOCAL CallData *exec_call;
57
+ static thread_local CallData *exec_call;
58
58
 
59
59
  static bool ChangeSize(const char *name, Napi::Value value, Size min_size, Size max_size, Size *out_size)
60
60
  {
@@ -201,14 +201,13 @@ static inline bool CheckAlignment(int64_t align)
201
201
  return valid;
202
202
  }
203
203
 
204
- // Prevent simple mistakes but don't be too strict, the world is bigger than the US!
205
204
  static bool IsNameValid(const char *name)
206
205
  {
207
- if (!name[0] || IsAsciiWhite(name[0]) || IsAsciiDigit(name[0])) [[unlikely]]
206
+ if (!IsXidStart(name[0]))
208
207
  return false;
209
208
 
210
209
  for (Size i = 1; name[i]; i++) {
211
- if (IsAsciiWhite(name[i])) [[unlikely]]
210
+ if (!IsXidContinue(name[i])) [[unlikely]]
212
211
  return false;
213
212
  }
214
213
 
@@ -259,10 +258,10 @@ static Napi::Value CreateStructType(const Napi::CallbackInfo &info, bool pad)
259
258
  Napi::Object obj = info[named].As<Napi::Object>();
260
259
  Napi::Array keys = GetOwnPropertyNames(obj);
261
260
 
262
- RG_DEFER_NC(err_guard, len = instance->types.len) {
263
- Size start = len + !named;
261
+ RG_DEFER_NC(err_guard, count = instance->types.count) {
262
+ Size start = count + !named;
264
263
 
265
- for (Size i = start; i < instance->types.len; i++) {
264
+ for (Size i = start; i < instance->types.count; i++) {
266
265
  const TypeInfo *it = &instance->types[i];
267
266
  const TypeInfo **ptr = instance->types_map.Find(it->name);
268
267
 
@@ -271,7 +270,7 @@ static Napi::Value CreateStructType(const Napi::CallbackInfo &info, bool pad)
271
270
  }
272
271
  }
273
272
 
274
- instance->types.RemoveFrom(len);
273
+ instance->types.RemoveFrom(count);
275
274
  };
276
275
 
277
276
  TypeInfo *type = instance->types.AppendDefault();
@@ -294,7 +293,7 @@ static Napi::Value CreateStructType(const Napi::CallbackInfo &info, bool pad)
294
293
  if (!MapType(env, instance, type, type->name))
295
294
  return env.Null();
296
295
  } else {
297
- type->name = Fmt(&instance->str_alloc, "<anonymous_%1>", instance->types.len).ptr;
296
+ type->name = Fmt(&instance->str_alloc, "<anonymous_%1>", instance->types.count).ptr;
298
297
  }
299
298
 
300
299
  type->primitive = PrimitiveKind::Record;
@@ -353,6 +352,9 @@ static Napi::Value CreateStructType(const Napi::CallbackInfo &info, bool pad)
353
352
  return env.Null();
354
353
  }
355
354
 
355
+ if (TestStr(member.name, "_"))
356
+ continue;
357
+
356
358
  if (!IsNameValid(member.name)) {
357
359
  ThrowError<Napi::Error>(env, "Invalid member name '%1'", member.name);
358
360
  return env.Null();
@@ -423,10 +425,10 @@ static Napi::Value CreateUnionType(const Napi::CallbackInfo &info)
423
425
  Napi::Object obj = info[named].As<Napi::Object>();
424
426
  Napi::Array keys = GetOwnPropertyNames(obj);
425
427
 
426
- RG_DEFER_NC(err_guard, len = instance->types.len) {
427
- Size start = len + !named;
428
+ RG_DEFER_NC(err_guard, count = instance->types.count) {
429
+ Size start = count + !named;
428
430
 
429
- for (Size i = start; i < instance->types.len; i++) {
431
+ for (Size i = start; i < instance->types.count; i++) {
430
432
  const TypeInfo *it = &instance->types[i];
431
433
  const TypeInfo **ptr = instance->types_map.Find(it->name);
432
434
 
@@ -435,7 +437,7 @@ static Napi::Value CreateUnionType(const Napi::CallbackInfo &info)
435
437
  }
436
438
  }
437
439
 
438
- instance->types.RemoveFrom(len);
440
+ instance->types.RemoveFrom(count);
439
441
  };
440
442
 
441
443
  TypeInfo *type = instance->types.AppendDefault();
@@ -458,7 +460,7 @@ static Napi::Value CreateUnionType(const Napi::CallbackInfo &info)
458
460
  if (!MapType(env, instance, type, type->name))
459
461
  return env.Null();
460
462
  } else {
461
- type->name = Fmt(&instance->str_alloc, "<anonymous_%1>", instance->types.len).ptr;
463
+ type->name = Fmt(&instance->str_alloc, "<anonymous_%1>", instance->types.count).ptr;
462
464
  }
463
465
 
464
466
  type->primitive = PrimitiveKind::Union;
@@ -508,6 +510,9 @@ static Napi::Value CreateUnionType(const Napi::CallbackInfo &info)
508
510
  size = std::max(size, member.type->size);
509
511
  type->align = std::max(type->align, align);
510
512
 
513
+ if (TestStr(member.name, "_"))
514
+ continue;
515
+
511
516
  if (!IsNameValid(member.name)) {
512
517
  ThrowError<Napi::Error>(env, "Invalid member name '%1'", member.name);
513
518
  return env.Null();
@@ -592,7 +597,7 @@ static Napi::Value CreateOpaqueType(const Napi::CallbackInfo &info)
592
597
  RG_DEFER_N(err_guard) { instance->types.RemoveLast(1); };
593
598
 
594
599
  type->name = named ? DuplicateString(name.Utf8Value().c_str(), &instance->str_alloc).ptr
595
- : Fmt(&instance->str_alloc, "<anonymous_%1>", instance->types.len).ptr;
600
+ : Fmt(&instance->str_alloc, "<anonymous_%1>", instance->types.count).ptr;
596
601
 
597
602
  type->primitive = PrimitiveKind::Void;
598
603
  type->size = 0;
@@ -788,7 +793,7 @@ static Napi::Value CreateDisposableType(const Napi::CallbackInfo &info)
788
793
  type->members.allocator = GetNullAllocator();
789
794
 
790
795
  type->name = named ? DuplicateString(name.Utf8Value().c_str(), &instance->str_alloc).ptr
791
- : Fmt(&instance->str_alloc, "<anonymous_%1>", instance->types.len).ptr;
796
+ : Fmt(&instance->str_alloc, "<anonymous_%1>", instance->types.count).ptr;
792
797
 
793
798
  type->dispose = dispose;
794
799
  type->dispose_ref = Napi::Persistent(dispose_func);
@@ -1005,7 +1010,7 @@ static bool ParseClassicFunction(const Napi::CallbackInfo &info, FunctionInfo *o
1005
1010
  parameters = info[3u].As<Napi::Array>();
1006
1011
  }
1007
1012
 
1008
- #ifdef _WIN32
1013
+ #if defined(_WIN32)
1009
1014
  if (name.IsNumber()) {
1010
1015
  out_func->ordinal_name = name.As<Napi::Number>().Int32Value();
1011
1016
  name = name.ToString();
@@ -1356,7 +1361,7 @@ static InstanceMemory *AllocateMemory(InstanceData *instance, Size stack_size, S
1356
1361
  RG_CRITICAL(mem->stack.ptr, "Failed to allocate %1 of memory", mem->stack.len);
1357
1362
  #endif
1358
1363
 
1359
- #ifdef __OpenBSD__
1364
+ #if defined(__OpenBSD__)
1360
1365
  // Make sure the SP points inside the MAP_STACK area, or (void) functions may crash on OpenBSD i386
1361
1366
  mem->stack.len -= 16;
1362
1367
  #endif
@@ -1365,7 +1370,7 @@ static InstanceMemory *AllocateMemory(InstanceData *instance, Size stack_size, S
1365
1370
  mem->stack0 = mem->stack;
1366
1371
 
1367
1372
  mem->heap.len = heap_size;
1368
- #ifdef _WIN32
1373
+ #if defined(_WIN32)
1369
1374
  mem->heap.ptr = (uint8_t *)VirtualAlloc(nullptr, mem->heap.len, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
1370
1375
  #else
1371
1376
  mem->heap.ptr = (uint8_t *)mmap(nullptr, mem->heap.len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
@@ -1673,7 +1678,7 @@ static Napi::Value FindLibraryFunction(const Napi::CallbackInfo &info)
1673
1678
  func->parameters.Grow(32);
1674
1679
  }
1675
1680
 
1676
- #ifdef _WIN32
1681
+ #if defined(_WIN32)
1677
1682
  if (func->ordinal_name < 0) {
1678
1683
  if (func->decorated_name) {
1679
1684
  func->native = (void *)GetProcAddress((HMODULE)lib->module, func->decorated_name);
@@ -1725,7 +1730,7 @@ static Napi::Value FindSymbol(const Napi::CallbackInfo &info)
1725
1730
  if (!type)
1726
1731
  return env.Null();
1727
1732
 
1728
- #ifdef _WIN32
1733
+ #if defined(_WIN32)
1729
1734
  void *ptr = (void *)GetProcAddress((HMODULE)lib->module, name.c_str());
1730
1735
  #else
1731
1736
  void *ptr = (void *)dlsym(lib->module, name.c_str());
@@ -1769,7 +1774,7 @@ static Napi::Value LoadSharedLibrary(const Napi::CallbackInfo &info)
1769
1774
  return env.Null();
1770
1775
  }
1771
1776
 
1772
- #ifndef _WIN32
1777
+ #if !defined(_WIN32)
1773
1778
  int flags = 0;
1774
1779
 
1775
1780
  if (info.Length() >= 2) {
@@ -1777,7 +1782,7 @@ static Napi::Value LoadSharedLibrary(const Napi::CallbackInfo &info)
1777
1782
 
1778
1783
  flags |= options.Get("lazy").ToBoolean() ? RTLD_LAZY : RTLD_NOW;
1779
1784
  flags |= options.Get("global").ToBoolean() ? RTLD_GLOBAL : RTLD_LOCAL;
1780
- #ifdef RTLD_DEEPBIND
1785
+ #if defined(RTLD_DEEPBIND)
1781
1786
  flags |= options.Get("deep").ToBoolean() ? RTLD_DEEPBIND : 0;
1782
1787
  #endif
1783
1788
  } else {
@@ -1792,7 +1797,7 @@ static Napi::Value LoadSharedLibrary(const Napi::CallbackInfo &info)
1792
1797
 
1793
1798
  // Load shared library
1794
1799
  void *module = nullptr;
1795
- #ifdef _WIN32
1800
+ #if defined(_WIN32)
1796
1801
  if (info[0].IsString()) {
1797
1802
  std::string filename = info[0].As<Napi::String>();
1798
1803
  module = LoadWindowsLibrary(env, filename.c_str());
@@ -2155,7 +2160,7 @@ static Napi::Value ResetKoffi(const Napi::CallbackInfo &info)
2155
2160
  instance->broker = nullptr;
2156
2161
  }
2157
2162
 
2158
- instance->types.RemoveFrom(instance->base_types_len);
2163
+ instance->types.RemoveFrom(instance->base_types_count);
2159
2164
 
2160
2165
  {
2161
2166
  HashSet<const void *> base_types;
@@ -2181,7 +2186,7 @@ static Napi::Value ResetKoffi(const Napi::CallbackInfo &info)
2181
2186
 
2182
2187
  void LibraryHolder::Unload()
2183
2188
  {
2184
- #ifdef _WIN32
2189
+ #if defined(_WIN32)
2185
2190
  if (module && module != GetModuleHandle(nullptr)) {
2186
2191
  FreeLibrary((HMODULE)module);
2187
2192
  }
@@ -2229,7 +2234,7 @@ void FunctionInfo::Unref() const
2229
2234
 
2230
2235
  InstanceMemory::~InstanceMemory()
2231
2236
  {
2232
- #ifdef _WIN32
2237
+ #if defined(_WIN32)
2233
2238
  if (stack.ptr) {
2234
2239
  VirtualFree(stack.ptr, 0, MEM_RELEASE);
2235
2240
  }
@@ -2322,7 +2327,7 @@ static inline PrimitiveKind GetSignPrimitive(Size len, bool sign)
2322
2327
 
2323
2328
  static inline PrimitiveKind GetLittleEndianPrimitive(PrimitiveKind kind)
2324
2329
  {
2325
- #ifdef RG_BIG_ENDIAN
2330
+ #if defined(RG_BIG_ENDIAN)
2326
2331
  return (PrimitiveKind)((int)kind + 1);
2327
2332
  #else
2328
2333
  return kind;
@@ -2331,7 +2336,7 @@ static inline PrimitiveKind GetLittleEndianPrimitive(PrimitiveKind kind)
2331
2336
 
2332
2337
  static inline PrimitiveKind GetBigEndianPrimitive(PrimitiveKind kind)
2333
2338
  {
2334
- #ifdef RG_BIG_ENDIAN
2339
+ #if defined(RG_BIG_ENDIAN)
2335
2340
  return kind;
2336
2341
  #else
2337
2342
  return (PrimitiveKind)((int)kind + 1);
@@ -2347,7 +2352,7 @@ static InstanceData *CreateInstance()
2347
2352
 
2348
2353
  instance->debug = GetDebugFlag("DUMP_CALLS");
2349
2354
 
2350
- #ifdef _WIN32
2355
+ #if defined(_WIN32)
2351
2356
  TEB *teb = GetTEB();
2352
2357
 
2353
2358
  instance->main_stack_max = teb->StackBase;
@@ -2498,7 +2503,7 @@ static Napi::Object InitModule(Napi::Env env, Napi::Object exports)
2498
2503
 
2499
2504
  instance->active_symbol = Napi::Symbol::New(env, "active");
2500
2505
 
2501
- instance->base_types_len = instance->types.len;
2506
+ instance->base_types_count = instance->types.count;
2502
2507
  }
2503
2508
 
2504
2509
  // Expose internal Node stuff
@@ -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
 
26
26
  #include <napi.h>
27
27
 
@@ -229,7 +229,7 @@ struct FunctionInfo {
229
229
 
230
230
  const char *name;
231
231
  const char *decorated_name; // Only set for some platforms/calling conventions
232
- #ifdef _WIN32
232
+ #if defined(_WIN32)
233
233
  int ordinal_name = -1;
234
234
  #endif
235
235
  const LibraryHolder *lib = nullptr;
@@ -278,7 +278,7 @@ struct InstanceData {
278
278
  BucketArray<TypeInfo> types;
279
279
  HashMap<const char *, const TypeInfo *> types_map;
280
280
  BucketArray<FunctionInfo> callbacks;
281
- Size base_types_len;
281
+ Size base_types_count;
282
282
 
283
283
  bool debug;
284
284
 
@@ -299,7 +299,7 @@ struct InstanceData {
299
299
  std::thread::id main_thread_id;
300
300
  napi_threadsafe_function broker = nullptr;
301
301
 
302
- #ifdef _WIN32
302
+ #if defined(_WIN32)
303
303
  void *main_stack_max;
304
304
  void *main_stack_min;
305
305
 
@@ -1,4 +1,4 @@
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
4
  // this software and associated documentation files (the “Software”), to deal in
@@ -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 "ffi.hh"
24
24
  #include "parser.hh"
25
25
 
@@ -98,9 +98,9 @@ void PrototypeParser::Tokenize(const char *str)
98
98
 
99
99
  if (IsAsciiWhite(c)) {
100
100
  continue;
101
- } else if (IsAsciiAlpha(c) || c == '_') {
101
+ } else if (IsXidStart(c)) {
102
102
  Size j = i;
103
- while (str[++j] && (IsAsciiAlphaOrDigit(str[j]) || str[j] == '_'));
103
+ while (str[++j] && IsXidContinue(str[j]));
104
104
 
105
105
  Span<const char> tok = MakeSpan(str + i, j - i);
106
106
  tokens.Append(tok);
@@ -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 "util.hh"
26
26
 
27
27
  #include <napi.h>
@@ -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,
@@ -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"
@@ -337,7 +337,7 @@ const TypeInfo *ResolveType(Napi::Env env, Span<const char> str, int *out_direct
337
337
  TypeInfo *copy = instance->types.AppendDefault();
338
338
 
339
339
  memcpy((void *)copy, (const void *)type, RG_SIZE(*type));
340
- copy->name = Fmt(&instance->str_alloc, "<anonymous_%1>", instance->types.len).ptr;
340
+ copy->name = Fmt(&instance->str_alloc, "<anonymous_%1>", instance->types.count).ptr;
341
341
  copy->members.allocator = GetNullAllocator();
342
342
 
343
343
  copy->dispose = [](Napi::Env env, const TypeInfo *, const void *ptr) {
@@ -1170,7 +1170,7 @@ void DecodeNormalArray(Napi::Array array, const uint8_t *origin, const TypeInfo
1170
1170
  void DecodeBuffer(Span<uint8_t> buffer, const uint8_t *origin, const TypeInfo *ref)
1171
1171
  {
1172
1172
  // Go fast brrrrr!
1173
- memcpy_safe(buffer.ptr, origin, (size_t)buffer.len);
1173
+ MemCpy(buffer.ptr, origin, (size_t)buffer.len);
1174
1174
 
1175
1175
  #define SWAP(CType) \
1176
1176
  do { \
@@ -1694,16 +1694,16 @@ int AnalyseFlat(const TypeInfo *type, FunctionRef<void(const TypeInfo *type, int
1694
1694
  void DumpMemory(const char *type, Span<const uint8_t> bytes)
1695
1695
  {
1696
1696
  if (bytes.len) {
1697
- PrintLn(stderr, "%1 at 0x%2 (%3):", type, bytes.ptr, FmtMemSize(bytes.len));
1697
+ PrintLn(StdErr, "%1 at 0x%2 (%3):", type, bytes.ptr, FmtMemSize(bytes.len));
1698
1698
 
1699
1699
  for (const uint8_t *ptr = bytes.begin(); ptr < bytes.end();) {
1700
- Print(stderr, " [0x%1 %2 %3] ", FmtArg(ptr).Pad0(-16),
1700
+ Print(StdErr, " [0x%1 %2 %3] ", FmtArg(ptr).Pad0(-16),
1701
1701
  FmtArg((ptr - bytes.begin()) / sizeof(void *)).Pad(-4),
1702
1702
  FmtArg(ptr - bytes.begin()).Pad(-4));
1703
1703
  for (int i = 0; ptr < bytes.end() && i < (int)sizeof(void *); i++, ptr++) {
1704
- Print(stderr, " %1", FmtHex(*ptr).Pad0(-2));
1704
+ Print(StdErr, " %1", FmtHex(*ptr).Pad0(-2));
1705
1705
  }
1706
- PrintLn(stderr);
1706
+ PrintLn(StdErr);
1707
1707
  }
1708
1708
  }
1709
1709
  }
@@ -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
 
27
27
  #include <napi.h>
@@ -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,15 +19,15 @@
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 _WIN32
22
+ #if defined(_WIN32)
23
23
 
24
24
  #include "util.hh"
25
25
  #include "win32.hh"
26
26
 
27
- #ifndef NOMINMAX
27
+ #if !defined(NOMINMAX)
28
28
  #define NOMINMAX
29
29
  #endif
30
- #ifndef WIN32_LEAN_AND_MEAN
30
+ #if !defined(WIN32_LEAN_AND_MEAN)
31
31
  #define WIN32_LEAN_AND_MEAN
32
32
  #endif
33
33
  #include <windows.h>
@@ -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
 
26
26
  #include <intrin.h>
27
27
  #include <napi.h>
@@ -82,9 +82,9 @@ struct TEB {
82
82
  char _pad4[162];
83
83
  uint16_t SameTebFlags;
84
84
  };
85
- static_assert(RG_OFFSET_OF(TEB, DeallocationStack) == 0x1478);
86
- static_assert(RG_OFFSET_OF(TEB, GuaranteedStackBytes) == 0x1748);
87
- static_assert(RG_OFFSET_OF(TEB, SameTebFlags) == 0x17EE);
85
+ static_assert(offsetof(TEB, DeallocationStack) == 0x1478);
86
+ static_assert(offsetof(TEB, GuaranteedStackBytes) == 0x1748);
87
+ static_assert(offsetof(TEB, SameTebFlags) == 0x17EE);
88
88
 
89
89
  #else
90
90
 
@@ -101,9 +101,9 @@ struct TEB {
101
101
  char _pad4[78];
102
102
  uint16_t SameTebFlags;
103
103
  };
104
- static_assert(RG_OFFSET_OF(TEB, DeallocationStack) == 0xE0C);
105
- static_assert(RG_OFFSET_OF(TEB, GuaranteedStackBytes) == 0x0F78);
106
- static_assert(RG_OFFSET_OF(TEB, SameTebFlags) == 0xFCA);
104
+ static_assert(offsetof(TEB, DeallocationStack) == 0xE0C);
105
+ static_assert(offsetof(TEB, GuaranteedStackBytes) == 0x0F78);
106
+ static_assert(offsetof(TEB, SameTebFlags) == 0xFCA);
107
107
 
108
108
  #endif
109
109