Skip to content

Commit 7f1c7f5

Browse files
re-enable list applies
1 parent 2901273 commit 7f1c7f5

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

crates/bevy_mod_scripting_core/src/bindings/allocator.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ impl ReflectAllocator {
170170
}
171171

172172
pub fn remove(&mut self, id: &ReflectAllocationId) -> Option<ReflectAllocation> {
173-
println!("removing {:?}", id);
174173
self.allocations.remove(id)
175174
}
176175

crates/bevy_mod_scripting_core/src/bindings/function/from_ref.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{any::TypeId, ffi::OsString, path::PathBuf};
22

3-
use bevy::reflect::{DynamicEnum, DynamicTuple, DynamicVariant, PartialReflect};
3+
use bevy::reflect::{DynamicEnum, DynamicList, DynamicTuple, DynamicVariant, PartialReflect};
44

55
use crate::{
66
bindings::{function::from::FromScript, ReflectReference, WorldGuard},
@@ -71,25 +71,35 @@ impl FromScriptRef for Box<dyn PartialReflect> {
7171
if type_info.is_option() {
7272
let inner_type = type_info.option_inner_type().expect("invariant");
7373
let mut dynamic_enum = match value {
74-
ScriptValue::Unit => {
75-
// build none variant
76-
let mut dynamic_enum = DynamicEnum::new("None", DynamicVariant::Unit);
77-
dynamic_enum
78-
}
74+
ScriptValue::Unit => DynamicEnum::new("None", DynamicVariant::Unit),
7975
_ => {
8076
let inner = Self::from_script_ref(inner_type, value, world)?;
81-
let mut dynamic_enum = DynamicEnum::new(
77+
DynamicEnum::new(
8278
"Some",
8379
DynamicVariant::Tuple(DynamicTuple::from_iter(vec![inner])),
84-
);
85-
dynamic_enum
80+
)
8681
}
8782
};
8883

8984
dynamic_enum.set_represented_type(Some(type_info));
9085
return Ok(Box::new(dynamic_enum));
9186
}
9287

88+
if type_info.is_list() {
89+
let inner_type = type_info.list_inner_type().expect("invariant");
90+
91+
if let ScriptValue::List(vec) = value {
92+
let mut dynamic_list = DynamicList::default();
93+
for item in vec {
94+
let inner = Self::from_script_ref(inner_type, item, world.clone())?;
95+
dynamic_list.push_box(inner);
96+
}
97+
98+
dynamic_list.set_represented_type(Some(type_info));
99+
return Ok(Box::new(dynamic_list));
100+
}
101+
}
102+
93103
match value {
94104
ScriptValue::Reference(reflect_reference) => reflect_reference.to_owned_value(world),
95105
value => Err(InteropError::value_mismatch(target, value)),

crates/bevy_mod_scripting_core/src/bindings/reference.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,6 @@ impl ReflectReference {
190190

191191
if let ReflectBase::Owned(id) = &self.base.base_id {
192192
if self.reflect_path.is_empty() && id.strong_count() == 0 {
193-
println!(
194-
"Trying to access allocation in owned value {}",
195-
self.display_value_with_world(world.clone())
196-
);
197193
let allocator = world.allocator();
198194
let mut allocator = allocator.write();
199195
let arc = allocator

crates/bevy_mod_scripting_functions/src/core.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ fn register_world_functions(reg: &mut FunctionRegistry) -> Result<(), FunctionRe
167167
value,
168168
world.clone(),
169169
)?;
170-
println!("Applying {:?} to {:?}", other, r);
171170

172171
r.try_apply(other.as_partial_reflect()).unwrap();
173172
Ok::<_, InteropError>(())

0 commit comments

Comments
 (0)