do not name struct in C api

This commit is contained in:
Vinzenz Schroeter 2024-10-16 18:34:21 +02:00
parent 16a0afe08d
commit 97a994fca2
2 changed files with 95 additions and 98 deletions

View file

@ -16,7 +16,7 @@ line_endings = "LF"
############################# Codegen Options ################################## ############################# Codegen Options ##################################
style = "both" style = "type"
usize_is_size_t = true usize_is_size_t = true
# this is needed because otherwise the order in the C# bindings is different on different machines # this is needed because otherwise the order in the C# bindings is different on different machines

View file

@ -196,7 +196,7 @@ typedef struct SPPacket SPPacket;
* - an instance of this created from C is never passed to a consuming function, as the rust code * - an instance of this created from C is never passed to a consuming function, as the rust code
* will try to free the memory of a potentially separate allocator. * will try to free the memory of a potentially separate allocator.
*/ */
typedef struct SPByteSlice { typedef struct {
/** /**
* The start address of the memory * The start address of the memory
*/ */
@ -229,7 +229,7 @@ extern "C" {
* - the returned instance is freed in some way, either by using a consuming function or * - the returned instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_bitmap_free`. * by explicitly calling `sp_bitmap_free`.
*/ */
struct SPBitmap *sp_bitmap_clone(const struct SPBitmap *bitmap); SPBitmap *sp_bitmap_clone(const SPBitmap *bitmap);
/** /**
* Sets the state of all pixels in the [SPBitmap]. * Sets the state of all pixels in the [SPBitmap].
@ -250,7 +250,7 @@ struct SPBitmap *sp_bitmap_clone(const struct SPBitmap *bitmap);
* - `bitmap` points to a valid [SPBitmap] * - `bitmap` points to a valid [SPBitmap]
* - `bitmap` is not written to or read from concurrently * - `bitmap` is not written to or read from concurrently
*/ */
void sp_bitmap_fill(struct SPBitmap *bitmap, bool value); void sp_bitmap_fill(SPBitmap *bitmap, bool value);
/** /**
* Deallocates a [SPBitmap]. * Deallocates a [SPBitmap].
@ -267,7 +267,7 @@ void sp_bitmap_fill(struct SPBitmap *bitmap, bool value);
* - `bitmap` is not used concurrently or after bitmap call * - `bitmap` is not used concurrently or after bitmap call
* - `bitmap` was not passed to another consuming function, e.g. to create a [SPCommand] * - `bitmap` was not passed to another consuming function, e.g. to create a [SPCommand]
*/ */
void sp_bitmap_free(struct SPBitmap *bitmap); void sp_bitmap_free(SPBitmap *bitmap);
/** /**
* Gets the current value at the specified position in the [SPBitmap]. * Gets the current value at the specified position in the [SPBitmap].
@ -289,7 +289,7 @@ void sp_bitmap_free(struct SPBitmap *bitmap);
* - `bitmap` points to a valid [SPBitmap] * - `bitmap` points to a valid [SPBitmap]
* - `bitmap` is not written to concurrently * - `bitmap` is not written to concurrently
*/ */
bool sp_bitmap_get(const struct SPBitmap *bitmap, size_t x, size_t y); bool sp_bitmap_get(const SPBitmap *bitmap, size_t x, size_t y);
/** /**
* Gets the height in pixels of the [SPBitmap] instance. * Gets the height in pixels of the [SPBitmap] instance.
@ -308,7 +308,7 @@ bool sp_bitmap_get(const struct SPBitmap *bitmap, size_t x, size_t y);
* *
* - `bitmap` points to a valid [SPBitmap] * - `bitmap` points to a valid [SPBitmap]
*/ */
size_t sp_bitmap_height(const struct SPBitmap *bitmap); size_t sp_bitmap_height(const SPBitmap *bitmap);
/** /**
* Loads a [SPBitmap] with the specified dimensions from the provided data. * Loads a [SPBitmap] with the specified dimensions from the provided data.
@ -334,7 +334,7 @@ size_t sp_bitmap_height(const struct SPBitmap *bitmap);
* - the returned instance is freed in some way, either by using a consuming function or * - the returned instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_bitmap_free`. * by explicitly calling `sp_bitmap_free`.
*/ */
struct SPBitmap *sp_bitmap_load(size_t width, SPBitmap *sp_bitmap_load(size_t width,
size_t height, size_t height,
const uint8_t *data, const uint8_t *data,
size_t data_length); size_t data_length);
@ -360,7 +360,7 @@ struct SPBitmap *sp_bitmap_load(size_t width,
* - the returned instance is freed in some way, either by using a consuming function or * - the returned instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_bitmap_free`. * by explicitly calling `sp_bitmap_free`.
*/ */
struct SPBitmap *sp_bitmap_new(size_t width, SPBitmap *sp_bitmap_new(size_t width,
size_t height); size_t height);
/** /**
@ -386,7 +386,7 @@ struct SPBitmap *sp_bitmap_new(size_t width,
* - `bitmap` points to a valid [SPBitmap] * - `bitmap` points to a valid [SPBitmap]
* - `bitmap` is not written to or read from concurrently * - `bitmap` is not written to or read from concurrently
*/ */
void sp_bitmap_set(struct SPBitmap *bitmap, size_t x, size_t y, bool value); void sp_bitmap_set(SPBitmap *bitmap, size_t x, size_t y, bool value);
/** /**
* Gets an unsafe reference to the data of the [SPBitmap] instance. * Gets an unsafe reference to the data of the [SPBitmap] instance.
@ -403,7 +403,7 @@ void sp_bitmap_set(struct SPBitmap *bitmap, size_t x, size_t y, bool value);
* - the returned memory range is never accessed after the passed [SPBitmap] has been freed * - the returned memory range is never accessed after the passed [SPBitmap] has been freed
* - the returned memory range is never accessed concurrently, either via the [SPBitmap] or directly * - the returned memory range is never accessed concurrently, either via the [SPBitmap] or directly
*/ */
struct SPByteSlice sp_bitmap_unsafe_data_ref(struct SPBitmap *bitmap); SPByteSlice sp_bitmap_unsafe_data_ref(SPBitmap *bitmap);
/** /**
* Gets the width in pixels of the [SPBitmap] instance. * Gets the width in pixels of the [SPBitmap] instance.
@ -422,7 +422,7 @@ struct SPByteSlice sp_bitmap_unsafe_data_ref(struct SPBitmap *bitmap);
* *
* - `bitmap` points to a valid [SPBitmap] * - `bitmap` points to a valid [SPBitmap]
*/ */
size_t sp_bitmap_width(const struct SPBitmap *bitmap); size_t sp_bitmap_width(const SPBitmap *bitmap);
/** /**
* Clones a [SPBitVec]. * Clones a [SPBitVec].
@ -442,7 +442,7 @@ size_t sp_bitmap_width(const struct SPBitmap *bitmap);
* - the returned instance is freed in some way, either by using a consuming function or * - the returned instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_bitvec_free`. * by explicitly calling `sp_bitvec_free`.
*/ */
struct SPBitVec *sp_bitvec_clone(const struct SPBitVec *bit_vec); SPBitVec *sp_bitvec_clone(const SPBitVec *bit_vec);
/** /**
* Sets the value of all bits in the [SPBitVec]. * Sets the value of all bits in the [SPBitVec].
@ -463,7 +463,7 @@ struct SPBitVec *sp_bitvec_clone(const struct SPBitVec *bit_vec);
* - `bit_vec` points to a valid [SPBitVec] * - `bit_vec` points to a valid [SPBitVec]
* - `bit_vec` is not written to or read from concurrently * - `bit_vec` is not written to or read from concurrently
*/ */
void sp_bitvec_fill(struct SPBitVec *bit_vec, bool value); void sp_bitvec_fill(SPBitVec *bit_vec, bool value);
/** /**
* Deallocates a [SPBitVec]. * Deallocates a [SPBitVec].
@ -480,7 +480,7 @@ void sp_bitvec_fill(struct SPBitVec *bit_vec, bool value);
* - `bit_vec` is not used concurrently or after this call * - `bit_vec` is not used concurrently or after this call
* - `bit_vec` was not passed to another consuming function, e.g. to create a [SPCommand] * - `bit_vec` was not passed to another consuming function, e.g. to create a [SPCommand]
*/ */
void sp_bitvec_free(struct SPBitVec *bit_vec); void sp_bitvec_free(SPBitVec *bit_vec);
/** /**
* Gets the value of a bit from the [SPBitVec]. * Gets the value of a bit from the [SPBitVec].
@ -504,7 +504,7 @@ void sp_bitvec_free(struct SPBitVec *bit_vec);
* - `bit_vec` points to a valid [SPBitVec] * - `bit_vec` points to a valid [SPBitVec]
* - `bit_vec` is not written to concurrently * - `bit_vec` is not written to concurrently
*/ */
bool sp_bitvec_get(const struct SPBitVec *bit_vec, size_t index); bool sp_bitvec_get(const SPBitVec *bit_vec, size_t index);
/** /**
* Returns true if length is 0. * Returns true if length is 0.
@ -523,7 +523,7 @@ bool sp_bitvec_get(const struct SPBitVec *bit_vec, size_t index);
* *
* - `bit_vec` points to a valid [SPBitVec] * - `bit_vec` points to a valid [SPBitVec]
*/ */
bool sp_bitvec_is_empty(const struct SPBitVec *bit_vec); bool sp_bitvec_is_empty(const SPBitVec *bit_vec);
/** /**
* Gets the length of the [SPBitVec] in bits. * Gets the length of the [SPBitVec] in bits.
@ -542,7 +542,7 @@ bool sp_bitvec_is_empty(const struct SPBitVec *bit_vec);
* *
* - `bit_vec` points to a valid [SPBitVec] * - `bit_vec` points to a valid [SPBitVec]
*/ */
size_t sp_bitvec_len(const struct SPBitVec *bit_vec); size_t sp_bitvec_len(const SPBitVec *bit_vec);
/** /**
* Interpret the data as a series of bits and load then into a new [SPBitVec] instance. * Interpret the data as a series of bits and load then into a new [SPBitVec] instance.
@ -562,7 +562,7 @@ size_t sp_bitvec_len(const struct SPBitVec *bit_vec);
* - the returned instance is freed in some way, either by using a consuming function or * - the returned instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_bitvec_free`. * by explicitly calling `sp_bitvec_free`.
*/ */
struct SPBitVec *sp_bitvec_load(const uint8_t *data, SPBitVec *sp_bitvec_load(const uint8_t *data,
size_t data_length); size_t data_length);
/** /**
@ -585,7 +585,7 @@ struct SPBitVec *sp_bitvec_load(const uint8_t *data,
* - the returned instance is freed in some way, either by using a consuming function or * - the returned instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_bitvec_free`. * by explicitly calling `sp_bitvec_free`.
*/ */
struct SPBitVec *sp_bitvec_new(size_t size); SPBitVec *sp_bitvec_new(size_t size);
/** /**
* Sets the value of a bit in the [SPBitVec]. * Sets the value of a bit in the [SPBitVec].
@ -608,7 +608,7 @@ struct SPBitVec *sp_bitvec_new(size_t size);
* - `bit_vec` points to a valid [SPBitVec] * - `bit_vec` points to a valid [SPBitVec]
* - `bit_vec` is not written to or read from concurrently * - `bit_vec` is not written to or read from concurrently
*/ */
void sp_bitvec_set(struct SPBitVec *bit_vec, size_t index, bool value); void sp_bitvec_set(SPBitVec *bit_vec, size_t index, bool value);
/** /**
* Gets an unsafe reference to the data of the [SPBitVec] instance. * Gets an unsafe reference to the data of the [SPBitVec] instance.
@ -629,7 +629,7 @@ void sp_bitvec_set(struct SPBitVec *bit_vec, size_t index, bool value);
* - the returned memory range is never accessed after the passed [SPBitVec] has been freed * - the returned memory range is never accessed after the passed [SPBitVec] has been freed
* - the returned memory range is never accessed concurrently, either via the [SPBitVec] or directly * - the returned memory range is never accessed concurrently, either via the [SPBitVec] or directly
*/ */
struct SPByteSlice sp_bitvec_unsafe_data_ref(struct SPBitVec *bit_vec); SPByteSlice sp_bitvec_unsafe_data_ref(SPBitVec *bit_vec);
/** /**
* Clones a [SPBrightnessGrid]. * Clones a [SPBrightnessGrid].
@ -653,7 +653,7 @@ struct SPByteSlice sp_bitvec_unsafe_data_ref(struct SPBitVec *bit_vec);
* - the returned instance is freed in some way, either by using a consuming function or * - the returned instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_brightness_grid_free`. * by explicitly calling `sp_brightness_grid_free`.
*/ */
struct SPBrightnessGrid *sp_brightness_grid_clone(const struct SPBrightnessGrid *brightness_grid); SPBrightnessGrid *sp_brightness_grid_clone(const SPBrightnessGrid *brightness_grid);
/** /**
* Sets the value of all cells in the [SPBrightnessGrid]. * Sets the value of all cells in the [SPBrightnessGrid].
@ -675,8 +675,7 @@ struct SPBrightnessGrid *sp_brightness_grid_clone(const struct SPBrightnessGrid
* - `brightness_grid` points to a valid [SPBrightnessGrid] * - `brightness_grid` points to a valid [SPBrightnessGrid]
* - `brightness_grid` is not written to or read from concurrently * - `brightness_grid` is not written to or read from concurrently
*/ */
void sp_brightness_grid_fill(struct SPBrightnessGrid *brightness_grid, void sp_brightness_grid_fill(SPBrightnessGrid *brightness_grid, uint8_t value);
uint8_t value);
/** /**
* Deallocates a [SPBrightnessGrid]. * Deallocates a [SPBrightnessGrid].
@ -697,7 +696,7 @@ void sp_brightness_grid_fill(struct SPBrightnessGrid *brightness_grid,
* - `brightness_grid` is not used concurrently or after this call * - `brightness_grid` is not used concurrently or after this call
* - `brightness_grid` was not passed to another consuming function, e.g. to create a [SPCommand] * - `brightness_grid` was not passed to another consuming function, e.g. to create a [SPCommand]
*/ */
void sp_brightness_grid_free(struct SPBrightnessGrid *brightness_grid); void sp_brightness_grid_free(SPBrightnessGrid *brightness_grid);
/** /**
* Gets the current value at the specified position. * Gets the current value at the specified position.
@ -721,7 +720,7 @@ void sp_brightness_grid_free(struct SPBrightnessGrid *brightness_grid);
* - `brightness_grid` points to a valid [SPBrightnessGrid] * - `brightness_grid` points to a valid [SPBrightnessGrid]
* - `brightness_grid` is not written to concurrently * - `brightness_grid` is not written to concurrently
*/ */
uint8_t sp_brightness_grid_get(const struct SPBrightnessGrid *brightness_grid, uint8_t sp_brightness_grid_get(const SPBrightnessGrid *brightness_grid,
size_t x, size_t x,
size_t y); size_t y);
@ -744,7 +743,7 @@ uint8_t sp_brightness_grid_get(const struct SPBrightnessGrid *brightness_grid,
* *
* - `brightness_grid` points to a valid [SPBrightnessGrid] * - `brightness_grid` points to a valid [SPBrightnessGrid]
*/ */
size_t sp_brightness_grid_height(const struct SPBrightnessGrid *brightness_grid); size_t sp_brightness_grid_height(const SPBrightnessGrid *brightness_grid);
/** /**
* Loads a [SPBrightnessGrid] with the specified dimensions from the provided data. * Loads a [SPBrightnessGrid] with the specified dimensions from the provided data.
@ -765,7 +764,7 @@ size_t sp_brightness_grid_height(const struct SPBrightnessGrid *brightness_grid)
* - the returned instance is freed in some way, either by using a consuming function or * - the returned instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_brightness_grid_free`. * by explicitly calling `sp_brightness_grid_free`.
*/ */
struct SPBrightnessGrid *sp_brightness_grid_load(size_t width, SPBrightnessGrid *sp_brightness_grid_load(size_t width,
size_t height, size_t height,
const uint8_t *data, const uint8_t *data,
size_t data_length); size_t data_length);
@ -782,7 +781,7 @@ struct SPBrightnessGrid *sp_brightness_grid_load(size_t width,
* - the returned instance is freed in some way, either by using a consuming function or * - the returned instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_brightness_grid_free`. * by explicitly calling `sp_brightness_grid_free`.
*/ */
struct SPBrightnessGrid *sp_brightness_grid_new(size_t width, SPBrightnessGrid *sp_brightness_grid_new(size_t width,
size_t height); size_t height);
/** /**
@ -809,7 +808,7 @@ struct SPBrightnessGrid *sp_brightness_grid_new(size_t width,
* - `brightness_grid` points to a valid [SPBitVec] * - `brightness_grid` points to a valid [SPBitVec]
* - `brightness_grid` is not written to or read from concurrently * - `brightness_grid` is not written to or read from concurrently
*/ */
void sp_brightness_grid_set(struct SPBrightnessGrid *brightness_grid, void sp_brightness_grid_set(SPBrightnessGrid *brightness_grid,
size_t x, size_t x,
size_t y, size_t y,
uint8_t value); uint8_t value);
@ -835,7 +834,7 @@ void sp_brightness_grid_set(struct SPBrightnessGrid *brightness_grid,
* - the returned memory range is never accessed after the passed [SPBrightnessGrid] has been freed * - the returned memory range is never accessed after the passed [SPBrightnessGrid] has been freed
* - the returned memory range is never accessed concurrently, either via the [SPBrightnessGrid] or directly * - the returned memory range is never accessed concurrently, either via the [SPBrightnessGrid] or directly
*/ */
struct SPByteSlice sp_brightness_grid_unsafe_data_ref(struct SPBrightnessGrid *brightness_grid); SPByteSlice sp_brightness_grid_unsafe_data_ref(SPBrightnessGrid *brightness_grid);
/** /**
* Gets the width of the [SPBrightnessGrid] instance. * Gets the width of the [SPBrightnessGrid] instance.
@ -856,7 +855,7 @@ struct SPByteSlice sp_brightness_grid_unsafe_data_ref(struct SPBrightnessGrid *b
* *
* - `brightness_grid` points to a valid [SPBrightnessGrid] * - `brightness_grid` points to a valid [SPBrightnessGrid]
*/ */
size_t sp_brightness_grid_width(const struct SPBrightnessGrid *brightness_grid); size_t sp_brightness_grid_width(const SPBrightnessGrid *brightness_grid);
/** /**
* Set pixel data starting at the pixel offset on screen. * Set pixel data starting at the pixel offset on screen.
@ -885,8 +884,8 @@ size_t sp_brightness_grid_width(const struct SPBrightnessGrid *brightness_grid);
* - the returned [SPCommand] instance is freed in some way, either by using a consuming function or * - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_command_free`. * by explicitly calling `sp_command_free`.
*/ */
struct SPCommand *sp_command_bitmap_linear(size_t offset, SPCommand *sp_command_bitmap_linear(size_t offset,
struct SPBitVec *bit_vec, SPBitVec *bit_vec,
SPCompressionCode compression); SPCompressionCode compression);
/** /**
@ -916,8 +915,8 @@ struct SPCommand *sp_command_bitmap_linear(size_t offset,
* - the returned [SPCommand] instance is freed in some way, either by using a consuming function or * - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_command_free`. * by explicitly calling `sp_command_free`.
*/ */
struct SPCommand *sp_command_bitmap_linear_and(size_t offset, SPCommand *sp_command_bitmap_linear_and(size_t offset,
struct SPBitVec *bit_vec, SPBitVec *bit_vec,
SPCompressionCode compression); SPCompressionCode compression);
/** /**
@ -947,8 +946,8 @@ struct SPCommand *sp_command_bitmap_linear_and(size_t offset,
* - the returned [SPCommand] instance is freed in some way, either by using a consuming function or * - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_command_free`. * by explicitly calling `sp_command_free`.
*/ */
struct SPCommand *sp_command_bitmap_linear_or(size_t offset, SPCommand *sp_command_bitmap_linear_or(size_t offset,
struct SPBitVec *bit_vec, SPBitVec *bit_vec,
SPCompressionCode compression); SPCompressionCode compression);
/** /**
@ -973,9 +972,9 @@ struct SPCommand *sp_command_bitmap_linear_or(size_t offset,
* - the returned [SPCommand] instance is freed in some way, either by using a consuming function or * - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_command_free`. * by explicitly calling `sp_command_free`.
*/ */
struct SPCommand *sp_command_bitmap_linear_win(size_t x, SPCommand *sp_command_bitmap_linear_win(size_t x,
size_t y, size_t y,
struct SPBitmap *bitmap, SPBitmap *bitmap,
SPCompressionCode compression_code); SPCompressionCode compression_code);
/** /**
@ -1005,8 +1004,8 @@ struct SPCommand *sp_command_bitmap_linear_win(size_t x,
* - the returned [SPCommand] instance is freed in some way, either by using a consuming function or * - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_command_free`. * by explicitly calling `sp_command_free`.
*/ */
struct SPCommand *sp_command_bitmap_linear_xor(size_t offset, SPCommand *sp_command_bitmap_linear_xor(size_t offset,
struct SPBitVec *bit_vec, SPBitVec *bit_vec,
SPCompressionCode compression); SPCompressionCode compression);
/** /**
@ -1025,7 +1024,7 @@ struct SPCommand *sp_command_bitmap_linear_xor(size_t offset,
* - the returned [SPCommand] instance is freed in some way, either by using a consuming function or * - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_command_free`. * by explicitly calling `sp_command_free`.
*/ */
struct SPCommand *sp_command_brightness(uint8_t brightness); SPCommand *sp_command_brightness(uint8_t brightness);
/** /**
* Set the brightness of individual tiles in a rectangular area of the display. * Set the brightness of individual tiles in a rectangular area of the display.
@ -1047,9 +1046,9 @@ struct SPCommand *sp_command_brightness(uint8_t brightness);
* - the returned [SPCommand] instance is freed in some way, either by using a consuming function or * - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_command_free`. * by explicitly calling `sp_command_free`.
*/ */
struct SPCommand *sp_command_char_brightness(size_t x, SPCommand *sp_command_char_brightness(size_t x,
size_t y, size_t y,
struct SPBrightnessGrid *grid); SPBrightnessGrid *grid);
/** /**
* Set all pixels to the off state. * Set all pixels to the off state.
@ -1071,7 +1070,7 @@ struct SPCommand *sp_command_char_brightness(size_t x,
* - the returned [SPCommand] instance is freed in some way, either by using a consuming function or * - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_command_free`. * by explicitly calling `sp_command_free`.
*/ */
struct SPCommand *sp_command_clear(void); SPCommand *sp_command_clear(void);
/** /**
* Clones a [SPCommand] instance. * Clones a [SPCommand] instance.
@ -1091,7 +1090,7 @@ struct SPCommand *sp_command_clear(void);
* - the returned [SPCommand] instance is freed in some way, either by using a consuming function or * - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_command_free`. * by explicitly calling `sp_command_free`.
*/ */
struct SPCommand *sp_command_clone(const struct SPCommand *command); SPCommand *sp_command_clone(const SPCommand *command);
/** /**
* Show text on the screen. * Show text on the screen.
@ -1113,9 +1112,9 @@ struct SPCommand *sp_command_clone(const struct SPCommand *command);
* - the returned [SPCommand] instance is freed in some way, either by using a consuming function or * - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_command_free`. * by explicitly calling `sp_command_free`.
*/ */
struct SPCommand *sp_command_cp437_data(size_t x, SPCommand *sp_command_cp437_data(size_t x,
size_t y, size_t y,
struct SPCp437Grid *grid); SPCp437Grid *grid);
/** /**
* A yet-to-be-tested command. * A yet-to-be-tested command.
@ -1129,7 +1128,7 @@ struct SPCommand *sp_command_cp437_data(size_t x,
* - the returned [SPCommand] instance is freed in some way, either by using a consuming function or * - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_command_free`. * by explicitly calling `sp_command_free`.
*/ */
struct SPCommand *sp_command_fade_out(void); SPCommand *sp_command_fade_out(void);
/** /**
* Deallocates a [SPCommand]. * Deallocates a [SPCommand].
@ -1153,7 +1152,7 @@ struct SPCommand *sp_command_fade_out(void);
* - `command` is not used concurrently or after this call * - `command` is not used concurrently or after this call
* - `command` was not passed to another consuming function, e.g. to create a [SPPacket] * - `command` was not passed to another consuming function, e.g. to create a [SPPacket]
*/ */
void sp_command_free(struct SPCommand *command); void sp_command_free(SPCommand *command);
/** /**
* Kills the udp daemon on the display, which usually results in a restart. * Kills the udp daemon on the display, which usually results in a restart.
@ -1169,7 +1168,7 @@ void sp_command_free(struct SPCommand *command);
* - the returned [SPCommand] instance is freed in some way, either by using a consuming function or * - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_command_free`. * by explicitly calling `sp_command_free`.
*/ */
struct SPCommand *sp_command_hard_reset(void); SPCommand *sp_command_hard_reset(void);
/** /**
* Tries to turn a [SPPacket] into a [SPCommand]. * Tries to turn a [SPPacket] into a [SPCommand].
@ -1192,7 +1191,7 @@ struct SPCommand *sp_command_hard_reset(void);
* - the returned [SPCommand] instance is freed in some way, either by using a consuming function or * - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_command_free`. * by explicitly calling `sp_command_free`.
*/ */
struct SPCommand *sp_command_try_from_packet(struct SPPacket *packet); SPCommand *sp_command_try_from_packet(SPPacket *packet);
/** /**
* Closes and deallocates a [SPConnection]. * Closes and deallocates a [SPConnection].
@ -1208,7 +1207,7 @@ struct SPCommand *sp_command_try_from_packet(struct SPPacket *packet);
* - `connection` points to a valid [SPConnection] * - `connection` points to a valid [SPConnection]
* - `connection` is not used concurrently or after this call * - `connection` is not used concurrently or after this call
*/ */
void sp_connection_free(struct SPConnection *connection); void sp_connection_free(SPConnection *connection);
/** /**
* Creates a new instance of [SPConnection]. * Creates a new instance of [SPConnection].
@ -1226,7 +1225,7 @@ void sp_connection_free(struct SPConnection *connection);
* - the returned instance is freed in some way, either by using a consuming function or * - the returned instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_connection_free`. * by explicitly calling `sp_connection_free`.
*/ */
struct SPConnection *sp_connection_open(const char *host); SPConnection *sp_connection_open(const char *host);
/** /**
* Sends a [SPCommand] to the display using the [SPConnection]. * Sends a [SPCommand] to the display using the [SPConnection].
@ -1248,8 +1247,8 @@ struct SPConnection *sp_connection_open(const char *host);
* - `command` points to a valid instance of [SPPacket] * - `command` points to a valid instance of [SPPacket]
* - `command` is not used concurrently or after this call * - `command` is not used concurrently or after this call
*/ */
bool sp_connection_send_command(const struct SPConnection *connection, bool sp_connection_send_command(const SPConnection *connection,
struct SPCommand *command); SPCommand *command);
/** /**
* Sends a [SPPacket] to the display using the [SPConnection]. * Sends a [SPPacket] to the display using the [SPConnection].
@ -1271,8 +1270,8 @@ bool sp_connection_send_command(const struct SPConnection *connection,
* - `packet` points to a valid instance of [SPPacket] * - `packet` points to a valid instance of [SPPacket]
* - `packet` is not used concurrently or after this call * - `packet` is not used concurrently or after this call
*/ */
bool sp_connection_send_packet(const struct SPConnection *connection, bool sp_connection_send_packet(const SPConnection *connection,
struct SPPacket *packet); SPPacket *packet);
/** /**
* Clones a [SPCp437Grid]. * Clones a [SPCp437Grid].
@ -1292,7 +1291,7 @@ bool sp_connection_send_packet(const struct SPConnection *connection,
* - the returned instance is freed in some way, either by using a consuming function or * - the returned instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_cp437_grid_free`. * by explicitly calling `sp_cp437_grid_free`.
*/ */
struct SPCp437Grid *sp_cp437_grid_clone(const struct SPCp437Grid *cp437_grid); SPCp437Grid *sp_cp437_grid_clone(const SPCp437Grid *cp437_grid);
/** /**
* Sets the value of all cells in the [SPCp437Grid]. * Sets the value of all cells in the [SPCp437Grid].
@ -1313,7 +1312,7 @@ struct SPCp437Grid *sp_cp437_grid_clone(const struct SPCp437Grid *cp437_grid);
* - `cp437_grid` points to a valid [SPCp437Grid] * - `cp437_grid` points to a valid [SPCp437Grid]
* - `cp437_grid` is not written to or read from concurrently * - `cp437_grid` is not written to or read from concurrently
*/ */
void sp_cp437_grid_fill(struct SPCp437Grid *cp437_grid, uint8_t value); void sp_cp437_grid_fill(SPCp437Grid *cp437_grid, uint8_t value);
/** /**
* Deallocates a [SPCp437Grid]. * Deallocates a [SPCp437Grid].
@ -1330,7 +1329,7 @@ void sp_cp437_grid_fill(struct SPCp437Grid *cp437_grid, uint8_t value);
* - `cp437_grid` is not used concurrently or after cp437_grid call * - `cp437_grid` is not used concurrently or after cp437_grid call
* - `cp437_grid` was not passed to another consuming function, e.g. to create a [SPCommand] * - `cp437_grid` was not passed to another consuming function, e.g. to create a [SPCommand]
*/ */
void sp_cp437_grid_free(struct SPCp437Grid *cp437_grid); void sp_cp437_grid_free(SPCp437Grid *cp437_grid);
/** /**
* Gets the current value at the specified position. * Gets the current value at the specified position.
@ -1352,9 +1351,7 @@ void sp_cp437_grid_free(struct SPCp437Grid *cp437_grid);
* - `cp437_grid` points to a valid [SPCp437Grid] * - `cp437_grid` points to a valid [SPCp437Grid]
* - `cp437_grid` is not written to concurrently * - `cp437_grid` is not written to concurrently
*/ */
uint8_t sp_cp437_grid_get(const struct SPCp437Grid *cp437_grid, uint8_t sp_cp437_grid_get(const SPCp437Grid *cp437_grid, size_t x, size_t y);
size_t x,
size_t y);
/** /**
* Gets the height of the [SPCp437Grid] instance. * Gets the height of the [SPCp437Grid] instance.
@ -1373,7 +1370,7 @@ uint8_t sp_cp437_grid_get(const struct SPCp437Grid *cp437_grid,
* *
* - `cp437_grid` points to a valid [SPCp437Grid] * - `cp437_grid` points to a valid [SPCp437Grid]
*/ */
size_t sp_cp437_grid_height(const struct SPCp437Grid *cp437_grid); size_t sp_cp437_grid_height(const SPCp437Grid *cp437_grid);
/** /**
* Loads a [SPCp437Grid] with the specified dimensions from the provided data. * Loads a [SPCp437Grid] with the specified dimensions from the provided data.
@ -1394,7 +1391,7 @@ size_t sp_cp437_grid_height(const struct SPCp437Grid *cp437_grid);
* - the returned instance is freed in some way, either by using a consuming function or * - the returned instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_cp437_grid_free`. * by explicitly calling `sp_cp437_grid_free`.
*/ */
struct SPCp437Grid *sp_cp437_grid_load(size_t width, SPCp437Grid *sp_cp437_grid_load(size_t width,
size_t height, size_t height,
const uint8_t *data, const uint8_t *data,
size_t data_length); size_t data_length);
@ -1411,7 +1408,7 @@ struct SPCp437Grid *sp_cp437_grid_load(size_t width,
* - the returned instance is freed in some way, either by using a consuming function or * - the returned instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_cp437_grid_free`. * by explicitly calling `sp_cp437_grid_free`.
*/ */
struct SPCp437Grid *sp_cp437_grid_new(size_t width, SPCp437Grid *sp_cp437_grid_new(size_t width,
size_t height); size_t height);
/** /**
@ -1437,7 +1434,7 @@ struct SPCp437Grid *sp_cp437_grid_new(size_t width,
* - `cp437_grid` points to a valid [SPBitVec] * - `cp437_grid` points to a valid [SPBitVec]
* - `cp437_grid` is not written to or read from concurrently * - `cp437_grid` is not written to or read from concurrently
*/ */
void sp_cp437_grid_set(struct SPCp437Grid *cp437_grid, void sp_cp437_grid_set(SPCp437Grid *cp437_grid,
size_t x, size_t x,
size_t y, size_t y,
uint8_t value); uint8_t value);
@ -1459,7 +1456,7 @@ void sp_cp437_grid_set(struct SPCp437Grid *cp437_grid,
* - the returned memory range is never accessed after the passed [SPCp437Grid] has been freed * - the returned memory range is never accessed after the passed [SPCp437Grid] has been freed
* - the returned memory range is never accessed concurrently, either via the [SPCp437Grid] or directly * - the returned memory range is never accessed concurrently, either via the [SPCp437Grid] or directly
*/ */
struct SPByteSlice sp_cp437_grid_unsafe_data_ref(struct SPCp437Grid *cp437_grid); SPByteSlice sp_cp437_grid_unsafe_data_ref(SPCp437Grid *cp437_grid);
/** /**
* Gets the width of the [SPCp437Grid] instance. * Gets the width of the [SPCp437Grid] instance.
@ -1478,7 +1475,7 @@ struct SPByteSlice sp_cp437_grid_unsafe_data_ref(struct SPCp437Grid *cp437_grid)
* *
* - `cp437_grid` points to a valid [SPCp437Grid] * - `cp437_grid` points to a valid [SPCp437Grid]
*/ */
size_t sp_cp437_grid_width(const struct SPCp437Grid *cp437_grid); size_t sp_cp437_grid_width(const SPCp437Grid *cp437_grid);
/** /**
* Clones a [SPPacket]. * Clones a [SPPacket].
@ -1498,7 +1495,7 @@ size_t sp_cp437_grid_width(const struct SPCp437Grid *cp437_grid);
* - the returned instance is freed in some way, either by using a consuming function or * - the returned instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_packet_free`. * by explicitly calling `sp_packet_free`.
*/ */
struct SPPacket *sp_packet_clone(const struct SPPacket *packet); SPPacket *sp_packet_clone(const SPPacket *packet);
/** /**
* Deallocates a [SPPacket]. * Deallocates a [SPPacket].
@ -1514,7 +1511,7 @@ struct SPPacket *sp_packet_clone(const struct SPPacket *packet);
* - `packet` points to a valid [SPPacket] * - `packet` points to a valid [SPPacket]
* - `packet` is not used concurrently or after this call * - `packet` is not used concurrently or after this call
*/ */
void sp_packet_free(struct SPPacket *packet); void sp_packet_free(SPPacket *packet);
/** /**
* Turns a [SPCommand] into a [SPPacket]. * Turns a [SPCommand] into a [SPPacket].
@ -1535,7 +1532,7 @@ void sp_packet_free(struct SPPacket *packet);
* - the returned [SPPacket] instance is freed in some way, either by using a consuming function or * - the returned [SPPacket] instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_packet_free`. * by explicitly calling `sp_packet_free`.
*/ */
struct SPPacket *sp_packet_from_command(struct SPCommand *command); SPPacket *sp_packet_from_command(SPCommand *command);
/** /**
* Tries to load a [SPPacket] from the passed array with the specified length. * Tries to load a [SPPacket] from the passed array with the specified length.
@ -1555,7 +1552,7 @@ struct SPPacket *sp_packet_from_command(struct SPCommand *command);
* - the returned [SPPacket] instance is freed in some way, either by using a consuming function or * - the returned [SPPacket] instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_packet_free`. * by explicitly calling `sp_packet_free`.
*/ */
struct SPPacket *sp_packet_try_load(const uint8_t *data, SPPacket *sp_packet_try_load(const uint8_t *data,
size_t length); size_t length);
#ifdef __cplusplus #ifdef __cplusplus