Skip to content

Commit

Permalink
Add queries that filter based on change detection (#42)
Browse files Browse the repository at this point in the history
Rebase of #30.
Resolves #23.

Adds support for trait queries that filter based on change detection.

Co-authored-by: Brian Merchant <bhmerchant@gmail.com>
  • Loading branch information
JoJoJet and bzm3r committed Sep 8, 2023
1 parent 53ca7c1 commit 491328e
Show file tree
Hide file tree
Showing 5 changed files with 952 additions and 168 deletions.
6 changes: 3 additions & 3 deletions proc-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn impl_trait_query(arg: TokenStream, item: TokenStream) -> Result<TokenStream2>

let my_crate = proc_macro_crate::crate_name("bevy-trait-query").unwrap();
let my_crate = match my_crate {
proc_macro_crate::FoundCrate::Itself => quote! { crate },
proc_macro_crate::FoundCrate::Itself => quote! { bevy_trait_query },
proc_macro_crate::FoundCrate::Name(x) => {
let ident = quote::format_ident!("{x}");
quote! { #ident }
Expand Down Expand Up @@ -156,7 +156,7 @@ fn impl_trait_query(arg: TokenStream, item: TokenStream) -> Result<TokenStream2>
#where_clause
{
type Item<'__w> = #my_crate::ReadTraits<'__w, #trait_object>;
type Fetch<'__w> = #my_crate::ReadAllTraitsFetch<'__w, #trait_object>;
type Fetch<'__w> = <#my_crate::All<&'__a #trait_object> as #imports::WorldQuery>::Fetch<'__w>;
type ReadOnly = Self;
type State = #my_crate::TraitQueryState<#trait_object>;

Expand Down Expand Up @@ -264,7 +264,7 @@ fn impl_trait_query(arg: TokenStream, item: TokenStream) -> Result<TokenStream2>
#where_clause
{
type Item<'__w> = #my_crate::WriteTraits<'__w, #trait_object>;
type Fetch<'__w> = #my_crate::WriteAllTraitsFetch<'__w, #trait_object>;
type Fetch<'__w> = <#my_crate::All<&'__a #trait_object> as #imports::WorldQuery>::Fetch<'__w>;
type ReadOnly = &'__a #trait_object;
type State = #my_crate::TraitQueryState<#trait_object>;

Expand Down
Loading

0 comments on commit 491328e

Please sign in to comment.