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
@@ -0,0 +1,81 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
3
+
4
+ #pragma once
5
+
6
+ #include "lib/native/base/base.hh"
7
+ #include "lib/native/wrap/json.hh"
8
+
9
+ namespace K {
10
+
11
+ static const int MaxTowerSources = 10;
12
+
13
+ class TowerServer {
14
+ #if defined(_WIN32)
15
+ char name[512] = {};
16
+ LocalArray<struct OverlappedPipe *, MaxTowerSources> pipes;
17
+ #else
18
+ int fd = -1;
19
+ #endif
20
+
21
+ LocalArray<WaitSource, MaxTowerSources> sources;
22
+
23
+ std::function<bool(StreamReader *, StreamWriter *)> handle_func;
24
+
25
+ public:
26
+ TowerServer() {}
27
+ ~TowerServer() { Stop(); }
28
+
29
+ bool Bind(const char *path);
30
+ void Start(std::function<bool(StreamReader *, StreamWriter *)> func);
31
+ void Stop();
32
+
33
+ Span<const WaitSource> GetWaitSources() const { return sources; }
34
+ bool Process(uint64_t ready = UINT64_MAX);
35
+
36
+ void Send(FunctionRef<void(StreamWriter *)> func);
37
+ void Send(Span<const uint8_t> buf) { Send([&](StreamWriter *writer) { writer->Write(buf); }); }
38
+ void Send(Span<const char> buf) { Send([&](StreamWriter *writer) { writer->Write(buf); }); }
39
+
40
+ private:
41
+ #if defined(_WIN32)
42
+ void RunClients(FunctionRef<bool(Size, struct OverlappedPipe *)> func);
43
+ #else
44
+ void RunClients(FunctionRef<bool(Size, int)> func);
45
+ #endif
46
+ };
47
+
48
+ class TowerClient {
49
+ #if defined(_WIN32)
50
+ struct OverlappedPipe *pipe = nullptr;
51
+ #else
52
+ int sock = -1;
53
+ #endif
54
+
55
+ std::function<void(StreamReader *)> handle_func;
56
+
57
+ WaitSource src = {};
58
+
59
+ public:
60
+ ~TowerClient() { Stop(); }
61
+
62
+ bool Connect(const char *path);
63
+ void Start(std::function<void(StreamReader *)> func);
64
+ void Stop();
65
+
66
+ WaitSource GetWaitSource() const { return src; }
67
+ bool Process();
68
+
69
+ bool Send(FunctionRef<void(StreamWriter *)> func);
70
+ bool Send(Span<const uint8_t> buf) { return Send([&](StreamWriter *writer) { writer->Write(buf); }); }
71
+ bool Send(Span<const char> buf) { return Send([&](StreamWriter *writer) { writer->Write(buf); }); }
72
+ };
73
+
74
+ enum class ControlScope {
75
+ System,
76
+ User
77
+ };
78
+
79
+ const char *GetControlSocketPath(ControlScope scope, const char *name, Allocator *alloc);
80
+
81
+ }
@@ -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
  // This file is autogenerated by unicode_gen.py
23
5
  // Version: DerivedCoreProperties-16.0.0.txt -- Date: 2024-05-31, 18:09:32 GMT
@@ -1,25 +1,6 @@
1
1
  #!/usr/bin/env python3
2
-
3
- # Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
4
-
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- # this software and associated documentation files (the “Software”), to deal in
7
- # the Software without restriction, including without limitation the rights to use,
8
- # copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
9
- # Software, and to permit persons to whom the Software is furnished to do so,
10
- # subject to the following conditions:
11
-
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
-
15
- # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
16
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
- # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
- # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
- # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
- # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- # OTHER DEALINGS IN THE SOFTWARE.
2
+ # SPDX-License-Identifier: MIT
3
+ # SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
23
4
 
24
5
  import sys
25
6
  import re
@@ -30,26 +11,8 @@ from collections import namedtuple
30
11
 
31
12
  DEFAULT_URL = 'https://unicode.org/Public/16.0.0'
32
13
 
33
- LICENSE_HEADER = """// Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
34
-
35
- // Permission is hereby granted, free of charge, to any person obtaining a copy of
36
- // this software and associated documentation files (the “Software”), to deal in
37
- // the Software without restriction, including without limitation the rights to use,
38
- // copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
39
- // Software, and to permit persons to whom the Software is furnished to do so,
40
- // subject to the following conditions:
41
-
42
- // The above copyright notice and this permission notice shall be included in all
43
- // copies or substantial portions of the Software.
44
-
45
- // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
46
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
47
- // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
48
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
49
- // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
50
- // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
51
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
52
- // OTHER DEALINGS IN THE SOFTWARE."""
14
+ LICENSE_HEADER = """// SPDX-License-Identifier: MIT
15
+ // SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>"""
53
16
 
54
17
  WcWidthResult = namedtuple('WcWidthResult', ['null', 'wide'])
55
18
  XidResult = namedtuple('XidResult', ['id_start', 'id_continue'])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "2.14.1",
3
+ "version": "2.15.0",
4
4
  "description": "Fast and simple C FFI (foreign function interface) for Node.js",
5
5
  "keywords": [
6
6
  "foreign",
@@ -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(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" OR
23
5
  CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
@@ -58,6 +40,8 @@ endfunction()
58
40
 
59
41
  if(USE_UNITY_BUILDS)
60
42
  function(enable_unity_build TARGET)
43
+ cmake_parse_arguments(ARG "" "" "EXCLUDE" ${ARGN})
44
+
61
45
  get_target_property(sources ${TARGET} SOURCES)
62
46
  string(GENEX_STRIP "${sources}" sources)
63
47
 
@@ -69,6 +53,10 @@ if(USE_UNITY_BUILDS)
69
53
  set(cpp_definitions "")
70
54
 
71
55
  foreach(src ${sources})
56
+ if (src IN_LIST ARG_EXCLUDE)
57
+ continue()
58
+ endif()
59
+
72
60
  get_source_file_property(language ${src} LANGUAGE)
73
61
  get_property(definitions SOURCE ${src} PROPERTY COMPILE_DEFINITIONS)
74
62
  if(IS_ABSOLUTE ${src})
@@ -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
  #include <stdlib.h>
23
5
  #if !defined(NOMINMAX)
@@ -1,25 +1,6 @@
1
1
  #!/usr/bin/env node
2
-
3
- // Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
4
- //
5
- // Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- // this software and associated documentation files (the “Software”), to deal in
7
- // the Software without restriction, including without limitation the rights to use,
8
- // copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
9
- // Software, and to permit persons to whom the Software is furnished to do so,
10
- // subject to the following conditions:
11
- //
12
- // The above copyright notice and this permission notice shall be included in all
13
- // copies or substantial portions of the Software.
14
- //
15
- // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
16
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
- // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
- // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
- // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- // OTHER DEALINGS IN THE SOFTWARE.
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
23
4
 
24
5
  'use strict';
25
6
 
@@ -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
  'use strict';
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
  const builder = require('./builder.js');
23
5
  const tools = require('./tools.js');
@@ -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
  'use strict';
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
  cmake_minimum_required(VERSION 3.6)
23
5
  cmake_policy(SET CMP0091 NEW)
@@ -54,6 +36,8 @@ if(UNIX AND NOT APPLE)
54
36
  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack")
55
37
  endif()
56
38
 
39
+ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
40
+
57
41
  # ---- Koffi ----
58
42
 
59
43
  # Recompute the version string after each commit
@@ -75,8 +59,9 @@ set(KOFFI_SRC
75
59
  src/ffi.cc
76
60
  src/parser.cc
77
61
  src/util.cc
62
+ src/uv.cc
78
63
  src/win32.cc
79
- ../../src/core/base/base.cc
64
+ ../../lib/native/base/base.cc
80
65
  )
81
66
  if(CMAKE_SIZEOF_VOID_P EQUAL 8)
82
67
  # CMAKE_SYSTEM_PROCESSOR is wrong on Windows ARM64
@@ -134,6 +119,18 @@ endif()
134
119
  add_node_addon(NAME koffi SOURCES ${KOFFI_SRC})
135
120
  target_include_directories(koffi PRIVATE . ../.. ../../vendor/node-addon-api)
136
121
 
122
+ if(WIN32)
123
+ set(UV_LINK_LIB "${CMAKE_CURRENT_BINARY_DIR}/uv.lib")
124
+ add_custom_command(OUTPUT ${UV_LINK_LIB}
125
+ COMMAND ${CMAKE_AR} ${CMAKE_STATIC_LINKER_FLAGS}
126
+ /def:src/uv.def /out:${UV_LINK_LIB}
127
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
128
+ MAIN_DEPENDENCY src/uv.def)
129
+ add_custom_target(uv.lib DEPENDS ${UV_LINK_LIB})
130
+ add_dependencies(koffi uv.lib)
131
+ target_link_libraries(koffi PRIVATE ${UV_LINK_LIB})
132
+ endif()
133
+
137
134
  target_compile_definitions(koffi PRIVATE FELIX_TARGET=koffi NAPI_DISABLE_CPP_EXCEPTIONS NAPI_VERSION=8 CORE_NO_STATX)
138
135
  if(WIN32)
139
136
  target_compile_definitions(koffi PRIVATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
@@ -157,4 +154,4 @@ if(NOT MSVC OR CMAKE_C_COMPILER_ID MATCHES "[Cc]lang")
157
154
  endif()
158
155
  endif()
159
156
 
160
- enable_unity_build(koffi)
157
+ enable_unity_build(koffi EXCLUDE src/uv.cc)
@@ -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
  add_library(raylib SHARED
23
5
  ../../../vendor/raylib/src/rcore.c
@@ -46,7 +28,7 @@ else()
46
28
  endif()
47
29
 
48
30
  if(WIN32)
49
- target_compile_definitions(raylib PRIVATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
31
+ target_compile_definitions(raylib PRIVATE _GLFW_WIN32 _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
50
32
  target_link_libraries(raylib PRIVATE winmm)
51
33
  endif()
52
34
 
@@ -60,7 +42,7 @@ endif()
60
42
 
61
43
  if(APPLE)
62
44
  target_compile_options(raylib PRIVATE -Wno-unknown-warning-option -Wno-macro-redefined)
63
- target_compile_definitions(raylib PRIVATE GL_SILENCE_DEPRECATION)
45
+ target_compile_definitions(raylib PRIVATE _GLFW_COCOA GL_SILENCE_DEPRECATION)
64
46
  set_source_files_properties(../../../vendor/raylib/src/rglfw.c PROPERTIES COMPILE_FLAGS "-x objective-c")
65
47
  target_link_libraries(raylib PRIVATE "-framework Cocoa" "-framework IOKit" "-framework CoreFoundation" "-framework OpenGL")
66
48
  endif()
@@ -98,5 +80,6 @@ if(UNIX AND NOT APPLE)
98
80
  message(FATAL_ERROR "Missing X11 development files: ${missing_xlib_str}")
99
81
  endif()
100
82
 
83
+ target_compile_definitions(raylib PRIVATE _GLFW_X11)
101
84
  target_include_directories(raylib PRIVATE ${XLIB_INCLUDE_DIRS})
102
85
  endif()
@@ -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
  add_library(sqlite3 SHARED ../../../vendor/sqlite3mc/sqlite3.c)
23
5
  set_target_properties(sqlite3 PROPERTIES PREFIX "")
@@ -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(__arm__) || (defined(__M_ARM) && !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"
@@ -536,7 +518,7 @@ Napi::Value CallData::Complete(const FunctionInfo *func)
536
518
  case PrimitiveKind::Callback: {
537
519
  if (result.ptr) {
538
520
  Napi::External<void> external = Napi::External<void>::New(env, result.ptr);
539
- SetValueTag(instance, external, func->ret.type->ref.marker);
521
+ SetValueTag(external, func->ret.type->ref.marker);
540
522
 
541
523
  return external;
542
524
  } else {
@@ -735,7 +717,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, bool switch_
735
717
 
736
718
  if (ptr2) {
737
719
  Napi::External<void> external = Napi::External<void>::New(env, ptr2);
738
- SetValueTag(instance, external, param.type->ref.marker);
720
+ SetValueTag(external, param.type->ref.marker);
739
721
 
740
722
  arguments.Append(external);
741
723
  } else {
@@ -936,7 +918,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, bool switch_
936
918
  case PrimitiveKind::Pointer: {
937
919
  uint8_t *ptr;
938
920
 
939
- if (CheckValueTag(instance, value, type->ref.marker)) {
921
+ if (CheckValueTag(value, type->ref.marker)) {
940
922
  ptr = value.As<Napi::External<uint8_t>>().Data();
941
923
  } else if (IsObject(value) && (type->ref.type->primitive == PrimitiveKind::Record ||
942
924
  type->ref.type->primitive == PrimitiveKind::Union)) {
@@ -1010,7 +992,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, bool switch_
1010
992
  ptr = ReserveTrampoline(type->ref.proto, func2);
1011
993
  if (!ptr) [[unlikely]]
1012
994
  return;
1013
- } else if (CheckValueTag(instance, value, type->ref.marker)) {
995
+ } else if (CheckValueTag(value, type->ref.marker)) {
1014
996
  ptr = value.As<Napi::External<void>>().Data();
1015
997
  } else if (IsNullOrUndefined(value)) {
1016
998
  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
  .syntax unified
23
5