Compare commits
No commits in common. "c65b735f5743f31a30e92f062062ec3c9e861c02" and "82696b2d1ae49042dab5944f5fef67a7159fd437" have entirely different histories.
c65b735f57
...
82696b2d1a
|
@ -1,19 +1,20 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
commands::{wrap_command, wrap_origin_accessors},
|
commands::{wrap_command, wrap_origin_accessors},
|
||||||
macros::wrap,
|
macros::{wrap_fields, wrap_functions},
|
||||||
};
|
};
|
||||||
use servicepoint::{Bitmap, BitmapCommand, CompressionCode, Origin};
|
use servicepoint::{Bitmap, BitmapCommand, CompressionCode, Origin};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
wrap_command!(Bitmap);
|
wrap_command!(Bitmap);
|
||||||
wrap_origin_accessors!(BitmapCommand);
|
|
||||||
|
|
||||||
wrap! {
|
wrap_fields!(BitmapCommand;
|
||||||
BitmapCommand {
|
|
||||||
properties:
|
|
||||||
prop bitmap: Bitmap { get mut; set move; };
|
prop bitmap: Bitmap { get mut; set move; };
|
||||||
prop compression: CompressionCode { get; set; };
|
prop compression: CompressionCode { get; set; };
|
||||||
functions:
|
);
|
||||||
|
|
||||||
|
wrap_origin_accessors!(BitmapCommand);
|
||||||
|
|
||||||
|
wrap_functions!(associate BitmapCommand;
|
||||||
/// Sets a window of pixels to the specified values.
|
/// Sets a window of pixels to the specified values.
|
||||||
///
|
///
|
||||||
/// The passed [Bitmap] gets consumed.
|
/// The passed [Bitmap] gets consumed.
|
||||||
|
@ -39,5 +40,4 @@ wrap! {
|
||||||
fn from_bitmap(bitmap: move NonNull<Bitmap>) -> move NonNull<BitmapCommand> {
|
fn from_bitmap(bitmap: move NonNull<Bitmap>) -> move NonNull<BitmapCommand> {
|
||||||
bitmap.into()
|
bitmap.into()
|
||||||
};
|
};
|
||||||
}
|
);
|
||||||
}
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
use crate::{commands::wrap_command, macros::wrap};
|
use crate::{
|
||||||
|
commands::wrap_command,
|
||||||
|
macros::{wrap_fields, wrap_functions},
|
||||||
|
};
|
||||||
use servicepoint::{
|
use servicepoint::{
|
||||||
BinaryOperation, BitVecCommand, CompressionCode, DisplayBitVec, Offset,
|
BinaryOperation, BitVecCommand, CompressionCode, DisplayBitVec, Offset,
|
||||||
};
|
};
|
||||||
|
@ -6,14 +9,14 @@ use std::ptr::NonNull;
|
||||||
|
|
||||||
wrap_command!(BitVec);
|
wrap_command!(BitVec);
|
||||||
|
|
||||||
wrap!(
|
wrap_fields!(BitVecCommand;
|
||||||
BitVecCommand {
|
|
||||||
properties:
|
|
||||||
prop bitvec: DisplayBitVec { get mut; set move; };
|
prop bitvec: DisplayBitVec { get mut; set move; };
|
||||||
prop offset: Offset { get; set; };
|
prop offset: Offset { get; set; };
|
||||||
prop operation: BinaryOperation { get; set; };
|
prop operation: BinaryOperation { get; set; };
|
||||||
prop compression: CompressionCode { get; set; };
|
prop compression: CompressionCode { get; set; };
|
||||||
functions:
|
);
|
||||||
|
|
||||||
|
wrap_functions!(associate BitVecCommand;
|
||||||
/// Set pixel data starting at the pixel offset on screen.
|
/// Set pixel data starting at the pixel offset on screen.
|
||||||
///
|
///
|
||||||
/// The screen will continuously overwrite more pixel data without regarding the offset, meaning
|
/// The screen will continuously overwrite more pixel data without regarding the offset, meaning
|
||||||
|
@ -39,5 +42,4 @@ wrap!(
|
||||||
compression,
|
compression,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
commands::{wrap_command, wrap_origin_accessors},
|
commands::{wrap_command, wrap_origin_accessors},
|
||||||
macros::wrap,
|
macros::{wrap_fields, wrap_functions},
|
||||||
};
|
};
|
||||||
use servicepoint::{BrightnessGrid, BrightnessGridCommand, Origin};
|
use servicepoint::{BrightnessGrid, BrightnessGridCommand, Origin};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
wrap_command!(BrightnessGrid);
|
wrap_command!(BrightnessGrid);
|
||||||
|
|
||||||
|
wrap_fields!(BrightnessGridCommand;
|
||||||
|
prop grid: BrightnessGrid { get mut; set move; };
|
||||||
|
);
|
||||||
|
|
||||||
wrap_origin_accessors!(BrightnessGridCommand);
|
wrap_origin_accessors!(BrightnessGridCommand);
|
||||||
|
|
||||||
wrap!(
|
wrap_functions!(associate BrightnessGridCommand;
|
||||||
BrightnessGridCommand {
|
|
||||||
properties:
|
|
||||||
prop grid: BrightnessGrid { get mut; set move; };
|
|
||||||
functions:
|
|
||||||
/// Set the brightness of individual tiles in a rectangular area of the display.
|
/// Set the brightness of individual tiles in a rectangular area of the display.
|
||||||
///
|
///
|
||||||
/// The passed [BrightnessGrid] gets consumed.
|
/// The passed [BrightnessGrid] gets consumed.
|
||||||
|
@ -34,5 +35,4 @@ wrap!(
|
||||||
fn from_grid(grid: move NonNull<BrightnessGrid>) -> move NonNull<BrightnessGridCommand> {
|
fn from_grid(grid: move NonNull<BrightnessGrid>) -> move NonNull<BrightnessGridCommand> {
|
||||||
grid.into()
|
grid.into()
|
||||||
};
|
};
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::commands::wrap_command;
|
use crate::{commands::wrap_command, macros::wrap_functions};
|
||||||
use servicepoint::{ClearCommand, FadeOutCommand, HardResetCommand};
|
use servicepoint::{ClearCommand, FadeOutCommand, HardResetCommand};
|
||||||
|
|
||||||
macro_rules! wrap_cc_only {
|
macro_rules! wrap_cc_only {
|
||||||
|
@ -6,17 +6,14 @@ macro_rules! wrap_cc_only {
|
||||||
::paste::paste!{
|
::paste::paste!{
|
||||||
wrap_command!($command);
|
wrap_command!($command);
|
||||||
|
|
||||||
$crate::macros::wrap!{
|
wrap_functions!(associate [< $command Command >];
|
||||||
[< $command Command >] {
|
|
||||||
functions:
|
|
||||||
$(#[$meta])*
|
$(#[$meta])*
|
||||||
///
|
///
|
||||||
#[doc = " Returns: a new [`" [< $command Command >] "`] instance."]
|
#[doc = " Returns: a new [`" [< $command Command >] "`] instance."]
|
||||||
fn new() -> move ::core::ptr::NonNull<[< $command Command >]> {
|
fn new() -> move ::core::ptr::NonNull<[< $command Command >]> {
|
||||||
[< $command Command >]
|
[< $command Command >]
|
||||||
};
|
};
|
||||||
}
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
commands::{wrap_command, wrap_origin_accessors},
|
commands::{wrap_command, wrap_origin_accessors},
|
||||||
macros::wrap,
|
macros::{wrap_fields, wrap_functions},
|
||||||
};
|
};
|
||||||
use servicepoint::{CharGrid, CharGridCommand, Origin};
|
use servicepoint::{CharGrid, CharGridCommand, Origin};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
wrap_command!(CharGrid);
|
wrap_command!(CharGrid);
|
||||||
|
|
||||||
|
wrap_fields!(CharGridCommand;
|
||||||
|
prop grid: CharGrid { get mut; set move; };
|
||||||
|
);
|
||||||
|
|
||||||
wrap_origin_accessors!(CharGridCommand);
|
wrap_origin_accessors!(CharGridCommand);
|
||||||
|
|
||||||
wrap!(
|
wrap_functions!(associate CharGridCommand;
|
||||||
CharGridCommand {
|
|
||||||
properties:
|
|
||||||
prop grid: CharGrid { get mut; set move; };
|
|
||||||
functions:
|
|
||||||
/// Show UTF-8 encoded text on the screen.
|
/// Show UTF-8 encoded text on the screen.
|
||||||
///
|
///
|
||||||
/// The passed [CharGrid] gets consumed.
|
/// The passed [CharGrid] gets consumed.
|
||||||
|
@ -34,5 +35,4 @@ wrap!(
|
||||||
fn from_grid(grid: move NonNull<CharGrid>) -> move NonNull<CharGridCommand> {
|
fn from_grid(grid: move NonNull<CharGrid>) -> move NonNull<CharGridCommand> {
|
||||||
grid.into()
|
grid.into()
|
||||||
};
|
};
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
commands::{wrap_command, wrap_origin_accessors},
|
commands::{wrap_command, wrap_origin_accessors},
|
||||||
macros::wrap,
|
macros::{wrap_fields, wrap_functions},
|
||||||
};
|
};
|
||||||
use servicepoint::{Cp437Grid, Cp437GridCommand, Origin};
|
use servicepoint::{Cp437Grid, Cp437GridCommand, Origin};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
wrap_command!(Cp437Grid);
|
wrap_command!(Cp437Grid);
|
||||||
|
|
||||||
|
wrap_fields!(Cp437GridCommand;
|
||||||
|
prop grid: Cp437Grid { get mut; set move; };
|
||||||
|
);
|
||||||
|
|
||||||
wrap_origin_accessors!(Cp437GridCommand);
|
wrap_origin_accessors!(Cp437GridCommand);
|
||||||
|
|
||||||
wrap!(
|
wrap_functions!(associate Cp437GridCommand;
|
||||||
Cp437GridCommand {
|
|
||||||
properties:
|
|
||||||
prop grid: Cp437Grid { get mut; set move; };
|
|
||||||
functions:
|
|
||||||
/// Show text on the screen.
|
/// Show text on the screen.
|
||||||
///
|
///
|
||||||
/// The text is sent in the form of a 2D grid of [CP-437] encoded characters.
|
/// The text is sent in the form of a 2D grid of [CP-437] encoded characters.
|
||||||
|
@ -34,5 +35,4 @@ wrap!(
|
||||||
fn from_grid(grid: move NonNull<Cp437Grid>) -> move NonNull<Cp437GridCommand> {
|
fn from_grid(grid: move NonNull<Cp437Grid>) -> move NonNull<Cp437GridCommand> {
|
||||||
grid.into()
|
grid.into()
|
||||||
};
|
};
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
macros::{derive_clone, derive_free, wrap},
|
macros::{derive_clone, derive_free, wrap_functions, wrap_methods},
|
||||||
mem::{
|
mem::{
|
||||||
heap_clone, heap_drop, heap_move, heap_move_nonnull, heap_move_ok,
|
heap_clone, heap_drop, heap_move, heap_move_nonnull, heap_move_ok,
|
||||||
heap_remove,
|
heap_remove,
|
||||||
|
@ -69,6 +69,8 @@ impl GenericCommand {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
derive_clone!(GenericCommand);
|
||||||
|
|
||||||
impl Clone for GenericCommand {
|
impl Clone for GenericCommand {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -142,6 +144,8 @@ impl Clone for GenericCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
derive_free!(GenericCommand);
|
||||||
|
|
||||||
impl Drop for GenericCommand {
|
impl Drop for GenericCommand {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -168,12 +172,7 @@ impl Drop for GenericCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
derive_clone!(GenericCommand);
|
wrap_functions!(associate GenericCommand;
|
||||||
derive_free!(GenericCommand);
|
|
||||||
|
|
||||||
wrap! {
|
|
||||||
GenericCommand {
|
|
||||||
functions:
|
|
||||||
/// Tries to turn a [Packet] into a [GenericCommand].
|
/// Tries to turn a [Packet] into a [GenericCommand].
|
||||||
///
|
///
|
||||||
/// The packet is dropped in the process.
|
/// The packet is dropped in the process.
|
||||||
|
@ -249,7 +248,9 @@ wrap! {
|
||||||
data: CommandUnion { null: null_mut() },
|
data: CommandUnion { null: null_mut() },
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
methods:
|
);
|
||||||
|
|
||||||
|
wrap_methods! { GenericCommand;
|
||||||
/// Tries to turn a [GenericCommand] into a [Packet].
|
/// Tries to turn a [GenericCommand] into a [Packet].
|
||||||
/// The [GenericCommand] gets consumed.
|
/// The [GenericCommand] gets consumed.
|
||||||
///
|
///
|
||||||
|
@ -289,5 +290,4 @@ wrap! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,21 @@
|
||||||
use crate::{commands::wrap_command, macros::wrap};
|
use crate::{
|
||||||
|
commands::wrap_command,
|
||||||
|
macros::{wrap_fields, wrap_functions},
|
||||||
|
};
|
||||||
use servicepoint::{Brightness, GlobalBrightnessCommand};
|
use servicepoint::{Brightness, GlobalBrightnessCommand};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
wrap_command!(GlobalBrightness);
|
wrap_functions!(associate GlobalBrightnessCommand;
|
||||||
|
|
||||||
wrap!(
|
|
||||||
GlobalBrightnessCommand {
|
|
||||||
properties:
|
|
||||||
prop brightness: Brightness { get; set; };
|
|
||||||
functions:
|
|
||||||
/// Set the brightness of all tiles to the same value.
|
/// Set the brightness of all tiles to the same value.
|
||||||
///
|
///
|
||||||
/// Returns: a new [GlobalBrightnessCommand] instance.
|
/// Returns: a new [GlobalBrightnessCommand] instance.
|
||||||
fn new(brightness: val Brightness) -> move NonNull<GlobalBrightnessCommand> {
|
fn new(brightness: val Brightness) -> move NonNull<GlobalBrightnessCommand> {
|
||||||
GlobalBrightnessCommand::from(brightness)
|
GlobalBrightnessCommand::from(brightness)
|
||||||
};
|
};
|
||||||
}
|
);
|
||||||
|
|
||||||
|
wrap_command!(GlobalBrightness);
|
||||||
|
|
||||||
|
wrap_fields!(GlobalBrightnessCommand;
|
||||||
|
prop brightness: Brightness { get; set; };
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
containers::{wrap_grid, ByteSlice},
|
containers::{wrap_grid, ByteSlice},
|
||||||
macros::wrap,
|
macros::{wrap_functions, wrap_methods},
|
||||||
};
|
};
|
||||||
use servicepoint::{
|
use servicepoint::{
|
||||||
Bitmap, BitmapCommand, CompressionCode, DataRef, DisplayBitVec, Grid,
|
Bitmap, BitmapCommand, CompressionCode, DataRef, DisplayBitVec, Grid,
|
||||||
|
@ -10,9 +10,7 @@ use std::ptr::NonNull;
|
||||||
|
|
||||||
wrap_grid!(Bitmap, bool);
|
wrap_grid!(Bitmap, bool);
|
||||||
|
|
||||||
wrap! {
|
wrap_functions!(associate Bitmap;
|
||||||
Bitmap {
|
|
||||||
functions:
|
|
||||||
/// Creates a new [Bitmap] with the specified dimensions.
|
/// Creates a new [Bitmap] with the specified dimensions.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
|
@ -74,8 +72,9 @@ wrap! {
|
||||||
) -> move_ok *mut Bitmap {
|
) -> move_ok *mut Bitmap {
|
||||||
Bitmap::from_bitvec(width, bitvec)
|
Bitmap::from_bitvec(width, bitvec)
|
||||||
};
|
};
|
||||||
|
);
|
||||||
|
|
||||||
methods:
|
wrap_methods!(Bitmap;
|
||||||
/// Consumes the Bitmap and returns the contained BitVec.
|
/// Consumes the Bitmap and returns the contained BitVec.
|
||||||
fn into_bitvec(move bitmap) -> move NonNull<DisplayBitVec> {
|
fn into_bitvec(move bitmap) -> move NonNull<DisplayBitVec> {
|
||||||
bitmap.into()
|
bitmap.into()
|
||||||
|
@ -98,5 +97,4 @@ wrap! {
|
||||||
///
|
///
|
||||||
/// The returned memory is valid for the lifetime of the bitmap.
|
/// The returned memory is valid for the lifetime of the bitmap.
|
||||||
fn data_ref_mut(mut instance) -> slice ByteSlice;
|
fn data_ref_mut(mut instance) -> slice ByteSlice;
|
||||||
}
|
);
|
||||||
}
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
containers::{wrap_container, ByteSlice},
|
containers::{wrap_container, ByteSlice},
|
||||||
macros::wrap,
|
macros::{wrap_functions, wrap_methods},
|
||||||
};
|
};
|
||||||
use servicepoint::{
|
use servicepoint::{
|
||||||
BinaryOperation, BitVecCommand, CompressionCode, DisplayBitVec, Packet,
|
BinaryOperation, BitVecCommand, CompressionCode, DisplayBitVec, Packet,
|
||||||
|
@ -9,9 +9,7 @@ use std::ptr::NonNull;
|
||||||
|
|
||||||
wrap_container!(DisplayBitVec);
|
wrap_container!(DisplayBitVec);
|
||||||
|
|
||||||
wrap! {
|
wrap_functions!(associate DisplayBitVec;
|
||||||
DisplayBitVec {
|
|
||||||
functions:
|
|
||||||
/// Creates a new [DisplayBitVec] instance.
|
/// Creates a new [DisplayBitVec] instance.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
|
@ -33,8 +31,9 @@ wrap! {
|
||||||
fn load(data: slice ByteSlice) -> move NonNull<DisplayBitVec> {
|
fn load(data: slice ByteSlice) -> move NonNull<DisplayBitVec> {
|
||||||
DisplayBitVec::from_slice(data)
|
DisplayBitVec::from_slice(data)
|
||||||
};
|
};
|
||||||
|
);
|
||||||
|
|
||||||
methods:
|
wrap_methods!(DisplayBitVec;
|
||||||
/// Creates a [BitVecCommand] and immediately turns that into a [Packet].
|
/// Creates a [BitVecCommand] and immediately turns that into a [Packet].
|
||||||
///
|
///
|
||||||
/// The provided [DisplayBitVec] gets consumed.
|
/// The provided [DisplayBitVec] gets consumed.
|
||||||
|
@ -99,5 +98,4 @@ wrap! {
|
||||||
///
|
///
|
||||||
/// The returned memory is valid for the lifetime of the bitvec.
|
/// The returned memory is valid for the lifetime of the bitvec.
|
||||||
fn as_raw_mut_slice(mut instance) -> slice ByteSlice;
|
fn as_raw_mut_slice(mut instance) -> slice ByteSlice;
|
||||||
}
|
);
|
||||||
}
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
containers::{wrap_grid, ByteSlice},
|
containers::{wrap_grid, ByteSlice},
|
||||||
macros::wrap,
|
macros::{wrap_functions, wrap_methods},
|
||||||
};
|
};
|
||||||
use servicepoint::{
|
use servicepoint::{
|
||||||
Brightness, BrightnessGrid, BrightnessGridCommand, ByteGrid, DataRef, Grid,
|
Brightness, BrightnessGrid, BrightnessGridCommand, ByteGrid, DataRef, Grid,
|
||||||
|
@ -10,9 +10,7 @@ use std::{mem::transmute, ptr::NonNull};
|
||||||
|
|
||||||
wrap_grid!(BrightnessGrid, Brightness);
|
wrap_grid!(BrightnessGrid, Brightness);
|
||||||
|
|
||||||
wrap! {
|
wrap_functions!(associate BrightnessGrid;
|
||||||
BrightnessGrid {
|
|
||||||
functions:
|
|
||||||
/// Creates a new [BrightnessGrid] with the specified dimensions.
|
/// Creates a new [BrightnessGrid] with the specified dimensions.
|
||||||
///
|
///
|
||||||
/// returns: [BrightnessGrid] initialized to 0.
|
/// returns: [BrightnessGrid] initialized to 0.
|
||||||
|
@ -47,8 +45,9 @@ wrap! {
|
||||||
ByteGrid::load(width, height, data)
|
ByteGrid::load(width, height, data)
|
||||||
.map(move |grid| grid.map(Brightness::saturating_from))
|
.map(move |grid| grid.map(Brightness::saturating_from))
|
||||||
};
|
};
|
||||||
|
);
|
||||||
|
|
||||||
methods:
|
wrap_methods!(BrightnessGrid;
|
||||||
/// Creates a [BrightnessGridCommand] and immediately turns that into a [Packet].
|
/// Creates a [BrightnessGridCommand] and immediately turns that into a [Packet].
|
||||||
///
|
///
|
||||||
/// The provided [BrightnessGrid] gets consumed.
|
/// The provided [BrightnessGrid] gets consumed.
|
||||||
|
@ -73,5 +72,4 @@ wrap! {
|
||||||
transmute::<&mut [Brightness], &mut [u8]>(br_slice)
|
transmute::<&mut [Brightness], &mut [u8]>(br_slice)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
);
|
||||||
}
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
containers::{derive_get_width_height, wrap_container, ByteSlice},
|
containers::{derive_get_width_height, wrap_container, ByteSlice},
|
||||||
macros::wrap,
|
macros::{wrap_functions, wrap_methods},
|
||||||
};
|
};
|
||||||
use servicepoint::{CharGrid, CharGridCommand, Grid, Origin, Packet};
|
use servicepoint::{CharGrid, CharGridCommand, Grid, Origin, Packet};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
@ -8,9 +8,7 @@ use std::ptr::NonNull;
|
||||||
wrap_container!(CharGrid);
|
wrap_container!(CharGrid);
|
||||||
derive_get_width_height!(CharGrid);
|
derive_get_width_height!(CharGrid);
|
||||||
|
|
||||||
wrap! {
|
wrap_functions!(associate CharGrid;
|
||||||
CharGrid {
|
|
||||||
functions:
|
|
||||||
/// Creates a new [CharGrid] with the specified dimensions.
|
/// Creates a new [CharGrid] with the specified dimensions.
|
||||||
///
|
///
|
||||||
/// returns: [CharGrid] initialized to 0.
|
/// returns: [CharGrid] initialized to 0.
|
||||||
|
@ -33,7 +31,10 @@ wrap! {
|
||||||
fn load(width: val usize, height: val usize, data: slice ByteSlice) -> move_ok *mut CharGrid {
|
fn load(width: val usize, height: val usize, data: slice ByteSlice) -> move_ok *mut CharGrid {
|
||||||
CharGrid::load_utf8(width, height, data.to_vec())
|
CharGrid::load_utf8(width, height, data.to_vec())
|
||||||
};
|
};
|
||||||
methods:
|
);
|
||||||
|
|
||||||
|
wrap_methods!(CharGrid;
|
||||||
|
|
||||||
/// Returns the current value at the specified position.
|
/// Returns the current value at the specified position.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
|
@ -85,5 +86,4 @@ wrap! {
|
||||||
origin: Origin::new(x, y),
|
origin: Origin::new(x, y),
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
}
|
);
|
||||||
}
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
containers::{wrap_grid, ByteSlice},
|
containers::{wrap_grid, ByteSlice},
|
||||||
macros::wrap,
|
macros::{wrap_functions, wrap_methods},
|
||||||
};
|
};
|
||||||
use servicepoint::{
|
use servicepoint::{
|
||||||
Cp437Grid, Cp437GridCommand, DataRef, Grid, Origin, Packet,
|
Cp437Grid, Cp437GridCommand, DataRef, Grid, Origin, Packet,
|
||||||
|
@ -9,9 +9,7 @@ use std::ptr::NonNull;
|
||||||
|
|
||||||
wrap_grid!(Cp437Grid, u8);
|
wrap_grid!(Cp437Grid, u8);
|
||||||
|
|
||||||
wrap! {
|
wrap_functions!(associate Cp437Grid;
|
||||||
Cp437Grid {
|
|
||||||
functions:
|
|
||||||
/// Creates a new [Cp437Grid] with the specified dimensions.
|
/// Creates a new [Cp437Grid] with the specified dimensions.
|
||||||
///
|
///
|
||||||
/// returns: [Cp437Grid] initialized to 0.
|
/// returns: [Cp437Grid] initialized to 0.
|
||||||
|
@ -23,8 +21,9 @@ wrap! {
|
||||||
fn load(width: val usize, height: val usize, data: slice ByteSlice) -> move_some *mut Cp437Grid {
|
fn load(width: val usize, height: val usize, data: slice ByteSlice) -> move_some *mut Cp437Grid {
|
||||||
Cp437Grid::load(width, height, data)
|
Cp437Grid::load(width, height, data)
|
||||||
};
|
};
|
||||||
|
);
|
||||||
|
|
||||||
methods:
|
wrap_methods!(Cp437Grid;
|
||||||
/// Creates a [Cp437GridCommand] and immediately turns that into a [Packet].
|
/// Creates a [Cp437GridCommand] and immediately turns that into a [Packet].
|
||||||
///
|
///
|
||||||
/// The provided [Cp437Grid] gets consumed.
|
/// The provided [Cp437Grid] gets consumed.
|
||||||
|
@ -41,5 +40,4 @@ wrap! {
|
||||||
///
|
///
|
||||||
/// The returned memory is valid for the lifetime of the instance.
|
/// The returned memory is valid for the lifetime of the instance.
|
||||||
fn data_ref_mut(mut instance) -> slice ByteSlice;
|
fn data_ref_mut(mut instance) -> slice ByteSlice;
|
||||||
}
|
);
|
||||||
}
|
|
||||||
|
|
|
@ -263,61 +263,8 @@ macro_rules! wrap_functions {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! wrap {
|
|
||||||
(
|
|
||||||
$object_type:ident {
|
|
||||||
$(
|
|
||||||
properties:
|
|
||||||
$(
|
|
||||||
prop $prop_name:ident : $prop_type:ty { $($accessor:ident $($modifier:ident)?;)+ };
|
|
||||||
)*
|
|
||||||
)?
|
|
||||||
$(
|
|
||||||
functions:
|
|
||||||
$(
|
|
||||||
$(#[$fn_meta:meta])+
|
|
||||||
fn $fn_name:ident($($fn_param_name:ident: $fn_param_modifier:ident $fn_param_type:ty),*$(,)?)
|
|
||||||
$(-> $fn_return_modifier:ident $fn_return_type:ty)?
|
|
||||||
$fn_block:block;
|
|
||||||
)*
|
|
||||||
)?
|
|
||||||
$(
|
|
||||||
methods:
|
|
||||||
$(
|
|
||||||
$(#[$method_meta:meta])+
|
|
||||||
fn $method_name:ident($method_instance_modifier:ident $method_instance:ident $(, $($method_param_name:ident: $method_param_modifier:ident $method_param_type:ty),*)?)
|
|
||||||
$(-> $method_return_modifier:ident $method_return_type:ty)?
|
|
||||||
$($method_impl:block)?;
|
|
||||||
)*
|
|
||||||
)?
|
|
||||||
}
|
|
||||||
) => {
|
|
||||||
$($(
|
|
||||||
$crate::macros::wrap_fields!($object_type;
|
|
||||||
prop $prop_name : $prop_type { $($accessor $($modifier)?;)+ };
|
|
||||||
);
|
|
||||||
)*)?
|
|
||||||
$($(
|
|
||||||
$crate::macros::wrap_functions!(associate $object_type;
|
|
||||||
$(#[$fn_meta])+
|
|
||||||
fn $fn_name($($fn_param_name: $fn_param_modifier $fn_param_type),*)
|
|
||||||
$(-> $fn_return_modifier $fn_return_type)?
|
|
||||||
$fn_block;
|
|
||||||
);
|
|
||||||
)*)?
|
|
||||||
$($(
|
|
||||||
$crate::macros::wrap_method!($object_type;
|
|
||||||
$(#[$method_meta])+
|
|
||||||
fn $method_name($method_instance_modifier $method_instance $(, $($method_param_name: $method_param_modifier $method_param_type),*)?)
|
|
||||||
$(-> $method_return_modifier $method_return_type)?
|
|
||||||
$($method_impl)?;
|
|
||||||
);
|
|
||||||
)*)?
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) use {
|
pub(crate) use {
|
||||||
apply_param_modifier, apply_return_modifier, derive_clone, derive_free,
|
apply_param_modifier, apply_return_modifier, derive_clone, derive_free,
|
||||||
wrap, wrap_fields, wrap_fields_accessor, wrap_function, wrap_functions,
|
wrap_fields, wrap_fields_accessor, wrap_function, wrap_functions,
|
||||||
wrap_method, wrap_methods,
|
wrap_method, wrap_methods,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,18 +1,13 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
containers::ByteSlice,
|
containers::ByteSlice,
|
||||||
macros::{derive_clone, derive_free, wrap, wrap_functions},
|
macros::{
|
||||||
|
derive_clone, derive_free, wrap_fields, wrap_functions, wrap_methods,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use servicepoint::{CommandCode, Header, Packet};
|
use servicepoint::{CommandCode, Header, Packet};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
derive_clone!(Packet);
|
wrap_functions!(associate Packet;
|
||||||
derive_free!(Packet);
|
|
||||||
|
|
||||||
wrap! {
|
|
||||||
Packet {
|
|
||||||
properties:
|
|
||||||
prop header: Header { get; get mut; set; };
|
|
||||||
functions:
|
|
||||||
/// Tries to load a [Packet] from the passed array with the specified length.
|
/// Tries to load a [Packet] from the passed array with the specified length.
|
||||||
///
|
///
|
||||||
/// returns: NULL in case of an error, pointer to the allocated packet otherwise
|
/// returns: NULL in case of an error, pointer to the allocated packet otherwise
|
||||||
|
@ -32,7 +27,16 @@ wrap! {
|
||||||
|
|
||||||
Packet { header, payload }
|
Packet { header, payload }
|
||||||
};
|
};
|
||||||
methods:
|
);
|
||||||
|
|
||||||
|
derive_clone!(Packet);
|
||||||
|
derive_free!(Packet);
|
||||||
|
|
||||||
|
wrap_fields!(Packet;
|
||||||
|
prop header: Header { get; get mut; set; };
|
||||||
|
);
|
||||||
|
|
||||||
|
wrap_methods! { Packet;
|
||||||
/// Returns a pointer to the current payload of the provided packet.
|
/// Returns a pointer to the current payload of the provided packet.
|
||||||
///
|
///
|
||||||
/// Returns an [ByteSlice::INVALID] instance in case the packet does not have any payload.
|
/// Returns an [ByteSlice::INVALID] instance in case the packet does not have any payload.
|
||||||
|
@ -66,10 +70,10 @@ wrap! {
|
||||||
packet.serialize_to(buffer.as_slice_mut()).unwrap_or(0)
|
packet.serialize_to(buffer.as_slice_mut()).unwrap_or(0)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wrap_functions!(sp;
|
wrap_functions!(sp;
|
||||||
|
|
||||||
/// Converts u16 into [CommandCode].
|
/// Converts u16 into [CommandCode].
|
||||||
///
|
///
|
||||||
/// If the provided value is not valid, false is returned and result is not changed.
|
/// If the provided value is not valid, false is returned and result is not changed.
|
||||||
|
|
11
src/udp.rs
11
src/udp.rs
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
commands::{CommandTag, GenericCommand},
|
commands::{CommandTag, GenericCommand},
|
||||||
macros::{derive_free, wrap},
|
macros::{derive_free, wrap_functions, wrap_methods},
|
||||||
mem::heap_remove,
|
mem::heap_remove,
|
||||||
};
|
};
|
||||||
use servicepoint::{Header, Packet, UdpSocketExt};
|
use servicepoint::{Header, Packet, UdpSocketExt};
|
||||||
|
@ -12,9 +12,7 @@ use std::{
|
||||||
|
|
||||||
derive_free!(UdpSocket);
|
derive_free!(UdpSocket);
|
||||||
|
|
||||||
wrap! {
|
wrap_functions!(associate UdpSocket;
|
||||||
UdpSocket {
|
|
||||||
functions:
|
|
||||||
/// Creates a new instance of [UdpSocket].
|
/// Creates a new instance of [UdpSocket].
|
||||||
///
|
///
|
||||||
/// returns: NULL if connection fails, or connected instance
|
/// returns: NULL if connection fails, or connected instance
|
||||||
|
@ -48,7 +46,9 @@ wrap! {
|
||||||
let addr = SocketAddrV4::new(Ipv4Addr::from([ip1, ip2, ip3, ip4]), port);
|
let addr = SocketAddrV4::new(Ipv4Addr::from([ip1, ip2, ip3, ip4]), port);
|
||||||
UdpSocket::bind_connect(addr)
|
UdpSocket::bind_connect(addr)
|
||||||
};
|
};
|
||||||
methods:
|
);
|
||||||
|
|
||||||
|
wrap_methods! {UdpSocket;
|
||||||
/// Sends a [Packet] to the display using the [UdpSocket].
|
/// Sends a [Packet] to the display using the [UdpSocket].
|
||||||
///
|
///
|
||||||
/// The passed `packet` gets consumed.
|
/// The passed `packet` gets consumed.
|
||||||
|
@ -105,7 +105,6 @@ wrap! {
|
||||||
};
|
};
|
||||||
udp_connection.send(&Vec::from(packet)).is_ok()
|
udp_connection.send(&Vec::from(packet)).is_ok()
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mod _hidden {
|
mod _hidden {
|
||||||
|
|
Loading…
Reference in a new issue