mirror of
https://github.com/FyroxEngine/Fyrox.git
synced 2026-10-12 02:02:20 +00:00
clean #[inspect(is_modified)]
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
# fyrox-core-derive
|
||||
|
||||
Provides the `#[derive(Visit)]` macro, which implements `fyrox::core::visitor::Visit`.
|
||||
This crate provides with some derive macros:
|
||||
|
||||
- `#[derive(Visit)]`
|
||||
- `#[derive(Inspect)]`
|
||||
- `#[derive(Reflect)]`
|
||||
|
||||
@@ -100,11 +100,11 @@ pub struct FieldArgs {
|
||||
#[darling(default)]
|
||||
pub description: Option<String>,
|
||||
|
||||
/// `#[inspect(getter = "<method_name>")]`
|
||||
/// `#[inspect(is_modified = <expr>)]`
|
||||
///
|
||||
/// True if the value has been modified.
|
||||
/// Method call syntax. It returns true if the value has been modified.
|
||||
#[darling(default)]
|
||||
pub is_modified: Option<String>,
|
||||
pub is_modified: Option<Expr>,
|
||||
}
|
||||
|
||||
impl FieldArgs {
|
||||
|
||||
@@ -206,7 +206,7 @@ fn quote_field_prop(
|
||||
let getter = match &field.getter {
|
||||
// use custom getter function to retrieve the target reference
|
||||
Some(getter) => {
|
||||
quote! { (#field_ref).#getter }
|
||||
quote! { #field_ref.#getter }
|
||||
}
|
||||
// default: get reference of the field
|
||||
None => field_ref.clone(),
|
||||
@@ -247,8 +247,7 @@ fn quote_field_prop(
|
||||
|
||||
let is_modified = match field.is_modified.as_ref() {
|
||||
Some(getter) => {
|
||||
let getter: Path = parse_str(getter).expect("can't parse `is_modified` as a path");
|
||||
quote! { #field_ref.#getter() }
|
||||
quote! { #field_ref.#getter }
|
||||
}
|
||||
None => quote! { false },
|
||||
};
|
||||
|
||||
@@ -310,7 +310,7 @@ fn inspect_with_custom_getter() {
|
||||
#[test]
|
||||
fn inspect_modified() {
|
||||
#[derive(Inspect, Reflect)]
|
||||
struct S(#[inspect(is_modified = "clone")] bool);
|
||||
struct S(#[inspect(is_modified = "clone()")] bool);
|
||||
|
||||
let s = S(true);
|
||||
assert_eq!(
|
||||
|
||||
@@ -73,7 +73,7 @@ pub struct Transform {
|
||||
#[inspect(
|
||||
deref,
|
||||
description = "Local scale of the transform",
|
||||
is_modified = "is_modified"
|
||||
is_modified = "is_modified()"
|
||||
)]
|
||||
#[reflect(deref)]
|
||||
local_scale: TemplateVariable<Vector3<f32>>,
|
||||
@@ -81,7 +81,7 @@ pub struct Transform {
|
||||
#[inspect(
|
||||
deref,
|
||||
description = "Local position of the transform",
|
||||
is_modified = "is_modified"
|
||||
is_modified = "is_modified()"
|
||||
)]
|
||||
#[reflect(deref)]
|
||||
local_position: TemplateVariable<Vector3<f32>>,
|
||||
@@ -89,7 +89,7 @@ pub struct Transform {
|
||||
#[inspect(
|
||||
deref,
|
||||
description = "Local rotation of the transform",
|
||||
is_modified = "is_modified"
|
||||
is_modified = "is_modified()"
|
||||
)]
|
||||
#[reflect(deref)]
|
||||
local_rotation: TemplateVariable<UnitQuaternion<f32>>,
|
||||
@@ -97,7 +97,7 @@ pub struct Transform {
|
||||
#[inspect(
|
||||
deref,
|
||||
description = "Pre rotation of the transform. Applied before local rotation.",
|
||||
is_modified = "is_modified"
|
||||
is_modified = "is_modified()"
|
||||
)]
|
||||
#[reflect(deref)]
|
||||
pre_rotation: TemplateVariable<UnitQuaternion<f32>>,
|
||||
@@ -105,7 +105,7 @@ pub struct Transform {
|
||||
#[inspect(
|
||||
deref,
|
||||
description = "Post rotation of the transform. Applied after local rotation.",
|
||||
is_modified = "is_modified"
|
||||
is_modified = "is_modified()"
|
||||
)]
|
||||
#[reflect(deref)]
|
||||
post_rotation: TemplateVariable<UnitQuaternion<f32>>,
|
||||
@@ -113,7 +113,7 @@ pub struct Transform {
|
||||
#[inspect(
|
||||
deref,
|
||||
description = "Rotation offset of the transform.",
|
||||
is_modified = "is_modified"
|
||||
is_modified = "is_modified()"
|
||||
)]
|
||||
#[reflect(deref)]
|
||||
rotation_offset: TemplateVariable<Vector3<f32>>,
|
||||
@@ -121,7 +121,7 @@ pub struct Transform {
|
||||
#[inspect(
|
||||
deref,
|
||||
description = "Rotation pivot of the transform.",
|
||||
is_modified = "is_modified"
|
||||
is_modified = "is_modified()"
|
||||
)]
|
||||
#[reflect(deref)]
|
||||
rotation_pivot: TemplateVariable<Vector3<f32>>,
|
||||
@@ -129,7 +129,7 @@ pub struct Transform {
|
||||
#[inspect(
|
||||
deref,
|
||||
description = "Scale offset of the transform.",
|
||||
is_modified = "is_modified"
|
||||
is_modified = "is_modified()"
|
||||
)]
|
||||
#[reflect(deref)]
|
||||
scaling_offset: TemplateVariable<Vector3<f32>>,
|
||||
@@ -137,7 +137,7 @@ pub struct Transform {
|
||||
#[inspect(
|
||||
deref,
|
||||
description = "Scale pivot of the transform.",
|
||||
is_modified = "is_modified"
|
||||
is_modified = "is_modified()"
|
||||
)]
|
||||
#[reflect(deref)]
|
||||
scaling_pivot: TemplateVariable<Vector3<f32>>,
|
||||
|
||||
Reference in New Issue
Block a user