wiggle: revamp error type conversions
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use proptest::prelude::*;
|
||||
use wiggle::{GuestError, GuestMemory, GuestPtr};
|
||||
use wiggle::{GuestMemory, GuestPtr};
|
||||
use wiggle_test::{impl_errno, HostMemory, MemArea, WasiCtx};
|
||||
|
||||
wiggle::from_witx!({
|
||||
@@ -7,7 +7,7 @@ wiggle::from_witx!({
|
||||
ctx: WasiCtx,
|
||||
});
|
||||
|
||||
impl_errno!(types::Errno);
|
||||
impl_errno!(types::Errno, types::GuestErrorConversion);
|
||||
|
||||
impl<'a> arrays::Arrays for WasiCtx<'a> {
|
||||
fn reduce_excuses(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use proptest::prelude::*;
|
||||
use wiggle::{GuestError, GuestMemory};
|
||||
use wiggle::GuestMemory;
|
||||
use wiggle_test::{impl_errno, HostMemory, MemArea, WasiCtx};
|
||||
|
||||
wiggle::from_witx!({
|
||||
@@ -7,7 +7,7 @@ wiggle::from_witx!({
|
||||
ctx: WasiCtx,
|
||||
});
|
||||
|
||||
impl_errno!(types::Errno);
|
||||
impl_errno!(types::Errno, types::GuestErrorConversion);
|
||||
|
||||
impl<'a> atoms::Atoms for WasiCtx<'a> {
|
||||
fn int_float_args(&self, an_int: u32, an_float: f32) -> Result<(), types::Errno> {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use proptest::prelude::*;
|
||||
use std::convert::TryFrom;
|
||||
use wiggle::{GuestError, GuestMemory, GuestPtr};
|
||||
use wiggle::{GuestMemory, GuestPtr};
|
||||
use wiggle_test::{impl_errno, HostMemory, MemArea, WasiCtx};
|
||||
|
||||
wiggle::from_witx!({
|
||||
@@ -8,7 +8,7 @@ wiggle::from_witx!({
|
||||
ctx: WasiCtx,
|
||||
});
|
||||
|
||||
impl_errno!(types::Errno);
|
||||
impl_errno!(types::Errno, types::GuestErrorConversion);
|
||||
|
||||
impl<'a> flags::Flags for WasiCtx<'a> {
|
||||
fn configure_car(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use proptest::prelude::*;
|
||||
use wiggle::{GuestError, GuestMemory, GuestType};
|
||||
use wiggle::{GuestMemory, GuestType};
|
||||
use wiggle_test::{impl_errno, HostMemory, MemArea, WasiCtx};
|
||||
|
||||
const FD_VAL: u32 = 123;
|
||||
@@ -9,7 +9,7 @@ wiggle::from_witx!({
|
||||
ctx: WasiCtx,
|
||||
});
|
||||
|
||||
impl_errno!(types::Errno);
|
||||
impl_errno!(types::Errno, types::GuestErrorConversion);
|
||||
|
||||
impl<'a> handle_examples::HandleExamples for WasiCtx<'a> {
|
||||
fn fd_create(&self) -> Result<types::Fd, types::Errno> {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use proptest::prelude::*;
|
||||
use std::convert::TryFrom;
|
||||
use wiggle::{GuestError, GuestMemory};
|
||||
use wiggle::GuestMemory;
|
||||
use wiggle_test::{impl_errno, HostMemory, MemArea, WasiCtx};
|
||||
|
||||
wiggle::from_witx!({
|
||||
@@ -8,7 +8,7 @@ wiggle::from_witx!({
|
||||
ctx: WasiCtx,
|
||||
});
|
||||
|
||||
impl_errno!(types::Errno);
|
||||
impl_errno!(types::Errno, types::GuestErrorConversion);
|
||||
|
||||
impl<'a> ints::Ints for WasiCtx<'a> {
|
||||
fn cookie_cutter(&self, init_cookie: types::Cookie) -> Result<types::Bool, types::Errno> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use proptest::prelude::*;
|
||||
use wiggle::{GuestError, GuestMemory, GuestPtr};
|
||||
use wiggle::{GuestMemory, GuestPtr};
|
||||
use wiggle_test::{impl_errno, HostMemory, MemArea, WasiCtx};
|
||||
|
||||
wiggle::from_witx!({
|
||||
@@ -7,7 +7,7 @@ wiggle::from_witx!({
|
||||
ctx: WasiCtx,
|
||||
});
|
||||
|
||||
impl_errno!(types::Errno);
|
||||
impl_errno!(types::Errno, types::GuestErrorConversion);
|
||||
|
||||
impl<'a> pointers::Pointers for WasiCtx<'a> {
|
||||
fn pointers_and_enums<'b>(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use proptest::prelude::*;
|
||||
use wiggle::{GuestBorrows, GuestError, GuestMemory, GuestPtr};
|
||||
use wiggle::{GuestBorrows, GuestMemory, GuestPtr};
|
||||
use wiggle_test::{impl_errno, HostMemory, MemArea, MemAreas, WasiCtx};
|
||||
|
||||
wiggle::from_witx!({
|
||||
@@ -7,7 +7,7 @@ wiggle::from_witx!({
|
||||
ctx: WasiCtx,
|
||||
});
|
||||
|
||||
impl_errno!(types::Errno);
|
||||
impl_errno!(types::Errno, types::GuestErrorConversion);
|
||||
|
||||
impl<'a> strings::Strings for WasiCtx<'a> {
|
||||
fn hello_string(&self, a_string: &GuestPtr<str>) -> Result<u32, types::Errno> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use proptest::prelude::*;
|
||||
use wiggle::{GuestError, GuestMemory, GuestPtr};
|
||||
use wiggle::{GuestMemory, GuestPtr};
|
||||
use wiggle_test::{impl_errno, HostMemory, MemArea, WasiCtx};
|
||||
|
||||
wiggle::from_witx!({
|
||||
@@ -7,7 +7,7 @@ wiggle::from_witx!({
|
||||
ctx: WasiCtx,
|
||||
});
|
||||
|
||||
impl_errno!(types::Errno);
|
||||
impl_errno!(types::Errno, types::GuestErrorConversion);
|
||||
|
||||
impl<'a> structs::Structs for WasiCtx<'a> {
|
||||
fn sum_of_pair(&self, an_pair: &types::PairInts) -> Result<i64, types::Errno> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use proptest::prelude::*;
|
||||
use wiggle::{GuestError, GuestMemory, GuestType};
|
||||
use wiggle::{GuestMemory, GuestType};
|
||||
use wiggle_test::{impl_errno, HostMemory, MemArea, WasiCtx};
|
||||
|
||||
wiggle::from_witx!({
|
||||
@@ -7,7 +7,7 @@ wiggle::from_witx!({
|
||||
ctx: WasiCtx,
|
||||
});
|
||||
|
||||
impl_errno!(types::Errno);
|
||||
impl_errno!(types::Errno, types::GuestErrorConversion);
|
||||
|
||||
// Avoid panics on overflow
|
||||
fn mult_lose_overflow(a: i32, b: u32) -> i32 {
|
||||
|
||||
@@ -29,6 +29,13 @@ impl GuestErrorType for types::Errno {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> types::GuestErrorConversion for WasiCtx<'a> {
|
||||
fn into_errno(&self, e: GuestError) -> types::Errno {
|
||||
eprintln!("GuestError {:?}", e);
|
||||
types::Errno::Badf
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> crate::wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiCtx<'a> {
|
||||
fn args_get(&self, _argv: &GuestPtr<GuestPtr<u8>>, _argv_buf: &GuestPtr<u8>) -> Result<()> {
|
||||
unimplemented!("args_get")
|
||||
|
||||
Reference in New Issue
Block a user