koffi 2.12.1 → 2.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE.txt +2 -2
  3. package/README.md +8 -8
  4. package/build/koffi/darwin_arm64/koffi.node +0 -0
  5. package/build/koffi/darwin_x64/koffi.node +0 -0
  6. package/build/koffi/freebsd_arm64/koffi.node +0 -0
  7. package/build/koffi/freebsd_ia32/koffi.node +0 -0
  8. package/build/koffi/freebsd_x64/koffi.node +0 -0
  9. package/build/koffi/linux_arm64/koffi.node +0 -0
  10. package/build/koffi/linux_armhf/koffi.node +0 -0
  11. package/build/koffi/linux_ia32/koffi.node +0 -0
  12. package/build/koffi/linux_loong64/koffi.node +0 -0
  13. package/build/koffi/linux_riscv64d/koffi.node +0 -0
  14. package/build/koffi/linux_x64/koffi.node +0 -0
  15. package/build/koffi/musl_arm64/koffi.node +0 -0
  16. package/build/koffi/musl_x64/koffi.node +0 -0
  17. package/build/koffi/openbsd_ia32/koffi.node +0 -0
  18. package/build/koffi/openbsd_x64/koffi.node +0 -0
  19. package/build/koffi/win32_arm64/koffi.exp +0 -0
  20. package/build/koffi/win32_arm64/koffi.node +0 -0
  21. package/build/koffi/win32_ia32/koffi.exp +0 -0
  22. package/build/koffi/win32_ia32/koffi.node +0 -0
  23. package/build/koffi/win32_x64/koffi.exp +0 -0
  24. package/build/koffi/win32_x64/koffi.node +0 -0
  25. package/doc/assets.ini +3 -3
  26. package/doc/develop.sh +4 -3
  27. package/doc/pages/platforms.md +1 -1
  28. package/doc/static/highlight.js +1 -1
  29. package/doc/static/koffi.css +3 -2
  30. package/doc/static/print.css +1 -1
  31. package/doc/templates/code.html +5 -5
  32. package/doc/templates/page.html +4 -4
  33. package/index.d.ts +228 -145
  34. package/index.js +25 -25
  35. package/indirect.js +25 -5
  36. package/package.json +2 -2
  37. package/src/cnoke/LICENSE.txt +2 -2
  38. package/src/cnoke/README.md +2 -0
  39. package/src/cnoke/assets/FindCNoke.cmake +12 -2
  40. package/src/cnoke/assets/win_delay_hook.c +4 -4
  41. package/src/cnoke/cnoke.js +4 -2
  42. package/src/cnoke/package.json +1 -1
  43. package/src/cnoke/src/builder.js +11 -14
  44. package/src/cnoke/src/index.js +2 -2
  45. package/src/cnoke/src/tools.js +34 -2
  46. package/src/core/{libcc/libcc.cc → base/base.cc} +3174 -1640
  47. package/src/core/{libcc/libcc.hh → base/base.hh} +3066 -2427
  48. package/src/core/{libcc → base}/mimetypes.inc +42 -4
  49. package/src/core/{libcc → base}/mimetypes_gen.py +3 -3
  50. package/src/core/base/unicode.inc +426 -0
  51. package/src/core/base/unicode_gen.py +189 -0
  52. package/src/koffi/CMakeLists.txt +7 -5
  53. package/src/koffi/cmake/raylib.cmake +6 -2
  54. package/src/koffi/cmake/{sqlite.cmake → sqlite3.cmake} +3 -3
  55. package/src/koffi/examples/electron-forge/forge.config.js +23 -3
  56. package/src/koffi/examples/electron-forge/package.json +18 -16
  57. package/src/koffi/src/abi_arm32.cc +7 -7
  58. package/src/koffi/src/abi_arm32_asm.S +2 -2
  59. package/src/koffi/src/abi_arm64.cc +45 -45
  60. package/src/koffi/src/abi_arm64_asm.S +4 -4
  61. package/src/koffi/src/abi_arm64_asm.asm +2 -2
  62. package/src/koffi/src/abi_loong64_asm.S +2 -2
  63. package/src/koffi/src/abi_riscv64.cc +5 -5
  64. package/src/koffi/src/abi_riscv64_asm.S +2 -2
  65. package/src/koffi/src/abi_x64_sysv.cc +3 -3
  66. package/src/koffi/src/abi_x64_sysv_asm.S +5 -5
  67. package/src/koffi/src/abi_x64_win.cc +3 -3
  68. package/src/koffi/src/abi_x64_win_asm.asm +2 -2
  69. package/src/koffi/src/abi_x86.cc +8 -8
  70. package/src/koffi/src/abi_x86_asm.S +2 -2
  71. package/src/koffi/src/abi_x86_asm.asm +2 -2
  72. package/src/koffi/src/call.cc +12 -12
  73. package/src/koffi/src/call.hh +8 -8
  74. package/src/koffi/src/errno.inc +152 -152
  75. package/src/koffi/src/ffi.cc +44 -39
  76. package/src/koffi/src/ffi.hh +6 -6
  77. package/src/koffi/src/init.js +1 -1
  78. package/src/koffi/src/parser.cc +5 -5
  79. package/src/koffi/src/parser.hh +3 -3
  80. package/src/koffi/src/trampolines/armasm.inc +2 -2
  81. package/src/koffi/src/trampolines/gnu.inc +2 -2
  82. package/src/koffi/src/trampolines/masm32.inc +2 -2
  83. package/src/koffi/src/trampolines/masm64.inc +2 -2
  84. package/src/koffi/src/trampolines/prototypes.inc +2 -2
  85. package/src/koffi/src/util.cc +9 -9
  86. package/src/koffi/src/util.hh +3 -3
  87. package/src/koffi/src/win32.cc +5 -5
  88. package/src/koffi/src/win32.hh +9 -9
  89. package/vendor/node-addon-api/CHANGELOG.md +97 -2
  90. package/vendor/node-addon-api/CONTRIBUTING.md +117 -7
  91. package/vendor/node-addon-api/README.md +25 -249
  92. package/vendor/node-addon-api/common.gypi +1 -0
  93. package/vendor/node-addon-api/doc/README.md +145 -0
  94. package/vendor/node-addon-api/doc/array_buffer.md +15 -15
  95. package/vendor/node-addon-api/doc/basic_env.md +200 -0
  96. package/vendor/node-addon-api/doc/buffer.md +24 -26
  97. package/vendor/node-addon-api/doc/cmake-js.md +19 -0
  98. package/vendor/node-addon-api/doc/{creating_a_release.md → contributing/creating_a_release.md} +16 -4
  99. package/vendor/node-addon-api/doc/env.md +11 -131
  100. package/vendor/node-addon-api/doc/error_handling.md +12 -0
  101. package/vendor/node-addon-api/doc/external.md +13 -4
  102. package/vendor/node-addon-api/doc/finalization.md +153 -0
  103. package/vendor/node-addon-api/doc/memory_management.md +1 -1
  104. package/vendor/node-addon-api/doc/object_wrap.md +19 -3
  105. package/vendor/node-addon-api/doc/promises.md +51 -0
  106. package/vendor/node-addon-api/doc/setup.md +29 -6
  107. package/vendor/node-addon-api/doc/value.md +13 -0
  108. package/vendor/node-addon-api/doc/version_management.md +2 -2
  109. package/vendor/node-addon-api/eslint.config.js +5 -0
  110. package/vendor/node-addon-api/index.js +2 -0
  111. package/vendor/node-addon-api/napi-inl.h +592 -166
  112. package/vendor/node-addon-api/napi.h +167 -59
  113. package/vendor/node-addon-api/node_addon_api.gyp +10 -0
  114. package/vendor/node-addon-api/noexcept.gypi +1 -1
  115. package/vendor/node-addon-api/package.json +10 -13
  116. package/vendor/node-addon-api/release-please-config.json +15 -0
  117. package/vendor/node-addon-api/test/addon_build/tpl/binding.gyp +2 -1
  118. package/vendor/node-addon-api/test/array_buffer.js +1 -1
  119. package/vendor/node-addon-api/test/async_context.js +2 -2
  120. package/vendor/node-addon-api/test/async_progress_queue_worker.js +3 -3
  121. package/vendor/node-addon-api/test/async_progress_worker.js +3 -3
  122. package/vendor/node-addon-api/test/async_worker.cc +15 -13
  123. package/vendor/node-addon-api/test/async_worker.js +5 -5
  124. package/vendor/node-addon-api/test/basic_types/value.cc +6 -0
  125. package/vendor/node-addon-api/test/basic_types/value.js +17 -0
  126. package/vendor/node-addon-api/test/binding.cc +8 -0
  127. package/vendor/node-addon-api/test/binding.gyp +23 -1
  128. package/vendor/node-addon-api/test/buffer.js +1 -2
  129. package/vendor/node-addon-api/test/common/index.js +1 -1
  130. package/vendor/node-addon-api/test/except_all.cc +22 -0
  131. package/vendor/node-addon-api/test/except_all.js +14 -0
  132. package/vendor/node-addon-api/test/exports.js +19 -0
  133. package/vendor/node-addon-api/test/finalizer_order.cc +152 -0
  134. package/vendor/node-addon-api/test/finalizer_order.js +98 -0
  135. package/vendor/node-addon-api/test/function.js +2 -2
  136. package/vendor/node-addon-api/test/function_reference.js +2 -2
  137. package/vendor/node-addon-api/test/globalObject/global_object_delete_property.cc +4 -4
  138. package/vendor/node-addon-api/test/globalObject/global_object_get_property.cc +4 -4
  139. package/vendor/node-addon-api/test/globalObject/global_object_has_own_property.cc +3 -3
  140. package/vendor/node-addon-api/test/globalObject/global_object_set_property.cc +5 -5
  141. package/vendor/node-addon-api/test/name.cc +10 -8
  142. package/vendor/node-addon-api/test/object/delete_property.cc +5 -5
  143. package/vendor/node-addon-api/test/object/get_property.cc +5 -5
  144. package/vendor/node-addon-api/test/object/has_own_property.cc +4 -4
  145. package/vendor/node-addon-api/test/object/has_property.cc +5 -5
  146. package/vendor/node-addon-api/test/object/object.cc +1 -1
  147. package/vendor/node-addon-api/test/object/set_property.cc +5 -5
  148. package/vendor/node-addon-api/test/object/subscript_operator.cc +3 -3
  149. package/vendor/node-addon-api/test/object_reference.cc +18 -18
  150. package/vendor/node-addon-api/test/promise.cc +75 -0
  151. package/vendor/node-addon-api/test/promise.js +23 -0
  152. package/vendor/node-addon-api/test/require_basic_finalizers/index.js +38 -0
  153. package/vendor/node-addon-api/test/require_basic_finalizers/tpl/addon.cc +12 -0
  154. package/vendor/node-addon-api/test/require_basic_finalizers/tpl/binding.gyp +48 -0
  155. package/vendor/node-addon-api/test/require_basic_finalizers/tpl/index.js +3 -0
  156. package/vendor/node-addon-api/test/require_basic_finalizers/tpl/package.json +11 -0
  157. package/vendor/node-addon-api/test/run_script.cc +1 -1
  158. package/vendor/node-addon-api/test/type_taggable.cc +1 -1
  159. package/vendor/node-addon-api/test/type_taggable.js +3 -4
  160. package/vendor/node-addon-api/test/typedarray.cc +28 -24
  161. package/vendor/node-addon-api/tools/conversion.js +1 -1
  162. package/vendor/node-api-headers/CHANGELOG.md +29 -0
  163. package/vendor/node-api-headers/CREATING_A_RELEASE.md +12 -2
  164. package/vendor/node-api-headers/def/js_native_api.def +6 -1
  165. package/vendor/node-api-headers/def/node_api.def +7 -1
  166. package/vendor/node-api-headers/include/js_native_api.h +56 -24
  167. package/vendor/node-api-headers/include/js_native_api_types.h +27 -0
  168. package/vendor/node-api-headers/include/node_api.h +38 -29
  169. package/vendor/node-api-headers/lib/parse-utils.js +92 -0
  170. package/vendor/node-api-headers/package.json +7 -7
  171. package/vendor/node-api-headers/release-please-config.json +12 -0
  172. package/vendor/node-api-headers/scripts/update-headers.js +63 -12
  173. package/vendor/node-api-headers/scripts/write-symbols.js +1 -1
  174. package/vendor/node-api-headers/symbols.js +17 -1
  175. package/vendor/node-api-headers/test/parse-utils.js +21 -0
  176. package/doc/flat/flat.css +0 -27
  177. package/doc/flat/normal.css +0 -429
  178. package/doc/flat/print.css +0 -29
  179. package/doc/flat/reset.css +0 -41
  180. package/doc/flat/small.css +0 -104
  181. package/doc/flat/static.js +0 -161
  182. package/src/core/libcc/brotli.cc +0 -186
  183. package/src/core/libcc/lz4.cc +0 -197
  184. package/src/core/libcc/miniz.cc +0 -353
  185. package/vendor/node-addon-api/tools/eslint-format.js +0 -79
  186. /package/vendor/node-api-headers/{scripts → lib}/clang-utils.js +0 -0
package/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- // Copyright 2023 Niels Martignène <niels.martignene@protonmail.com>
1
+ // Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
2
2
  //
3
3
  // Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- // this software and associated documentation files (the “Software”), to deal in
4
+ // this software and associated documentation files (the “Software”), to deal in
5
5
  // the Software without restriction, including without limitation the rights to use,
6
6
  // copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
7
  // Software, and to permit persons to whom the Software is furnished to do so,
@@ -19,151 +19,234 @@
19
19
  // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
20
  // OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
- declare module 'koffi' {
23
- export function load(path: string | null): IKoffiLib;
24
-
25
- interface IKoffiCType { __brand: 'IKoffiCType' }
26
- interface IKoffiPointerCast { __brand: 'IKoffiPointerCast' }
27
- interface IKoffiRegisteredCallback { __brand: 'IKoffiRegisteredCallback' }
28
-
29
- type PrimitiveKind = 'Void' | 'Bool' | 'Int8' | 'UInt8' | 'Int16' | 'Int16S' | 'UInt16' | 'UInt16S' |
30
- 'Int32' | 'Int32S' | 'UInt32' | 'UInt32S' | 'Int64' | 'Int64S' | 'UInt64' | 'UInt64S' |
31
- 'String' | 'String16' | 'Pointer' | 'Record' | 'Union' | 'Array' | 'Float32' | 'Float64' |
32
- 'Prototype' | 'Callback';
33
- type ArrayHint = 'Array' | 'Typed' | 'String';
34
-
35
- type TypeSpec = string | IKoffiCType;
36
- type TypeSpecWithAlignment = TypeSpec | [number, TypeSpec];
37
- type TypeInfo = {
38
- name: string;
39
- primitive: PrimitiveKind;
40
- size: number;
41
- alignment: number;
42
- disposable: boolean;
43
- length?: number;
44
- hint?: ArrayHint;
45
- ref?: IKoffiCType;
46
- members?: Record<string, { name: string, type: IKoffiCType, offset: number }>;
47
- };
48
- type KoffiFunction = {
49
- (...args: any[]) : any;
50
- async: (...args: any[]) => any;
51
- info: {
52
- name: string,
53
- arguments: IKoffiCType[],
54
- result: IKoffiCType
55
- };
22
+ export function load(path: string | null): IKoffiLib;
23
+
24
+ interface IKoffiCType { __brand: 'IKoffiCType' }
25
+ interface IKoffiPointerCast { __brand: 'IKoffiPointerCast' }
26
+ interface IKoffiRegisteredCallback { __brand: 'IKoffiRegisteredCallback' }
27
+
28
+ type PrimitiveKind = 'Void' | 'Bool' | 'Int8' | 'UInt8' | 'Int16' | 'Int16S' | 'UInt16' | 'UInt16S' |
29
+ 'Int32' | 'Int32S' | 'UInt32' | 'UInt32S' | 'Int64' | 'Int64S' | 'UInt64' | 'UInt64S' |
30
+ 'String' | 'String16' | 'Pointer' | 'Record' | 'Union' | 'Array' | 'Float32' | 'Float64' |
31
+ 'Prototype' | 'Callback';
32
+ type ArrayHint = 'Array' | 'Typed' | 'String';
33
+
34
+ type TypeSpec = string | IKoffiCType;
35
+ type TypeSpecWithAlignment = TypeSpec | [number, TypeSpec];
36
+ type TypeInfo = {
37
+ name: string;
38
+ primitive: PrimitiveKind;
39
+ size: number;
40
+ alignment: number;
41
+ disposable: boolean;
42
+ length?: number;
43
+ hint?: ArrayHint;
44
+ ref?: IKoffiCType;
45
+ members?: Record<string, { name: string, type: IKoffiCType, offset: number }>;
46
+ };
47
+ type KoffiFunction = {
48
+ (...args: any[]) : any;
49
+ async: (...args: any[]) => any;
50
+ info: {
51
+ name: string,
52
+ arguments: IKoffiCType[],
53
+ result: IKoffiCType
56
54
  };
55
+ };
56
+
57
+ export type KoffiFunc<T extends (...args: any) => any> = T & {
58
+ async: (...args: [...Parameters<T>, (err: any, result: ReturnType<T>) => void]) => void;
59
+ info: {
60
+ name: string;
61
+ arguments: IKoffiCType[];
62
+ result: IKoffiCType;
63
+ };
64
+ };
65
+
66
+ export interface IKoffiLib {
67
+ func(definition: string): KoffiFunction;
68
+ func(name: string, result: TypeSpec, arguments: TypeSpec[]): KoffiFunction;
69
+ func(convention: string, name: string, result: TypeSpec, arguments: TypeSpec[]): KoffiFunction;
70
+
71
+ /** @deprecated */ cdecl(definition: string): KoffiFunction;
72
+ /** @deprecated */ cdecl(name: string, result: TypeSpec, arguments: TypeSpec[]): KoffiFunction;
73
+ /** @deprecated */ stdcall(definition: string): KoffiFunction;
74
+ /** @deprecated */ stdcall(name: string, result: TypeSpec, arguments: TypeSpec[]): KoffiFunction;
75
+ /** @deprecated */ fastcall(definition: string): KoffiFunction;
76
+ /** @deprecated */ fastcall(name: string, result: TypeSpec, arguments: TypeSpec[]): KoffiFunction;
77
+ /** @deprecated */ thiscall(definition: string): KoffiFunction;
78
+ /** @deprecated */ thiscall(name: string, result: TypeSpec, arguments: TypeSpec[]): KoffiFunction;
79
+
80
+ symbol(name: string, type: TypeSpec): any;
81
+
82
+ unload(): void;
83
+ }
57
84
 
58
- export type KoffiFunc<T extends (...args: any) => any> = T & {
59
- async: (...args: [...Parameters<T>, (err: any, result: ReturnType<T>) => void]) => void;
60
- info: {
61
- name: string;
62
- arguments: IKoffiCType[];
63
- result: IKoffiCType;
64
- };
65
- };
85
+ export function struct(name: string, def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
86
+ export function struct(ref: IKoffiCType, def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
87
+ export function struct(def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
88
+ export function pack(name: string, def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
89
+ export function pack(ref: IKoffiCType, def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
90
+ export function pack(def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
66
91
 
67
- export interface IKoffiLib {
68
- func(definition: string): KoffiFunction;
69
- func(name: string, result: TypeSpec, arguments: TypeSpec[]): KoffiFunction;
70
- func(convention: string, name: string, result: TypeSpec, arguments: TypeSpec[]): KoffiFunction;
71
-
72
- /** @deprecated */ cdecl(definition: string): KoffiFunction;
73
- /** @deprecated */ cdecl(name: string, result: TypeSpec, arguments: TypeSpec[]): KoffiFunction;
74
- /** @deprecated */ stdcall(definition: string): KoffiFunction;
75
- /** @deprecated */ stdcall(name: string, result: TypeSpec, arguments: TypeSpec[]): KoffiFunction;
76
- /** @deprecated */ fastcall(definition: string): KoffiFunction;
77
- /** @deprecated */ fastcall(name: string, result: TypeSpec, arguments: TypeSpec[]): KoffiFunction;
78
- /** @deprecated */ thiscall(definition: string): KoffiFunction;
79
- /** @deprecated */ thiscall(name: string, result: TypeSpec, arguments: TypeSpec[]): KoffiFunction;
80
-
81
- symbol(name: string, type: TypeSpec): any;
82
-
83
- unload(): void;
84
- }
85
-
86
- export function struct(name: string, def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
87
- export function struct(def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
88
- export function pack(name: string, def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
89
- export function pack(def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
90
-
91
- export function union(name: string, def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
92
- export function union(def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
93
-
94
- export class Union {
95
- constructor(type: TypeSpec);
96
- [s: string]: any;
97
- }
98
-
99
- export function array(ref: TypeSpec, len: number, hint?: ArrayHint | null): IKoffiCType;
100
-
101
- export function opaque(name: string): IKoffiCType;
102
- export function opaque(): IKoffiCType;
103
- /** @deprecated */ export function handle(name: string): IKoffiCType;
104
- /** @deprecated */ export function handle(): IKoffiCType;
105
-
106
- export function pointer(ref: TypeSpec): IKoffiCType;
107
- export function pointer(ref: TypeSpec, asteriskCount?: number): IKoffiCType;
108
- export function pointer(name: string, ref: TypeSpec, asteriskCount?: number): IKoffiCType;
109
-
110
- export function out(type: TypeSpec): IKoffiCType;
111
- export function inout(type: TypeSpec): IKoffiCType;
112
-
113
- export function disposable(type: TypeSpec): IKoffiCType;
114
- export function disposable(name: string, type: TypeSpec): IKoffiCType;
115
- export function disposable(name: string, type: TypeSpec, freeFunction: Function): IKoffiCType;
116
-
117
- export function proto(definition: string): IKoffiCType;
118
- export function proto(name: string, result: TypeSpec, arguments: TypeSpec[]): IKoffiCType;
119
- export function proto(convention: string, name: string, result: TypeSpec, arguments: TypeSpec[]): IKoffiCType;
120
- /** @deprecated */ export function callback(definition: string): IKoffiCType;
121
- /** @deprecated */ export function callback(name: string, result: TypeSpec, arguments: TypeSpec[]): IKoffiCType;
122
- /** @deprecated */ export function callback(convention: string, name: string, result: TypeSpec, arguments: TypeSpec[]): IKoffiCType;
123
-
124
- export function register(callback: Function, type: TypeSpec): IKoffiRegisteredCallback;
125
- export function register(thisValue: any, callback: Function, type: TypeSpec): IKoffiRegisteredCallback;
126
- export function unregister(callback: IKoffiRegisteredCallback): void;
127
-
128
- export function as(value: any, type: TypeSpec): IKoffiPointerCast;
129
- export function decode(value: any, type: TypeSpec): any;
130
- export function decode(value: any, type: TypeSpec, len: number): any;
131
- export function decode(value: any, offset: number, type: TypeSpec): any;
132
- export function decode(value: any, offset: number, type: TypeSpec, len: number): any;
133
- export function address(value: any): bigint;
134
- export function call(value: any, type: TypeSpec, ...args: any[]): any;
135
- export function encode(ref: any, type: TypeSpec, value: any): void;
136
- export function encode(ref: any, type: TypeSpec, value: any, len: number): void;
137
- export function encode(ref: any, offset: number, type: TypeSpec): void;
138
- export function encode(ref: any, offset: number, type: TypeSpec, value: any): void;
139
- export function encode(ref: any, offset: number, type: TypeSpec, value: any, len: number): void;
140
-
141
- export function sizeof(type: TypeSpec): number;
142
- export function alignof(type: TypeSpec): number;
143
- export function offsetof(type: TypeSpec): number;
144
- export function resolve(type: TypeSpec): IKoffiCType;
145
- export function introspect(type: TypeSpec): TypeInfo;
146
-
147
- export function alias(name: string, type: TypeSpec): IKoffiCType;
148
-
149
- export function config(): Record<string, unknown>;
150
- export function config(cfg: Record<string, unknown>): Record<string, unknown>;
151
- export function stats(): Record<string, unknown>;
152
-
153
- export function alloc(type: TypeSpec, length: number): any;
154
- export function free(value: any): void;
155
-
156
- export function errno(): number;
157
- export function errno(value: number): number;
158
-
159
- export function reset(): void;
160
-
161
- export const internal: Boolean;
162
- export const extension: String;
163
-
164
- export const os: {
165
- errno: Record<string, number>
166
- };
92
+ export function union(name: string, def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
93
+ export function union(ref: IKoffiCType, def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
94
+ export function union(def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
167
95
 
168
- export const types: Record<string, IKoffiCType>;
96
+ export class Union {
97
+ constructor(type: TypeSpec);
98
+ [s: string]: any;
169
99
  }
100
+
101
+ export function array(ref: TypeSpec, len: number, hint?: ArrayHint | null): IKoffiCType;
102
+
103
+ export function opaque(name: string): IKoffiCType;
104
+ export function opaque(): IKoffiCType;
105
+ /** @deprecated */ export function handle(name: string): IKoffiCType;
106
+ /** @deprecated */ export function handle(): IKoffiCType;
107
+
108
+ export function pointer(ref: TypeSpec): IKoffiCType;
109
+ export function pointer(ref: TypeSpec, asteriskCount?: number): IKoffiCType;
110
+ export function pointer(name: string, ref: TypeSpec, asteriskCount?: number): IKoffiCType;
111
+
112
+ export function out(type: TypeSpec): IKoffiCType;
113
+ export function inout(type: TypeSpec): IKoffiCType;
114
+
115
+ export function disposable(type: TypeSpec): IKoffiCType;
116
+ export function disposable(name: string, type: TypeSpec): IKoffiCType;
117
+ export function disposable(name: string, type: TypeSpec, freeFunction: Function): IKoffiCType;
118
+
119
+ export function proto(definition: string): IKoffiCType;
120
+ export function proto(name: string, result: TypeSpec, arguments: TypeSpec[]): IKoffiCType;
121
+ export function proto(convention: string, name: string, result: TypeSpec, arguments: TypeSpec[]): IKoffiCType;
122
+ /** @deprecated */ export function callback(definition: string): IKoffiCType;
123
+ /** @deprecated */ export function callback(name: string, result: TypeSpec, arguments: TypeSpec[]): IKoffiCType;
124
+ /** @deprecated */ export function callback(convention: string, name: string, result: TypeSpec, arguments: TypeSpec[]): IKoffiCType;
125
+
126
+ export function register(callback: Function, type: TypeSpec): IKoffiRegisteredCallback;
127
+ export function register(thisValue: any, callback: Function, type: TypeSpec): IKoffiRegisteredCallback;
128
+ export function unregister(callback: IKoffiRegisteredCallback): void;
129
+
130
+ export function as(value: any, type: TypeSpec): IKoffiPointerCast;
131
+ export function decode(value: any, type: TypeSpec): any;
132
+ export function decode(value: any, type: TypeSpec, len: number): any;
133
+ export function decode(value: any, offset: number, type: TypeSpec): any;
134
+ export function decode(value: any, offset: number, type: TypeSpec, len: number): any;
135
+ export function address(value: any): bigint;
136
+ export function call(value: any, type: TypeSpec, ...args: any[]): any;
137
+ export function encode(ref: any, type: TypeSpec, value: any): void;
138
+ export function encode(ref: any, type: TypeSpec, value: any, len: number): void;
139
+ export function encode(ref: any, offset: number, type: TypeSpec): void;
140
+ export function encode(ref: any, offset: number, type: TypeSpec, value: any): void;
141
+ export function encode(ref: any, offset: number, type: TypeSpec, value: any, len: number): void;
142
+ export function view(ref: any, len: number): ArrayBuffer;
143
+
144
+ export function sizeof(type: TypeSpec): number;
145
+ export function alignof(type: TypeSpec): number;
146
+ export function offsetof(type: TypeSpec, member_name: string): number;
147
+ export function resolve(type: TypeSpec): IKoffiCType;
148
+ export function introspect(type: TypeSpec): TypeInfo;
149
+
150
+ export function alias(name: string, type: TypeSpec): IKoffiCType;
151
+
152
+ export function config(): Record<string, unknown>;
153
+ export function config(cfg: Record<string, unknown>): Record<string, unknown>;
154
+ export function stats(): Record<string, unknown>;
155
+
156
+ export function alloc(type: TypeSpec, length: number): any;
157
+ export function free(value: any): void;
158
+
159
+ export function errno(): number;
160
+ export function errno(value: number): number;
161
+
162
+ export function reset(): void;
163
+
164
+ export const internal: Boolean;
165
+ export const extension: String;
166
+
167
+ export const os: {
168
+ errno: Record<string, number>
169
+ };
170
+
171
+ // https://koffi.dev/input#standard-types
172
+ type PrimitiveTypes =
173
+ | 'bool'
174
+ | 'char'
175
+ | 'char16_t'
176
+ | 'char16'
177
+ | 'char32_t'
178
+ | 'char32'
179
+ | 'double'
180
+ | 'float'
181
+ | 'float32'
182
+ | 'float64'
183
+ | 'int'
184
+ | 'int8_t'
185
+ | 'int8'
186
+ | 'int16_be_t'
187
+ | 'int16_be'
188
+ | 'int16_le_t'
189
+ | 'int16_le'
190
+ | 'int16_t'
191
+ | 'int16'
192
+ | 'int32_be_t'
193
+ | 'int32_be'
194
+ | 'int32_le_t'
195
+ | 'int32_le'
196
+ | 'int32_t'
197
+ | 'int32'
198
+ | 'int64_be_t'
199
+ | 'int64_be'
200
+ | 'int64_le_t'
201
+ | 'int64_le'
202
+ | 'int64_t'
203
+ | 'int64'
204
+ | 'intptr_t'
205
+ | 'intptr'
206
+ | 'long long'
207
+ | 'long'
208
+ | 'longlong'
209
+ | 'short'
210
+ | 'size_t'
211
+ | 'str'
212
+ | 'str16'
213
+ | 'str32'
214
+ | 'string'
215
+ | 'string16'
216
+ | 'string32'
217
+ | 'uchar'
218
+ | 'uint'
219
+ | 'uint8_t'
220
+ | 'uint8'
221
+ | 'uint16_be_t'
222
+ | 'uint16_be'
223
+ | 'uint16_le_t'
224
+ | 'uint16_le'
225
+ | 'uint16_t'
226
+ | 'uint16'
227
+ | 'uint32_be_t'
228
+ | 'uint32_be'
229
+ | 'uint32_le_t'
230
+ | 'uint32_le'
231
+ | 'uint32_t'
232
+ | 'uint32'
233
+ | 'uint64_be_t'
234
+ | 'uint64_be'
235
+ | 'uint64_le_t'
236
+ | 'uint64_le'
237
+ | 'uint64_t'
238
+ | 'uint64'
239
+ | 'uintptr_t'
240
+ | 'uintptr'
241
+ | 'ulong'
242
+ | 'ulonglong'
243
+ | 'unsigned char'
244
+ | 'unsigned int'
245
+ | 'unsigned long long'
246
+ | 'unsigned long'
247
+ | 'unsigned short'
248
+ | 'ushort'
249
+ | 'void'
250
+ | 'wchar'
251
+ | 'wchar_t'
252
+ export const types: Record<PrimitiveTypes, IKoffiCType>
package/index.js CHANGED
@@ -178,6 +178,28 @@ var require_tools = __commonJS({
178
178
  return true;
179
179
  return false;
180
180
  }
181
+ function sync_files(src_dir, dest_dir) {
182
+ let keep = /* @__PURE__ */ new Set();
183
+ {
184
+ let entries = fs2.readdirSync(src_dir, { withFileTypes: true });
185
+ for (let entry of entries) {
186
+ if (!entry.isFile())
187
+ continue;
188
+ keep.add(entry.name);
189
+ fs2.copyFileSync(src_dir + `/${entry.name}`, dest_dir + `/${entry.name}`);
190
+ }
191
+ }
192
+ {
193
+ let entries = fs2.readdirSync(dest_dir, { withFileTypes: true });
194
+ for (let entry of entries) {
195
+ if (!entry.isFile())
196
+ continue;
197
+ if (keep.has(entry.name))
198
+ continue;
199
+ fs2.unlinkSync(dest_dir + `/${entry.name}`);
200
+ }
201
+ }
202
+ }
181
203
  function determine_arch2() {
182
204
  let arch = process.arch;
183
205
  if (arch == "riscv32" || arch == "riscv64") {
@@ -366,6 +388,7 @@ var require_tools = __commonJS({
366
388
  extract_targz,
367
389
  path_is_absolute,
368
390
  path_has_dotdot,
391
+ sync_files,
369
392
  determine_arch: determine_arch2,
370
393
  unlink_recursive,
371
394
  get_napi_version: get_napi_version2,
@@ -379,8 +402,8 @@ var require_package = __commonJS({
379
402
  "../../bin/Koffi/package/src/koffi/package.json"(exports2, module2) {
380
403
  module2.exports = {
381
404
  name: "koffi",
382
- version: "2.12.1",
383
- stable: "2.12.1",
405
+ version: "2.12.3",
406
+ stable: "2.12.3",
384
407
  description: "Fast and simple C FFI (foreign function interface) for Node.js",
385
408
  keywords: [
386
409
  "foreign",
@@ -410,9 +433,6 @@ var require_package = __commonJS({
410
433
  package: "node tools/koffi.js build"
411
434
  },
412
435
  license: "MIT",
413
- devDependencies: {
414
- esbuild: "^0.19.2"
415
- },
416
436
  cnoke: {
417
437
  api: "../../vendor/node-api-headers",
418
438
  output: "../../bin/Koffi/{{ platform }}_{{ arch }}",
@@ -599,31 +619,11 @@ try {
599
619
  } catch {
600
620
  try {
601
621
  switch (triplet2) {
602
- case "linux_armhf":
603
- {
604
- native2 = require("./build/koffi/musl_armhf/koffi.node");
605
- }
606
- break;
607
622
  case "linux_arm64":
608
623
  {
609
624
  native2 = require("./build/koffi/musl_arm64/koffi.node");
610
625
  }
611
626
  break;
612
- case "linux_ia32":
613
- {
614
- native2 = require("./build/koffi/musl_ia32/koffi.node");
615
- }
616
- break;
617
- case "linux_loong64":
618
- {
619
- native2 = require("./build/koffi/musl_loong64/koffi.node");
620
- }
621
- break;
622
- case "linux_riscv64d":
623
- {
624
- native2 = require("./build/koffi/musl_riscv64d/koffi.node");
625
- }
626
- break;
627
627
  case "linux_x64":
628
628
  {
629
629
  native2 = require("./build/koffi/musl_x64/koffi.node");
package/indirect.js CHANGED
@@ -178,6 +178,28 @@ var require_tools = __commonJS({
178
178
  return true;
179
179
  return false;
180
180
  }
181
+ function sync_files(src_dir, dest_dir) {
182
+ let keep = /* @__PURE__ */ new Set();
183
+ {
184
+ let entries = fs2.readdirSync(src_dir, { withFileTypes: true });
185
+ for (let entry of entries) {
186
+ if (!entry.isFile())
187
+ continue;
188
+ keep.add(entry.name);
189
+ fs2.copyFileSync(src_dir + `/${entry.name}`, dest_dir + `/${entry.name}`);
190
+ }
191
+ }
192
+ {
193
+ let entries = fs2.readdirSync(dest_dir, { withFileTypes: true });
194
+ for (let entry of entries) {
195
+ if (!entry.isFile())
196
+ continue;
197
+ if (keep.has(entry.name))
198
+ continue;
199
+ fs2.unlinkSync(dest_dir + `/${entry.name}`);
200
+ }
201
+ }
202
+ }
181
203
  function determine_arch2() {
182
204
  let arch = process.arch;
183
205
  if (arch == "riscv32" || arch == "riscv64") {
@@ -366,6 +388,7 @@ var require_tools = __commonJS({
366
388
  extract_targz,
367
389
  path_is_absolute,
368
390
  path_has_dotdot,
391
+ sync_files,
369
392
  determine_arch: determine_arch2,
370
393
  unlink_recursive,
371
394
  get_napi_version: get_napi_version2,
@@ -379,8 +402,8 @@ var require_package = __commonJS({
379
402
  "../../bin/Koffi/package/src/koffi/package.json"(exports2, module2) {
380
403
  module2.exports = {
381
404
  name: "koffi",
382
- version: "2.12.1",
383
- stable: "2.12.1",
405
+ version: "2.12.3",
406
+ stable: "2.12.3",
384
407
  description: "Fast and simple C FFI (foreign function interface) for Node.js",
385
408
  keywords: [
386
409
  "foreign",
@@ -410,9 +433,6 @@ var require_package = __commonJS({
410
433
  package: "node tools/koffi.js build"
411
434
  },
412
435
  license: "MIT",
413
- devDependencies: {
414
- esbuild: "^0.19.2"
415
- },
416
436
  cnoke: {
417
437
  api: "../../vendor/node-api-headers",
418
438
  output: "../../bin/Koffi/{{ platform }}_{{ arch }}",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "2.12.1",
4
- "stable": "2.12.1",
3
+ "version": "2.12.3",
4
+ "stable": "2.12.3",
5
5
  "description": "Fast and simple C FFI (foreign function interface) for Node.js",
6
6
  "keywords": [
7
7
  "foreign",
@@ -1,9 +1,9 @@
1
1
  MIT License
2
2
 
3
- Copyright 2023 Niels Martignène <niels.martignene@protonmail.com>
3
+ Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
4
4
 
5
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
6
+ this software and associated documentation files (the “Software”), to deal in
7
7
  the Software without restriction, including without limitation the rights to use,
8
8
  copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
9
9
  Software, and to permit persons to whom the Software is furnished to do so,
@@ -65,11 +65,13 @@ You can find the same help text by running `cnoke --help`:
65
65
  Usage: cnoke [command] [options...] [targets...]
66
66
 
67
67
  Commands:
68
+
68
69
  configure Configure CMake build
69
70
  build Build project (configure if needed)
70
71
  clean Clean build files
71
72
 
72
73
  Options:
74
+
73
75
  -d, --directory <DIR> Change project directory
74
76
  (default: current working directory)
75
77
 
@@ -1,7 +1,7 @@
1
- # Copyright 2023 Niels Martignène <niels.martignene@protonmail.com>
1
+ # Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- # this software and associated documentation files (the “Software”), to deal in
4
+ # this software and associated documentation files (the “Software”), to deal in
5
5
  # the Software without restriction, including without limitation the rights to use,
6
6
  # copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
7
  # Software, and to permit persons to whom the Software is furnished to do so,
@@ -110,3 +110,13 @@ else()
110
110
  function(enable_unity_build TARGET)
111
111
  endfunction()
112
112
  endif()
113
+
114
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
115
+ message(STATUS ${CMAKE_SYSTEM_PROCESSOR})
116
+ if(CMAKE_SYSTEM_PROCESSOR MATCHES "(amd64|x86_64)")
117
+ foreach(lang C CXX)
118
+ set(CMAKE_${lang}_FLAGS_RELEASE "${CMAKE_${lang}_FLAGS_RELEASE} -mpopcnt -msse4.1 -msse4.2 -mssse3 -mcx16")
119
+ set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO "${CMAKE_${lang}_FLAGS_RELWITHDEBINFO} -mpopcnt -msse4.1 -msse4.2 -mssse3 -mcx16")
120
+ endforeach()
121
+ endif()
122
+ endif()
@@ -1,7 +1,7 @@
1
- // Copyright 2023 Niels Martignène <niels.martignene@protonmail.com>
1
+ // Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
2
2
  //
3
3
  // Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- // this software and associated documentation files (the “Software”), to deal in
4
+ // this software and associated documentation files (the “Software”), to deal in
5
5
  // the Software without restriction, including without limitation the rights to use,
6
6
  // copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
7
  // Software, and to permit persons to whom the Software is furnished to do so,
@@ -20,10 +20,10 @@
20
20
  // OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  #include <stdlib.h>
23
- #ifndef NOMINMAX
23
+ #if !defined(NOMINMAX)
24
24
  #define NOMINMAX
25
25
  #endif
26
- #ifndef WIN32_LEAN_AND_MEAN
26
+ #if !defined(WIN32_LEAN_AND_MEAN)
27
27
  #define WIN32_LEAN_AND_MEAN
28
28
  #endif
29
29
  #include <windows.h>
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // Copyright 2023 Niels Martignène <niels.martignene@protonmail.com>
3
+ // Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
4
4
  //
5
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
6
+ // this software and associated documentation files (the “Software”), to deal in
7
7
  // the Software without restriction, including without limitation the rights to use,
8
8
  // copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
9
9
  // Software, and to permit persons to whom the Software is furnished to do so,
@@ -153,11 +153,13 @@ function print_usage() {
153
153
  let help = `Usage: cnoke [command] [options...]
154
154
 
155
155
  Commands:
156
+
156
157
  configure Configure CMake build
157
158
  build Build project (configure if needed)
158
159
  clean Clean build files
159
160
 
160
161
  Options:
162
+
161
163
  -d, --directory <DIR> Change source directory
162
164
  (default: current working directory)
163
165
  -p, --package <DIR> Change package directory
@@ -11,7 +11,7 @@
11
11
  ],
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "https://github.com/Koromix/rygel.git"
14
+ "url": "https://codeberg.org/Koromix/rygel.git"
15
15
  },
16
16
  "author": {
17
17
  "name": "Niels Martignène",