|
@@ -1,21 +1,3 @@
|
|
|
-pub struct SpecsUnit;
|
|
|
-impl<'a> specs::SystemData<'a> for SpecsUnit {
|
|
|
- fn setup(_world: &mut specs::World) {
|
|
|
- }
|
|
|
-
|
|
|
- fn fetch(_world: &'a specs::World) -> Self {
|
|
|
- SpecsUnit
|
|
|
- }
|
|
|
-
|
|
|
- fn reads() -> Vec<specs::prelude::ResourceId> {
|
|
|
- Vec::new()
|
|
|
- }
|
|
|
-
|
|
|
- fn writes() -> Vec<specs::prelude::ResourceId> {
|
|
|
- Vec::new()
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
#[macro_export]
|
|
|
macro_rules! system {
|
|
|
($name:ident ( $($pat:tt)* ) { $($rest:tt)* } ) => {
|
|
@@ -45,13 +27,18 @@ macro_rules! system {
|
|
|
|
|
|
#[macro_export]
|
|
|
macro_rules! args_to_systemdata {
|
|
|
- ( ( ) ) => { crate::SpecsUnit };
|
|
|
( ( $name:ident : $ty:ty $(,)? ) ) => {
|
|
|
( specs::ReadStorage<'a, $ty> ,)
|
|
|
};
|
|
|
( ( mut $name:ident : $ty:ty $(,)? ) ) => {
|
|
|
( specs::WriteStorage<'a, $ty> ,)
|
|
|
};
|
|
|
+ ( ( resource $name:ident : $ty:ty $(,)? ) ) => {
|
|
|
+ compile_error!("Resources cannot come at the end of the argument block.")
|
|
|
+ };
|
|
|
+ ( ( resource mut $name:ident : $ty:ty $(,)? ) ) => {
|
|
|
+ compile_error!("Resources cannot come at the end of the argument block.")
|
|
|
+ };
|
|
|
( ( $name:ident : $ty:ty , $($tok:tt)* ) ) => {
|
|
|
( specs::ReadStorage<'a, $ty>, args_to_systemdata!( ( $( $tok )* ) ) )
|
|
|
};
|
|
@@ -68,13 +55,18 @@ macro_rules! args_to_systemdata {
|
|
|
|
|
|
#[macro_export]
|
|
|
macro_rules! args_to_fn_pat {
|
|
|
- ( ( ) ) => { _ };
|
|
|
( ( $name:ident : $ty:ty $(,)? ) ) => {
|
|
|
( $name ,)
|
|
|
};
|
|
|
( ( mut $name:ident : $ty:ty $(,)? ) ) => {
|
|
|
( mut $name ,)
|
|
|
};
|
|
|
+ ( ( resource $name:ident : $ty:ty $(,)? ) ) => {
|
|
|
+ compile_error!("Resources cannot come at the end of the argument block.")
|
|
|
+ };
|
|
|
+ ( ( resource mut $name:ident : $ty:ty $(,)? ) ) => {
|
|
|
+ compile_error!("Resources cannot come at the end of the argument block.")
|
|
|
+ };
|
|
|
( ( $name:ident : $ty:ty , $($tok:tt)* ) ) => {
|
|
|
( $name, args_to_fn_pat!( ( $($tok)* ) ) )
|
|
|
};
|
|
@@ -91,13 +83,18 @@ macro_rules! args_to_fn_pat {
|
|
|
|
|
|
#[macro_export]
|
|
|
macro_rules! args_to_join_pat {
|
|
|
- ( ( ) ) => { _ };
|
|
|
( ( $name:ident : $ty:ty $(,)? ) ) => {
|
|
|
( $name ,)
|
|
|
};
|
|
|
( ( mut $name:ident : $ty:ty $(,)? ) ) => {
|
|
|
( mut $name ,)
|
|
|
};
|
|
|
+ ( ( resource $name:ident : $ty:ty $(,)? ) ) => {
|
|
|
+ compile_error!("Resources cannot come at the end of the argument block.")
|
|
|
+ };
|
|
|
+ ( ( resource mut $name:ident : $ty:ty $(,)? ) ) => {
|
|
|
+ compile_error!("Resources cannot come at the end of the argument block.")
|
|
|
+ };
|
|
|
( ( $name:ident : $ty:ty , $($tok:tt)* ) ) => {
|
|
|
( $name, args_to_join_pat!( ( $($tok)* ) ) )
|
|
|
};
|
|
@@ -114,13 +111,18 @@ macro_rules! args_to_join_pat {
|
|
|
|
|
|
#[macro_export]
|
|
|
macro_rules! args_to_join {
|
|
|
- ( ( ) ) => { crate::SpecsUnit };
|
|
|
( ( $name:ident : $ty:ty $(,)? ) ) => {
|
|
|
( & $name ,)
|
|
|
};
|
|
|
( ( mut $name:ident : $ty:ty $(,)? ) ) => {
|
|
|
( &mut $name ,)
|
|
|
};
|
|
|
+ ( ( resource $name:ident : $ty:ty $(,)? ) ) => {
|
|
|
+ compile_error!("Resources cannot come at the end of the argument block.")
|
|
|
+ };
|
|
|
+ ( ( resource mut $name:ident : $ty:ty $(,)? ) ) => {
|
|
|
+ compile_error!("Resources cannot come at the end of the argument block.")
|
|
|
+ };
|
|
|
( ( $name:ident : $ty:ty , $($tok:tt)* ) ) => {
|
|
|
( & $name, args_to_join!( ( $($tok)* ) ) )
|
|
|
};
|
|
@@ -172,11 +174,4 @@ mod tests {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- system! {
|
|
|
- Quux (resource mut n: usize, _x: Mov, mut y: Pos) {
|
|
|
- y.x += *n;
|
|
|
- *n += 1
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
}
|