Skip to content

Commit

Permalink
fix(wasi-http): update to fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-jerry-ye committed Aug 7, 2024
1 parent 4643565 commit ab1c89b
Show file tree
Hide file tree
Showing 44 changed files with 693 additions and 265 deletions.
2 changes: 1 addition & 1 deletion examples/wasi-http/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.DEFAULT_GOAL = build

serve:
serve: build
@wasmtime serve target/wasm/debug/build/gen/gen.wasm

build:
Expand Down
2 changes: 1 addition & 1 deletion examples/wasi-http/gen/moon.pkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"link": {
"wasm": {
"exports": ["cabi_realloc:cabi_realloc", "wasmExportHandle:wasi:http/[email protected].0#handle"],
"exports": ["cabi_realloc:cabi_realloc", "wasmExportHandle:wasi:http/[email protected].1#handle"],
"export-memory-name": "memory",
"heap-start-address": 0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ It is intended to be portable at least between Unix-family platforms and
Windows.

A monotonic clock is a clock which has an unspecified initial value, and
successive reads of the clock will produce non-decreasing values.

It is intended for measuring elapsed time.
successive reads of the clock will produce non-decreasing values.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Generated by `wit-bindgen` 0.28.0. DO NOT EDIT!
fn wasmImportNow() -> Int64 = "wasi:clocks/[email protected].0" "now"
fn wasmImportNow() -> Int64 = "wasi:clocks/[email protected].1" "now"

/// Read the current value of the clock.
///
Expand All @@ -10,7 +10,7 @@ pub fn now() -> UInt64 {
return result.to_uint64()
}

fn wasmImportResolution() -> Int64 = "wasi:clocks/[email protected].0" "resolution"
fn wasmImportResolution() -> Int64 = "wasi:clocks/[email protected].1" "resolution"

/// Query the resolution of the clock. Returns the duration of time
/// corresponding to a clock tick.
Expand All @@ -19,20 +19,19 @@ pub fn resolution() -> UInt64 {
return result.to_uint64()
}

fn wasmImportSubscribeInstant(p0 : Int64) -> Int = "wasi:clocks/[email protected].0" "subscribe-instant"
fn wasmImportSubscribeInstant(p0 : Int64) -> Int = "wasi:clocks/[email protected].1" "subscribe-instant"

/// Create a `pollable` which will resolve once the specified instant
/// occured.
/// has occurred.
pub fn subscribe_instant(when : UInt64) -> @poll.Pollable {
let result : Int = wasmImportSubscribeInstant(when.to_int64())
return @poll.Pollable::Pollable(result)
}

fn wasmImportSubscribeDuration(p0 : Int64) -> Int = "wasi:clocks/[email protected].0" "subscribe-duration"
fn wasmImportSubscribeDuration(p0 : Int64) -> Int = "wasi:clocks/[email protected].1" "subscribe-duration"

/// Create a `pollable` which will resolve once the given duration has
/// elapsed, starting at the time at which this function was called.
/// occured.
/// Create a `pollable` that will resolve after the specified duration has
/// elapsed from the time this function is invoked.
pub fn subscribe_duration(when : UInt64) -> @poll.Pollable {
let result : Int = wasmImportSubscribeDuration(when.to_int64())
return @poll.Pollable::Pollable(result)
Expand Down
183 changes: 95 additions & 88 deletions examples/wasi-http/interface/imports/wasi/http/types/top.mbt

Large diffs are not rendered by default.

16 changes: 7 additions & 9 deletions examples/wasi-http/interface/imports/wasi/io/error/top.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,23 @@
/// `wasi:io/streams/stream-error` type.
///
/// To provide more specific error information, other interfaces may
/// provide functions to further "downcast" this error into more specific
/// error information. For example, `error`s returned in streams derived
/// from filesystem types to be described using the filesystem's own
/// error-code type, using the function
/// `wasi:filesystem/types/filesystem-error-code`, which takes a parameter
/// `borrow<error>` and returns
/// `option<wasi:filesystem/types/error-code>`.
/// offer functions to "downcast" this error into more specific types. For example,
/// errors returned from streams derived from filesystem types can be described using
/// the filesystem's own error-code type. This is done using the function
/// `wasi:filesystem/types/filesystem-error-code`, which takes a `borrow<error>`
/// parameter and returns an `option<wasi:filesystem/types/error-code>`.
///
/// The set of functions which can "downcast" an `error` into a more
/// concrete type is open.
pub type Error_ Int derive(Show, Eq)

fn wasmImportResourceDropError_(resource : Int) = "wasi:io/[email protected].0" "[resource-drop]error"
fn wasmImportResourceDropError_(resource : Int) = "wasi:io/[email protected].1" "[resource-drop]error"

pub fn Error_::drop(self : Error_) -> Unit {
wasmImportResourceDropError_(self.0)
}

fn wasmImportMethodErrorToDebugString(p0 : Int, p1 : Int) = "wasi:io/[email protected].0" "[method]error.to-debug-string"
fn wasmImportMethodErrorToDebugString(p0 : Int, p1 : Int) = "wasi:io/[email protected].1" "[method]error.to-debug-string"

/// Returns a string that is suitable to assist humans in debugging
/// this error.
Expand Down
15 changes: 8 additions & 7 deletions examples/wasi-http/interface/imports/wasi/io/poll/top.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
/// `pollable` represents a single I/O event which may be ready, or not.
pub type Pollable Int derive(Show, Eq)

fn wasmImportResourceDropPollable(resource : Int) = "wasi:io/[email protected].0" "[resource-drop]pollable"
fn wasmImportResourceDropPollable(resource : Int) = "wasi:io/[email protected].1" "[resource-drop]pollable"

pub fn Pollable::drop(self : Pollable) -> Unit {
wasmImportResourceDropPollable(self.0)
}

fn wasmImportMethodPollableReady(p0 : Int) -> Int = "wasi:io/[email protected].0" "[method]pollable.ready"
fn wasmImportMethodPollableReady(p0 : Int) -> Int = "wasi:io/[email protected].1" "[method]pollable.ready"

/// Return the readiness of a pollable. This function never blocks.
///
Expand All @@ -18,7 +18,7 @@ pub fn Pollable::ready(self : Pollable) -> Bool {
return result != 0
}

fn wasmImportMethodPollableBlock(p0 : Int) = "wasi:io/[email protected].0" "[method]pollable.block"
fn wasmImportMethodPollableBlock(p0 : Int) = "wasi:io/[email protected].1" "[method]pollable.block"

/// `block` returns immediately if the pollable is ready, and otherwise
/// blocks until ready.
Expand All @@ -29,7 +29,7 @@ pub fn Pollable::block(self : Pollable) -> Unit {
wasmImportMethodPollableBlock(self.0)
}

fn wasmImportPoll(p0 : Int, p1 : Int, p2 : Int) = "wasi:io/[email protected].0" "poll"
fn wasmImportPoll(p0 : Int, p1 : Int, p2 : Int) = "wasi:io/[email protected].1" "poll"

/// Poll for completion on a set of pollables.
///
Expand All @@ -39,16 +39,17 @@ fn wasmImportPoll(p0 : Int, p1 : Int, p2 : Int) = "wasi:io/[email protected]" "poll"
/// 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.
/// This function traps if either:
/// - the list is empty, or:
/// - the list contains more elements than can be indexed with a `u32` value.
///
/// 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.
/// being ready for I/O.
pub fn poll(in : Array[Pollable]) -> Array[UInt] {
let address = @ffi.malloc(in.length() * 4)
for index = 0; index < in.length(); index = index + 1 {
Expand Down
42 changes: 23 additions & 19 deletions examples/wasi-http/interface/imports/wasi/io/streams/top.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub enum StreamError {
/// for using `wasi:io/poll`.
pub type InputStream Int derive(Show, Eq)

fn wasmImportResourceDropInputStream(resource : Int) = "wasi:io/[email protected].0" "[resource-drop]input-stream"
fn wasmImportResourceDropInputStream(resource : Int) = "wasi:io/[email protected].1" "[resource-drop]input-stream"

pub fn InputStream::drop(self : InputStream) -> Unit {
wasmImportResourceDropInputStream(self.0)
Expand All @@ -29,15 +29,19 @@ pub fn InputStream::drop(self : InputStream) -> Unit {
/// promptly, which could even be zero. To wait for the stream to be ready to
/// accept data, the `subscribe` function to obtain a `pollable` which can be
/// polled for using `wasi:io/poll`.
///
/// Dropping an `output-stream` while there's still an active write in
/// progress may result in the data being lost. Before dropping the stream,
/// be sure to fully flush your writes.
pub type OutputStream Int derive(Show, Eq)

fn wasmImportResourceDropOutputStream(resource : Int) = "wasi:io/[email protected].0" "[resource-drop]output-stream"
fn wasmImportResourceDropOutputStream(resource : Int) = "wasi:io/[email protected].1" "[resource-drop]output-stream"

pub fn OutputStream::drop(self : OutputStream) -> Unit {
wasmImportResourceDropOutputStream(self.0)
}

fn wasmImportMethodInputStreamRead(p0 : Int, p1 : Int64, p2 : Int) = "wasi:io/[email protected].0" "[method]input-stream.read"
fn wasmImportMethodInputStreamRead(p0 : Int, p1 : Int64, p2 : Int) = "wasi:io/[email protected].1" "[method]input-stream.read"

/// Perform a non-blocking read from the stream.
///
Expand Down Expand Up @@ -93,7 +97,7 @@ pub fn InputStream::read(
return lifted6
}

fn wasmImportMethodInputStreamBlockingRead(p0 : Int, p1 : Int64, p2 : Int) = "wasi:io/[email protected].0" "[method]input-stream.blocking-read"
fn wasmImportMethodInputStreamBlockingRead(p0 : Int, p1 : Int64, p2 : Int) = "wasi:io/[email protected].1" "[method]input-stream.blocking-read"

/// Read bytes from a stream, after blocking until at least one byte can
/// be read. Except for blocking, behavior is identical to `read`.
Expand Down Expand Up @@ -125,7 +129,7 @@ pub fn InputStream::blocking_read(
return lifted6
}

fn wasmImportMethodInputStreamSkip(p0 : Int, p1 : Int64, p2 : Int) = "wasi:io/[email protected].0" "[method]input-stream.skip"
fn wasmImportMethodInputStreamSkip(p0 : Int, p1 : Int64, p2 : Int) = "wasi:io/[email protected].1" "[method]input-stream.skip"

/// Skip bytes from a stream. Returns number of bytes skipped.
///
Expand Down Expand Up @@ -156,7 +160,7 @@ pub fn InputStream::skip(
return lifted6
}

fn wasmImportMethodInputStreamBlockingSkip(p0 : Int, p1 : Int64, p2 : Int) = "wasi:io/[email protected].0" "[method]input-stream.blocking-skip"
fn wasmImportMethodInputStreamBlockingSkip(p0 : Int, p1 : Int64, p2 : Int) = "wasi:io/[email protected].1" "[method]input-stream.blocking-skip"

/// Skip bytes from a stream, after blocking until at least one byte
/// can be skipped. Except for blocking behavior, identical to `skip`.
Expand Down Expand Up @@ -185,7 +189,7 @@ pub fn InputStream::blocking_skip(
return lifted6
}

fn wasmImportMethodInputStreamSubscribe(p0 : Int) -> Int = "wasi:io/[email protected].0" "[method]input-stream.subscribe"
fn wasmImportMethodInputStreamSubscribe(p0 : Int) -> Int = "wasi:io/[email protected].1" "[method]input-stream.subscribe"

/// Create a `pollable` which will resolve once either the specified stream
/// has bytes available to read or the other end of the stream has been
Expand All @@ -198,7 +202,7 @@ pub fn InputStream::subscribe(self : InputStream) -> @poll.Pollable {
return @poll.Pollable::Pollable(result)
}

fn wasmImportMethodOutputStreamCheckWrite(p0 : Int, p1 : Int) = "wasi:io/[email protected].0" "[method]output-stream.check-write"
fn wasmImportMethodOutputStreamCheckWrite(p0 : Int, p1 : Int) = "wasi:io/[email protected].1" "[method]output-stream.check-write"

/// Check readiness for writing. This function never blocks.
///
Expand Down Expand Up @@ -233,7 +237,7 @@ pub fn OutputStream::check_write(
return lifted6
}

fn wasmImportMethodOutputStreamWrite(p0 : Int, p1 : Int, p2 : Int, p3 : Int) = "wasi:io/[email protected].0" "[method]output-stream.write"
fn wasmImportMethodOutputStreamWrite(p0 : Int, p1 : Int, p2 : Int, p3 : Int) = "wasi:io/[email protected].1" "[method]output-stream.write"

/// Perform a write. This function never blocks.
///
Expand Down Expand Up @@ -284,7 +288,7 @@ fn wasmImportMethodOutputStreamBlockingWriteAndFlush(
p1 : Int,
p2 : Int,
p3 : Int
) = "wasi:io/[email protected].0" "[method]output-stream.blocking-write-and-flush"
) = "wasi:io/[email protected].1" "[method]output-stream.blocking-write-and-flush"

/// Perform a write of up to 4096 bytes, and then flush the stream. Block
/// until all of these operations are complete, or an error occurs.
Expand Down Expand Up @@ -341,7 +345,7 @@ pub fn OutputStream::blocking_write_and_flush(
return lifted6
}

fn wasmImportMethodOutputStreamFlush(p0 : Int, p1 : Int) = "wasi:io/[email protected].0" "[method]output-stream.flush"
fn wasmImportMethodOutputStreamFlush(p0 : Int, p1 : Int) = "wasi:io/[email protected].1" "[method]output-stream.flush"

/// Request to flush buffered output. This function never blocks.
///
Expand Down Expand Up @@ -375,7 +379,7 @@ pub fn OutputStream::flush(self : OutputStream) -> Result[Unit, StreamError] {
return lifted6
}

fn wasmImportMethodOutputStreamBlockingFlush(p0 : Int, p1 : Int) = "wasi:io/[email protected].0" "[method]output-stream.blocking-flush"
fn wasmImportMethodOutputStreamBlockingFlush(p0 : Int, p1 : Int) = "wasi:io/[email protected].1" "[method]output-stream.blocking-flush"

/// Request to flush buffered output, and block until flush completes
/// and stream is ready for writing again.
Expand Down Expand Up @@ -403,10 +407,10 @@ pub fn OutputStream::blocking_flush(
return lifted6
}

fn wasmImportMethodOutputStreamSubscribe(p0 : Int) -> Int = "wasi:io/[email protected].0" "[method]output-stream.subscribe"
fn wasmImportMethodOutputStreamSubscribe(p0 : Int) -> Int = "wasi:io/[email protected].1" "[method]output-stream.subscribe"

/// Create a `pollable` which will resolve once the output-stream
/// is ready for more writing, or an error has occured. When this
/// is ready for more writing, or an error has occurred. When this
/// pollable is ready, `check-write` will return `ok(n)` with n>0, or an
/// error.
///
Expand All @@ -420,7 +424,7 @@ pub fn OutputStream::subscribe(self : OutputStream) -> @poll.Pollable {
return @poll.Pollable::Pollable(result)
}

fn wasmImportMethodOutputStreamWriteZeroes(p0 : Int, p1 : Int64, p2 : Int) = "wasi:io/[email protected].0" "[method]output-stream.write-zeroes"
fn wasmImportMethodOutputStreamWriteZeroes(p0 : Int, p1 : Int64, p2 : Int) = "wasi:io/[email protected].1" "[method]output-stream.write-zeroes"

/// Write zeroes to a stream.
///
Expand Down Expand Up @@ -457,7 +461,7 @@ fn wasmImportMethodOutputStreamBlockingWriteZeroesAndFlush(
p0 : Int,
p1 : Int64,
p2 : Int
) = "wasi:io/[email protected].0" "[method]output-stream.blocking-write-zeroes-and-flush"
) = "wasi:io/[email protected].1" "[method]output-stream.blocking-write-zeroes-and-flush"

/// Perform a write of up to 4096 zeroes, and then flush the stream.
/// Block until all of these operations are complete, or an error
Expand Down Expand Up @@ -512,11 +516,11 @@ pub fn OutputStream::blocking_write_zeroes_and_flush(
return lifted6
}

fn wasmImportMethodOutputStreamSplice(p0 : Int, p1 : Int, p2 : Int64, p3 : Int) = "wasi:io/[email protected].0" "[method]output-stream.splice"
fn wasmImportMethodOutputStreamSplice(p0 : Int, p1 : Int, p2 : Int64, p3 : Int) = "wasi:io/[email protected].1" "[method]output-stream.splice"

/// Read from one stream and write to another.
///
/// The behavior of splice is equivelant to:
/// The behavior of splice is equivalent to:
/// 1. calling `check-write` on the `output-stream`
/// 2. calling `read` on the `input-stream` with the smaller of the
/// `check-write` permitted length and the `len` provided to `splice`
Expand Down Expand Up @@ -558,7 +562,7 @@ fn wasmImportMethodOutputStreamBlockingSplice(
p1 : Int,
p2 : Int64,
p3 : Int
) = "wasi:io/[email protected].0" "[method]output-stream.blocking-splice"
) = "wasi:io/[email protected].1" "[method]output-stream.blocking-splice"

/// Read from one stream and write to another, with blocking.
///
Expand Down
30 changes: 15 additions & 15 deletions examples/wasi-http/wit/deps.lock
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
[cli]
sha256 = "285865a31d777181b075f39e92bcfe59c89cd6bacce660be1b9a627646956258"
sha512 = "da2622210a9e3eea82b99f1a5b8a44ce5443d009cb943f7bca0bf9cf4360829b289913d7ee727c011f0f72994ea7dc8e661ebcc0a6b34b587297d80cd9b3f7e8"
sha256 = "1de50b8e6940e73110cda10b7f90ca87a8fea886f0fa36c748f96dc70671ee38"
sha512 = "bbb6cd3e7b4d3237b6af9bfbb2633ccd2c4ea2a4f37b8c033255c7e0c1cb037be7f22ec1f8ca792cc8ec1942199582943979e646b4b272b85dcff7654eac51d0"

[clocks]
sha256 = "468b4d12892fe926b8eb5d398dbf579d566c93231fa44f415440572c695b7613"
sha512 = "e6b53a07221f1413953c9797c68f08b815fdaebf66419bbc1ea3e8b7dece73731062693634731f311a03957b268cf9cc509c518bd15e513c318aa04a8459b93a"
sha256 = "ea9d69ee803bc176e23e5268f5e24a2ac485dd1f62a0ab4c748e9d3f901f576f"
sha512 = "5efc22927c46cd56c41e5549ec775561c7fac2ea0d365abc0b55396d9475a7c9f984077a81f84a44a726f1c008fd2fadbffffa4fa53ecd5fbfd05afd379ab428"

[filesystem]
sha256 = "498c465cfd04587db40f970fff2185daa597d074c20b68a8bcbae558f261499b"
sha512 = "ead452f9b7bfb88593a502ec00d76d4228003d51c40fd0408aebc32d35c94673551b00230d730873361567cc209ec218c41fb4e95bad194268592c49e7964347"
sha256 = "cfe8c420e8b857de612ae2a3336680dae16b95c93c8ba3a6ff05b21210966740"
sha512 = "3c00c5544a58658e3e8025677091685286027fd49f37abf198c30b4e83b9e68f19723975aaa98794fba9f425ae9ef4f3dc0f5b9cf59203b5ecfaadf62b296f9a"

[http]
url = "https://github.com/WebAssembly/wasi-http/archive/v0.2.0.tar.gz"
sha256 = "8f44402bde16c48e28c47dc53eab0b26af5b3b3482a1852cf77673e0880ba1c1"
sha512 = "760695f9a25c25bf75a25b731cb21c3bda9e288e450edda823324ecbc73d5d798bbb5de2edad999566980836f037463ee9e57d61789d04b3f3e381475b1a9a0f"
url = "https://github.com/WebAssembly/wasi-http/archive/v0.2.1.tar.gz"
sha256 = "ff21e05571af02488371bebc9cb674e30e0613eda22e3c1d8e1aba36cdff5ee8"
sha512 = "1825b56f1718e822acf1b49929ead8f6493752b1d3524ce0974c3acdf656af2fc3fe5c8456b71ffab44583bc3ae7061d5a285d8a7203fcae949d44b3d81e2f2b"
deps = ["cli", "clocks", "filesystem", "io", "random", "sockets"]

[io]
sha256 = "7210e5653539a15478f894d4da24cc69d61924cbcba21d2804d69314a88e5a4c"
sha512 = "49184a1b0945a889abd52d25271172ed3dc2db6968fcdddb1bab7ee0081f4a3eeee0977ad2291126a37631c0d86eeea75d822fa8af224c422134500bf9f0f2bb"
sha256 = "2a74bd811adc46b5a0f19827ddbde89870e52b17615f4d0873f06fd977250caf"
sha512 = "94624f00c66e66203592cee820f80b1ba91ecdb71f682c154f25eaf71f8d8954197dcb64503bc21e72ed5e812af7eae876df47b7eb727b02db3a74a7ce0aefca"

[random]
sha256 = "7371d03c037d924caba2587fb2e7c5773a0d3c5fcecbf7971e0e0ba57973c53d"
sha512 = "964c4e8925a53078e4d94ba907b54f89a0b7e154f46823a505391471466c17f53c8692682e5c85771712acd88b348686173fc07c53a3cfe3d301b8cd8ddd0de4"
sha256 = "9e2d5056186f81b2e7f96bc97d2babd0341840f6abb4f170449b70992f1b598f"
sha512 = "67bf41d8d5d4b7af084124ee85196585225785969059f59e2f9ddb77ac1a8095cfe811ae29d076aac817418fa01064d7b9fbc0233930bace680758eeb21e36f8"

[sockets]
sha256 = "622bd28bbeb43736375dc02bd003fd3a016ff8ee91e14bab488325c6b38bf966"
sha512 = "5a63c1f36de0c4548e1d2297bdbededb28721cbad94ef7825c469eae29d7451c97e00b4c1d6730ee1ec0c4a5aac922961a2795762d4a0c3bb54e30a391a84bae"
sha256 = "4c361137a7e61e8b9a73da2a0899dd9ad1a0c2dfee7d310cf168704c57b7a07c"
sha512 = "348b4ef381f57aec23d48537df8b69ab8963587dcb056e94c4cd5657e217677a4ee2a545868a5c829d2334cc6b8b0a61d3e72797999f44d78553fbd3a73c5b8d"
2 changes: 1 addition & 1 deletion examples/wasi-http/wit/deps.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
http = "https://github.com/WebAssembly/wasi-http/archive/v0.2.0.tar.gz"
http = "https://github.com/WebAssembly/wasi-http/archive/v0.2.1.tar.gz"
5 changes: 4 additions & 1 deletion examples/wasi-http/wit/deps/cli/command.wit
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package wasi:cli@0.2.0;
package wasi:cli@0.2.1;

@since(version = 0.2.0)
world command {
@since(version = 0.2.0)
include imports;

@since(version = 0.2.0)
export run;
}
Loading

0 comments on commit ab1c89b

Please sign in to comment.