import "bitbucket.org/binet/go-ffi/pkg/ffi"
ffi provides an easy way to call into C code using the libffi Foreign Function Interface library
const (
TrampolineSize = C.FFI_TRAMPOLINE_SIZE
NativeRawApi = C.FFI_NATIVE_RAW_API
)
var (
Void = Type{&C.ffi_type_void}
Uchar = Type{&C.ffi_type_uchar}
Char = Type{&C.ffi_type_schar}
Ushort = Type{&C.ffi_type_ushort}
Short = Type{&C.ffi_type_sshort}
Uint = Type{&C.ffi_type_uint}
Int = Type{&C.ffi_type_sint}
Ulong = Type{&C.ffi_type_ulong}
Long = Type{&C.ffi_type_slong}
Uint8 = Type{&C.ffi_type_uint8}
Int8 = Type{&C.ffi_type_sint8}
Uint16 = Type{&C.ffi_type_uint16}
Int16 = Type{&C.ffi_type_sint16}
Uint32 = Type{&C.ffi_type_uint32}
Int32 = Type{&C.ffi_type_sint32}
Uint64 = Type{&C.ffi_type_uint64}
Int64 = Type{&C.ffi_type_sint64}
Float = Type{&C.ffi_type_float}
Double = Type{&C.ffi_type_double}
LongDouble = Type{&C.ffi_type_longdouble}
Pointer = Type{&C.ffi_type_pointer}
)
type Abi C.ffi_abi
Abi is the ffi abi of the local plateform
const (
FirstAbi Abi = C.FFI_FIRST_ABI
DefaultAbi Abi = C.FFI_DEFAULT_ABI
LastAbi Abi = C.FFI_LAST_ABI
)
type Cif struct {
// contains filtered or unexported fields
}Cif is the ffi call interface
func NewCif(abi Abi, rtype Type, args []Type) (*Cif, error)
NewCif creates a new ffi call interface object
func (cif *Cif) Call(fct FctPtr, args ...interface{}) (reflect.Value, error)
Call invokes the cif with the provided function pointer and arguments
type Closure struct {
// contains filtered or unexported fields
}Closure models a ffi closure
type FctPtr struct {
// contains filtered or unexported fields
}
type Function func(args ...interface{}) reflect.ValueFunction is a dl-loaded function from a dl-opened library
type Library struct {
// contains filtered or unexported fields
}Library is a dl-opened library holding the corresponding dl.Handle
func NewLibrary(libname string) (lib Library, err error)
func (lib Library) Close() error
func (lib Library) Fct(fctname string, rtype Type, argtypes []Type) (Function, error)
type Status uint32
const (
Ok Status = C.FFI_OK
BadTypedef Status = C.FFI_BAD_TYPEDEF
BadAbi Status = C.FFI_BAD_ABI
)
func (sc Status) String() string
type Type struct {
// contains filtered or unexported fields
}Type is a FFI type, describing functions' type arguments