WIP: type per command #4

Draft
vinzenz wants to merge 49 commits from next into main
3 changed files with 29 additions and 29 deletions
Showing only changes of commit 8296773779 - Show all commits

View file

@ -12,7 +12,7 @@ void enable_all_pixels(void) {
}
void make_brightness_pattern(BrightnessGrid *grid) {
ByteSlice slice = sp_brightness_grid_unsafe_data_ref(grid);
ByteSlice slice = sp_brightness_grid_data_ref_mut(grid);
for (size_t index = 0; index < slice.length; index++) {
slice.start[index] = (uint8_t)(index % ((size_t) Brightness_MAX));
}

View file

@ -1588,6 +1588,11 @@ void sp_cmd_hard_reset_free(struct HardResetCommand */*notnull*/ instance);
*/
struct HardResetCommand */*notnull*/ sp_cmd_hard_reset_new(void);
/**
*Clones a [Cp437Grid] instance.
*/
Cp437Grid */*notnull*/ sp_cp437_grid_clone(Cp437Grid */*notnull*/ instance);
/**
* Calls [`servicepoint::Cp437Grid::data_ref_mut`].
*
@ -1595,7 +1600,7 @@ struct HardResetCommand */*notnull*/ sp_cmd_hard_reset_new(void);
*
* The returned memory is valid for the lifetime of the instance.
*/
struct ByteSlice sp_cp437_data_ref_mut(Cp437Grid */*notnull*/ instance);
struct ByteSlice sp_cp437_grid_data_ref_mut(Cp437Grid */*notnull*/ instance);
/**
* Calls [`servicepoint::Cp437Grid::fill`].
@ -1607,7 +1612,12 @@ struct ByteSlice sp_cp437_data_ref_mut(Cp437Grid */*notnull*/ instance);
* - `cp437_grid`: instance to write to
* - `value`: the value to set all cells to
*/
void sp_cp437_fill(Cp437Grid */*notnull*/ instance, uint8_t value);
void sp_cp437_grid_fill(Cp437Grid */*notnull*/ instance, uint8_t value);
/**
*Deallocates a [Cp437Grid] instance.
*/
void sp_cp437_grid_free(Cp437Grid */*notnull*/ instance);
/**
* Calls [`servicepoint::Cp437Grid::get`].
@ -1622,17 +1632,14 @@ void sp_cp437_fill(Cp437Grid */*notnull*/ instance, uint8_t value);
*
* - when accessing `x` or `y` out of bounds
*/
uint8_t sp_cp437_get(Cp437Grid */*notnull*/ instance, size_t x, size_t y);
uint8_t sp_cp437_grid_get(Cp437Grid */*notnull*/ instance, size_t x, size_t y);
/**
*Clones a [Cp437Grid] instance.
* Calls [`servicepoint::Cp437Grid::height`].
*
* Gets the height of the grid.
*/
Cp437Grid */*notnull*/ sp_cp437_grid_clone(Cp437Grid */*notnull*/ instance);
/**
*Deallocates a [Cp437Grid] instance.
*/
void sp_cp437_grid_free(Cp437Grid */*notnull*/ instance);
size_t sp_cp437_grid_height(Cp437Grid */*notnull*/ instance);
/**
* Creates a [Cp437GridCommand] and immediately turns that into a [Packet].
@ -1659,13 +1666,6 @@ Cp437Grid *sp_cp437_grid_load(size_t width,
*/
Cp437Grid */*notnull*/ sp_cp437_grid_new(size_t width, size_t height);
/**
* Calls [`servicepoint::Cp437Grid::height`].
*
* Gets the height of the grid.
*/
size_t sp_cp437_height(Cp437Grid */*notnull*/ instance);
/**
* Calls [`servicepoint::Cp437Grid::set`].
*
@ -1682,7 +1682,7 @@ size_t sp_cp437_height(Cp437Grid */*notnull*/ instance);
*
* - when accessing `x` or `y` out of bounds
*/
void sp_cp437_set(Cp437Grid */*notnull*/ instance,
void sp_cp437_grid_set(Cp437Grid */*notnull*/ instance,
size_t x,
size_t y,
uint8_t value);
@ -1692,7 +1692,7 @@ void sp_cp437_set(Cp437Grid */*notnull*/ instance,
*
* Gets the width of the grid.
*/
size_t sp_cp437_width(Cp437Grid */*notnull*/ instance);
size_t sp_cp437_grid_width(Cp437Grid */*notnull*/ instance);
/**
*Clones a [Packet] instance.

View file

@ -34,7 +34,7 @@ wrap_clone!(sp_cp437_grid::Cp437Grid);
wrap_free!(sp_cp437_grid::Cp437Grid);
wrap_method!(
sp_cp437::Cp437Grid;
sp_cp437_grid::Cp437Grid;
/// Gets the current value at the specified position.
///
/// # Arguments
@ -48,7 +48,7 @@ wrap_method!(
);
wrap_method!(
sp_cp437::Cp437Grid;
sp_cp437_grid::Cp437Grid;
/// Sets the value at the specified position.
///
/// # Arguments
@ -65,7 +65,7 @@ wrap_method!(
);
wrap_method!(
sp_cp437::Cp437Grid;
sp_cp437_grid::Cp437Grid;
/// Sets the value of all cells in the grid.
///
/// # Arguments
@ -76,19 +76,19 @@ wrap_method!(
);
wrap_method!(
sp_cp437::Cp437Grid;
sp_cp437_grid::Cp437Grid;
/// Gets the width of the grid.
ref fn width() -> usize;
);
wrap_method!(
sp_cp437::Cp437Grid;
sp_cp437_grid::Cp437Grid;
/// Gets the height of the grid.
ref fn height() -> usize;
);
wrap_method!(
sp_cp437::Cp437Grid;
sp_cp437_grid::Cp437Grid;
/// Gets an unsafe reference to the data of the grid.
///
/// The returned memory is valid for the lifetime of the instance.