internal/{cm,wasi}: regenerate WASI 0.2 bindings with wasm-tools-go v0.3.0

This commit is contained in:
Randy Reddig
2024-10-17 08:08:21 -07:00
committed by Ron Evans
parent a0d4ecb607
commit d5f195387d
70 changed files with 3350 additions and 684 deletions
+20 -8
View File
@@ -4,14 +4,25 @@ import "unsafe"
// List represents a Component Model list.
// The binary representation of list<T> is similar to a Go slice minus the cap field.
type List[T any] struct{ list[T] }
type List[T any] struct {
_ HostLayout
list[T]
}
// AnyList is a type constraint for generic functions that accept any [List] type.
type AnyList[T any] interface {
~struct {
_ HostLayout
list[T]
}
}
// NewList returns a List[T] from data and len.
func NewList[T any](data *T, len uint) List[T] {
func NewList[T any, Len AnyInteger](data *T, len Len) List[T] {
return List[T]{
list[T]{
list: list[T]{
data: data,
len: len,
len: uintptr(len),
},
}
}
@@ -20,15 +31,16 @@ func NewList[T any](data *T, len uint) List[T] {
// The underlying slice data is not copied, and the resulting List points at the
// same array storage as the slice.
func ToList[S ~[]T, T any](s S) List[T] {
return NewList[T](unsafe.SliceData([]T(s)), uint(len(s)))
return NewList[T](unsafe.SliceData([]T(s)), uintptr(len(s)))
}
// list represents the internal representation of a Component Model list.
// It is intended to be embedded in a [List], so embedding types maintain
// the methods defined on this type.
type list[T any] struct {
_ HostLayout
data *T
len uint
len uintptr
}
// Slice returns a Go slice representing the List.
@@ -42,7 +54,7 @@ func (l list[T]) Data() *T {
}
// Len returns the length of the list.
// TODO: should this return an int instead of a uint?
func (l list[T]) Len() uint {
// TODO: should this return an int instead of a uintptr?
func (l list[T]) Len() uintptr {
return l.len
}