WIP: type per command #4

Draft
vinzenz wants to merge 49 commits from next into main
2 changed files with 248 additions and 111 deletions
Showing only changes of commit 21987d05f3 - Show all commits

View file

@ -640,7 +640,9 @@ extern "C" {
void init_env_logger(void); void init_env_logger(void);
/** /**
*Clones a [Bitmap] instance. *Clones a [`Bitmap`] instance.
*
* This function is part of the sp_bitmap module.
*/ */
struct Bitmap */*notnull*/ sp_bitmap_clone(struct Bitmap */*notnull*/ instance); struct Bitmap */*notnull*/ sp_bitmap_clone(struct Bitmap */*notnull*/ instance);
@ -650,6 +652,8 @@ struct Bitmap */*notnull*/ sp_bitmap_clone(struct Bitmap */*notnull*/ instance);
* Gets an unsafe reference to the data of the [Bitmap] instance. * Gets an unsafe reference to the data of the [Bitmap] instance.
* *
* The returned memory is valid for the lifetime of the bitmap. * The returned memory is valid for the lifetime of the bitmap.
*
* This function is part of the sp_bitmap module.
*/ */
struct ByteSlice sp_bitmap_data_ref_mut(struct Bitmap */*notnull*/ instance); struct ByteSlice sp_bitmap_data_ref_mut(struct Bitmap */*notnull*/ instance);
@ -661,11 +665,15 @@ struct ByteSlice sp_bitmap_data_ref_mut(struct Bitmap */*notnull*/ instance);
* # Arguments * # Arguments
* *
* - `value`: the value to set all pixels to * - `value`: the value to set all pixels to
*
* This function is part of the sp_bitmap module.
*/ */
void sp_bitmap_fill(struct Bitmap */*notnull*/ instance, bool value); void sp_bitmap_fill(struct Bitmap */*notnull*/ instance, bool value);
/** /**
*Deallocates a [Bitmap] instance. *Deallocates a [`Bitmap`] instance.
*
* This function is part of the sp_bitmap module.
*/ */
void sp_bitmap_free(struct Bitmap */*notnull*/ instance); void sp_bitmap_free(struct Bitmap */*notnull*/ instance);
@ -692,6 +700,8 @@ struct Bitmap *sp_bitmap_from_bitvec(size_t width, BitVec */*notnull*/ bitvec);
* # Panics * # Panics
* *
* - when accessing `x` or `y` out of bounds * - when accessing `x` or `y` out of bounds
*
* This function is part of the sp_bitmap module.
*/ */
bool sp_bitmap_get(struct Bitmap */*notnull*/ instance, size_t x, size_t y); bool sp_bitmap_get(struct Bitmap */*notnull*/ instance, size_t x, size_t y);
@ -699,6 +709,8 @@ bool sp_bitmap_get(struct Bitmap */*notnull*/ instance, size_t x, size_t y);
* Calls [`servicepoint::Bitmap::height`]. * Calls [`servicepoint::Bitmap::height`].
* *
* Gets the height in pixels. * Gets the height in pixels.
*
* This function is part of the sp_bitmap module.
*/ */
size_t sp_bitmap_height(struct Bitmap */*notnull*/ instance); size_t sp_bitmap_height(struct Bitmap */*notnull*/ instance);
@ -790,6 +802,8 @@ struct Bitmap */*notnull*/ sp_bitmap_new_max_sized(void);
* # Panics * # Panics
* *
* - when accessing `x` or `y` out of bounds * - when accessing `x` or `y` out of bounds
*
* This function is part of the sp_bitmap module.
*/ */
void sp_bitmap_set(struct Bitmap */*notnull*/ instance, void sp_bitmap_set(struct Bitmap */*notnull*/ instance,
size_t x, size_t x,
@ -800,6 +814,8 @@ void sp_bitmap_set(struct Bitmap */*notnull*/ instance,
* Calls [`servicepoint::Bitmap::width`]. * Calls [`servicepoint::Bitmap::width`].
* *
* Gets the width in pixels. * Gets the width in pixels.
*
* This function is part of the sp_bitmap module.
*/ */
size_t sp_bitmap_width(struct Bitmap */*notnull*/ instance); size_t sp_bitmap_width(struct Bitmap */*notnull*/ instance);
@ -809,11 +825,15 @@ size_t sp_bitmap_width(struct Bitmap */*notnull*/ instance);
* Gets an unsafe reference to the data of the [DisplayBitVec] instance. * Gets an unsafe reference to the data of the [DisplayBitVec] instance.
* *
* The returned memory is valid for the lifetime of the bitvec. * The returned memory is valid for the lifetime of the bitvec.
*
* This function is part of the sp_bitvec module.
*/ */
struct ByteSlice sp_bitvec_as_raw_mut_slice(BitVec */*notnull*/ instance); struct ByteSlice sp_bitvec_as_raw_mut_slice(BitVec */*notnull*/ instance);
/** /**
*Clones a [DisplayBitVec] instance. *Clones a [`DisplayBitVec`] instance.
*
* This function is part of the sp_bitvec module.
*/ */
BitVec */*notnull*/ sp_bitvec_clone(BitVec */*notnull*/ instance); BitVec */*notnull*/ sp_bitvec_clone(BitVec */*notnull*/ instance);
@ -825,11 +845,15 @@ BitVec */*notnull*/ sp_bitvec_clone(BitVec */*notnull*/ instance);
* # Arguments * # Arguments
* *
* - `value`: the value to set all bits to * - `value`: the value to set all bits to
*
* This function is part of the sp_bitvec module.
*/ */
void sp_bitvec_fill(BitVec */*notnull*/ instance, bool value); void sp_bitvec_fill(BitVec */*notnull*/ instance, bool value);
/** /**
*Deallocates a [DisplayBitVec] instance. *Deallocates a [`DisplayBitVec`] instance.
*
* This function is part of the sp_bitvec module.
*/ */
void sp_bitvec_free(BitVec */*notnull*/ instance); void sp_bitvec_free(BitVec */*notnull*/ instance);
@ -848,6 +872,8 @@ void sp_bitvec_free(BitVec */*notnull*/ instance);
* # Panics * # Panics
* *
* - when accessing `index` out of bounds * - when accessing `index` out of bounds
*
* This function is part of the sp_bitvec module.
*/ */
bool sp_bitvec_get(BitVec */*notnull*/ instance, size_t index); bool sp_bitvec_get(BitVec */*notnull*/ instance, size_t index);
@ -869,6 +895,8 @@ struct Packet *sp_bitvec_into_packet(BitVec */*notnull*/ bitvec,
* Calls [`servicepoint::DisplayBitVec::is_empty`]. * Calls [`servicepoint::DisplayBitVec::is_empty`].
* *
* Returns true if length is 0. * Returns true if length is 0.
*
* This function is part of the sp_bitvec module.
*/ */
bool sp_bitvec_is_empty(BitVec */*notnull*/ instance); bool sp_bitvec_is_empty(BitVec */*notnull*/ instance);
@ -876,6 +904,8 @@ bool sp_bitvec_is_empty(BitVec */*notnull*/ instance);
* Calls [`servicepoint::DisplayBitVec::len`]. * Calls [`servicepoint::DisplayBitVec::len`].
* *
* Gets the length in bits. * Gets the length in bits.
*
* This function is part of the sp_bitvec module.
*/ */
size_t sp_bitvec_len(BitVec */*notnull*/ instance); size_t sp_bitvec_len(BitVec */*notnull*/ instance);
@ -918,11 +948,15 @@ BitVec */*notnull*/ sp_bitvec_new(size_t size);
* # Panics * # Panics
* *
* - when accessing `index` out of bounds * - when accessing `index` out of bounds
*
* This function is part of the sp_bitvec module.
*/ */
void sp_bitvec_set(BitVec */*notnull*/ instance, size_t index, bool value); void sp_bitvec_set(BitVec */*notnull*/ instance, size_t index, bool value);
/** /**
*Clones a [BrightnessGrid] instance. *Clones a [`BrightnessGrid`] instance.
*
* This function is part of the sp_brightness_grid module.
*/ */
BrightnessGrid */*notnull*/ sp_brightness_grid_clone(BrightnessGrid */*notnull*/ instance); BrightnessGrid */*notnull*/ sp_brightness_grid_clone(BrightnessGrid */*notnull*/ instance);
@ -932,6 +966,8 @@ BrightnessGrid */*notnull*/ sp_brightness_grid_clone(BrightnessGrid */*notnull*/
* Gets an unsafe reference to the data of the instance. * Gets an unsafe reference to the data of the instance.
* *
* The returned memory is valid for the lifetime of the grid. * The returned memory is valid for the lifetime of the grid.
*
* This function is part of the sp_brightness_grid module.
*/ */
struct ByteSlice sp_brightness_grid_data_ref_mut(BrightnessGrid */*notnull*/ instance); struct ByteSlice sp_brightness_grid_data_ref_mut(BrightnessGrid */*notnull*/ instance);
@ -943,12 +979,16 @@ struct ByteSlice sp_brightness_grid_data_ref_mut(BrightnessGrid */*notnull*/ ins
* # Arguments * # Arguments
* *
* - `value`: the value to set all cells to * - `value`: the value to set all cells to
*
* This function is part of the sp_brightness_grid module.
*/ */
void sp_brightness_grid_fill(BrightnessGrid */*notnull*/ instance, void sp_brightness_grid_fill(BrightnessGrid */*notnull*/ instance,
Brightness value); Brightness value);
/** /**
*Deallocates a [BrightnessGrid] instance. *Deallocates a [`BrightnessGrid`] instance.
*
* This function is part of the sp_brightness_grid module.
*/ */
void sp_brightness_grid_free(BrightnessGrid */*notnull*/ instance); void sp_brightness_grid_free(BrightnessGrid */*notnull*/ instance);
@ -965,6 +1005,8 @@ void sp_brightness_grid_free(BrightnessGrid */*notnull*/ instance);
* *
* # Panics * # Panics
* - When accessing `x` or `y` out of bounds. * - When accessing `x` or `y` out of bounds.
*
* This function is part of the sp_brightness_grid module.
*/ */
Brightness sp_brightness_grid_get(BrightnessGrid */*notnull*/ instance, Brightness sp_brightness_grid_get(BrightnessGrid */*notnull*/ instance,
size_t x, size_t x,
@ -974,6 +1016,8 @@ Brightness sp_brightness_grid_get(BrightnessGrid */*notnull*/ instance,
* Calls [`servicepoint::BrightnessGrid::height`]. * Calls [`servicepoint::BrightnessGrid::height`].
* *
* Gets the height of the grid. * Gets the height of the grid.
*
* This function is part of the sp_brightness_grid module.
*/ */
size_t sp_brightness_grid_height(BrightnessGrid */*notnull*/ instance); size_t sp_brightness_grid_height(BrightnessGrid */*notnull*/ instance);
@ -1041,6 +1085,8 @@ BrightnessGrid */*notnull*/ sp_brightness_grid_new(size_t width, size_t height);
* # Panics * # Panics
* *
* - When accessing `x` or `y` out of bounds. * - When accessing `x` or `y` out of bounds.
*
* This function is part of the sp_brightness_grid module.
*/ */
void sp_brightness_grid_set(BrightnessGrid */*notnull*/ instance, void sp_brightness_grid_set(BrightnessGrid */*notnull*/ instance,
size_t x, size_t x,
@ -1051,11 +1097,15 @@ void sp_brightness_grid_set(BrightnessGrid */*notnull*/ instance,
* Calls [`servicepoint::BrightnessGrid::width`]. * Calls [`servicepoint::BrightnessGrid::width`].
* *
* Gets the width of the grid. * Gets the width of the grid.
*
* This function is part of the sp_brightness_grid module.
*/ */
size_t sp_brightness_grid_width(BrightnessGrid */*notnull*/ instance); size_t sp_brightness_grid_width(BrightnessGrid */*notnull*/ instance);
/** /**
*Clones a [CharGrid] instance. *Clones a [`CharGrid`] instance.
*
* This function is part of the sp_char_grid module.
*/ */
CharGrid */*notnull*/ sp_char_grid_clone(CharGrid */*notnull*/ instance); CharGrid */*notnull*/ sp_char_grid_clone(CharGrid */*notnull*/ instance);
@ -1068,11 +1118,15 @@ CharGrid */*notnull*/ sp_char_grid_clone(CharGrid */*notnull*/ instance);
* *
* - `value`: the value to set all cells to * - `value`: the value to set all cells to
* - when providing values that cannot be converted to Rust's `char`. * - when providing values that cannot be converted to Rust's `char`.
*
* This function is part of the sp_char_grid module.
*/ */
void sp_char_grid_fill(CharGrid */*notnull*/ instance, uint32_t value); void sp_char_grid_fill(CharGrid */*notnull*/ instance, uint32_t value);
/** /**
*Deallocates a [CharGrid] instance. *Deallocates a [`CharGrid`] instance.
*
* This function is part of the sp_char_grid module.
*/ */
void sp_char_grid_free(CharGrid */*notnull*/ instance); void sp_char_grid_free(CharGrid */*notnull*/ instance);
@ -1088,6 +1142,8 @@ void sp_char_grid_free(CharGrid */*notnull*/ instance);
* # Panics * # Panics
* *
* - when accessing `x` or `y` out of bounds * - when accessing `x` or `y` out of bounds
*
* This function is part of the sp_char_grid module.
*/ */
uint32_t sp_char_grid_get(CharGrid */*notnull*/ instance, size_t x, size_t y); uint32_t sp_char_grid_get(CharGrid */*notnull*/ instance, size_t x, size_t y);
@ -1095,6 +1151,8 @@ uint32_t sp_char_grid_get(CharGrid */*notnull*/ instance, size_t x, size_t y);
* Calls [`servicepoint::CharGrid::height`]. * Calls [`servicepoint::CharGrid::height`].
* *
* Gets the height of the grid. * Gets the height of the grid.
*
* This function is part of the sp_char_grid module.
*/ */
size_t sp_char_grid_height(CharGrid */*notnull*/ instance); size_t sp_char_grid_height(CharGrid */*notnull*/ instance);
@ -1154,6 +1212,8 @@ CharGrid */*notnull*/ sp_char_grid_new(size_t width, size_t height);
* *
* - when accessing `x` or `y` out of bounds * - when accessing `x` or `y` out of bounds
* - when providing values that cannot be converted to Rust's `char`. * - when providing values that cannot be converted to Rust's `char`.
*
* This function is part of the sp_char_grid module.
*/ */
void sp_char_grid_set(CharGrid */*notnull*/ instance, void sp_char_grid_set(CharGrid */*notnull*/ instance,
size_t x, size_t x,
@ -1164,16 +1224,22 @@ void sp_char_grid_set(CharGrid */*notnull*/ instance,
* Calls [`servicepoint::CharGrid::width`]. * Calls [`servicepoint::CharGrid::width`].
* *
* Gets the width of the grid. * Gets the width of the grid.
*
* This function is part of the sp_char_grid module.
*/ */
size_t sp_char_grid_width(CharGrid */*notnull*/ instance); size_t sp_char_grid_width(CharGrid */*notnull*/ instance);
/** /**
*Clones a [BitmapCommand] instance. *Clones a [`BitmapCommand`] instance.
*
* This function is part of the sp_cmd_bitmap module.
*/ */
struct BitmapCommand */*notnull*/ sp_cmd_bitmap_clone(struct BitmapCommand */*notnull*/ instance); struct BitmapCommand */*notnull*/ sp_cmd_bitmap_clone(struct BitmapCommand */*notnull*/ instance);
/** /**
*Deallocates a [BitmapCommand] instance. *Deallocates a [`BitmapCommand`] instance.
*
* This function is part of the sp_cmd_bitmap module.
*/ */
void sp_cmd_bitmap_free(struct BitmapCommand */*notnull*/ instance); void sp_cmd_bitmap_free(struct BitmapCommand */*notnull*/ instance);
@ -1199,6 +1265,8 @@ struct Bitmap */*notnull*/ sp_cmd_bitmap_get(struct BitmapCommand */*notnull*/ c
/** /**
* Gets the value of field `compression` of the [`servicepoint::BitmapCommand`]. * Gets the value of field `compression` of the [`servicepoint::BitmapCommand`].
*
* This function is part of the sp_cmd_bitmap module.
*/ */
CompressionCode sp_cmd_bitmap_get_compression(struct BitmapCommand */*notnull*/ instance); CompressionCode sp_cmd_bitmap_get_compression(struct BitmapCommand */*notnull*/ instance);
@ -1231,6 +1299,8 @@ void sp_cmd_bitmap_set(struct BitmapCommand */*notnull*/ command,
/** /**
* Sets the value of field `compression` of the [`servicepoint::BitmapCommand`]. * Sets the value of field `compression` of the [`servicepoint::BitmapCommand`].
*
* This function is part of the sp_cmd_bitmap module.
*/ */
void sp_cmd_bitmap_set_compression(struct BitmapCommand */*notnull*/ instance, void sp_cmd_bitmap_set_compression(struct BitmapCommand */*notnull*/ instance,
CompressionCode value); CompressionCode value);
@ -1252,12 +1322,16 @@ void sp_cmd_bitmap_set_origin(struct BitmapCommand */*notnull*/ command,
struct Packet *sp_cmd_bitmap_try_into_packet(struct BitmapCommand */*notnull*/ command); struct Packet *sp_cmd_bitmap_try_into_packet(struct BitmapCommand */*notnull*/ command);
/** /**
*Clones a [BitVecCommand] instance. *Clones a [`BitVecCommand`] instance.
*
* This function is part of the sp_cmd_bitvec module.
*/ */
struct BitVecCommand */*notnull*/ sp_cmd_bitvec_clone(struct BitVecCommand */*notnull*/ instance); struct BitVecCommand */*notnull*/ sp_cmd_bitvec_clone(struct BitVecCommand */*notnull*/ instance);
/** /**
*Deallocates a [BitVecCommand] instance. *Deallocates a [`BitVecCommand`] instance.
*
* This function is part of the sp_cmd_bitvec module.
*/ */
void sp_cmd_bitvec_free(struct BitVecCommand */*notnull*/ instance); void sp_cmd_bitvec_free(struct BitVecCommand */*notnull*/ instance);
@ -1268,16 +1342,22 @@ BitVec *sp_cmd_bitvec_get(struct BitVecCommand */*notnull*/ command);
/** /**
* Gets the value of field `compression` of the [`servicepoint::BitVecCommand`]. * Gets the value of field `compression` of the [`servicepoint::BitVecCommand`].
*
* This function is part of the sp_cmd_bitvec module.
*/ */
CompressionCode sp_cmd_bitvec_get_compression(struct BitVecCommand */*notnull*/ instance); CompressionCode sp_cmd_bitvec_get_compression(struct BitVecCommand */*notnull*/ instance);
/** /**
* Gets the value of field `offset` of the [`servicepoint::BitVecCommand`]. * Gets the value of field `offset` of the [`servicepoint::BitVecCommand`].
*
* This function is part of the sp_cmd_bitvec module.
*/ */
Offset sp_cmd_bitvec_get_offset(struct BitVecCommand */*notnull*/ instance); Offset sp_cmd_bitvec_get_offset(struct BitVecCommand */*notnull*/ instance);
/** /**
* Gets the value of field `operation` of the [`servicepoint::BitVecCommand`]. * Gets the value of field `operation` of the [`servicepoint::BitVecCommand`].
*
* This function is part of the sp_cmd_bitvec module.
*/ */
BinaryOperation sp_cmd_bitvec_get_operation(struct BitVecCommand */*notnull*/ instance); BinaryOperation sp_cmd_bitvec_get_operation(struct BitVecCommand */*notnull*/ instance);
@ -1310,18 +1390,24 @@ void sp_cmd_bitvec_set(struct BitVecCommand */*notnull*/ command,
/** /**
* Sets the value of field `compression` of the [`servicepoint::BitVecCommand`]. * Sets the value of field `compression` of the [`servicepoint::BitVecCommand`].
*
* This function is part of the sp_cmd_bitvec module.
*/ */
void sp_cmd_bitvec_set_compression(struct BitVecCommand */*notnull*/ instance, void sp_cmd_bitvec_set_compression(struct BitVecCommand */*notnull*/ instance,
CompressionCode value); CompressionCode value);
/** /**
* Sets the value of field `offset` of the [`servicepoint::BitVecCommand`]. * Sets the value of field `offset` of the [`servicepoint::BitVecCommand`].
*
* This function is part of the sp_cmd_bitvec module.
*/ */
void sp_cmd_bitvec_set_offset(struct BitVecCommand */*notnull*/ instance, void sp_cmd_bitvec_set_offset(struct BitVecCommand */*notnull*/ instance,
Offset value); Offset value);
/** /**
* Sets the value of field `operation` of the [`servicepoint::BitVecCommand`]. * Sets the value of field `operation` of the [`servicepoint::BitVecCommand`].
*
* This function is part of the sp_cmd_bitvec module.
*/ */
void sp_cmd_bitvec_set_operation(struct BitVecCommand */*notnull*/ instance, void sp_cmd_bitvec_set_operation(struct BitVecCommand */*notnull*/ instance,
BinaryOperation value); BinaryOperation value);
@ -1336,17 +1422,23 @@ void sp_cmd_bitvec_set_operation(struct BitVecCommand */*notnull*/ instance,
struct Packet *sp_cmd_bitvec_try_into_packet(struct BitVecCommand */*notnull*/ command); struct Packet *sp_cmd_bitvec_try_into_packet(struct BitVecCommand */*notnull*/ command);
/** /**
*Clones a [GlobalBrightnessCommand] instance. *Clones a [`GlobalBrightnessCommand`] instance.
*
* This function is part of the sp_cmd_brightness_global module.
*/ */
struct GlobalBrightnessCommand */*notnull*/ sp_cmd_brightness_global_clone(struct GlobalBrightnessCommand */*notnull*/ instance); struct GlobalBrightnessCommand */*notnull*/ sp_cmd_brightness_global_clone(struct GlobalBrightnessCommand */*notnull*/ instance);
/** /**
*Deallocates a [GlobalBrightnessCommand] instance. *Deallocates a [`GlobalBrightnessCommand`] instance.
*
* This function is part of the sp_cmd_brightness_global module.
*/ */
void sp_cmd_brightness_global_free(struct GlobalBrightnessCommand */*notnull*/ instance); void sp_cmd_brightness_global_free(struct GlobalBrightnessCommand */*notnull*/ instance);
/** /**
* Gets the value of field `brightness` of the [`servicepoint::GlobalBrightnessCommand`]. * Gets the value of field `brightness` of the [`servicepoint::GlobalBrightnessCommand`].
*
* This function is part of the sp_cmd_brightness_global module.
*/ */
Brightness sp_cmd_brightness_global_get_brightness(struct GlobalBrightnessCommand */*notnull*/ instance); Brightness sp_cmd_brightness_global_get_brightness(struct GlobalBrightnessCommand */*notnull*/ instance);
@ -1368,17 +1460,23 @@ struct GlobalBrightnessCommand */*notnull*/ sp_cmd_brightness_global_new(Brightn
/** /**
* Sets the value of field `brightness` of the [`servicepoint::GlobalBrightnessCommand`]. * Sets the value of field `brightness` of the [`servicepoint::GlobalBrightnessCommand`].
*
* This function is part of the sp_cmd_brightness_global module.
*/ */
void sp_cmd_brightness_global_set_brightness(struct GlobalBrightnessCommand */*notnull*/ instance, void sp_cmd_brightness_global_set_brightness(struct GlobalBrightnessCommand */*notnull*/ instance,
Brightness value); Brightness value);
/** /**
*Clones a [BrightnessGridCommand] instance. *Clones a [`BrightnessGridCommand`] instance.
*
* This function is part of the sp_cmd_brightness_grid module.
*/ */
struct BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_clone(struct BrightnessGridCommand */*notnull*/ instance); struct BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_clone(struct BrightnessGridCommand */*notnull*/ instance);
/** /**
*Deallocates a [BrightnessGridCommand] instance. *Deallocates a [`BrightnessGridCommand`] instance.
*
* This function is part of the sp_cmd_brightness_grid module.
*/ */
void sp_cmd_brightness_grid_free(struct BrightnessGridCommand */*notnull*/ instance); void sp_cmd_brightness_grid_free(struct BrightnessGridCommand */*notnull*/ instance);
@ -1438,12 +1536,16 @@ void sp_cmd_brightness_grid_set_origin(struct BrightnessGridCommand */*notnull*/
size_t origin_y); size_t origin_y);
/** /**
*Clones a [CharGridCommand] instance. *Clones a [`CharGridCommand`] instance.
*
* This function is part of the sp_cmd_char_grid module.
*/ */
struct CharGridCommand */*notnull*/ sp_cmd_char_grid_clone(struct CharGridCommand */*notnull*/ instance); struct CharGridCommand */*notnull*/ sp_cmd_char_grid_clone(struct CharGridCommand */*notnull*/ instance);
/** /**
*Deallocates a [CharGridCommand] instance. *Deallocates a [`CharGridCommand`] instance.
*
* This function is part of the sp_cmd_char_grid module.
*/ */
void sp_cmd_char_grid_free(struct CharGridCommand */*notnull*/ instance); void sp_cmd_char_grid_free(struct CharGridCommand */*notnull*/ instance);
@ -1503,7 +1605,9 @@ void sp_cmd_char_grid_set_origin(struct CharGridCommand */*notnull*/ command,
struct Packet *sp_cmd_char_grid_try_into_packet(struct CharGridCommand */*notnull*/ command); struct Packet *sp_cmd_char_grid_try_into_packet(struct CharGridCommand */*notnull*/ command);
/** /**
*Deallocates a [ClearCommand] instance. *Deallocates a [`ClearCommand`] instance.
*
* This function is part of the sp_cmd_clear module.
*/ */
void sp_cmd_clear_free(struct ClearCommand */*notnull*/ instance); void sp_cmd_clear_free(struct ClearCommand */*notnull*/ instance);
@ -1519,12 +1623,16 @@ void sp_cmd_clear_free(struct ClearCommand */*notnull*/ instance);
struct ClearCommand */*notnull*/ sp_cmd_clear_new(void); struct ClearCommand */*notnull*/ sp_cmd_clear_new(void);
/** /**
*Clones a [Cp437GridCommand] instance. *Clones a [`Cp437GridCommand`] instance.
*
* This function is part of the sp_cmd_cp437_grid module.
*/ */
struct Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_clone(struct Cp437GridCommand */*notnull*/ instance); struct Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_clone(struct Cp437GridCommand */*notnull*/ instance);
/** /**
*Deallocates a [Cp437GridCommand] instance. *Deallocates a [`Cp437GridCommand`] instance.
*
* This function is part of the sp_cmd_cp437_grid module.
*/ */
void sp_cmd_cp437_grid_free(struct Cp437GridCommand */*notnull*/ instance); void sp_cmd_cp437_grid_free(struct Cp437GridCommand */*notnull*/ instance);
@ -1595,7 +1703,9 @@ void sp_cmd_cp437_grid_set_origin(struct Cp437GridCommand */*notnull*/ command,
struct Packet *sp_cmd_cp437_grid_try_into_packet(struct Cp437GridCommand */*notnull*/ command); struct Packet *sp_cmd_cp437_grid_try_into_packet(struct Cp437GridCommand */*notnull*/ command);
/** /**
*Deallocates a [FadeOutCommand] instance. *Deallocates a [`FadeOutCommand`] instance.
*
* This function is part of the sp_cmd_fade_out module.
*/ */
void sp_cmd_fade_out_free(struct FadeOutCommand */*notnull*/ instance); void sp_cmd_fade_out_free(struct FadeOutCommand */*notnull*/ instance);
@ -1647,7 +1757,9 @@ struct Packet *sp_cmd_generic_into_packet(struct Command command);
struct Command sp_cmd_generic_try_from_packet(struct Packet */*notnull*/ packet); struct Command sp_cmd_generic_try_from_packet(struct Packet */*notnull*/ packet);
/** /**
*Deallocates a [HardResetCommand] instance. *Deallocates a [`HardResetCommand`] instance.
*
* This function is part of the sp_cmd_hard_reset module.
*/ */
void sp_cmd_hard_reset_free(struct HardResetCommand */*notnull*/ instance); void sp_cmd_hard_reset_free(struct HardResetCommand */*notnull*/ instance);
@ -1663,7 +1775,9 @@ void sp_cmd_hard_reset_free(struct HardResetCommand */*notnull*/ instance);
struct HardResetCommand */*notnull*/ sp_cmd_hard_reset_new(void); struct HardResetCommand */*notnull*/ sp_cmd_hard_reset_new(void);
/** /**
*Clones a [Cp437Grid] instance. *Clones a [`Cp437Grid`] instance.
*
* This function is part of the sp_cp437_grid module.
*/ */
Cp437Grid */*notnull*/ sp_cp437_grid_clone(Cp437Grid */*notnull*/ instance); Cp437Grid */*notnull*/ sp_cp437_grid_clone(Cp437Grid */*notnull*/ instance);
@ -1673,6 +1787,8 @@ Cp437Grid */*notnull*/ sp_cp437_grid_clone(Cp437Grid */*notnull*/ instance);
* Gets an unsafe reference to the data of the grid. * Gets an unsafe reference to the data of the grid.
* *
* The returned memory is valid for the lifetime of the instance. * The returned memory is valid for the lifetime of the instance.
*
* This function is part of the sp_cp437_grid module.
*/ */
struct ByteSlice sp_cp437_grid_data_ref_mut(Cp437Grid */*notnull*/ instance); struct ByteSlice sp_cp437_grid_data_ref_mut(Cp437Grid */*notnull*/ instance);
@ -1685,11 +1801,15 @@ struct ByteSlice sp_cp437_grid_data_ref_mut(Cp437Grid */*notnull*/ instance);
* *
* - `cp437_grid`: instance to write to * - `cp437_grid`: instance to write to
* - `value`: the value to set all cells to * - `value`: the value to set all cells to
*
* This function is part of the sp_cp437_grid module.
*/ */
void sp_cp437_grid_fill(Cp437Grid */*notnull*/ instance, uint8_t value); void sp_cp437_grid_fill(Cp437Grid */*notnull*/ instance, uint8_t value);
/** /**
*Deallocates a [Cp437Grid] instance. *Deallocates a [`Cp437Grid`] instance.
*
* This function is part of the sp_cp437_grid module.
*/ */
void sp_cp437_grid_free(Cp437Grid */*notnull*/ instance); void sp_cp437_grid_free(Cp437Grid */*notnull*/ instance);
@ -1705,6 +1825,8 @@ void sp_cp437_grid_free(Cp437Grid */*notnull*/ instance);
* # Panics * # Panics
* *
* - when accessing `x` or `y` out of bounds * - when accessing `x` or `y` out of bounds
*
* This function is part of the sp_cp437_grid module.
*/ */
uint8_t sp_cp437_grid_get(Cp437Grid */*notnull*/ instance, size_t x, size_t y); uint8_t sp_cp437_grid_get(Cp437Grid */*notnull*/ instance, size_t x, size_t y);
@ -1712,6 +1834,8 @@ uint8_t sp_cp437_grid_get(Cp437Grid */*notnull*/ instance, size_t x, size_t y);
* Calls [`servicepoint::Cp437Grid::height`]. * Calls [`servicepoint::Cp437Grid::height`].
* *
* Gets the height of the grid. * Gets the height of the grid.
*
* This function is part of the sp_cp437_grid module.
*/ */
size_t sp_cp437_grid_height(Cp437Grid */*notnull*/ instance); size_t sp_cp437_grid_height(Cp437Grid */*notnull*/ instance);
@ -1761,6 +1885,8 @@ Cp437Grid */*notnull*/ sp_cp437_grid_new(size_t width, size_t height);
* # Panics * # Panics
* *
* - when accessing `x` or `y` out of bounds * - when accessing `x` or `y` out of bounds
*
* This function is part of the sp_cp437_grid module.
*/ */
void sp_cp437_grid_set(Cp437Grid */*notnull*/ instance, void sp_cp437_grid_set(Cp437Grid */*notnull*/ instance,
size_t x, size_t x,
@ -1771,16 +1897,22 @@ void sp_cp437_grid_set(Cp437Grid */*notnull*/ instance,
* Calls [`servicepoint::Cp437Grid::width`]. * Calls [`servicepoint::Cp437Grid::width`].
* *
* Gets the width of the grid. * Gets the width of the grid.
*
* This function is part of the sp_cp437_grid module.
*/ */
size_t sp_cp437_grid_width(Cp437Grid */*notnull*/ instance); size_t sp_cp437_grid_width(Cp437Grid */*notnull*/ instance);
/** /**
*Clones a [Packet] instance. *Clones a [`Packet`] instance.
*
* This function is part of the sp_packet module.
*/ */
struct Packet */*notnull*/ sp_packet_clone(struct Packet */*notnull*/ instance); struct Packet */*notnull*/ sp_packet_clone(struct Packet */*notnull*/ instance);
/** /**
*Deallocates a [Packet] instance. *Deallocates a [`Packet`] instance.
*
* This function is part of the sp_packet module.
*/ */
void sp_packet_free(struct Packet */*notnull*/ instance); void sp_packet_free(struct Packet */*notnull*/ instance);
@ -1794,6 +1926,8 @@ struct Packet */*notnull*/ sp_packet_from_parts(struct Header header,
/** /**
* Gets the value of field `header` of the [`servicepoint::Packet`]. * Gets the value of field `header` of the [`servicepoint::Packet`].
*
* This function is part of the sp_packet module.
*/ */
struct Header sp_packet_get_header(struct Packet */*notnull*/ instance); struct Header sp_packet_get_header(struct Packet */*notnull*/ instance);
@ -1825,6 +1959,8 @@ void sp_packet_serialize_to(struct Packet */*notnull*/ packet,
/** /**
* Sets the value of field `header` of the [`servicepoint::Packet`]. * Sets the value of field `header` of the [`servicepoint::Packet`].
*
* This function is part of the sp_packet module.
*/ */
void sp_packet_set_header(struct Packet */*notnull*/ instance, void sp_packet_set_header(struct Packet */*notnull*/ instance,
struct Header value); struct Header value);
@ -1853,7 +1989,9 @@ bool sp_u16_to_command_code(uint16_t code,
CommandCode *result); CommandCode *result);
/** /**
*Deallocates a [UdpSocket] instance. *Deallocates a [`UdpSocket`] instance.
*
* This function is part of the sp_udp module.
*/ */
void sp_udp_free(struct UdpSocket */*notnull*/ instance); void sp_udp_free(struct UdpSocket */*notnull*/ instance);

View file

@ -1,24 +1,22 @@
macro_rules! wrap_free { macro_rules! wrap_free {
($prefix:ident :: $typ:ty) => { ($prefix:ident :: $typ:ty) => {
paste::paste! { $crate::macros::wrap_functions!($prefix;
#[doc = concat!("Deallocates a [", stringify!($typ), "] instance.")] #[doc = concat!("Deallocates a [`", stringify!($typ), "`] instance.")]
#[no_mangle] fn free(instance: NonNull<$typ>) {
pub unsafe extern "C" fn [<$prefix _free>](instance: NonNull<$typ>) {
unsafe { $crate::mem::heap_drop(instance) } unsafe { $crate::mem::heap_drop(instance) }
} }
} );
}; };
} }
macro_rules! wrap_clone { macro_rules! wrap_clone {
($prefix:ident :: $typ:ty) => { ($prefix:ident :: $typ:ty) => {
paste::paste! { $crate::macros::wrap_functions!($prefix;
#[doc = concat!("Clones a [", stringify!($typ), "] instance.")] #[doc = concat!("Clones a [`", stringify!($typ), "`] instance.")]
#[no_mangle] fn clone(instance: NonNull<$typ>) -> NonNull<$typ> {
pub unsafe extern "C" fn [<$prefix _clone>](instance: NonNull<$typ>) -> NonNull<$typ> {
unsafe { $crate::mem::heap_clone(instance) } unsafe { $crate::mem::heap_clone(instance) }
} }
} );
}; };
} }
@ -50,13 +48,13 @@ macro_rules! wrap_methods {
)+ )+
) => { ) => {
paste::paste! { paste::paste! {
$crate::macros::wrap_functions!($prefix;
$( $(
#[doc = concat!(" Calls [`servicepoint::", stringify!($object_type), #[doc = concat!(" Calls [`servicepoint::", stringify!($object_type),
"::", stringify!($function), "`].")] "::", stringify!($function), "`].")]
#[doc = ""] #[doc = ""]
$(#[$meta])* $(#[$meta])*
#[no_mangle] fn $function(
pub unsafe extern "C" fn [<$prefix _ $function>](
instance: NonNull<$object_type>, instance: NonNull<$object_type>,
$($param_name: $param_type),* $($param_name: $param_type),*
) $(-> $return_type)? { ) $(-> $return_type)? {
@ -77,6 +75,7 @@ macro_rules! wrap_methods {
return result; return result;
} }
)+ )+
);
} }
}; };
} }
@ -103,6 +102,7 @@ macro_rules! wrap_fields {
)+ )+
) => { ) => {
paste::paste! { paste::paste! {
$crate::macros::wrap_functions!($prefix;
$( $(
$( $(
#[doc = concat!(" Gets the value of field `", stringify!($prop_name), #[doc = concat!(" Gets the value of field `", stringify!($prop_name),
@ -111,8 +111,7 @@ macro_rules! wrap_fields {
#[doc = ""] #[doc = ""]
#[$get_meta] #[$get_meta]
)*)? )*)?
#[no_mangle] fn [<get _ $prop_name>](
pub unsafe extern "C" fn [<$prefix _ get _ $prop_name>](
instance: NonNull<$object_type> instance: NonNull<$object_type>
) -> $prop_type { ) -> $prop_type {
let instance = unsafe { $crate::macros::nonnull_as_ref!(instance) }; let instance = unsafe { $crate::macros::nonnull_as_ref!(instance) };
@ -131,8 +130,7 @@ macro_rules! wrap_fields {
#[doc = ""] #[doc = ""]
#[$set_meta] #[$set_meta]
)*)? )*)?
#[no_mangle] fn [<set _ $prop_name>](
pub unsafe extern "C" fn [<$prefix _ set _ $prop_name>](
instance: NonNull<$object_type>, instance: NonNull<$object_type>,
value: $prop_type, value: $prop_type,
) { ) {
@ -145,6 +143,7 @@ macro_rules! wrap_fields {
} }
)? )?
)+ )+
);
} }
}; };
} }