Skip to content

Commit

Permalink
refactor!: remove prelude
Browse files Browse the repository at this point in the history
  • Loading branch information
zetanumbers committed Jan 14, 2022
1 parent e2a6345 commit 4340269
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
9 changes: 6 additions & 3 deletions wasm4/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions wasm4/src/prelude.rs

This file was deleted.

4 changes: 2 additions & 2 deletions wasm4/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand All @@ -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_(),
}
}
Expand Down
6 changes: 3 additions & 3 deletions wasm4/src/sound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -13,7 +13,7 @@ impl Resource {

/// Leak resource and return static reference. Expect no runtime overhead.
pub fn leak(self) -> &'static Self {
&Resource(())
&Audio(())
}
}

Expand Down

0 comments on commit 4340269

Please # to comment.