Skip to content

Commit f41c9e0

Browse files
syntax: world + interface (#413)
* syntax: world + interface Signed-off-by: Brian H <brian.hardock@fermyon.com> * Get tests passing Remove all parsing tests related to `use` along the way to get re-added once `use` is re-implemented for top-level worlds. * Update wit-parser tests to worlds Drop usage of the old `Interface::parse_file` function. * Add some basic tests for world Assert some assorted failures as well as a basic successful structure. * Remove existing support for `use` This will come back shortly with worlds, but for now nothing uses this in the repository any more and it's not implemented within the resolver so temporarily remove it. * Thread through docs on worlds/interfaces * Remove docs from imports/exports They're not threaded anywhere right now so remove them. Can be added back in if needed in the future. * Implement temporary stopgap of `default export` * Fix demo build Signed-off-by: Brian H <brian.hardock@fermyon.com> Co-authored-by: Alex Crichton <alex@alexcrichton.com>
1 parent 064bd1a commit f41c9e0

131 files changed

Lines changed: 1160 additions & 2022 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ heck = { version = "0.4", features = ["unicode"] }
2424
pulldown-cmark = { version = "0.8", default-features = false }
2525
clap = { version = "4.0.9", features = ["derive"] }
2626
env_logger = "0.9.1"
27+
indexmap = "1.9.1"
2728

2829
wasmtime = { git = "https://github.com/bytecodealliance/wasmtime", features = ["component-model"] }
2930
wasmtime-environ = { git = "https://github.com/bytecodealliance/wasmtime" }

crates/wit-bindgen-demo/demo.wit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ record options {
1616
wasmtime-tracing: bool,
1717
js-compat: bool,
1818
js-instantiation: bool,
19-
import: bool,
19+
is-import: bool,
2020
}
2121

2222
render: func(lang: lang, wit: string, options: options) -> result<files, string>

crates/wit-bindgen-demo/main.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Editor {
4141
wasmtimeTracing: false,
4242
jsCompat: false,
4343
jsInstantiation: false,
44-
import: false,
44+
isImport: false,
4545
};
4646
this.rerender = null;
4747
}
@@ -108,7 +108,7 @@ class Editor {
108108
break;
109109
default: return;
110110
}
111-
this.options.import = is_import;
111+
this.options.isImport = is_import;
112112
try {
113113
const results = render(lang, wit, this.options);
114114
this.generatedFiles = {};
@@ -122,8 +122,8 @@ class Editor {
122122
}
123123
if (selectedFile in this.generatedFiles)
124124
this.files.value = selectedFile;
125-
126-
this.updateSelectedFile();
125+
126+
this.updateSelectedFile();
127127
} catch (e) {
128128
this.outputEditor.setValue(e.payload);
129129
this.outputEditor.clearSelection();

crates/wit-bindgen-demo/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ fn init() {
5555
fn render(lang: demo::Lang, wit: &str, files: &mut Files, options: &demo::Options) -> Result<()> {
5656
let iface = Interface::parse("input", &wit)?;
5757
let interfaces = ComponentInterfaces {
58-
imports: if options.import {
58+
imports: if options.is_import {
5959
[(iface.name.clone(), iface.clone())].into_iter().collect()
6060
} else {
6161
Default::default()
6262
},
6363
exports: Default::default(),
64-
default: if !options.import {
64+
default: if !options.is_import {
6565
Some(iface.clone())
6666
} else {
6767
None

crates/wit-component/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ wasm-encoder = { workspace = true }
2020
wat = { workspace = true }
2121
wit-parser = { workspace = true }
2222
anyhow = { workspace = true }
23-
indexmap = "1.9.1"
2423
clap = { workspace = true, optional = true }
2524
env_logger = { workspace = true, optional = true }
2625
log = "0.4.17"
2726
bitflags = { workspace = true }
27+
indexmap = { workspace = true }
2828

2929
[dev-dependencies]
3030
wasmprinter = { workspace = true }

crates/wit-parser/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ edition.workspace = true
77
[dependencies]
88
id-arena = "2"
99
anyhow = { workspace = true }
10+
indexmap = { workspace = true }
1011
pulldown-cmark = { workspace = true }
1112
unicode-xid = "0.2.2"
1213

0 commit comments

Comments
 (0)