more type name based naming
This commit is contained in:
parent
8f13ba61f0
commit
8116375fd0
27 changed files with 787 additions and 750 deletions
|
@ -8,14 +8,14 @@ use std::ptr::NonNull;
|
|||
|
||||
wrap_command!(Bitmap);
|
||||
|
||||
wrap_fields!(cmd_bitmap::BitmapCommand;
|
||||
wrap_fields!(BitmapCommand;
|
||||
prop bitmap: Bitmap { mut get(); move set(value); };
|
||||
prop compression: CompressionCode { get(); set(value); };
|
||||
);
|
||||
|
||||
wrap_origin_accessors!(cmd_bitmap::BitmapCommand);
|
||||
wrap_origin_accessors!(BitmapCommand);
|
||||
|
||||
wrap_functions!(cmd_bitmap;
|
||||
wrap_functions!(associate BitmapCommand;
|
||||
/// Sets a window of pixels to the specified values.
|
||||
///
|
||||
/// The passed [Bitmap] gets consumed.
|
||||
|
|
|
@ -11,14 +11,14 @@ use std::ptr::NonNull;
|
|||
|
||||
wrap_command!(BitVec);
|
||||
|
||||
wrap_fields!(cmd_bitvec::BitVecCommand;
|
||||
wrap_fields!(BitVecCommand;
|
||||
prop bitvec: DisplayBitVec { mut get(); move set(value); };
|
||||
prop offset: Offset { get(); set(value); };
|
||||
prop operation: BinaryOperation { get(); set(value); };
|
||||
prop compression: CompressionCode { get(); set(value); };
|
||||
);
|
||||
|
||||
wrap_functions!(cmd_bitvec;
|
||||
wrap_functions!(associate BitVecCommand;
|
||||
|
||||
/// Set pixel data starting at the pixel offset on screen.
|
||||
///
|
||||
|
|
|
@ -8,13 +8,13 @@ use std::ptr::NonNull;
|
|||
|
||||
wrap_command!(BrightnessGrid);
|
||||
|
||||
wrap_fields!(cmd_brightnessgrid::BrightnessGridCommand;
|
||||
wrap_fields!(BrightnessGridCommand;
|
||||
prop grid: BrightnessGrid { mut get(); move set(grid); };
|
||||
);
|
||||
|
||||
wrap_origin_accessors!(cmd_brightnessgrid::BrightnessGridCommand);
|
||||
wrap_origin_accessors!(BrightnessGridCommand);
|
||||
|
||||
wrap_functions!(cmd_brightnessgrid;
|
||||
wrap_functions!(associate BrightnessGridCommand;
|
||||
|
||||
/// Set the brightness of individual tiles in a rectangular area of the display.
|
||||
///
|
||||
|
|
|
@ -5,22 +5,18 @@ use servicepoint::{ClearCommand, FadeOutCommand, HardResetCommand};
|
|||
use std::ptr::NonNull;
|
||||
|
||||
macro_rules! wrap_cc_only {
|
||||
($(#[$meta:meta])*; $command:ident, $prefix:ident, $object_type:ident) => {
|
||||
wrap_command!($command);
|
||||
|
||||
wrap_functions!($prefix;
|
||||
$(#[$meta])*
|
||||
///
|
||||
#[doc = concat!(" Returns: a new [`",stringify!($object_type),"`] instance.")]
|
||||
fn new() -> NonNull<$object_type> {
|
||||
heap_move_nonnull($object_type)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
($(#[$meta:meta])* $command:ident) => {
|
||||
::paste::paste!{
|
||||
wrap_cc_only!($(#[$meta])*; $command, [< cmd_ $command:lower >], [< $command Command >]);
|
||||
wrap_command!($command);
|
||||
|
||||
wrap_functions!(associate [< $command Command >];
|
||||
$(#[$meta])*
|
||||
///
|
||||
#[doc = " Returns: a new [`" [< $command Command >] "`] instance."]
|
||||
fn new() -> NonNull<[< $command Command >]> {
|
||||
heap_move_nonnull([< $command Command >])
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -8,11 +8,11 @@ use std::ptr::NonNull;
|
|||
|
||||
wrap_command!(CharGrid);
|
||||
|
||||
wrap_fields!(cmd_chargrid::CharGridCommand;
|
||||
wrap_fields!(CharGridCommand;
|
||||
prop grid: CharGrid { mut get(); move set(grid); };
|
||||
);
|
||||
|
||||
wrap_origin_accessors!(cmd_chargrid::CharGridCommand);
|
||||
wrap_origin_accessors!(CharGridCommand);
|
||||
|
||||
wrap_functions!(cmd_chargrid;
|
||||
|
||||
|
|
|
@ -8,11 +8,11 @@ use std::ptr::NonNull;
|
|||
|
||||
wrap_command!(Cp437Grid);
|
||||
|
||||
wrap_fields!(cmd_cp437grid::Cp437GridCommand;
|
||||
wrap_fields!(Cp437GridCommand;
|
||||
prop grid: Cp437Grid { mut get(); move set(grid); };
|
||||
);
|
||||
|
||||
wrap_origin_accessors!(cmd_cp437grid::Cp437GridCommand);
|
||||
wrap_origin_accessors!(Cp437GridCommand);
|
||||
|
||||
wrap_functions!(cmd_cp437grid;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::{
|
|||
use servicepoint::{Brightness, GlobalBrightnessCommand, Packet};
|
||||
use std::ptr::NonNull;
|
||||
|
||||
wrap_functions!(cmd_globalbrightness;
|
||||
wrap_functions!(associate GlobalBrightnessCommand;
|
||||
|
||||
/// Set the brightness of all tiles to the same value.
|
||||
///
|
||||
|
@ -24,8 +24,7 @@ wrap_functions!(cmd_globalbrightness;
|
|||
|
||||
wrap_command!(GlobalBrightness);
|
||||
|
||||
wrap_fields!(
|
||||
cmd_globalbrightness::GlobalBrightnessCommand;
|
||||
wrap_fields!(GlobalBrightnessCommand;
|
||||
prop brightness: Brightness {
|
||||
get();
|
||||
set(value);
|
||||
|
|
|
@ -15,32 +15,35 @@ pub use cp437_grid_command::*;
|
|||
pub use generic_command::*;
|
||||
|
||||
macro_rules! wrap_origin_accessors {
|
||||
( $prefix:ident :: $object_type:ty ) => {
|
||||
$crate::macros::wrap_functions!($prefix;
|
||||
#[doc = concat!(" Reads the origin field of the [`", stringify!($object_type), "`].")]
|
||||
fn get_origin(
|
||||
command: NonNull<$object_type>,
|
||||
origin_x: NonNull<usize>,
|
||||
origin_y: NonNull<usize>,
|
||||
) {
|
||||
unsafe {
|
||||
let origin = &command.as_ref().origin;
|
||||
*origin_x.as_ptr() = origin.x;
|
||||
*origin_y.as_ptr() = origin.y;
|
||||
( $object_type:ident ) => {
|
||||
::paste::paste! {
|
||||
$crate::macros::wrap_functions!(associate $object_type;
|
||||
#[doc = " Reads the origin field of the [`" $object_type "`]."]
|
||||
fn get_origin(
|
||||
command: NonNull<$object_type>,
|
||||
origin_x: NonNull<usize>,
|
||||
origin_y: NonNull<usize>,
|
||||
) {
|
||||
unsafe {
|
||||
let origin = &command.as_ref().origin;
|
||||
*origin_x.as_ptr() = origin.x;
|
||||
*origin_y.as_ptr() = origin.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[doc = concat!(" Overwrites the origin field of the [`", stringify!($object_type), "`].")]
|
||||
fn set_origin(
|
||||
command: NonNull<$object_type>,
|
||||
origin_x: usize,
|
||||
origin_y: usize,
|
||||
) {
|
||||
unsafe {
|
||||
$crate::macros::nonnull_as_mut!(command).origin = ::servicepoint::Origin::new(origin_x, origin_y);
|
||||
#[doc = " Overwrites the origin field of the [`" $object_type "`]."]
|
||||
fn set_origin(
|
||||
command: NonNull<$object_type>,
|
||||
origin_x: usize,
|
||||
origin_y: usize,
|
||||
) {
|
||||
unsafe {
|
||||
$crate::macros::nonnull_as_mut!(command).origin =
|
||||
::servicepoint::Origin::new(origin_x, origin_y);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -62,15 +65,14 @@ macro_rules! derive_command_from {
|
|||
}
|
||||
|
||||
macro_rules! wrap_command {
|
||||
($command:ident, $prefix:ident, $object_type:ident) => {
|
||||
$crate::macros::wrap_clone!($prefix::$object_type);
|
||||
$crate::macros::wrap_free!($prefix::$object_type);
|
||||
|
||||
($command:ident, $object_type:ident) => {
|
||||
$crate::macros::wrap_clone!($object_type);
|
||||
$crate::macros::wrap_free!($object_type);
|
||||
$crate::commands::derive_command_from!($command);
|
||||
};
|
||||
($command:ident) => {
|
||||
::paste::paste!{
|
||||
wrap_command!($command, [< cmd_ $command:lower >], [< $command Command >]);
|
||||
::paste::paste! {
|
||||
wrap_command!($command, [< $command Command >]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue