Documentation ¶
Index ¶
- Constants
- type Function
- type Global
- type Memory
- func (m *Memory) Definition() api.MemoryDefinition
- func (m *Memory) Grow(deltaPages uint32) (previousPages uint32, ok bool)
- func (m *Memory) Pages() uint32
- func (m *Memory) Read(offset, length uint32) ([]byte, bool)
- func (m *Memory) ReadByte(offset uint32) (byte, bool)
- func (m *Memory) ReadFloat32Le(offset uint32) (float32, bool)
- func (m *Memory) ReadFloat64Le(offset uint32) (float64, bool)
- func (m *Memory) ReadUint16Le(offset uint32) (uint16, bool)
- func (m *Memory) ReadUint32Le(offset uint32) (uint32, bool)
- func (m *Memory) ReadUint64Le(offset uint32) (uint64, bool)
- func (m *Memory) Size() uint32
- func (m *Memory) Write(offset uint32, value []byte) bool
- func (m *Memory) WriteByte(offset uint32, value byte) bool
- func (m *Memory) WriteFloat32Le(offset uint32, value float32) bool
- func (m *Memory) WriteFloat64Le(offset uint32, value float64) bool
- func (m *Memory) WriteString(offset uint32, value string) bool
- func (m *Memory) WriteUint16Le(offset uint32, value uint16) bool
- func (m *Memory) WriteUint32Le(offset uint32, value uint32) bool
- func (m *Memory) WriteUint64Le(offset uint32, value uint64) bool
- type Module
- func (m *Module) Close(ctx context.Context) error
- func (m *Module) CloseWithExitCode(ctx context.Context, exitCode uint32) error
- func (m *Module) ExitStatus() (exitCode uint32, exited bool)
- func (m *Module) ExportedFunction(name string) api.Function
- func (m *Module) ExportedFunctionDefinitions() map[string]api.FunctionDefinition
- func (m *Module) ExportedGlobal(name string) api.Global
- func (m *Module) ExportedMemory(name string) api.Memory
- func (m *Module) ExportedMemoryDefinitions() map[string]api.MemoryDefinition
- func (m *Module) Function(i int) api.Function
- func (m *Module) Global(i int) api.Global
- func (m *Module) IsClosed() bool
- func (m *Module) Memory() api.Memory
- func (m *Module) Name() string
- func (m *Module) NumFunction() int
- func (m *Module) NumGlobal() int
- func (m *Module) String() string
Constants ¶
const PageSize = 65536
The PageSize constant defines the size of WebAssembly memory pages in bytes.
See https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/#page-size
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Function ¶
type Function struct { internalapi.WazeroOnlyType // GoModuleFunction may be set to a non-nil value to allow calling of the // function via Call or CallWithStack. // // It is the user's responsibility to ensure that the signature of this // implementation matches the ParamTypes and ResultTypes fields. GoModuleFunction api.GoModuleFunction // Type lists representing the function signature. Those fields should be // set for the function to be properly constructed. The Function's Call // and CallWithStack methods will error if those fields are nil. ParamTypes []api.ValueType ResultTypes []api.ValueType // Sets of names associated with the function. It is valid to leave those // names empty, they are only used for debugging purposes. FunctionName string DebugName string ParamNames []string ResultNames []string ExportNames []string // contains filtered or unexported fields }
Function is an implementation of the api.Function interface, it represents a function in a WebAssembly module.
Until accessed through a Module's method, the function definition's ModuleName method returns an empty string and its Index method returns 0.
func NewFunction ¶
NewFunction constructs a Function object from a Go function.
The function fn must accept at least two arguments of type context.Context and api.Module. Any other arguments and return values must be of type uint32, uint64, int32, int64, float32, or float64. The call panics if fn is not a Go functionn or has an unsupported signature.
func (*Function) CallWithStack ¶
func (*Function) Definition ¶
func (f *Function) Definition() api.FunctionDefinition
type Global ¶
type Global struct { internalapi.WazeroOnlyType // Type of the global value, used to interpret bits of the Value field. ValueType api.ValueType // Value of the global packed in a 64 bits field. Value uint64 // List of names that the globla is exported as. ExportNames []string }
Global is an implementation of the api.Global interface, it represents a global in a WebAssembly module.
type Memory ¶
type Memory struct { internalapi.WazeroOnlyType // Byte slices holding the memory pages. // // It is the user's repsonsibility to ensure that the length of this byte // slice is a multiple of the page size. Bytes []byte // Min and max number of memory pages which may be held in this memory. // // Leaving Max to zero means no upper bound. Min uint32 Max uint32 // contains filtered or unexported fields }
Memory is an implementation of the api.Memory interface, representing the memory of a WebAssembly module.
func NewFixedMemory ¶
NewFixedMemory constructs a Memory object of the given size. The returned memory is configured with a max limit to prevent growing beyond its initial size.
func NewMemory ¶
NewMemory constructs a Memory object with a buffer of the given size, aligned to the closest multiple of the page size.
func (*Memory) Definition ¶
func (m *Memory) Definition() api.MemoryDefinition
type Module ¶
type Module struct { internalapi.WazeroOnlyType // The module name that will be returned by calling the Name method. ModuleName string // The list of functions of the module. Functions with a non-empty export // names will be exported by the module. Functions []*Function // The list of globals of the module. Global Globals []*Global // The program memory. If non-nil, the memory is automatically exported as // "memory". ExportMemory *Memory // contains filtered or unexported fields }
Module is an implementation of the api.Module interface, it represents a WebAssembly module.
func (*Module) CloseWithExitCode ¶
CloseWithExitCode implements the same method as documented on api.Closer.
func (*Module) ExitStatus ¶
func (*Module) ExportedFunction ¶
ExportedFunction implements the same method as documented on api.Module.
func (*Module) ExportedFunctionDefinitions ¶
func (m *Module) ExportedFunctionDefinitions() map[string]api.FunctionDefinition
ExportedFunctionDefinitions implements the same method as documented on api.Module.
func (*Module) ExportedGlobal ¶
ExportedGlobal implements the same method as documented on api.Module.
func (*Module) ExportedMemory ¶
ExportedMemory implements the same method as documented on api.Module.
func (*Module) ExportedMemoryDefinitions ¶
func (m *Module) ExportedMemoryDefinitions() map[string]api.MemoryDefinition
ExportedMemoryDefinitions implements the same method as documented on api.Module.
func (*Module) Global ¶
Global implements the same method as documented on experimental.InternalModule.
func (*Module) IsClosed ¶ added in v1.3.0
IsClosed implements the same method as documented on api.Module.