78 lines
2.1 KiB
Rust
78 lines
2.1 KiB
Rust
mod bitmap;
|
|
mod bitvec;
|
|
mod brightness_grid;
|
|
mod byte_slice;
|
|
mod char_grid;
|
|
mod cp437_grid;
|
|
|
|
pub use bitmap::*;
|
|
pub use bitvec::*;
|
|
pub use brightness_grid::*;
|
|
pub use byte_slice::*;
|
|
pub use char_grid::*;
|
|
pub use cp437_grid::*;
|
|
|
|
macro_rules! derive_container {
|
|
($object_type:ident) => {
|
|
$crate::macros::derive_clone!($object_type);
|
|
$crate::macros::derive_free!($object_type);
|
|
};
|
|
}
|
|
|
|
macro_rules! derive_get_width_height {
|
|
($object_type:ident) => {
|
|
$crate::macros::wrap_methods! {$object_type;
|
|
/// Gets the width.
|
|
fn width(ref instance) -> val usize;
|
|
|
|
/// Gets the height.
|
|
fn height(ref instance) -> val usize;
|
|
}
|
|
};
|
|
}
|
|
|
|
macro_rules! derive_grid {
|
|
($object_type:ident, $value_type:ident) => {
|
|
$crate::containers::derive_get_width_height!($object_type);
|
|
$crate::macros::wrap_methods! {$object_type;
|
|
/// Gets the current value at the specified position.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// - `x` and `y`: position of the cell to read
|
|
///
|
|
/// # Panics
|
|
///
|
|
/// - when accessing `x` or `y` out of bounds
|
|
fn get(ref instance, x: val usize, y: val usize) -> val $value_type;
|
|
|
|
/// Sets the value of the specified position.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// - `x` and `y`: position of the cell
|
|
/// - `value`: the value to write to the cell
|
|
///
|
|
/// # Panics
|
|
///
|
|
/// - when accessing `x` or `y` out of bounds
|
|
fn set(mut instance, x: val usize, y: val usize, value: val $value_type);
|
|
|
|
/// Sets the state of all cells in the grid.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// - `value`: the value to set all cells to
|
|
fn fill(mut instance, value: val $value_type);
|
|
}
|
|
};
|
|
}
|
|
|
|
pub(crate) use {derive_container, derive_get_width_height, derive_grid};
|
|
|
|
mod _hidden {
|
|
/// This is a type only used by cbindgen to have a type for pointers.
|
|
#[allow(unused)]
|
|
pub struct DisplayBitVec;
|
|
}
|