servicepoint_binding_c 0.15.0

C bindings for the servicepoint crate.
Documentation
mod bitmap_command;
mod bitvec_command;
mod brightness_grid_command;
mod cc_only_commands;
mod char_grid_command;
mod cp437_grid_command;
mod generic_command;
mod global_brightness_command;

pub use bitmap_command::*;
pub use bitvec_command::*;
pub use brightness_grid_command::*;
pub use char_grid_command::*;
pub use cp437_grid_command::*;
pub use generic_command::*;

macro_rules! derive_origin_accessors {
    ($object_type:ident) => {
        ::paste::paste! {
            $crate::macros::wrap_methods!($object_type;
                #[doc = " Reads the origin field of the [`" $object_type "`]."]
                fn get_origin(
                    ref command,
                    origin_x: mut ::core::ptr::NonNull<usize>,
                    origin_y: mut ::core::ptr::NonNull<usize>
                ) {
                    let origin = command.origin;
                    *origin_x = origin.x;
                    *origin_y = origin.y;
                };

                #[doc = " Overwrites the origin field of the [`" $object_type "`]."]
                fn set_origin(mut command, origin_x: val usize, origin_y: val usize) {
                    command.origin = ::servicepoint::Origin::new(origin_x, origin_y);
                };
            );
        }
    };
}

macro_rules! derive_command_from {
    ($command:ident) => {
        ::paste::paste! {
            impl From<::servicepoint::[< $command Command >]> for $crate::commands::GenericCommand {
                fn from(command: ::servicepoint::[< $command Command >]) -> Self {
                    Self {
                        tag: $crate::commands::CommandTag::$command,
                        data: $crate::commands::CommandUnion {
                            [< $command:snake >]: $crate::mem::heap_move_nonnull(command)
                        },
                    }
                }
            }
        }
    };
}

macro_rules! derive_command_into_packet {
    ($command_type:ident) => {
        ::paste::paste! {
            $crate::macros::wrap_method!($command_type;
                #[doc = "Tries to turn a [`" $command_type "`] into a [Packet]."]
                ///
                /// Returns: NULL or a [Packet] containing the command.
                ///
                /// [Packet]: [`servicepoint::Packet`]
                fn try_into_packet(move instance) -> move_ok *mut ::servicepoint::Packet {
                    instance.try_into()
                };
            );
        }
    }
}

macro_rules! derive_command {
    ($object_type:ident, $command: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);
    };
}

pub(crate) use {
    derive_command, derive_command_from, derive_command_into_packet,
    derive_origin_accessors,
};