Skip to content

Conversation

@MrGVSV
Copy link
Member

@MrGVSV MrGVSV commented Jul 6, 2024

Objective

Function reflection requires a lot of macro code generation in the form of several all_tuples! invocations, as well as impls generated in the Reflect derive macro.

Seeing as function reflection is currently a bit more niche, it makes sense to gate it all behind a feature.

Solution

Add a functions feature to bevy_reflect, which can be enabled in Bevy using the reflect_functions feature.

Testing

You can test locally by running:

cargo test --package bevy_reflect

That should ensure that everything still works with the feature disabled.

To test with the feature on, you can run:

cargo test --package bevy_reflect --features functions

Changelog

  • Moved function reflection behind a Cargo feature (bevy/reflect_functions and bevy_reflect/functions)
  • Add IntoFunction export in bevy_reflect::prelude

Internal Migration Guide

Important

Function reflection was introduced as part of the 0.15 dev cycle. This migration guide was written for developers relying on main during 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:

  • If using bevy_reflect directly, enable the functions feature
  • If using bevy, enable the reflect_functions feature

@MrGVSV MrGVSV added D-Trivial Nice and easy! A great choice to get started with Bevy A-Reflection Runtime information about types S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 6, 2024
@MrGVSV MrGVSV force-pushed the mrgvsv/reflect/function-feature branch from 0bc4c03 to df2c349 Compare July 6, 2024 05:22
bevy_state = ["bevy_internal/bevy_state"]

# Enable function reflection
reflect_functions = ["bevy_internal/reflect_functions"]
Copy link
Member Author

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.

Copy link
Member

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.

Comment on lines +522 to +523
#[cfg(feature = "functions")]
pub use crate::func::IntoFunction;
Copy link
Member Author

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!

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 14, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jul 14, 2024
Merged via the queue into bevyengine:main with commit 99c9218 Jul 14, 2024
@MrGVSV MrGVSV deleted the mrgvsv/reflect/function-feature branch July 15, 2024 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Reflection Runtime information about types D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants