FFIType

Bun

Symbol

FFIType

enum FFIType

  • bool

    Boolean value

    Must be true or false. 0 and 1 type coercion is not supported.

    In C, this corresponds to:

    bool
    _Bool
    
  • cstring

    When used as a returns, this will automatically become a CString.

    When used in args it is equivalent to FFIType.pointer

  • double

    Doubles are not supported yet!

  • f32

    Floats are not supported yet!

  • f64

    Doubles are not supported yet!

  • float

    Floats are not supported yet!

  • i16

    16-bit signed integer

    Must be a value between -32768 and 32767

    When passing to a FFI function (C ABI), type coercion is not performed.

    In C:

    in16_t
    short // on arm64 & x64
    

    In JavaScript:

    var num = 0;
    
  • i32

    32-bit signed integer

    Alias of FFIType.int32_t

  • i64

    i64 is a 64-bit signed integer

    This is not implemented yet!

  • i64_fast

    Attempt to coerce BigInt into a Number if it fits. This improves performance but means you might get a BigInt or you might get a number.

    In C, this always becomes int64_t

    In JavaScript, this could be number or it could be BigInt, depending on what value is passed in.

  • i8

    8-bit signed integer

    Must be a value between -127 and 127

    When passing to a FFI function (C ABI), type coercion is not performed.

    In C:

    signed char
    char // on x64 & aarch64 macOS
    

    In JavaScript:

    var num = 0;
    
  • int

    32-bit signed integer

    The same as int in C

    int
    
  • int16_t

    16-bit signed integer

    Must be a value between -32768 and 32767

    When passing to a FFI function (C ABI), type coercion is not performed.

    In C:

    in16_t
    short // on arm64 & x64
    

    In JavaScript:

    var num = 0;
    
  • int32_t

    32-bit signed integer

  • int64_t

    int64 is a 64-bit signed integer

    This is not implemented yet!

  • int8_t

    8-bit signed integer

    Must be a value between -127 and 127

    When passing to a FFI function (C ABI), type coercion is not performed.

    In C:

    signed char
    char // on x64 & aarch64 macOS
    

    In JavaScript:

    var num = 0;
    
  • pointer

    Pointer value

    alias of FFIType.ptr

  • ptr

    Pointer value

    See Bun.FFI.ptr for more information

    In C:

    void*
    

    In JavaScript:

    ptr(new Uint8Array(1))
    
  • u16

    16-bit unsigned integer

    Must be a value between 0 and 65535, inclusive.

    When passing to a FFI function (C ABI), type coercion is not performed.

    In C:

    uint16_t
    unsigned short // on arm64 & x64
    

    In JavaScript:

    var num = 0;
    
  • u32

    32-bit unsigned integer

    Alias of FFIType.uint32_t

  • u64

    64-bit unsigned integer

    This is not implemented yet!

  • u64_fast

    Attempt to coerce BigInt into a Number if it fits. This improves performance but means you might get a BigInt or you might get a number.

    In C, this always becomes uint64_t

    In JavaScript, this could be number or it could be BigInt, depending on what value is passed in.

  • u8

    8-bit unsigned integer

    Must be a value between 0 and 255

    When passing to a FFI function (C ABI), type coercion is not performed.

    In C:

    unsigned char
    

    In JavaScript:

    var num = 0;
    
  • uint16_t

    16-bit unsigned integer

    Must be a value between 0 and 65535, inclusive.

    When passing to a FFI function (C ABI), type coercion is not performed.

    In C:

    uint16_t
    unsigned short // on arm64 & x64
    

    In JavaScript:

    var num = 0;
    
  • uint32_t

    32-bit unsigned integer

    The same as unsigned int in C (on x64 & arm64)

    C:

    unsigned int
    

    JavaScript:

    ptr(new Uint32Array(1))
    
  • uint64_t

    64-bit unsigned integer

    This is not implemented yet!

  • uint8_t

    8-bit unsigned integer

    Must be a value between 0 and 255

    When passing to a FFI function (C ABI), type coercion is not performed.

    In C:

    unsigned char
    

    In JavaScript:

    var num = 0;
    
  • void

    void value

    void arguments are not supported

    void return type is the default return type

    In C:

    void