wrap normal methods with macro
Some checks failed
Rust / build-gnu-apt (pull_request) Failing after 1m31s
Rust / build-size-gnu-unstable (pull_request) Failing after 43s

This commit is contained in:
Vinzenz Schroeter 2025-06-17 21:12:24 +02:00
parent f524038625
commit 9756ef39b7
7 changed files with 477 additions and 591 deletions

View file

@ -645,14 +645,24 @@ void init_env_logger(void);
struct Bitmap */*notnull*/ sp_bitmap_clone(struct Bitmap */*notnull*/ instance);
/**
* Calls [`servicepoint::Bitmap::data_ref_mut`].
*
* Gets an unsafe reference to the data of the [Bitmap] instance.
*
* The returned memory is valid for the lifetime of the bitmap.
*/
struct ByteSlice sp_bitmap_data_ref_mut(struct Bitmap */*notnull*/ instance);
/**
* Calls [`servicepoint::Bitmap::fill`].
*
* Sets the state of all pixels in the [Bitmap].
*
* # Arguments
*
* - `bitmap`: instance to write to
* - `value`: the value to set all pixels to
*/
void sp_bitmap_fill(struct Bitmap */*notnull*/ bitmap, bool value);
void sp_bitmap_fill(struct Bitmap */*notnull*/ instance, bool value);
/**
*Deallocates a [Bitmap] instance.
@ -669,30 +679,29 @@ void sp_bitmap_free(struct Bitmap */*notnull*/ instance);
struct Bitmap *sp_bitmap_from_bitvec(size_t width, BitVec */*notnull*/ bitvec);
/**
* Gets the current value at the specified position in the [Bitmap].
* Calls [`servicepoint::Bitmap::get`].
*
* Gets the current value at the specified position.
*
* # Arguments
*
* - `bitmap`: instance to read from
* - `x` and `y`: position of the cell to read
*
* # Panics
*
* - when accessing `x` or `y` out of bounds
*/
bool sp_bitmap_get(struct Bitmap */*notnull*/ bitmap, size_t x, size_t y);
bool sp_bitmap_get(struct Bitmap */*notnull*/ instance, size_t x, size_t y);
/**
* Gets the height in pixels of the [Bitmap] instance.
* Calls [`servicepoint::Bitmap::height`].
*
* # Arguments
*
* - `bitmap`: instance to read from
* Gets the height in pixels.
*/
size_t sp_bitmap_height(struct Bitmap */*notnull*/ bitmap);
size_t sp_bitmap_height(struct Bitmap */*notnull*/ instance);
/**
* Consumes the Bitmap and returns the contained BitVec
* Consumes the Bitmap and returns the contained BitVec.
*/
BitVec */*notnull*/ sp_bitmap_into_bitvec(struct Bitmap */*notnull*/ bitmap);
@ -757,11 +766,12 @@ struct Bitmap *sp_bitmap_new(size_t width, size_t height);
struct Bitmap */*notnull*/ sp_bitmap_new_max_sized(void);
/**
* Sets the value of the specified position in the [Bitmap].
* Calls [`servicepoint::Bitmap::set`].
*
* Sets the value of the specified position.
*
* # Arguments
*
* - `bitmap`: instance to write to
* - `x` and `y`: position of the cell
* - `value`: the value to write to the cell
*
@ -769,36 +779,26 @@ struct Bitmap */*notnull*/ sp_bitmap_new_max_sized(void);
*
* - when accessing `x` or `y` out of bounds
*/
void sp_bitmap_set(struct Bitmap */*notnull*/ bitmap,
void sp_bitmap_set(struct Bitmap */*notnull*/ instance,
size_t x,
size_t y,
bool value);
/**
* Gets an unsafe reference to the data of the [Bitmap] instance.
* Calls [`servicepoint::Bitmap::width`].
*
* The returned memory is valid for the lifetime of the bitmap.
* Gets the width in pixels.
*/
struct ByteSlice sp_bitmap_unsafe_data_ref(struct Bitmap */*notnull*/ bitmap);
size_t sp_bitmap_width(struct Bitmap */*notnull*/ instance);
/**
* Gets the width in pixels of the [Bitmap] instance.
* Calls [`servicepoint::DisplayBitVec::as_raw_mut_slice`].
*
* # Arguments
* Gets an unsafe reference to the data of the [DisplayBitVec] instance.
*
* - `bitmap`: instance to read from
*
* # Panics
*
* - when `bitmap` is NULL
*
* # Safety
*
* The caller has to make sure that:
*
* - `bitmap` points to a valid [Bitmap]
* The returned memory is valid for the lifetime of the bitvec.
*/
size_t sp_bitmap_width(struct Bitmap */*notnull*/ bitmap);
struct ByteSlice sp_bitvec_as_raw_mut_slice(BitVec */*notnull*/ instance);
/**
*Clones a [DisplayBitVec] instance.
@ -806,14 +806,15 @@ size_t sp_bitmap_width(struct Bitmap */*notnull*/ bitmap);
BitVec */*notnull*/ sp_bitvec_clone(BitVec */*notnull*/ instance);
/**
* Sets the value of all bits in the [DisplayBitVec].
* Calls [`servicepoint::DisplayBitVec::fill`].
*
* Sets the value of all bits.
*
* # Arguments
*
* - `bit_vec`: instance to write to
* - `value`: the value to set all bits to
*/
void sp_bitvec_fill(BitVec */*notnull*/ bit_vec, bool value);
void sp_bitvec_fill(BitVec */*notnull*/ instance, bool value);
/**
*Deallocates a [DisplayBitVec] instance.
@ -821,7 +822,9 @@ void sp_bitvec_fill(BitVec */*notnull*/ bit_vec, bool value);
void sp_bitvec_free(BitVec */*notnull*/ instance);
/**
* Gets the value of a bit from the [DisplayBitVec].
* Calls [`servicepoint::DisplayBitVec::get`].
*
* Gets the value of a bit.
*
* # Arguments
*
@ -834,7 +837,7 @@ void sp_bitvec_free(BitVec */*notnull*/ instance);
*
* - when accessing `index` out of bounds
*/
bool sp_bitvec_get(BitVec */*notnull*/ bit_vec, size_t index);
bool sp_bitvec_get(BitVec */*notnull*/ instance, size_t index);
/**
* Creates a [BitVecCommand] and immediately turns that into a [Packet].
@ -849,22 +852,18 @@ struct Packet *sp_bitvec_into_packet(BitVec */*notnull*/ bitvec,
CompressionCode compression);
/**
* Calls [`servicepoint::DisplayBitVec::is_empty`].
*
* Returns true if length is 0.
*
* # Arguments
*
* - `bit_vec`: instance to write to
*/
bool sp_bitvec_is_empty(BitVec */*notnull*/ bit_vec);
bool sp_bitvec_is_empty(BitVec */*notnull*/ instance);
/**
* Gets the length of the [DisplayBitVec] in bits.
* Calls [`servicepoint::DisplayBitVec::len`].
*
* # Arguments
*
* - `bit_vec`: instance to write to
* Gets the length in bits.
*/
size_t sp_bitvec_len(BitVec */*notnull*/ bit_vec);
size_t sp_bitvec_len(BitVec */*notnull*/ instance);
/**
* Interpret the data as a series of bits and load then into a new [DisplayBitVec] instance.
@ -889,11 +888,12 @@ BitVec */*notnull*/ sp_bitvec_load(struct ByteSlice data);
BitVec */*notnull*/ sp_bitvec_new(size_t size);
/**
* Sets the value of a bit in the [DisplayBitVec].
* Calls [`servicepoint::DisplayBitVec::set`].
*
* Sets the value of a bit.
*
* # Arguments
*
* - `bit_vec`: instance to write to
* - `index`: the bit index to edit
* - `value`: the value to set the bit to
*
@ -901,18 +901,7 @@ BitVec */*notnull*/ sp_bitvec_new(size_t size);
*
* - when accessing `index` out of bounds
*/
void sp_bitvec_set(BitVec */*notnull*/ bit_vec, size_t index, bool value);
/**
* Gets an unsafe reference to the data of the [DisplayBitVec] instance.
*
* The returned memory is valid for the lifetime of the bitvec.
*
* # Arguments
*
* - `bit_vec`: instance to write to
*/
struct ByteSlice sp_bitvec_unsafe_data_ref(BitVec */*notnull*/ bit_vec);
void sp_bitvec_set(BitVec */*notnull*/ instance, size_t index, bool value);
/**
*Clones a [BrightnessGrid] instance.
@ -920,14 +909,24 @@ struct ByteSlice sp_bitvec_unsafe_data_ref(BitVec */*notnull*/ bit_vec);
BrightnessGrid */*notnull*/ sp_brightness_grid_clone(BrightnessGrid */*notnull*/ instance);
/**
* Sets the value of all cells in the [BrightnessGrid].
* Calls [`servicepoint::BrightnessGrid::data_ref_mut`].
*
* Gets an unsafe reference to the data of the instance.
*
* The returned memory is valid for the lifetime of the grid.
*/
struct ByteSlice sp_brightness_grid_data_ref_mut(BrightnessGrid */*notnull*/ instance);
/**
* Calls [`servicepoint::BrightnessGrid::fill`].
*
* Sets the value of all cells.
*
* # Arguments
*
* - `brightness_grid`: instance to write to
* - `value`: the value to set all cells to
*/
void sp_brightness_grid_fill(BrightnessGrid */*notnull*/ brightness_grid,
void sp_brightness_grid_fill(BrightnessGrid */*notnull*/ instance,
Brightness value);
/**
@ -936,11 +935,12 @@ void sp_brightness_grid_fill(BrightnessGrid */*notnull*/ brightness_grid,
void sp_brightness_grid_free(BrightnessGrid */*notnull*/ instance);
/**
* Calls [`servicepoint::BrightnessGrid::get`].
*
* Gets the current value at the specified position.
*
* # Arguments
*
* - `brightness_grid`: instance to read from
* - `x` and `y`: position of the cell to read
*
* returns: value at position
@ -948,20 +948,16 @@ void sp_brightness_grid_free(BrightnessGrid */*notnull*/ instance);
* # Panics
* - When accessing `x` or `y` out of bounds.
*/
Brightness sp_brightness_grid_get(BrightnessGrid */*notnull*/ brightness_grid,
Brightness sp_brightness_grid_get(BrightnessGrid */*notnull*/ instance,
size_t x,
size_t y);
/**
* Gets the height of the [BrightnessGrid] instance.
* Calls [`servicepoint::BrightnessGrid::height`].
*
* # Arguments
*
* - `brightness_grid`: instance to read from
*
* returns: height
* Gets the height of the grid.
*/
size_t sp_brightness_grid_height(BrightnessGrid */*notnull*/ brightness_grid);
size_t sp_brightness_grid_height(BrightnessGrid */*notnull*/ instance);
/**
* Creates a [BrightnessGridCommand] and immediately turns that into a [Packet].
@ -1007,11 +1003,12 @@ BrightnessGrid *sp_brightness_grid_load(size_t width,
BrightnessGrid */*notnull*/ sp_brightness_grid_new(size_t width, size_t height);
/**
* Sets the value of the specified position in the [BrightnessGrid].
* Calls [`servicepoint::BrightnessGrid::set`].
*
* Sets the value of the specified position.
*
* # Arguments
*
* - `brightness_grid`: instance to write to
* - `x` and `y`: position of the cell
* - `value`: the value to write to the cell
*
@ -1021,34 +1018,17 @@ BrightnessGrid */*notnull*/ sp_brightness_grid_new(size_t width, size_t height);
*
* - When accessing `x` or `y` out of bounds.
*/
void sp_brightness_grid_set(BrightnessGrid */*notnull*/ brightness_grid,
void sp_brightness_grid_set(BrightnessGrid */*notnull*/ instance,
size_t x,
size_t y,
Brightness value);
/**
* Gets an unsafe reference to the data of the [BrightnessGrid] instance.
* Calls [`servicepoint::BrightnessGrid::width`].
*
* The returned memory is valid for the lifetime of the brightness grid.
*
* # Arguments
*
* - `brightness_grid`: instance to read from
*
* returns: slice of bytes underlying the `brightness_grid`.
* Gets the width of the grid.
*/
struct ByteSlice sp_brightness_grid_unsafe_data_ref(BrightnessGrid */*notnull*/ brightness_grid);
/**
* Gets the width of the [BrightnessGrid] instance.
*
* # Arguments
*
* - `brightness_grid`: instance to read from
*
* returns: width
*/
size_t sp_brightness_grid_width(BrightnessGrid */*notnull*/ brightness_grid);
size_t sp_brightness_grid_width(BrightnessGrid */*notnull*/ instance);
/**
*Clones a [CharGrid] instance.
@ -1056,14 +1036,16 @@ size_t sp_brightness_grid_width(BrightnessGrid */*notnull*/ brightness_grid);
CharGrid */*notnull*/ sp_char_grid_clone(CharGrid */*notnull*/ instance);
/**
* Sets the value of all cells in the [CharGrid].
* Calls [`servicepoint::CharGrid::fill`].
*
* Sets the value of all cells in the grid.
*
* # Arguments
*
* - `char_grid`: instance to write to
* - `value`: the value to set all cells to
* - when providing values that cannot be converted to Rust's `char`.
*/
void sp_char_grid_fill(CharGrid */*notnull*/ char_grid, uint32_t value);
void sp_char_grid_fill(CharGrid */*notnull*/ instance, uint32_t value);
/**
*Deallocates a [CharGrid] instance.
@ -1071,27 +1053,26 @@ void sp_char_grid_fill(CharGrid */*notnull*/ char_grid, uint32_t value);
void sp_char_grid_free(CharGrid */*notnull*/ instance);
/**
* Calls [`servicepoint::CharGrid::get`].
*
* Returns the current value at the specified position.
*
* # Arguments
*
* - `char_grid`: instance to read from
* - `x` and `y`: position of the cell to read
*
* # Panics
*
* - when accessing `x` or `y` out of bounds
*/
uint32_t sp_char_grid_get(CharGrid */*notnull*/ char_grid, size_t x, size_t y);
uint32_t sp_char_grid_get(CharGrid */*notnull*/ instance, size_t x, size_t y);
/**
* Gets the height of the [CharGrid] instance.
* Calls [`servicepoint::CharGrid::height`].
*
* # Arguments
*
* - `char_grid`: instance to read from
* Gets the height of the grid.
*/
size_t sp_char_grid_height(CharGrid */*notnull*/ char_grid);
size_t sp_char_grid_height(CharGrid */*notnull*/ instance);
/**
* Creates a [CharGridCommand] and immediately turns that into a [Packet].
@ -1128,11 +1109,12 @@ CharGrid *sp_char_grid_load(size_t width, size_t height, struct ByteSlice data);
CharGrid */*notnull*/ sp_char_grid_new(size_t width, size_t height);
/**
* Sets the value of the specified position in the [CharGrid].
* Calls [`servicepoint::CharGrid::set`].
*
* Sets the value of the specified position in the grid.
*
* # Arguments
*
* - `char_grid`: instance to write to
* - `x` and `y`: position of the cell
* - `value`: the value to write to the cell
*
@ -1141,20 +1123,19 @@ CharGrid */*notnull*/ sp_char_grid_new(size_t width, size_t height);
* # Panics
*
* - when accessing `x` or `y` out of bounds
* - when providing values that cannot be converted to Rust's `char`.
*/
void sp_char_grid_set(CharGrid */*notnull*/ char_grid,
void sp_char_grid_set(CharGrid */*notnull*/ instance,
size_t x,
size_t y,
uint32_t value);
/**
* Gets the width of the [CharGrid] instance.
* Calls [`servicepoint::CharGrid::width`].
*
* # Arguments
*
* - `char_grid`: instance to read from
* Gets the width of the grid.
*/
size_t sp_char_grid_width(CharGrid */*notnull*/ char_grid);
size_t sp_char_grid_width(CharGrid */*notnull*/ instance);
/**
*Clones a [BitmapCommand] instance.
@ -1608,49 +1589,50 @@ void sp_cmd_hard_reset_free(struct HardResetCommand */*notnull*/ instance);
struct HardResetCommand */*notnull*/ sp_cmd_hard_reset_new(void);
/**
*Clones a [Cp437Grid] instance.
* Calls [`servicepoint::Cp437Grid::data_ref_mut`].
*
* Gets an unsafe reference to the data of the grid.
*
* The returned memory is valid for the lifetime of the instance.
*/
Cp437Grid */*notnull*/ sp_cp437_grid_clone(Cp437Grid */*notnull*/ instance);
struct ByteSlice sp_cp437_data_ref_mut(Cp437Grid */*notnull*/ instance);
/**
* Sets the value of all cells in the [Cp437Grid].
* Calls [`servicepoint::Cp437Grid::fill`].
*
* Sets the value of all cells in the grid.
*
* # Arguments
*
* - `cp437_grid`: instance to write to
* - `value`: the value to set all cells to
*/
void sp_cp437_grid_fill(Cp437Grid */*notnull*/ cp437_grid, uint8_t value);
/**
*Deallocates a [Cp437Grid] instance.
*/
void sp_cp437_grid_free(Cp437Grid */*notnull*/ instance);
void sp_cp437_fill(Cp437Grid */*notnull*/ instance, uint8_t value);
/**
* Calls [`servicepoint::Cp437Grid::get`].
*
* Gets the current value at the specified position.
*
* # Arguments
*
* - `cp437_grid`: instance to read from
* - `x` and `y`: position of the cell to read
*
* # Panics
*
* - when accessing `x` or `y` out of bounds
*/
uint8_t sp_cp437_grid_get(Cp437Grid */*notnull*/ cp437_grid,
size_t x,
size_t y);
uint8_t sp_cp437_get(Cp437Grid */*notnull*/ instance, size_t x, size_t y);
/**
* Gets the height of the [Cp437Grid] instance.
*
* # Arguments
*
* - `cp437_grid`: instance to read from
*Clones a [Cp437Grid] instance.
*/
size_t sp_cp437_grid_height(Cp437Grid */*notnull*/ cp437_grid);
Cp437Grid */*notnull*/ sp_cp437_grid_clone(Cp437Grid */*notnull*/ instance);
/**
*Deallocates a [Cp437Grid] instance.
*/
void sp_cp437_grid_free(Cp437Grid */*notnull*/ instance);
/**
* Creates a [Cp437GridCommand] and immediately turns that into a [Packet].
@ -1678,11 +1660,19 @@ Cp437Grid *sp_cp437_grid_load(size_t width,
Cp437Grid */*notnull*/ sp_cp437_grid_new(size_t width, size_t height);
/**
* Sets the value of the specified position in the [Cp437Grid].
* Calls [`servicepoint::Cp437Grid::height`].
*
* Gets the height of the grid.
*/
size_t sp_cp437_height(Cp437Grid */*notnull*/ instance);
/**
* Calls [`servicepoint::Cp437Grid::set`].
*
* Sets the value at the specified position.
*
* # Arguments
*
* - `cp437_grid`: instance to write to
* - `x` and `y`: position of the cell
* - `value`: the value to write to the cell
*
@ -1692,26 +1682,17 @@ Cp437Grid */*notnull*/ sp_cp437_grid_new(size_t width, size_t height);
*
* - when accessing `x` or `y` out of bounds
*/
void sp_cp437_grid_set(Cp437Grid */*notnull*/ cp437_grid,
size_t x,
size_t y,
uint8_t value);
void sp_cp437_set(Cp437Grid */*notnull*/ instance,
size_t x,
size_t y,
uint8_t value);
/**
* Gets an unsafe reference to the data of the [Cp437Grid] instance.
* Calls [`servicepoint::Cp437Grid::width`].
*
* The returned memory is valid for the lifetime of the grid.
* Gets the width of the grid.
*/
struct ByteSlice sp_cp437_grid_unsafe_data_ref(Cp437Grid */*notnull*/ cp437_grid);
/**
* Gets the width of the [Cp437Grid] instance.
*
* # Arguments
*
* - `cp437_grid`: instance to read from
*/
size_t sp_cp437_grid_width(Cp437Grid */*notnull*/ cp437_grid);
size_t sp_cp437_width(Cp437Grid */*notnull*/ instance);
/**
*Clones a [Packet] instance.