Skip to content

Commit

Permalink
Merge pull request #41 from bytecodealliance/wasmtime-3.0.0
Browse files Browse the repository at this point in the history
Wasmtime 3.0.0
  • Loading branch information
jbourassa authored Nov 23, 2022
2 parents 1d69c9c + 2333c13 commit 2af68e5
Show file tree
Hide file tree
Showing 8 changed files with 196 additions and 127 deletions.
141 changes: 85 additions & 56 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion ext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ crate-type = ["cdylib"]
lazy_static = "1.4.0"
magnus = { git = "https://github.com/matsadler/magnus", features = ["rb-sys-interop"] }
rb-sys = "~0.9.44"
wasmtime = "2.0.2"
wasmtime = "3.0.0"
anyhow = "*" # Use whatever Wasmtime uses
12 changes: 6 additions & 6 deletions ext/src/ruby_api/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use magnus::{
use std::cell::UnsafeCell;
use wasmtime::{
AsContext, AsContextMut, Caller as CallerImpl, Func as FuncImpl, StoreContext, StoreContextMut,
Trap, Val,
Val,
};

/// @yard
Expand Down Expand Up @@ -168,7 +168,7 @@ impl From<&Func<'_>> for wasmtime::Extern {
pub fn make_func_closure(
ty: &wasmtime::FuncType,
callable: Proc,
) -> impl Fn(CallerImpl<'_, StoreData>, &[Val], &mut [Val]) -> Result<(), Trap> + Send + Sync + 'static
) -> impl Fn(CallerImpl<'_, StoreData>, &[Val], &mut [Val]) -> anyhow::Result<()> + Send + Sync + 'static
{
let ty = ty.to_owned();
let callable = ShareableProc(callable);
Expand All @@ -182,9 +182,9 @@ pub fn make_func_closure(
rparams.push(Value::from(wrapped_caller)).unwrap();

for (i, param) in params.iter().enumerate() {
let rparam = param.to_ruby_value(&store_context).map_err(|e| {
wasmtime::Trap::new(format!("invalid argument at index {}: {}", i, e))
})?;
let rparam = param
.to_ruby_value(&store_context)
.map_err(|e| anyhow::anyhow!(format!("invalid argument at index {}: {}", i, e)))?;
rparams.push(rparam).unwrap();
}

Expand Down Expand Up @@ -223,7 +223,7 @@ pub fn make_func_closure(
}
})
.map_err(|e| {
wasmtime::Trap::new(format!(
anyhow::anyhow!(format!(
"Error when calling Func {}\n Error: {}",
callable.inspect(),
e
Expand Down
Loading

0 comments on commit 2af68e5

Please sign in to comment.