wiggle-generate: always pass GuestPtr by reference
with the prev approach, it would be passed by reference sometimes (e.g. when used as an Array argument) but by value most of the time. this was inconsistient. theres no need to pass the owned version, all operations are &self.
This commit is contained in:
@@ -14,7 +14,7 @@ impl<'a> flags::Flags for WasiCtx<'a> {
|
||||
fn configure_car(
|
||||
&self,
|
||||
old_config: types::CarConfig,
|
||||
other_config_ptr: GuestPtr<types::CarConfig>,
|
||||
other_config_ptr: &GuestPtr<types::CarConfig>,
|
||||
) -> Result<types::CarConfig, types::Errno> {
|
||||
let other_config = other_config_ptr.read().map_err(|e| {
|
||||
eprintln!("old_config_ptr error: {}", e);
|
||||
|
||||
@@ -13,9 +13,9 @@ impl<'a> pointers::Pointers for WasiCtx<'a> {
|
||||
fn pointers_and_enums<'b>(
|
||||
&self,
|
||||
input1: types::Excuse,
|
||||
input2_ptr: GuestPtr<'b, types::Excuse>,
|
||||
input3_ptr: GuestPtr<'b, types::Excuse>,
|
||||
input4_ptr_ptr: GuestPtr<'b, GuestPtr<'b, types::Excuse>>,
|
||||
input2_ptr: &GuestPtr<'b, types::Excuse>,
|
||||
input3_ptr: &GuestPtr<'b, types::Excuse>,
|
||||
input4_ptr_ptr: &GuestPtr<'b, GuestPtr<'b, types::Excuse>>,
|
||||
) -> Result<(), types::Errno> {
|
||||
println!("BAZ input1 {:?}", input1);
|
||||
let input2: types::Excuse = input2_ptr.read().map_err(|e| {
|
||||
@@ -52,7 +52,7 @@ impl<'a> pointers::Pointers for WasiCtx<'a> {
|
||||
println!("input4 {:?}", input4);
|
||||
|
||||
// Write ptr value to mutable ptr:
|
||||
input4_ptr_ptr.write(input2_ptr).map_err(|e| {
|
||||
input4_ptr_ptr.write(*input2_ptr).map_err(|e| {
|
||||
eprintln!("input4_ptr_ptr error: {}", e);
|
||||
types::Errno::InvalidArg
|
||||
})?;
|
||||
|
||||
@@ -44,10 +44,13 @@ impl<'a> structs::Structs for WasiCtx<'a> {
|
||||
|
||||
fn return_pair_of_ptrs<'b>(
|
||||
&self,
|
||||
first: GuestPtr<'b, i32>,
|
||||
second: GuestPtr<'b, i32>,
|
||||
first: &GuestPtr<'b, i32>,
|
||||
second: &GuestPtr<'b, i32>,
|
||||
) -> Result<types::PairIntPtrs<'b>, types::Errno> {
|
||||
Ok(types::PairIntPtrs { first, second })
|
||||
Ok(types::PairIntPtrs {
|
||||
first: *first,
|
||||
second: *second,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ impl<'a> GuestErrorType<'a> for types::Errno {
|
||||
}
|
||||
|
||||
impl<'a> crate::wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiCtx<'a> {
|
||||
fn args_get(&self, _argv: GuestPtr<GuestPtr<u8>>, _argv_buf: GuestPtr<u8>) -> Result<()> {
|
||||
fn args_get(&self, _argv: &GuestPtr<GuestPtr<u8>>, _argv_buf: &GuestPtr<u8>) -> Result<()> {
|
||||
unimplemented!("args_get")
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ impl<'a> crate::wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiCtx<'a> {
|
||||
|
||||
fn environ_get(
|
||||
&self,
|
||||
_environ: GuestPtr<GuestPtr<u8>>,
|
||||
_environ_buf: GuestPtr<u8>,
|
||||
_environ: &GuestPtr<GuestPtr<u8>>,
|
||||
_environ_buf: &GuestPtr<u8>,
|
||||
) -> Result<()> {
|
||||
unimplemented!("environ_get")
|
||||
}
|
||||
@@ -153,7 +153,7 @@ impl<'a> crate::wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiCtx<'a> {
|
||||
fn fd_prestat_dir_name(
|
||||
&self,
|
||||
_fd: types::Fd,
|
||||
_path: GuestPtr<u8>,
|
||||
_path: &GuestPtr<u8>,
|
||||
_path_len: types::Size,
|
||||
) -> Result<()> {
|
||||
unimplemented!("fd_prestat_dir_name")
|
||||
@@ -175,7 +175,7 @@ impl<'a> crate::wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiCtx<'a> {
|
||||
fn fd_readdir(
|
||||
&self,
|
||||
_fd: types::Fd,
|
||||
_buf: GuestPtr<u8>,
|
||||
_buf: &GuestPtr<u8>,
|
||||
_buf_len: types::Size,
|
||||
_cookie: types::Dircookie,
|
||||
) -> Result<types::Size> {
|
||||
@@ -260,7 +260,7 @@ impl<'a> crate::wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiCtx<'a> {
|
||||
&self,
|
||||
_fd: types::Fd,
|
||||
_path: &GuestPtr<'_, str>,
|
||||
_buf: GuestPtr<u8>,
|
||||
_buf: &GuestPtr<u8>,
|
||||
_buf_len: types::Size,
|
||||
) -> Result<types::Size> {
|
||||
unimplemented!("path_readlink")
|
||||
@@ -295,8 +295,8 @@ impl<'a> crate::wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiCtx<'a> {
|
||||
|
||||
fn poll_oneoff(
|
||||
&self,
|
||||
_in_: GuestPtr<types::Subscription>,
|
||||
_out: GuestPtr<types::Event>,
|
||||
_in_: &GuestPtr<types::Subscription>,
|
||||
_out: &GuestPtr<types::Event>,
|
||||
_nsubscriptions: types::Size,
|
||||
) -> Result<types::Size> {
|
||||
unimplemented!("poll_oneoff")
|
||||
@@ -314,7 +314,7 @@ impl<'a> crate::wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiCtx<'a> {
|
||||
unimplemented!("sched_yield")
|
||||
}
|
||||
|
||||
fn random_get(&self, _buf: GuestPtr<u8>, _buf_len: types::Size) -> Result<()> {
|
||||
fn random_get(&self, _buf: &GuestPtr<u8>, _buf_len: types::Size) -> Result<()> {
|
||||
unimplemented!("random_get")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user