koffi 2.14.1 → 2.15.0

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 (102) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/build/koffi/darwin_arm64/koffi.node +0 -0
  3. package/build/koffi/darwin_x64/koffi.node +0 -0
  4. package/build/koffi/freebsd_arm64/koffi.node +0 -0
  5. package/build/koffi/freebsd_ia32/koffi.node +0 -0
  6. package/build/koffi/freebsd_x64/koffi.node +0 -0
  7. package/build/koffi/linux_arm64/koffi.node +0 -0
  8. package/build/koffi/linux_armhf/koffi.node +0 -0
  9. package/build/koffi/linux_ia32/koffi.node +0 -0
  10. package/build/koffi/linux_loong64/koffi.node +0 -0
  11. package/build/koffi/linux_riscv64d/koffi.node +0 -0
  12. package/build/koffi/linux_x64/koffi.node +0 -0
  13. package/build/koffi/musl_arm64/koffi.node +0 -0
  14. package/build/koffi/musl_x64/koffi.node +0 -0
  15. package/build/koffi/openbsd_ia32/koffi.node +0 -0
  16. package/build/koffi/openbsd_x64/koffi.node +0 -0
  17. package/build/koffi/win32_arm64/koffi.node +0 -0
  18. package/build/koffi/win32_ia32/koffi.node +0 -0
  19. package/build/koffi/win32_x64/koffi.node +0 -0
  20. package/doc/assets.ini +2 -1
  21. package/doc/build.sh +9 -0
  22. package/doc/pages/404.md +17 -0
  23. package/doc/pages/index.md +1 -1
  24. package/doc/pages/misc.md +16 -11
  25. package/doc/pages.ini +4 -0
  26. package/doc/static/highlight.js +2 -14
  27. package/doc/static/koffi.css +3 -15
  28. package/doc/static/print.css +2 -14
  29. package/index.d.ts +29 -24
  30. package/index.js +8 -8
  31. package/indirect.js +8 -8
  32. package/{src/core → lib/native}/base/base.cc +1058 -630
  33. package/{src/core → lib/native}/base/base.hh +334 -165
  34. package/{src/core → lib/native}/base/crc.inc +2 -20
  35. package/lib/native/base/crc_gen.py +72 -0
  36. package/{src/core → lib/native}/base/mimetypes.inc +2 -20
  37. package/{src/core → lib/native}/base/mimetypes_gen.py +2 -21
  38. package/lib/native/base/tower.cc +821 -0
  39. package/lib/native/base/tower.hh +81 -0
  40. package/{src/core → lib/native}/base/unicode.inc +2 -20
  41. package/{src/core → lib/native}/base/unicode_gen.py +4 -41
  42. package/package.json +1 -1
  43. package/src/cnoke/assets/FindCNoke.cmake +8 -20
  44. package/src/cnoke/assets/win_delay_hook.c +2 -20
  45. package/src/cnoke/cnoke.js +2 -21
  46. package/src/cnoke/src/builder.js +2 -20
  47. package/src/cnoke/src/index.js +2 -20
  48. package/src/cnoke/src/tools.js +2 -20
  49. package/src/koffi/CMakeLists.txt +19 -22
  50. package/src/koffi/cmake/raylib.cmake +5 -22
  51. package/src/koffi/cmake/sqlite3.cmake +2 -20
  52. package/src/koffi/src/abi_arm32.cc +7 -25
  53. package/src/koffi/src/abi_arm32_asm.S +2 -20
  54. package/src/koffi/src/abi_arm64.cc +7 -25
  55. package/src/koffi/src/abi_arm64_asm.S +2 -20
  56. package/src/koffi/src/abi_arm64_asm.asm +2 -20
  57. package/src/koffi/src/abi_loong64.cc +2 -20
  58. package/src/koffi/src/abi_loong64_asm.S +2 -20
  59. package/src/koffi/src/abi_riscv64.cc +7 -25
  60. package/src/koffi/src/abi_riscv64_asm.S +2 -20
  61. package/src/koffi/src/abi_x64_sysv.cc +7 -25
  62. package/src/koffi/src/abi_x64_sysv_asm.S +2 -20
  63. package/src/koffi/src/abi_x64_win.cc +12 -30
  64. package/src/koffi/src/abi_x64_win_asm.asm +2 -20
  65. package/src/koffi/src/abi_x86.cc +7 -25
  66. package/src/koffi/src/abi_x86_asm.S +2 -20
  67. package/src/koffi/src/abi_x86_asm.asm +2 -20
  68. package/src/koffi/src/call.cc +25 -45
  69. package/src/koffi/src/call.hh +3 -21
  70. package/src/koffi/src/errno.inc +2 -20
  71. package/src/koffi/src/ffi.cc +62 -62
  72. package/src/koffi/src/ffi.hh +14 -29
  73. package/src/koffi/src/init.js +2 -20
  74. package/src/koffi/src/parser.cc +13 -27
  75. package/src/koffi/src/parser.hh +3 -21
  76. package/src/koffi/src/trampolines/armasm.inc +0 -21
  77. package/src/koffi/src/trampolines/gnu.inc +0 -21
  78. package/src/koffi/src/trampolines/masm32.inc +0 -21
  79. package/src/koffi/src/trampolines/masm64.inc +0 -21
  80. package/src/koffi/src/trampolines/prototypes.inc +0 -21
  81. package/src/koffi/src/util.cc +44 -59
  82. package/src/koffi/src/util.hh +6 -24
  83. package/src/koffi/src/uv.cc +193 -0
  84. package/src/koffi/src/uv.def +10 -0
  85. package/src/koffi/src/uv.hh +40 -0
  86. package/src/koffi/src/win32.cc +2 -20
  87. package/src/koffi/src/win32.hh +3 -21
  88. package/vendor/node-api-headers/include/uv/aix.h +32 -0
  89. package/vendor/node-api-headers/include/uv/bsd.h +34 -0
  90. package/vendor/node-api-headers/include/uv/darwin.h +61 -0
  91. package/vendor/node-api-headers/include/uv/errno.h +483 -0
  92. package/vendor/node-api-headers/include/uv/linux.h +34 -0
  93. package/vendor/node-api-headers/include/uv/os390.h +33 -0
  94. package/vendor/node-api-headers/include/uv/posix.h +31 -0
  95. package/vendor/node-api-headers/include/uv/sunos.h +44 -0
  96. package/vendor/node-api-headers/include/uv/threadpool.h +37 -0
  97. package/vendor/node-api-headers/include/uv/tree.h +521 -0
  98. package/vendor/node-api-headers/include/uv/unix.h +512 -0
  99. package/vendor/node-api-headers/include/uv/version.h +43 -0
  100. package/vendor/node-api-headers/include/uv/win.h +698 -0
  101. package/vendor/node-api-headers/include/uv.h +1990 -0
  102. package/src/core/base/crc_gen.py +0 -109
@@ -1,27 +1,9 @@
1
- // Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
2
- //
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
5
- // the Software without restriction, including without limitation the rights to use,
6
- // copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
- // Software, and to permit persons to whom the Software is furnished to do so,
8
- // subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in all
11
- // copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
14
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15
- // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17
- // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
- // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
- // OTHER DEALINGS IN THE SOFTWARE.
1
+ // SPDX-License-Identifier: MIT
2
+ // SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
21
3
 
22
4
  #if defined(__aarch64__) || defined(_M_ARM64)
23
5
 
24
- #include "src/core/base/base.hh"
6
+ #include "lib/native/base/base.hh"
25
7
  #include "ffi.hh"
26
8
  #include "call.hh"
27
9
  #include "util.hh"
@@ -675,7 +657,7 @@ Napi::Value CallData::Complete(const FunctionInfo *func)
675
657
  case PrimitiveKind::Callback: {
676
658
  if (result.ptr) {
677
659
  Napi::External<void> external = Napi::External<void>::New(env, result.ptr);
678
- SetValueTag(instance, external, func->ret.type->ref.marker);
660
+ SetValueTag(external, func->ret.type->ref.marker);
679
661
 
680
662
  return external;
681
663
  } else {
@@ -1054,7 +1036,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, bool switch_
1054
1036
 
1055
1037
  if (ptr2) {
1056
1038
  Napi::External<void> external = Napi::External<void>::New(env, ptr2);
1057
- SetValueTag(instance, external, param.type->ref.marker);
1039
+ SetValueTag(external, param.type->ref.marker);
1058
1040
 
1059
1041
  arguments.Append(external);
1060
1042
  } else {
@@ -1235,7 +1217,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, bool switch_
1235
1217
  case PrimitiveKind::Pointer: {
1236
1218
  uint8_t *ptr;
1237
1219
 
1238
- if (CheckValueTag(instance, value, type->ref.marker)) {
1220
+ if (CheckValueTag(value, type->ref.marker)) {
1239
1221
  ptr = value.As<Napi::External<uint8_t>>().Data();
1240
1222
  } else if (IsObject(value) && (type->ref.type->primitive == PrimitiveKind::Record ||
1241
1223
  type->ref.type->primitive == PrimitiveKind::Union)) {
@@ -1306,7 +1288,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, bool switch_
1306
1288
  ptr = ReserveTrampoline(type->ref.proto, func2);
1307
1289
  if (!ptr) [[unlikely]]
1308
1290
  return;
1309
- } else if (CheckValueTag(instance, value, type->ref.marker)) {
1291
+ } else if (CheckValueTag(value, type->ref.marker)) {
1310
1292
  ptr = value.As<Napi::External<void>>().Data();
1311
1293
  } else if (IsNullOrUndefined(value)) {
1312
1294
  ptr = nullptr;
@@ -1,23 +1,5 @@
1
- # Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
2
- #
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
5
- # the Software without restriction, including without limitation the rights to use,
6
- # copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
- # Software, and to permit persons to whom the Software is furnished to do so,
8
- # subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
14
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15
- # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17
- # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
- # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
- # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
- # OTHER DEALINGS IN THE SOFTWARE.
1
+ # SPDX-License-Identifier: MIT
2
+ # SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
21
3
 
22
4
  #if defined(__APPLE__)
23
5
  #define SYMBOL(Symbol) _ ## Symbol
@@ -1,23 +1,5 @@
1
- ; Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
2
- ;
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
5
- ; the Software without restriction, including without limitation the rights to use,
6
- ; copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
- ; Software, and to permit persons to whom the Software is furnished to do so,
8
- ; subject to the following conditions:
9
- ;
10
- ; The above copyright notice and this permission notice shall be included in all
11
- ; copies or substantial portions of the Software.
12
- ;
13
- ; THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
14
- ; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15
- ; OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
- ; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17
- ; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
- ; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
- ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
- ; OTHER DEALINGS IN THE SOFTWARE.
1
+ ; SPDX-License-Identifier: MIT
2
+ ; SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
21
3
 
22
4
  AREA |.text|, CODE
23
5
 
@@ -1,23 +1,5 @@
1
- // Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
2
- //
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
5
- // the Software without restriction, including without limitation the rights to use,
6
- // copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
- // Software, and to permit persons to whom the Software is furnished to do so,
8
- // subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in all
11
- // copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
14
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15
- // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17
- // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
- // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
- // OTHER DEALINGS IN THE SOFTWARE.
1
+ // SPDX-License-Identifier: MIT
2
+ // SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
21
3
 
22
4
  // There's nothing to see here, this architecture uses the ABI code in abi_riscv64.cc!
23
5
  // This file only exists to avoid leaving abi_loong64_asm.S alone :)
@@ -1,23 +1,5 @@
1
- # Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
2
- #
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
5
- # the Software without restriction, including without limitation the rights to use,
6
- # copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
- # Software, and to permit persons to whom the Software is furnished to do so,
8
- # subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
14
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15
- # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17
- # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
- # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
- # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
- # OTHER DEALINGS IN THE SOFTWARE.
1
+ # SPDX-License-Identifier: MIT
2
+ # SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
21
3
 
22
4
  #define SYMBOL(Symbol) Symbol
23
5
 
@@ -1,27 +1,9 @@
1
- // Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
2
- //
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
5
- // the Software without restriction, including without limitation the rights to use,
6
- // copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
- // Software, and to permit persons to whom the Software is furnished to do so,
8
- // subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in all
11
- // copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
14
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15
- // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17
- // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
- // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
- // OTHER DEALINGS IN THE SOFTWARE.
1
+ // SPDX-License-Identifier: MIT
2
+ // SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
21
3
 
22
4
  #if __riscv_xlen == 64 || defined(__loongarch64)
23
5
 
24
- #include "src/core/base/base.hh"
6
+ #include "lib/native/base/base.hh"
25
7
  #include "ffi.hh"
26
8
  #include "call.hh"
27
9
  #include "util.hh"
@@ -472,7 +454,7 @@ Napi::Value CallData::Complete(const FunctionInfo *func)
472
454
  case PrimitiveKind::Callback: {
473
455
  if (result.ptr) {
474
456
  Napi::External<void> external = Napi::External<void>::New(env, result.ptr);
475
- SetValueTag(instance, external, func->ret.type->ref.marker);
457
+ SetValueTag(external, func->ret.type->ref.marker);
476
458
 
477
459
  return external;
478
460
  } else {
@@ -664,7 +646,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, bool switch_
664
646
 
665
647
  if (ptr2) {
666
648
  Napi::External<void> external = Napi::External<void>::New(env, ptr2);
667
- SetValueTag(instance, external, param.type->ref.marker);
649
+ SetValueTag(external, param.type->ref.marker);
668
650
 
669
651
  arguments.Append(external);
670
652
  } else {
@@ -824,7 +806,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, bool switch_
824
806
  case PrimitiveKind::Pointer: {
825
807
  uint8_t *ptr;
826
808
 
827
- if (CheckValueTag(instance, value, type->ref.marker)) {
809
+ if (CheckValueTag(value, type->ref.marker)) {
828
810
  ptr = value.As<Napi::External<uint8_t>>().Data();
829
811
  } else if (IsObject(value) && (type->ref.type->primitive == PrimitiveKind::Record ||
830
812
  type->ref.type->primitive == PrimitiveKind::Union)) {
@@ -909,7 +891,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, bool switch_
909
891
  ptr = ReserveTrampoline(type->ref.proto, func2);
910
892
  if (!ptr) [[unlikely]]
911
893
  return;
912
- } else if (CheckValueTag(instance, value, type->ref.marker)) {
894
+ } else if (CheckValueTag(value, type->ref.marker)) {
913
895
  ptr = value.As<Napi::External<void>>().Data();
914
896
  } else if (IsNullOrUndefined(value)) {
915
897
  ptr = nullptr;
@@ -1,23 +1,5 @@
1
- # Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
2
- #
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
5
- # the Software without restriction, including without limitation the rights to use,
6
- # copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
- # Software, and to permit persons to whom the Software is furnished to do so,
8
- # subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
14
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15
- # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17
- # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
- # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
- # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
- # OTHER DEALINGS IN THE SOFTWARE.
1
+ # SPDX-License-Identifier: MIT
2
+ # SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
21
3
 
22
4
  #define SYMBOL(Symbol) Symbol
23
5
 
@@ -1,27 +1,9 @@
1
- // Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
2
- //
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
5
- // the Software without restriction, including without limitation the rights to use,
6
- // copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
- // Software, and to permit persons to whom the Software is furnished to do so,
8
- // subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in all
11
- // copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
14
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15
- // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17
- // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
- // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
- // OTHER DEALINGS IN THE SOFTWARE.
1
+ // SPDX-License-Identifier: MIT
2
+ // SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
21
3
 
22
4
  #if defined(__x86_64__) && !defined(_WIN32)
23
5
 
24
- #include "src/core/base/base.hh"
6
+ #include "lib/native/base/base.hh"
25
7
  #include "ffi.hh"
26
8
  #include "call.hh"
27
9
  #include "util.hh"
@@ -513,7 +495,7 @@ Napi::Value CallData::Complete(const FunctionInfo *func)
513
495
  case PrimitiveKind::Callback: {
514
496
  if (result.ptr) {
515
497
  Napi::External<void> external = Napi::External<void>::New(env, result.ptr);
516
- SetValueTag(instance, external, func->ret.type->ref.marker);
498
+ SetValueTag(external, func->ret.type->ref.marker);
517
499
 
518
500
  return external;
519
501
  } else {
@@ -700,7 +682,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, bool switch_
700
682
 
701
683
  if (ptr2) {
702
684
  Napi::External<void> external = Napi::External<void>::New(env, ptr2);
703
- SetValueTag(instance, external, param.type->ref.marker);
685
+ SetValueTag(external, param.type->ref.marker);
704
686
 
705
687
  arguments.Append(external);
706
688
  } else {
@@ -849,7 +831,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, bool switch_
849
831
  case PrimitiveKind::Pointer: {
850
832
  uint8_t *ptr;
851
833
 
852
- if (CheckValueTag(instance, value, type->ref.marker)) {
834
+ if (CheckValueTag(value, type->ref.marker)) {
853
835
  ptr = value.As<Napi::External<uint8_t>>().Data();
854
836
  } else if (IsObject(value) && (type->ref.type->primitive == PrimitiveKind::Record ||
855
837
  type->ref.type->primitive == PrimitiveKind::Union)) {
@@ -933,7 +915,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, bool switch_
933
915
  ptr = ReserveTrampoline(type->ref.proto, func2);
934
916
  if (!ptr) [[unlikely]]
935
917
  return;
936
- } else if (CheckValueTag(instance, value, type->ref.marker)) {
918
+ } else if (CheckValueTag(value, type->ref.marker)) {
937
919
  ptr = value.As<Napi::External<void>>().Data();
938
920
  } else if (IsNullOrUndefined(value)) {
939
921
  ptr = nullptr;
@@ -1,23 +1,5 @@
1
- # Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
2
- #
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
5
- # the Software without restriction, including without limitation the rights to use,
6
- # copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
- # Software, and to permit persons to whom the Software is furnished to do so,
8
- # subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
14
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15
- # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17
- # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
- # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
- # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
- # OTHER DEALINGS IN THE SOFTWARE.
1
+ # SPDX-License-Identifier: MIT
2
+ # SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
21
3
 
22
4
  #if defined(__APPLE__)
23
5
  #define SYMBOL(Symbol) _ ## Symbol
@@ -1,27 +1,9 @@
1
- // Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
2
- //
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
5
- // the Software without restriction, including without limitation the rights to use,
6
- // copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
- // Software, and to permit persons to whom the Software is furnished to do so,
8
- // subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in all
11
- // copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
14
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15
- // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17
- // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
- // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
- // OTHER DEALINGS IN THE SOFTWARE.
1
+ // SPDX-License-Identifier: MIT
2
+ // SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
21
3
 
22
4
  #if defined(_WIN32) && (defined(__x86_64__) || defined(_M_AMD64))
23
5
 
24
- #include "src/core/base/base.hh"
6
+ #include "lib/native/base/base.hh"
25
7
  #include "ffi.hh"
26
8
  #include "call.hh"
27
9
  #include "util.hh"
@@ -224,11 +206,11 @@ void CallData::Execute(const FunctionInfo *func, void *native)
224
206
 
225
207
  // Restore previous stack limits at the end
226
208
  K_DEFER_C(exception_list = teb->ExceptionList,
227
- base = teb->StackBase,
228
- limit = teb->StackLimit,
229
- dealloc = teb->DeallocationStack,
230
- guaranteed = teb->GuaranteedStackBytes,
231
- stfs = teb->SameTebFlags) {
209
+ base = teb->StackBase,
210
+ limit = teb->StackLimit,
211
+ dealloc = teb->DeallocationStack,
212
+ guaranteed = teb->GuaranteedStackBytes,
213
+ stfs = teb->SameTebFlags) {
232
214
  teb->ExceptionList = exception_list;
233
215
  teb->StackBase = base;
234
216
  teb->StackLimit = limit;
@@ -324,7 +306,7 @@ Napi::Value CallData::Complete(const FunctionInfo *func)
324
306
  case PrimitiveKind::Callback: {
325
307
  if (result.ptr) {
326
308
  Napi::External<void> external = Napi::External<void>::New(env, result.ptr);
327
- SetValueTag(instance, external, func->ret.type->ref.marker);
309
+ SetValueTag(external, func->ret.type->ref.marker);
328
310
 
329
311
  return external;
330
312
  } else {
@@ -545,7 +527,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, bool switch_
545
527
 
546
528
  if (ptr2) {
547
529
  Napi::External<void> external = Napi::External<void>::New(env, ptr2);
548
- SetValueTag(instance, external, param.type->ref.marker);
530
+ SetValueTag(external, param.type->ref.marker);
549
531
 
550
532
  arguments.Append(external);
551
533
  } else {
@@ -674,7 +656,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, bool switch_
674
656
  case PrimitiveKind::Pointer: {
675
657
  uint8_t *ptr;
676
658
 
677
- if (CheckValueTag(instance, value, type->ref.marker)) {
659
+ if (CheckValueTag(value, type->ref.marker)) {
678
660
  ptr = value.As<Napi::External<uint8_t>>().Data();
679
661
  } else if (IsObject(value) && (type->ref.type->primitive == PrimitiveKind::Record ||
680
662
  type->ref.type->primitive == PrimitiveKind::Union)) {
@@ -740,7 +722,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, bool switch_
740
722
  ptr = ReserveTrampoline(type->ref.proto, func2);
741
723
  if (!ptr) [[unlikely]]
742
724
  return;
743
- } else if (CheckValueTag(instance, value, type->ref.marker)) {
725
+ } else if (CheckValueTag(value, type->ref.marker)) {
744
726
  ptr = value.As<Napi::External<void>>().Data();
745
727
  } else if (IsNullOrUndefined(value)) {
746
728
  ptr = nullptr;
@@ -1,23 +1,5 @@
1
- ; Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
2
- ;
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
5
- ; the Software without restriction, including without limitation the rights to use,
6
- ; copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
- ; Software, and to permit persons to whom the Software is furnished to do so,
8
- ; subject to the following conditions:
9
- ;
10
- ; The above copyright notice and this permission notice shall be included in all
11
- ; copies or substantial portions of the Software.
12
- ;
13
- ; THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
14
- ; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15
- ; OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
- ; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17
- ; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
- ; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
- ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
- ; OTHER DEALINGS IN THE SOFTWARE.
1
+ ; SPDX-License-Identifier: MIT
2
+ ; SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
21
3
 
22
4
  ; Forward
23
5
  ; ----------------------------
@@ -1,27 +1,9 @@
1
- // Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
2
- //
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
5
- // the Software without restriction, including without limitation the rights to use,
6
- // copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
- // Software, and to permit persons to whom the Software is furnished to do so,
8
- // subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in all
11
- // copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
14
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15
- // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17
- // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
- // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
- // OTHER DEALINGS IN THE SOFTWARE.
1
+ // SPDX-License-Identifier: MIT
2
+ // SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
21
3
 
22
4
  #if defined(__i386__) || defined(_M_IX86)
23
5
 
24
- #include "src/core/base/base.hh"
6
+ #include "lib/native/base/base.hh"
25
7
  #include "ffi.hh"
26
8
  #include "call.hh"
27
9
  #include "util.hh"
@@ -438,7 +420,7 @@ Napi::Value CallData::Complete(const FunctionInfo *func)
438
420
  case PrimitiveKind::Callback: {
439
421
  if (result.ptr) {
440
422
  Napi::External<void> external = Napi::External<void>::New(env, result.ptr);
441
- SetValueTag(instance, external, func->ret.type->ref.marker);
423
+ SetValueTag(external, func->ret.type->ref.marker);
442
424
 
443
425
  return external;
444
426
  } else {
@@ -660,7 +642,7 @@ void CallData::Relay(Size idx, uint8_t *, uint8_t *caller_sp, bool switch_stack,
660
642
 
661
643
  if (ptr2) {
662
644
  Napi::External<void> external = Napi::External<void>::New(env, ptr2);
663
- SetValueTag(instance, external, param.type->ref.marker);
645
+ SetValueTag(external, param.type->ref.marker);
664
646
 
665
647
  arguments.Append(external);
666
648
  } else {
@@ -810,7 +792,7 @@ void CallData::Relay(Size idx, uint8_t *, uint8_t *caller_sp, bool switch_stack,
810
792
  case PrimitiveKind::Pointer: {
811
793
  uint8_t *ptr;
812
794
 
813
- if (CheckValueTag(instance, value, type->ref.marker)) {
795
+ if (CheckValueTag(value, type->ref.marker)) {
814
796
  ptr = value.As<Napi::External<uint8_t>>().Data();
815
797
  } else if (IsObject(value) && (type->ref.type->primitive == PrimitiveKind::Record ||
816
798
  type->ref.type->primitive == PrimitiveKind::Union)) {
@@ -874,7 +856,7 @@ void CallData::Relay(Size idx, uint8_t *, uint8_t *caller_sp, bool switch_stack,
874
856
  ptr = ReserveTrampoline(type->ref.proto, func2);
875
857
  if (!ptr) [[unlikely]]
876
858
  return;
877
- } else if (CheckValueTag(instance, value, type->ref.marker)) {
859
+ } else if (CheckValueTag(value, type->ref.marker)) {
878
860
  ptr = value.As<Napi::External<void>>().Data();
879
861
  } else if (IsNullOrUndefined(value)) {
880
862
  ptr = nullptr;
@@ -1,23 +1,5 @@
1
- # Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
2
- #
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
5
- # the Software without restriction, including without limitation the rights to use,
6
- # copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
- # Software, and to permit persons to whom the Software is furnished to do so,
8
- # subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
14
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15
- # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17
- # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
- # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
- # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
- # OTHER DEALINGS IN THE SOFTWARE.
1
+ # SPDX-License-Identifier: MIT
2
+ # SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
21
3
 
22
4
  #define SYMBOL(Symbol) Symbol
23
5
 
@@ -1,23 +1,5 @@
1
- ; Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
2
- ;
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
5
- ; the Software without restriction, including without limitation the rights to use,
6
- ; copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
- ; Software, and to permit persons to whom the Software is furnished to do so,
8
- ; subject to the following conditions:
9
- ;
10
- ; The above copyright notice and this permission notice shall be included in all
11
- ; copies or substantial portions of the Software.
12
- ;
13
- ; THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
14
- ; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15
- ; OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
- ; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17
- ; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
- ; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
- ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
- ; OTHER DEALINGS IN THE SOFTWARE.
1
+ ; SPDX-License-Identifier: MIT
2
+ ; SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
21
3
 
22
4
  ; Forward
23
5
  ; ----------------------------