Skip to content

Commit

Permalink
Fix dynamic diffing and cleanup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MrGVSV committed May 6, 2024
1 parent e2378ef commit c4be479
Show file tree
Hide file tree
Showing 9 changed files with 510 additions and 482 deletions.
1 change: 1 addition & 0 deletions crates/bevy_reflect/bevy_reflect_derive/src/impls/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ pub(crate) fn impl_enum(reflect_enum: &ReflectEnum) -> proc_macro2::TokenStream
}

fn apply_enum_diff(&mut self, diff: #bevy_reflect_path::diff::EnumDiff) -> #bevy_reflect_path::diff::DiffApplyResult {
println!("Diffing... {}", #bevy_reflect_path::DynamicTypePath::reflect_type_path(self));
let info = <Self as #bevy_reflect_path::Typed>::type_info();

if info.type_id() != diff.type_info().type_id() {
Expand Down
12 changes: 7 additions & 5 deletions crates/bevy_reflect/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,16 @@ impl Array for DynamicArray {
}

fn apply_array_diff(&mut self, diff: ArrayDiff) -> DiffApplyResult {
let Some(info) = self.get_represented_type_info() else {
return Err(DiffApplyError::MissingTypeInfo);
};

if info.type_id() != diff.type_info().type_id() || self.len() != diff.len() {
if self.len() != diff.len() {
return Err(DiffApplyError::TypeMismatch);
}

if let Some(info) = self.get_represented_type_info() {
if info.type_id() != diff.type_info().type_id() {
return Err(DiffApplyError::TypeMismatch);
}
};

for (index, diff) in diff.take_changes().into_iter().enumerate() {
self.get_mut(index)
.ok_or(DiffApplyError::MissingField)?
Expand Down
Loading

0 comments on commit c4be479

Please sign in to comment.