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

Function wasmtime_arrayref_get

crates/c-api/src/arrayref.rs:90–109  ·  view source on GitHub ↗
(
    mut cx: WasmtimeStoreContextMut<'_>,
    arrayref: Option<&wasmtime_arrayref_t>,
    index: u32,
    out: &mut MaybeUninit<crate::wasmtime_val_t>,
)

Source from the content-addressed store, hash-verified

88
89#[unsafe(no_mangle)]
90pub unsafe extern "C" fn wasmtime_arrayref_get(
91 mut cx: WasmtimeStoreContextMut<'_>,
92 arrayref: Option<&wasmtime_arrayref_t>,
93 index: u32,
94 out: &mut MaybeUninit<crate::wasmtime_val_t>,
95) -> Option<Box<crate::wasmtime_error_t>> {
96 let arrayref = arrayref
97 .and_then(|a| a.as_wasmtime())
98 .expect("non-null arrayref required");
99 let mut scope = RootScope::new(&mut cx);
100 let rooted = arrayref.to_rooted(&mut scope);
101 match rooted.get(&mut scope, index) {
102 Ok(val) => {
103 let c_val = crate::wasmtime_val_t::from_val(&mut scope, val);
104 crate::initialize(out, c_val);
105 None
106 }
107 Err(e) => Some(Box::new(e.into())),
108 }
109}
110
111#[unsafe(no_mangle)]
112pub unsafe extern "C" fn wasmtime_arrayref_set(

Callers 1

getMethod · 0.85

Calls 6

as_wasmtimeMethod · 0.80
initializeFunction · 0.70
newFunction · 0.50
expectMethod · 0.45
to_rootedMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected