MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / wasmtime_exnref_new

Function wasmtime_exnref_new

crates/c-api/src/exnref.rs:18–41  ·  view source on GitHub ↗
(
    mut store: WasmtimeStoreContextMut<'_>,
    tag: &Tag,
    fields: *const wasmtime_val_t,
    nfields: usize,
    exn_ret: &mut MaybeUninit<wasmtime_exnref_t>,
)

Source from the content-addressed store, hash-verified

16
17#[unsafe(no_mangle)]
18pub 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)]
44pub extern "C" fn wasmtime_exnref_tag(

Callers 1

createMethod · 0.85

Calls 11

slice_from_raw_partsFunction · 0.85
handle_resultFunction · 0.85
collectMethod · 0.80
to_valMethod · 0.80
newFunction · 0.50
tyMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
unwrapMethod · 0.45
to_owned_rootedMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected