Documentation ¶
Index ¶
- Variables
- func SetArgs(mem Memory, args, envs []string) (int32, int32, error)
- type Instance
- type Memory
- type Module
- func (mod *Module) Call(name string, args ...any) (any, error)
- func (mod *Module) ClearTimeoutEvent(sp uint32)
- func (mod *Module) CopyBytesToGo(sp uint32)
- func (mod *Module) CopyBytesToJS(sp uint32)
- func (mod *Module) Debug(sp uint32)
- func (mod *Module) FinalizeRef(sp uint32)
- func (mod *Module) GetRandomData(sp uint32)
- func (mod *Module) Invoke(operation string, payload []byte) ([]byte, error)
- func (mod *Module) Nanotime1(sp uint32)
- func (mod *Module) ResetMemoryDataView(sp uint32)
- func (mod *Module) ScheduleTimeoutEvent(sp uint32)
- func (mod *Module) StringVal(sp uint32)
- func (mod *Module) ValueCall(sp uint32)
- func (mod *Module) ValueDelete(sp uint32)
- func (mod *Module) ValueGet(sp uint32)
- func (mod *Module) ValueIndex(sp uint32)
- func (mod *Module) ValueInstanceOf(sp uint32)
- func (mod *Module) ValueInvoke(sp uint32)
- func (mod *Module) ValueLength(sp uint32)
- func (mod *Module) ValueLoadString(sp uint32)
- func (mod *Module) ValueNew(sp uint32)
- func (mod *Module) ValuePrepareString(sp uint32)
- func (mod *Module) ValueSet(sp uint32)
- func (mod *Module) ValueSetIndex(sp uint32)
- func (mod *Module) Walltime(sp uint32)
- func (mod *Module) WasmExit(sp uint32)
- func (mod *Module) WasmWrite(sp uint32)
Constants ¶
This section is empty.
Variables ¶
var ErrFault = errors.New("bad address")
ErrFault is returned whenever memory was accessed that was not addressable.
var NaN = math.NaN()
NaN describes a not-a-number value.
Functions ¶
Types ¶
type Instance ¶
type Instance interface { Memory // Get the SP value. GetSP() (uint32, error) // Resume the execution of Go code until it needs to wait for an event. Resume() error }
Instance describes an instance of a Wasm module.
type Memory ¶
type Memory interface { Range(offset, length uint32) ([]byte, error) GetUInt32(offset uint32) (uint32, error) GetInt64(offset uint32) (int64, error) GetFloat64(offset uint32) (float64, error) SetUInt8(offset uint32, val uint8) error SetUInt32(offset, val uint32) error SetInt64(offset uint32, val int64) error SetFloat64(offset uint32, val float64) error }
Memory describes an instantiated module's memory.
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module implements the JavaScript imports that a Go program compiled with GOOS=js expects.
func (*Module) ClearTimeoutEvent ¶
ClearTimeoutEvent clears a timeout event scheduled by ScheduleTimeoutEvent.
This method is called from the runtime package.
func (*Module) CopyBytesToGo ¶
CopyBytesToGo copies bytes from JavaScript to Go.
func (*Module) CopyBytesToJS ¶
CopyBytesToJS copies bytes from Go to JavaScript.
func (*Module) FinalizeRef ¶
FinalizeRef removes a value from memory.
This method is called from various places in syscall/js.Value.
func (*Module) GetRandomData ¶
GetRandomData returns random data.
This method is called from the runtime package.
func (*Module) Invoke ¶
Invoke calls operation with the specified payload and returns a []byte payload.
func (*Module) Nanotime1 ¶
Nanotime1 returns the current time in nanoseconds.
This method is called from the runtime package.
func (*Module) ResetMemoryDataView ¶
ResetMemoryDataView is called whenever WebAssembly's memory.grow instruction has been used.
This method is called from the runtime package.
func (*Module) ScheduleTimeoutEvent ¶
ScheduleTimeoutEvent is called whenever an event needs to be scheduled after a certain amount of milliseconds.
This method is called from the runtime package.
func (*Module) StringVal ¶
StringVal stores a value as a string.
This method is called from syscall/js.ValueOf().
func (*Module) ValueCall ¶
ValueCall calls the method on an object with the give arguments.
This method is called from syscall/js.Value.Call().
func (*Module) ValueDelete ¶
ValueDelete deletes a property on an object.
This method is called from syscall/js.Value.Delete().
func (*Module) ValueGet ¶
ValueGet returns the JavaScript property of an object.
This method is called from syscall/js.Value.Get().
func (*Module) ValueIndex ¶
ValueIndex returns a value at a particular index in an array.
This method is called from syscall/js.Value.Index().
func (*Module) ValueInstanceOf ¶
ValueInstanceOf returns true when v is an instance of type t.
This method is called from syscall/js.Value.InstanceOf().
func (*Module) ValueInvoke ¶
ValueInvoke calls the value v with the specified arguments.
This method is called from syscall/js.Value.Invoke().
func (*Module) ValueLength ¶
ValueLength returns the JavaScript property of "length" of v.
This method is called from syscall/js.Value.Length().
func (*Module) ValueLoadString ¶
ValueLoadString loads a string into memory.
This method is called from syscall/js.Value.jsString().
func (*Module) ValueNew ¶
ValueNew calls a constructor function with the given arguments. This is akin to JavaScript's "new" operator.
This method is called from syscall/js.Value.New().
func (*Module) ValuePrepareString ¶
ValuePrepareString converts a value to a string and stores it.
This method is called from syscall/js.Value.jsString() for jsString, Boolean and Number types.
func (*Module) ValueSet ¶
ValueSet sets a value on a property on an object.
This method is called from syscall/js.Value.Set().
func (*Module) ValueSetIndex ¶
ValueSetIndex sets the value at a particular index of an array.
This method is called from syscall/js.Value.SetIndex().
func (*Module) Walltime ¶
Walltime returns the current seconds and nanoseconds.
This method is called from the runtime package.