Skip to content
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

reflect: stable type path v2 #7184

Merged
merged 56 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
91cafeb
a lot.
soqb Jan 10, 2023
2beb8de
compiles!
soqb Jan 13, 2023
8ea850f
`type_name` attributes
soqb Jan 13, 2023
fc45a9a
better test
soqb Jan 13, 2023
190cf5c
`cargo fmt --all`
soqb Jan 13, 2023
171d528
first pass docs
soqb Jan 14, 2023
5c7e113
primitive fix
soqb Jan 14, 2023
0cb050a
messy rebase & ci
soqb Jan 14, 2023
6929d9c
ci wrangling
soqb Jan 14, 2023
7f8f7a9
const generics
soqb Jan 14, 2023
4fe6989
`cargo fmt --all`
soqb Jan 14, 2023
ec4c78e
use literals where possible
soqb Jan 27, 2023
c54b776
remove `TypePathStorage`
soqb Jan 27, 2023
b79e3d0
added `DynamicTypePath`
soqb Jan 27, 2023
52719c1
`cargo fmt --all`
soqb Jan 27, 2023
973759b
fix one implementation
soqb Jan 28, 2023
b523e91
cleanup
soqb Jan 28, 2023
f867b1e
fix examples
soqb Jan 28, 2023
d03725f
improve docs
soqb Jan 28, 2023
43cecd1
fix method names
soqb Jan 28, 2023
0434345
docs for `ReflectTypePath`
soqb Jan 28, 2023
f726916
decouple `impl_type_path` from `impl_typed`
soqb Jan 28, 2023
280ab6a
rebase
soqb Jan 28, 2023
31fad8c
`cargo fmt --all`
soqb Jan 28, 2023
033b7ac
fix `extend_where_clause`
soqb Jan 28, 2023
974d499
`cargo fmt --all`
soqb Jan 28, 2023
d59c3fb
ci fixes
soqb Jan 28, 2023
cdb356e
Merge branch 'main' of https://github.com/bevyengine/bevy into reflec…
soqb Mar 23, 2023
a58bdb6
audio sink
soqb Mar 23, 2023
ff846ca
fixed issues
soqb Mar 23, 2023
0fa7142
revise `WhereClauseOptions`
soqb Mar 23, 2023
2a2bccf
docs
soqb Mar 23, 2023
f25cac0
doc fixes
soqb Mar 23, 2023
b600b85
refactor `TypedProperty`
soqb Mar 26, 2023
d5ee8e8
improve `(Non)GenericTypeCell`
soqb Mar 26, 2023
dad224f
remove superfluous colon seperators
soqb Mar 26, 2023
395f907
better tests
soqb Mar 26, 2023
b52deba
fix doc test
soqb Mar 26, 2023
1f173ca
document `*TypeCell` aliases
soqb Mar 26, 2023
a68ebce
fix various ci
soqb Mar 26, 2023
a42c641
ci tweaks
soqb Mar 27, 2023
a771aea
prefix custom paths
soqb Mar 27, 2023
c12ad4b
`path_to_type` -> `type_path`
soqb Mar 27, 2023
ee798d6
generics on `ReflectTypePath`, prefix custom path
soqb Apr 4, 2023
4b0acbb
Merge branch 'main' of https://github.com/bevyengine/bevy into reflec…
soqb Apr 4, 2023
b10dbd2
revert formatting of `Cargo.toml` so ci passes
soqb Apr 4, 2023
04b395b
typecell in derive refactor
soqb Apr 4, 2023
fd02571
introduce `StringExpr`
soqb Apr 4, 2023
8003efe
appease clippy
soqb Apr 4, 2023
1010ed9
review feedback + hashbrown fix
soqb Apr 23, 2023
5caf285
Merge branch 'main' of https://github.com/bevyengine/bevy into reflec…
soqb Apr 23, 2023
21600e4
Merge branch 'main' of https://github.com/bevyengine/bevy into reflec…
soqb Jun 5, 2023
63b85e5
rebase part 2
soqb Jun 5, 2023
6f807a5
bless rust 1.70
soqb Jun 5, 2023
6e22c5a
revert compile fail changes
soqb Jun 5, 2023
3fea3c6
doctest fix
soqb Jun 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/bevy_asset/src/asset_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub struct AssetServerInternal {
/// use bevy_asset::{AssetServer, Handle};
/// use bevy_ecs::prelude::{Commands, Res};
///
/// # #[derive(Debug, bevy_reflect::TypeUuid)]
/// # #[derive(Debug, bevy_reflect::TypeUuid, bevy_reflect::TypePath)]
/// # #[uuid = "00000000-0000-0000-0000-000000000000"]
/// # struct Image;
///
Expand Down Expand Up @@ -646,10 +646,10 @@ mod test {
use crate::{loader::LoadedAsset, update_asset_storage_system};
use bevy_app::{App, Update};
use bevy_ecs::prelude::*;
use bevy_reflect::TypeUuid;
use bevy_reflect::{TypePath, TypeUuid};
use bevy_utils::BoxedFuture;

#[derive(Debug, TypeUuid)]
#[derive(Debug, TypeUuid, TypePath)]
#[uuid = "a5189b72-0572-4290-a2e0-96f73a491c44"]
struct PngAsset;

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ mod tests {

#[test]
fn asset_overwriting() {
#[derive(bevy_reflect::TypeUuid)]
#[derive(bevy_reflect::TypeUuid, bevy_reflect::TypePath)]
#[uuid = "44115972-f31b-46e5-be5c-2b9aece6a52f"]
struct MyAsset;
let mut app = App::new();
Expand Down
5 changes: 3 additions & 2 deletions crates/bevy_asset/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::{
use anyhow::Error;
use anyhow::Result;
use bevy_ecs::system::{Res, ResMut};
use bevy_reflect::TypePath;
use bevy_reflect::{TypeUuid, TypeUuidDynamic};
use bevy_utils::{BoxedFuture, HashMap};
use crossbeam_channel::{Receiver, Sender};
Expand Down Expand Up @@ -47,13 +48,13 @@ pub trait AssetLoader: Send + Sync + 'static {
///
/// In order to load assets into your game you must either add them manually to an asset storage
/// with [`Assets::add`] or load them from the filesystem with [`AssetServer::load`].
pub trait Asset: TypeUuid + AssetDynamic {}
pub trait Asset: TypeUuid + TypePath + AssetDynamic {}

/// An untyped version of the [`Asset`] trait.
pub trait AssetDynamic: Downcast + TypeUuidDynamic + Send + Sync + 'static {}
impl_downcast!(AssetDynamic);

impl<T> Asset for T where T: TypeUuid + AssetDynamic + TypeUuidDynamic {}
impl<T> Asset for T where T: TypeUuid + TypePath + AssetDynamic + TypeUuidDynamic {}

impl<T> AssetDynamic for T where T: Send + Sync + 'static + TypeUuidDynamic {}

Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_audio/src/audio_source.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use anyhow::Result;
use bevy_asset::{Asset, AssetLoader, LoadContext, LoadedAsset};
use bevy_reflect::TypeUuid;
use bevy_reflect::{TypePath, TypeUuid};
use bevy_utils::BoxedFuture;
use std::{io::Cursor, sync::Arc};

/// A source of audio data
#[derive(Debug, Clone, TypeUuid)]
#[derive(Debug, Clone, TypeUuid, TypePath)]
#[uuid = "7a14806a-672b-443b-8d16-4f18afefa463"]
pub struct AudioSource {
/// Raw data of the audio source.
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_audio/src/sinks.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy_math::Vec3;
use bevy_reflect::TypeUuid;
use bevy_reflect::{TypePath, TypeUuid};
use bevy_transform::prelude::Transform;
use rodio::{Sink, SpatialSink};

Expand Down Expand Up @@ -84,7 +84,7 @@ pub trait AudioSinkPlayback {
/// }
/// ```
///
#[derive(TypeUuid)]
#[derive(TypePath, TypeUuid)]
#[uuid = "8BEE570C-57C2-4FC0-8CFB-983A22F7D981"]
pub struct AudioSink {
// This field is an Option in order to allow us to have a safe drop that will detach the sink.
Expand Down Expand Up @@ -151,7 +151,7 @@ impl AudioSinkPlayback for AudioSink {
/// }
/// ```
///
#[derive(TypeUuid)]
#[derive(TypePath, TypeUuid)]
#[uuid = "F3CA4C47-595E-453B-96A7-31C3DDF2A177"]
pub struct SpatialAudioSink {
// This field is an Option in order to allow us to have a safe drop that will detach the sink.
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ impl<C: Resource + Reflect + FromWorld> FromType<C> for ReflectResource {
}
}

impl_reflect_value!(Entity(Hash, PartialEq, Serialize, Deserialize));
impl_reflect_value!((in bevy_ecs) Entity(Hash, PartialEq, Serialize, Deserialize));
impl_from_reflect_value!(Entity);

#[derive(Clone)]
Expand Down
10 changes: 5 additions & 5 deletions crates/bevy_gltf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use bevy_app::prelude::*;
use bevy_asset::{AddAsset, Handle};
use bevy_ecs::{prelude::Component, reflect::ReflectComponent};
use bevy_pbr::StandardMaterial;
use bevy_reflect::{Reflect, TypeUuid};
use bevy_reflect::{Reflect, TypePath, TypeUuid};
use bevy_render::mesh::Mesh;
use bevy_scene::Scene;

Expand All @@ -29,7 +29,7 @@ impl Plugin for GltfPlugin {
}

/// Representation of a loaded glTF file.
#[derive(Debug, TypeUuid)]
#[derive(Debug, TypeUuid, TypePath)]
#[uuid = "5c7d5f8a-f7b0-4e45-a09e-406c0372fea2"]
pub struct Gltf {
pub scenes: Vec<Handle<Scene>>,
Expand All @@ -49,7 +49,7 @@ pub struct Gltf {

/// A glTF node with all of its child nodes, its [`GltfMesh`],
/// [`Transform`](bevy_transform::prelude::Transform) and an optional [`GltfExtras`].
#[derive(Debug, Clone, TypeUuid)]
#[derive(Debug, Clone, TypeUuid, TypePath)]
#[uuid = "dad74750-1fd6-460f-ac51-0a7937563865"]
pub struct GltfNode {
pub children: Vec<GltfNode>,
Expand All @@ -60,15 +60,15 @@ pub struct GltfNode {

/// A glTF mesh, which may consist of multiple [`GltfPrimitives`](GltfPrimitive)
/// and an optional [`GltfExtras`].
#[derive(Debug, Clone, TypeUuid)]
#[derive(Debug, Clone, TypeUuid, TypePath)]
#[uuid = "8ceaec9a-926a-4f29-8ee3-578a69f42315"]
pub struct GltfMesh {
pub primitives: Vec<GltfPrimitive>,
pub extras: Option<GltfExtras>,
}

/// Part of a [`GltfMesh`] that consists of a [`Mesh`], an optional [`StandardMaterial`] and [`GltfExtras`].
#[derive(Debug, Clone, TypeUuid)]
#[derive(Debug, Clone, TypeUuid, TypePath)]
#[uuid = "cbfca302-82fd-41cb-af77-cab6b3d50af1"]
pub struct GltfPrimitive {
pub mesh: Handle<Mesh>,
Expand Down
4 changes: 3 additions & 1 deletion crates/bevy_input/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,12 @@ where

#[cfg(test)]
mod test {
use bevy_reflect::TypePath;

use crate::Input;

/// Used for testing the functionality of [`Input`].
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
#[derive(TypePath, Copy, Clone, Eq, PartialEq, Hash)]
enum DummyInput {
Input1,
Input2,
Expand Down
10 changes: 6 additions & 4 deletions crates/bevy_pbr/src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use bevy_ecs::{
SystemParamItem,
},
};
use bevy_reflect::TypeUuid;
use bevy_reflect::{TypePath, TypeUuid};
use bevy_render::{
extract_component::ExtractComponentPlugin,
mesh::{Mesh, MeshVertexBufferLayout},
Expand Down Expand Up @@ -58,11 +58,11 @@ use std::marker::PhantomData;
/// ```
/// # use bevy_pbr::{Material, MaterialMeshBundle};
/// # use bevy_ecs::prelude::*;
/// # use bevy_reflect::TypeUuid;
/// # use bevy_reflect::{TypeUuid, TypePath};
/// # use bevy_render::{render_resource::{AsBindGroup, ShaderRef}, texture::Image, color::Color};
/// # use bevy_asset::{Handle, AssetServer, Assets};
///
/// #[derive(AsBindGroup, TypeUuid, Debug, Clone)]
/// #[derive(AsBindGroup, TypeUuid, TypePath, Debug, Clone)]
/// #[uuid = "f690fdae-d598-45ab-8225-97e2a3f056e0"]
/// pub struct CustomMaterial {
/// // Uniform bindings must implement `ShaderType`, which will be used to convert the value to
Expand Down Expand Up @@ -105,7 +105,9 @@ use std::marker::PhantomData;
/// @group(1) @binding(2)
/// var color_sampler: sampler;
/// ```
pub trait Material: AsBindGroup + Send + Sync + Clone + TypeUuid + Sized + 'static {
pub trait Material:
AsBindGroup + Send + Sync + Clone + TypeUuid + TypePath + Sized + 'static
{
/// Returns this material's vertex shader. If [`ShaderRef::Default`] is returned, the default mesh vertex shader
/// will be used.
fn vertex_shader() -> ShaderRef {
Expand Down
Loading