Common WebAssembly API Compliance

This ABI complies to the spec outlined in the GitHub repo CommonWA/cwa-spec. The vendored copy of the CWA spec will reflect what Olin implements.

There are no tests for CWA compliance, so some will be developed as part of this.

Expand ▾ Collapse ▴



    Package cwa contains the ABI for CommonWA[1] applications.




    View Source
    const (
    	LogLevelError   = 1
    	LogLevelWarning = 3
    	LogLevelInfo    = 6

      Log levels

      View Source
      const (
      	SpecMajor   = 0
      	SpecMinor   = 1
      	RuntimeName = "olin"



        This section is empty.


        func ErrorCode

        func ErrorCode(err error) int

          ErrorCode extracts the code from an error.


          type Error

          type Error int

            Error is an individual error as defined by the CommonWA spec.

            const (
            	ErrNone Error = (iota * -1)

              CommonWA errors as defined by the spec at

              func (Error) Error

              func (e Error) Error() string

              func (Error) String

              func (i Error) String() string

              type Process

              type Process struct {
              	HC     *http.Client
              	Logger *log.Logger
              	Policy *policy.Policy
              	FileHandles    map[int32]abi.File
              	Stdin          io.Reader
              	Stdout, Stderr io.Writer
              	// contains filtered or unexported fields

                Process is an individual CommonWA process. It is the collection of resources and other macguffins that the child module ends up requiring.

                func NewProcess

                func NewProcess(name string, argv []string, env map[string]string) *Process

                  NewProcess creates a new process with the given name, arguments and environment.

                  func (*Process) ArgAt

                  func (p *Process) ArgAt(i int32, outPtr, outLen uint32) (int32, error)

                  func (*Process) ArgLen

                  func (p *Process) ArgLen() int32

                  func (*Process) EnvGet

                  func (p *Process) EnvGet(keyPtr, keyLen, valPtr, valLen uint32) (int32, error)

                  func (*Process) Files

                  func (p *Process) Files() []abi.File

                    Files returns the set of open files in use by this process.

                    func (*Process) IOGetStderr

                    func (p *Process) IOGetStderr() int32

                    func (*Process) IOGetStdin

                    func (p *Process) IOGetStdin() int32

                    func (*Process) IOGetStdout

                    func (p *Process) IOGetStdout() int32

                    func (*Process) LogWrite

                    func (p *Process) LogWrite(level int32, msgPtr, msgLen uint32)

                    func (*Process) Name

                    func (p *Process) Name() string

                      Name returns this process' name.

                      func (Process) Open

                      func (Process) Open(abi.File)

                        Open does nothing

                        func (*Process) RandI32

                        func (p *Process) RandI32() int32

                        func (*Process) RandI64

                        func (p *Process) RandI64() int64

                        func (*Process) ResolveFunc

                        func (p *Process) ResolveFunc(module, field string) exec.FunctionImport

                          ResolveFunc resolves the CommonWA ABI and importable functions.

                          func (*Process) ResolveGlobal

                          func (p *Process) ResolveGlobal(module, field string) int64

                            ResolveGlobal does nothing, currently.

                            func (*Process) ResourceClose

                            func (p *Process) ResourceClose(fid int32) error

                            func (*Process) ResourceFlush

                            func (p *Process) ResourceFlush(fid int32) error

                            func (*Process) ResourceOpen

                            func (p *Process) ResourceOpen(urlPtr, urlLen uint32) (int32, error)

                            func (*Process) ResourceRead

                            func (p *Process) ResourceRead(fid int32, dataPtr, dataLen uint32) (int32, error)

                            func (*Process) ResourceWrite

                            func (p *Process) ResourceWrite(fid int32, dataPtr, dataLen uint32) (int32, error)

                            func (*Process) RuntimeName

                            func (p *Process) RuntimeName(namePtr, nameLen uint32) int32

                            func (*Process) SetVM

                            func (p *Process) SetVM(vm *exec.VirtualMachine)

                              SetVM sets the VM associated with this process.

                              func (*Process) Setenv

                              func (p *Process) Setenv(m map[string]string)

                                Setenv updates a process' environment. This does not inform the process. It is up to the running process to detect these values have changed.

                                func (Process) SyscallCount

                                func (p Process) SyscallCount() int64

                                func (*Process) TimeNow

                                func (p *Process) TimeNow() int64