Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use WASI generated types instead of manual ones #3150

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e33496b
WIP
silwol Aug 10, 2022
f2a4b87
Generate bindings directly for now
silwol Aug 16, 2022
1a48fab
WIP
silwol Aug 16, 2022
8d36b49
WIP: something that builds with Errno from wasi-types-generated
silwol Aug 16, 2022
8fdbde4
WIP
silwol Aug 17, 2022
d1bc30d
WIP
silwol Aug 17, 2022
a54005f
WIP
silwol Aug 17, 2022
c6e2eb0
Eventtype
silwol Aug 17, 2022
6d53f23
Advice
silwol Aug 17, 2022
293c67f
WIP: Rights
silwol Aug 17, 2022
75be1d3
WIP: Eventrwflags
silwol Aug 18, 2022
40b5b53
WIP: Subcodeflags
silwol Aug 18, 2022
24f88fd
WIP: Clockid
silwol Aug 18, 2022
5207cc1
WIP: Dirent struct
silwol Aug 18, 2022
a3deb19
WIP: Fdflags
silwol Aug 18, 2022
7e8b835
WIP: Preopentype
silwol Aug 18, 2022
39fad86
WIP: Fdstat
silwol Aug 18, 2022
188d069
WIP: Fd
silwol Aug 18, 2022
06ced06
WIP
silwol Aug 19, 2022
005b05d
Sauhaufen!
silwol Aug 19, 2022
d471def
Builds again
silwol Aug 23, 2022
26f4207
Timestamp
silwol Aug 23, 2022
8f5a1a6
BusErrno
silwol Aug 23, 2022
60cbd02
Socktype
silwol Aug 24, 2022
0b86b61
Sockstatus
silwol Aug 24, 2022
7c70dcb
Sockoption
silwol Aug 24, 2022
4bb761f
Streamsecurity
silwol Aug 24, 2022
4abe73c
Addressfamily
silwol Aug 24, 2022
721ece0
Filesize
silwol Aug 24, 2022
fdb7850
Inode
silwol Aug 24, 2022
ef8021a
Device
silwol Aug 24, 2022
14f1f42
Linkcount
silwol Aug 24, 2022
9fefd22
snapshot0 Filestat
silwol Aug 25, 2022
19e979c
Filestat
silwol Aug 25, 2022
7f2bd8f
snapshot0 Whence
silwol Aug 25, 2022
a9290a5
Whence
silwol Aug 25, 2022
7c6164d
Fstflags
silwol Aug 25, 2022
aa8d6fa
Tty
silwol Aug 25, 2022
7aacc7a
Tid + Pid
silwol Aug 25, 2022
5ba7615
WIP, Temporary: reference wit-bindgen silwol/wasi-types-generation gi…
silwol Aug 26, 2022
04bddcb
Merge branch 'master' into silwol/wasi-types-generation
fschutt Aug 31, 2022
9849e12
Add wasi_io_typenames and wasi_snapshot0
fschutt Aug 31, 2022
04c4bee
Disable wasi_snapshot0 and wasi_io_typenames for now
fschutt Aug 31, 2022
d3fac0c
Update Cargo.lock
fschutt Aug 31, 2022
ce75765
Meeting discussion
fschutt Sep 2, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 115 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ members = [
"lib/vm",
"lib/wasi",
"lib/wasi-types",
"lib/wasi-types-generated",
"lib/wasi-experimental-io-devices",
"lib/wasi-local-networking",
"lib/types",
Expand Down
29 changes: 29 additions & 0 deletions lib/api/src/js/externals/memory_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,35 @@ impl<'a> MemoryView<'a> {
self.size
}

// TODO: do we want a proper implementation here instead?
/// Retrieve a slice of the memory contents.
///
/// # Safety
///
/// Until the returned slice is dropped, it is undefined behaviour to
/// modify the memory contents in any way including by calling a wasm
/// function that writes to the memory or by resizing the memory.
#[doc(hidden)]
pub unsafe fn data_unchecked(&self) -> &[u8] {
unimplemented!("direct data pointer access is not possible in JavaScript");
}

// TODO: do we want a proper implementation here instead?
/// Retrieve a mutable slice of the memory contents.
///
/// # Safety
///
/// This method provides interior mutability without an UnsafeCell. Until
/// the returned value is dropped, it is undefined behaviour to read or
/// write to the pointed-to memory in any way except through this slice,
/// including by calling a wasm function that reads the memory contents or
/// by resizing this Memory.
#[allow(clippy::mut_from_ref)]
#[doc(hidden)]
pub unsafe fn data_unchecked_mut(&self) -> &mut [u8] {
unimplemented!("direct data pointer access is not possible in JavaScript");
}

/// Returns the size (in [`Pages`]) of the `Memory`.
///
/// # Example
Expand Down
1 change: 1 addition & 0 deletions lib/types/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ macro_rules! primitives {
)*)
}
primitives! {
bool
i8 u8
i16 u16
i32 u32
Expand Down
7 changes: 5 additions & 2 deletions lib/wasi-experimental-io-devices/src/link-ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use std::collections::{BTreeSet, VecDeque};
use std::convert::TryInto;
use std::io::{Read, Seek, SeekFrom, Write};
use tracing::debug;
use wasmer_wasi::{types::*, WasiInodes};
use wasmer_wasi::{
types::{wasi::Filesize, *},
WasiInodes,
};
use wasmer_wasi::{Fd, VirtualFile, WasiFs, WasiFsError, ALL_RIGHTS, VIRTUAL_ROOT_FD};

use minifb::{Key, KeyRepeat, MouseButton, Scale, Window, WindowOptions};
Expand Down Expand Up @@ -417,7 +420,7 @@ impl VirtualFile for FrameBuffer {
fn size(&self) -> u64 {
0
}
fn set_len(&mut self, _new_size: __wasi_filesize_t) -> Result<(), WasiFsError> {
fn set_len(&mut self, _new_size: Filesize) -> Result<(), WasiFsError> {
Ok(())
}
fn unlink(&mut self) -> Result<(), WasiFsError> {
Expand Down
20 changes: 20 additions & 0 deletions lib/wasi-types-generated/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "wasmer-wasi-types-generated"
version = "3.0.0-beta"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
wasmer-derive = { path = "../derive", version = "=3.0.0-beta" }
wasmer-types = { path = "../types", version = "=3.0.0-beta" }

[dependencies.wit-bindgen-rust]
default-features = false
git = "https://github.com/wasmerio/wit-bindgen.git"
branch = "main"
package = "wit-bindgen-gen-rust-wasm"

[features]
js = []
sys = []
16 changes: 16 additions & 0 deletions lib/wasi-types-generated/regenerate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

BASEDIR=$(dirname "$0")

rm -f \
"$BASEDIR"/src/bindings.rs \
"$BASEDIR"/src/*/bindings.rs

# TODO: merge typenames.wit and wasi_unstable.wit

wit-bindgen rust-wasm \
--import \
"$BASEDIR"/wit-clean/typenames.wit \
--out-dir "$BASEDIR"/src/wasi

#wit-bindgen rust-wasm --import wit/wasi-snapshot0.wit wit/wasi-filesystem.wit --out-dir .
4 changes: 4 additions & 0 deletions lib/wasi-types-generated/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub mod wasi;
pub mod wasi_filesystem;
pub mod wasi_io_typenames;
pub mod wasi_snapshot0;
Loading