rename function to ...try to indicate possible null return
This commit is contained in:
parent
b4730ffdf3
commit
7a836783e1
9 changed files with 82 additions and 83 deletions
|
@ -2,7 +2,6 @@ use crate::{
|
|||
commands::wrap_command, macros::wrap_functions, mem::heap_move_nonnull,
|
||||
};
|
||||
use servicepoint::{ClearCommand, FadeOutCommand, HardResetCommand};
|
||||
use std::ptr::NonNull;
|
||||
|
||||
macro_rules! wrap_cc_only {
|
||||
($(#[$meta:meta])* $command:ident) => {
|
||||
|
@ -13,7 +12,7 @@ macro_rules! wrap_cc_only {
|
|||
$(#[$meta])*
|
||||
///
|
||||
#[doc = " Returns: a new [`" [< $command Command >] "`] instance."]
|
||||
fn new() -> NonNull<[< $command Command >]> {
|
||||
fn new() -> ::core::ptr::NonNull<[< $command Command >]> {
|
||||
heap_move_nonnull([< $command Command >])
|
||||
}
|
||||
);
|
||||
|
|
|
@ -20,9 +20,9 @@ macro_rules! wrap_origin_accessors {
|
|||
$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>,
|
||||
command: ::core::ptr::NonNull<$object_type>,
|
||||
origin_x: ::core::ptr::NonNull<usize>,
|
||||
origin_y: ::core::ptr::NonNull<usize>,
|
||||
) {
|
||||
unsafe {
|
||||
let origin = &command.as_ref().origin;
|
||||
|
@ -33,7 +33,7 @@ macro_rules! wrap_origin_accessors {
|
|||
|
||||
#[doc = " Overwrites the origin field of the [`" $object_type "`]."]
|
||||
fn set_origin(
|
||||
command: NonNull<$object_type>,
|
||||
command: ::core::ptr::NonNull<$object_type>,
|
||||
origin_x: usize,
|
||||
origin_y: usize,
|
||||
) {
|
||||
|
@ -72,7 +72,7 @@ macro_rules! derive_command_into_packet {
|
|||
///
|
||||
/// Returns: NULL or a [Packet] containing the command.
|
||||
fn try_into_packet(
|
||||
command: NonNull<$command_type>,
|
||||
command: ::core::ptr::NonNull<$command_type>,
|
||||
) -> *mut ::servicepoint::Packet {
|
||||
$crate::mem::heap_move_ok(unsafe { $crate::mem::heap_remove(command) }.try_into())
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ wrap_functions!(bitmap;
|
|||
/// The provided [Bitmap] gets consumed.
|
||||
///
|
||||
/// Returns NULL in case of an error.
|
||||
fn into_packet(
|
||||
fn try_into_packet(
|
||||
bitmap: NonNull<Bitmap>,
|
||||
x: usize,
|
||||
y: usize,
|
||||
|
|
|
@ -40,7 +40,7 @@ wrap_functions!(associate DisplayBitVec;
|
|||
/// The provided [DisplayBitVec] gets consumed.
|
||||
///
|
||||
/// Returns NULL in case of an error.
|
||||
fn into_packet(
|
||||
fn try_into_packet(
|
||||
bitvec: NonNull<DisplayBitVec>,
|
||||
offset: usize,
|
||||
operation: BinaryOperation,
|
||||
|
|
|
@ -59,7 +59,7 @@ wrap_functions!(associate BrightnessGrid;
|
|||
/// The provided [BrightnessGrid] gets consumed.
|
||||
///
|
||||
/// Returns NULL in case of an error.
|
||||
fn into_packet(
|
||||
fn try_into_packet(
|
||||
grid: NonNull<BrightnessGrid>,
|
||||
x: usize,
|
||||
y: usize,
|
||||
|
|
|
@ -47,7 +47,7 @@ wrap_functions!(associate CharGrid;
|
|||
/// The provided [CharGrid] gets consumed.
|
||||
///
|
||||
/// Returns NULL in case of an error.
|
||||
fn into_packet(
|
||||
fn try_into_packet(
|
||||
grid: NonNull<CharGrid>,
|
||||
x: usize,
|
||||
y: usize,
|
||||
|
|
|
@ -37,7 +37,7 @@ wrap_functions!(cp437grid;
|
|||
/// The provided [Cp437Grid] gets consumed.
|
||||
///
|
||||
/// Returns NULL in case of an error.
|
||||
fn into_packet(
|
||||
fn try_into_packet(
|
||||
grid: NonNull<Cp437Grid>,
|
||||
x: usize,
|
||||
y: usize,
|
||||
|
|
|
@ -3,7 +3,7 @@ macro_rules! derive_free {
|
|||
::paste::paste! {
|
||||
$crate::macros::wrap_functions!([< $typ:lower >];
|
||||
#[doc = "Deallocates a [`" $typ "`] instance."]
|
||||
fn free(instance: NonNull<$typ>) {
|
||||
fn free(instance: ::core::ptr::NonNull<$typ>) {
|
||||
unsafe { $crate::mem::heap_drop(instance) }
|
||||
}
|
||||
);
|
||||
|
@ -16,7 +16,7 @@ macro_rules! derive_clone {
|
|||
::paste::paste! {
|
||||
$crate::macros::wrap_functions!([< $typ:lower >];
|
||||
#[doc = "Clones a [`" $typ "`] instance."]
|
||||
fn clone(instance: NonNull<$typ>) -> NonNull<$typ> {
|
||||
fn clone(instance: ::core::ptr::NonNull<$typ>) -> ::core::ptr::NonNull<$typ> {
|
||||
unsafe { $crate::mem::heap_clone(instance) }
|
||||
}
|
||||
);
|
||||
|
@ -58,7 +58,7 @@ macro_rules! wrap_methods {
|
|||
#[doc = ""]
|
||||
$(#[$meta])*
|
||||
fn $function(
|
||||
instance: NonNull<$object_type>,
|
||||
instance: ::core::ptr::NonNull<$object_type>,
|
||||
$($param_name: $param_type),*
|
||||
) $(-> $return_type)? {
|
||||
let instance = unsafe { $crate::macros:: [< nonnull_as_ $ref_or_mut >] !(instance) };
|
||||
|
@ -192,7 +192,7 @@ macro_rules! wrap_fields {
|
|||
)*)?
|
||||
fn [<set _ $prop_name>](
|
||||
instance: ::core::ptr::NonNull<$object_type>,
|
||||
value: NonNull<$prop_type>,
|
||||
value: ::core::ptr::NonNull<$prop_type>,
|
||||
) {
|
||||
let instance = unsafe { $crate::macros::nonnull_as_mut!(instance) };
|
||||
let value = unsafe { $crate::mem::heap_remove(value) };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue