mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
mark function that can be used unsafely unsafe
This commit is contained in:
parent
f86bf9c07a
commit
82b68fc335
|
@ -155,7 +155,9 @@ impl OAMManager<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
fn do_work_with_sprite_loader<C, T>(&self, c: C) -> T
|
||||
/// SAFETY:
|
||||
/// Do not reenter or recurse or otherwise use sprite loader cell during this.
|
||||
unsafe fn do_work_with_sprite_loader<C, T>(&self, c: C) -> T
|
||||
where
|
||||
C: Fn(&mut StaticSpriteLoader) -> T,
|
||||
{
|
||||
|
@ -184,8 +186,11 @@ impl OAMManager<'_> {
|
|||
// finished OAM interactions
|
||||
|
||||
self.object_store.remove_all_in_removal_list();
|
||||
// safety: not reentrant
|
||||
unsafe {
|
||||
self.do_work_with_sprite_loader(StaticSpriteLoader::garbage_collect);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_object(&self, sprite: SpriteVram) -> Object<'_> {
|
||||
self.object_store
|
||||
|
@ -193,8 +198,11 @@ impl OAMManager<'_> {
|
|||
}
|
||||
|
||||
pub fn get_vram_sprite(&self, sprite: &'static Sprite) -> SpriteVram {
|
||||
// safety: not reentrant
|
||||
unsafe {
|
||||
self.do_work_with_sprite_loader(|sprite_loader| sprite_loader.get_vram_sprite(sprite))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_object_static_sprite(&self, sprite: &'static Sprite) -> Object<'_> {
|
||||
self.add_object(self.get_vram_sprite(sprite))
|
||||
|
|
Loading…
Reference in a new issue