Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
soqb committed Jan 28, 2023
1 parent 33c644d commit 910f654
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 17 deletions.
3 changes: 2 additions & 1 deletion crates/bevy_asset/src/reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ pub struct ReflectAsset {
assets_resource_type_id: TypeId,

get: fn(&World, HandleUntyped) -> Option<&dyn PartialReflect>,
get_unchecked_mut: unsafe fn(UnsafeWorldCell<'_>, HandleUntyped) -> Option<&mut dyn PartialReflect>,
get_unchecked_mut:
unsafe fn(UnsafeWorldCell<'_>, HandleUntyped) -> Option<&mut dyn PartialReflect>,
add: fn(&mut World, &dyn PartialReflect) -> HandleUntyped,
set: fn(&mut World, HandleUntyped, &dyn PartialReflect) -> HandleUntyped,
len: fn(&World) -> usize,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_core_pipeline/src/bloom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use bevy_ecs::{
world::{FromWorld, World},
};
use bevy_math::{UVec2, UVec4, Vec4};
use bevy_reflect::{PartialReflect, TypeUuid, Reflect};
use bevy_reflect::{PartialReflect, Reflect, TypeUuid};
use bevy_render::{
camera::ExtractedCamera,
extract_component::{
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_ecs/src/reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ pub struct ReflectResourceFns {
///
/// # Safety
/// The function may only be called with an [`UnsafeWorldCell`] that can be used to mutably access the relevant resource.
pub reflect_unchecked_mut: unsafe fn(UnsafeWorldCell<'_>) -> Option<Mut<'_, dyn PartialReflect>>,
pub reflect_unchecked_mut:
unsafe fn(UnsafeWorldCell<'_>) -> Option<Mut<'_, dyn PartialReflect>>,
/// Function pointer implementing [`ReflectResource::copy()`].
pub copy: fn(&World, &mut World),
}
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_reflect/bevy_reflect_derive/src/impls/enums.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::derive_data::{EnumVariant, EnumVariantFields, ReflectEnum, StructField};
use crate::enum_utility::{get_variant_constructors, EnumVariantConstructors};
use crate::fq_std::{FQBox, FQOption, FQResult};
use crate::impls::{impl_typed, impl_full_reflect};
use crate::impls::{impl_full_reflect, impl_typed};
use crate::utility::extend_where_clause;
use proc_macro::TokenStream;
use proc_macro2::{Ident, Span};
Expand Down Expand Up @@ -91,8 +91,8 @@ pub(crate) fn impl_enum(reflect_enum: &ReflectEnum) -> TokenStream {
let get_type_registration_impl = reflect_enum
.meta()
.get_type_registration(&where_clause_options);
let impl_full_reflect = impl_full_reflect(reflect_enum.meta());

let impl_full_reflect = impl_full_reflect(reflect_enum.meta(), &where_clause_options);

let (impl_generics, ty_generics, where_clause) =
reflect_enum.meta().generics().split_for_impl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@ use quote::quote;
use crate::{
derive_data::ReflectMeta,
fq_std::{FQAny, FQBox, FQResult},
utility::{extend_where_clause, WhereClauseOptions},
};

pub(crate) fn impl_full_reflect(meta: &ReflectMeta) -> proc_macro2::TokenStream {
pub(crate) fn impl_full_reflect(
meta: &ReflectMeta,
where_clause_options: &WhereClauseOptions,
) -> proc_macro2::TokenStream {
let type_name = meta.type_name();
let bevy_reflect_path = meta.bevy_reflect_path();

let (impl_generics, ty_generics, where_clause) = meta.generics().split_for_impl();

let where_reflect_clause = extend_where_clause(where_clause, where_clause_options);

quote! {
impl #impl_generics #bevy_reflect_path::Reflect for #type_name #ty_generics #where_clause {
impl #impl_generics #bevy_reflect_path::Reflect for #type_name #ty_generics #where_reflect_clause {
#[inline]
fn into_any(self: #FQBox<Self>) -> #FQBox<dyn #FQAny> {
self
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_reflect/bevy_reflect_derive/src/impls/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ pub(crate) fn impl_struct(reflect_struct: &ReflectStruct) -> TokenStream {
);

let get_type_registration_impl = reflect_struct.get_type_registration(&where_clause_options);
let impl_full_reflect = impl_full_reflect(reflect_struct.meta());

let impl_full_reflect = impl_full_reflect(reflect_struct.meta(), &where_clause_options);

let (impl_generics, ty_generics, where_clause) =
reflect_struct.meta().generics().split_for_impl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub(crate) fn impl_tuple_struct(reflect_struct: &ReflectStruct) -> TokenStream {
bevy_reflect_path,
);

let impl_full_reflect = impl_full_reflect(reflect_struct.meta());
let impl_full_reflect = impl_full_reflect(reflect_struct.meta(), &where_clause_options);

let (impl_generics, ty_generics, where_clause) =
reflect_struct.meta().generics().split_for_impl();
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_reflect/bevy_reflect_derive/src/impls/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ pub(crate) fn impl_value(meta: &ReflectMeta) -> TokenStream {
},
bevy_reflect_path,
);
let impl_full_reflect = impl_full_reflect(meta);

let impl_full_reflect = impl_full_reflect(meta, &where_clause_options);

let (impl_generics, ty_generics, where_clause) = meta.generics().split_for_impl();

let get_type_registration_impl = meta.get_type_registration(&where_clause_options);

TokenStream::from(quote! {
Expand Down
10 changes: 8 additions & 2 deletions crates/bevy_reflect/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1289,11 +1289,17 @@ bevy_reflect::tests::should_reflect_debug::Test {
let mut v = vec3(1.0, 2.0, 3.0);

assert_eq!(
*v.reflect_path("x").unwrap().try_downcast_ref::<f32>().unwrap(),
*v.reflect_path("x")
.unwrap()
.try_downcast_ref::<f32>()
.unwrap(),
1.0
);

*v.reflect_path_mut("y").unwrap().try_downcast_mut::<f32>().unwrap() = 6.0;
*v.reflect_path_mut("y")
.unwrap()
.try_downcast_mut::<f32>()
.unwrap() = 6.0;

assert_eq!(v.y, 6.0);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ui/src/focus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bevy_ecs::{
};
use bevy_input::{mouse::MouseButton, touch::Touches, Input};
use bevy_math::Vec2;
use bevy_reflect::{PartialReflect, ReflectDeserialize, ReflectSerialize, Reflect};
use bevy_reflect::{PartialReflect, Reflect, ReflectDeserialize, ReflectSerialize};
use bevy_render::{camera::NormalizedRenderTarget, prelude::Camera, view::ComputedVisibility};
use bevy_transform::components::GlobalTransform;

Expand Down

0 comments on commit 910f654

Please sign in to comment.