node-ctypes - v2.17.1
    Preparing search index...

    Interface FunctionWrapper

    Wrapper returned by Python-like property access on CDLL.

    Supports the argtypes/restype pattern from Python ctypes.

    const abs_func = libc.abs;
    abs_func.argtypes = [c_int];
    abs_func.restype = c_int;
    console.log(abs_func(-42)); // 42
    interface FunctionWrapper {
        address: bigint;
        _as_parameter_: bigint;
        __name__?: string;
        callAsync(...args: any[]): Promise<any>;
        callOn(target: ExecutorTarget, ...args: any[]): Promise<any>;
        argtypes: FFIType[];
        restype: FFIType | ((value: number) => any) | (new (value: number) => any);
        errcheck: ErrcheckCallback;
        (...args: any[]): any;
    }
    • Call the function.

      Parameters

      • ...args: any[]

      Returns any

    Index
    address: bigint

    Resolve the native function address.

    _as_parameter_: bigint
    __name__?: string

    The export name, as Python's fn.__name__, for functions read from the library (lib.name, lib.__getitem__(name)); undefined for an ordinal lookup.

    argtypes: FFIType[]

    Argument types (null clears declared argtypes, as Python's None). Set before calling. Reads [] when unset (Python: None). An item without a from_param method throws TypeError item N in _argtypes_ has no from_param method, a value that is not a sequence _argtypes_ must be a sequence of types; a failed assignment keeps the previous value.

    restype: FFIType | ((value: number) => any) | (new (value: number) => any)

    Return type (null for void). As in Python it may be any callable taking the raw c_int result; a class is constructed (new restype(value)). Another value throws TypeError restype must be a type, a callable, or None and keeps the previous value.

    Optional error checking callback (null when not set). Another value throws TypeError the errcheck attribute must be callable.

    • Call the function asynchronously on a worker thread (see FFIFunction.callAsync).

      Parameters

      • ...args: any[]

      Returns Promise<any>