wasi preview 2 support (#4027)

* all: wasip2 support

Co-authored-by: Randy Reddig <randy.reddig@fastly.com>
This commit is contained in:
Damian Gryski
2024-07-02 07:02:03 -07:00
committed by GitHub
parent f18c6e342f
commit 9cb263479c
125 changed files with 7035 additions and 154 deletions
@@ -0,0 +1,3 @@
// This file exists for testing this package without WebAssembly,
// allowing empty function bodies with a //go:wasmimport directive.
// See https://pkg.go.dev/cmd/compile for more information.
@@ -0,0 +1,73 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
//go:build !wasip1
// Package ioerror represents the imported interface "wasi:io/error@0.2.0".
package ioerror
import (
"github.com/ydnar/wasm-tools-go/cm"
)
// Error represents the imported resource "wasi:io/error@0.2.0#error".
//
// A resource which represents some error information.
//
// The only method provided by this resource is `to-debug-string`,
// which provides some human-readable information about the error.
//
// In the `wasi:io` package, this resource is returned through the
// `wasi:io/streams/stream-error` type.
//
// To provide more specific error information, other interfaces may
// provide functions to further "downcast" this error into more specific
// error information. For example, `error`s returned in streams derived
// from filesystem types to be described using the filesystem's own
// error-code type, using the function
// `wasi:filesystem/types/filesystem-error-code`, which takes a parameter
// `borrow<error>` and returns
// `option<wasi:filesystem/types/error-code>`.
//
// The set of functions which can "downcast" an `error` into a more
// concrete type is open.
//
// resource error
type Error cm.Resource
// ResourceDrop represents the imported resource-drop for resource "error".
//
// Drops a resource handle.
//
//go:nosplit
func (self Error) ResourceDrop() {
self0 := cm.Reinterpret[uint32](self)
wasmimport_ErrorResourceDrop((uint32)(self0))
return
}
//go:wasmimport wasi:io/error@0.2.0 [resource-drop]error
//go:noescape
func wasmimport_ErrorResourceDrop(self0 uint32)
// ToDebugString represents the imported method "to-debug-string".
//
// Returns a string that is suitable to assist humans in debugging
// this error.
//
// WARNING: The returned string should not be consumed mechanically!
// It may change across platforms, hosts, or other implementation
// details. Parsing this string is a major platform-compatibility
// hazard.
//
// to-debug-string: func() -> string
//
//go:nosplit
func (self Error) ToDebugString() (result string) {
self0 := cm.Reinterpret[uint32](self)
wasmimport_ErrorToDebugString((uint32)(self0), &result)
return
}
//go:wasmimport wasi:io/error@0.2.0 [method]error.to-debug-string
//go:noescape
func wasmimport_ErrorToDebugString(self0 uint32, result *string)