add derives
This commit is contained in:
parent
c65b735f57
commit
91e8771e81
|
@ -1,15 +1,10 @@
|
||||||
use crate::{
|
use crate::macros::wrap;
|
||||||
commands::{wrap_command, wrap_origin_accessors},
|
|
||||||
macros::wrap,
|
|
||||||
};
|
|
||||||
use servicepoint::{Bitmap, BitmapCommand, CompressionCode, Origin};
|
use servicepoint::{Bitmap, BitmapCommand, CompressionCode, Origin};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
wrap_command!(Bitmap);
|
|
||||||
wrap_origin_accessors!(BitmapCommand);
|
|
||||||
|
|
||||||
wrap! {
|
wrap! {
|
||||||
BitmapCommand {
|
BitmapCommand {
|
||||||
|
derives: crate::commands::derive_command[Bitmap], crate::commands::derive_origin_accessors;
|
||||||
properties:
|
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; };
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
use crate::{commands::wrap_command, macros::wrap};
|
use crate::macros::wrap;
|
||||||
use servicepoint::{
|
use servicepoint::{
|
||||||
BinaryOperation, BitVecCommand, CompressionCode, DisplayBitVec, Offset,
|
BinaryOperation, BitVecCommand, CompressionCode, DisplayBitVec, Offset,
|
||||||
};
|
};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
wrap_command!(BitVec);
|
|
||||||
|
|
||||||
wrap!(
|
wrap!(
|
||||||
BitVecCommand {
|
BitVecCommand {
|
||||||
|
derives: crate::commands::derive_command[BitVec];
|
||||||
properties:
|
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; };
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
use crate::{
|
use crate::macros::wrap;
|
||||||
commands::{wrap_command, wrap_origin_accessors},
|
|
||||||
macros::wrap,
|
|
||||||
};
|
|
||||||
use servicepoint::{BrightnessGrid, BrightnessGridCommand, Origin};
|
use servicepoint::{BrightnessGrid, BrightnessGridCommand, Origin};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
wrap_command!(BrightnessGrid);
|
|
||||||
wrap_origin_accessors!(BrightnessGridCommand);
|
|
||||||
|
|
||||||
wrap!(
|
wrap!(
|
||||||
BrightnessGridCommand {
|
BrightnessGridCommand {
|
||||||
|
derives: crate::commands::derive_command[BrightnessGrid], crate::commands::derive_origin_accessors;
|
||||||
properties:
|
properties:
|
||||||
prop grid: BrightnessGrid { get mut; set move; };
|
prop grid: BrightnessGrid { get mut; set move; };
|
||||||
functions:
|
functions:
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
use crate::commands::wrap_command;
|
|
||||||
use servicepoint::{ClearCommand, FadeOutCommand, HardResetCommand};
|
use servicepoint::{ClearCommand, FadeOutCommand, HardResetCommand};
|
||||||
|
|
||||||
macro_rules! wrap_cc_only {
|
macro_rules! wrap_cc_only {
|
||||||
($(#[$meta:meta])* $command:ident) => {
|
($(#[$meta:meta])* $command:ident) => {
|
||||||
::paste::paste!{
|
::paste::paste!{
|
||||||
wrap_command!($command);
|
|
||||||
|
|
||||||
$crate::macros::wrap!{
|
$crate::macros::wrap!{
|
||||||
[< $command Command >] {
|
[< $command Command >] {
|
||||||
|
derives: $crate::commands::derive_command[$command];
|
||||||
functions:
|
functions:
|
||||||
$(#[$meta])*
|
$(#[$meta])*
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
use crate::{
|
use crate::macros::wrap;
|
||||||
commands::{wrap_command, wrap_origin_accessors},
|
|
||||||
macros::wrap,
|
|
||||||
};
|
|
||||||
use servicepoint::{CharGrid, CharGridCommand, Origin};
|
use servicepoint::{CharGrid, CharGridCommand, Origin};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
wrap_command!(CharGrid);
|
|
||||||
wrap_origin_accessors!(CharGridCommand);
|
|
||||||
|
|
||||||
wrap!(
|
wrap!(
|
||||||
CharGridCommand {
|
CharGridCommand {
|
||||||
|
derives: crate::commands::derive_command[CharGrid], crate::commands::derive_origin_accessors;
|
||||||
properties:
|
properties:
|
||||||
prop grid: CharGrid { get mut; set move; };
|
prop grid: CharGrid { get mut; set move; };
|
||||||
functions:
|
functions:
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
use crate::{
|
use crate::macros::wrap;
|
||||||
commands::{wrap_command, wrap_origin_accessors},
|
|
||||||
macros::wrap,
|
|
||||||
};
|
|
||||||
use servicepoint::{Cp437Grid, Cp437GridCommand, Origin};
|
use servicepoint::{Cp437Grid, Cp437GridCommand, Origin};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
wrap_command!(Cp437Grid);
|
|
||||||
wrap_origin_accessors!(Cp437GridCommand);
|
|
||||||
|
|
||||||
wrap!(
|
wrap!(
|
||||||
Cp437GridCommand {
|
Cp437GridCommand {
|
||||||
|
derives: crate::commands::derive_command[Cp437Grid], crate::commands::derive_origin_accessors;
|
||||||
properties:
|
properties:
|
||||||
prop grid: Cp437Grid { get mut; set move; };
|
prop grid: Cp437Grid { get mut; set move; };
|
||||||
functions:
|
functions:
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
use crate::{commands::wrap_command, macros::wrap};
|
use crate::macros::wrap;
|
||||||
use servicepoint::{Brightness, GlobalBrightnessCommand};
|
use servicepoint::{Brightness, GlobalBrightnessCommand};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
wrap_command!(GlobalBrightness);
|
|
||||||
|
|
||||||
wrap!(
|
wrap!(
|
||||||
GlobalBrightnessCommand {
|
GlobalBrightnessCommand {
|
||||||
|
derives: crate::commands::derive_command[GlobalBrightness];
|
||||||
properties:
|
properties:
|
||||||
prop brightness: Brightness { get; set; };
|
prop brightness: Brightness { get; set; };
|
||||||
functions:
|
functions:
|
||||||
|
|
|
@ -14,8 +14,8 @@ pub use char_grid_command::*;
|
||||||
pub use cp437_grid_command::*;
|
pub use cp437_grid_command::*;
|
||||||
pub use generic_command::*;
|
pub use generic_command::*;
|
||||||
|
|
||||||
macro_rules! wrap_origin_accessors {
|
macro_rules! derive_origin_accessors {
|
||||||
( $object_type:ident ) => {
|
($object_type:ident) => {
|
||||||
::paste::paste! {
|
::paste::paste! {
|
||||||
$crate::macros::wrap_methods!($object_type;
|
$crate::macros::wrap_methods!($object_type;
|
||||||
#[doc = " Reads the origin field of the [`" $object_type "`]."]
|
#[doc = " Reads the origin field of the [`" $object_type "`]."]
|
||||||
|
@ -70,21 +70,16 @@ macro_rules! derive_command_into_packet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! wrap_command {
|
macro_rules! derive_command {
|
||||||
($command:ident, $object_type:ident) => {
|
($object_type:ident, $command:ident) => {
|
||||||
$crate::macros::derive_clone!($object_type);
|
$crate::macros::derive_clone!($object_type);
|
||||||
$crate::macros::derive_free!($object_type);
|
$crate::macros::derive_free!($object_type);
|
||||||
$crate::commands::derive_command_from!($command);
|
$crate::commands::derive_command_from!($command);
|
||||||
$crate::commands::derive_command_into_packet!($object_type);
|
$crate::commands::derive_command_into_packet!($object_type);
|
||||||
};
|
};
|
||||||
($command:ident) => {
|
|
||||||
::paste::paste! {
|
|
||||||
$crate::commands::wrap_command!($command, [< $command Command >]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) use {
|
pub(crate) use {
|
||||||
derive_command_from, derive_command_into_packet, wrap_command,
|
derive_command, derive_command_from, derive_command_into_packet,
|
||||||
wrap_origin_accessors,
|
derive_origin_accessors,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
use crate::{
|
use crate::{containers::ByteSlice, macros::wrap};
|
||||||
containers::{wrap_grid, ByteSlice},
|
|
||||||
macros::wrap,
|
|
||||||
};
|
|
||||||
use servicepoint::{
|
use servicepoint::{
|
||||||
Bitmap, BitmapCommand, CompressionCode, DataRef, DisplayBitVec, Grid,
|
Bitmap, BitmapCommand, CompressionCode, DataRef, DisplayBitVec, Grid,
|
||||||
Origin, Packet,
|
Origin, Packet,
|
||||||
};
|
};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
wrap_grid!(Bitmap, bool);
|
|
||||||
|
|
||||||
wrap! {
|
wrap! {
|
||||||
Bitmap {
|
Bitmap {
|
||||||
|
derives: crate::containers::derive_container, crate::containers::derive_grid[bool];
|
||||||
functions:
|
functions:
|
||||||
/// Creates a new [Bitmap] with the specified dimensions.
|
/// Creates a new [Bitmap] with the specified dimensions.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
use crate::{
|
use crate::{containers::ByteSlice, macros::wrap};
|
||||||
containers::{wrap_container, ByteSlice},
|
|
||||||
macros::wrap,
|
|
||||||
};
|
|
||||||
use servicepoint::{
|
use servicepoint::{
|
||||||
BinaryOperation, BitVecCommand, CompressionCode, DisplayBitVec, Packet,
|
BinaryOperation, BitVecCommand, CompressionCode, DisplayBitVec, Packet,
|
||||||
};
|
};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
wrap_container!(DisplayBitVec);
|
|
||||||
|
|
||||||
wrap! {
|
wrap! {
|
||||||
DisplayBitVec {
|
DisplayBitVec {
|
||||||
|
derives: crate::containers::derive_container;
|
||||||
functions:
|
functions:
|
||||||
/// Creates a new [DisplayBitVec] instance.
|
/// Creates a new [DisplayBitVec] instance.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
use crate::{
|
use crate::{containers::ByteSlice, macros::wrap};
|
||||||
containers::{wrap_grid, ByteSlice},
|
|
||||||
macros::wrap,
|
|
||||||
};
|
|
||||||
use servicepoint::{
|
use servicepoint::{
|
||||||
Brightness, BrightnessGrid, BrightnessGridCommand, ByteGrid, DataRef, Grid,
|
Brightness, BrightnessGrid, BrightnessGridCommand, ByteGrid, DataRef, Grid,
|
||||||
Origin, Packet,
|
Origin, Packet,
|
||||||
};
|
};
|
||||||
use std::{mem::transmute, ptr::NonNull};
|
use std::{mem::transmute, ptr::NonNull};
|
||||||
|
|
||||||
wrap_grid!(BrightnessGrid, Brightness);
|
|
||||||
|
|
||||||
wrap! {
|
wrap! {
|
||||||
BrightnessGrid {
|
BrightnessGrid {
|
||||||
|
derives: crate::containers::derive_container, crate::containers::derive_grid[Brightness];
|
||||||
functions:
|
functions:
|
||||||
/// Creates a new [BrightnessGrid] with the specified dimensions.
|
/// Creates a new [BrightnessGrid] with the specified dimensions.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
use crate::{
|
use crate::{containers::ByteSlice, macros::wrap};
|
||||||
containers::{derive_get_width_height, wrap_container, ByteSlice},
|
|
||||||
macros::wrap,
|
|
||||||
};
|
|
||||||
use servicepoint::{CharGrid, CharGridCommand, Grid, Origin, Packet};
|
use servicepoint::{CharGrid, CharGridCommand, Grid, Origin, Packet};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
wrap_container!(CharGrid);
|
|
||||||
derive_get_width_height!(CharGrid);
|
|
||||||
|
|
||||||
wrap! {
|
wrap! {
|
||||||
CharGrid {
|
CharGrid {
|
||||||
|
derives: crate::containers::derive_container, crate::containers::derive_get_width_height;
|
||||||
functions:
|
functions:
|
||||||
/// Creates a new [CharGrid] with the specified dimensions.
|
/// Creates a new [CharGrid] with the specified dimensions.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
use crate::{
|
use crate::{containers::ByteSlice, macros::wrap};
|
||||||
containers::{wrap_grid, ByteSlice},
|
|
||||||
macros::wrap,
|
|
||||||
};
|
|
||||||
use servicepoint::{
|
use servicepoint::{
|
||||||
Cp437Grid, Cp437GridCommand, DataRef, Grid, Origin, Packet,
|
Cp437Grid, Cp437GridCommand, DataRef, Grid, Origin, Packet,
|
||||||
};
|
};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
wrap_grid!(Cp437Grid, u8);
|
|
||||||
|
|
||||||
wrap! {
|
wrap! {
|
||||||
Cp437Grid {
|
Cp437Grid {
|
||||||
|
derives: crate::containers::derive_container, crate::containers::derive_grid[u8];
|
||||||
functions:
|
functions:
|
||||||
/// Creates a new [Cp437Grid] with the specified dimensions.
|
/// Creates a new [Cp437Grid] with the specified dimensions.
|
||||||
///
|
///
|
||||||
|
|
|
@ -12,7 +12,7 @@ pub use byte_slice::*;
|
||||||
pub use char_grid::*;
|
pub use char_grid::*;
|
||||||
pub use cp437_grid::*;
|
pub use cp437_grid::*;
|
||||||
|
|
||||||
macro_rules! wrap_container {
|
macro_rules! derive_container {
|
||||||
($object_type:ident) => {
|
($object_type:ident) => {
|
||||||
$crate::macros::derive_clone!($object_type);
|
$crate::macros::derive_clone!($object_type);
|
||||||
$crate::macros::derive_free!($object_type);
|
$crate::macros::derive_free!($object_type);
|
||||||
|
@ -31,9 +31,8 @@ macro_rules! derive_get_width_height {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! wrap_grid {
|
macro_rules! derive_grid {
|
||||||
($object_type:ident, $value_type:ident) => {
|
($object_type:ident, $value_type:ident) => {
|
||||||
$crate::containers::wrap_container!($object_type);
|
|
||||||
$crate::containers::derive_get_width_height!($object_type);
|
$crate::containers::derive_get_width_height!($object_type);
|
||||||
$crate::macros::wrap_methods! {$object_type;
|
$crate::macros::wrap_methods! {$object_type;
|
||||||
/// Gets the current value at the specified position.
|
/// Gets the current value at the specified position.
|
||||||
|
@ -69,7 +68,7 @@ macro_rules! wrap_grid {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) use {derive_get_width_height, wrap_container, wrap_grid};
|
pub(crate) use {derive_container, derive_get_width_height, derive_grid};
|
||||||
|
|
||||||
mod _hidden {
|
mod _hidden {
|
||||||
/// This is a type only used by cbindgen to have a type for pointers.
|
/// This is a type only used by cbindgen to have a type for pointers.
|
||||||
|
|
|
@ -266,6 +266,12 @@ macro_rules! wrap_functions {
|
||||||
macro_rules! wrap {
|
macro_rules! wrap {
|
||||||
(
|
(
|
||||||
$object_type:ident {
|
$object_type:ident {
|
||||||
|
$(
|
||||||
|
derives:
|
||||||
|
$(
|
||||||
|
$derive:path $( [ $( $derive_arg:ident ),+ ] )?
|
||||||
|
),+;
|
||||||
|
)?
|
||||||
$(
|
$(
|
||||||
properties:
|
properties:
|
||||||
$(
|
$(
|
||||||
|
@ -292,6 +298,9 @@ macro_rules! wrap {
|
||||||
)?
|
)?
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
|
$($(
|
||||||
|
$derive!($object_type $(, $($derive_arg),+)?);
|
||||||
|
)+)?
|
||||||
$($(
|
$($(
|
||||||
$crate::macros::wrap_fields!($object_type;
|
$crate::macros::wrap_fields!($object_type;
|
||||||
prop $prop_name : $prop_type { $($accessor $($modifier)?;)+ };
|
prop $prop_name : $prop_type { $($accessor $($modifier)?;)+ };
|
||||||
|
|
Loading…
Reference in a new issue