wasmtime/runtime/component/
store.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use crate::prelude::*;
use crate::store::{StoreData, StoredData};

macro_rules! component_store_data {
    ($($field:ident => $t:ty,)*) => (
        #[derive(Default)]
        pub struct ComponentStoreData {
            $($field: Vec<$t>,)*
        }

        $(
            impl StoredData for $t {
                #[inline]
                fn list(data: &StoreData) -> &Vec<Self> {
                    &data.components.$field
                }
                #[inline]
                fn list_mut(data: &mut StoreData) -> &mut Vec<Self> {
                    &mut data.components.$field
                }
            }
        )*
    )
}

component_store_data! {
    funcs => crate::component::func::FuncData,
    instances => Option<Box<crate::component::instance::InstanceData>>,
}