From 4340269a340c2da865b0f7c143fbf0306d0ab8ae Mon Sep 17 00:00:00 2001 From: Daria Sukhonina Date: Mon, 10 Jan 2022 17:18:29 +0300 Subject: [PATCH] refactor!: remove prelude --- wasm4/src/lib.rs | 9 ++++++--- wasm4/src/prelude.rs | 4 ---- wasm4/src/runtime.rs | 4 ++-- wasm4/src/sound.rs | 6 +++--- 4 files changed, 11 insertions(+), 12 deletions(-) delete mode 100644 wasm4/src/prelude.rs diff --git a/wasm4/src/lib.rs b/wasm4/src/lib.rs index 70eee06..051c351 100644 --- a/wasm4/src/lib.rs +++ b/wasm4/src/lib.rs @@ -27,13 +27,16 @@ //! ``` pub mod draw; -pub mod prelude; pub mod runtime; pub mod sound; mod utils; -pub use runtime::*; -pub use utils::OutOfDomainError; +pub use self::{ + draw::{Framebuffer, Sprite}, + runtime::*, + sound::Audio, + utils::OutOfDomainError, +}; pub use wasm4_sys as sys; pub fn trace(msg: &str) { diff --git a/wasm4/src/prelude.rs b/wasm4/src/prelude.rs deleted file mode 100644 index 13c9b31..0000000 --- a/wasm4/src/prelude.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub use crate::{ - draw::{self, Framebuffer}, - sound, -}; diff --git a/wasm4/src/runtime.rs b/wasm4/src/runtime.rs index 07f9c32..38eb6df 100644 --- a/wasm4/src/runtime.rs +++ b/wasm4/src/runtime.rs @@ -6,7 +6,7 @@ pub trait Runtime { } pub struct Resources { - pub sound: crate::sound::Resource, + pub sound: crate::sound::Audio, pub framebuffer: crate::draw::Framebuffer, } @@ -16,7 +16,7 @@ impl Resources { /// Called inside of the [`crate::main`] macro. pub unsafe fn new() -> Self { Resources { - sound: crate::sound::Resource(()), + sound: crate::sound::Audio(()), framebuffer: crate::draw::Framebuffer::new_(), } } diff --git a/wasm4/src/sound.rs b/wasm4/src/sound.rs index 094d12e..785b25f 100644 --- a/wasm4/src/sound.rs +++ b/wasm4/src/sound.rs @@ -2,9 +2,9 @@ use crate::utils::OutOfDomainError; use core::mem; #[derive(PartialEq, Eq)] -pub struct Resource(pub(crate) ()); +pub struct Audio(pub(crate) ()); -impl Resource { +impl Audio { /// Plays a sound tone. Volume is between 0 and 100. pub fn tone(&self, frequency: LinearFrequency, duration: Duration, volume: u32, flags: Flags) { // SAFETY: calling extern function @@ -13,7 +13,7 @@ impl Resource { /// Leak resource and return static reference. Expect no runtime overhead. pub fn leak(self) -> &'static Self { - &Resource(()) + &Audio(()) } }