mirror of
https://github.com/FyroxEngine/Fyrox.git
synced 2026-10-12 02:02:20 +00:00
removed redundant type_name field from FieldInfo
- it can be fetched "on-demand" using `info.value.type_name()` - speeds up fields access and iteration a bit
This commit is contained in:
@@ -195,7 +195,7 @@ where
|
||||
let mut descriptor = PropertyDescriptor {
|
||||
path: path.clone(),
|
||||
display_name: field_info.display_name.to_owned(),
|
||||
type_name: field_info.type_name.to_owned(),
|
||||
type_name: field_info.value.type_name().to_owned(),
|
||||
type_id: field_info.value.type_id(),
|
||||
children_properties: Default::default(),
|
||||
read_only: field_info.read_only,
|
||||
@@ -227,7 +227,7 @@ where
|
||||
let mut descriptor = PropertyDescriptor {
|
||||
path: path.clone(),
|
||||
display_name: field_info.display_name.to_owned(),
|
||||
type_name: field_info.type_name.to_owned(),
|
||||
type_name: field_info.value.type_name().to_owned(),
|
||||
type_id: field_info.value.type_id(),
|
||||
children_properties: Default::default(),
|
||||
read_only: field_info.read_only,
|
||||
@@ -283,7 +283,7 @@ where
|
||||
if !processed {
|
||||
descriptors.push(PropertyDescriptor {
|
||||
display_name: field_info.display_name.to_owned(),
|
||||
type_name: field_info.type_name.to_owned(),
|
||||
type_name: field_info.value.type_name().to_owned(),
|
||||
type_id: field_info.value.type_id(),
|
||||
read_only: field_info.read_only,
|
||||
children_properties: object_to_property_tree(&path, field_ref, filter),
|
||||
|
||||
@@ -98,7 +98,6 @@ macro_rules! define_two_args_node {
|
||||
display_name: "Lhs",
|
||||
description: "",
|
||||
tag: "",
|
||||
type_name: type_name::<Self>(),
|
||||
value: &*self.lhs,
|
||||
reflect_value: &*self.lhs,
|
||||
read_only: false,
|
||||
@@ -115,7 +114,6 @@ macro_rules! define_two_args_node {
|
||||
display_name: "Rhs",
|
||||
description: "",
|
||||
tag: "",
|
||||
type_name: type_name::<Self>(),
|
||||
value: &*self.rhs,
|
||||
reflect_value: &*self.rhs,
|
||||
read_only: false,
|
||||
@@ -261,7 +259,6 @@ impl<T: EntityId> Reflect for NotNode<T> {
|
||||
display_name: "Lhs",
|
||||
description: "",
|
||||
tag: "",
|
||||
type_name: type_name::<Self>(),
|
||||
value: &*self.lhs,
|
||||
reflect_value: &*self.lhs,
|
||||
read_only: false,
|
||||
|
||||
@@ -120,8 +120,6 @@ fn quote_field_prop(
|
||||
|
||||
let tag = field.tag.clone().unwrap_or_default();
|
||||
|
||||
let ty = field.ty.clone();
|
||||
|
||||
let read_only = field.read_only;
|
||||
|
||||
let immutable_collection = field.immutable_collection;
|
||||
@@ -143,8 +141,7 @@ fn quote_field_prop(
|
||||
reflect_value: #field_getter,
|
||||
step: #step,
|
||||
precision: #precision,
|
||||
description: #description,
|
||||
type_name: std::any::type_name::<#ty>()
|
||||
description: #description
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,7 +345,6 @@ fn default_prop() -> FieldInfo<'static, 'static> {
|
||||
precision: None,
|
||||
description: "",
|
||||
tag: "",
|
||||
type_name: "",
|
||||
doc: "",
|
||||
}
|
||||
}
|
||||
@@ -415,7 +414,6 @@ fn inspect_attributes() {
|
||||
name: "x",
|
||||
display_name: "Super X",
|
||||
value: &data.x,
|
||||
type_name: std::any::type_name::<f32>(),
|
||||
..default_prop()
|
||||
},
|
||||
FieldInfo {
|
||||
@@ -432,7 +430,6 @@ fn inspect_attributes() {
|
||||
precision: Some(3),
|
||||
description: "This is a property description.",
|
||||
tag: "SomeTag",
|
||||
type_name: std::any::type_name::<f32>(),
|
||||
doc: "",
|
||||
},
|
||||
];
|
||||
@@ -456,7 +453,6 @@ fn inspect_struct() {
|
||||
name: "0",
|
||||
display_name: "0",
|
||||
value: &x.0,
|
||||
type_name: std::any::type_name::<f32>(),
|
||||
..default_prop()
|
||||
},
|
||||
FieldInfo {
|
||||
@@ -464,7 +460,6 @@ fn inspect_struct() {
|
||||
name: "1",
|
||||
display_name: "1",
|
||||
value: &x.1,
|
||||
type_name: std::any::type_name::<f32>(),
|
||||
..default_prop()
|
||||
},
|
||||
]
|
||||
@@ -510,14 +505,12 @@ fn inspect_enum() {
|
||||
Data::Named { ref x, .. } => x,
|
||||
_ => unreachable!(),
|
||||
},
|
||||
type_name: std::any::type_name::<u32>(),
|
||||
..default_prop()
|
||||
},
|
||||
FieldInfo {
|
||||
owner_type_id: TypeId::of::<Data>(),
|
||||
name: "Named@y",
|
||||
display_name: "Y",
|
||||
type_name: std::any::type_name::<u32>(),
|
||||
value: match data {
|
||||
Data::Named { ref y, .. } => y,
|
||||
_ => unreachable!(),
|
||||
@@ -528,7 +521,6 @@ fn inspect_enum() {
|
||||
owner_type_id: TypeId::of::<Data>(),
|
||||
name: "Named@z",
|
||||
display_name: "Z",
|
||||
type_name: std::any::type_name::<NonCopy>(),
|
||||
value: match data {
|
||||
Data::Named { ref z, .. } => z,
|
||||
_ => unreachable!(),
|
||||
@@ -549,7 +541,6 @@ fn inspect_enum() {
|
||||
owner_type_id: TypeId::of::<Data>(),
|
||||
name: "Tuple@0",
|
||||
display_name: "0",
|
||||
type_name: std::any::type_name::<f32>(),
|
||||
value: match data {
|
||||
Data::Tuple(ref f0, ref _f1) => f0,
|
||||
_ => unreachable!(),
|
||||
@@ -560,7 +551,6 @@ fn inspect_enum() {
|
||||
owner_type_id: TypeId::of::<Data>(),
|
||||
name: "Tuple@1",
|
||||
display_name: "1",
|
||||
type_name: std::any::type_name::<f32>(),
|
||||
value: match data {
|
||||
Data::Tuple(ref _f0, ref f1) => f1,
|
||||
_ => unreachable!(),
|
||||
|
||||
@@ -123,7 +123,6 @@ impl<T: Reflect> Reflect for Handle<T> {
|
||||
display_name: "Index",
|
||||
description: "",
|
||||
tag: "",
|
||||
type_name: type_name::<u32>(),
|
||||
value: &self.index,
|
||||
reflect_value: &self.index,
|
||||
read_only: false,
|
||||
@@ -140,7 +139,6 @@ impl<T: Reflect> Reflect for Handle<T> {
|
||||
display_name: "Generation",
|
||||
description: "",
|
||||
tag: "",
|
||||
type_name: type_name::<u32>(),
|
||||
value: &self.generation,
|
||||
reflect_value: &self.generation,
|
||||
read_only: false,
|
||||
|
||||
@@ -41,12 +41,18 @@ pub mod prelude {
|
||||
pub trait FieldValue: Any + 'static {
|
||||
/// Casts `self` to a `&dyn Any`
|
||||
fn as_any(&self) -> &dyn Any;
|
||||
|
||||
fn type_name(&self) -> &'static str;
|
||||
}
|
||||
|
||||
impl<T: 'static> FieldValue for T {
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
}
|
||||
|
||||
fn type_name(&self) -> &'static str {
|
||||
std::any::type_name::<T>()
|
||||
}
|
||||
}
|
||||
|
||||
/// An error that can occur during "type casting"
|
||||
@@ -82,9 +88,6 @@ pub struct FieldInfo<'a, 'b> {
|
||||
/// specific property by its tag.
|
||||
pub tag: &'b str,
|
||||
|
||||
/// Type name of the property.
|
||||
pub type_name: &'b str,
|
||||
|
||||
/// Doc comment content.
|
||||
pub doc: &'b str,
|
||||
|
||||
|
||||
@@ -103,7 +103,6 @@ impl Reflect for Limb {
|
||||
display_name: "Bone",
|
||||
description: "",
|
||||
tag: "",
|
||||
type_name: type_name::<Handle<Node>>(),
|
||||
value: &self.bone,
|
||||
reflect_value: &self.bone,
|
||||
read_only: false,
|
||||
@@ -120,7 +119,6 @@ impl Reflect for Limb {
|
||||
display_name: "Physical Bone",
|
||||
description: "",
|
||||
tag: "",
|
||||
type_name: type_name::<Handle<Node>>(),
|
||||
value: &self.physical_bone,
|
||||
reflect_value: &self.physical_bone,
|
||||
read_only: false,
|
||||
@@ -137,7 +135,6 @@ impl Reflect for Limb {
|
||||
display_name: "Children",
|
||||
description: "",
|
||||
tag: "",
|
||||
type_name: type_name::<Vec<Limb>>(),
|
||||
value: &self.children,
|
||||
reflect_value: &self.children,
|
||||
read_only: false,
|
||||
|
||||
@@ -140,7 +140,6 @@ where
|
||||
precision: array_property_info.precision,
|
||||
description: array_property_info.description,
|
||||
tag: array_property_info.tag,
|
||||
type_name: array_property_info.type_name,
|
||||
doc: array_property_info.doc,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -254,7 +254,6 @@ where
|
||||
precision: collection_property_info.precision,
|
||||
description: collection_property_info.description,
|
||||
tag: collection_property_info.tag,
|
||||
type_name: collection_property_info.type_name,
|
||||
doc: collection_property_info.doc,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -235,7 +235,6 @@ where
|
||||
precision: property_info.precision,
|
||||
description: property_info.description,
|
||||
tag: property_info.tag,
|
||||
type_name: property_info.type_name,
|
||||
doc: property_info.doc,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -86,7 +86,6 @@ where
|
||||
precision: property_info.precision,
|
||||
description: property_info.description,
|
||||
tag: property_info.tag,
|
||||
type_name: property_info.type_name,
|
||||
doc: property_info.doc,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -228,7 +228,6 @@ where
|
||||
precision: property_info.precision,
|
||||
description: property_info.description,
|
||||
tag: property_info.tag,
|
||||
type_name: property_info.type_name,
|
||||
doc: property_info.doc,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -947,7 +947,7 @@ impl InspectorContext {
|
||||
.with_vertical_text_alignment(VerticalAlignment::Center)
|
||||
.with_text(format!(
|
||||
"Property Editor Is Missing For Type {}!",
|
||||
info.type_name
|
||||
info.value.type_name()
|
||||
))
|
||||
.build(ctx),
|
||||
&description,
|
||||
|
||||
Reference in New Issue
Block a user