Skip to content

Commit

Permalink
Redesign ComponentAccessExpr, improve error diagnostics (#35)
Browse files Browse the repository at this point in the history
This PR redesigns the `ComponentAccessExpr` type to track access
conflicts more precisely. Queries such as `Or<Or<(&mut A, With<&B>),
(&A, Not<&B>)>, (&A, Not<&B>)>` and `(&mut A, &mut A, Not<&A>)` will now
pass the component access checker.

Additionally, we now defer access errors until after handler init has
finished. This improves diagnostics by showing a list of all access
conflicts together.

## TODO

- [x] Clean up warnings
  • Loading branch information
rj00a authored Apr 5, 2024
1 parent ee968d7 commit 8ab990d
Show file tree
Hide file tree
Showing 16 changed files with 761 additions and 972 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## Unreleased

- Redesign component access checking. Complex queries will now pass the component access checker in more cases.
- Improve diagnostics for component access errors.
- Redesign `Config` interface to hide implementation details. (Now named `HandlerConfig`).
- Removed `bit_set` module from public API.

## 0.4.2 - 2024-03-24

- Fixed bug in entity despawning.
Expand Down
2 changes: 1 addition & 1 deletion evenio_macros/src/handler_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub(crate) fn derive_handler_param(input: TokenStream) -> Result<TokenStream> {

fn init(
world: &mut ::evenio::world::World,
config: &mut ::evenio::handler::Config,
config: &mut ::evenio::handler::HandlerConfig,
) -> ::core::result::Result<Self::State, ::evenio::handler::InitError>
{
<#tuple_ty as ::evenio::handler::HandlerParam>::init(world, config)
Expand Down
4 changes: 2 additions & 2 deletions evenio_macros/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ pub(crate) fn derive_query(input: TokenStream) -> Result<TokenStream> {

fn init(
world: &mut ::evenio::world::World,
config: &mut ::evenio::handler::Config
) -> ::core::result::Result<(::evenio::access::ComponentAccessExpr, Self::State), ::evenio::handler::InitError>
config: &mut ::evenio::handler::HandlerConfig
) -> ::core::result::Result<(::evenio::access::ComponentAccess, Self::State), ::evenio::handler::InitError>
{
<#tuple_ty as ::evenio::query::Query>::init(world, config)
}
Expand Down
Loading

0 comments on commit 8ab990d

Please sign in to comment.