Skip to content

Commit 3faf486

Browse files
authored
Update how WIT is parsed with new helpers (#837)
* Update how WIT is parsed throughout Use the `Resolve::push_path` API added recently to wasm-tools to support more forms of input directories. * Bump crates to 0.18.0
1 parent a84d232 commit 3faf486

File tree

18 files changed

+58
-78
lines changed

18 files changed

+58
-78
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "wit-bindgen-cli"
33
authors = ["Alex Crichton <alex@alexcrichton.com>"]
4-
version = "0.17.1"
4+
version = "0.18.0"
55
edition = { workspace = true }
66
repository = 'https://github.com/bytecodealliance/wit-bindgen'
77
license = "Apache-2.0 WITH LLVM-exception"
@@ -34,14 +34,14 @@ wasm-metadata = "0.10.20"
3434
wit-parser = "0.14.0"
3535
wit-component = "0.21.0"
3636

37-
wit-bindgen-core = { path = 'crates/core', version = '0.17.1' }
38-
wit-bindgen-c = { path = 'crates/c', version = '0.17.1' }
39-
wit-bindgen-rust = { path = "crates/rust", version = "0.17.1" }
40-
wit-bindgen-teavm-java = { path = 'crates/teavm-java', version = '0.17.1' }
41-
wit-bindgen-go = { path = 'crates/go', version = '0.17.1' }
42-
wit-bindgen-csharp = { path = 'crates/csharp', version = '0.17.1' }
43-
wit-bindgen-markdown = { path = 'crates/markdown', version = '0.17.1' }
44-
wit-bindgen = { path = 'crates/guest-rust', version = '0.17.1', default-features = false }
37+
wit-bindgen-core = { path = 'crates/core', version = '0.18.0' }
38+
wit-bindgen-c = { path = 'crates/c', version = '0.18.0' }
39+
wit-bindgen-rust = { path = "crates/rust", version = "0.18.0" }
40+
wit-bindgen-teavm-java = { path = 'crates/teavm-java', version = '0.18.0' }
41+
wit-bindgen-go = { path = 'crates/go', version = '0.18.0' }
42+
wit-bindgen-csharp = { path = 'crates/csharp', version = '0.18.0' }
43+
wit-bindgen-markdown = { path = 'crates/markdown', version = '0.18.0' }
44+
wit-bindgen = { path = 'crates/guest-rust', version = '0.18.0', default-features = false }
4545

4646
[[bin]]
4747
name = "wit-bindgen"

crates/c/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "wit-bindgen-c"
33
authors = ["Alex Crichton <alex@alexcrichton.com>"]
4-
version = "0.17.1"
4+
version = "0.18.0"
55
edition.workspace = true
66
repository = 'https://github.com/bytecodealliance/wit-bindgen'
77
license = "Apache-2.0 WITH LLVM-exception"

crates/core/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "wit-bindgen-core"
33
authors = ["Alex Crichton <alex@alexcrichton.com>"]
4-
version = "0.17.1"
4+
version = "0.18.0"
55
edition.workspace = true
66
repository = 'https://github.com/bytecodealliance/wit-bindgen'
77
license = "Apache-2.0 WITH LLVM-exception"
@@ -17,4 +17,3 @@ doctest = false
1717
[dependencies]
1818
wit-parser = { workspace = true }
1919
anyhow = { workspace = true }
20-
wit-component = { workspace = true }

crates/csharp/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "wit-bindgen-csharp"
33
authors = ["Timmy Silesmo <silesmo@nor2.io>"]
4-
version = "0.17.1"
4+
version = "0.18.0"
55
edition.workspace = true
66
repository = 'https://github.com/bytecodealliance/wit-bindgen'
77
license = "Apache-2.0 WITH LLVM-exception"

crates/csharp/src/lib.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
mod component_type_object;
22

33
use anyhow::Result;
4-
use heck::{ToLowerCamelCase, ToShoutySnakeCase, ToSnakeCase, ToUpperCamelCase};
4+
use heck::{ToLowerCamelCase, ToShoutySnakeCase, ToUpperCamelCase};
55
use std::{
66
collections::{HashMap, HashSet},
77
fmt::Write,
@@ -17,7 +17,7 @@ use wit_bindgen_core::{
1717
uwrite, uwriteln,
1818
wit_parser::{
1919
Docs, Enum, Flags, FlagsRepr, Function, FunctionKind, Int, InterfaceId, Record, Resolve,
20-
Result_, SizeAlign, Tuple, Type, TypeDef, TypeDefKind, TypeId, TypeOwner, Variant, WorldId,
20+
Result_, SizeAlign, Tuple, Type, TypeDefKind, TypeId, TypeOwner, Variant, WorldId,
2121
WorldKey,
2222
},
2323
Files, InterfaceGenerator as _, Ns, WorldGenerator,
@@ -338,15 +338,15 @@ impl WorldGenerator for CSharp {
338338
public bool IsOk => Tag == OK;
339339
public bool IsErr => Tag == ERR;
340340
341-
public Ok AsOk
342-
{
343-
get
341+
public Ok AsOk
342+
{
343+
get
344344
{
345-
if (Tag == OK)
345+
if (Tag == OK)
346346
return (Ok)_value;
347-
else
347+
else
348348
throw new ArgumentException("expected OK, got " + Tag);
349-
}
349+
}
350350
}
351351
352352
public Err AsErr
@@ -406,7 +406,7 @@ impl WorldGenerator for CSharp {
406406
private struct ReturnArea
407407
{{
408408
private byte buffer;
409-
409+
410410
private int GetS32(int offset)
411411
{{
412412
ReadOnlySpan<byte> span = MemoryMarshal.CreateSpan(ref buffer, {0});
@@ -424,7 +424,7 @@ impl WorldGenerator for CSharp {
424424
public void SetF32(int offset, float value)
425425
{{
426426
Span<byte> span = this;
427-
427+
428428
BitConverter.TryWriteBytes(span.Slice(offset), value);
429429
}}
430430
@@ -441,7 +441,7 @@ impl WorldGenerator for CSharp {
441441
return Encoding.UTF8.GetString((byte*)p0, p1);
442442
}}
443443
}}
444-
444+
445445
[ThreadStatic]
446446
private static ReturnArea returnArea = default;
447447
",
@@ -478,7 +478,7 @@ impl WorldGenerator for CSharp {
478478
/* of WASI libc prevent us doing so. */
479479
/* See https://github.com/bytecodealliance/wit-bindgen/issues/777 */
480480
/* and https://github.com/WebAssembly/wasi-libc/issues/452 */
481-
/* The component model `start` function might be an alternative to this depending on whether it
481+
/* The component model `start` function might be an alternative to this depending on whether it
482482
/* has the same constraints as `cabi_realloc` */
483483
__attribute__((__weak__, __export_name__("cabi_realloc")))
484484
void *cabi_realloc(void *ptr, size_t old_size, size_t align, size_t new_size) {
@@ -535,7 +535,7 @@ impl WorldGenerator for CSharp {
535535
let body = format!(
536536
"// Generated by `wit-bindgen` {version}. DO NOT EDIT!
537537
{CSHARP_IMPORTS}
538-
538+
539539
namespace {fully_qualified_namespace};
540540
541541
public partial class {stub_class_name} : {interface_or_class_name} {{
@@ -614,7 +614,7 @@ impl WorldGenerator for CSharp {
614614
{CSHARP_IMPORTS}
615615
616616
namespace {namespace};
617-
617+
618618
public interface {interface_name} {{
619619
{body}
620620
}}
@@ -839,14 +839,14 @@ impl InterfaceGenerator<'_> {
839839
private struct ReturnArea
840840
{{
841841
private byte buffer;
842-
842+
843843
private int GetS32(int offset)
844844
{{
845845
ReadOnlySpan<byte> span = MemoryMarshal.CreateSpan(ref buffer, {0});
846846
847847
return BitConverter.ToInt32(span.Slice(offset, 4));
848848
}}
849-
849+
850850
public void SetS8(int offset, int value)
851851
{{
852852
Span<byte> span = MemoryMarshal.CreateSpan(ref buffer, {0});
@@ -871,7 +871,7 @@ impl InterfaceGenerator<'_> {
871871
public void SetF32(int offset, float value)
872872
{{
873873
Span<byte> span = this;
874-
874+
875875
BitConverter.TryWriteBytes(span.Slice(offset), value);
876876
}}
877877
@@ -888,7 +888,7 @@ impl InterfaceGenerator<'_> {
888888
return Encoding.UTF8.GetString((byte*)p0, p1);
889889
}}
890890
}}
891-
891+
892892
[ThreadStatic]
893893
private static ReturnArea returnArea = default;
894894
",

crates/go/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "wit-bindgen-go"
33
authors = ["Mossaka <duibao55328@gmail.com>"]
4-
version = "0.17.1"
4+
version = "0.18.0"
55
edition.workspace = true
66
repository = 'https://github.com/bytecodealliance/wit-bindgen'
77
license = "Apache-2.0 WITH LLVM-exception"

crates/guest-rust/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "wit-bindgen"
33
authors = ["Alex Crichton <alex@alexcrichton.com>"]
4-
version = "0.17.1"
4+
version = "0.18.0"
55
edition.workspace = true
66
repository = 'https://github.com/bytecodealliance/wit-bindgen'
77
license = "Apache-2.0 WITH LLVM-exception"
@@ -12,7 +12,7 @@ Used when compiling Rust programs to the component model.
1212
"""
1313

1414
[dependencies]
15-
wit-bindgen-rust-macro = { path = "../rust-macro", optional = true, version = "0.17.1" }
15+
wit-bindgen-rust-macro = { path = "../rust-macro", optional = true, version = "0.18.0" }
1616
bitflags = { workspace = true }
1717

1818
[features]

crates/markdown/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "wit-bindgen-markdown"
3-
version = "0.17.1"
3+
version = "0.18.0"
44
edition.workspace = true
55
repository = 'https://github.com/bytecodealliance/wit-bindgen'
66
license = "Apache-2.0 WITH LLVM-exception"

crates/rust-macro/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "wit-bindgen-rust-macro"
33
authors = ["Alex Crichton <alex@alexcrichton.com>"]
4-
version = "0.17.1"
4+
version = "0.18.0"
55
edition.workspace = true
66
repository = 'https://github.com/bytecodealliance/wit-bindgen'
77
license = "Apache-2.0 WITH LLVM-exception"
@@ -21,5 +21,4 @@ syn = { version = "2.0", features = ["printing"] }
2121
quote = "1"
2222
wit-bindgen-core = { workspace = true }
2323
wit-bindgen-rust = { workspace = true }
24-
wit-component = { workspace = true }
2524
anyhow = { workspace = true }

0 commit comments

Comments
 (0)