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

Remove TypeUuid #11497

Merged
merged 7 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
4 changes: 2 additions & 2 deletions crates/bevy_asset/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use bevy_ecs::{
prelude::EventWriter,
system::{Res, ResMut, Resource},
};
use bevy_reflect::{Reflect, TypePath, Uuid};
use bevy_utils::HashMap;
use bevy_reflect::{Reflect, TypePath};
use bevy_utils::{HashMap, Uuid};
use crossbeam_channel::{Receiver, Sender};
use serde::{Deserialize, Serialize};
use std::{
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_asset/src/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::{
UntypedAssetId,
};
use bevy_ecs::prelude::*;
use bevy_reflect::{Reflect, TypePath, Uuid};
use bevy_utils::get_short_name;
use bevy_reflect::{Reflect, TypePath};
use bevy_utils::{get_short_name, Uuid};
use crossbeam_channel::{Receiver, Sender};
use std::{
any::TypeId,
Expand Down
4 changes: 3 additions & 1 deletion crates/bevy_asset/src/id.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::{Asset, AssetIndex};
use bevy_reflect::{Reflect, Uuid};
use bevy_reflect::Reflect;
use bevy_utils::Uuid;

use std::{
any::TypeId,
fmt::{Debug, Display},
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use std::marker::PhantomData;
/// ```
/// # use bevy_pbr::{Material, MaterialMeshBundle};
/// # use bevy_ecs::prelude::*;
/// # use bevy_reflect::{TypeUuid, TypePath};
/// # use bevy_reflect::TypePath;
/// # use bevy_render::{render_resource::{AsBindGroup, ShaderRef}, texture::Image, color::Color};
/// # use bevy_asset::{Handle, AssetServer, Assets, Asset};
///
Expand Down
5 changes: 2 additions & 3 deletions crates/bevy_pbr/src/wireframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{Material, MaterialPipeline, MaterialPipelineKey, MaterialPlugin};
use bevy_app::{Plugin, Startup, Update};
use bevy_asset::{load_internal_asset, Asset, Assets, Handle};
use bevy_ecs::prelude::*;
use bevy_reflect::{std_traits::ReflectDefault, Reflect, TypePath, TypeUuid};
use bevy_reflect::{std_traits::ReflectDefault, Reflect, TypePath};
use bevy_render::{
color::Color,
extract_resource::ExtractResource,
Expand Down Expand Up @@ -194,8 +194,7 @@ fn apply_global_wireframe_material(
}
}

#[derive(Default, AsBindGroup, TypeUuid, TypePath, Debug, Clone, Asset)]
#[uuid = "9e694f70-9963-4418-8bc1-3474c66b13b8"]
#[derive(Default, AsBindGroup, TypePath, Debug, Clone, Asset)]
pub struct WireframeMaterial {
#[uniform(0)]
pub color: Color,
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_reflect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ glam = { version = "0.25", features = ["serde"], optional = true }
smol_str = { version = "0.2.0", optional = true }

[dev-dependencies]
glam = { version = "0.25", features = ["serde"] }
ron = "0.8.0"
rmp-serde = "1.1"
bincode = "1.3"
Expand Down
32 changes: 2 additions & 30 deletions crates/bevy_reflect/bevy_reflect_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
//! such as `Struct`, `GetTypeRegistration`, and more— all with a single derive!
//!
//! Some other noteworthy exports include the derive macros for [`FromReflect`] and
//! [`TypeUuid`], as well as the [`reflect_trait`] attribute macro.
//! [`TypePath`], as well as the [`reflect_trait`] attribute macro.
//!
//! [`Reflect`]: crate::derive_reflect
//! [`FromReflect`]: crate::derive_from_reflect
//! [`TypeUuid`]: crate::derive_type_uuid
//! [`TypePath`]: crate::derive_type_path
//! [`reflect_trait`]: macro@reflect_trait

extern crate proc_macro;
Expand All @@ -27,7 +27,6 @@ mod registration;
mod serialization;
mod trait_reflection;
mod type_path;
mod type_uuid;
mod utility;

use crate::derive_data::{ReflectDerive, ReflectMeta, ReflectStruct};
Expand Down Expand Up @@ -291,20 +290,6 @@ pub fn derive_type_path(input: TokenStream) -> TokenStream {
})
}

// From https://github.com/randomPoison/type-uuid
#[proc_macro_derive(TypeUuid, attributes(uuid))]
pub fn derive_type_uuid(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput);
let uuid_impl =
type_uuid::type_uuid_derive(input).unwrap_or_else(syn::Error::into_compile_error);

TokenStream::from(quote! {
const _: () = {
#uuid_impl
};
})
}

/// A macro that automatically generates type data for traits, which their implementors can then register.
///
/// The output of this macro is a struct that takes reflected instances of the implementor's type
Expand Down Expand Up @@ -616,16 +601,3 @@ pub fn impl_type_path(input: TokenStream) -> TokenStream {
};
})
}

/// Derives `TypeUuid` for the given type. This is used internally to implement `TypeUuid` on foreign types, such as those in the std. This macro should be used in the format of `<[Generic Params]> [Type (Path)], [Uuid (String Literal)]`.
#[proc_macro]
pub fn impl_type_uuid(input: TokenStream) -> TokenStream {
let def = parse_macro_input!(input as type_uuid::TypeUuidDef);
let uuid_impl = type_uuid::gen_impl_type_uuid(def);

TokenStream::from(quote! {
const _: () = {
#uuid_impl
};
})
}
108 changes: 0 additions & 108 deletions crates/bevy_reflect/bevy_reflect_derive/src/type_uuid.rs

This file was deleted.

10 changes: 4 additions & 6 deletions crates/bevy_reflect/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,6 @@ mod tuple_struct;
mod type_info;
mod type_path;
mod type_registry;
mod type_uuid;
mod type_uuid_impl;
mod impls {
#[cfg(feature = "glam")]
mod glam;
Expand Down Expand Up @@ -523,7 +521,6 @@ pub use tuple_struct::*;
pub use type_info::*;
pub use type_path::*;
pub use type_registry::*;
pub use type_uuid::*;

pub use bevy_reflect_derive::*;
pub use erased_serde;
Expand All @@ -538,14 +535,15 @@ pub mod __macro_exports {
#[cfg(test)]
#[allow(clippy::disallowed_types, clippy::approx_constant)]
mod tests {
#[cfg(feature = "glam")]
use ::glam::{quat, vec3, Quat, Vec3};
use ::serde::{de::DeserializeSeed, Deserialize, Serialize};
use bevy_utils::HashMap;
#[rustfmt::skip]
use ::glam::{quat, vec3, Quat, Vec3};
AxiomaticSemantics marked this conversation as resolved.
Show resolved Hide resolved
use ron::{
ser::{to_string_pretty, PrettyConfig},
Deserializer,
};
#[rustfmt::skip]
use ::serde::{de::DeserializeSeed, Deserialize, Serialize};
use std::{
any::TypeId,
borrow::Cow,
Expand Down
Loading