bevy/crates
radiish 1efc762924
reflect: stable type path v2 (#7184)
# Objective

- Introduce a stable alternative to
[`std::any::type_name`](https://doc.rust-lang.org/std/any/fn.type_name.html).
- Rewrite of #5805 with heavy inspiration in design.
- On the path to #5830.
- Part of solving #3327.


## 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
- [x] ~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`?](2afbd85532 (r961067892))
2023-06-05 20:31:20 +00:00
..
bevy_a11y Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_animation Fixed several missing links in docs. (#8117) 2023-04-23 17:28:36 +00:00
bevy_app fix warning: variable does not need to be mutable (#8688) 2023-05-27 20:50:40 +00:00
bevy_asset reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
bevy_audio reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
bevy_core Add Reflect and FromReflect for AssetPath (#8531) 2023-05-08 19:19:19 +00:00
bevy_core_pipeline Change Camera3dBundle::tonemapping to Default (#8753) 2023-06-05 01:50:03 +00:00
bevy_derive bevy_derive: Add #[deref] attribute (#8552) 2023-05-16 18:29:09 +00:00
bevy_diagnostic Update cargo deny configuration (#8734) 2023-06-01 16:29:45 +00:00
bevy_dylib Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_dynamic_plugin Update libloading requirement from 0.7 to 0.8 (#8649) 2023-05-22 20:04:15 +00:00
bevy_ecs reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
bevy_ecs_compile_fail_tests Resolve clippy issues for rust 1.70.0 (#8738) 2023-06-01 21:05:05 +00:00
bevy_encase_derive update syn, encase, glam and hexasphere (#8573) 2023-05-16 01:24:17 +00:00
bevy_gilrs Add gamepad rumble support to bevy_input (#8398) 2023-04-24 15:28:53 +00:00
bevy_gizmos Webgpu support (#8336) 2023-05-04 22:07:57 +00:00
bevy_gltf reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
bevy_hierarchy Expose sorting methods in Children (#8522) 2023-05-01 15:57:25 +00:00
bevy_input reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
bevy_internal Add support for pnm textures (#8601) 2023-05-16 23:51:47 +00:00
bevy_log Update android_log-sys requirement from 0.2.0 to 0.3.0 (#7925) 2023-06-01 07:55:33 +00:00
bevy_macro_utils update syn, encase, glam and hexasphere (#8573) 2023-05-16 01:24:17 +00:00
bevy_macros_compile_fail_tests bevy_derive: Add #[deref] attribute (#8552) 2023-05-16 18:29:09 +00:00
bevy_math Add CubicCurve::segment_count + iter_samples adjustment (#8711) 2023-05-31 14:57:37 +00:00
bevy_mikktspace update syn, encase, glam and hexasphere (#8573) 2023-05-16 01:24:17 +00:00
bevy_pbr reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
bevy_ptr Fixed several missing links in docs. (#8117) 2023-04-23 17:28:36 +00:00
bevy_reflect reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
bevy_reflect_compile_fail_tests reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
bevy_render reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
bevy_scene reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
bevy_sprite reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
bevy_tasks remove some use of once_cell that can be replace with new std (#8739) 2023-06-01 21:55:18 +00:00
bevy_text reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
bevy_time Hide naga info logs & Derive PartialEq on Timer and Stopwatch (#8664) 2023-05-24 15:16:15 +00:00
bevy_transform Rename apply_system_buffers to apply_deferred (#8726) 2023-06-02 14:04:13 +00:00
bevy_ui Move bevy_ui accessibility systems to PostUpdate. (#8653) 2023-05-23 23:50:48 +00:00
bevy_utils Fix all_tuples + added docs. (#8743) 2023-06-02 16:05:27 +00:00
bevy_window Correct RequestRedraw documentation (#8640) 2023-05-23 02:16:56 +00:00
bevy_winit remove some use of once_cell that can be replace with new std (#8739) 2023-06-01 21:55:18 +00:00