implement the new event system, things are still really messy

This commit is contained in:
lumi 2017-05-10 00:13:54 +02:00
commit 917b14b5d2
11 changed files with 403 additions and 156 deletions

26
src/plugin_macro.rs Normal file
View file

@ -0,0 +1,26 @@
#[macro_export]
macro_rules! impl_plugin {
($plugin:ty, $proxy:ident, [$($evt:ty => $pri:expr),*]) => {
impl $crate::plugin::Plugin for $plugin {
fn get_proxy(&mut self) -> &mut $crate::plugin::PluginProxy {
&mut self.$proxy
}
}
#[allow(unused_variables)]
impl $crate::plugin::PluginInit for $plugin {
fn init( dispatcher: &mut $crate::event::Dispatcher
, me: ::std::sync::Arc<Box<$crate::plugin::Plugin>>) {
$(
dispatcher.register($pri, unsafe {
$crate::event::EventProxy::new::<$plugin>(me.clone())
});
)*
}
}
};
($plugin:ty, $proxy:ident, [$($evt:ty => $pri:expr),*,]) => {
impl_plugin!($plugin, $proxy, [$($evt => $pri),*]);
};
}