* Adds support for flags datatype This commit adds support for `FlagsDatatype`. In WASI, flags are represented as bitfields/bitflags, therefore, it is important for the type to have bitwise operations implemented, and some way of checking whether the current set of flags contains some other set (i.e., they intersect). Thus, this commit automatically derives `BitAnd`, etc. for the derived flags datatype. It also automatically provides an `ALL_FLAGS` value which corresponds to a bitwise-or of all flag values present and is provided for convenience. * Simplify read_from_guest
76 lines
2.0 KiB
Plaintext
76 lines
2.0 KiB
Plaintext
(typename $errno
|
|
(enum u32
|
|
$ok
|
|
$invalid_arg
|
|
$dont_want_to
|
|
$physically_unable
|
|
$picket_line))
|
|
|
|
(typename $excuse
|
|
(enum u8
|
|
$dog_ate
|
|
$traffic
|
|
$sleeping))
|
|
|
|
(typename $car_config
|
|
(flags u8
|
|
$automatic
|
|
$awd
|
|
$suv))
|
|
|
|
(typename $pair_ints
|
|
(struct
|
|
(field $first s32)
|
|
(field $second s32)))
|
|
|
|
(typename $pair_int_ptrs
|
|
(struct
|
|
(field $first (@witx const_pointer s32))
|
|
(field $second (@witx const_pointer s32))))
|
|
|
|
(typename $named_ptr (@witx pointer f32))
|
|
(typename $named_ptr_to_ptr (@witx pointer (@witx pointer f64)))
|
|
|
|
(typename $const_excuse_array (array (@witx const_pointer $excuse)))
|
|
(typename $excuse_array (array (@witx pointer $excuse)))
|
|
|
|
(module $foo
|
|
(@interface func (export "bar")
|
|
(param $an_int u32)
|
|
(param $an_float f32)
|
|
(result $error $errno))
|
|
(@interface func (export "baz")
|
|
(param $an_excuse $excuse)
|
|
(param $an_excuse_by_reference (@witx pointer $excuse))
|
|
(param $a_lamer_excuse (@witx const_pointer $excuse))
|
|
(param $two_layers_of_excuses (@witx pointer (@witx const_pointer $excuse)))
|
|
(result $error $errno))
|
|
(@interface func (export "bat")
|
|
(param $an_int u32)
|
|
(result $error $errno)
|
|
(result $doubled_it f32))
|
|
(@interface func (export "sum_of_pair")
|
|
(param $an_pair $pair_ints)
|
|
(result $error $errno)
|
|
(result $doubled s64))
|
|
(@interface func (export "sum_of_pair_of_ptrs")
|
|
(param $an_pair $pair_int_ptrs)
|
|
(result $error $errno)
|
|
(result $doubled s64))
|
|
(@interface func (export "reduce_excuses")
|
|
(param $excuses $const_excuse_array)
|
|
(result $error $errno)
|
|
(result $reduced $excuse)
|
|
)
|
|
(@interface func (export "populate_excuses")
|
|
(param $excuses $excuse_array)
|
|
(result $error $errno)
|
|
)
|
|
(@interface func (export "configure_car")
|
|
(param $old_config $car_config)
|
|
(param $old_config_by_ptr (@witx const_pointer $car_config))
|
|
(result $error $errno)
|
|
(result $new_config $car_config)
|
|
)
|
|
)
|