(
mut cx: WasmtimeStoreContextMut<'_>,
pre: &wasmtime_struct_ref_pre_t,
fields: *const crate::wasmtime_val_t,
nfields: usize,
out: &mut MaybeUninit<wasmtime_structref_t>,
)
| 25 | |
| 26 | #[unsafe(no_mangle)] |
| 27 | pub unsafe extern "C" fn wasmtime_structref_new( |
| 28 | mut cx: WasmtimeStoreContextMut<'_>, |
| 29 | pre: &wasmtime_struct_ref_pre_t, |
| 30 | fields: *const crate::wasmtime_val_t, |
| 31 | nfields: usize, |
| 32 | out: &mut MaybeUninit<wasmtime_structref_t>, |
| 33 | ) -> Option<Box<crate::wasmtime_error_t>> { |
| 34 | let c_fields = crate::slice_from_raw_parts(fields, nfields); |
| 35 | let mut scope = RootScope::new(&mut cx); |
| 36 | let vals: Vec<Val> = c_fields.iter().map(|v| v.to_val(&mut scope)).collect(); |
| 37 | match StructRef::new(&mut scope, &pre.pre, &vals) { |
| 38 | Ok(structref) => { |
| 39 | let owned = structref |
| 40 | .to_owned_rooted(&mut scope) |
| 41 | .expect("just allocated"); |
| 42 | crate::initialize(out, Some(owned).into()); |
| 43 | None |
| 44 | } |
| 45 | Err(e) => { |
| 46 | crate::initialize(out, None::<OwnedRooted<StructRef>>.into()); |
| 47 | Some(Box::new(e.into())) |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | #[unsafe(no_mangle)] |
| 53 | pub unsafe extern "C" fn wasmtime_structref_to_anyref( |
no test coverage detected