mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
unsafe is unsafe
This commit is contained in:
parent
82b68fc335
commit
d8f0d78d4b
|
@ -357,75 +357,90 @@ impl Object<'_> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn object(&mut self) -> &mut UnmanagedObject {
|
/// Safety:
|
||||||
|
/// Only have *ONE* of these at a time, do not call any functions that modify the slot map while having this.
|
||||||
|
unsafe fn object(&mut self) -> &mut UnmanagedObject {
|
||||||
unsafe { &mut *self.store.get_object(self.me).object.get() }
|
unsafe { &mut *self.store.get_object(self.me).object.get() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn object_shared(&self) -> &UnmanagedObject {
|
/// Safety:
|
||||||
|
/// Don't have a mutable one of these while having one of these, do not call any functions that modify the slot map while having this.
|
||||||
|
unsafe fn object_shared(&self) -> &UnmanagedObject {
|
||||||
unsafe { &*self.store.get_object(self.me).object.get() }
|
unsafe { &*self.store.get_object(self.me).object.get() }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn is_visible(&self) -> bool {
|
pub fn is_visible(&self) -> bool {
|
||||||
self.object_shared().is_visible()
|
// safety: only have one of these, doesn't modify slotmap
|
||||||
|
unsafe { self.object_shared() }.is_visible()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn show(&mut self) -> &mut Self {
|
pub fn show(&mut self) -> &mut Self {
|
||||||
self.object().show();
|
// safety: only have one of these, doesn't modify slotmap
|
||||||
|
unsafe { self.object().show() };
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn show_affine(&mut self, affine_mode: AffineMode) -> &mut Self {
|
pub fn show_affine(&mut self, affine_mode: AffineMode) -> &mut Self {
|
||||||
self.object().show_affine(affine_mode);
|
// safety: only have one of these, doesn't modify slotmap
|
||||||
|
unsafe { self.object().show_affine(affine_mode) };
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_hflip(&mut self, flip: bool) -> &mut Self {
|
pub fn set_hflip(&mut self, flip: bool) -> &mut Self {
|
||||||
self.object().set_hflip(flip);
|
// safety: only have one of these, doesn't modify slotmap
|
||||||
|
unsafe { self.object().set_hflip(flip) };
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_vflip(&mut self, flip: bool) -> &mut Self {
|
pub fn set_vflip(&mut self, flip: bool) -> &mut Self {
|
||||||
self.object().set_vflip(flip);
|
// safety: only have one of these, doesn't modify slotmap
|
||||||
|
unsafe { self.object().set_vflip(flip) };
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_x(&mut self, x: u16) -> &mut Self {
|
pub fn set_x(&mut self, x: u16) -> &mut Self {
|
||||||
self.object().set_x(x);
|
// safety: only have one of these, doesn't modify slotmap
|
||||||
|
unsafe { self.object().set_x(x) };
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_priority(&mut self, priority: Priority) -> &mut Self {
|
pub fn set_priority(&mut self, priority: Priority) -> &mut Self {
|
||||||
self.object().set_priority(priority);
|
// safety: only have one of these, doesn't modify slotmap
|
||||||
|
unsafe { self.object().set_priority(priority) };
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hide(&mut self) -> &mut Self {
|
pub fn hide(&mut self) -> &mut Self {
|
||||||
self.object().hide();
|
// safety: only have one of these, doesn't modify slotmap
|
||||||
|
unsafe { self.object().hide() };
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_y(&mut self, y: u16) -> &mut Self {
|
pub fn set_y(&mut self, y: u16) -> &mut Self {
|
||||||
self.object().set_y(y);
|
// safety: only have one of these, doesn't modify slotmap
|
||||||
|
unsafe { self.object().set_y(y) };
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_position(&mut self, position: Vector2D<i32>) -> &mut Self {
|
pub fn set_position(&mut self, position: Vector2D<i32>) -> &mut Self {
|
||||||
self.object().set_position(position);
|
// safety: only have one of these, doesn't modify slotmap
|
||||||
|
unsafe { self.object().set_position(position) };
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_sprite(&mut self, sprite: SpriteVram) -> &mut Self {
|
pub fn set_sprite(&mut self, sprite: SpriteVram) -> &mut Self {
|
||||||
self.object().set_sprite(sprite);
|
// safety: only have one of these, doesn't modify slotmap
|
||||||
|
unsafe { self.object().set_sprite(sprite) };
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue