Skip to content

Commit

Permalink
- Changing ArchetypeSelect... to Select (ArchetypeSelectId is now Sel…
Browse files Browse the repository at this point in the history
…ectArchetype)

- Reserving With<> and Without<> as query argument keywords for future use
- Code cleanup
  • Loading branch information
recatek committed Jan 18, 2025
1 parent c17a406 commit 993fc64
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 122 deletions.
41 changes: 36 additions & 5 deletions macros/src/generate/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ pub fn generate_query_find(
// TODO PERF: We could avoid binding entirely if we know that the params have no OneOf.

// Types
let ArchetypeSelectInternalWorld =
format_ident!("__ArchetypeSelectInternal{}", world_data.name);
let __WorldSelectTotal = format_ident!("__{}SelectTotal", world_data.name);

// Variables and fields
let world = &query_data.world;
Expand Down Expand Up @@ -124,7 +123,7 @@ pub fn generate_query_find(
};

queries.push(quote!(
#ArchetypeSelectInternalWorld::#Archetype(#resolved_entity) => {
#__WorldSelectTotal::#Archetype(#resolved_entity) => {
// Alias the current archetype for use in the closure.
type MatchedArchetype = #Archetype;
// The closure needs to be made per-archetype because of OneOf types.
Expand All @@ -135,7 +134,7 @@ pub fn generate_query_find(

#fetch.map(|found| closure(#(#attrs #bind),*))
}
#ArchetypeSelectInternalWorld::#ArchetypeDirect(#resolved_entity) => {
#__WorldSelectTotal::#ArchetypeDirect(#resolved_entity) => {
// Alias the current archetype for use in the closure.
type MatchedArchetype = #Archetype;
// The closure needs to be made per-archetype because of OneOf types.
Expand All @@ -158,7 +157,7 @@ pub fn generate_query_find(
} else {
Ok(quote!(
{
match #ArchetypeSelectInternalWorld::try_from(#entity).expect("invalid entity type") {
match #__WorldSelectTotal::try_from(#entity).expect("invalid entity type") {
#(#queries)*
_ => None,
}
Expand Down Expand Up @@ -194,6 +193,12 @@ fn find_bind_mut(param: &ParseQueryParam) -> TokenStream {
ParseQueryParamType::OneOf(_) => {
panic!("must unpack OneOf first")
}
ParseQueryParamType::With(_) => {
todo!() // Not yet implemented
}
ParseQueryParamType::Without(_) => {
todo!() // Not yet implemented
}
}
}

Expand Down Expand Up @@ -226,6 +231,12 @@ fn find_bind_borrow(param: &ParseQueryParam) -> TokenStream {
}
ParseQueryParamType::OneOf(_) => {
panic!("must unpack OneOf first")
}
ParseQueryParamType::With(_) => {
todo!() // Not yet implemented
}
ParseQueryParamType::Without(_) => {
todo!() // Not yet implemented
}
}
}
Expand Down Expand Up @@ -495,6 +506,12 @@ fn iter_bind_mut(param: &ParseQueryParam) -> TokenStream {
}
ParseQueryParamType::OneOf(_) => {
panic!("must unpack OneOf first")
}
ParseQueryParamType::With(_) => {
todo!() // Not yet implemented
}
ParseQueryParamType::Without(_) => {
todo!() // Not yet implemented
}
}
}
Expand Down Expand Up @@ -528,6 +545,12 @@ fn iter_bind_borrow(param: &ParseQueryParam) -> TokenStream {
}
ParseQueryParamType::OneOf(_) => {
panic!("must unpack OneOf first")
}
ParseQueryParamType::With(_) => {
todo!() // Not yet implemented
}
ParseQueryParamType::Without(_) => {
todo!() // Not yet implemented
}
}
}
Expand All @@ -549,6 +572,8 @@ fn to_type(param: &ParseQueryParam, archetype: &DataArchetype) -> TokenStream {
ParseQueryParamType::EntityDirectAny => quote!(EntityDirectAny),
ParseQueryParamType::EntityDirectWild => quote!(EntityDirect<#archetype_name>),
ParseQueryParamType::OneOf(_) => panic!("must unpack OneOf first"),
ParseQueryParamType::With(_) => todo!(),
ParseQueryParamType::Without(_) => todo!(),
}
}

Expand Down Expand Up @@ -651,6 +676,12 @@ fn bind_query_params(
continue; // No need to check more
}
}
ParseQueryParamType::With(_) => {
todo!() // Not yet implemented
}
ParseQueryParamType::Without(_) => {
todo!() // Not yet implemented
}
}
}

Expand Down
Loading

0 comments on commit 993fc64

Please sign in to comment.