Repository navigation
Conversation
| #[test] | ||
| fn arrays_in_bsn() { | ||
| #[derive(Component)] | ||
| struct Foo(Vec<Entity>); |
There was a problem hiding this comment.
Can we have another test case where the internals are a true array of [Entity; 3]?
There was a problem hiding this comment.
And then use direct literal construction for it.
| bracketed!(content in forked); | ||
| let parse_punctuated_bsn_values = || -> Result<Vec<BsnValue>> { | ||
| let mut values = Vec::new(); | ||
| parse_punctuated_vec_autocomplete_friendly!(values, content, BsnValue, Comma); |
There was a problem hiding this comment.
I've swapped out the default "punctuated" parsing logic for our "autocomplete friendly" parsing logic
cart
left a comment
There was a problem hiding this comment.
I'm on board for the general direction here. I'm thinking ultimately we'll want to consider making this a BsnValue variant so we can support it in arbitrary value positions, but that does mean making our parsing logic more expensive and complicated. This is a good temporary solution.
alice-i-cecile
left a comment
There was a problem hiding this comment.
This looks basically good, but there are a few regressions introduced. See zincdev0#1 for some failing tests.
The core problem here is that BsnFnArg::parse commits to "aha! an array!" too eagerly :)
| #[test] | ||
| fn arrays_in_bsn() { | ||
| #[derive(Component)] | ||
| struct Foo(Vec<Entity>); |
There was a problem hiding this comment.
And then use direct literal construction for it.
Objective
Currently, entity references in bsn are limited to positions where
BsnValues are parsed.This PR addresses that limitation for arrays in function arguments. The entity reference limitations of bsn should probably not be addressed individually, but this particular case is kind of a blocker for allowing bevy_enhanced_input to use bsn.
Solution
A new variant has been added to
BsnFnArgfor arrays, which allows any amount ofBsnValues in a list.Testing
A regression test (
arrays_in_bsn) has been added tocrates/bevy_scene/src/lib.rs.