Implement RFC 11: Redesigning Wasmtime's APIs (#2897)

Implement Wasmtime's new API as designed by RFC 11. This is quite a large commit which has had lots of discussion externally, so for more information it's best to read the RFC thread and the PR thread.
This commit is contained in:
Alex Crichton
2021-06-03 09:10:53 -05:00
committed by GitHub
parent a5a28b1c5b
commit 7a1b7cdf92
233 changed files with 13349 additions and 11997 deletions

View File

@@ -9,11 +9,14 @@ wiggle::from_witx!({
impl_errno!(types::Errno);
impl<'a> atoms::Atoms for WasiCtx<'a> {
fn int_float_args(&self, an_int: u32, an_float: f32) -> Result<(), types::Errno> {
fn int_float_args(&mut self, an_int: u32, an_float: f32) -> Result<(), types::Errno> {
println!("INT FLOAT ARGS: {} {}", an_int, an_float);
Ok(())
}
fn double_int_return_float(&self, an_int: u32) -> Result<types::AliasToFloat, types::Errno> {
fn double_int_return_float(
&mut self,
an_int: u32,
) -> Result<types::AliasToFloat, types::Errno> {
Ok((an_int as f32) * 2.0)
}
}
@@ -28,10 +31,10 @@ struct IntFloatExercise {
impl IntFloatExercise {
pub fn test(&self) {
let ctx = WasiCtx::new();
let mut ctx = WasiCtx::new();
let host_memory = HostMemory::new();
let e = atoms::int_float_args(&ctx, &host_memory, self.an_int as i32, self.an_float);
let e = atoms::int_float_args(&mut ctx, &host_memory, self.an_int as i32, self.an_float);
assert_eq!(e, Ok(types::Errno::Ok as i32), "int_float_args error");
}
@@ -57,11 +60,11 @@ struct DoubleIntExercise {
impl DoubleIntExercise {
pub fn test(&self) {
let ctx = WasiCtx::new();
let mut ctx = WasiCtx::new();
let host_memory = HostMemory::new();
let e = atoms::double_int_return_float(
&ctx,
&mut ctx,
&host_memory,
self.input as i32,
self.return_loc.ptr as i32,