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

Function wasmtime_arrayref_new

crates/c-api/src/arrayref.rs:27–49  ·  view source on GitHub ↗
(
    mut cx: WasmtimeStoreContextMut<'_>,
    pre: &wasmtime_array_ref_pre_t,
    elem: &crate::wasmtime_val_t,
    len: u32,
    out: &mut MaybeUninit<wasmtime_arrayref_t>,
)

Source from the content-addressed store, hash-verified

25
26#[unsafe(no_mangle)]
27pub unsafe extern "C" fn wasmtime_arrayref_new(
28 mut cx: WasmtimeStoreContextMut<'_>,
29 pre: &wasmtime_array_ref_pre_t,
30 elem: &crate::wasmtime_val_t,
31 len: u32,
32 out: &mut MaybeUninit<wasmtime_arrayref_t>,
33) -> Option<Box<crate::wasmtime_error_t>> {
34 let mut scope = RootScope::new(&mut cx);
35 let val = elem.to_val(&mut scope);
36 match ArrayRef::new(&mut scope, &pre.pre, &val, len) {
37 Ok(arrayref) => {
38 let owned = arrayref
39 .to_owned_rooted(&mut scope)
40 .expect("just allocated");
41 crate::initialize(out, Some(owned).into());
42 None
43 }
44 Err(e) => {
45 crate::initialize(out, None::<OwnedRooted<ArrayRef>>.into());
46 Some(Box::new(e.into()))
47 }
48 }
49}
50
51#[unsafe(no_mangle)]
52pub unsafe extern "C" fn wasmtime_arrayref_to_anyref(

Callers 1

createMethod · 0.85

Calls 5

to_valMethod · 0.80
initializeFunction · 0.70
newFunction · 0.50
expectMethod · 0.45
to_owned_rootedMethod · 0.45

Tested by

no test coverage detected