replace usages of 'this' as parameter name

This commit is contained in:
Vinzenz Schroeter 2024-09-07 15:06:11 +02:00
parent 3e3a933ecb
commit e46391ca5f
9 changed files with 506 additions and 427 deletions

View file

@ -203,28 +203,29 @@ extern "C" {
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPBitVec`
* - `this` is not written to concurrently
* - `bit_vec` points to a valid `SPBitVec`
* - `bit_vec` is not written to concurrently
* - the returned instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_bit_vec_free`.
*/
struct SPBitVec *sp_bit_vec_clone(const struct SPBitVec *this_);
struct SPBitVec *sp_bit_vec_clone(const struct SPBitVec *bit_vec);
/**
* Sets the value of all bits in the `SPBitVec`.
*
* # Arguments
*
* - `bit_vec`: instance to write to
* - `value`: the value to set all bits to
*
* # Safety
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPBitVec`
* - `this` is not written to or read from concurrently
* - `bit_vec` points to a valid `SPBitVec`
* - `bit_vec` is not written to or read from concurrently
*/
void sp_bit_vec_fill(struct SPBitVec *this_, bool value);
void sp_bit_vec_fill(struct SPBitVec *bit_vec, bool value);
/**
* Deallocates a `SPBitVec`.
@ -233,18 +234,18 @@ void sp_bit_vec_fill(struct SPBitVec *this_, bool value);
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPBitVec`
* - `this` is not used concurrently or after this call
* - `this` was not passed to another consuming function, e.g. to create a `SPCommand`
* - `bit_vec` points to a valid `SPBitVec`
* - `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`
*/
void sp_bit_vec_free(struct SPBitVec *this_);
void sp_bit_vec_free(struct SPBitVec *bit_vec);
/**
* Gets the value of a bit from the `SPBitVec`.
*
* # Arguments
*
* - `this`: instance to read from
* - `bit_vec`: instance to read from
* - `index`: the bit index to read
*
* returns: value of the bit
@ -257,32 +258,40 @@ void sp_bit_vec_free(struct SPBitVec *this_);
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPBitVec`
* - `this` is not written to concurrently
* - `bit_vec` points to a valid `SPBitVec`
* - `bit_vec` is not written to concurrently
*/
bool sp_bit_vec_get(const struct SPBitVec *this_, size_t index);
bool sp_bit_vec_get(const struct SPBitVec *bit_vec, size_t index);
/**
* Returns true if length is 0.
*
* # Arguments
*
* - `bit_vec`: instance to write to
*
* # Safety
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPBitVec`
* - `bit_vec` points to a valid `SPBitVec`
*/
bool sp_bit_vec_is_empty(const struct SPBitVec *this_);
bool sp_bit_vec_is_empty(const struct SPBitVec *bit_vec);
/**
* Gets the length of the `SPBitVec` in bits.
*
* # Arguments
*
* - `bit_vec`: instance to write to
*
* # Safety
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPBitVec`
* - `bit_vec` points to a valid `SPBitVec`
*/
size_t sp_bit_vec_len(const struct SPBitVec *this_);
size_t sp_bit_vec_len(const struct SPBitVec *bit_vec);
/**
* Interpret the data as a series of bits and load then into a new `SPBitVec` instance.
@ -326,7 +335,7 @@ struct SPBitVec *sp_bit_vec_new(size_t size);
*
* # Arguments
*
* - `this`: instance to write to
* - `bit_vec`: instance to write to
* - `index`: the bit index to edit
* - `value`: the value to set the bit to
*
@ -340,44 +349,52 @@ struct SPBitVec *sp_bit_vec_new(size_t size);
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPBitVec`
* - `this` is not written to or read from concurrently
* - `bit_vec` points to a valid `SPBitVec`
* - `bit_vec` is not written to or read from concurrently
*/
void sp_bit_vec_set(struct SPBitVec *this_, size_t index, bool value);
void sp_bit_vec_set(struct SPBitVec *bit_vec, size_t index, bool value);
/**
* Gets an unsafe reference to the data of the `SPBitVec` instance.
*
* # Arguments
*
* - `bit_vec`: instance to write to
*
* ## Safety
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPBitVec`
* - `bit_vec` points to a valid `SPBitVec`
* - 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
*/
struct SPByteSlice sp_bit_vec_unsafe_data_ref(struct SPBitVec *this_);
struct SPByteSlice sp_bit_vec_unsafe_data_ref(struct SPBitVec *bit_vec);
/**
* Clones a `SPBrightnessGrid`.
*
* # Arguments
*
* - `brightness_grid`: instance to read from
*
* # Safety
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPBrightnessGrid`
* - `this` is not written to concurrently
* - `brightness_grid` points to a valid `SPBrightnessGrid`
* - `brightness_grid` is not written to concurrently
* - the returned instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_brightness_grid_free`.
*/
struct SPBrightnessGrid *sp_brightness_grid_clone(const struct SPBrightnessGrid *this_);
struct SPBrightnessGrid *sp_brightness_grid_clone(const struct SPBrightnessGrid *brightness_grid);
/**
* Sets the value of all cells in the `SPBrightnessGrid`.
*
* # Arguments
*
* - `this`: instance to write to
* - `brightness_grid`: instance to write to
* - `value`: the value to set all cells to
*
* # Panics
@ -388,30 +405,35 @@ struct SPBrightnessGrid *sp_brightness_grid_clone(const struct SPBrightnessGrid
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPBrightnessGrid`
* - `this` is not written to or read from concurrently
* - `brightness_grid` points to a valid `SPBrightnessGrid`
* - `brightness_grid` is not written to or read from concurrently
*/
void sp_brightness_grid_fill(struct SPBrightnessGrid *this_, uint8_t value);
void sp_brightness_grid_fill(struct SPBrightnessGrid *brightness_grid,
uint8_t value);
/**
* Deallocates a `SPBrightnessGrid`.
*
* # Arguments
*
* - `brightness_grid`: instance to read from
*
* # Safety
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPBrightnessGrid`
* - `this` is not used concurrently or after this call
* - `this` was not passed to another consuming function, e.g. to create a `SPCommand`
* - `brightness_grid` points to a valid `SPBrightnessGrid`
* - `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`
*/
void sp_brightness_grid_free(struct SPBrightnessGrid *this_);
void sp_brightness_grid_free(struct SPBrightnessGrid *brightness_grid);
/**
* Gets the current value at the specified position.
*
* # Arguments
*
* - `this`: instance to read from
* - `brightness_grid`: instance to read from
* - `x` and `y`: position of the cell to read
*
* # Panics
@ -422,10 +444,10 @@ void sp_brightness_grid_free(struct SPBrightnessGrid *this_);
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPBrightnessGrid`
* - `this` is not written to concurrently
* - `brightness_grid` points to a valid `SPBrightnessGrid`
* - `brightness_grid` is not written to concurrently
*/
uint8_t sp_brightness_grid_get(const struct SPBrightnessGrid *this_,
uint8_t sp_brightness_grid_get(const struct SPBrightnessGrid *brightness_grid,
size_t x,
size_t y);
@ -434,15 +456,15 @@ uint8_t sp_brightness_grid_get(const struct SPBrightnessGrid *this_,
*
* # Arguments
*
* - `this`: instance to read from
* - `brightness_grid`: instance to read from
*
* # Safety
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPBrightnessGrid`
* - `brightness_grid` points to a valid `SPBrightnessGrid`
*/
size_t sp_brightness_grid_height(const struct SPBrightnessGrid *this_);
size_t sp_brightness_grid_height(const struct SPBrightnessGrid *brightness_grid);
/**
* Loads a `SPBrightnessGrid` with the specified dimensions from the provided data.
@ -485,7 +507,7 @@ struct SPBrightnessGrid *sp_brightness_grid_new(size_t width,
*
* # Arguments
*
* - `this`: instance to write to
* - `brightness_grid`: instance to write to
* - `x` and `y`: position of the cell
* - `value`: the value to write to the cell
*
@ -500,10 +522,10 @@ struct SPBrightnessGrid *sp_brightness_grid_new(size_t width,
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPBitVec`
* - `this` is not written to or read from concurrently
* - `brightness_grid` points to a valid `SPBitVec`
* - `brightness_grid` is not written to or read from concurrently
*/
void sp_brightness_grid_set(struct SPBrightnessGrid *this_,
void sp_brightness_grid_set(struct SPBrightnessGrid *brightness_grid,
size_t x,
size_t y,
uint8_t value);
@ -511,30 +533,34 @@ void sp_brightness_grid_set(struct SPBrightnessGrid *this_,
/**
* Gets an unsafe reference to the data of the `SPBrightnessGrid` instance.
*
* # Arguments
*
* - `brightness_grid`: instance to read from
*
* ## Safety
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPBrightnessGrid`
* - `brightness_grid` points to a valid `SPBrightnessGrid`
* - 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
*/
struct SPByteSlice sp_brightness_grid_unsafe_data_ref(struct SPBrightnessGrid *this_);
struct SPByteSlice sp_brightness_grid_unsafe_data_ref(struct SPBrightnessGrid *brightness_grid);
/**
* Gets the width of the `SPBrightnessGrid` instance.
*
* # Arguments
*
* - `this`: instance to read from
* - `brightness_grid`: instance to read from
*
* # Safety
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPBrightnessGrid`
* - `brightness_grid` points to a valid `SPBrightnessGrid`
*/
size_t sp_brightness_grid_width(const struct SPBrightnessGrid *this_);
size_t sp_brightness_grid_width(const struct SPBrightnessGrid *brightness_grid);
/**
* Set pixel data starting at the pixel offset on screen.
@ -729,12 +755,12 @@ struct SPCommand *sp_command_clear(void);
*
* The caller has to make sure that:
*
* - `this` points to a valid instance of `SPCommand`
* - `this` is not written to concurrently
* - `command` points to a valid instance of `SPCommand`
* - `command` is not written to concurrently
* - the returned `SPCommand` instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_command_free`.
*/
struct SPCommand *sp_command_clone(const struct SPCommand *original);
struct SPCommand *sp_command_clone(const struct SPCommand *command);
/**
* Show text on the screen.
@ -789,11 +815,11 @@ struct SPCommand *sp_command_fade_out(void);
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPCommand`
* - `this` is not used concurrently or after this call
* - `this` was not passed to another consuming function, e.g. to create a `SPPacket`
* - `command` points to a valid `SPCommand`
* - `command` is not used concurrently or after this call
* - `command` was not passed to another consuming function, e.g. to create a `SPPacket`
*/
void sp_command_free(struct SPCommand *ptr);
void sp_command_free(struct SPCommand *command);
/**
* Kills the udp daemon on the display, which usually results in a restart.
@ -837,10 +863,10 @@ struct SPCommand *sp_command_try_from_packet(struct SPPacket *packet);
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPConnection`
* - `this` is not used concurrently or after this call
* - `connection` points to a valid `SPConnection`
* - `connection` is not used concurrently or after this call
*/
void sp_connection_free(struct SPConnection *ptr);
void sp_connection_free(struct SPConnection *connection);
/**
* Creates a new instance of `SPConnection`.
@ -863,7 +889,7 @@ struct SPConnection *sp_connection_open(const char *host);
/**
* Sends a `SPCommand` to the display using the `SPConnection`.
*
* The passed `SPCommand` gets consumed.
* The passed `command` gets consumed.
*
* returns: true in case of success
*
@ -881,7 +907,7 @@ bool sp_connection_send_command(const struct SPConnection *connection,
/**
* Sends a `SPPacket` to the display using the `SPConnection`.
*
* The passed `SPPacket` gets consumed.
* The passed `packet` gets consumed.
*
* returns: true in case of success
*
@ -889,9 +915,9 @@ bool sp_connection_send_command(const struct SPConnection *connection,
*
* The caller has to make sure that:
*
* - `SPConnection` points to a valid instance of `SPConnection`
* - `SPPacket` points to a valid instance of `SPPacket`
* - `SPPacket` is not used concurrently or after this call
* - `connection` points to a valid instance of `SPConnection`
* - `packet` points to a valid instance of `SPPacket`
* - `packet` is not used concurrently or after this call
*/
bool sp_connection_send_packet(const struct SPConnection *connection,
struct SPPacket *packet);
@ -905,29 +931,29 @@ bool sp_connection_send_packet(const struct SPConnection *connection,
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPCp437Grid`
* - `this` is not written to concurrently
* - `cp437_grid` points to a valid `SPCp437Grid`
* - `cp437_grid` is not written to concurrently
* - the returned instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_cp437_grid_free`.
*/
struct SPCp437Grid *sp_cp437_grid_clone(const struct SPCp437Grid *this_);
struct SPCp437Grid *sp_cp437_grid_clone(const struct SPCp437Grid *cp437_grid);
/**
* Sets the value of all cells in the `SPCp437Grid`.
*
* # Arguments
*
* - `this`: instance to write to
* - `cp437_grid`: instance to write to
* - `value`: the value to set all cells to
*
* # Safety
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPCp437Grid`
* - `this` is not written to or read from concurrently
* - `cp437_grid` points to a valid `SPCp437Grid`
* - `cp437_grid` is not written to or read from concurrently
*/
void sp_cp437_grid_fill(struct SPCp437Grid *this_, uint8_t value);
void sp_cp437_grid_fill(struct SPCp437Grid *cp437_grid, uint8_t value);
/**
* Deallocates a `SPCp437Grid`.
@ -936,18 +962,18 @@ void sp_cp437_grid_fill(struct SPCp437Grid *this_, uint8_t value);
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPCp437Grid`
* - `this` is not used concurrently or after this call
* - `this` was not passed to another consuming function, e.g. to create a `SPCommand`
* - `cp437_grid` points to a valid `SPCp437Grid`
* - `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`
*/
void sp_cp437_grid_free(struct SPCp437Grid *this_);
void sp_cp437_grid_free(struct SPCp437Grid *cp437_grid);
/**
* Gets the current value at the specified position.
*
* # Arguments
*
* - `this`: instance to read from
* - `cp437_grid`: instance to read from
* - `x` and `y`: position of the cell to read
*
* # Panics
@ -958,25 +984,27 @@ void sp_cp437_grid_free(struct SPCp437Grid *this_);
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPCp437Grid`
* - `this` is not written to concurrently
* - `cp437_grid` points to a valid `SPCp437Grid`
* - `cp437_grid` is not written to concurrently
*/
uint8_t sp_cp437_grid_get(const struct SPCp437Grid *this_, size_t x, size_t y);
uint8_t sp_cp437_grid_get(const struct SPCp437Grid *cp437_grid,
size_t x,
size_t y);
/**
* Gets the height of the `SPCp437Grid` instance.
*
* # Arguments
*
* - `this`: instance to read from
* - `cp437_grid`: instance to read from
*
* # Safety
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPCp437Grid`
* - `cp437_grid` points to a valid `SPCp437Grid`
*/
size_t sp_cp437_grid_height(const struct SPCp437Grid *this_);
size_t sp_cp437_grid_height(const struct SPCp437Grid *cp437_grid);
/**
* Loads a `SPCp437Grid` with the specified dimensions from the provided data.
@ -1021,7 +1049,7 @@ struct SPCp437Grid *sp_cp437_grid_new(size_t width,
*
* # Arguments
*
* - `this`: instance to write to
* - `cp437_grid`: instance to write to
* - `x` and `y`: position of the cell
* - `value`: the value to write to the cell
*
@ -1035,10 +1063,10 @@ struct SPCp437Grid *sp_cp437_grid_new(size_t width,
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPBitVec`
* - `this` is not written to or read from concurrently
* - `cp437_grid` points to a valid `SPBitVec`
* - `cp437_grid` is not written to or read from concurrently
*/
void sp_cp437_grid_set(struct SPCp437Grid *this_,
void sp_cp437_grid_set(struct SPCp437Grid *cp437_grid,
size_t x,
size_t y,
uint8_t value);
@ -1052,26 +1080,26 @@ void sp_cp437_grid_set(struct SPCp437Grid *this_,
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPCp437Grid`
* - `cp437_grid` points to a valid `SPCp437Grid`
* - 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
*/
struct SPByteSlice sp_cp437_grid_unsafe_data_ref(struct SPCp437Grid *this_);
struct SPByteSlice sp_cp437_grid_unsafe_data_ref(struct SPCp437Grid *cp437_grid);
/**
* Gets the width of the `SPCp437Grid` instance.
*
* # Arguments
*
* - `this`: instance to read from
* - `cp437_grid`: instance to read from
*
* # Safety
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPCp437Grid`
* - `cp437_grid` points to a valid `SPCp437Grid`
*/
size_t sp_cp437_grid_width(const struct SPCp437Grid *this_);
size_t sp_cp437_grid_width(const struct SPCp437Grid *cp437_grid);
/**
* Clones a `SPPacket`.
@ -1082,12 +1110,12 @@ size_t sp_cp437_grid_width(const struct SPCp437Grid *this_);
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPPacket`
* - `this` is not written to concurrently
* - `packet` points to a valid `SPPacket`
* - `packet` is not written to concurrently
* - the returned instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_packet_free`.
*/
struct SPPacket *sp_packet_clone(const struct SPPacket *this_);
struct SPPacket *sp_packet_clone(const struct SPPacket *packet);
/**
* Deallocates a `SPPacket`.
@ -1096,10 +1124,10 @@ struct SPPacket *sp_packet_clone(const struct SPPacket *this_);
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPPacket`
* - `this` is not used concurrently or after this call
* - `packet` points to a valid `SPPacket`
* - `packet` is not used concurrently or after this call
*/
void sp_packet_free(struct SPPacket *this_);
void sp_packet_free(struct SPPacket *packet);
/**
* Turns a `SPCommand` into a `SPPacket`.
@ -1144,29 +1172,29 @@ struct SPPacket *sp_packet_try_load(const uint8_t *data,
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPPixelGrid`
* - `this` is not written to concurrently
* - `pixel_grid` points to a valid `SPPixelGrid`
* - `pixel_grid` is not written to concurrently
* - the returned instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_pixel_grid_free`.
*/
struct SPPixelGrid *sp_pixel_grid_clone(const struct SPPixelGrid *this_);
struct SPPixelGrid *sp_pixel_grid_clone(const struct SPPixelGrid *pixel_grid);
/**
* Sets the state of all pixels in the `SPPixelGrid`.
*
* # Arguments
*
* - `this`: instance to write to
* - `pixel_grid`: instance to write to
* - `value`: the value to set all pixels to
*
* # Safety
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPPixelGrid`
* - `this` is not written to or read from concurrently
* - `pixel_grid` points to a valid `SPPixelGrid`
* - `pixel_grid` is not written to or read from concurrently
*/
void sp_pixel_grid_fill(struct SPPixelGrid *this_, bool value);
void sp_pixel_grid_fill(struct SPPixelGrid *pixel_grid, bool value);
/**
* Deallocates a `SPPixelGrid`.
@ -1175,18 +1203,18 @@ void sp_pixel_grid_fill(struct SPPixelGrid *this_, bool value);
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPPixelGrid`
* - `this` is not used concurrently or after this call
* - `this` was not passed to another consuming function, e.g. to create a `SPCommand`
* - `pixel_grid` points to a valid `SPPixelGrid`
* - `pixel_grid` is not used concurrently or after pixel_grid call
* - `pixel_grid` was not passed to another consuming function, e.g. to create a `SPCommand`
*/
void sp_pixel_grid_free(struct SPPixelGrid *this_);
void sp_pixel_grid_free(struct SPPixelGrid *pixel_grid);
/**
* Gets the current value at the specified position in the `SPPixelGrid`.
*
* # Arguments
*
* - `this`: instance to read from
* - `pixel_grid`: instance to read from
* - `x` and `y`: position of the cell to read
*
* # Panics
@ -1197,25 +1225,27 @@ void sp_pixel_grid_free(struct SPPixelGrid *this_);
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPPixelGrid`
* - `this` is not written to concurrently
* - `pixel_grid` points to a valid `SPPixelGrid`
* - `pixel_grid` is not written to concurrently
*/
bool sp_pixel_grid_get(const struct SPPixelGrid *this_, size_t x, size_t y);
bool sp_pixel_grid_get(const struct SPPixelGrid *pixel_grid,
size_t x,
size_t y);
/**
* Gets the height in pixels of the `SPPixelGrid` instance.
*
* # Arguments
*
* - `this`: instance to read from
* - `pixel_grid`: instance to read from
*
* # Safety
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPPixelGrid`
* - `pixel_grid` points to a valid `SPPixelGrid`
*/
size_t sp_pixel_grid_height(const struct SPPixelGrid *this_);
size_t sp_pixel_grid_height(const struct SPPixelGrid *pixel_grid);
/**
* Loads a `SPPixelGrid` with the specified dimensions from the provided data.
@ -1274,7 +1304,7 @@ struct SPPixelGrid *sp_pixel_grid_new(size_t width,
*
* # Arguments
*
* - `this`: instance to write to
* - `pixel_grid`: instance to write to
* - `x` and `y`: position of the cell
* - `value`: the value to write to the cell
*
@ -1288,10 +1318,10 @@ struct SPPixelGrid *sp_pixel_grid_new(size_t width,
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPPixelGrid`
* - `this` is not written to or read from concurrently
* - `pixel_grid` points to a valid `SPPixelGrid`
* - `pixel_grid` is not written to or read from concurrently
*/
void sp_pixel_grid_set(struct SPPixelGrid *this_,
void sp_pixel_grid_set(struct SPPixelGrid *pixel_grid,
size_t x,
size_t y,
bool value);
@ -1303,26 +1333,26 @@ void sp_pixel_grid_set(struct SPPixelGrid *this_,
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPPixelGrid`
* - `pixel_grid` points to a valid `SPPixelGrid`
* - the returned memory range is never accessed after the passed `SPPixelGrid` has been freed
* - the returned memory range is never accessed concurrently, either via the `SPPixelGrid` or directly
*/
struct SPByteSlice sp_pixel_grid_unsafe_data_ref(struct SPPixelGrid *this_);
struct SPByteSlice sp_pixel_grid_unsafe_data_ref(struct SPPixelGrid *pixel_grid);
/**
* Gets the width in pixels of the `SPPixelGrid` instance.
*
* # Arguments
*
* - `this`: instance to read from
* - `pixel_grid`: instance to read from
*
* # Safety
*
* The caller has to make sure that:
*
* - `this` points to a valid `SPPixelGrid`
* - `pixel_grid` points to a valid `SPPixelGrid`
*/
size_t sp_pixel_grid_width(const struct SPPixelGrid *this_);
size_t sp_pixel_grid_width(const struct SPPixelGrid *pixel_grid);
#ifdef __cplusplus
} // extern "C"

View file

@ -81,15 +81,15 @@ pub unsafe extern "C" fn sp_bit_vec_load(
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBitVec`
/// - `this` is not written to concurrently
/// - `bit_vec` points to a valid `SPBitVec`
/// - `bit_vec` is not written to concurrently
/// - the returned instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_bit_vec_free`.
#[no_mangle]
pub unsafe extern "C" fn sp_bit_vec_clone(
this: *const SPBitVec,
bit_vec: *const SPBitVec,
) -> *mut SPBitVec {
Box::into_raw(Box::new((*this).clone()))
Box::into_raw(Box::new((*bit_vec).clone()))
}
/// Deallocates a `SPBitVec`.
@ -98,19 +98,19 @@ pub unsafe extern "C" fn sp_bit_vec_clone(
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBitVec`
/// - `this` is not used concurrently or after this call
/// - `this` was not passed to another consuming function, e.g. to create a `SPCommand`
/// - `bit_vec` points to a valid `SPBitVec`
/// - `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`
#[no_mangle]
pub unsafe extern "C" fn sp_bit_vec_free(this: *mut SPBitVec) {
_ = Box::from_raw(this);
pub unsafe extern "C" fn sp_bit_vec_free(bit_vec: *mut SPBitVec) {
_ = Box::from_raw(bit_vec);
}
/// Gets the value of a bit from the `SPBitVec`.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `bit_vec`: instance to read from
/// - `index`: the bit index to read
///
/// returns: value of the bit
@ -123,21 +123,21 @@ pub unsafe extern "C" fn sp_bit_vec_free(this: *mut SPBitVec) {
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBitVec`
/// - `this` is not written to concurrently
/// - `bit_vec` points to a valid `SPBitVec`
/// - `bit_vec` is not written to concurrently
#[no_mangle]
pub unsafe extern "C" fn sp_bit_vec_get(
this: *const SPBitVec,
bit_vec: *const SPBitVec,
index: usize,
) -> bool {
*(*this).0.get(index).unwrap()
*(*bit_vec).0.get(index).unwrap()
}
/// Sets the value of a bit in the `SPBitVec`.
///
/// # Arguments
///
/// - `this`: instance to write to
/// - `bit_vec`: instance to write to
/// - `index`: the bit index to edit
/// - `value`: the value to set the bit to
///
@ -151,72 +151,85 @@ pub unsafe extern "C" fn sp_bit_vec_get(
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBitVec`
/// - `this` is not written to or read from concurrently
/// - `bit_vec` points to a valid `SPBitVec`
/// - `bit_vec` is not written to or read from concurrently
#[no_mangle]
pub unsafe extern "C" fn sp_bit_vec_set(
this: *mut SPBitVec,
bit_vec: *mut SPBitVec,
index: usize,
value: bool,
) {
(*this).0.set(index, value)
(*bit_vec).0.set(index, value)
}
/// Sets the value of all bits in the `SPBitVec`.
///
/// # Arguments
///
/// - `bit_vec`: instance to write to
/// - `value`: the value to set all bits to
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBitVec`
/// - `this` is not written to or read from concurrently
/// - `bit_vec` points to a valid `SPBitVec`
/// - `bit_vec` is not written to or read from concurrently
#[no_mangle]
pub unsafe extern "C" fn sp_bit_vec_fill(this: *mut SPBitVec, value: bool) {
(*this).0.fill(value)
pub unsafe extern "C" fn sp_bit_vec_fill(bit_vec: *mut SPBitVec, value: bool) {
(*bit_vec).0.fill(value)
}
/// Gets the length of the `SPBitVec` in bits.
///
/// # Arguments
///
/// - `bit_vec`: instance to write to
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBitVec`
/// - `bit_vec` points to a valid `SPBitVec`
#[no_mangle]
pub unsafe extern "C" fn sp_bit_vec_len(this: *const SPBitVec) -> usize {
(*this).0.len()
pub unsafe extern "C" fn sp_bit_vec_len(bit_vec: *const SPBitVec) -> usize {
(*bit_vec).0.len()
}
/// Returns true if length is 0.
///
/// # Arguments
///
/// - `bit_vec`: instance to write to
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBitVec`
/// - `bit_vec` points to a valid `SPBitVec`
#[no_mangle]
pub unsafe extern "C" fn sp_bit_vec_is_empty(this: *const SPBitVec) -> bool {
(*this).0.is_empty()
pub unsafe extern "C" fn sp_bit_vec_is_empty(bit_vec: *const SPBitVec) -> bool {
(*bit_vec).0.is_empty()
}
/// Gets an unsafe reference to the data of the `SPBitVec` instance.
///
/// # Arguments
///
/// - `bit_vec`: instance to write to
///
/// ## Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBitVec`
/// - `bit_vec` points to a valid `SPBitVec`
/// - 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
#[no_mangle]
pub unsafe extern "C" fn sp_bit_vec_unsafe_data_ref(
this: *mut SPBitVec,
bit_vec: *mut SPBitVec,
) -> SPByteSlice {
let data = (*this).0.as_raw_mut_slice();
let data = (*bit_vec).0.as_raw_mut_slice();
SPByteSlice {
start: data.as_mut_ptr_range().start,
length: data.len(),

View file

@ -21,15 +21,11 @@ use std::intrinsics::transmute;
/// SPCommand command = sp_command_char_brightness(grid);
/// sp_connection_free(connection);
/// ```
pub struct SPBrightnessGrid {
pub(crate) actual: servicepoint::BrightnessGrid,
}
pub struct SPBrightnessGrid(pub(crate) servicepoint::BrightnessGrid);
impl Clone for SPBrightnessGrid {
fn clone(&self) -> Self {
SPBrightnessGrid {
actual: self.actual.clone(),
}
SPBrightnessGrid(self.0.clone())
}
}
@ -48,9 +44,9 @@ pub unsafe extern "C" fn sp_brightness_grid_new(
width: usize,
height: usize,
) -> *mut SPBrightnessGrid {
Box::into_raw(Box::new(SPBrightnessGrid {
actual: servicepoint::BrightnessGrid::new(width, height),
}))
Box::into_raw(Box::new(SPBrightnessGrid(
servicepoint::BrightnessGrid::new(width, height),
)))
}
/// Loads a `SPBrightnessGrid` with the specified dimensions from the provided data.
@ -78,47 +74,55 @@ pub unsafe extern "C" fn sp_brightness_grid_load(
let grid = PrimitiveGrid::load(width, height, data);
let grid = servicepoint::BrightnessGrid::try_from(grid)
.expect("invalid brightness value");
Box::into_raw(Box::new(SPBrightnessGrid { actual: grid }))
Box::into_raw(Box::new(SPBrightnessGrid(grid)))
}
/// Clones a `SPBrightnessGrid`.
///
/// # Arguments
///
/// - `brightness_grid`: instance to read from
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBrightnessGrid`
/// - `this` is not written to concurrently
/// - `brightness_grid` points to a valid `SPBrightnessGrid`
/// - `brightness_grid` is not written to concurrently
/// - the returned instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_brightness_grid_free`.
#[no_mangle]
pub unsafe extern "C" fn sp_brightness_grid_clone(
this: *const SPBrightnessGrid,
brightness_grid: *const SPBrightnessGrid,
) -> *mut SPBrightnessGrid {
Box::into_raw(Box::new((*this).clone()))
Box::into_raw(Box::new((*brightness_grid).clone()))
}
/// Deallocates a `SPBrightnessGrid`.
///
/// # Arguments
///
/// - `brightness_grid`: instance to read from
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBrightnessGrid`
/// - `this` is not used concurrently or after this call
/// - `this` was not passed to another consuming function, e.g. to create a `SPCommand`
/// - `brightness_grid` points to a valid `SPBrightnessGrid`
/// - `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`
#[no_mangle]
pub unsafe extern "C" fn sp_brightness_grid_free(
this: *mut SPBrightnessGrid,
brightness_grid: *mut SPBrightnessGrid,
) {
_ = Box::from_raw(this);
_ = Box::from_raw(brightness_grid);
}
/// Gets the current value at the specified position.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `brightness_grid`: instance to read from
/// - `x` and `y`: position of the cell to read
///
/// # Panics
@ -129,22 +133,22 @@ pub unsafe extern "C" fn sp_brightness_grid_free(
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBrightnessGrid`
/// - `this` is not written to concurrently
/// - `brightness_grid` points to a valid `SPBrightnessGrid`
/// - `brightness_grid` is not written to concurrently
#[no_mangle]
pub unsafe extern "C" fn sp_brightness_grid_get(
this: *const SPBrightnessGrid,
brightness_grid: *const SPBrightnessGrid,
x: usize,
y: usize,
) -> u8 {
(*this).actual.get(x, y).into()
(*brightness_grid).0.get(x, y).into()
}
/// Sets the value of the specified position in the `SPBrightnessGrid`.
///
/// # Arguments
///
/// - `this`: instance to write to
/// - `brightness_grid`: instance to write to
/// - `x` and `y`: position of the cell
/// - `value`: the value to write to the cell
///
@ -159,25 +163,25 @@ pub unsafe extern "C" fn sp_brightness_grid_get(
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBitVec`
/// - `this` is not written to or read from concurrently
/// - `brightness_grid` points to a valid `SPBitVec`
/// - `brightness_grid` is not written to or read from concurrently
#[no_mangle]
pub unsafe extern "C" fn sp_brightness_grid_set(
this: *mut SPBrightnessGrid,
brightness_grid: *mut SPBrightnessGrid,
x: usize,
y: usize,
value: u8,
) {
let brightness =
Brightness::try_from(value).expect("invalid brightness value");
(*this).actual.set(x, y, brightness);
(*brightness_grid).0.set(x, y, brightness);
}
/// Sets the value of all cells in the `SPBrightnessGrid`.
///
/// # Arguments
///
/// - `this`: instance to write to
/// - `brightness_grid`: instance to write to
/// - `value`: the value to set all cells to
///
/// # Panics
@ -188,70 +192,74 @@ pub unsafe extern "C" fn sp_brightness_grid_set(
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBrightnessGrid`
/// - `this` is not written to or read from concurrently
/// - `brightness_grid` points to a valid `SPBrightnessGrid`
/// - `brightness_grid` is not written to or read from concurrently
#[no_mangle]
pub unsafe extern "C" fn sp_brightness_grid_fill(
this: *mut SPBrightnessGrid,
brightness_grid: *mut SPBrightnessGrid,
value: u8,
) {
let brightness =
Brightness::try_from(value).expect("invalid brightness value");
(*this).actual.fill(brightness);
(*brightness_grid).0.fill(brightness);
}
/// Gets the width of the `SPBrightnessGrid` instance.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `brightness_grid`: instance to read from
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBrightnessGrid`
/// - `brightness_grid` points to a valid `SPBrightnessGrid`
#[no_mangle]
pub unsafe extern "C" fn sp_brightness_grid_width(
this: *const SPBrightnessGrid,
brightness_grid: *const SPBrightnessGrid,
) -> usize {
(*this).actual.width()
(*brightness_grid).0.width()
}
/// Gets the height of the `SPBrightnessGrid` instance.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `brightness_grid`: instance to read from
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBrightnessGrid`
/// - `brightness_grid` points to a valid `SPBrightnessGrid`
#[no_mangle]
pub unsafe extern "C" fn sp_brightness_grid_height(
this: *const SPBrightnessGrid,
brightness_grid: *const SPBrightnessGrid,
) -> usize {
(*this).actual.height()
(*brightness_grid).0.height()
}
/// Gets an unsafe reference to the data of the `SPBrightnessGrid` instance.
///
/// # Arguments
///
/// - `brightness_grid`: instance to read from
///
/// ## Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBrightnessGrid`
/// - `brightness_grid` points to a valid `SPBrightnessGrid`
/// - 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
#[no_mangle]
pub unsafe extern "C" fn sp_brightness_grid_unsafe_data_ref(
this: *mut SPBrightnessGrid,
brightness_grid: *mut SPBrightnessGrid,
) -> SPByteSlice {
assert_eq!(std::mem::size_of::<Brightness>(), 1);
assert_eq!(core::mem::size_of::<Brightness>(), 1);
let data = (*this).actual.data_ref_mut();
let data = (*brightness_grid).0.data_ref_mut();
let data: &mut [u8] = transmute(data);
SPByteSlice {
start: data.as_mut_ptr_range().start,

View file

@ -63,15 +63,15 @@ pub unsafe extern "C" fn sp_command_try_from_packet(
///
/// The caller has to make sure that:
///
/// - `this` points to a valid instance of `SPCommand`
/// - `this` is not written to concurrently
/// - `command` points to a valid instance of `SPCommand`
/// - `command` is not written to concurrently
/// - the returned `SPCommand` instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_command_free`.
#[no_mangle]
pub unsafe extern "C" fn sp_command_clone(
original: *const SPCommand,
command: *const SPCommand,
) -> *mut SPCommand {
Box::into_raw(Box::new((*original).clone()))
Box::into_raw(Box::new((*command).clone()))
}
/// Set all pixels to the off state.
@ -177,7 +177,7 @@ pub unsafe extern "C" fn sp_command_char_brightness(
let byte_grid = *Box::from_raw(grid);
Box::into_raw(Box::new(SPCommand(servicepoint::Command::CharBrightness(
Origin::new(x, y),
byte_grid.actual,
byte_grid.0,
))))
}
@ -394,10 +394,10 @@ pub unsafe extern "C" fn sp_command_bitmap_linear_win(
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPCommand`
/// - `this` is not used concurrently or after this call
/// - `this` was not passed to another consuming function, e.g. to create a `SPPacket`
/// - `command` points to a valid `SPCommand`
/// - `command` is not used concurrently or after this call
/// - `command` was not passed to another consuming function, e.g. to create a `SPPacket`
#[no_mangle]
pub unsafe extern "C" fn sp_command_free(ptr: *mut SPCommand) {
_ = Box::from_raw(ptr);
pub unsafe extern "C" fn sp_command_free(command: *mut SPCommand) {
_ = Box::from_raw(command);
}

View file

@ -47,7 +47,7 @@ pub unsafe extern "C" fn sp_connection_open(
/// Sends a `SPPacket` to the display using the `SPConnection`.
///
/// The passed `SPPacket` gets consumed.
/// The passed `packet` gets consumed.
///
/// returns: true in case of success
///
@ -55,9 +55,9 @@ pub unsafe extern "C" fn sp_connection_open(
///
/// The caller has to make sure that:
///
/// - `SPConnection` points to a valid instance of `SPConnection`
/// - `SPPacket` points to a valid instance of `SPPacket`
/// - `SPPacket` is not used concurrently or after this call
/// - `connection` points to a valid instance of `SPConnection`
/// - `packet` points to a valid instance of `SPPacket`
/// - `packet` is not used concurrently or after this call
#[no_mangle]
pub unsafe extern "C" fn sp_connection_send_packet(
connection: *const SPConnection,
@ -69,7 +69,7 @@ pub unsafe extern "C" fn sp_connection_send_packet(
/// Sends a `SPCommand` to the display using the `SPConnection`.
///
/// The passed `SPCommand` gets consumed.
/// The passed `command` gets consumed.
///
/// returns: true in case of success
///
@ -95,9 +95,9 @@ pub unsafe extern "C" fn sp_connection_send_command(
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPConnection`
/// - `this` is not used concurrently or after this call
/// - `connection` points to a valid `SPConnection`
/// - `connection` is not used concurrently or after this call
#[no_mangle]
pub unsafe extern "C" fn sp_connection_free(ptr: *mut SPConnection) {
_ = Box::from_raw(ptr);
pub unsafe extern "C" fn sp_connection_free(connection: *mut SPConnection) {
_ = Box::from_raw(connection);
}

View file

@ -86,15 +86,15 @@ pub unsafe extern "C" fn sp_cp437_grid_load(
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPCp437Grid`
/// - `this` is not written to concurrently
/// - `cp437_grid` points to a valid `SPCp437Grid`
/// - `cp437_grid` is not written to concurrently
/// - the returned instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_cp437_grid_free`.
#[no_mangle]
pub unsafe extern "C" fn sp_cp437_grid_clone(
this: *const SPCp437Grid,
cp437_grid: *const SPCp437Grid,
) -> *mut SPCp437Grid {
Box::into_raw(Box::new((*this).clone()))
Box::into_raw(Box::new((*cp437_grid).clone()))
}
/// Deallocates a `SPCp437Grid`.
@ -103,19 +103,19 @@ pub unsafe extern "C" fn sp_cp437_grid_clone(
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPCp437Grid`
/// - `this` is not used concurrently or after this call
/// - `this` was not passed to another consuming function, e.g. to create a `SPCommand`
/// - `cp437_grid` points to a valid `SPCp437Grid`
/// - `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`
#[no_mangle]
pub unsafe extern "C" fn sp_cp437_grid_free(this: *mut SPCp437Grid) {
_ = Box::from_raw(this);
pub unsafe extern "C" fn sp_cp437_grid_free(cp437_grid: *mut SPCp437Grid) {
_ = Box::from_raw(cp437_grid);
}
/// Gets the current value at the specified position.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `cp437_grid`: instance to read from
/// - `x` and `y`: position of the cell to read
///
/// # Panics
@ -126,22 +126,22 @@ pub unsafe extern "C" fn sp_cp437_grid_free(this: *mut SPCp437Grid) {
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPCp437Grid`
/// - `this` is not written to concurrently
/// - `cp437_grid` points to a valid `SPCp437Grid`
/// - `cp437_grid` is not written to concurrently
#[no_mangle]
pub unsafe extern "C" fn sp_cp437_grid_get(
this: *const SPCp437Grid,
cp437_grid: *const SPCp437Grid,
x: usize,
y: usize,
) -> u8 {
(*this).actual.get(x, y)
(*cp437_grid).actual.get(x, y)
}
/// Sets the value of the specified position in the `SPCp437Grid`.
///
/// # Arguments
///
/// - `this`: instance to write to
/// - `cp437_grid`: instance to write to
/// - `x` and `y`: position of the cell
/// - `value`: the value to write to the cell
///
@ -155,70 +155,73 @@ pub unsafe extern "C" fn sp_cp437_grid_get(
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBitVec`
/// - `this` is not written to or read from concurrently
/// - `cp437_grid` points to a valid `SPBitVec`
/// - `cp437_grid` is not written to or read from concurrently
#[no_mangle]
pub unsafe extern "C" fn sp_cp437_grid_set(
this: *mut SPCp437Grid,
cp437_grid: *mut SPCp437Grid,
x: usize,
y: usize,
value: u8,
) {
(*this).actual.set(x, y, value);
(*cp437_grid).actual.set(x, y, value);
}
/// Sets the value of all cells in the `SPCp437Grid`.
///
/// # Arguments
///
/// - `this`: instance to write to
/// - `cp437_grid`: instance to write to
/// - `value`: the value to set all cells to
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPCp437Grid`
/// - `this` is not written to or read from concurrently
/// - `cp437_grid` points to a valid `SPCp437Grid`
/// - `cp437_grid` is not written to or read from concurrently
#[no_mangle]
pub unsafe extern "C" fn sp_cp437_grid_fill(this: *mut SPCp437Grid, value: u8) {
(*this).actual.fill(value);
pub unsafe extern "C" fn sp_cp437_grid_fill(
cp437_grid: *mut SPCp437Grid,
value: u8,
) {
(*cp437_grid).actual.fill(value);
}
/// Gets the width of the `SPCp437Grid` instance.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `cp437_grid`: instance to read from
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPCp437Grid`
/// - `cp437_grid` points to a valid `SPCp437Grid`
#[no_mangle]
pub unsafe extern "C" fn sp_cp437_grid_width(
this: *const SPCp437Grid,
cp437_grid: *const SPCp437Grid,
) -> usize {
(*this).actual.width()
(*cp437_grid).actual.width()
}
/// Gets the height of the `SPCp437Grid` instance.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `cp437_grid`: instance to read from
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPCp437Grid`
/// - `cp437_grid` points to a valid `SPCp437Grid`
#[no_mangle]
pub unsafe extern "C" fn sp_cp437_grid_height(
this: *const SPCp437Grid,
cp437_grid: *const SPCp437Grid,
) -> usize {
(*this).actual.height()
(*cp437_grid).actual.height()
}
/// Gets an unsafe reference to the data of the `SPCp437Grid` instance.
@ -229,14 +232,14 @@ pub unsafe extern "C" fn sp_cp437_grid_height(
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPCp437Grid`
/// - `cp437_grid` points to a valid `SPCp437Grid`
/// - 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
#[no_mangle]
pub unsafe extern "C" fn sp_cp437_grid_unsafe_data_ref(
this: *mut SPCp437Grid,
cp437_grid: *mut SPCp437Grid,
) -> SPByteSlice {
let data = (*this).actual.data_ref_mut();
let data = (*cp437_grid).actual.data_ref_mut();
SPByteSlice {
start: data.as_mut_ptr_range().start,
length: data.len(),

View file

@ -63,15 +63,15 @@ pub unsafe extern "C" fn sp_packet_try_load(
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPPacket`
/// - `this` is not written to concurrently
/// - `packet` points to a valid `SPPacket`
/// - `packet` is not written to concurrently
/// - the returned instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_packet_free`.
#[no_mangle]
pub unsafe extern "C" fn sp_packet_clone(
this: *const SPPacket,
packet: *const SPPacket,
) -> *mut SPPacket {
Box::into_raw(Box::new(SPPacket((*this).0.clone())))
Box::into_raw(Box::new(SPPacket((*packet).0.clone())))
}
/// Deallocates a `SPPacket`.
@ -80,9 +80,9 @@ pub unsafe extern "C" fn sp_packet_clone(
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPPacket`
/// - `this` is not used concurrently or after this call
/// - `packet` points to a valid `SPPacket`
/// - `packet` is not used concurrently or after this call
#[no_mangle]
pub unsafe extern "C" fn sp_packet_free(this: *mut SPPacket) {
_ = Box::from_raw(this)
pub unsafe extern "C" fn sp_packet_free(packet: *mut SPPacket) {
_ = Box::from_raw(packet)
}

View file

@ -89,15 +89,15 @@ pub unsafe extern "C" fn sp_pixel_grid_load(
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPPixelGrid`
/// - `this` is not written to concurrently
/// - `pixel_grid` points to a valid `SPPixelGrid`
/// - `pixel_grid` is not written to concurrently
/// - the returned instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_pixel_grid_free`.
#[no_mangle]
pub unsafe extern "C" fn sp_pixel_grid_clone(
this: *const SPPixelGrid,
pixel_grid: *const SPPixelGrid,
) -> *mut SPPixelGrid {
Box::into_raw(Box::new(SPPixelGrid((*this).0.clone())))
Box::into_raw(Box::new(SPPixelGrid((*pixel_grid).0.clone())))
}
/// Deallocates a `SPPixelGrid`.
@ -106,19 +106,19 @@ pub unsafe extern "C" fn sp_pixel_grid_clone(
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPPixelGrid`
/// - `this` is not used concurrently or after this call
/// - `this` was not passed to another consuming function, e.g. to create a `SPCommand`
/// - `pixel_grid` points to a valid `SPPixelGrid`
/// - `pixel_grid` is not used concurrently or after pixel_grid call
/// - `pixel_grid` was not passed to another consuming function, e.g. to create a `SPCommand`
#[no_mangle]
pub unsafe extern "C" fn sp_pixel_grid_free(this: *mut SPPixelGrid) {
_ = Box::from_raw(this);
pub unsafe extern "C" fn sp_pixel_grid_free(pixel_grid: *mut SPPixelGrid) {
_ = Box::from_raw(pixel_grid);
}
/// Gets the current value at the specified position in the `SPPixelGrid`.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `pixel_grid`: instance to read from
/// - `x` and `y`: position of the cell to read
///
/// # Panics
@ -129,22 +129,22 @@ pub unsafe extern "C" fn sp_pixel_grid_free(this: *mut SPPixelGrid) {
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPPixelGrid`
/// - `this` is not written to concurrently
/// - `pixel_grid` points to a valid `SPPixelGrid`
/// - `pixel_grid` is not written to concurrently
#[no_mangle]
pub unsafe extern "C" fn sp_pixel_grid_get(
this: *const SPPixelGrid,
pixel_grid: *const SPPixelGrid,
x: usize,
y: usize,
) -> bool {
(*this).0.get(x, y)
(*pixel_grid).0.get(x, y)
}
/// Sets the value of the specified position in the `SPPixelGrid`.
///
/// # Arguments
///
/// - `this`: instance to write to
/// - `pixel_grid`: instance to write to
/// - `x` and `y`: position of the cell
/// - `value`: the value to write to the cell
///
@ -158,73 +158,73 @@ pub unsafe extern "C" fn sp_pixel_grid_get(
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPPixelGrid`
/// - `this` is not written to or read from concurrently
/// - `pixel_grid` points to a valid `SPPixelGrid`
/// - `pixel_grid` is not written to or read from concurrently
#[no_mangle]
pub unsafe extern "C" fn sp_pixel_grid_set(
this: *mut SPPixelGrid,
pixel_grid: *mut SPPixelGrid,
x: usize,
y: usize,
value: bool,
) {
(*this).0.set(x, y, value);
(*pixel_grid).0.set(x, y, value);
}
/// Sets the state of all pixels in the `SPPixelGrid`.
///
/// # Arguments
///
/// - `this`: instance to write to
/// - `pixel_grid`: instance to write to
/// - `value`: the value to set all pixels to
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPPixelGrid`
/// - `this` is not written to or read from concurrently
/// - `pixel_grid` points to a valid `SPPixelGrid`
/// - `pixel_grid` is not written to or read from concurrently
#[no_mangle]
pub unsafe extern "C" fn sp_pixel_grid_fill(
this: *mut SPPixelGrid,
pixel_grid: *mut SPPixelGrid,
value: bool,
) {
(*this).0.fill(value);
(*pixel_grid).0.fill(value);
}
/// Gets the width in pixels of the `SPPixelGrid` instance.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `pixel_grid`: instance to read from
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPPixelGrid`
/// - `pixel_grid` points to a valid `SPPixelGrid`
#[no_mangle]
pub unsafe extern "C" fn sp_pixel_grid_width(
this: *const SPPixelGrid,
pixel_grid: *const SPPixelGrid,
) -> usize {
(*this).0.width()
(*pixel_grid).0.width()
}
/// Gets the height in pixels of the `SPPixelGrid` instance.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `pixel_grid`: instance to read from
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPPixelGrid`
/// - `pixel_grid` points to a valid `SPPixelGrid`
#[no_mangle]
pub unsafe extern "C" fn sp_pixel_grid_height(
this: *const SPPixelGrid,
pixel_grid: *const SPPixelGrid,
) -> usize {
(*this).0.height()
(*pixel_grid).0.height()
}
/// Gets an unsafe reference to the data of the `SPPixelGrid` instance.
@ -233,14 +233,14 @@ pub unsafe extern "C" fn sp_pixel_grid_height(
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPPixelGrid`
/// - `pixel_grid` points to a valid `SPPixelGrid`
/// - the returned memory range is never accessed after the passed `SPPixelGrid` has been freed
/// - the returned memory range is never accessed concurrently, either via the `SPPixelGrid` or directly
#[no_mangle]
pub unsafe extern "C" fn sp_pixel_grid_unsafe_data_ref(
this: *mut SPPixelGrid,
pixel_grid: *mut SPPixelGrid,
) -> SPByteSlice {
let data = (*this).0.data_ref_mut();
let data = (*pixel_grid).0.data_ref_mut();
SPByteSlice {
start: data.as_mut_ptr_range().start,
length: data.len(),

View file

@ -64,13 +64,13 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBitVec`
/// - `this` is not written to concurrently
/// - `bit_vec` points to a valid `SPBitVec`
/// - `bit_vec` is not written to concurrently
/// - the returned instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_bit_vec_free`.
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_bit_vec_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern BitVec* sp_bit_vec_clone(BitVec* @this);
public static extern BitVec* sp_bit_vec_clone(BitVec* bit_vec);
/// <summary>
/// Deallocates a `SPBitVec`.
@ -79,19 +79,19 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBitVec`
/// - `this` is not used concurrently or after this call
/// - `this` was not passed to another consuming function, e.g. to create a `SPCommand`
/// - `bit_vec` points to a valid `SPBitVec`
/// - `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`
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_bit_vec_free", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_bit_vec_free(BitVec* @this);
public static extern void sp_bit_vec_free(BitVec* bit_vec);
/// <summary>
/// Gets the value of a bit from the `SPBitVec`.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `bit_vec`: instance to read from
/// - `index`: the bit index to read
///
/// returns: value of the bit
@ -104,19 +104,19 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBitVec`
/// - `this` is not written to concurrently
/// - `bit_vec` points to a valid `SPBitVec`
/// - `bit_vec` is not written to concurrently
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_bit_vec_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool sp_bit_vec_get(BitVec* @this, nuint index);
public static extern bool sp_bit_vec_get(BitVec* bit_vec, nuint index);
/// <summary>
/// Sets the value of a bit in the `SPBitVec`.
///
/// # Arguments
///
/// - `this`: instance to write to
/// - `bit_vec`: instance to write to
/// - `index`: the bit index to edit
/// - `value`: the value to set the bit to
///
@ -130,67 +130,80 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBitVec`
/// - `this` is not written to or read from concurrently
/// - `bit_vec` points to a valid `SPBitVec`
/// - `bit_vec` is not written to or read from concurrently
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_bit_vec_set", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_bit_vec_set(BitVec* @this, nuint index, [MarshalAs(UnmanagedType.U1)] bool value);
public static extern void sp_bit_vec_set(BitVec* bit_vec, nuint index, [MarshalAs(UnmanagedType.U1)] bool value);
/// <summary>
/// Sets the value of all bits in the `SPBitVec`.
///
/// # Arguments
///
/// - `bit_vec`: instance to write to
/// - `value`: the value to set all bits to
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBitVec`
/// - `this` is not written to or read from concurrently
/// - `bit_vec` points to a valid `SPBitVec`
/// - `bit_vec` is not written to or read from concurrently
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_bit_vec_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_bit_vec_fill(BitVec* @this, [MarshalAs(UnmanagedType.U1)] bool value);
public static extern void sp_bit_vec_fill(BitVec* bit_vec, [MarshalAs(UnmanagedType.U1)] bool value);
/// <summary>
/// Gets the length of the `SPBitVec` in bits.
///
/// # Arguments
///
/// - `bit_vec`: instance to write to
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBitVec`
/// - `bit_vec` points to a valid `SPBitVec`
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_bit_vec_len", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern nuint sp_bit_vec_len(BitVec* @this);
public static extern nuint sp_bit_vec_len(BitVec* bit_vec);
/// <summary>
/// Returns true if length is 0.
///
/// # Arguments
///
/// - `bit_vec`: instance to write to
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBitVec`
/// - `bit_vec` points to a valid `SPBitVec`
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_bit_vec_is_empty", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool sp_bit_vec_is_empty(BitVec* @this);
public static extern bool sp_bit_vec_is_empty(BitVec* bit_vec);
/// <summary>
/// Gets an unsafe reference to the data of the `SPBitVec` instance.
///
/// # Arguments
///
/// - `bit_vec`: instance to write to
///
/// ## Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBitVec`
/// - `bit_vec` points to a valid `SPBitVec`
/// - 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
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_bit_vec_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ByteSlice sp_bit_vec_unsafe_data_ref(BitVec* @this);
public static extern ByteSlice sp_bit_vec_unsafe_data_ref(BitVec* bit_vec);
/// <summary>
/// Creates a new `SPBrightnessGrid` with the specified dimensions.
@ -229,38 +242,46 @@ namespace ServicePoint.BindGen
/// <summary>
/// Clones a `SPBrightnessGrid`.
///
/// # Arguments
///
/// - `brightness_grid`: instance to read from
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBrightnessGrid`
/// - `this` is not written to concurrently
/// - `brightness_grid` points to a valid `SPBrightnessGrid`
/// - `brightness_grid` is not written to concurrently
/// - the returned instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_brightness_grid_free`.
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_brightness_grid_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern BrightnessGrid* sp_brightness_grid_clone(BrightnessGrid* @this);
public static extern BrightnessGrid* sp_brightness_grid_clone(BrightnessGrid* brightness_grid);
/// <summary>
/// Deallocates a `SPBrightnessGrid`.
///
/// # Arguments
///
/// - `brightness_grid`: instance to read from
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBrightnessGrid`
/// - `this` is not used concurrently or after this call
/// - `this` was not passed to another consuming function, e.g. to create a `SPCommand`
/// - `brightness_grid` points to a valid `SPBrightnessGrid`
/// - `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`
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_brightness_grid_free", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_brightness_grid_free(BrightnessGrid* @this);
public static extern void sp_brightness_grid_free(BrightnessGrid* brightness_grid);
/// <summary>
/// Gets the current value at the specified position.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `brightness_grid`: instance to read from
/// - `x` and `y`: position of the cell to read
///
/// # Panics
@ -271,18 +292,18 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBrightnessGrid`
/// - `this` is not written to concurrently
/// - `brightness_grid` points to a valid `SPBrightnessGrid`
/// - `brightness_grid` is not written to concurrently
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_brightness_grid_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte sp_brightness_grid_get(BrightnessGrid* @this, nuint x, nuint y);
public static extern byte sp_brightness_grid_get(BrightnessGrid* brightness_grid, nuint x, nuint y);
/// <summary>
/// Sets the value of the specified position in the `SPBrightnessGrid`.
///
/// # Arguments
///
/// - `this`: instance to write to
/// - `brightness_grid`: instance to write to
/// - `x` and `y`: position of the cell
/// - `value`: the value to write to the cell
///
@ -297,18 +318,18 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBitVec`
/// - `this` is not written to or read from concurrently
/// - `brightness_grid` points to a valid `SPBitVec`
/// - `brightness_grid` is not written to or read from concurrently
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_brightness_grid_set", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_brightness_grid_set(BrightnessGrid* @this, nuint x, nuint y, byte value);
public static extern void sp_brightness_grid_set(BrightnessGrid* brightness_grid, nuint x, nuint y, byte value);
/// <summary>
/// Sets the value of all cells in the `SPBrightnessGrid`.
///
/// # Arguments
///
/// - `this`: instance to write to
/// - `brightness_grid`: instance to write to
/// - `value`: the value to set all cells to
///
/// # Panics
@ -319,57 +340,61 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBrightnessGrid`
/// - `this` is not written to or read from concurrently
/// - `brightness_grid` points to a valid `SPBrightnessGrid`
/// - `brightness_grid` is not written to or read from concurrently
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_brightness_grid_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_brightness_grid_fill(BrightnessGrid* @this, byte value);
public static extern void sp_brightness_grid_fill(BrightnessGrid* brightness_grid, byte value);
/// <summary>
/// Gets the width of the `SPBrightnessGrid` instance.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `brightness_grid`: instance to read from
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBrightnessGrid`
/// - `brightness_grid` points to a valid `SPBrightnessGrid`
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_brightness_grid_width", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern nuint sp_brightness_grid_width(BrightnessGrid* @this);
public static extern nuint sp_brightness_grid_width(BrightnessGrid* brightness_grid);
/// <summary>
/// Gets the height of the `SPBrightnessGrid` instance.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `brightness_grid`: instance to read from
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBrightnessGrid`
/// - `brightness_grid` points to a valid `SPBrightnessGrid`
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_brightness_grid_height", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern nuint sp_brightness_grid_height(BrightnessGrid* @this);
public static extern nuint sp_brightness_grid_height(BrightnessGrid* brightness_grid);
/// <summary>
/// Gets an unsafe reference to the data of the `SPBrightnessGrid` instance.
///
/// # Arguments
///
/// - `brightness_grid`: instance to read from
///
/// ## Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBrightnessGrid`
/// - `brightness_grid` points to a valid `SPBrightnessGrid`
/// - 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
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_brightness_grid_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ByteSlice sp_brightness_grid_unsafe_data_ref(BrightnessGrid* @this);
public static extern ByteSlice sp_brightness_grid_unsafe_data_ref(BrightnessGrid* brightness_grid);
/// <summary>
/// Tries to turn a `SPPacket` into a `SPCommand`.
@ -398,13 +423,13 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid instance of `SPCommand`
/// - `this` is not written to concurrently
/// - `command` points to a valid instance of `SPCommand`
/// - `command` is not written to concurrently
/// - the returned `SPCommand` instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_command_free`.
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_command_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern Command* sp_command_clone(Command* original);
public static extern Command* sp_command_clone(Command* command);
/// <summary>
/// Set all pixels to the off state.
@ -657,12 +682,12 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPCommand`
/// - `this` is not used concurrently or after this call
/// - `this` was not passed to another consuming function, e.g. to create a `SPPacket`
/// - `command` points to a valid `SPCommand`
/// - `command` is not used concurrently or after this call
/// - `command` was not passed to another consuming function, e.g. to create a `SPPacket`
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_command_free", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_command_free(Command* ptr);
public static extern void sp_command_free(Command* command);
/// <summary>
/// Creates a new instance of `SPConnection`.
@ -686,7 +711,7 @@ namespace ServicePoint.BindGen
/// <summary>
/// Sends a `SPPacket` to the display using the `SPConnection`.
///
/// The passed `SPPacket` gets consumed.
/// The passed `packet` gets consumed.
///
/// returns: true in case of success
///
@ -694,9 +719,9 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `SPConnection` points to a valid instance of `SPConnection`
/// - `SPPacket` points to a valid instance of `SPPacket`
/// - `SPPacket` is not used concurrently or after this call
/// - `connection` points to a valid instance of `SPConnection`
/// - `packet` points to a valid instance of `SPPacket`
/// - `packet` is not used concurrently or after this call
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_connection_send_packet", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
@ -705,7 +730,7 @@ namespace ServicePoint.BindGen
/// <summary>
/// Sends a `SPCommand` to the display using the `SPConnection`.
///
/// The passed `SPCommand` gets consumed.
/// The passed `command` gets consumed.
///
/// returns: true in case of success
///
@ -728,11 +753,11 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPConnection`
/// - `this` is not used concurrently or after this call
/// - `connection` points to a valid `SPConnection`
/// - `connection` is not used concurrently or after this call
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_connection_free", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_connection_free(Connection* ptr);
public static extern void sp_connection_free(Connection* connection);
/// <summary>
/// Creates a new `SPCp437Grid` with the specified dimensions.
@ -779,13 +804,13 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPCp437Grid`
/// - `this` is not written to concurrently
/// - `cp437_grid` points to a valid `SPCp437Grid`
/// - `cp437_grid` is not written to concurrently
/// - the returned instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_cp437_grid_free`.
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern Cp437Grid* sp_cp437_grid_clone(Cp437Grid* @this);
public static extern Cp437Grid* sp_cp437_grid_clone(Cp437Grid* cp437_grid);
/// <summary>
/// Deallocates a `SPCp437Grid`.
@ -794,19 +819,19 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPCp437Grid`
/// - `this` is not used concurrently or after this call
/// - `this` was not passed to another consuming function, e.g. to create a `SPCommand`
/// - `cp437_grid` points to a valid `SPCp437Grid`
/// - `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`
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_free", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_cp437_grid_free(Cp437Grid* @this);
public static extern void sp_cp437_grid_free(Cp437Grid* cp437_grid);
/// <summary>
/// Gets the current value at the specified position.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `cp437_grid`: instance to read from
/// - `x` and `y`: position of the cell to read
///
/// # Panics
@ -817,18 +842,18 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPCp437Grid`
/// - `this` is not written to concurrently
/// - `cp437_grid` points to a valid `SPCp437Grid`
/// - `cp437_grid` is not written to concurrently
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte sp_cp437_grid_get(Cp437Grid* @this, nuint x, nuint y);
public static extern byte sp_cp437_grid_get(Cp437Grid* cp437_grid, nuint x, nuint y);
/// <summary>
/// Sets the value of the specified position in the `SPCp437Grid`.
///
/// # Arguments
///
/// - `this`: instance to write to
/// - `cp437_grid`: instance to write to
/// - `x` and `y`: position of the cell
/// - `value`: the value to write to the cell
///
@ -842,61 +867,61 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPBitVec`
/// - `this` is not written to or read from concurrently
/// - `cp437_grid` points to a valid `SPBitVec`
/// - `cp437_grid` is not written to or read from concurrently
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_set", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_cp437_grid_set(Cp437Grid* @this, nuint x, nuint y, byte value);
public static extern void sp_cp437_grid_set(Cp437Grid* cp437_grid, nuint x, nuint y, byte value);
/// <summary>
/// Sets the value of all cells in the `SPCp437Grid`.
///
/// # Arguments
///
/// - `this`: instance to write to
/// - `cp437_grid`: instance to write to
/// - `value`: the value to set all cells to
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPCp437Grid`
/// - `this` is not written to or read from concurrently
/// - `cp437_grid` points to a valid `SPCp437Grid`
/// - `cp437_grid` is not written to or read from concurrently
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_cp437_grid_fill(Cp437Grid* @this, byte value);
public static extern void sp_cp437_grid_fill(Cp437Grid* cp437_grid, byte value);
/// <summary>
/// Gets the width of the `SPCp437Grid` instance.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `cp437_grid`: instance to read from
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPCp437Grid`
/// - `cp437_grid` points to a valid `SPCp437Grid`
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_width", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern nuint sp_cp437_grid_width(Cp437Grid* @this);
public static extern nuint sp_cp437_grid_width(Cp437Grid* cp437_grid);
/// <summary>
/// Gets the height of the `SPCp437Grid` instance.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `cp437_grid`: instance to read from
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPCp437Grid`
/// - `cp437_grid` points to a valid `SPCp437Grid`
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_height", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern nuint sp_cp437_grid_height(Cp437Grid* @this);
public static extern nuint sp_cp437_grid_height(Cp437Grid* cp437_grid);
/// <summary>
/// Gets an unsafe reference to the data of the `SPCp437Grid` instance.
@ -907,12 +932,12 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPCp437Grid`
/// - `cp437_grid` points to a valid `SPCp437Grid`
/// - 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
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ByteSlice sp_cp437_grid_unsafe_data_ref(Cp437Grid* @this);
public static extern ByteSlice sp_cp437_grid_unsafe_data_ref(Cp437Grid* cp437_grid);
/// <summary>
/// Turns a `SPCommand` into a `SPPacket`.
@ -958,13 +983,13 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPPacket`
/// - `this` is not written to concurrently
/// - `packet` points to a valid `SPPacket`
/// - `packet` is not written to concurrently
/// - the returned instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_packet_free`.
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_packet_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern Packet* sp_packet_clone(Packet* @this);
public static extern Packet* sp_packet_clone(Packet* packet);
/// <summary>
/// Deallocates a `SPPacket`.
@ -973,11 +998,11 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPPacket`
/// - `this` is not used concurrently or after this call
/// - `packet` points to a valid `SPPacket`
/// - `packet` is not used concurrently or after this call
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_packet_free", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_packet_free(Packet* @this);
public static extern void sp_packet_free(Packet* packet);
/// <summary>
/// Creates a new `SPPixelGrid` with the specified dimensions.
@ -1038,13 +1063,13 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPPixelGrid`
/// - `this` is not written to concurrently
/// - `pixel_grid` points to a valid `SPPixelGrid`
/// - `pixel_grid` is not written to concurrently
/// - the returned instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_pixel_grid_free`.
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_pixel_grid_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern PixelGrid* sp_pixel_grid_clone(PixelGrid* @this);
public static extern PixelGrid* sp_pixel_grid_clone(PixelGrid* pixel_grid);
/// <summary>
/// Deallocates a `SPPixelGrid`.
@ -1053,19 +1078,19 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPPixelGrid`
/// - `this` is not used concurrently or after this call
/// - `this` was not passed to another consuming function, e.g. to create a `SPCommand`
/// - `pixel_grid` points to a valid `SPPixelGrid`
/// - `pixel_grid` is not used concurrently or after pixel_grid call
/// - `pixel_grid` was not passed to another consuming function, e.g. to create a `SPCommand`
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_pixel_grid_free", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_pixel_grid_free(PixelGrid* @this);
public static extern void sp_pixel_grid_free(PixelGrid* pixel_grid);
/// <summary>
/// Gets the current value at the specified position in the `SPPixelGrid`.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `pixel_grid`: instance to read from
/// - `x` and `y`: position of the cell to read
///
/// # Panics
@ -1076,19 +1101,19 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPPixelGrid`
/// - `this` is not written to concurrently
/// - `pixel_grid` points to a valid `SPPixelGrid`
/// - `pixel_grid` is not written to concurrently
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_pixel_grid_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool sp_pixel_grid_get(PixelGrid* @this, nuint x, nuint y);
public static extern bool sp_pixel_grid_get(PixelGrid* pixel_grid, nuint x, nuint y);
/// <summary>
/// Sets the value of the specified position in the `SPPixelGrid`.
///
/// # Arguments
///
/// - `this`: instance to write to
/// - `pixel_grid`: instance to write to
/// - `x` and `y`: position of the cell
/// - `value`: the value to write to the cell
///
@ -1102,61 +1127,61 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPPixelGrid`
/// - `this` is not written to or read from concurrently
/// - `pixel_grid` points to a valid `SPPixelGrid`
/// - `pixel_grid` is not written to or read from concurrently
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_pixel_grid_set", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_pixel_grid_set(PixelGrid* @this, nuint x, nuint y, [MarshalAs(UnmanagedType.U1)] bool value);
public static extern void sp_pixel_grid_set(PixelGrid* pixel_grid, nuint x, nuint y, [MarshalAs(UnmanagedType.U1)] bool value);
/// <summary>
/// Sets the state of all pixels in the `SPPixelGrid`.
///
/// # Arguments
///
/// - `this`: instance to write to
/// - `pixel_grid`: instance to write to
/// - `value`: the value to set all pixels to
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPPixelGrid`
/// - `this` is not written to or read from concurrently
/// - `pixel_grid` points to a valid `SPPixelGrid`
/// - `pixel_grid` is not written to or read from concurrently
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_pixel_grid_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_pixel_grid_fill(PixelGrid* @this, [MarshalAs(UnmanagedType.U1)] bool value);
public static extern void sp_pixel_grid_fill(PixelGrid* pixel_grid, [MarshalAs(UnmanagedType.U1)] bool value);
/// <summary>
/// Gets the width in pixels of the `SPPixelGrid` instance.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `pixel_grid`: instance to read from
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPPixelGrid`
/// - `pixel_grid` points to a valid `SPPixelGrid`
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_pixel_grid_width", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern nuint sp_pixel_grid_width(PixelGrid* @this);
public static extern nuint sp_pixel_grid_width(PixelGrid* pixel_grid);
/// <summary>
/// Gets the height in pixels of the `SPPixelGrid` instance.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `pixel_grid`: instance to read from
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPPixelGrid`
/// - `pixel_grid` points to a valid `SPPixelGrid`
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_pixel_grid_height", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern nuint sp_pixel_grid_height(PixelGrid* @this);
public static extern nuint sp_pixel_grid_height(PixelGrid* pixel_grid);
/// <summary>
/// Gets an unsafe reference to the data of the `SPPixelGrid` instance.
@ -1165,12 +1190,12 @@ namespace ServicePoint.BindGen
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `SPPixelGrid`
/// - `pixel_grid` points to a valid `SPPixelGrid`
/// - the returned memory range is never accessed after the passed `SPPixelGrid` has been freed
/// - the returned memory range is never accessed concurrently, either via the `SPPixelGrid` or directly
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_pixel_grid_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ByteSlice sp_pixel_grid_unsafe_data_ref(PixelGrid* @this);
public static extern ByteSlice sp_pixel_grid_unsafe_data_ref(PixelGrid* pixel_grid);
}