ffi

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrValueMustBeCons is raised when a complex Unwrap call can't treat its
	// source as a data.Cons
	ErrValueMustBeCons = "value must be a cons cell"

	// ErrConsMustContainFloat is raised when a complex Unwrap call can't treat
	// its source's components as data.Floats
	ErrConsMustContainFloat = "components must be float values"
)
View Source
const (
	// ErrInterfaceTypeMismatch is raised when an interface of the receiver in
	// a data.Object doesn't match the expected wrapped interface
	ErrInterfaceTypeMismatch = "interface type mismatch"

	// ErrInterfaceCoercionNotSupported is raised when the value to unwrap
	// isn't a data.Object
	ErrInterfaceCoercionNotSupported = "value cannot be coerced into interface"
)
View Source
const AleTag = "ale"

AleTag identifies the tag used to specify the kwd used when wrapping a struct as an Object

View Source
const ErrChannelCoercionNotSupported = "value cannot be coerced into chan"

ErrChannelCoercionNotSupported is raised when a channel Unwrap is called

View Source
const ErrCycleDetected = "cycle detected in wrapping"

ErrCycleDetected is raised when wrapping encounters a reference cycle

View Source
const ErrMustImplementValue = "must implement value"

ErrMustImplementValue is raised when a value Unwrap call can't treat its source as a data.Value

View Source
const ErrUnsupportedType = "unsupported type"

ErrUnsupportedType is raised when wrapping encounters an unsupported type

View Source
const ErrValueMustBeBool = "value must be a bool"

ErrValueMustBeBool is raised when a boolean Unwrap call can't treat its source as a data.Bool

View Source
const ErrValueMustBeFloat = "value must be a float"

ErrValueMustBeFloat is raised when a float Unwrap call can't treat its source as a data.Integer or data.Float

View Source
const ErrValueMustBeInteger = "value must be an integer"

ErrValueMustBeInteger is raised when an integer Unwrap call can't treat its source as a data.Integer

View Source
const ErrValueMustBeProcedure = "value must be a procedure"

ErrValueMustBeProcedure is raised when a function Unwrap call can't treat its source as a data.Procedure

View Source
const ErrValueMustBeSequence = "value must be a sequence"

ErrValueMustBeSequence is raised when an Array Unwrap call can't treat its source as a data.Sequence

View Source
const ErrValueMustBeString = "value must be a string"

ErrValueMustBeString is raised when an string Unwrap call can't treat its source as a data.String

View Source
const ReceiverKey = data.Keyword("receiver")

ReceiverKey is the key used to store an interface receiver

Variables

This section is empty.

Functions

func MustWrap

func MustWrap(i any) data.Value

MustWrap wraps a Go value into a data.Value or explodes violently

func Wrap

func Wrap(i any) (data.Value, error)

Wrap takes a native Go value, potentially builds a Wrapper for its type, and returns a marshaled data.Value from the Wrapper

Types

type Context

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

Context tracks wrapped reflect.Values to detect cycles

func (*Context) Push

func (c *Context) Push(v reflect.Value) (*Context, error)

Push creates a new Context, checking the parent chain for cycles

type Wrapper

type Wrapper interface {
	Wrap(*Context, reflect.Value) (data.Value, error)
	Unwrap(data.Value) (reflect.Value, error)
}

Wrapper can marshal a native Go value to and from a data.Value

func WrapType

func WrapType(t reflect.Type) (Wrapper, error)

WrapType potentially builds a Wrapper for the provided reflected Type

type Wrappers

type Wrappers []Wrapper

Wrappers is a set of Wrapper

Jump to

Keyboard shortcuts

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