Skip to content

reflect: stable type path v2#7184

Merged
alice-i-cecile merged 56 commits intobevyengine:mainfrom
soqb:reflect-type-path
Jun 5, 2023
Merged

reflect: stable type path v2#7184
alice-i-cecile merged 56 commits intobevyengine:mainfrom
soqb:reflect-type-path

Conversation

@soqb
Copy link
Contributor

@soqb soqb commented Jan 13, 2023

Objective

Solution

  • Add a TypePath trait for static stable type path/name information.
  • Add a TypePath derive macro.
  • Add a impl_type_path macro for implementing internal and foreign types in bevy_reflect.

Changelog

  • Added TypePath trait.
  • Added DynamicTypePath trait and get_type_path method to Reflect.
  • Added a TypePath derive macro.
  • Added a bevy_reflect::impl_type_path for implementing TypePath on internal and foreign types in bevy_reflect.
  • Changed bevy_reflect::utility::(Non)GenericTypeInfoCell to (Non)GenericTypedCell<T> which allows us to be generic over both TypeInfo and TypePath.
  • TypePath is now a supertrait of Asset, Material and Material2d.
  • impl_reflect_struct needs a #[type_path = "..."] attribute to be specified.
  • impl_reflect_value needs to either specify path starting with a double colon (::core::option::Option) or an in my_crate::foo declaration.
  • Added bevy_reflect_derive::ReflectTypePath.
  • Most uses of Ident in bevy_reflect_derive changed to use ReflectTypePath.

Migration Guide

  • Implementors of Asset, Material and Material2d now also need to derive TypePath.
  • Manual implementors of Reflect will need to implement the new get_type_path method.

Open Questions

  • This PR currently does not migrate any usages of std::any::type_name to use bevy_reflect::TypePath to ease the review process. Should it? Migration will be left to a follow-up PR.
  • This PR adds a lot of #[derive(TypePath)] and T: TypePath to satisfy new bounds, mostly when deriving TypeUuid. Should we make TypePath a supertrait of TypeUuid? Should we remove TypeUuid in favour of TypePath?

Loading
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 C-Feature A new feature, making something new possible D-Complex Quite challenging from either a design or technical perspective. Ask for help! M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

No open projects
Status: In Progress

Development

Successfully merging this pull request may close these issues.

8 participants