go-ffi: bitbucket.org/binet/go-ffi/pkg/ffi Index | Files

package ffi

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

Index

Constants

const (
    TrampolineSize = C.FFI_TRAMPOLINE_SIZE
    NativeRawApi   = C.FFI_NATIVE_RAW_API
)

Variables

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

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

type Cif struct {
    // contains filtered or unexported fields
}

Cif is the ffi call interface

func NewCif

func NewCif(abi Abi, rtype Type, args []Type) (*Cif, error)

NewCif creates a new ffi call interface object

func (*Cif) Call

func (cif *Cif) Call(fct FctPtr, args ...interface{}) (reflect.Value, error)

Call invokes the cif with the provided function pointer and arguments

type Closure

type Closure struct {
    // contains filtered or unexported fields
}

Closure models a ffi closure

type FctPtr

type FctPtr struct {
    // contains filtered or unexported fields
}

type Function

type Function func(args ...interface{}) reflect.Value

Function is a dl-loaded function from a dl-opened library

type Library

type Library struct {
    // contains filtered or unexported fields
}

Library is a dl-opened library holding the corresponding dl.Handle

func NewLibrary

func NewLibrary(libname string) (lib Library, err error)

func (Library) Close

func (lib Library) Close() error

func (Library) Fct

func (lib Library) Fct(fctname string, rtype Type, argtypes []Type) (Function, error)

type Status

type Status uint32
const (
    Ok         Status = C.FFI_OK
    BadTypedef Status = C.FFI_BAD_TYPEDEF
    BadAbi     Status = C.FFI_BAD_ABI
)

func (Status) String

func (sc Status) String() string

type Type

type Type struct {
    // contains filtered or unexported fields
}

Type is a FFI type, describing functions' type arguments

Files

doc.go ffi.go cgoflags.go

Package ffi imports 5 packages (graph). Updated 2013-03-28. Refresh.