|
@@ -1,6 +1,6 @@
|
|
|
#[macro_export]
|
|
|
macro_rules! system {
|
|
|
- ($name:ident $pat:tt => $($rest:tt)* ) => {
|
|
|
+ ($name:ident $pat:tt { $($rest:tt)* } ) => {
|
|
|
struct $name;
|
|
|
impl<'a> specs::System<'a> for $name {
|
|
|
type SystemData = args_to_systemdata!($pat);
|
|
@@ -11,6 +11,18 @@ macro_rules! system {
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
+ ($name:ident $pat:tt { $($rest:tt)* } finally { $($finally:tt)* }) => {
|
|
|
+ struct $name;
|
|
|
+ impl<'a> specs::System<'a> for $name {
|
|
|
+ type SystemData = args_to_systemdata!($pat);
|
|
|
+ fn run(&mut self, args_to_pat!($pat): Self::SystemData) {
|
|
|
+ for args_to_pat!($pat) in args_to_join!($pat).join() {
|
|
|
+ $($rest)*
|
|
|
+ }
|
|
|
+ $($finally)*
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
#[macro_export]
|
|
@@ -77,7 +89,15 @@ mod tests {
|
|
|
type Storage = specs::VecStorage<Mov>;
|
|
|
}
|
|
|
|
|
|
- system! { Foo (_x: Mov, mut y: Pos,) =>
|
|
|
+ system! { Foo (_x: Mov, mut y: Pos) {
|
|
|
y.x += 1;
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ system! { Bar (_x: Mov, mut y: Pos) {
|
|
|
+ y.x += 1;
|
|
|
+ } finally {
|
|
|
+ println!("Done!");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|