Skip to content

Commit

Permalink
And fix exports
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Levick <[email protected]>
  • Loading branch information
rylev committed Oct 9, 2023
1 parent 4397ce3 commit b4034fa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 4 additions & 4 deletions crates/rust/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,16 +404,16 @@ impl InterfaceGenerator<'_> {
pub fn generate_stub(
&mut self,
resource: Option<TypeId>,
pkg: Option<&PackageName>,
pkg: Option<(String, String)>,
name: &str,
in_interface: bool,
funcs: &[&Function],
) {
let path = if let Some(pkg) = pkg {
let path = if let Some((namespace, pkg_name)) = pkg {
format!(
"{}::{}::{}",
to_rust_ident(&pkg.namespace),
to_rust_ident(&pkg.name),
to_rust_ident(&namespace),
to_rust_ident(&pkg_name),
to_rust_ident(name),
)
} else {
Expand Down
7 changes: 6 additions & 1 deletion crates/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ impl WorldGenerator for RustWasm {
WorldKey::Interface(id) => {
let interface = &resolve.interfaces[*id];
(
Some(&resolve.packages[interface.package.unwrap()].name),
Some(interface.package.unwrap()),
interface.name.as_ref().unwrap(),
)
}
Expand All @@ -481,6 +481,11 @@ impl WorldGenerator for RustWasm {
{
let mut gen =
self.interface(Identifier::World(world_id), None, resolve, false);
let pkg = pkg.map(|pid| {
let namespace = resolve.packages[pid].name.namespace.clone();
let package_module = name_package_module(resolve, pid);
(namespace, package_module)
});
gen.generate_stub(resource, pkg, name, true, &funcs);
let stub = gen.finish();
self.src.push_str(&stub);
Expand Down
1 change: 1 addition & 0 deletions tests/codegen/multiversion/root.wit
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ package foo:bar;
world foo {
import my:dep/a@0.1.0;
import my:dep/a@0.2.0;
export my:dep/a@0.2.0;
}

0 comments on commit b4034fa

Please sign in to comment.