(
mut store: WasmtimeStoreContextMut<'_>,
tag: &Tag,
fields: *const wasmtime_val_t,
nfields: usize,
exn_ret: &mut MaybeUninit<wasmtime_exnref_t>,
)
| 16 | |
| 17 | #[unsafe(no_mangle)] |
| 18 | pub unsafe extern "C" fn wasmtime_exnref_new( |
| 19 | mut store: WasmtimeStoreContextMut<'_>, |
| 20 | tag: &Tag, |
| 21 | fields: *const wasmtime_val_t, |
| 22 | nfields: usize, |
| 23 | exn_ret: &mut MaybeUninit<wasmtime_exnref_t>, |
| 24 | ) -> Option<Box<wasmtime_error_t>> { |
| 25 | let mut scope = RootScope::new(&mut store); |
| 26 | |
| 27 | let result = (|| { |
| 28 | let tag_ty = tag.ty(&scope); |
| 29 | let exn_type = ExnType::from_tag_type(&tag_ty)?; |
| 30 | let allocator = ExnRefPre::new(&mut scope, exn_type); |
| 31 | let raw_fields = crate::slice_from_raw_parts(fields, nfields); |
| 32 | let field_vals: Vec<wasmtime::Val> = |
| 33 | raw_fields.iter().map(|f| f.to_val(&mut scope)).collect(); |
| 34 | ExnRef::new(&mut scope, &allocator, tag, &field_vals) |
| 35 | })(); |
| 36 | |
| 37 | handle_result(result, |rooted| { |
| 38 | let owned = rooted.to_owned_rooted(&mut scope).unwrap(); |
| 39 | exn_ret.write(owned.into()); |
| 40 | }) |
| 41 | } |
| 42 | |
| 43 | #[unsafe(no_mangle)] |
| 44 | pub extern "C" fn wasmtime_exnref_tag( |
no test coverage detected