Compare commits

..

No commits in common. "4893c783afa02e01cb48bc156803f1a168ea89b2" and "c65b735f5743f31a30e92f062062ec3c9e861c02" have entirely different histories.

16 changed files with 84 additions and 42 deletions

View file

@ -3,4 +3,4 @@ set -e
SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
cbindgen --config $SCRIPT_PATH/cbindgen.toml --crate servicepoint_binding_c --output $SCRIPT_PATH/include/servicepoint.h --clean
cbindgen --config $SCRIPT_PATH/cbindgen.toml --crate servicepoint_binding_c --output $SCRIPT_PATH/include/servicepoint.h

View file

@ -1,10 +1,15 @@
use crate::macros::wrap;
use crate::{
commands::{wrap_command, wrap_origin_accessors},
macros::wrap,
};
use servicepoint::{Bitmap, BitmapCommand, CompressionCode, Origin};
use std::ptr::NonNull;
wrap_command!(Bitmap);
wrap_origin_accessors!(BitmapCommand);
wrap! {
BitmapCommand {
derives: crate::commands::derive_command[Bitmap], crate::commands::derive_origin_accessors;
properties:
prop bitmap: Bitmap { get mut; set move; };
prop compression: CompressionCode { get; set; };

View file

@ -1,12 +1,13 @@
use crate::macros::wrap;
use crate::{commands::wrap_command, macros::wrap};
use servicepoint::{
BinaryOperation, BitVecCommand, CompressionCode, DisplayBitVec, Offset,
};
use std::ptr::NonNull;
wrap_command!(BitVec);
wrap!(
BitVecCommand {
derives: crate::commands::derive_command[BitVec];
properties:
prop bitvec: DisplayBitVec { get mut; set move; };
prop offset: Offset { get; set; };

View file

@ -1,10 +1,15 @@
use crate::macros::wrap;
use crate::{
commands::{wrap_command, wrap_origin_accessors},
macros::wrap,
};
use servicepoint::{BrightnessGrid, BrightnessGridCommand, Origin};
use std::ptr::NonNull;
wrap_command!(BrightnessGrid);
wrap_origin_accessors!(BrightnessGridCommand);
wrap!(
BrightnessGridCommand {
derives: crate::commands::derive_command[BrightnessGrid], crate::commands::derive_origin_accessors;
properties:
prop grid: BrightnessGrid { get mut; set move; };
functions:

View file

@ -1,11 +1,13 @@
use crate::commands::wrap_command;
use servicepoint::{ClearCommand, FadeOutCommand, HardResetCommand};
macro_rules! wrap_cc_only {
($(#[$meta:meta])* $command:ident) => {
::paste::paste!{
wrap_command!($command);
$crate::macros::wrap!{
[< $command Command >] {
derives: $crate::commands::derive_command[$command];
functions:
$(#[$meta])*
///

View file

@ -1,10 +1,15 @@
use crate::macros::wrap;
use crate::{
commands::{wrap_command, wrap_origin_accessors},
macros::wrap,
};
use servicepoint::{CharGrid, CharGridCommand, Origin};
use std::ptr::NonNull;
wrap_command!(CharGrid);
wrap_origin_accessors!(CharGridCommand);
wrap!(
CharGridCommand {
derives: crate::commands::derive_command[CharGrid], crate::commands::derive_origin_accessors;
properties:
prop grid: CharGrid { get mut; set move; };
functions:

View file

@ -1,10 +1,15 @@
use crate::macros::wrap;
use crate::{
commands::{wrap_command, wrap_origin_accessors},
macros::wrap,
};
use servicepoint::{Cp437Grid, Cp437GridCommand, Origin};
use std::ptr::NonNull;
wrap_command!(Cp437Grid);
wrap_origin_accessors!(Cp437GridCommand);
wrap!(
Cp437GridCommand {
derives: crate::commands::derive_command[Cp437Grid], crate::commands::derive_origin_accessors;
properties:
prop grid: Cp437Grid { get mut; set move; };
functions:

View file

@ -1,10 +1,11 @@
use crate::macros::wrap;
use crate::{commands::wrap_command, macros::wrap};
use servicepoint::{Brightness, GlobalBrightnessCommand};
use std::ptr::NonNull;
wrap_command!(GlobalBrightness);
wrap!(
GlobalBrightnessCommand {
derives: crate::commands::derive_command[GlobalBrightness];
properties:
prop brightness: Brightness { get; set; };
functions:

View file

@ -14,8 +14,8 @@ pub use char_grid_command::*;
pub use cp437_grid_command::*;
pub use generic_command::*;
macro_rules! derive_origin_accessors {
($object_type:ident) => {
macro_rules! wrap_origin_accessors {
( $object_type:ident ) => {
::paste::paste! {
$crate::macros::wrap_methods!($object_type;
#[doc = " Reads the origin field of the [`" $object_type "`]."]
@ -70,16 +70,21 @@ macro_rules! derive_command_into_packet {
}
}
macro_rules! derive_command {
($object_type:ident, $command:ident) => {
macro_rules! wrap_command {
($command:ident, $object_type:ident) => {
$crate::macros::derive_clone!($object_type);
$crate::macros::derive_free!($object_type);
$crate::commands::derive_command_from!($command);
$crate::commands::derive_command_into_packet!($object_type);
};
($command:ident) => {
::paste::paste! {
$crate::commands::wrap_command!($command, [< $command Command >]);
}
};
}
pub(crate) use {
derive_command, derive_command_from, derive_command_into_packet,
derive_origin_accessors,
derive_command_from, derive_command_into_packet, wrap_command,
wrap_origin_accessors,
};

View file

@ -1,13 +1,17 @@
use crate::{containers::ByteSlice, macros::wrap};
use crate::{
containers::{wrap_grid, ByteSlice},
macros::wrap,
};
use servicepoint::{
Bitmap, BitmapCommand, CompressionCode, DataRef, DisplayBitVec, Grid,
Origin, Packet,
};
use std::ptr::NonNull;
wrap_grid!(Bitmap, bool);
wrap! {
Bitmap {
derives: crate::containers::derive_container, crate::containers::derive_grid[bool];
functions:
/// Creates a new [Bitmap] with the specified dimensions.
///

View file

@ -1,12 +1,16 @@
use crate::{containers::ByteSlice, macros::wrap};
use crate::{
containers::{wrap_container, ByteSlice},
macros::wrap,
};
use servicepoint::{
BinaryOperation, BitVecCommand, CompressionCode, DisplayBitVec, Packet,
};
use std::ptr::NonNull;
wrap_container!(DisplayBitVec);
wrap! {
DisplayBitVec {
derives: crate::containers::derive_container;
functions:
/// Creates a new [DisplayBitVec] instance.
///

View file

@ -1,13 +1,17 @@
use crate::{containers::ByteSlice, macros::wrap};
use crate::{
containers::{wrap_grid, ByteSlice},
macros::wrap,
};
use servicepoint::{
Brightness, BrightnessGrid, BrightnessGridCommand, ByteGrid, DataRef, Grid,
Origin, Packet,
};
use std::{mem::transmute, ptr::NonNull};
wrap_grid!(BrightnessGrid, Brightness);
wrap! {
BrightnessGrid {
derives: crate::containers::derive_container, crate::containers::derive_grid[Brightness];
functions:
/// Creates a new [BrightnessGrid] with the specified dimensions.
///

View file

@ -1,10 +1,15 @@
use crate::{containers::ByteSlice, macros::wrap};
use crate::{
containers::{derive_get_width_height, wrap_container, ByteSlice},
macros::wrap,
};
use servicepoint::{CharGrid, CharGridCommand, Grid, Origin, Packet};
use std::ptr::NonNull;
wrap_container!(CharGrid);
derive_get_width_height!(CharGrid);
wrap! {
CharGrid {
derives: crate::containers::derive_container, crate::containers::derive_get_width_height;
functions:
/// Creates a new [CharGrid] with the specified dimensions.
///

View file

@ -1,12 +1,16 @@
use crate::{containers::ByteSlice, macros::wrap};
use crate::{
containers::{wrap_grid, ByteSlice},
macros::wrap,
};
use servicepoint::{
Cp437Grid, Cp437GridCommand, DataRef, Grid, Origin, Packet,
};
use std::ptr::NonNull;
wrap_grid!(Cp437Grid, u8);
wrap! {
Cp437Grid {
derives: crate::containers::derive_container, crate::containers::derive_grid[u8];
functions:
/// Creates a new [Cp437Grid] with the specified dimensions.
///

View file

@ -12,7 +12,7 @@ pub use byte_slice::*;
pub use char_grid::*;
pub use cp437_grid::*;
macro_rules! derive_container {
macro_rules! wrap_container {
($object_type:ident) => {
$crate::macros::derive_clone!($object_type);
$crate::macros::derive_free!($object_type);
@ -31,8 +31,9 @@ macro_rules! derive_get_width_height {
};
}
macro_rules! derive_grid {
macro_rules! wrap_grid {
($object_type:ident, $value_type:ident) => {
$crate::containers::wrap_container!($object_type);
$crate::containers::derive_get_width_height!($object_type);
$crate::macros::wrap_methods! {$object_type;
/// Gets the current value at the specified position.
@ -68,7 +69,7 @@ macro_rules! derive_grid {
};
}
pub(crate) use {derive_container, derive_get_width_height, derive_grid};
pub(crate) use {derive_get_width_height, wrap_container, wrap_grid};
mod _hidden {
/// This is a type only used by cbindgen to have a type for pointers.

View file

@ -266,12 +266,6 @@ macro_rules! wrap_functions {
macro_rules! wrap {
(
$object_type:ident {
$(
derives:
$(
$derive:path $( [ $( $derive_arg:ident ),+ ] )?
),+;
)?
$(
properties:
$(
@ -298,9 +292,6 @@ macro_rules! wrap {
)?
}
) => {
$($(
$derive!($object_type $(, $($derive_arg),+)?);
)+)?
$($(
$crate::macros::wrap_fields!($object_type;
prop $prop_name : $prop_type { $($accessor $($modifier)?;)+ };