multiple methods in one macro invocation
This commit is contained in:
parent
7d52ccf638
commit
35e9c36ccd
6 changed files with 48 additions and 111 deletions
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
containers::ByteSlice,
|
||||
macros::{wrap_clone, wrap_free, wrap_method},
|
||||
macros::{wrap_clone, wrap_free, wrap_methods},
|
||||
mem::{heap_move_nonnull, heap_move_ok, heap_move_some, heap_remove},
|
||||
};
|
||||
use servicepoint::{
|
||||
|
@ -83,8 +83,9 @@ pub unsafe extern "C" fn sp_bitmap_from_bitvec(
|
|||
wrap_clone!(sp_bitmap::Bitmap);
|
||||
wrap_free!(sp_bitmap::Bitmap);
|
||||
|
||||
wrap_method!(
|
||||
wrap_methods!(
|
||||
sp_bitmap::Bitmap;
|
||||
|
||||
/// Gets the current value at the specified position.
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -95,10 +96,7 @@ wrap_method!(
|
|||
///
|
||||
/// - when accessing `x` or `y` out of bounds
|
||||
ref fn get(x: usize, y: usize) -> bool;
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_bitmap::Bitmap;
|
||||
|
||||
/// Sets the value of the specified position.
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -110,32 +108,20 @@ wrap_method!(
|
|||
///
|
||||
/// - when accessing `x` or `y` out of bounds
|
||||
mut fn set(x: usize, y: usize, value: bool);
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_bitmap::Bitmap;
|
||||
|
||||
/// Sets the state of all pixels in the [Bitmap].
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// - `value`: the value to set all pixels to
|
||||
mut fn fill(value: bool);
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_bitmap::Bitmap;
|
||||
|
||||
/// Gets the width in pixels.
|
||||
ref fn width() -> usize;
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_bitmap::Bitmap;
|
||||
|
||||
/// Gets the height in pixels.
|
||||
ref fn height() -> usize;
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_bitmap::Bitmap;
|
||||
|
||||
/// Gets an unsafe reference to the data of the [Bitmap] instance.
|
||||
///
|
||||
/// The returned memory is valid for the lifetime of the bitmap.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
containers::ByteSlice,
|
||||
macros::{wrap_clone, wrap_free, wrap_method},
|
||||
macros::{wrap_clone, wrap_free, wrap_methods},
|
||||
mem::{heap_move_nonnull, heap_move_ok, heap_remove},
|
||||
};
|
||||
use servicepoint::{
|
||||
|
@ -38,8 +38,9 @@ pub unsafe extern "C" fn sp_bitvec_load(
|
|||
wrap_clone!(sp_bitvec::DisplayBitVec);
|
||||
wrap_free!(sp_bitvec::DisplayBitVec);
|
||||
|
||||
wrap_method!(
|
||||
wrap_methods!(
|
||||
sp_bitvec::DisplayBitVec;
|
||||
|
||||
/// Gets the value of a bit.
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -54,10 +55,7 @@ wrap_method!(
|
|||
/// - when accessing `index` out of bounds
|
||||
ref fn get(index: usize) -> bool;
|
||||
|result| result.map(|x| *x).unwrap_or(false);
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_bitvec::DisplayBitVec;
|
||||
|
||||
/// Sets the value of a bit.
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -69,32 +67,20 @@ wrap_method!(
|
|||
///
|
||||
/// - when accessing `index` out of bounds
|
||||
mut fn set(index: usize, value: bool);
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_bitvec::DisplayBitVec;
|
||||
|
||||
/// Sets the value of all bits.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// - `value`: the value to set all bits to
|
||||
mut fn fill(value: bool);
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_bitvec::DisplayBitVec;
|
||||
|
||||
/// Gets the length in bits.
|
||||
ref fn len() -> usize;
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_bitvec::DisplayBitVec;
|
||||
|
||||
/// Returns true if length is 0.
|
||||
ref fn is_empty() -> bool;
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_bitvec::DisplayBitVec;
|
||||
|
||||
/// Gets an unsafe reference to the data of the [DisplayBitVec] instance.
|
||||
///
|
||||
/// The returned memory is valid for the lifetime of the bitvec.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
containers::ByteSlice,
|
||||
macros::{wrap_clone, wrap_free, wrap_method},
|
||||
macros::{wrap_clone, wrap_free, wrap_methods},
|
||||
mem::{heap_move_nonnull, heap_move_ok, heap_move_some, heap_remove},
|
||||
};
|
||||
use servicepoint::{
|
||||
|
@ -55,8 +55,9 @@ pub unsafe extern "C" fn sp_brightness_grid_load(
|
|||
wrap_clone!(sp_brightness_grid::BrightnessGrid);
|
||||
wrap_free!(sp_brightness_grid::BrightnessGrid);
|
||||
|
||||
wrap_method!(
|
||||
wrap_methods!(
|
||||
sp_brightness_grid::BrightnessGrid;
|
||||
|
||||
/// Gets the current value at the specified position.
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -68,10 +69,7 @@ wrap_method!(
|
|||
/// # Panics
|
||||
/// - When accessing `x` or `y` out of bounds.
|
||||
ref fn get(x: usize, y: usize) -> Brightness;
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_brightness_grid::BrightnessGrid;
|
||||
|
||||
/// Sets the value of the specified position.
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -85,32 +83,20 @@ wrap_method!(
|
|||
///
|
||||
/// - When accessing `x` or `y` out of bounds.
|
||||
mut fn set(x: usize, y: usize, value: Brightness);
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_brightness_grid::BrightnessGrid;
|
||||
|
||||
/// Sets the value of all cells.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// - `value`: the value to set all cells to
|
||||
mut fn fill(value: Brightness);
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_brightness_grid::BrightnessGrid;
|
||||
|
||||
/// Gets the width of the grid.
|
||||
ref fn width() -> usize;
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_brightness_grid::BrightnessGrid;
|
||||
|
||||
/// Gets the height of the grid.
|
||||
ref fn height() -> usize;
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_brightness_grid::BrightnessGrid;
|
||||
|
||||
/// Gets an unsafe reference to the data of the instance.
|
||||
///
|
||||
/// The returned memory is valid for the lifetime of the grid.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
containers::ByteSlice,
|
||||
macros::{wrap_clone, wrap_free, wrap_method},
|
||||
macros::{wrap_clone, wrap_free, wrap_methods},
|
||||
mem::{heap_move_nonnull, heap_move_ok, heap_remove},
|
||||
};
|
||||
use servicepoint::{CharGrid, CharGridCommand, Grid, Origin, Packet};
|
||||
|
@ -42,8 +42,9 @@ pub unsafe extern "C" fn sp_char_grid_load(
|
|||
wrap_clone!(sp_char_grid::CharGrid);
|
||||
wrap_free!(sp_char_grid::CharGrid);
|
||||
|
||||
wrap_method!(
|
||||
wrap_methods!(
|
||||
sp_char_grid::CharGrid;
|
||||
|
||||
/// Returns the current value at the specified position.
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -54,11 +55,8 @@ wrap_method!(
|
|||
///
|
||||
/// - when accessing `x` or `y` out of bounds
|
||||
ref fn get(x: usize, y: usize) -> u32;
|
||||
| char | char as u32
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_char_grid::CharGrid;
|
||||
| char | char as u32;
|
||||
|
||||
/// Sets the value of the specified position in the grid.
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -74,10 +72,7 @@ wrap_method!(
|
|||
/// - when providing values that cannot be converted to Rust's `char`.
|
||||
mut fn set(x: usize, y: usize, value: u32);
|
||||
let value = char::from_u32(value).unwrap();
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_char_grid::CharGrid;
|
||||
|
||||
/// Sets the value of all cells in the grid.
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -86,16 +81,10 @@ wrap_method!(
|
|||
/// - when providing values that cannot be converted to Rust's `char`.
|
||||
mut fn fill(value: u32);
|
||||
let value = char::from_u32(value).unwrap();
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_char_grid::CharGrid;
|
||||
|
||||
/// Gets the width of the grid.
|
||||
ref fn width() -> usize;
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_char_grid::CharGrid;
|
||||
|
||||
/// Gets the height of the grid.
|
||||
ref fn height() -> usize;
|
||||
);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
containers::ByteSlice,
|
||||
macros::{wrap_clone, wrap_free, wrap_method},
|
||||
macros::{wrap_clone, wrap_free, wrap_methods},
|
||||
mem::{heap_move_nonnull, heap_move_ok, heap_move_some, heap_remove},
|
||||
};
|
||||
use servicepoint::{
|
||||
|
@ -33,7 +33,7 @@ pub unsafe extern "C" fn sp_cp437_grid_load(
|
|||
wrap_clone!(sp_cp437_grid::Cp437Grid);
|
||||
wrap_free!(sp_cp437_grid::Cp437Grid);
|
||||
|
||||
wrap_method!(
|
||||
wrap_methods!(
|
||||
sp_cp437_grid::Cp437Grid;
|
||||
/// Gets the current value at the specified position.
|
||||
///
|
||||
|
@ -45,10 +45,7 @@ wrap_method!(
|
|||
///
|
||||
/// - when accessing `x` or `y` out of bounds
|
||||
ref fn get(x: usize, y: usize) -> u8;
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_cp437_grid::Cp437Grid;
|
||||
/// Sets the value at the specified position.
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -62,10 +59,7 @@ wrap_method!(
|
|||
///
|
||||
/// - when accessing `x` or `y` out of bounds
|
||||
mut fn set(x: usize, y: usize, value: u8);
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_cp437_grid::Cp437Grid;
|
||||
/// Sets the value of all cells in the grid.
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -73,22 +67,13 @@ wrap_method!(
|
|||
/// - `cp437_grid`: instance to write to
|
||||
/// - `value`: the value to set all cells to
|
||||
mut fn fill(value: u8);
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_cp437_grid::Cp437Grid;
|
||||
/// Gets the width of the grid.
|
||||
ref fn width() -> usize;
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_cp437_grid::Cp437Grid;
|
||||
/// Gets the height of the grid.
|
||||
ref fn height() -> usize;
|
||||
);
|
||||
|
||||
wrap_method!(
|
||||
sp_cp437_grid::Cp437Grid;
|
||||
|
||||
/// Gets an unsafe reference to the data of the grid.
|
||||
///
|
||||
/// The returned memory is valid for the lifetime of the instance.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue