Skip to content

Commit

Permalink
Merge pull request #102 from ydnar/ydnar/minor-fixes
Browse files Browse the repository at this point in the history
wit: minor fixes
  • Loading branch information
ydnar authored Jun 8, 2024
2 parents ac8a3a3 + fb9d866 commit bff8cbc
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 6 deletions.
5 changes: 3 additions & 2 deletions testdata/wasi/cli.wit.json.golden.wit
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ interface types {
/// `error-code::read-only`.
///
/// Note: This is similar to `openat` in POSIX.
open-at: func(path-flags: path-flags, path: string, open-flags: open-flags, flags: descriptor-flags) -> result<descriptor, error-code>;
open-at: func(path-flags: path-flags, path: string, open-flags: open-flags, %flags: descriptor-flags) -> result<descriptor, error-code>;

/// Read from a descriptor, without using and updating the descriptor's offset.
///
Expand Down Expand Up @@ -1844,7 +1844,7 @@ interface udp {
/// - <https://man7.org/linux/man-pages/man2/connect.2.html>
/// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-connect>
/// - <https://man.freebsd.org/cgi/man.cgi?connect>
stream: func(remote-address: option<ip-socket-address>) -> result<tuple<incoming-datagram-stream, outgoing-datagram-stream>, error-code>;
%stream: func(remote-address: option<ip-socket-address>) -> result<tuple<incoming-datagram-stream, outgoing-datagram-stream>, error-code>;

/// Create a `pollable` which will resolve once the socket is ready for I/O.
///
Expand Down Expand Up @@ -2142,6 +2142,7 @@ world imports {
import wasi:random/insecure@0.2.0;
import wasi:random/insecure-seed@0.2.0;
}

world command {
import environment;
import exit;
Expand Down
8 changes: 5 additions & 3 deletions testdata/wasi/http.wit.json.golden.wit
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ interface types {
/// `error-code::read-only`.
///
/// Note: This is similar to `openat` in POSIX.
open-at: func(path-flags: path-flags, path: string, open-flags: open-flags, flags: descriptor-flags) -> result<descriptor, error-code>;
open-at: func(path-flags: path-flags, path: string, open-flags: open-flags, %flags: descriptor-flags) -> result<descriptor, error-code>;

/// Read from a descriptor, without using and updating the descriptor's offset.
///
Expand Down Expand Up @@ -1762,7 +1762,7 @@ interface udp {
/// - <https://man7.org/linux/man-pages/man2/connect.2.html>
/// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-connect>
/// - <https://man.freebsd.org/cgi/man.cgi?connect>
stream: func(remote-address: option<ip-socket-address>) -> result<tuple<incoming-datagram-stream, outgoing-datagram-stream>, error-code>;
%stream: func(remote-address: option<ip-socket-address>) -> result<tuple<incoming-datagram-stream, outgoing-datagram-stream>, error-code>;

/// Create a `pollable` which will resolve once the socket is ready for I/O.
///
Expand Down Expand Up @@ -2142,6 +2142,7 @@ world imports {
import wasi:random/insecure@0.2.0;
import wasi:random/insecure-seed@0.2.0;
}

world command {
import environment;
import exit;
Expand Down Expand Up @@ -2581,7 +2582,7 @@ interface types {
/// backpressure is to be applied when the user is consuming the body,
/// and for that backpressure to not inhibit delivery of the trailers if
/// the user does not read the entire body.
stream: func() -> result<input-stream>;
%stream: func() -> result<input-stream>;

/// Takes ownership of `incoming-body`, and returns a `future-trailers`.
/// This function will trap if the `input-stream` child is still alive.
Expand Down Expand Up @@ -2795,6 +2796,7 @@ world imports {
import outgoing-handler;
import wasi:clocks/wall-clock@0.2.0;
}

/// The `wasi:http/proxy` world captures a widely-implementable intersection of
/// hosts that includes HTTP forward and reverse proxies. Components targeting
/// this world may concurrently stream in and out any number of incoming and
Expand Down
3 changes: 3 additions & 0 deletions testdata/wit-parser/complex-include.wit.json.golden.wit
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@ world a {
import ai;
import bi;
}

world b {
import foo:bar/a;
import foo:bar/b;
}

world c {
import foo:bar/a;
import foo:bar/b;
}

world union-world {
import ai;
import bi;
Expand Down
3 changes: 3 additions & 0 deletions testdata/wit-parser/foreign-deps-union.wit.json.golden.wit
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,19 @@ world my-world {
import foo:wasi/clocks;
export foo:corp/saas;
}

world my-world2 {
import foo:wasi/filesystem;
import foo:wasi/clocks;
export foo;
export foo:corp/saas;
}

world bars-world {
import foo:some-pkg/the-default;
import foo:another-pkg/other-interface;
}

world unionw-world {
import foo:wasi/filesystem;
import foo:wasi/clocks;
Expand Down
2 changes: 2 additions & 0 deletions testdata/wit-parser/foreign-deps.wit.json.golden.wit
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ world my-world {
import foo:wasi/clocks;
export foo:corp/saas;
}

world my-world2 {
import foo:wasi/filesystem;
import foo:wasi/clocks;
export foo;
export foo:corp/saas;
}

world bars-world {
import foo:some-pkg/the-default;
import foo:another-pkg/other-interface;
Expand Down
1 change: 1 addition & 0 deletions testdata/wit-parser/include-reps.wit.json.golden.wit
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ world bar {
import a;
export b;
}

world foo {
import a;
export b;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package foo:foo;
world foo {
import a: func();
}

world bar {
import a: func();
}

world baz {
import b: func();
import a: func();
Expand Down
1 change: 1 addition & 0 deletions testdata/wit-parser/multi-file.wit.json.golden.wit
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ world more-depends-on-later-things {
import later-interface;
export later-interface;
}

world the-world {
import depend-on-me;
use depend-on-me.{x};
Expand Down
2 changes: 2 additions & 0 deletions testdata/wit-parser/union-fuzz-1.wit.json.golden.wit
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package foo:bar;

world xo {}

world name {}

world x {}
1 change: 1 addition & 0 deletions testdata/wit-parser/union-fuzz-2.wit.json.golden.wit
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package foo:bar;
world foo {
export foo: func() -> (name2: f32);
}

world bar {
record foo {}
export foo: func() -> (name2: f32);
Expand Down
2 changes: 2 additions & 0 deletions testdata/wit-parser/worlds-union-dedup.wit.json.golden.wit
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ world my-world-a {
import a1;
import b1;
}

world my-world-b {
import a1;
import b1;
}

world union-my-world {
import a1;
import b1;
Expand Down
2 changes: 2 additions & 0 deletions testdata/wit-parser/worlds-with-types.wit.json.golden.wit
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ world foo {
type b = a;
export c: func(a: a) -> b;
}

world bar {
import disambiguate;
use disambiguate.{t};
export foo: func() -> t;
}

world the-test {
record a { x: u32 }
variant b { c(a) }
Expand Down
5 changes: 4 additions & 1 deletion wit/wit.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ var witKeywords = map[string]bool{
"export": true,
"flags": true,
"func": true,
"future": true,
"import": true,
"include": true,
"interface": true,
Expand All @@ -351,6 +352,7 @@ var witKeywords = map[string]bool{
"resource": true,
"result": true,
"static": true,
"stream": true,
"type": true,
"variant": true,
"world": true,
Expand Down Expand Up @@ -861,7 +863,7 @@ func (p *Param) WIT(_ Node, _ string) string {
if p.Name == "" {
return p.Type.WIT(p, "")
}
return p.Name + ": " + p.Type.WIT(p, "")
return escape(p.Name) + ": " + p.Type.WIT(p, "")
}

// WITKind returns the WIT kind.
Expand Down Expand Up @@ -898,6 +900,7 @@ func (p *Package) WIT(ctx Node, _ string) string {
}
b.WriteString(w.WIT(p, name))
b.WriteRune('\n')
i++
return true
})
}
Expand Down

0 comments on commit bff8cbc

Please sign in to comment.