/** * TODO: * - Implement Double and other SIMD types * - Add check for correct number / type of arguments. * - Can we tell whether a function throws via its metadata? */ import { ProtocolComposition } from "./types.js"; import { TargetMetadata } from "../abi/metadata.js"; export type NativeSwiftType = TargetMetadata | ProtocolComposition | NativeFunctionReturnType | NativeFunctionArgumentType; export declare const MAX_LOADABLE_SIZE: number; export declare const INDRIECT_RETURN_REGISTER = "x8"; export interface SwiftNativeFunction { address: NativePointer; (...args: any[]): any; } /** * TODO: * - Re-cook this spaghetti * - Add dynamic type checks */ export declare function makeSwiftNativeFunction(address: NativePointer, retType: NativeSwiftType, argTypes: NativeSwiftType[], context?: NativePointer, throws?: boolean): SwiftNativeFunction; export declare function shouldPassIndirectly(typeMetadata: TargetMetadata): boolean; export declare class SwiftcallNativeFunction { #private; constructor(target: NativePointer, resultType: NativeFunctionReturnType, argTypes: NativeFunctionArgumentType[], context?: NativePointer, errorResult?: NativePointer); wrapper: (...args: NativeFunctionArgumentValue[]) => string | number | NativePointer | Int64 | ReadValueType[]; call(...args: NativeFunctionArgumentValue[]): ReadValueType | Array | undefined; } type ReadValueType = NativePointer | string | number | Int64 | null; declare global { interface NativePointer { readValue(type: "pointer"): NativePointer; readValue(type: "string"): string | null; readValue(type: "int" | "uint" | "int8" | "uint8" | "int16" | "uint16" | "int32" | "uint32"): number; readValue(type: "long" | "ulong"): number | Int64; readValue(type: Exclude): never; readValue(type: NativeFunctionReturnType | "string"): NativePointer | string | number | Int64 | null; } } export {};