Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
yowl committed Jan 8, 2024
2 parents 1a86775 + 1abbfe7 commit 7cc7ee7
Show file tree
Hide file tree
Showing 26 changed files with 810 additions and 332 deletions.
398 changes: 204 additions & 194 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ clap = { version = "4.3.19", features = ["derive"] }
env_logger = "0.10.0"
indexmap = "2.0.0"

wasm-encoder = "0.38.0"
wasm-metadata = "0.10.13"
wasmtime-wasi = "15.0.0"
wasm-encoder = "0.38.1"
wasm-metadata = "0.10.14"
wit-parser = "0.13.0"
wit-component = "0.18.2"
wit-component = "0.19.0"

wit-bindgen-core = { path = 'crates/core', version = '0.16.0' }
wit-bindgen-c = { path = 'crates/c', version = '0.16.0' }
Expand Down Expand Up @@ -79,7 +78,7 @@ csharp-mono = ['csharp']

[dev-dependencies]
heck = { workspace = true }
wasmtime = { version = "15", features = ['component-model'] }
wasmtime-wasi = { workspace = true }
wasmtime = { git = "https://github.com/bytecodealliance/wasmtime", features = ['component-model'] }
wasmtime-wasi = { git = "https://github.com/bytecodealliance/wasmtime"}
test-artifacts = { path = 'crates/test-rust-wasm/artifacts' }
wit-parser = { workspace = true }
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ which allows core WebAssembly binaries produced by native compilers to be
transformed into a component. All imports into a WebAssembly binary and all
exports must be described with [WIT]. An example file looks like:

```
package example:host
```wit
package example:host;
world host {
import print: func(msg: string)
import print: func(msg: string);
export run: func()
export run: func();
}
```

Expand All @@ -63,32 +63,32 @@ WebAssembly component will have available. In this case the host will provide a

Functionality in [WIT] can also be organized into `interface`s:

```
package example:my-game
```wit
package example:my-game;
interface my-plugin-api {
record coord {
x: u32,
y: u32,
}
get-position: func() -> coord
set-position: func(pos: coord)
get-position: func() -> coord;
set-position: func(pos: coord);
record monster {
name: string,
hp: u32,
pos: coord,
}
monsters: func() -> list<monster>
monsters: func() -> list<monster>;
}
world my-game {
import print: func(msg: string)
import plugin: self.my-plugin-api
import print: func(msg: string);
import my-plugin-api;
export run: func()
export run: func();
}
```

Expand Down Expand Up @@ -170,14 +170,14 @@ are listed here for each language of how to use it as well.
Each project below will assume the following `*.wit` file in the root of your
project.

```
```wit
// wit/host.wit
package example:host
package example:host;
world host {
import print: func(msg: string)
import print: func(msg: string);
export run: func()
export run: func();
}
```

Expand Down
11 changes: 8 additions & 3 deletions crates/c/src/component_type_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ pub fn linking_symbol(name: &str) -> String {
format!("__component_type_object_force_link_{snake}")
}

pub fn object(resolve: &Resolve, world: WorldId, encoding: StringEncoding) -> Result<Vec<u8>> {
pub fn object(
resolve: &Resolve,
world: WorldId,
world_name: &str,
encoding: StringEncoding,
suffix: Option<&str>,
) -> Result<Vec<u8>> {
let mut module = Module::new();

// Build a module with one function that's a "dummy function"
Expand Down Expand Up @@ -41,8 +47,7 @@ pub fn object(resolve: &Resolve, world: WorldId, encoding: StringEncoding) -> Re
// otherwise is attempted to be unique here to ensure that this doesn't get
// concatenated to other custom sections by LLD by accident since LLD will
// concatenate custom sections of the same name.
let world_name = &resolve.worlds[world].name;
let section_name = format!("component-type:{world_name}");
let section_name = format!("component-type:{world_name}{}", suffix.unwrap_or(""));

// Add our custom section
module.section(&CustomSection {
Expand Down
Loading

0 comments on commit 7cc7ee7

Please sign in to comment.