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

    Interface ArrayTypeDef<E>

    An array type definition created by the array function.

    Python equivalent: c_int * 5. Call it (with or without new) with the initial elements, as Python's (c_int * 5)(1, 2, 3).

    const IntArray5 = array(c_int32, 5);
    const arr = IntArray5(1, 2, 3, 4, 5); // or IntArray5.create([1, 2, 3, 4, 5])
    console.log(arr[0]); // 1
    interface ArrayTypeDef<E = any> {
        new ArrayTypeDef(...values: ArrayElementArg<E>[]): ArrayInstance<E>;
        elementType:
            | AnyType
            | StructureClass
            | PointerTypeDef<any>
            | ArrayTypeDef<any>
            | FuncPtrFactory<FFIType, readonly FFIType[]>;
        length: number;
        _type_:
            | AnyType
            | StructureClass
            | PointerTypeDef<any>
            | ArrayTypeDef<any>
            | FuncPtrFactory<FFIType, readonly FFIType[]>;
        _length_: number;
        __pointer_type__?: PointerTypeDef<ArrayTypeDef<E>>;
        from_param(value: unknown): ArrayInstance<E>;
        getSize(): number;
        getLength(): number;
        getAlignment(): number;
        create(values?: string | readonly ArrayElementArg<E>[]): ArrayInstance<E>;
        wrap(buffer: Buffer): ArrayInstance<E>;
        from_buffer(
            source: ArrayBufferView<ArrayBufferLike> | { _buffer: Buffer },
            offset?: BufferOffset,
        ): ArrayInstance<E>;
        from_buffer_copy(
            source:
                | ReadonlyMemoryView
                | ArrayBufferView<ArrayBufferLike>
                | { _buffer: Buffer },
            offset?: BufferOffset,
        ): ArrayInstance<E>;
        from_address(address: number | bigint): ArrayInstance<E>;
        in_dll(library: Library | CDLL, name: string): ArrayInstance<E>;
        (...values: ArrayElementArg<E>[]): ArrayInstance<E>;
    }

    Type Parameters

    • E = any
    • Create an array initialized with the given elements (Python: (c_int * 3)(1, 2, 3)).

      Parameters

      • ...values: ArrayElementArg<E>[]

      Returns ArrayInstance<E>

    Index
    elementType:
        | AnyType
        | StructureClass
        | PointerTypeDef<any>
        | ArrayTypeDef<any>
        | FuncPtrFactory<FFIType, readonly FFIType[]>

    Element type.

    length: number

    Number of elements.

    _type_:
        | AnyType
        | StructureClass
        | PointerTypeDef<any>
        | ArrayTypeDef<any>
        | FuncPtrFactory<FFIType, readonly FFIType[]>

    Python ctypes alias for the element type.

    _length_: number

    Python ctypes alias for the element count.

    __pointer_type__?: PointerTypeDef<ArrayTypeDef<E>>

    Python 3.14 T.__pointer_type__: the type POINTER(T) returns (undefined before the first POINTER(T)).

    • CPython from_param: an instance of this array type (or an object whose _as_parameter_ is one) is returned; other values throw TypeError expected <name> instance instead of <type>.

      Parameters

      • value: unknown

      Returns ArrayInstance<E>

    • Total size in bytes (elementSize * length).

      Returns number

    • Create a new array, optionally initialized with values (a string writes its char codes). Returns a Proxy with index access.

      Parameters

      • Optionalvalues: string | readonly ArrayElementArg<E>[]

      Returns ArrayInstance<E>

    • Array sharing the memory of source from offset (Python: (c_int * 3).from_buffer(source, offset)). A negative offset throws RangeError offset cannot be negative, a short source RangeError Buffer size too small (N instead of at least M bytes).

      Parameters

      • source: ArrayBufferView<ArrayBufferLike> | { _buffer: Buffer }
      • Optionaloffset: BufferOffset

      Returns ArrayInstance<E>

    • Array with a copy of the bytes of source from offset (Python: from_buffer_copy).

      Parameters

      • source: ReadonlyMemoryView | ArrayBufferView<ArrayBufferLike> | { _buffer: Buffer }
      • Optionaloffset: BufferOffset

      Returns ArrayInstance<E>

    • Array on the memory at address (Python: (c_int * 3).from_address(address)). Its _buffer is a Buffer over that memory, as Python's memoryview((c_char * n).from_address(address)); where EXTERNAL_BUFFERS is false it is a copy kept in sync by the array's element accesses.

      Parameters

      • address: number | bigint

      Returns ArrayInstance<E>