ffi

package
v0.0.0-...-f1d475f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2024 License: 0BSD Imports: 15 Imported by: 0

Documentation

Overview

Package ffi provides information about the platform-native C ABI types.

Index

Constants

View Source
const (
	ErrTagMissingType errorString = "missing type information"
)

Variables

This section is empty.

Functions

func CompileForSpeed

func CompileForSpeed(fn reflect.Type, foreign Type) (*cpu.Program, error)

func CompileReliably

func CompileReliably(fn reflect.Type, foreign Type) (src *cpu.Program, err error)

func Const

func Const(name string) string

Const returns an empty string if the constant is not supported.

func Kind

func Kind(name string) reflect.Kind

Kind returns reflect.Invalid if the type is not supported.

func Sizeof

func Sizeof(name string) uintptr

Sizeof returns 0 if the type is not supported.

Types

type Argument

type Argument struct {
	Check bool   // should this assertion be checked?
	Index uint8  // of the argument being referred to. if greater than zero ignore const and value.
	Const string // C standard constant (or supported macro) name.
	Value int64  // integer value
}

Argument for a Type assertion within a [Tag].

type Assertions

type Assertions struct {
	Capacity bool     // []
	Inverted bool     // !
	Indirect int      // /
	Lifetime Argument // ^
	Overlaps Argument // ~
	SameType Argument // :
	Equality Argument // =
	MoreThan Argument // >
	LessThan Argument // <
	OfFormat Argument // f
}

Assertions for a Type within a [Tag].

type Call

type Call struct {
	Name string     // symbol name
	Args []Argument // arguments to pass to the function
}

Call represents a function to call on failure within a [Tag], to return information about why the assertion failed.

type Error

type Error int8

func (Error) Error

func (err Error) Error() string

type SyntaxError

type SyntaxError struct {
	Tag string
	Pos int
	Err error
}

SyntaxError for a [Tag].

func (SyntaxError) Error

func (e SyntaxError) Error() string

type Type

type Type struct {
	Name string

	Func *Type  // return type.
	Args []Type // arguments (if function)

	Hash bool       // immutablity marker, true if preceded by '#'
	Free rune       // ownership assertion, one of '$', '&', '*', '~', '+' or '-'
	Test Assertions // memory safety assertions
	Call Call       // symbol to lookup on failure (if function)
	More bool       // varaidic

	Maps int // index of the Go argument that is mapped to this value.
}

Type structure.

func ParseTag

func ParseTag(tag string) ([]string, Type, error)

ParseTag returns a structured representation of the symbols and type defined in the tag.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL