mirror of
https://github.com/bevyengine/bevy
synced 2024-11-23 05:03:47 +00:00
Reflect now requires DynamicTypePath. Remove Reflect::get_type_path() (#8764)
Followup to #7184 This makes `Reflect: DynamicTypePath` which allows us to remove `Reflect::get_type_path`, reducing unnecessary codegen and simplifying `Reflect` implementations.
This commit is contained in:
parent
89cbc78d3d
commit
8b9d88f4d0
17 changed files with 36 additions and 143 deletions
|
@ -199,11 +199,6 @@ pub(crate) fn impl_enum(reflect_enum: &ReflectEnum) -> TokenStream {
|
||||||
#FQOption::Some(<Self as #bevy_reflect_path::Typed>::type_info())
|
#FQOption::Some(<Self as #bevy_reflect_path::Typed>::type_info())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn get_type_path(&self) -> &dyn #bevy_reflect_path::DynamicTypePath {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into_any(self: #FQBox<Self>) -> #FQBox<dyn #FQAny> {
|
fn into_any(self: #FQBox<Self>) -> #FQBox<dyn #FQAny> {
|
||||||
self
|
self
|
||||||
|
|
|
@ -174,11 +174,6 @@ pub(crate) fn impl_struct(reflect_struct: &ReflectStruct) -> TokenStream {
|
||||||
#FQOption::Some(<Self as #bevy_reflect_path::Typed>::type_info())
|
#FQOption::Some(<Self as #bevy_reflect_path::Typed>::type_info())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn get_type_path(&self) -> &dyn #bevy_reflect_path::DynamicTypePath {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into_any(self: #FQBox<Self>) -> #FQBox<dyn #FQAny> {
|
fn into_any(self: #FQBox<Self>) -> #FQBox<dyn #FQAny> {
|
||||||
self
|
self
|
||||||
|
|
|
@ -144,11 +144,6 @@ pub(crate) fn impl_tuple_struct(reflect_struct: &ReflectStruct) -> TokenStream {
|
||||||
#FQOption::Some(<Self as #bevy_reflect_path::Typed>::type_info())
|
#FQOption::Some(<Self as #bevy_reflect_path::Typed>::type_info())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn get_type_path(&self) -> &dyn #bevy_reflect_path::DynamicTypePath {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into_any(self: #FQBox<Self>) -> #FQBox<dyn #FQAny> {
|
fn into_any(self: #FQBox<Self>) -> #FQBox<dyn #FQAny> {
|
||||||
self
|
self
|
||||||
|
|
|
@ -56,11 +56,6 @@ pub(crate) fn impl_value(meta: &ReflectMeta) -> TokenStream {
|
||||||
#FQOption::Some(<Self as #bevy_reflect_path::Typed>::type_info())
|
#FQOption::Some(<Self as #bevy_reflect_path::Typed>::type_info())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn get_type_path(&self) -> &dyn #bevy_reflect_path::DynamicTypePath {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into_any(self: #FQBox<Self>) -> #FQBox<dyn #FQAny> {
|
fn into_any(self: #FQBox<Self>) -> #FQBox<dyn #FQAny> {
|
||||||
self
|
self
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use bevy_reflect_derive::impl_type_path;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
self as bevy_reflect, utility::reflect_hasher, DynamicTypePath, Reflect, ReflectMut,
|
self as bevy_reflect, utility::reflect_hasher, Reflect, ReflectMut, ReflectOwned, ReflectRef,
|
||||||
ReflectOwned, ReflectRef, TypeInfo,
|
TypeInfo,
|
||||||
};
|
};
|
||||||
|
use bevy_reflect_derive::impl_type_path;
|
||||||
use std::{
|
use std::{
|
||||||
any::{Any, TypeId},
|
any::{Any, TypeId},
|
||||||
fmt::Debug,
|
fmt::Debug,
|
||||||
|
@ -226,11 +225,6 @@ impl Reflect for DynamicArray {
|
||||||
self.represented_type
|
self.represented_type
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn get_type_path(&self) -> &dyn DynamicTypePath {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
||||||
self
|
self
|
||||||
|
|
|
@ -2,8 +2,8 @@ use bevy_reflect_derive::impl_type_path;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
self as bevy_reflect, enum_debug, enum_hash, enum_partial_eq, DynamicStruct, DynamicTuple,
|
self as bevy_reflect, enum_debug, enum_hash, enum_partial_eq, DynamicStruct, DynamicTuple,
|
||||||
DynamicTypePath, Enum, Reflect, ReflectMut, ReflectOwned, ReflectRef, Struct, Tuple, TypeInfo,
|
Enum, Reflect, ReflectMut, ReflectOwned, ReflectRef, Struct, Tuple, TypeInfo, VariantFieldIter,
|
||||||
VariantFieldIter, VariantType,
|
VariantType,
|
||||||
};
|
};
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::fmt::Formatter;
|
use std::fmt::Formatter;
|
||||||
|
@ -300,11 +300,6 @@ impl Reflect for DynamicEnum {
|
||||||
self.represented_type
|
self.represented_type
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn get_type_path(&self) -> &dyn DynamicTypePath {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
||||||
self
|
self
|
||||||
|
|
|
@ -4,9 +4,9 @@ use std::any::Any;
|
||||||
|
|
||||||
use crate::utility::GenericTypeInfoCell;
|
use crate::utility::GenericTypeInfoCell;
|
||||||
use crate::{
|
use crate::{
|
||||||
self as bevy_reflect, DynamicTypePath, FromReflect, FromType, GetTypeRegistration, List,
|
self as bevy_reflect, FromReflect, FromType, GetTypeRegistration, List, ListInfo, ListIter,
|
||||||
ListInfo, ListIter, Reflect, ReflectFromPtr, ReflectMut, ReflectOwned, ReflectRef, TypeInfo,
|
Reflect, ReflectFromPtr, ReflectMut, ReflectOwned, ReflectRef, TypeInfo, TypePath,
|
||||||
TypePath, TypeRegistration, Typed,
|
TypeRegistration, Typed,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<T: smallvec::Array + TypePath + Send + Sync> List for SmallVec<T>
|
impl<T: smallvec::Array + TypePath + Send + Sync> List for SmallVec<T>
|
||||||
|
@ -88,11 +88,6 @@ where
|
||||||
Some(<Self as Typed>::type_info())
|
Some(<Self as Typed>::type_info())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn get_type_path(&self) -> &dyn DynamicTypePath {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ use crate::std_traits::ReflectDefault;
|
||||||
use crate::{self as bevy_reflect, ReflectFromPtr, ReflectFromReflect, ReflectOwned};
|
use crate::{self as bevy_reflect, ReflectFromPtr, ReflectFromReflect, ReflectOwned};
|
||||||
use crate::{
|
use crate::{
|
||||||
impl_type_path, map_apply, map_partial_eq, Array, ArrayInfo, ArrayIter, DynamicEnum,
|
impl_type_path, map_apply, map_partial_eq, Array, ArrayInfo, ArrayIter, DynamicEnum,
|
||||||
DynamicMap, DynamicTypePath, Enum, EnumInfo, FromReflect, FromType, GetTypeRegistration, List,
|
DynamicMap, Enum, EnumInfo, FromReflect, FromType, GetTypeRegistration, List, ListInfo,
|
||||||
ListInfo, ListIter, Map, MapInfo, MapIter, Reflect, ReflectDeserialize, ReflectMut, ReflectRef,
|
ListIter, Map, MapInfo, MapIter, Reflect, ReflectDeserialize, ReflectMut, ReflectRef,
|
||||||
ReflectSerialize, TupleVariantInfo, TypeInfo, TypePath, TypeRegistration, Typed,
|
ReflectSerialize, TupleVariantInfo, TypeInfo, TypePath, TypeRegistration, Typed,
|
||||||
UnitVariantInfo, UnnamedField, ValueInfo, VariantFieldIter, VariantInfo, VariantType,
|
UnitVariantInfo, UnnamedField, ValueInfo, VariantFieldIter, VariantInfo, VariantType,
|
||||||
};
|
};
|
||||||
|
@ -332,11 +332,6 @@ macro_rules! impl_reflect_for_veclike {
|
||||||
Some(<Self as Typed>::type_info())
|
Some(<Self as Typed>::type_info())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn get_type_path(&self) -> &dyn DynamicTypePath {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -555,10 +550,6 @@ macro_rules! impl_reflect_for_hashmap {
|
||||||
Some(<Self as Typed>::type_info())
|
Some(<Self as Typed>::type_info())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_type_path(&self) -> &dyn DynamicTypePath {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -721,11 +712,6 @@ impl<T: Reflect + TypePath, const N: usize> Reflect for [T; N] {
|
||||||
Some(<Self as Typed>::type_info())
|
Some(<Self as Typed>::type_info())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn get_type_path(&self) -> &dyn DynamicTypePath {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
||||||
self
|
self
|
||||||
|
@ -943,11 +929,6 @@ impl<T: FromReflect + TypePath> Reflect for Option<T> {
|
||||||
Some(<Self as Typed>::type_info())
|
Some(<Self as Typed>::type_info())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn get_type_path(&self) -> &dyn DynamicTypePath {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
||||||
self
|
self
|
||||||
|
@ -1115,11 +1096,6 @@ impl Reflect for Cow<'static, str> {
|
||||||
Some(<Self as Typed>::type_info())
|
Some(<Self as Typed>::type_info())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn get_type_path(&self) -> &dyn DynamicTypePath {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -1252,11 +1228,6 @@ impl Reflect for &'static Path {
|
||||||
Some(<Self as Typed>::type_info())
|
Some(<Self as Typed>::type_info())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn get_type_path(&self) -> &dyn DynamicTypePath {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -1366,11 +1337,6 @@ impl Reflect for Cow<'static, Path> {
|
||||||
std::any::type_name::<Self>()
|
std::any::type_name::<Self>()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn get_type_path(&self) -> &dyn DynamicTypePath {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_represented_type_info(&self) -> Option<&'static TypeInfo> {
|
fn get_represented_type_info(&self) -> Option<&'static TypeInfo> {
|
||||||
Some(<Self as Typed>::type_info())
|
Some(<Self as Typed>::type_info())
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,7 @@ use bevy_reflect_derive::impl_type_path;
|
||||||
|
|
||||||
use crate::utility::reflect_hasher;
|
use crate::utility::reflect_hasher;
|
||||||
use crate::{
|
use crate::{
|
||||||
self as bevy_reflect, DynamicTypePath, FromReflect, Reflect, ReflectMut, ReflectOwned,
|
self as bevy_reflect, FromReflect, Reflect, ReflectMut, ReflectOwned, ReflectRef, TypeInfo,
|
||||||
ReflectRef, TypeInfo,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A trait used to power [list-like] operations via [reflection].
|
/// A trait used to power [list-like] operations via [reflection].
|
||||||
|
@ -276,11 +275,6 @@ impl Reflect for DynamicList {
|
||||||
self.represented_type
|
self.represented_type
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn get_type_path(&self) -> &dyn DynamicTypePath {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
||||||
self
|
self
|
||||||
|
|
|
@ -5,9 +5,7 @@ use std::hash::Hash;
|
||||||
use bevy_reflect_derive::impl_type_path;
|
use bevy_reflect_derive::impl_type_path;
|
||||||
use bevy_utils::{Entry, HashMap};
|
use bevy_utils::{Entry, HashMap};
|
||||||
|
|
||||||
use crate::{
|
use crate::{self as bevy_reflect, Reflect, ReflectMut, ReflectOwned, ReflectRef, TypeInfo};
|
||||||
self as bevy_reflect, DynamicTypePath, Reflect, ReflectMut, ReflectOwned, ReflectRef, TypeInfo,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// A trait used to power [map-like] operations via [reflection].
|
/// A trait used to power [map-like] operations via [reflection].
|
||||||
///
|
///
|
||||||
|
@ -310,11 +308,6 @@ impl Reflect for DynamicMap {
|
||||||
self.represented_type
|
self.represented_type
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn get_type_path(&self) -> &dyn DynamicTypePath {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ pub enum ReflectOwned {
|
||||||
/// [`bevy_reflect`]: crate
|
/// [`bevy_reflect`]: crate
|
||||||
/// [derive macro]: bevy_reflect_derive::Reflect
|
/// [derive macro]: bevy_reflect_derive::Reflect
|
||||||
/// [crate-level documentation]: crate
|
/// [crate-level documentation]: crate
|
||||||
pub trait Reflect: Any + Send + Sync {
|
pub trait Reflect: DynamicTypePath + Any + Send + Sync {
|
||||||
/// Returns the [type name][std::any::type_name] of the underlying type.
|
/// Returns the [type name][std::any::type_name] of the underlying type.
|
||||||
fn type_name(&self) -> &str;
|
fn type_name(&self) -> &str;
|
||||||
|
|
||||||
|
@ -93,14 +93,6 @@ pub trait Reflect: Any + Send + Sync {
|
||||||
/// [`TypeRegistry::get_type_info`]: crate::TypeRegistry::get_type_info
|
/// [`TypeRegistry::get_type_info`]: crate::TypeRegistry::get_type_info
|
||||||
fn get_represented_type_info(&self) -> Option<&'static TypeInfo>;
|
fn get_represented_type_info(&self) -> Option<&'static TypeInfo>;
|
||||||
|
|
||||||
/// Returns the [`TypePath`] implementation for the underlying type.
|
|
||||||
///
|
|
||||||
/// Methods on [`DynamicTypePath`] suffer the same performance concerns as [`get_represented_type_info`].
|
|
||||||
///
|
|
||||||
/// [`TypePath`]: crate::TypePath
|
|
||||||
/// [`get_represented_type_info`]: Reflect::get_represented_type_info
|
|
||||||
fn get_type_path(&self) -> &dyn DynamicTypePath;
|
|
||||||
|
|
||||||
/// Returns the value as a [`Box<dyn Any>`][std::any::Any].
|
/// Returns the value as a [`Box<dyn Any>`][std::any::Any].
|
||||||
fn into_any(self: Box<Self>) -> Box<dyn Any>;
|
fn into_any(self: Box<Self>) -> Box<dyn Any>;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
self as bevy_reflect, DynamicTypePath, NamedField, Reflect, ReflectMut, ReflectOwned,
|
self as bevy_reflect, NamedField, Reflect, ReflectMut, ReflectOwned, ReflectRef, TypeInfo,
|
||||||
ReflectRef, TypeInfo,
|
|
||||||
};
|
};
|
||||||
use bevy_reflect_derive::impl_type_path;
|
use bevy_reflect_derive::impl_type_path;
|
||||||
use bevy_utils::{Entry, HashMap};
|
use bevy_utils::{Entry, HashMap};
|
||||||
|
@ -405,11 +404,6 @@ impl Reflect for DynamicStruct {
|
||||||
self.represented_type
|
self.represented_type
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn get_type_path(&self) -> &dyn DynamicTypePath {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
||||||
self
|
self
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use bevy_reflect_derive::impl_type_path;
|
use bevy_reflect_derive::impl_type_path;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
self as bevy_reflect, utility::GenericTypePathCell, DynamicTypePath, FromReflect,
|
self as bevy_reflect, utility::GenericTypePathCell, FromReflect, GetTypeRegistration, Reflect,
|
||||||
GetTypeRegistration, Reflect, ReflectMut, ReflectOwned, ReflectRef, TypeInfo, TypePath,
|
ReflectMut, ReflectOwned, ReflectRef, TypeInfo, TypePath, TypeRegistration, Typed,
|
||||||
TypeRegistration, Typed, UnnamedField,
|
UnnamedField,
|
||||||
};
|
};
|
||||||
use std::any::{Any, TypeId};
|
use std::any::{Any, TypeId};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
@ -321,11 +321,6 @@ impl Reflect for DynamicTuple {
|
||||||
self.represented_type
|
self.represented_type
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn get_type_path(&self) -> &dyn DynamicTypePath {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
||||||
self
|
self
|
||||||
|
@ -538,11 +533,6 @@ macro_rules! impl_reflect_tuple {
|
||||||
Some(<Self as Typed>::type_info())
|
Some(<Self as Typed>::type_info())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn get_type_path(&self) -> &dyn DynamicTypePath {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use bevy_reflect_derive::impl_type_path;
|
use bevy_reflect_derive::impl_type_path;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
self as bevy_reflect, DynamicTypePath, Reflect, ReflectMut, ReflectOwned, ReflectRef, TypeInfo,
|
self as bevy_reflect, Reflect, ReflectMut, ReflectOwned, ReflectRef, TypeInfo, UnnamedField,
|
||||||
UnnamedField,
|
|
||||||
};
|
};
|
||||||
use std::any::{Any, TypeId};
|
use std::any::{Any, TypeId};
|
||||||
use std::fmt::{Debug, Formatter};
|
use std::fmt::{Debug, Formatter};
|
||||||
|
@ -308,11 +307,6 @@ impl Reflect for DynamicTupleStruct {
|
||||||
self.represented_type
|
self.represented_type
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn get_type_path(&self) -> &dyn DynamicTypePath {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
fn into_any(self: Box<Self>) -> Box<dyn Any> {
|
||||||
self
|
self
|
||||||
|
|
|
@ -24,7 +24,7 @@ use std::fmt::Debug;
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use std::any::Any;
|
/// # use std::any::Any;
|
||||||
/// # use bevy_reflect::{DynamicTypePath, NamedField, Reflect, ReflectMut, ReflectOwned, ReflectRef, StructInfo, TypeInfo, ValueInfo};
|
/// # use bevy_reflect::{DynamicTypePath, NamedField, Reflect, ReflectMut, ReflectOwned, ReflectRef, StructInfo, TypeInfo, TypePath, ValueInfo};
|
||||||
/// # use bevy_reflect::utility::NonGenericTypeInfoCell;
|
/// # use bevy_reflect::utility::NonGenericTypeInfoCell;
|
||||||
/// use bevy_reflect::Typed;
|
/// use bevy_reflect::Typed;
|
||||||
///
|
///
|
||||||
|
@ -51,7 +51,6 @@ use std::fmt::Debug;
|
||||||
/// # impl Reflect for MyStruct {
|
/// # impl Reflect for MyStruct {
|
||||||
/// # fn type_name(&self) -> &str { todo!() }
|
/// # fn type_name(&self) -> &str { todo!() }
|
||||||
/// # fn get_represented_type_info(&self) -> Option<&'static TypeInfo> { todo!() }
|
/// # fn get_represented_type_info(&self) -> Option<&'static TypeInfo> { todo!() }
|
||||||
/// # fn get_type_path(&self) -> &dyn DynamicTypePath { todo!() }
|
|
||||||
/// # fn into_any(self: Box<Self>) -> Box<dyn Any> { todo!() }
|
/// # fn into_any(self: Box<Self>) -> Box<dyn Any> { todo!() }
|
||||||
/// # fn as_any(&self) -> &dyn Any { todo!() }
|
/// # fn as_any(&self) -> &dyn Any { todo!() }
|
||||||
/// # fn as_any_mut(&mut self) -> &mut dyn Any { todo!() }
|
/// # fn as_any_mut(&mut self) -> &mut dyn Any { todo!() }
|
||||||
|
@ -65,6 +64,11 @@ use std::fmt::Debug;
|
||||||
/// # fn reflect_owned(self: Box<Self>) -> ReflectOwned { todo!() }
|
/// # fn reflect_owned(self: Box<Self>) -> ReflectOwned { todo!() }
|
||||||
/// # fn clone_value(&self) -> Box<dyn Reflect> { todo!() }
|
/// # fn clone_value(&self) -> Box<dyn Reflect> { todo!() }
|
||||||
/// # }
|
/// # }
|
||||||
|
/// #
|
||||||
|
/// # impl TypePath for MyStruct {
|
||||||
|
/// # fn type_path() -> &'static str { todo!() }
|
||||||
|
/// # fn short_type_path() -> &'static str { todo!() }
|
||||||
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [utility]: crate::utility
|
/// [utility]: crate::utility
|
||||||
|
|
|
@ -123,10 +123,6 @@ pub trait TypePath: 'static {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Dynamic dispatch for [`TypePath`].
|
/// Dynamic dispatch for [`TypePath`].
|
||||||
///
|
|
||||||
/// Retrieved using [`Reflect::get_type_path`].
|
|
||||||
///
|
|
||||||
/// [`Reflect::get_type_path`]: crate::Reflect::get_type_path
|
|
||||||
pub trait DynamicTypePath {
|
pub trait DynamicTypePath {
|
||||||
/// See [`TypePath::type_path`].
|
/// See [`TypePath::type_path`].
|
||||||
fn reflect_type_path(&self) -> &str;
|
fn reflect_type_path(&self) -> &str;
|
||||||
|
|
|
@ -50,7 +50,7 @@ mod sealed {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use std::any::Any;
|
/// # use std::any::Any;
|
||||||
/// # use bevy_reflect::{DynamicTypePath, NamedField, Reflect, ReflectMut, ReflectOwned, ReflectRef, StructInfo, Typed, TypeInfo};
|
/// # use bevy_reflect::{DynamicTypePath, NamedField, Reflect, ReflectMut, ReflectOwned, ReflectRef, StructInfo, Typed, TypeInfo, TypePath};
|
||||||
/// use bevy_reflect::utility::NonGenericTypeInfoCell;
|
/// use bevy_reflect::utility::NonGenericTypeInfoCell;
|
||||||
///
|
///
|
||||||
/// struct Foo {
|
/// struct Foo {
|
||||||
|
@ -70,7 +70,6 @@ mod sealed {
|
||||||
/// #
|
/// #
|
||||||
/// # impl Reflect for Foo {
|
/// # impl Reflect for Foo {
|
||||||
/// # fn type_name(&self) -> &str { todo!() }
|
/// # fn type_name(&self) -> &str { todo!() }
|
||||||
/// # fn get_type_path(&self) -> &dyn DynamicTypePath { todo!() }
|
|
||||||
/// # fn get_represented_type_info(&self) -> Option<&'static TypeInfo> { todo!() }
|
/// # fn get_represented_type_info(&self) -> Option<&'static TypeInfo> { todo!() }
|
||||||
/// # fn into_any(self: Box<Self>) -> Box<dyn Any> { todo!() }
|
/// # fn into_any(self: Box<Self>) -> Box<dyn Any> { todo!() }
|
||||||
/// # fn as_any(&self) -> &dyn Any { todo!() }
|
/// # fn as_any(&self) -> &dyn Any { todo!() }
|
||||||
|
@ -85,6 +84,11 @@ mod sealed {
|
||||||
/// # fn reflect_owned(self: Box<Self>) -> ReflectOwned { todo!() }
|
/// # fn reflect_owned(self: Box<Self>) -> ReflectOwned { todo!() }
|
||||||
/// # fn clone_value(&self) -> Box<dyn Reflect> { todo!() }
|
/// # fn clone_value(&self) -> Box<dyn Reflect> { todo!() }
|
||||||
/// # }
|
/// # }
|
||||||
|
|
||||||
|
/// # impl TypePath for Foo {
|
||||||
|
/// # fn type_path() -> &'static str { todo!() }
|
||||||
|
/// # fn short_type_path() -> &'static str { todo!() }
|
||||||
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`TypePath`]: crate::TypePath
|
/// [`TypePath`]: crate::TypePath
|
||||||
|
@ -124,7 +128,7 @@ impl<T: TypedProperty> NonGenericTypeCell<T> {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use std::any::Any;
|
/// # use std::any::Any;
|
||||||
/// # use bevy_reflect::{DynamicTypePath, Reflect, ReflectMut, ReflectOwned, ReflectRef, TupleStructInfo, Typed, TypeInfo, UnnamedField};
|
/// # use bevy_reflect::{DynamicTypePath, Reflect, ReflectMut, ReflectOwned, ReflectRef, TupleStructInfo, Typed, TypeInfo, TypePath, UnnamedField};
|
||||||
/// use bevy_reflect::utility::GenericTypeInfoCell;
|
/// use bevy_reflect::utility::GenericTypeInfoCell;
|
||||||
///
|
///
|
||||||
/// struct Foo<T>(T);
|
/// struct Foo<T>(T);
|
||||||
|
@ -142,7 +146,6 @@ impl<T: TypedProperty> NonGenericTypeCell<T> {
|
||||||
/// #
|
/// #
|
||||||
/// # impl<T: Reflect> Reflect for Foo<T> {
|
/// # impl<T: Reflect> Reflect for Foo<T> {
|
||||||
/// # fn type_name(&self) -> &str { todo!() }
|
/// # fn type_name(&self) -> &str { todo!() }
|
||||||
/// # fn get_type_path(&self) -> &dyn DynamicTypePath { todo!() }
|
|
||||||
/// # fn get_represented_type_info(&self) -> Option<&'static TypeInfo> { todo!() }
|
/// # fn get_represented_type_info(&self) -> Option<&'static TypeInfo> { todo!() }
|
||||||
/// # fn into_any(self: Box<Self>) -> Box<dyn Any> { todo!() }
|
/// # fn into_any(self: Box<Self>) -> Box<dyn Any> { todo!() }
|
||||||
/// # fn as_any(&self) -> &dyn Any { todo!() }
|
/// # fn as_any(&self) -> &dyn Any { todo!() }
|
||||||
|
@ -157,6 +160,10 @@ impl<T: TypedProperty> NonGenericTypeCell<T> {
|
||||||
/// # fn reflect_owned(self: Box<Self>) -> ReflectOwned { todo!() }
|
/// # fn reflect_owned(self: Box<Self>) -> ReflectOwned { todo!() }
|
||||||
/// # fn clone_value(&self) -> Box<dyn Reflect> { todo!() }
|
/// # fn clone_value(&self) -> Box<dyn Reflect> { todo!() }
|
||||||
/// # }
|
/// # }
|
||||||
|
/// # impl<T: Reflect> TypePath for Foo<T> {
|
||||||
|
/// # fn type_path() -> &'static str { todo!() }
|
||||||
|
/// # fn short_type_path() -> &'static str { todo!() }
|
||||||
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Implementing [`TypePath`] with generics.
|
/// Implementing [`TypePath`] with generics.
|
||||||
|
@ -180,9 +187,8 @@ impl<T: TypedProperty> NonGenericTypeCell<T> {
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
/// #
|
||||||
/// # impl<T: Reflect> Reflect for Foo<T> {
|
/// # impl<T: Reflect + TypePath> Reflect for Foo<T> {
|
||||||
/// # fn type_name(&self) -> &str { todo!() }
|
/// # fn type_name(&self) -> &str { todo!() }
|
||||||
/// # fn get_type_path(&self) -> &dyn DynamicTypePath { todo!() }
|
|
||||||
/// # fn get_represented_type_info(&self) -> Option<&'static TypeInfo> { todo!() }
|
/// # fn get_represented_type_info(&self) -> Option<&'static TypeInfo> { todo!() }
|
||||||
/// # fn into_any(self: Box<Self>) -> Box<dyn Any> { todo!() }
|
/// # fn into_any(self: Box<Self>) -> Box<dyn Any> { todo!() }
|
||||||
/// # fn as_any(&self) -> &dyn Any { todo!() }
|
/// # fn as_any(&self) -> &dyn Any { todo!() }
|
||||||
|
|
Loading…
Reference in a new issue