Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stages! macro doesn't work without trailing comma #62

Closed
Anders429 opened this issue Feb 27, 2022 · 2 comments
Closed

stages! macro doesn't work without trailing comma #62

Anders429 opened this issue Feb 27, 2022 · 2 comments
Labels
A - Scheduling Area: Parallel scheduling of systems. C - Compilation Category: Code expected to compile is failing to do so. P - High Priority: Urgent, needing immediate attention. S - Needs Investigation Status: Further investigation is needed.

Comments

@Anders429
Copy link
Owner

Came across this today. With the trailing comma, it compiles just fine, but without the comma it seems to not be resolving the macro properly, complaining about a @ character being present.

@Anders429 Anders429 added the C - Bug Category: Something is not functioning as expected. label Feb 27, 2022
@Anders429 Anders429 added S - Needs Investigation Status: Further investigation is needed. C - Compilation Category: Code expected to compile is failing to do so. P - High Priority: Urgent, needing immediate attention. and removed C - Bug Category: Something is not functioning as expected. labels Sep 15, 2022
@Anders429
Copy link
Owner Author

Seems this doesn't happen with flush commands, but it does happen with system commands. For example,

#[derive(Clone)]
struct A(f32);
#[derive(Clone)]
struct B(f32);
#[derive(Clone)]
struct C(f32);
#[derive(Clone)]
struct D(f32);
#[derive(Clone)]
struct E(f32);

type Registry = registry!(A, B, C, D, E);

struct AB;

impl<'a> System<'a> for AB {
    type Views = views!(&'a mut A, &'a mut B);
    type Filter = filter::None;

    fn run<R, FI, VI, P, I, Q>(
        &mut self,
        query_results: result::Iter<'a, R, Self::Filter, FI, Self::Views, VI, P, I, Q>,
    ) where
        R: ContainsQuery<'a, Self::Filter, FI, Self::Views, VI, P, I, Q> + 'a,
    {
        for result!(a, b) in query_results {
            core::mem::swap(&mut a.0, &mut b.0);
        }
    }
}

struct CD;

impl<'a> System<'a> for CD {
    type Views = views!(&'a mut C, &'a mut D);
    type Filter = filter::None;

    fn run<R, FI, VI, P, I, Q>(
        &mut self,
        query_results: result::Iter<'a, R, Self::Filter, FI, Self::Views, VI, P, I, Q>,
    ) where
        R: ContainsQuery<'a, Self::Filter, FI, Self::Views, VI, P, I, Q> + 'a,
    {
        for result!(c, d) in query_results {
            core::mem::swap(&mut c.0, &mut d.0);
        }
    }
}

struct CE;

impl<'a> System<'a> for CE {
    type Views = views!(&'a mut C, &'a mut E);
    type Filter = filter::None;

    fn run<R, FI, VI, P, I, Q>(
        &mut self,
        query_results: result::Iter<'a, R, Self::Filter, FI, Self::Views, VI, P, I, Q>,
    ) where
        R: ContainsQuery<'a, Self::Filter, FI, Self::Views, VI, P, I, Q> + 'a,
    {
        for result!(c, e) in query_results {
            core::mem::swap(&mut c.0, &mut e.0);
        }
    }
}

type Stages = stages!(
    system: AB,
    system: CD,
    system: CE
);

does not compile, but adding the comma after CE does compile.

@Anders429
Copy link
Owner Author

Turns out a ! character was missing from the macro definition on this line.

@Anders429 Anders429 added the A - Scheduling Area: Parallel scheduling of systems. label Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A - Scheduling Area: Parallel scheduling of systems. C - Compilation Category: Code expected to compile is failing to do so. P - High Priority: Urgent, needing immediate attention. S - Needs Investigation Status: Further investigation is needed.
Projects
None yet
Development

No branches or pull requests

1 participant