motherearthapimeta

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2022 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EIFunction

type EIFunction struct {
	// An implementation must be of type:
	// `func(context unsafe.Pointer, arguments ...interface{}) interface{}`.
	// It represents the real function implementation written in Go.
	Implementation interface{}

	// The pointer to the cgo function implementation, something
	// like `C.foo`.
	CgoPointer unsafe.Pointer

	// The function implementation signature.
	FunctionInputs []EIFunctionValue

	// The function implementation signature.
	FunctionOutputs []EIFunctionValue

	// The namespace of the imported function.
	Namespace string
}

EIFunction represents a EI function that gets imported in a constract WASM module.

type EIFunctionReceiver

type EIFunctionReceiver interface {
	Namespace(namespace string)
	Append(importName string, implementation interface{}, cgoPointer unsafe.Pointer) error
}

EIFunctionReceiver abstracts an EI imports container, where EI functions are registered.

type EIFunctionValue

type EIFunctionValue int

EIFunctionValue represents EI argument types

const (
	EIFunctionValueInt32 EIFunctionValue = iota
	EIFunctionValueInt64
)

type EIFunctions

type EIFunctions struct {
	FunctionMap map[string]EIFunction

	// Current namespace where to register the import.
	CurrentNamespace string
}

EIFunctions holds a collection of EI functions.

func NewEIFunctions

func NewEIFunctions() *EIFunctions

NewEIFunctions constructs a new empty `EIFunctions`.

func (*EIFunctions) Append

func (imports *EIFunctions) Append(importName string, implementation interface{}, cgoPointer unsafe.Pointer) error

Append validates and adds a new imported function to the current structure.

func (*EIFunctions) Namespace

func (imports *EIFunctions) Namespace(namespace string)

Namespace changes the current namespace of the next imported functions.

type ImportedFunctionError

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

ImportedFunctionError represents any kind of errors related to a WebAssembly imported function. It is returned by `Import` or `Imports` functions only.

func NewImportedFunctionError

func NewImportedFunctionError(functionName string, message string) *ImportedFunctionError

NewImportedFunctionError constructs a new `ImportedFunctionError`, where `functionName` is the name of the imported function, and `message` is the error message. If the error message contains `%s`, then this parameter will be replaced by `functionName`.

func (*ImportedFunctionError) Error

func (error *ImportedFunctionError) Error() string

ImportedFunctionError is an actual error. The `Error` function returns the error message.

Jump to

Keyboard shortcuts

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