koffi 2.14.0 → 2.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/README.md +1 -1
  3. package/build/koffi/darwin_arm64/koffi.node +0 -0
  4. package/build/koffi/darwin_x64/koffi.node +0 -0
  5. package/build/koffi/freebsd_arm64/koffi.node +0 -0
  6. package/build/koffi/freebsd_ia32/koffi.node +0 -0
  7. package/build/koffi/freebsd_x64/koffi.node +0 -0
  8. package/build/koffi/linux_arm64/koffi.node +0 -0
  9. package/build/koffi/linux_armhf/koffi.node +0 -0
  10. package/build/koffi/linux_ia32/koffi.node +0 -0
  11. package/build/koffi/linux_loong64/koffi.node +0 -0
  12. package/build/koffi/linux_riscv64d/koffi.node +0 -0
  13. package/build/koffi/linux_x64/koffi.node +0 -0
  14. package/build/koffi/musl_arm64/koffi.node +0 -0
  15. package/build/koffi/musl_x64/koffi.node +0 -0
  16. package/build/koffi/openbsd_ia32/koffi.node +0 -0
  17. package/build/koffi/openbsd_x64/koffi.node +0 -0
  18. package/build/koffi/win32_arm64/koffi.node +0 -0
  19. package/build/koffi/win32_ia32/koffi.node +0 -0
  20. package/build/koffi/win32_x64/koffi.node +0 -0
  21. package/doc/pages/index.md +43 -4
  22. package/doc/pages/platforms.md +8 -19
  23. package/doc/pages.ini +0 -7
  24. package/doc/static/perf_windows.png +0 -0
  25. package/index.js +3 -2
  26. package/indirect.js +3 -2
  27. package/package.json +3 -2
  28. package/src/cnoke/src/builder.js +1 -2
  29. package/src/core/base/base.cc +791 -555
  30. package/src/core/base/base.hh +577 -450
  31. package/src/core/base/crc.inc +1 -1
  32. package/src/core/base/crc_gen.py +1 -1
  33. package/src/core/base/unicode.inc +1 -1
  34. package/src/core/base/unicode_gen.py +1 -1
  35. package/src/koffi/src/abi_arm32.cc +24 -24
  36. package/src/koffi/src/abi_arm64.cc +29 -29
  37. package/src/koffi/src/abi_riscv64.cc +27 -27
  38. package/src/koffi/src/abi_x64_sysv.cc +29 -29
  39. package/src/koffi/src/abi_x64_win.cc +20 -20
  40. package/src/koffi/src/abi_x86.cc +26 -26
  41. package/src/koffi/src/call.cc +82 -236
  42. package/src/koffi/src/call.hh +6 -6
  43. package/src/koffi/src/ffi.cc +60 -60
  44. package/src/koffi/src/ffi.hh +9 -9
  45. package/src/koffi/src/parser.cc +2 -2
  46. package/src/koffi/src/parser.hh +1 -1
  47. package/src/koffi/src/trampolines/prototypes.inc +1 -1
  48. package/src/koffi/src/util.cc +43 -43
  49. package/src/koffi/src/util.hh +5 -5
  50. package/src/koffi/src/win32.cc +5 -5
  51. package/src/koffi/src/win32.hh +1 -1
@@ -50,7 +50,7 @@
50
50
 
51
51
  #include <napi.h>
52
52
 
53
- namespace RG {
53
+ namespace K {
54
54
 
55
55
  SharedData shared;
56
56
 
@@ -147,7 +147,7 @@ static Napi::Value GetSetConfig(const Napi::CallbackInfo &info)
147
147
  if (!ChangeMemorySize(key.c_str(), value, &new_config.async_heap_size))
148
148
  return env.Null();
149
149
  } else if (key == "resident_async_pools") {
150
- if (!ChangeAsyncLimit(key.c_str(), value, RG_LEN(instance->memories.data) - 1, &new_config.resident_async_pools))
150
+ if (!ChangeAsyncLimit(key.c_str(), value, K_LEN(instance->memories.data) - 1, &new_config.resident_async_pools))
151
151
  return env.Null();
152
152
  } else if (key == "max_async_calls") {
153
153
  if (!ChangeAsyncLimit(key.c_str(), value, MaxAsyncCalls, &max_async_calls))
@@ -259,7 +259,7 @@ static Napi::Value CreateStructType(const Napi::CallbackInfo &info, bool pad)
259
259
  Napi::Object obj = info[skip].As<Napi::Object>();
260
260
  Napi::Array keys = GetOwnPropertyNames(obj);
261
261
 
262
- RG_DEFER_NC(err_guard, count = instance->types.count) {
262
+ K_DEFER_NC(err_guard, count = instance->types.count) {
263
263
  Size start = count + !skip;
264
264
 
265
265
  for (Size i = start; i < instance->types.count; i++) {
@@ -454,7 +454,7 @@ static Napi::Value CreateUnionType(const Napi::CallbackInfo &info)
454
454
  Napi::Object obj = info[skip].As<Napi::Object>();
455
455
  Napi::Array keys = GetOwnPropertyNames(obj);
456
456
 
457
- RG_DEFER_NC(err_guard, count = instance->types.count) {
457
+ K_DEFER_NC(err_guard, count = instance->types.count) {
458
458
  Size start = count + !skip;
459
459
 
460
460
  for (Size i = start; i < instance->types.count; i++) {
@@ -629,7 +629,7 @@ static Napi::Value CreateOpaqueType(const Napi::CallbackInfo &info)
629
629
  Napi::String name = info[0].As<Napi::String>();
630
630
 
631
631
  TypeInfo *type = instance->types.AppendDefault();
632
- RG_DEFER_N(err_guard) { instance->types.RemoveLast(1); };
632
+ K_DEFER_N(err_guard) { instance->types.RemoveLast(1); };
633
633
 
634
634
  type->name = named ? DuplicateString(name.Utf8Value().c_str(), &instance->str_alloc).ptr
635
635
  : Fmt(&instance->str_alloc, "<anonymous_%1>", instance->types.count).ptr;
@@ -690,13 +690,13 @@ static Napi::Value CreatePointerType(const Napi::CallbackInfo &info)
690
690
  }
691
691
 
692
692
  TypeInfo *type = MakePointerType(instance, ref, count);
693
- RG_ASSERT(type);
693
+ K_ASSERT(type);
694
694
 
695
695
  if (named || !countedby.IsEmpty()) {
696
696
  TypeInfo *copy = instance->types.AppendDefault();
697
- RG_DEFER_N(err_guard) { instance->types.RemoveLast(1); };
697
+ K_DEFER_N(err_guard) { instance->types.RemoveLast(1); };
698
698
 
699
- memcpy((void *)copy, type, RG_SIZE(*type));
699
+ memcpy((void *)copy, type, K_SIZE(*type));
700
700
  copy->name = named ? DuplicateString(name.c_str(), &instance->str_alloc).ptr : copy->name;
701
701
 
702
702
  if (!countedby.IsEmpty()) {
@@ -717,7 +717,7 @@ static Napi::Value CreatePointerType(const Napi::CallbackInfo &info)
717
717
 
718
718
  static Napi::Value EncodePointerDirection(const Napi::CallbackInfo &info, int directions)
719
719
  {
720
- RG_ASSERT(directions >= 1 && directions <= 3);
720
+ K_ASSERT(directions >= 1 && directions <= 3);
721
721
 
722
722
  Napi::Env env = info.Env();
723
723
  InstanceData *instance = env.GetInstanceData<InstanceData>();
@@ -817,7 +817,7 @@ static Napi::Value CreateDisposableType(const Napi::CallbackInfo &info)
817
817
  external
818
818
  };
819
819
 
820
- ref.Call(self, RG_LEN(args), args);
820
+ ref.Call(self, K_LEN(args), args);
821
821
  instance->stats.disposed++;
822
822
  };
823
823
  dispose_func = func;
@@ -831,9 +831,9 @@ static Napi::Value CreateDisposableType(const Napi::CallbackInfo &info)
831
831
  }
832
832
 
833
833
  TypeInfo *type = instance->types.AppendDefault();
834
- RG_DEFER_N(err_guard) { instance->types.RemoveLast(1); };
834
+ K_DEFER_N(err_guard) { instance->types.RemoveLast(1); };
835
835
 
836
- memcpy((void *)type, (const void *)src, RG_SIZE(*src));
836
+ memcpy((void *)type, (const void *)src, K_SIZE(*src));
837
837
  type->members.allocator = GetNullAllocator();
838
838
 
839
839
  type->name = named ? DuplicateString(name.Utf8Value().c_str(), &instance->str_alloc).ptr
@@ -1052,7 +1052,7 @@ static Napi::Value CreateArrayType(const Napi::CallbackInfo &info)
1052
1052
 
1053
1053
  static bool ParseClassicFunction(const Napi::CallbackInfo &info, bool concrete, FunctionInfo *out_func)
1054
1054
  {
1055
- RG_ASSERT(info.Length() >= 2);
1055
+ K_ASSERT(info.Length() >= 2);
1056
1056
 
1057
1057
  Napi::Env env = info.Env();
1058
1058
  InstanceData *instance = env.GetInstanceData<InstanceData>();
@@ -1158,7 +1158,7 @@ static Napi::Value CreateFunctionType(const Napi::CallbackInfo &info)
1158
1158
  InstanceData *instance = env.GetInstanceData<InstanceData>();
1159
1159
 
1160
1160
  FunctionInfo *func = instance->callbacks.AppendDefault();
1161
- RG_DEFER_N(err_guard) { instance->callbacks.RemoveLast(1); };
1161
+ K_DEFER_N(err_guard) { instance->callbacks.RemoveLast(1); };
1162
1162
 
1163
1163
  if (info.Length() >= 2) {
1164
1164
  if (!ParseClassicFunction(info, false, func))
@@ -1205,7 +1205,7 @@ static Napi::Value CreateFunctionType(const Napi::CallbackInfo &info)
1205
1205
 
1206
1206
  type->primitive = PrimitiveKind::Prototype;
1207
1207
  type->align = alignof(void *);
1208
- type->size = RG_SIZE(void *);
1208
+ type->size = K_SIZE(void *);
1209
1209
  type->ref.proto = func;
1210
1210
 
1211
1211
  instance->types_map.Set(type->name, type);
@@ -1428,7 +1428,7 @@ static InstanceMemory *AllocateMemory(InstanceData *instance, Size stack_size, S
1428
1428
  return nullptr;
1429
1429
 
1430
1430
  InstanceMemory *mem = new InstanceMemory();
1431
- RG_DEFER_N(mem_guard) { delete mem; };
1431
+ K_DEFER_N(mem_guard) { delete mem; };
1432
1432
 
1433
1433
  stack_size = AlignLen(stack_size, Kibibytes(64));
1434
1434
 
@@ -1437,12 +1437,12 @@ static InstanceMemory *AllocateMemory(InstanceData *instance, Size stack_size, S
1437
1437
  mem->stack.len = stack_size;
1438
1438
  mem->stack.ptr = (uint8_t *)VirtualAlloc(nullptr, mem->stack.len, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
1439
1439
 
1440
- RG_CRITICAL(mem->stack.ptr, "Failed to allocate %1 of memory", mem->stack.len);
1440
+ K_CRITICAL(mem->stack.ptr, "Failed to allocate %1 of memory", mem->stack.len);
1441
1441
  #else
1442
1442
  mem->stack.len = stack_size;
1443
1443
  mem->stack.ptr = (uint8_t *)mmap(nullptr, mem->stack.len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_STACK, -1, 0);
1444
1444
 
1445
- RG_CRITICAL(mem->stack.ptr, "Failed to allocate %1 of memory", mem->stack.len);
1445
+ K_CRITICAL(mem->stack.ptr, "Failed to allocate %1 of memory", mem->stack.len);
1446
1446
  #endif
1447
1447
 
1448
1448
  #if defined(__OpenBSD__)
@@ -1459,7 +1459,7 @@ static InstanceMemory *AllocateMemory(InstanceData *instance, Size stack_size, S
1459
1459
  #else
1460
1460
  mem->heap.ptr = (uint8_t *)mmap(nullptr, mem->heap.len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
1461
1461
  #endif
1462
- RG_CRITICAL(mem->heap.ptr, "Failed to allocate %1 of memory", mem->heap.len);
1462
+ K_CRITICAL(mem->heap.ptr, "Failed to allocate %1 of memory", mem->heap.len);
1463
1463
 
1464
1464
  if (temporary) {
1465
1465
  instance->temporaries++;
@@ -1498,7 +1498,7 @@ static Napi::Value TranslateNormalCall(const FunctionInfo *func, void *native,
1498
1498
 
1499
1499
  // Execute call
1500
1500
  {
1501
- RG_DEFER_C(prev_call = exec_call) { exec_call = prev_call; };
1501
+ K_DEFER_C(prev_call = exec_call) { exec_call = prev_call; };
1502
1502
  exec_call = &call;
1503
1503
 
1504
1504
  call.Execute(func, native);
@@ -1520,11 +1520,11 @@ static Napi::Value TranslateVariadicCall(const FunctionInfo *func, void *native,
1520
1520
  InstanceData *instance = env.GetInstanceData<InstanceData>();
1521
1521
 
1522
1522
  FunctionInfo copy;
1523
- memcpy((void *)&copy, func, RG_SIZE(*func));
1523
+ memcpy((void *)&copy, func, K_SIZE(*func));
1524
1524
  copy.lib = nullptr;
1525
1525
 
1526
1526
  // This makes variadic calls non-reentrant
1527
- RG_DEFER_C(len = copy.parameters.len) {
1527
+ K_DEFER_C(len = copy.parameters.len) {
1528
1528
  copy.parameters.RemoveFrom(len);
1529
1529
  copy.parameters.Leak();
1530
1530
  };
@@ -1579,7 +1579,7 @@ static Napi::Value TranslateVariadicCall(const FunctionInfo *func, void *native,
1579
1579
 
1580
1580
  // Execute call
1581
1581
  {
1582
- RG_DEFER_C(prev_call = exec_call) { exec_call = prev_call; };
1582
+ K_DEFER_C(prev_call = exec_call) { exec_call = prev_call; };
1583
1583
  exec_call = &call;
1584
1584
 
1585
1585
  call.Execute(&copy, native);
@@ -1629,7 +1629,7 @@ public:
1629
1629
  void AsyncCall::Execute()
1630
1630
  {
1631
1631
  if (prepared) {
1632
- RG_DEFER_C(prev_call = exec_call) { exec_call = prev_call; };
1632
+ K_DEFER_C(prev_call = exec_call) { exec_call = prev_call; };
1633
1633
  exec_call = &call;
1634
1634
 
1635
1635
  call.Execute(func, native);
@@ -1638,7 +1638,7 @@ void AsyncCall::Execute()
1638
1638
 
1639
1639
  void AsyncCall::OnOK()
1640
1640
  {
1641
- RG_ASSERT(prepared);
1641
+ K_ASSERT(prepared);
1642
1642
 
1643
1643
  Napi::FunctionReference &callback = Callback();
1644
1644
 
@@ -1648,13 +1648,13 @@ void AsyncCall::OnOK()
1648
1648
  call.Complete(func)
1649
1649
  };
1650
1650
 
1651
- callback.Call(self, RG_LEN(args), args);
1651
+ callback.Call(self, K_LEN(args), args);
1652
1652
  }
1653
1653
 
1654
1654
  static Napi::Value TranslateAsyncCall(const FunctionInfo *func, void *native,
1655
1655
  const Napi::CallbackInfo &info)
1656
1656
  {
1657
- RG_ASSERT(!func->variadic);
1657
+ K_ASSERT(!func->variadic);
1658
1658
 
1659
1659
  Napi::Env env = info.Env();
1660
1660
  InstanceData *instance = env.GetInstanceData<InstanceData>();
@@ -1712,7 +1712,7 @@ extern "C" void RelayCallback(Size idx, uint8_t *own_sp, uint8_t *caller_sp, Bac
1712
1712
  }
1713
1713
 
1714
1714
  // Avoid triggering the "use callback beyond FFI" check
1715
- RG_DEFER_C(generation = trampoline->generation) { trampoline->generation = generation; };
1715
+ K_DEFER_C(generation = trampoline->generation) { trampoline->generation = generation; };
1716
1716
  trampoline->generation = -1;
1717
1717
 
1718
1718
  // We set dispose_call to true so that the main thread will dispose of CallData itself
@@ -1728,7 +1728,7 @@ static Napi::Value FindLibraryFunction(const Napi::CallbackInfo &info)
1728
1728
  LibraryHolder *lib = (LibraryHolder *)info.Data();
1729
1729
 
1730
1730
  FunctionInfo *func = new FunctionInfo();
1731
- RG_DEFER { func->Unref(); };
1731
+ K_DEFER { func->Unref(); };
1732
1732
 
1733
1733
  func->lib = lib->Ref();
1734
1734
 
@@ -1876,7 +1876,7 @@ static Napi::Value LoadSharedLibrary(const Napi::CallbackInfo &info)
1876
1876
 
1877
1877
  if (!instance->memories.len) {
1878
1878
  AllocateMemory(instance, instance->config.sync_stack_size, instance->config.sync_heap_size);
1879
- RG_ASSERT(instance->memories.len);
1879
+ K_ASSERT(instance->memories.len);
1880
1880
  }
1881
1881
 
1882
1882
  // Load shared library
@@ -1890,7 +1890,7 @@ static Napi::Value LoadSharedLibrary(const Napi::CallbackInfo &info)
1890
1890
  return env.Null();
1891
1891
  } else {
1892
1892
  module = GetModuleHandle(nullptr);
1893
- RG_ASSERT(module);
1893
+ K_ASSERT(module);
1894
1894
  }
1895
1895
  #else
1896
1896
  if (info[0].IsString()) {
@@ -1917,7 +1917,7 @@ static Napi::Value LoadSharedLibrary(const Napi::CallbackInfo &info)
1917
1917
  #endif
1918
1918
 
1919
1919
  LibraryHolder *lib = new LibraryHolder(module);
1920
- RG_DEFER { lib->Unref(); };
1920
+ K_DEFER { lib->Unref(); };
1921
1921
 
1922
1922
  Napi::Object obj = Napi::Object::New(env);
1923
1923
 
@@ -2040,7 +2040,7 @@ static Napi::Value UnregisterCallback(const Napi::CallbackInfo &info)
2040
2040
  std::lock_guard<std::mutex> lock(shared.mutex);
2041
2041
 
2042
2042
  TrampolineInfo *trampoline = &shared.trampolines[idx];
2043
- RG_ASSERT(!trampoline->func.IsEmpty());
2043
+ K_ASSERT(!trampoline->func.IsEmpty());
2044
2044
 
2045
2045
  trampoline->func.Reset();
2046
2046
  trampoline->recv.Reset();
@@ -2354,8 +2354,8 @@ bool InitAsyncBroker(Napi::Env env, InstanceData *instance)
2354
2354
  static void RegisterPrimitiveType(Napi::Env env, Napi::Object map, std::initializer_list<const char *> names,
2355
2355
  PrimitiveKind primitive, int32_t size, int16_t align, const char *ref = nullptr)
2356
2356
  {
2357
- RG_ASSERT(names.size() > 0);
2358
- RG_ASSERT(align <= size);
2357
+ K_ASSERT(names.size() > 0);
2358
+ K_ASSERT(align <= size);
2359
2359
 
2360
2360
  InstanceData *instance = env.GetInstanceData<InstanceData>();
2361
2361
 
@@ -2379,7 +2379,7 @@ static void RegisterPrimitiveType(Napi::Env env, Napi::Object map, std::initiali
2379
2379
 
2380
2380
  if (ref) {
2381
2381
  const TypeInfo *marker = instance->types_map.FindValue(ref, nullptr);
2382
- RG_ASSERT(marker);
2382
+ K_ASSERT(marker);
2383
2383
 
2384
2384
  type->ref.marker = marker;
2385
2385
  }
@@ -2389,7 +2389,7 @@ static void RegisterPrimitiveType(Napi::Env env, Napi::Object map, std::initiali
2389
2389
  for (const char *name: names) {
2390
2390
  bool inserted;
2391
2391
  instance->types_map.TrySet(name, type, &inserted);
2392
- RG_ASSERT(inserted);
2392
+ K_ASSERT(inserted);
2393
2393
 
2394
2394
  if (!EndsWith(name, "*")) {
2395
2395
  map.Set(name, wrapper);
@@ -2406,12 +2406,12 @@ static inline PrimitiveKind GetSignPrimitive(Size len, bool sign)
2406
2406
  case 8: return sign ? PrimitiveKind::Int64 : PrimitiveKind::UInt64;
2407
2407
  }
2408
2408
 
2409
- RG_UNREACHABLE();
2409
+ K_UNREACHABLE();
2410
2410
  }
2411
2411
 
2412
2412
  static inline PrimitiveKind GetLittleEndianPrimitive(PrimitiveKind kind)
2413
2413
  {
2414
- #if defined(RG_BIG_ENDIAN)
2414
+ #if defined(K_BIG_ENDIAN)
2415
2415
  return (PrimitiveKind)((int)kind + 1);
2416
2416
  #else
2417
2417
  return kind;
@@ -2420,7 +2420,7 @@ static inline PrimitiveKind GetLittleEndianPrimitive(PrimitiveKind kind)
2420
2420
 
2421
2421
  static inline PrimitiveKind GetBigEndianPrimitive(PrimitiveKind kind)
2422
2422
  {
2423
- #if defined(RG_BIG_ENDIAN)
2423
+ #if defined(K_BIG_ENDIAN)
2424
2424
  return kind;
2425
2425
  #else
2426
2426
  return (PrimitiveKind)((int)kind + 1);
@@ -2430,7 +2430,7 @@ static inline PrimitiveKind GetBigEndianPrimitive(PrimitiveKind kind)
2430
2430
  static InstanceData *CreateInstance()
2431
2431
  {
2432
2432
  InstanceData *instance = new InstanceData();
2433
- RG_DEFER_N(err_guard) { delete instance; };
2433
+ K_DEFER_N(err_guard) { delete instance; };
2434
2434
 
2435
2435
  instance->main_thread_id = std::this_thread::get_id();
2436
2436
 
@@ -2450,7 +2450,7 @@ static InstanceData *CreateInstance()
2450
2450
  static Napi::Object InitModule(Napi::Env env, Napi::Object exports)
2451
2451
  {
2452
2452
  InstanceData *instance = CreateInstance();
2453
- RG_CRITICAL(instance, "Failed to initialize Koffi");
2453
+ K_CRITICAL(instance, "Failed to initialize Koffi");
2454
2454
 
2455
2455
  env.SetInstanceData(instance);
2456
2456
 
@@ -2525,16 +2525,16 @@ static Napi::Object InitModule(Napi::Env env, Napi::Object exports)
2525
2525
  exports.Set("types", types);
2526
2526
 
2527
2527
  RegisterPrimitiveType(env, types, {"void"}, PrimitiveKind::Void, 0, 0);
2528
- RegisterPrimitiveType(env, types, {"bool"}, PrimitiveKind::Bool, RG_SIZE(bool), alignof(bool));
2528
+ RegisterPrimitiveType(env, types, {"bool"}, PrimitiveKind::Bool, K_SIZE(bool), alignof(bool));
2529
2529
  RegisterPrimitiveType(env, types, {"int8_t", "int8"}, PrimitiveKind::Int8, 1, 1);
2530
2530
  RegisterPrimitiveType(env, types, {"uint8_t", "uint8"}, PrimitiveKind::UInt8, 1, 1);
2531
2531
  RegisterPrimitiveType(env, types, {"char"}, PrimitiveKind::Int8, 1, 1);
2532
2532
  RegisterPrimitiveType(env, types, {"unsigned char", "uchar"}, PrimitiveKind::UInt8, 1, 1);
2533
2533
  RegisterPrimitiveType(env, types, {"char16_t", "char16"}, PrimitiveKind::Int16, 2, 2);
2534
2534
  RegisterPrimitiveType(env, types, {"char32_t", "char32"}, PrimitiveKind::Int32, 4, 4);
2535
- if (RG_SIZE(wchar_t) == 2) {
2535
+ if (K_SIZE(wchar_t) == 2) {
2536
2536
  RegisterPrimitiveType(env, types, {"wchar_t", "wchar"}, PrimitiveKind::Int16, 2, 2);
2537
- } else if (RG_SIZE(wchar_t) == 4) {
2537
+ } else if (K_SIZE(wchar_t) == 4) {
2538
2538
  RegisterPrimitiveType(env, types, {"wchar_t", "wchar"}, PrimitiveKind::Int32, 4, 4);
2539
2539
  }
2540
2540
  RegisterPrimitiveType(env, types, {"int16_t", "int16"}, PrimitiveKind::Int16, 2, 2);
@@ -2559,22 +2559,22 @@ static Napi::Object InitModule(Napi::Env env, Napi::Object exports)
2559
2559
  RegisterPrimitiveType(env, types, {"uint64_t", "uint64"}, PrimitiveKind::UInt64, 8, alignof(int64_t));
2560
2560
  RegisterPrimitiveType(env, types, {"uint64_le_t", "uint64_le"}, GetLittleEndianPrimitive(PrimitiveKind::UInt64), 8, alignof(int64_t));
2561
2561
  RegisterPrimitiveType(env, types, {"uint64_be_t", "uint64_be"}, GetBigEndianPrimitive(PrimitiveKind::UInt64), 8, alignof(int64_t));
2562
- RegisterPrimitiveType(env, types, {"intptr_t", "intptr"}, GetSignPrimitive(RG_SIZE(intptr_t), true), RG_SIZE(intptr_t), alignof(intptr_t));
2563
- RegisterPrimitiveType(env, types, {"uintptr_t", "uintptr"}, GetSignPrimitive(RG_SIZE(intptr_t), false), RG_SIZE(intptr_t), alignof(intptr_t));
2564
- RegisterPrimitiveType(env, types, {"size_t"}, GetSignPrimitive(RG_SIZE(size_t), false), RG_SIZE(size_t), alignof(size_t));
2565
- RegisterPrimitiveType(env, types, {"long"}, GetSignPrimitive(RG_SIZE(long), true), RG_SIZE(long), alignof(long));
2566
- RegisterPrimitiveType(env, types, {"unsigned long", "ulong"}, GetSignPrimitive(RG_SIZE(long), false), RG_SIZE(long), alignof(long));
2567
- RegisterPrimitiveType(env, types, {"long long", "longlong"}, PrimitiveKind::Int64, RG_SIZE(int64_t), alignof(int64_t));
2568
- RegisterPrimitiveType(env, types, {"unsigned long long", "ulonglong"}, PrimitiveKind::UInt64, RG_SIZE(uint64_t), alignof(uint64_t));
2562
+ RegisterPrimitiveType(env, types, {"intptr_t", "intptr"}, GetSignPrimitive(K_SIZE(intptr_t), true), K_SIZE(intptr_t), alignof(intptr_t));
2563
+ RegisterPrimitiveType(env, types, {"uintptr_t", "uintptr"}, GetSignPrimitive(K_SIZE(intptr_t), false), K_SIZE(intptr_t), alignof(intptr_t));
2564
+ RegisterPrimitiveType(env, types, {"size_t"}, GetSignPrimitive(K_SIZE(size_t), false), K_SIZE(size_t), alignof(size_t));
2565
+ RegisterPrimitiveType(env, types, {"long"}, GetSignPrimitive(K_SIZE(long), true), K_SIZE(long), alignof(long));
2566
+ RegisterPrimitiveType(env, types, {"unsigned long", "ulong"}, GetSignPrimitive(K_SIZE(long), false), K_SIZE(long), alignof(long));
2567
+ RegisterPrimitiveType(env, types, {"long long", "longlong"}, PrimitiveKind::Int64, K_SIZE(int64_t), alignof(int64_t));
2568
+ RegisterPrimitiveType(env, types, {"unsigned long long", "ulonglong"}, PrimitiveKind::UInt64, K_SIZE(uint64_t), alignof(uint64_t));
2569
2569
  RegisterPrimitiveType(env, types, {"float", "float32"}, PrimitiveKind::Float32, 4, alignof(float));
2570
2570
  RegisterPrimitiveType(env, types, {"double", "float64"}, PrimitiveKind::Float64, 8, alignof(double));
2571
- RegisterPrimitiveType(env, types, {"char *", "str", "string"}, PrimitiveKind::String, RG_SIZE(void *), alignof(void *), "char");
2572
- RegisterPrimitiveType(env, types, {"char16_t *", "char16 *", "str16", "string16"}, PrimitiveKind::String16, RG_SIZE(void *), alignof(void *), "char16_t");
2573
- RegisterPrimitiveType(env, types, {"char32_t *", "char32 *", "str32", "string32"}, PrimitiveKind::String32, RG_SIZE(void *), alignof(void *), "char32_t");
2574
- if (RG_SIZE(wchar_t) == 2) {
2575
- RegisterPrimitiveType(env, types, {"wchar_t *", "wchar *"}, PrimitiveKind::String16, RG_SIZE(void *), alignof(void *), "wchar_t");
2576
- } else if (RG_SIZE(wchar_t) == 4) {
2577
- RegisterPrimitiveType(env, types, {"wchar_t *", "wchar *"}, PrimitiveKind::String32, RG_SIZE(void *), alignof(void *), "wchar_t");
2571
+ RegisterPrimitiveType(env, types, {"char *", "str", "string"}, PrimitiveKind::String, K_SIZE(void *), alignof(void *), "char");
2572
+ RegisterPrimitiveType(env, types, {"char16_t *", "char16 *", "str16", "string16"}, PrimitiveKind::String16, K_SIZE(void *), alignof(void *), "char16_t");
2573
+ RegisterPrimitiveType(env, types, {"char32_t *", "char32 *", "str32", "string32"}, PrimitiveKind::String32, K_SIZE(void *), alignof(void *), "char32_t");
2574
+ if (K_SIZE(wchar_t) == 2) {
2575
+ RegisterPrimitiveType(env, types, {"wchar_t *", "wchar *"}, PrimitiveKind::String16, K_SIZE(void *), alignof(void *), "wchar_t");
2576
+ } else if (K_SIZE(wchar_t) == 4) {
2577
+ RegisterPrimitiveType(env, types, {"wchar_t *", "wchar *"}, PrimitiveKind::String32, K_SIZE(void *), alignof(void *), "wchar_t");
2578
2578
  }
2579
2579
 
2580
2580
  instance->void_type = instance->types_map.FindValue("void", nullptr);
@@ -2601,7 +2601,7 @@ static Napi::Object InitModule(Napi::Env env, Napi::Object exports)
2601
2601
  node.Set("env", external);
2602
2602
  }
2603
2603
 
2604
- exports.Set("version", Napi::String::New(env, RG_STRINGIFY(VERSION)));
2604
+ exports.Set("version", Napi::String::New(env, K_STRINGIFY(VERSION)));
2605
2605
 
2606
2606
  return exports;
2607
2607
  }
@@ -25,7 +25,7 @@
25
25
 
26
26
  #include <napi.h>
27
27
 
28
- namespace RG {
28
+ namespace K {
29
29
 
30
30
  static const Size DefaultSyncStackSize = Mebibytes(1);
31
31
  static const Size DefaultSyncHeapSize = Mebibytes(2);
@@ -47,17 +47,17 @@ enum class PrimitiveKind {
47
47
  Int8,
48
48
  UInt8,
49
49
  Int16,
50
- Int16S,
50
+ Int16S, // Keep behind Int16
51
51
  UInt16,
52
- UInt16S,
52
+ UInt16S, // Keep behind UInt16
53
53
  Int32,
54
- Int32S,
54
+ Int32S, // Keep behind Int32
55
55
  UInt32,
56
- UInt32S,
56
+ UInt32S, // Keep behind UInt32
57
57
  Int64,
58
- Int64S,
58
+ Int64S, // Keep behind Int64
59
59
  UInt64,
60
- UInt64S,
60
+ UInt64S, // Keep behind UInt64
61
61
  String,
62
62
  String16,
63
63
  String32,
@@ -152,7 +152,7 @@ struct TypeInfo {
152
152
  mutable Napi::FunctionReference construct; // Union only
153
153
  mutable Napi::ObjectReference defn;
154
154
 
155
- RG_HASHTABLE_HANDLER(TypeInfo, name);
155
+ K_HASHTABLE_HANDLER(TypeInfo, name);
156
156
  };
157
157
 
158
158
  struct RecordMember {
@@ -329,7 +329,7 @@ struct InstanceData {
329
329
  int64_t disposed = 0;
330
330
  } stats;
331
331
  };
332
- static_assert(DefaultResidentAsyncPools <= RG_LEN(InstanceData::memories.data) - 1);
332
+ static_assert(DefaultResidentAsyncPools <= K_LEN(InstanceData::memories.data) - 1);
333
333
  static_assert(DefaultMaxAsyncCalls >= DefaultResidentAsyncPools);
334
334
  static_assert(MaxAsyncCalls >= DefaultMaxAsyncCalls);
335
335
 
@@ -25,7 +25,7 @@
25
25
 
26
26
  #include <napi.h>
27
27
 
28
- namespace RG {
28
+ namespace K {
29
29
 
30
30
  bool PrototypeParser::Parse(const char *str, bool concrete, FunctionInfo *out_func)
31
31
  {
@@ -221,7 +221,7 @@ bool PrototypeParser::Match(const char *expect)
221
221
 
222
222
  bool PrototypeParser::IsIdentifier(Span<const char> tok) const
223
223
  {
224
- RG_ASSERT(tok.len);
224
+ K_ASSERT(tok.len);
225
225
  return IsAsciiAlpha(tok[0]) || tok[0] == '_';
226
226
  }
227
227
 
@@ -26,7 +26,7 @@
26
26
 
27
27
  #include <napi.h>
28
28
 
29
- namespace RG {
29
+ namespace K {
30
30
 
31
31
  struct InstanceData;
32
32
  struct TypeInfo;
@@ -16406,4 +16406,4 @@ static void *const Trampolines[][2] = {
16406
16406
  { &Trampoline8190, &TrampolineX8190 },
16407
16407
  { &Trampoline8191, &TrampolineX8191 }
16408
16408
  };
16409
- static_assert(RG_LEN(Trampolines) == MaxTrampolines);
16409
+ static_assert(K_LEN(Trampolines) == MaxTrampolines);