Fix some wit-bindgen-related issues with generated bindings (#5692)

* Prefix component-bindgen-generated-functions with `call_`

This fixes clashes between Rust-native methods and the methods
themselves. For example right now `new` is a Rust-generated function for
constructing the wrapper but this can conflict with a world-exported
function called `new`.

Closes #5585

* Fix types being both shared and owned

This refactors some inherited cruft from the original `wit-bindgen`
repository to be more Wasmtime-specific and fixes a codegen case where
a type was used in both a shared and an owned context.

Closes #5688
This commit is contained in:
Alex Crichton
2023-02-02 11:54:35 -06:00
committed by GitHub
parent 63d80fc509
commit 545749b279
7 changed files with 79 additions and 57 deletions

View File

@@ -46,8 +46,8 @@ mod no_imports {
let linker = Linker::new(&engine);
let mut store = Store::new(&engine, ());
let (no_imports, _) = NoImports::instantiate(&mut store, &component, &linker)?;
no_imports.bar(&mut store)?;
no_imports.foo().foo(&mut store)?;
no_imports.call_bar(&mut store)?;
no_imports.foo().call_foo(&mut store)?;
Ok(())
}
}
@@ -108,7 +108,7 @@ mod one_import {
foo::add_to_linker(&mut linker, |f: &mut MyImports| f)?;
let mut store = Store::new(&engine, MyImports::default());
let (one_import, _) = OneImport::instantiate(&mut store, &component, &linker)?;
one_import.bar(&mut store)?;
one_import.call_bar(&mut store)?;
assert!(store.data().hit);
Ok(())
}