-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
bevy_reflect: Feature-gate function reflection #14174
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
bevy_reflect: Feature-gate function reflection #14174
Conversation
0bc4c03 to
df2c349
Compare
| bevy_state = ["bevy_internal/bevy_state"] | ||
|
|
||
| # Enable function reflection | ||
| reflect_functions = ["bevy_internal/reflect_functions"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on naming? I originally had function_reflection, but I switched it to reflect_functions since it sounds a bit more like the bevy_reflect/functions.
I'm also trying to think about potential future features. For example, we have a bevy_reflect/documentation feature. Using this naming strategy, it could be reflect_documentation. And so on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I like this naming.
| #[cfg(feature = "functions")] | ||
| pub use crate::func::IntoFunction; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I was at it, I also included a prelude export for IntoFunction because I feel it would be useful to not have to import it every time. If we don't want to include it in the prelude, though, let me know and I can revert this!
Objective
Function reflection requires a lot of macro code generation in the form of several
all_tuples!invocations, as well as impls generated in theReflectderive macro.Seeing as function reflection is currently a bit more niche, it makes sense to gate it all behind a feature.
Solution
Add a
functionsfeature tobevy_reflect, which can be enabled in Bevy using thereflect_functionsfeature.Testing
You can test locally by running:
That should ensure that everything still works with the feature disabled.
To test with the feature on, you can run:
Changelog
bevy/reflect_functionsandbevy_reflect/functions)IntoFunctionexport inbevy_reflect::preludeInternal Migration Guide
Important
Function reflection was introduced as part of the 0.15 dev cycle. This migration guide was written for developers relying on
mainduring this cycle, and is not a breaking change coming from 0.14.Function reflection is now gated behind a feature. To use function reflection, enable the feature:
bevy_reflectdirectly, enable thefunctionsfeaturebevy, enable thereflect_functionsfeature