MIRROR: javascript for 馃悳's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 59 lines 1.8 kB view raw
1declare module 'ant:ffi' { 2 interface FFITypeConstants { 3 void: 'void'; 4 int8: 'int8'; 5 int16: 'int16'; 6 int: 'int'; 7 int64: 'int64'; 8 uint8: 'uint8'; 9 uint16: 'uint16'; 10 uint64: 'uint64'; 11 float: 'float'; 12 double: 'double'; 13 pointer: 'pointer'; 14 string: 'string'; 15 spread: '...'; 16 } 17 18 type FFIType = FFITypeConstants[keyof FFITypeConstants]; 19 type FFIValueType = Exclude<FFIType, '...'>; 20 21 interface FunctionSignature { 22 returns: FFIValueType; 23 args: FFIType[]; 24 } 25 26 interface FFIPointer { 27 address(): number; 28 isNull(): boolean; 29 offset(bytes: number): FFIPointer; 30 read(type?: FFIValueType): unknown; 31 write(type: FFIValueType, value: unknown): FFIPointer; 32 free(): FFIPointer; 33 } 34 35 interface FFICallback { 36 address(): number; 37 close(): FFICallback; 38 } 39 40 interface FFIFunction<Args extends unknown[] = unknown[], Return = unknown> { 41 (...args: Args): Return; 42 address(): number; 43 } 44 45 interface FFILibrary { 46 define(name: string, signature: FunctionSignature | [FFIValueType, FFIType[]]): FFIFunction; 47 call(name: string, ...args: unknown[]): unknown; 48 close(): FFILibrary; 49 } 50 51 const suffix: 'dylib' | 'so' | 'dll'; 52 const FFIType: FFITypeConstants; 53 54 function alloc(size: number): FFIPointer; 55 function pointer(value?: string | FFIPointer | FFICallback | ArrayBuffer | ArrayBufferView | null): FFIPointer; 56 function callback(signature: FunctionSignature | [FFIValueType, FFIType[]], fn: (...args: unknown[]) => unknown): FFICallback; 57 function callback(fn: (...args: unknown[]) => unknown, signature: FunctionSignature | [FFIValueType, FFIType[]]): FFICallback; 58 function dlopen<T extends object = {}>(libraryPath: string): FFILibrary & T; 59}