object name to snake case
All checks were successful
Rust / build-gnu-apt (pull_request) Successful in 2m0s
Rust / build-size-gnu-unstable (pull_request) Successful in 41s

This commit is contained in:
Vinzenz Schroeter 2025-06-28 18:38:20 +02:00
parent c702d832f4
commit 41fbdbf3a3
10 changed files with 712 additions and 694 deletions

View file

@ -3,27 +3,27 @@
int main(void) { int main(void) {
sock_init(); sock_init();
sp_udpsocket_send_header(sock, (Header) {.command_code = COMMAND_CODE_CLEAR}); sp_udp_socket_send_header(sock, (Header) {.command_code = COMMAND_CODE_CLEAR});
CharGrid *grid = sp_chargrid_new(5, 2); CharGrid *grid = sp_char_grid_new(5, 2);
if (grid == NULL) if (grid == NULL)
return 1; return 1;
sp_chargrid_set(grid, 0, 0, 'H'); sp_char_grid_set(grid, 0, 0, 'H');
sp_chargrid_set(grid, 1, 0, 'e'); sp_char_grid_set(grid, 1, 0, 'e');
sp_chargrid_set(grid, 2, 0, 'l'); sp_char_grid_set(grid, 2, 0, 'l');
sp_chargrid_set(grid, 3, 0, 'l'); sp_char_grid_set(grid, 3, 0, 'l');
sp_chargrid_set(grid, 4, 0, 'o'); sp_char_grid_set(grid, 4, 0, 'o');
sp_chargrid_set(grid, 0, 1, 'W'); sp_char_grid_set(grid, 0, 1, 'W');
sp_chargrid_set(grid, 1, 1, 'o'); sp_char_grid_set(grid, 1, 1, 'o');
sp_chargrid_set(grid, 2, 1, 'r'); sp_char_grid_set(grid, 2, 1, 'r');
sp_chargrid_set(grid, 3, 1, 'l'); sp_char_grid_set(grid, 3, 1, 'l');
sp_chargrid_set(grid, 4, 1, 'd'); sp_char_grid_set(grid, 4, 1, 'd');
Packet *packet = sp_chargrid_try_into_packet(grid, 0, 0); Packet *packet = sp_char_grid_try_into_packet(grid, 0, 0);
if (packet == NULL) if (packet == NULL)
return 1; return 1;
sp_udpsocket_send_packet(sock, packet); sp_udp_socket_send_packet(sock, packet);
return 0; return 0;
} }

View file

@ -5,14 +5,14 @@ void enable_all_pixels(void) {
Bitmap *all_on = sp_bitmap_new_max_sized(); Bitmap *all_on = sp_bitmap_new_max_sized();
sp_bitmap_fill(all_on, true); sp_bitmap_fill(all_on, true);
BitmapCommand *bitmapCommand = sp_bitmapcommand_from_bitmap(all_on); BitmapCommand *bitmapCommand = sp_bitmap_command_from_bitmap(all_on);
Packet *packet = sp_bitmapcommand_try_into_packet(bitmapCommand); Packet *packet = sp_bitmap_command_try_into_packet(bitmapCommand);
if (packet != NULL) if (packet != NULL)
sp_udpsocket_send_packet(sock, packet); sp_udp_socket_send_packet(sock, packet);
} }
void make_brightness_pattern(BrightnessGrid *grid) { void make_brightness_pattern(BrightnessGrid *grid) {
ByteSlice slice = sp_brightnessgrid_data_ref_mut(grid); ByteSlice slice = sp_brightness_grid_data_ref_mut(grid);
for (size_t index = 0; index < slice.length; index++) { for (size_t index = 0; index < slice.length; index++) {
slice.start[index] = (uint8_t)(index % ((size_t) Brightness_MAX)); slice.start[index] = (uint8_t)(index % ((size_t) Brightness_MAX));
} }
@ -23,13 +23,13 @@ int main(void) {
enable_all_pixels(); enable_all_pixels();
BrightnessGrid *grid = sp_brightnessgrid_new(TILE_WIDTH, TILE_HEIGHT); BrightnessGrid *grid = sp_brightness_grid_new(TILE_WIDTH, TILE_HEIGHT);
make_brightness_pattern(grid); make_brightness_pattern(grid);
Packet *packet = sp_brightnessgridcommand_try_into_packet(sp_brightnessgridcommand_from_grid(grid)); Packet *packet = sp_brightness_grid_command_try_into_packet(sp_brightness_grid_command_from_grid(grid));
if (packet == NULL) if (packet == NULL)
return -2; return -2;
sp_udpsocket_send_packet(sock, packet); sp_udp_socket_send_packet(sock, packet);
return 0; return 0;
} }

View file

@ -28,12 +28,12 @@ bool log_command(struct GenericCommand *command) {
case COMMAND_TAG_BITMAP: { case COMMAND_TAG_BITMAP: {
BitmapCommand *bitmapCommand = command->data.bitmap; BitmapCommand *bitmapCommand = command->data.bitmap;
CompressionCode compression = sp_bitmapcommand_get_compression(bitmapCommand); CompressionCode compression = sp_bitmap_command_get_compression(bitmapCommand);
size_t x, y; size_t x, y;
sp_bitmapcommand_get_origin(bitmapCommand, &x, &y); sp_bitmap_command_get_origin(bitmapCommand, &x, &y);
Bitmap *bitmap = sp_bitmapcommand_get_bitmap_mut(bitmapCommand); Bitmap *bitmap = sp_bitmap_command_get_bitmap_mut(bitmapCommand);
size_t w = sp_bitmap_width(bitmap); size_t w = sp_bitmap_width(bitmap);
size_t h = sp_bitmap_height(bitmap); size_t h = sp_bitmap_height(bitmap);
@ -45,11 +45,11 @@ bool log_command(struct GenericCommand *command) {
BrightnessGridCommand *gridCommand = command->data.brightness_grid; BrightnessGridCommand *gridCommand = command->data.brightness_grid;
size_t x, y; size_t x, y;
sp_brightnessgridcommand_get_origin(gridCommand, &x, &y); sp_brightness_grid_command_get_origin(gridCommand, &x, &y);
BrightnessGrid *grid = sp_brightnessgridcommand_get_grid_mut(gridCommand); BrightnessGrid *grid = sp_brightness_grid_command_get_grid_mut(gridCommand);
size_t w = sp_brightnessgrid_width(grid); size_t w = sp_brightness_grid_width(grid);
size_t h = sp_brightnessgrid_height(grid); size_t h = sp_brightness_grid_height(grid);
printf("-> BrightnessGridCommand with params: x=%zu, y=%zu, w=%zu, h=%zu\n", printf("-> BrightnessGridCommand with params: x=%zu, y=%zu, w=%zu, h=%zu\n",
x, y, w, h); x, y, w, h);
@ -59,11 +59,11 @@ bool log_command(struct GenericCommand *command) {
CharGridCommand *gridCommand = command->data.char_grid; CharGridCommand *gridCommand = command->data.char_grid;
size_t x, y; size_t x, y;
sp_chargridcommand_get_origin(gridCommand, &x, &y); sp_char_grid_command_get_origin(gridCommand, &x, &y);
CharGrid *grid = sp_chargridcommand_get_grid_mut(gridCommand); CharGrid *grid = sp_char_grid_command_get_grid_mut(gridCommand);
size_t w = sp_chargrid_width(grid); size_t w = sp_char_grid_width(grid);
size_t h = sp_chargrid_height(grid); size_t h = sp_char_grid_height(grid);
printf("-> CharGridCommand with params: x=%zu, y=%zu, w=%zu, h=%zu\n", printf("-> CharGridCommand with params: x=%zu, y=%zu, w=%zu, h=%zu\n",
x, y, w, h); x, y, w, h);
@ -73,11 +73,11 @@ bool log_command(struct GenericCommand *command) {
Cp437GridCommand *gridCommand = command->data.cp437_grid; Cp437GridCommand *gridCommand = command->data.cp437_grid;
size_t x, y; size_t x, y;
sp_cp437gridcommand_get_origin(gridCommand, &x, &y); sp_cp437_grid_command_get_origin(gridCommand, &x, &y);
Cp437Grid *grid = sp_cp437gridcommand_get_grid_mut(gridCommand); Cp437Grid *grid = sp_cp437_grid_command_get_grid_mut(gridCommand);
size_t w = sp_cp437grid_width(grid); size_t w = sp_cp437_grid_width(grid);
size_t h = sp_cp437grid_height(grid); size_t h = sp_cp437_grid_height(grid);
printf("-> Cp437GridCommand with params: x=%zu, y=%zu, w=%zu, h=%zu\n", printf("-> Cp437GridCommand with params: x=%zu, y=%zu, w=%zu, h=%zu\n",
x, y, w, h); x, y, w, h);
@ -86,10 +86,10 @@ bool log_command(struct GenericCommand *command) {
case COMMAND_TAG_BIT_VEC: { case COMMAND_TAG_BIT_VEC: {
BitVecCommand *bitvecCommand = command->data.bit_vec; BitVecCommand *bitvecCommand = command->data.bit_vec;
size_t offset = sp_bitveccommand_get_offset(bitvecCommand); size_t offset = sp_bit_vec_command_get_offset(bitvecCommand);
CompressionCode compression = sp_bitveccommand_get_compression(bitvecCommand); CompressionCode compression = sp_bit_vec_command_get_compression(bitvecCommand);
BinaryOperation operation = sp_bitveccommand_get_operation(bitvecCommand); BinaryOperation operation = sp_bit_vec_command_get_operation(bitvecCommand);
char *operationText; char *operationText;
switch (operation) { switch (operation) {
case BINARY_OPERATION_AND: case BINARY_OPERATION_AND:
@ -109,8 +109,8 @@ bool log_command(struct GenericCommand *command) {
break; break;
} }
DisplayBitVec *bitvec = sp_bitveccommand_get_bitvec_mut(bitvecCommand); DisplayBitVec *bitvec = sp_bit_vec_command_get_bitvec_mut(bitvecCommand);
size_t len = sp_displaybitvec_len(bitvec); size_t len = sp_display_bit_vec_len(bitvec);
printf("-> BitVecCommand with params: offset=%zu, length=%zu, compression=%hu, operation=%s\n", printf("-> BitVecCommand with params: offset=%zu, length=%zu, compression=%hu, operation=%s\n",
offset, len, compression, operationText); offset, len, compression, operationText);
@ -129,7 +129,7 @@ bool log_command(struct GenericCommand *command) {
break; break;
} }
case COMMAND_TAG_GLOBAL_BRIGHTNESS: { case COMMAND_TAG_GLOBAL_BRIGHTNESS: {
Brightness brightness = sp_globalbrightnesscommand_get_brightness(command->data.global_brightness); Brightness brightness = sp_global_brightness_command_get_brightness(command->data.global_brightness);
printf("-> GlobalBrightnessCommand with params: brightness=%hu\n", brightness); printf("-> GlobalBrightnessCommand with params: brightness=%hu\n", brightness);
break; break;
} }
@ -198,10 +198,10 @@ int main(int argc, char **argv) {
header->command_code, header->a, header->b, header->c, header->d, header->command_code, header->a, header->b, header->c, header->d,
payload.start, payload.length); payload.start, payload.length);
struct GenericCommand *command = sp_genericcommand_try_from_packet(packet); struct GenericCommand *command = sp_generic_command_try_from_packet(packet);
done = log_command(command); done = log_command(command);
sp_genericcommand_free(command); sp_generic_command_free(command);
} }
close(udp_socket); close(udp_socket);

View file

@ -10,11 +10,11 @@
static UdpSocket *sock = NULL; static UdpSocket *sock = NULL;
void sock_free() { void sock_free() {
sp_udpsocket_free(sock); sp_udp_socket_free(sock);
} }
void sock_init() { void sock_init() {
sock = sp_udpsocket_open_ipv4(127, 0, 0, 1, 2342); sock = sp_udp_socket_open_ipv4(127, 0, 0, 1, 2342);
//sock = sp_udp_open_ipv4(172, 23, 42, 29, 2342); //sock = sp_udp_open_ipv4(172, 23, 42, 29, 2342);
if (sock == NULL) if (sock == NULL)
exit(-1); exit(-1);

View file

@ -13,14 +13,14 @@ int main(void) {
sp_bitmap_set(bitmap, (y + x) % PIXEL_WIDTH, y, true); sp_bitmap_set(bitmap, (y + x) % PIXEL_WIDTH, y, true);
} }
BitmapCommand *command = sp_bitmapcommand_from_bitmap(sp_bitmap_clone(bitmap)); BitmapCommand *command = sp_bitmap_command_from_bitmap(sp_bitmap_clone(bitmap));
Packet *packet = sp_bitmapcommand_try_into_packet(command); Packet *packet = sp_bitmap_command_try_into_packet(command);
if (packet == NULL) { if (packet == NULL) {
result = -2; result = -2;
goto exit; goto exit;
} }
if (!sp_udpsocket_send_packet(sock, packet)) { if (!sp_udp_socket_send_packet(sock, packet)) {
result = -3; result = -3;
goto exit; goto exit;
} }

View file

@ -18,6 +18,6 @@ int main(void) {
Header *header = sp_packet_get_header_mut(packet); Header *header = sp_packet_get_header_mut(packet);
printf("[%d, %d, %d, %d, %d]\n", header->command_code, header->a, header->b, header->c, header->d); printf("[%d, %d, %d, %d, %d]\n", header->command_code, header->a, header->b, header->c, header->d);
sp_udpsocket_send_packet(sock, packet); sp_udp_socket_send_packet(sock, packet);
return 0; return 0;
} }

View file

@ -4,9 +4,9 @@
/// DO NOT DO ANY OF THIS! /// DO NOT DO ANY OF THIS!
int main(void) { int main(void) {
BitmapCommand *bmcmd = sp_bitmapcommand_new(sp_bitmap_new_max_sized(), 0, 0, COMPRESSION_CODE_UNCOMPRESSED); BitmapCommand *bmcmd = sp_bitmap_command_new(sp_bitmap_new_max_sized(), 0, 0, COMPRESSION_CODE_UNCOMPRESSED);
BitVecCommand *bvcmd = (BitVecCommand *) bmcmd; BitVecCommand *bvcmd = (BitVecCommand *) bmcmd;
sp_bitveccommand_free(bvcmd); sp_bit_vec_command_free(bvcmd);
uint8_t *data = calloc(1024, 1); uint8_t *data = calloc(1024, 1);
struct GenericCommand generic = { struct GenericCommand generic = {
@ -16,7 +16,7 @@ int main(void) {
sock_init(); sock_init();
sp_udpsocket_send_command(sock, &generic); sp_udp_socket_send_command(sock, &generic);
return 0; return 0;
} }

View file

@ -14,13 +14,13 @@ int main() {
} }
DisplayBitVec *bitvec = sp_bitmap_into_bitvec(sp_bitmap_clone(enabled_pixels)); DisplayBitVec *bitvec = sp_bitmap_into_bitvec(sp_bitmap_clone(enabled_pixels));
BitVecCommand *command = sp_bitveccommand_new(bitvec, 0, BINARY_OPERATION_AND, COMPRESSION_CODE_LZMA); BitVecCommand *command = sp_bit_vec_command_new(bitvec, 0, BINARY_OPERATION_AND, COMPRESSION_CODE_LZMA);
Packet *packet = sp_bitveccommand_try_into_packet(command); Packet *packet = sp_bit_vec_command_try_into_packet(command);
if (packet == NULL) { if (packet == NULL) {
result = -2; result = -2;
goto exit; goto exit;
} }
if (!sp_udpsocket_send_packet(sock, packet)) { if (!sp_udp_socket_send_packet(sock, packet)) {
result = -3; result = -3;
goto exit; goto exit;
} }

File diff suppressed because it is too large Load diff

View file

@ -46,7 +46,7 @@ macro_rules! wrap_method {
$impl:block; $impl:block;
) => { ) => {
paste::paste! { paste::paste! {
$crate::macros::wrap_functions!([< $object_type:lower >]; $crate::macros::wrap_functions!(associate $object_type;
$(#[$meta])* $(#[$meta])*
fn $function( fn $function(
$instance: $ref_or_mut ::core::ptr::NonNull<$object_type> $instance: $ref_or_mut ::core::ptr::NonNull<$object_type>
@ -246,7 +246,7 @@ macro_rules! wrap_functions {
)+ )+
) => { ) => {
::paste::paste! { ::paste::paste! {
$crate::macros::wrap_functions!{[< $object_type:lower >]; $crate::macros::wrap_functions!{[< $object_type:snake >];
$( $(
$(#[$meta])+ $(#[$meta])+
fn $function($($param_name: $param_modifier $param_type),*) $(-> $return_modifier $return_type)? fn $function($($param_name: $param_modifier $param_type),*) $(-> $return_modifier $return_type)?