#![allow(unused_imports)]
use lazy_static::lazy_static;
use paste::paste;
use memoffset::offset_of;
#[macro_export]
macro_rules! define_structs {
( $($name:ident { $($field:ident : $type:ty),* $(,)? })* ) => {
$(
#[repr(align(8))]
struct $name {
#[allow(dead_code)]
pub flex: BTreeMap<String, String>,
$(pub $field : $type,)*
}
impl $name {
#[allow(dead_code)]
pub fn new_intern($($field : $type),*) -> Self {
Self {
flex: BTreeMap::new(),
$($field : $field,)*
}
}
}
impl Pr47DynBase for $name {
fn get_type_id(&self) -> TypeId {
std::any::TypeId::of::<$name>()
}
fn get_type_name(&self) -> &'static str {
std::any::type_name::<$name>()
}
}
paste::paste! {
lazy_static! {
static ref [<$name _PR47_FIELD_MAP>] : BTreeMap<String, (TypeId, usize)> = {
let mut ret = BTreeMap::new();
$(ret.insert(stringify!($field).into(),
(std::any::TypeId::of::<$type>(),
offset_of!($name, $field)));)*
ret
};
}
}
)*
}
}