wasmer/wasm_c_api/externals/
table.rs1use super::super::store::wasm_store_t;
2use super::super::types::{wasm_ref_t, wasm_table_size_t, wasm_tabletype_t};
3use super::wasm_extern_t;
4use wasmer_api::Extern;
5
6#[allow(non_camel_case_types)]
7#[repr(C)]
8#[derive(Clone)]
9pub struct wasm_table_t {
10 pub(crate) extern_: wasm_extern_t,
11}
12
13impl wasm_table_t {
14 pub(crate) fn try_from(e: &wasm_extern_t) -> Option<&wasm_table_t> {
15 match &e.inner {
16 Extern::Table(_) => Some(unsafe { &*(e as *const _ as *const _) }),
17 _ => None,
18 }
19 }
20}
21
22#[no_mangle]
23pub unsafe extern "C" fn wasm_table_new(
24 _store: Option<&wasm_store_t>,
25 _table_type: Option<&wasm_tabletype_t>,
26 _init: *const wasm_ref_t,
27) -> Option<Box<wasm_table_t>> {
28 todo!("get val from init somehow");
29}
30
31#[no_mangle]
32pub unsafe extern "C" fn wasm_table_delete(_table: Option<Box<wasm_table_t>>) {}
33
34#[no_mangle]
35pub unsafe extern "C" fn wasm_table_copy(table: &wasm_table_t) -> Box<wasm_table_t> {
36 Box::new(table.clone())
38}
39
40#[no_mangle]
41pub unsafe extern "C" fn wasm_table_size(table: &wasm_table_t) -> usize {
42 table.extern_.table().size(&table.extern_.store.store()) as _
43}
44
45#[no_mangle]
46pub unsafe extern "C" fn wasm_table_same(
47 wasm_table1: &wasm_table_t,
48 wasm_table2: &wasm_table_t,
49) -> bool {
50 wasm_table1.extern_.table() == wasm_table2.extern_.table()
51}
52
53#[no_mangle]
54pub unsafe extern "C" fn wasm_table_grow(
55 _table: &mut wasm_table_t,
56 _delta: wasm_table_size_t,
57 _init: *mut wasm_ref_t,
58) -> bool {
59 todo!("Blocked on transforming ExternRef into a val type")
62}