koffi-cream 2.12.2 → 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 (2) hide show
  1. package/index.d.ts +226 -143
  2. package/package.json +14 -14
package/index.d.ts CHANGED
@@ -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-cream' {
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koffi-cream",
3
- "version": "2.12.2",
3
+ "version": "2.12.3",
4
4
  "description": "A lighter packaging for Koffi, the fast and simple C FFI (foreign function interface) for Node.js",
5
5
  "author": {
6
6
  "name": "Stephan 'Septh' Schreiber",
@@ -41,18 +41,18 @@
41
41
  "main": "index.js",
42
42
  "types": "index.d.ts",
43
43
  "optionalDependencies": {
44
- "@septh/koffi-darwin-arm64": "2.12.2",
45
- "@septh/koffi-darwin-x64": "2.12.2",
46
- "@septh/koffi-linux-arm64-glibc": "2.12.2",
47
- "@septh/koffi-linux-arm64-musl": "2.12.2",
48
- "@septh/koffi-linux-x64-glibc": "2.12.2",
49
- "@septh/koffi-linux-x64-musl": "2.12.2",
50
- "@septh/koffi-linux-loong64": "2.12.2",
51
- "@septh/koffi-linux-riscv64": "2.12.2",
52
- "@septh/koffi-win32-arm64": "2.12.2",
53
- "@septh/koffi-win32-x64": "2.12.2",
54
- "@septh/koffi-freebsd-arm64": "2.12.2",
55
- "@septh/koffi-freebsd-x64": "2.12.2",
56
- "@septh/koffi-openbsd-x64": "2.12.2"
44
+ "@septh/koffi-darwin-arm64": "2.12.3",
45
+ "@septh/koffi-darwin-x64": "2.12.3",
46
+ "@septh/koffi-linux-arm64-glibc": "2.12.3",
47
+ "@septh/koffi-linux-arm64-musl": "2.12.3",
48
+ "@septh/koffi-linux-x64-glibc": "2.12.3",
49
+ "@septh/koffi-linux-x64-musl": "2.12.3",
50
+ "@septh/koffi-linux-loong64": "2.12.3",
51
+ "@septh/koffi-linux-riscv64": "2.12.3",
52
+ "@septh/koffi-win32-arm64": "2.12.3",
53
+ "@septh/koffi-win32-x64": "2.12.3",
54
+ "@septh/koffi-freebsd-arm64": "2.12.3",
55
+ "@septh/koffi-freebsd-x64": "2.12.3",
56
+ "@septh/koffi-openbsd-x64": "2.12.3"
57
57
  }
58
58
  }