Allow returning structs if copy (#19)
* Allow returning structs if copy This commit does three things: 1. enables marshalling of structs as return args from interface funcs but so far *only* for the case when the struct itself is copy 2. puts bits that use `std::convert::TryInto` in a local scope to avoid multiple reimports 3. for added clarity, we now print for which `tref` type the marshalling of results is unimplemented The first case (1.) is required to make `fd_fdstat_get` WASI interface func work which returns `Fdstat` struct (which is copy). The second case (2.) caused me some grief somewhere along the lines when I was playing with snapshot1. Putting the code that requires it inside a local scope fixed all the issues * Add proptests for returing struct if copyable * Use write_ptr_to_guest to marshal value to guest * Successfully return non-copy struct
This commit is contained in:
@@ -29,4 +29,12 @@
|
||||
(param $an_pair $pair_int_and_ptr)
|
||||
(result $error $errno)
|
||||
(result $double s64))
|
||||
(@interface func (export "return_pair_ints")
|
||||
(result $error $errno)
|
||||
(result $an_pair $pair_ints))
|
||||
(@interface func (export "return_pair_of_ptrs")
|
||||
(param $first (@witx const_pointer s32))
|
||||
(param $second (@witx const_pointer s32))
|
||||
(result $error $errno)
|
||||
(result $an_pair $pair_int_ptrs))
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user