Skip to content

Commit 4706914

Browse files
committed
cooking
1 parent b5068e5 commit 4706914

File tree

15 files changed

+367
-518
lines changed

15 files changed

+367
-518
lines changed

crates/bevy_mod_scripting_core/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ parking_lot = "0.12.1"
3636
dashmap = "6"
3737
smallvec = "1.11"
3838
itertools = "0.13"
39+
allocator-api2 = "0.2"
40+
blink-alloc = { version = "0.3", features = ["sync"] }
3941

4042
[dev-dependencies]
4143
test_utils = { workspace = true }

crates/bevy_mod_scripting_core/src/bindings/access_map.rs

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use smallvec::SmallVec;
1010

1111
use crate::error::InteropError;
1212

13-
use super::{ReflectAllocationId, ReflectBase};
13+
use super::{ReflectAllocation2, ReflectBase};
1414

1515
#[derive(Debug, Clone, PartialEq, Eq)]
1616
pub struct ClaimOwner {
@@ -153,10 +153,14 @@ impl ReflectAccessId {
153153
Ok(Self::for_component_id(component_id))
154154
}
155155

156-
pub fn for_allocation(id: ReflectAllocationId) -> Self {
156+
pub fn for_allocation(allocation: &ReflectAllocation2) -> Self {
157+
debug_assert!(
158+
usize::MAX as u128 <= u64::MAX as u128,
159+
"usize assumption broken"
160+
);
157161
Self {
158162
kind: ReflectAccessKind::Allocation,
159-
id: id.id(),
163+
id: allocation.unique_id() as u64,
160164
}
161165
}
162166

@@ -171,26 +175,20 @@ impl ReflectAccessId {
171175
match base {
172176
ReflectBase::Resource(id) => Self::for_component_id(id),
173177
ReflectBase::Component(_, id) => Self::for_component_id(id),
174-
ReflectBase::Owned(id) => Self::for_allocation(id),
178+
ReflectBase::Owned(id) => Self::for_allocation(&id),
175179
}
176180
}
177181
}
178182

179183
impl From<ComponentId> for ReflectAccessId {
180184
fn from(value: ComponentId) -> Self {
181-
Self {
182-
kind: ReflectAccessKind::ComponentOrResource,
183-
id: value.index() as u64,
184-
}
185+
ReflectAccessId::for_component_id(value)
185186
}
186187
}
187188

188-
impl From<ReflectAllocationId> for ReflectAccessId {
189-
fn from(value: ReflectAllocationId) -> Self {
190-
Self {
191-
kind: ReflectAccessKind::Allocation,
192-
id: value.id(),
193-
}
189+
impl From<&ReflectAllocation2> for ReflectAccessId {
190+
fn from(value: &ReflectAllocation2) -> Self {
191+
ReflectAccessId::for_allocation(value)
194192
}
195193
}
196194

@@ -200,12 +198,6 @@ impl From<ReflectAccessId> for ComponentId {
200198
}
201199
}
202200

203-
impl From<ReflectAccessId> for ReflectAllocationId {
204-
fn from(val: ReflectAccessId) -> Self {
205-
ReflectAllocationId::new(val.id)
206-
}
207-
}
208-
209201
#[derive(Debug, Default)]
210202
pub struct AccessMap {
211203
individual_accesses: DashMap<u64, AccessCount>,

0 commit comments

Comments
 (0)