Skip to content

Commit f6409d0

Browse files
authored
Add support for WIT features (#957)
This commit updates the wasm-tools crates to their 209 versions which include support for WIT features from bytecodealliance/wasm-tools#1508. This adds a `--features` CLI flag in addition to a `features` configuration of the Rust bindings macro.
1 parent e8cd824 commit f6409d0

File tree

13 files changed

+129
-105
lines changed

13 files changed

+129
-105
lines changed

Cargo.lock

Lines changed: 34 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ pulldown-cmark = { version = "0.9", default-features = false }
2828
clap = { version = "4.3.19", features = ["derive"] }
2929
indexmap = "2.0.0"
3030

31-
wasmparser = "0.208.0"
32-
wasm-encoder = "0.208.0"
33-
wasm-metadata = "0.208.0"
34-
wit-parser = "0.208.0"
35-
wit-component = "0.208.0"
31+
wasmparser = "0.209.0"
32+
wasm-encoder = "0.209.0"
33+
wasm-metadata = "0.209.0"
34+
wit-parser = "0.209.0"
35+
wit-component = "0.209.0"
3636

3737
wit-bindgen-core = { path = 'crates/core', version = '0.25.0' }
3838
wit-bindgen-c = { path = 'crates/c', version = '0.25.0' }

crates/c/src/lib.rs

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -656,9 +656,9 @@ pub fn imported_types_used_by_exported_interfaces(
656656
for (_, export) in resolve.worlds[world].exports.iter() {
657657
match export {
658658
WorldItem::Function(_) => {}
659-
WorldItem::Interface(i) => {
660-
exported_interfaces.insert(*i);
661-
live_export_types.add_interface(resolve, *i)
659+
WorldItem::Interface { id, .. } => {
660+
exported_interfaces.insert(*id);
661+
live_export_types.add_interface(resolve, *id)
662662
}
663663
WorldItem::Type(_) => unreachable!(),
664664
}
@@ -1346,7 +1346,7 @@ impl<'a> wit_bindgen_core::AnonymousTypeGenerator<'a> for InterfaceGenerator<'a>
13461346
self.resolve
13471347
}
13481348

1349-
fn anonymous_type_handle(&mut self, id: TypeId, handle: &Handle, docs: &Docs) {
1349+
fn anonymous_type_handle(&mut self, id: TypeId, handle: &Handle, _docs: &Docs) {
13501350
self.src.h_defs("\ntypedef ");
13511351
let resource = match handle {
13521352
Handle::Borrow(id) | Handle::Own(id) => id,
@@ -1360,7 +1360,7 @@ impl<'a> wit_bindgen_core::AnonymousTypeGenerator<'a> for InterfaceGenerator<'a>
13601360
self.print_typedef_target(id);
13611361
}
13621362

1363-
fn anonymous_type_tuple(&mut self, id: TypeId, ty: &Tuple, docs: &Docs) {
1363+
fn anonymous_type_tuple(&mut self, id: TypeId, ty: &Tuple, _docs: &Docs) {
13641364
self.src.h_defs("\ntypedef ");
13651365
self.src.h_defs("struct {\n");
13661366
for (i, t) in ty.types.iter().enumerate() {
@@ -1372,7 +1372,7 @@ impl<'a> wit_bindgen_core::AnonymousTypeGenerator<'a> for InterfaceGenerator<'a>
13721372
self.print_typedef_target(id);
13731373
}
13741374

1375-
fn anonymous_type_option(&mut self, id: TypeId, ty: &Type, docs: &Docs) {
1375+
fn anonymous_type_option(&mut self, id: TypeId, ty: &Type, _docs: &Docs) {
13761376
self.src.h_defs("\ntypedef ");
13771377
self.src.h_defs("struct {\n");
13781378
self.src.h_defs("bool is_some;\n");
@@ -1383,7 +1383,7 @@ impl<'a> wit_bindgen_core::AnonymousTypeGenerator<'a> for InterfaceGenerator<'a>
13831383
self.print_typedef_target(id);
13841384
}
13851385

1386-
fn anonymous_type_result(&mut self, id: TypeId, ty: &Result_, docs: &Docs) {
1386+
fn anonymous_type_result(&mut self, id: TypeId, ty: &Result_, _docs: &Docs) {
13871387
self.src.h_defs("\ntypedef ");
13881388
self.src.h_defs(
13891389
"struct {
@@ -1409,7 +1409,7 @@ impl<'a> wit_bindgen_core::AnonymousTypeGenerator<'a> for InterfaceGenerator<'a>
14091409
self.print_typedef_target(id);
14101410
}
14111411

1412-
fn anonymous_type_list(&mut self, id: TypeId, ty: &Type, docs: &Docs) {
1412+
fn anonymous_type_list(&mut self, id: TypeId, ty: &Type, _docs: &Docs) {
14131413
self.src.h_defs("\ntypedef ");
14141414
self.src.h_defs("struct {\n");
14151415
let ty = self.gen.type_name(ty);
@@ -1420,15 +1420,15 @@ impl<'a> wit_bindgen_core::AnonymousTypeGenerator<'a> for InterfaceGenerator<'a>
14201420
self.print_typedef_target(id);
14211421
}
14221422

1423-
fn anonymous_type_future(&mut self, id: TypeId, ty: &Option<Type>, docs: &Docs) {
1423+
fn anonymous_type_future(&mut self, _id: TypeId, _ty: &Option<Type>, _docs: &Docs) {
14241424
todo!("print_anonymous_type for future");
14251425
}
14261426

1427-
fn anonymous_type_stream(&mut self, id: TypeId, ty: &Stream, docs: &Docs) {
1427+
fn anonymous_type_stream(&mut self, _id: TypeId, _ty: &Stream, _docs: &Docs) {
14281428
todo!("print_anonymous_type for stream");
14291429
}
14301430

1431-
fn anonymous_typ_type(&mut self, id: TypeId, ty: &Type, docs: &Docs) {
1431+
fn anonymous_typ_type(&mut self, _id: TypeId, _ty: &Type, _docs: &Docs) {
14321432
todo!("print_anonymous_type for typ");
14331433
}
14341434
}
@@ -3098,16 +3098,6 @@ impl Source {
30983098
}
30993099
}
31003100

3101-
trait SourceExt {
3102-
fn as_source(&mut self) -> &mut wit_bindgen_core::Source;
3103-
}
3104-
3105-
impl SourceExt for wit_bindgen_core::Source {
3106-
fn as_source(&mut self) -> &mut wit_bindgen_core::Source {
3107-
self
3108-
}
3109-
}
3110-
31113101
fn wasm_type(ty: WasmType) -> &'static str {
31123102
match ty {
31133103
WasmType::I32 => "int32_t",

crates/core/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub trait WorldGenerator {
3737
for (name, import) in world.imports.iter() {
3838
match import {
3939
WorldItem::Function(f) => funcs.push((unwrap_name(name), f)),
40-
WorldItem::Interface(id) => self.import_interface(resolve, name, *id, files),
40+
WorldItem::Interface { id, .. } => self.import_interface(resolve, name, *id, files),
4141
WorldItem::Type(id) => types.push((unwrap_name(name), *id)),
4242
}
4343
}
@@ -61,7 +61,7 @@ pub trait WorldGenerator {
6161
for (name, export) in world.exports.iter() {
6262
match export {
6363
WorldItem::Function(f) => funcs.push((unwrap_name(name), f)),
64-
WorldItem::Interface(id) => interfaces.push((name, id)),
64+
WorldItem::Interface { id, .. } => interfaces.push((name, id)),
6565
WorldItem::Type(_) => unreachable!(),
6666
}
6767
}

crates/core/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl Types {
7777
WorldItem::Function(f) => {
7878
self.type_info_func(resolve, f, import);
7979
}
80-
WorldItem::Interface(id) => {
80+
WorldItem::Interface { id, stability: _ } => {
8181
for (_, f) in resolve.interfaces[*id].functions.iter() {
8282
self.type_info_func(resolve, f, import);
8383
}

crates/go/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use wit_bindgen_core::{Direction, Files, Source, WorldGenerator};
1414
mod bindgen;
1515
mod imports;
1616
mod interface;
17-
mod path;
1817

1918
#[derive(Debug, Clone)]
2019
#[cfg_attr(feature = "clap", derive(clap::Args))]

crates/go/src/path.rs

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)