Rename {native,typed} functions, reintroduce *_with_env variants

This commit is contained in:
Wolfgang Silbermayr
2022-08-03 11:45:31 +02:00
parent 663f922f78
commit 7df3e3ca23
42 changed files with 1327 additions and 1305 deletions

View File

@@ -17,7 +17,7 @@
//!
//! Ready?
use wasmer::{imports, wat2wasm, FunctionEnv, Instance, Module, Store, TypedFunction, Value};
use wasmer::{imports, wat2wasm, Instance, Module, Store, TypedFunction, Value};
use wasmer_compiler_cranelift::Cranelift;
fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -81,17 +81,17 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// that's possible with the `TypedFunction` API. The function
// will use native Rust values.
//
// Note that `native` takes 2 generic parameters: `Args` and
// Note that `typed` takes 2 generic parameters: `Args` and
// `Rets`, respectively for the parameters and the results. If
// those values don't match the exported function signature, an
// error will be raised.
let sum_native: TypedFunction<(i32, i32), i32> = sum.native(&mut store)?;
let sum_typed: TypedFunction<(i32, i32), i32> = sum.typed(&mut store)?;
println!("Calling `sum` function (natively)...");
// Let's call the `sum` exported function. The parameters are
// statically typed Rust values of type `i32` and `i32`. The
// result, in this case particular case, in a unit of type `i32`.
let result = sum_native.call(&mut store, 3, 4)?;
let result = sum_typed.call(&mut store, 3, 4)?;
println!("Results: {:?}", result);
assert_eq!(result, 7);