44 lines
1.0 KiB
Rust
44 lines
1.0 KiB
Rust
|
|
macro_rules! impl_base_obj {
|
||
|
|
($base_name:ident) => {
|
||
|
|
fn instantiate(&mut self, ty: $crate::obj::ObjP) {
|
||
|
|
self.$base_name.instantiate(ty);
|
||
|
|
}
|
||
|
|
|
||
|
|
fn is_instantiated(&self) -> bool {
|
||
|
|
self.$base_name.is_instantiated()
|
||
|
|
}
|
||
|
|
|
||
|
|
fn attrs(&self) -> &$crate::obj::Attrs {
|
||
|
|
self.$base_name.attrs()
|
||
|
|
}
|
||
|
|
|
||
|
|
fn attrs_mut(&mut self) -> &mut $crate::obj::Attrs {
|
||
|
|
self.$base_name.attrs_mut()
|
||
|
|
}
|
||
|
|
|
||
|
|
fn as_any(&self) -> &dyn std::any::Any {
|
||
|
|
self
|
||
|
|
}
|
||
|
|
|
||
|
|
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
|
||
|
|
self
|
||
|
|
}
|
||
|
|
};
|
||
|
|
() => {
|
||
|
|
impl_base_obj! { base }
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
macro_rules! impl_create {
|
||
|
|
($($arg:ident : $ty:ty),* $(,)?) => {
|
||
|
|
pub fn create(ty: $crate::obj::ObjP $(, $arg : $ty )*) -> $crate::obj::ObjP {
|
||
|
|
let ptr = make_ptr(Self::new($($arg),*));
|
||
|
|
ptr.borrow_mut().instantiate(ty);
|
||
|
|
ptr
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub(crate) use impl_base_obj;
|
||
|
|
pub(crate) use impl_create;
|