Skip to content

Commit

Permalink
Convert to resources.
Browse files Browse the repository at this point in the history
Convert `descriptor` and `directory-entry-stream` to resources, and update
the dependencies to account for the changes in WebAssembly/wasi-io#46 and
WebAssembly/wasi-clocks#50.
  • Loading branch information
sunfishcode committed Sep 13, 2023
1 parent 9675a4b commit 06cd9c3
Show file tree
Hide file tree
Showing 11 changed files with 2,334 additions and 2,206 deletions.
1,439 changes: 0 additions & 1,439 deletions example-world.md

Large diffs are not rendered by default.

1,530 changes: 1,530 additions & 0 deletions imports.md

Large diffs are not rendered by default.

17 changes: 6 additions & 11 deletions wit/deps.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
[clocks]
url = "https://github.com/WebAssembly/wasi-clocks/archive/main.tar.gz"
sha256 = "1ed7e35b3f9738663854f0dd92a95bfadc410ea07170501f5c2fec0cc24e3d57"
sha512 = "ef1e23704a8a8436fd3718593d4c4d8b6d1c64dad3595b7496c0888ca14b725046f2900109800faca1bc8c14f237cdcaca791dba8284e1ad50105ab2d036825b"
url = "https://github.com/sunfishcode/wasi-clocks/archive/resources.tar.gz"
sha256 = "ea955af7a152f85941b651c5b07345c4f077ae7f9e996c909ab8cc0a68c0120e"
sha512 = "114bc4f583a487cf1ccfdd6efa25c4c60cf637d4501a189eebd4b1d52aec2c8eb63ae14ce494db53dfd25bc20f6c4b533dc6f2143537e5cd14ca80d5d4b6a49d"

[io]
url = "https://github.com/WebAssembly/wasi-io/archive/main.tar.gz"
sha256 = "a47690f7d4dba1683a42897cc65fe813409827d72cc93afe03b127ee81763e13"
sha512 = "661aa9cf9c67d7d712caccfbb3c317da01b033764892623c8902d9dcfdb67f3088889102b036d3ed19d818a5c2d151247b25d9f6fd145cdf433f325605a5a747"

[poll]
url = "https://github.com/WebAssembly/wasi-poll/archive/main.tar.gz"
sha256 = "d4c27124f4c137eb538b5c92ba5858ed9042e11b24a2eef85d14becd0b7f55de"
sha512 = "422c01b273b4b1377ece6f2e4ba0dfc609ca8ef30a3e0be0e172e1303fcf7b3ca4c470f4dea6c51bdf114b0f5c871ebc4934dfe3bf217d66ea689748df2b1e55"
url = "https://github.com/sunfishcode/wasi-io/archive/resources.tar.gz"
sha256 = "c01495e96837dbd33b8d8dd70b75a0bf2ee5795b6c85ab50701e870bbcf2ceb3"
sha512 = "fd8f60fad6560396d07d530efb76a4c54ce823d523528ba5ba61ccdc521e361c1e9660d0a77c02a5e6b80ea981cddedbaa703322f1ba502333784ea974edb835"
8 changes: 5 additions & 3 deletions wit/deps.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
io = "https://github.com/WebAssembly/wasi-io/archive/main.tar.gz"
poll = "https://github.com/WebAssembly/wasi-poll/archive/main.tar.gz"
clocks = "https://github.com/WebAssembly/wasi-clocks/archive/main.tar.gz"
# Temporarily use the resources branches.
#io = "https://github.com/WebAssembly/wasi-io/archive/main.tar.gz"
io = "https://github.com/sunfishcode/wasi-io/archive/resources.tar.gz"
#clocks = "https://github.com/WebAssembly/wasi-clocks/archive/main.tar.gz"
clocks = "https://github.com/sunfishcode/wasi-clocks/archive/resources.tar.gz"
2 changes: 1 addition & 1 deletion wit/deps/clocks/monotonic-clock.wit
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
///
/// It is intended for measuring elapsed time.
interface monotonic-clock {
use wasi:poll/poll.{pollable}
use wasi:io/poll.{pollable}

/// A timestamp in nanoseconds.
type instant = u64
Expand Down
17 changes: 2 additions & 15 deletions wit/deps/clocks/timezone.wit
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
interface timezone {
use wall-clock.{datetime}

/// A timezone.
///
/// In timezones that recognize daylight saving time, also known as daylight
/// time and summer time, the information returned from the functions varies
/// over time to reflect these adjustments.
///
/// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources).
type timezone = u32

/// Return information needed to display the given `datetime`. This includes
/// the UTC offset, the time zone name, and a flag indicating whether
/// daylight saving time is active.
///
/// If the timezone cannot be determined for the given `datetime`, return a
/// `timezone-display` for `UTC` with a `utc-offset` of 0 and no daylight
/// saving time.
display: func(this: timezone, when: datetime) -> timezone-display
display: func(when: datetime) -> timezone-display

/// The same as `display`, but only return the UTC offset.
utc-offset: func(this: timezone, when: datetime) -> s32

/// Dispose of the specified input-stream, after which it may no longer
/// be used.
drop-timezone: func(this: timezone)
utc-offset: func(when: datetime) -> s32

/// Information useful for displaying the timezone of a specific `datetime`.
///
Expand Down
2 changes: 1 addition & 1 deletion wit/deps/clocks/world.wit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package wasi:clocks

world example-world {
world imports {
import monotonic-clock
import wall-clock
import timezone
Expand Down
34 changes: 34 additions & 0 deletions wit/deps/io/poll.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package wasi:io

/// A poll API intended to let users wait for I/O events on multiple handles
/// at once.
interface poll {
/// A "pollable" handle.
resource pollable

/// Poll for completion on a set of pollables.
///
/// This function takes a list of pollables, which identify I/O sources of
/// interest, and waits until one or more of the events is ready for I/O.
///
/// The result `list<u32>` contains one or more indices of handles in the
/// argument list that is ready for I/O.
///
/// If the list contains more elements than can be indexed with a `u32`
/// value, this function traps.
///
/// A timeout can be implemented by adding a pollable from the
/// wasi-clocks API to the list.
///
/// This function does not return a `result`; polling in itself does not
/// do any I/O so it doesn't fail. If any of the I/O sources identified by
/// the pollables has an error, it is indicated by marking the source as
/// being reaedy for I/O.
poll-list: func(in: list<pollable>) -> list<u32>

/// Poll for completion on a single pollable.
///
/// This function is similar to `poll-list`, but operates on only a single
/// pollable. When it returns, the handle is ready for I/O.
poll-one: func(in: pollable)
}
Loading

0 comments on commit 06cd9c3

Please sign in to comment.