object name to snake case
This commit is contained in:
		
							parent
							
								
									c702d832f4
								
							
						
					
					
						commit
						41fbdbf3a3
					
				
					 10 changed files with 712 additions and 694 deletions
				
			
		|  | @ -3,27 +3,27 @@ | |||
| int main(void) { | ||||
|     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) | ||||
|         return 1; | ||||
| 
 | ||||
|     sp_chargrid_set(grid, 0, 0, 'H'); | ||||
|     sp_chargrid_set(grid, 1, 0, 'e'); | ||||
|     sp_chargrid_set(grid, 2, 0, 'l'); | ||||
|     sp_chargrid_set(grid, 3, 0, 'l'); | ||||
|     sp_chargrid_set(grid, 4, 0, 'o'); | ||||
|     sp_chargrid_set(grid, 0, 1, 'W'); | ||||
|     sp_chargrid_set(grid, 1, 1, 'o'); | ||||
|     sp_chargrid_set(grid, 2, 1, 'r'); | ||||
|     sp_chargrid_set(grid, 3, 1, 'l'); | ||||
|     sp_chargrid_set(grid, 4, 1, 'd'); | ||||
|     sp_char_grid_set(grid, 0, 0, 'H'); | ||||
|     sp_char_grid_set(grid, 1, 0, 'e'); | ||||
|     sp_char_grid_set(grid, 2, 0, 'l'); | ||||
|     sp_char_grid_set(grid, 3, 0, 'l'); | ||||
|     sp_char_grid_set(grid, 4, 0, 'o'); | ||||
|     sp_char_grid_set(grid, 0, 1, 'W'); | ||||
|     sp_char_grid_set(grid, 1, 1, 'o'); | ||||
|     sp_char_grid_set(grid, 2, 1, 'r'); | ||||
|     sp_char_grid_set(grid, 3, 1, 'l'); | ||||
|     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) | ||||
|         return 1; | ||||
|     sp_udpsocket_send_packet(sock, packet); | ||||
|     sp_udp_socket_send_packet(sock, packet); | ||||
| 
 | ||||
|     return 0; | ||||
| } | ||||
|  |  | |||
|  | @ -5,14 +5,14 @@ void enable_all_pixels(void) { | |||
|     Bitmap *all_on = sp_bitmap_new_max_sized(); | ||||
|     sp_bitmap_fill(all_on, true); | ||||
| 
 | ||||
|     BitmapCommand *bitmapCommand = sp_bitmapcommand_from_bitmap(all_on); | ||||
|     Packet *packet = sp_bitmapcommand_try_into_packet(bitmapCommand); | ||||
|     BitmapCommand *bitmapCommand = sp_bitmap_command_from_bitmap(all_on); | ||||
|     Packet *packet = sp_bitmap_command_try_into_packet(bitmapCommand); | ||||
|     if (packet != NULL) | ||||
|         sp_udpsocket_send_packet(sock, packet); | ||||
|         sp_udp_socket_send_packet(sock, packet); | ||||
| } | ||||
| 
 | ||||
| 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++) { | ||||
|         slice.start[index] = (uint8_t)(index % ((size_t) Brightness_MAX)); | ||||
|     } | ||||
|  | @ -23,13 +23,13 @@ int main(void) { | |||
| 
 | ||||
|     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); | ||||
| 
 | ||||
|     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) | ||||
|         return -2; | ||||
| 
 | ||||
|     sp_udpsocket_send_packet(sock, packet); | ||||
|     sp_udp_socket_send_packet(sock, packet); | ||||
|     return 0; | ||||
| } | ||||
|  |  | |||
|  | @ -28,12 +28,12 @@ bool log_command(struct GenericCommand *command) { | |||
|         case COMMAND_TAG_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; | ||||
|             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 h = sp_bitmap_height(bitmap); | ||||
| 
 | ||||
|  | @ -45,11 +45,11 @@ bool log_command(struct GenericCommand *command) { | |||
|             BrightnessGridCommand *gridCommand = command->data.brightness_grid; | ||||
| 
 | ||||
|             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); | ||||
|             size_t w = sp_brightnessgrid_width(grid); | ||||
|             size_t h = sp_brightnessgrid_height(grid); | ||||
|             BrightnessGrid *grid = sp_brightness_grid_command_get_grid_mut(gridCommand); | ||||
|             size_t w = sp_brightness_grid_width(grid); | ||||
|             size_t h = sp_brightness_grid_height(grid); | ||||
| 
 | ||||
|             printf("-> BrightnessGridCommand with params: x=%zu, y=%zu, w=%zu, h=%zu\n", | ||||
|                     x, y, w, h); | ||||
|  | @ -59,11 +59,11 @@ bool log_command(struct GenericCommand *command) { | |||
|             CharGridCommand *gridCommand = command->data.char_grid; | ||||
| 
 | ||||
|             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); | ||||
|             size_t w = sp_chargrid_width(grid); | ||||
|             size_t h = sp_chargrid_height(grid); | ||||
|             CharGrid *grid = sp_char_grid_command_get_grid_mut(gridCommand); | ||||
|             size_t w = sp_char_grid_width(grid); | ||||
|             size_t h = sp_char_grid_height(grid); | ||||
| 
 | ||||
|             printf("-> CharGridCommand with params: x=%zu, y=%zu, w=%zu, h=%zu\n", | ||||
|                     x, y, w, h); | ||||
|  | @ -73,11 +73,11 @@ bool log_command(struct GenericCommand *command) { | |||
|             Cp437GridCommand *gridCommand = command->data.cp437_grid; | ||||
| 
 | ||||
|             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); | ||||
|             size_t w = sp_cp437grid_width(grid); | ||||
|             size_t h = sp_cp437grid_height(grid); | ||||
|             Cp437Grid *grid = sp_cp437_grid_command_get_grid_mut(gridCommand); | ||||
|             size_t w = sp_cp437_grid_width(grid); | ||||
|             size_t h = sp_cp437_grid_height(grid); | ||||
| 
 | ||||
|             printf("-> Cp437GridCommand with params: x=%zu, y=%zu, w=%zu, h=%zu\n", | ||||
|                     x, y, w, h); | ||||
|  | @ -86,10 +86,10 @@ bool log_command(struct GenericCommand *command) { | |||
|         case COMMAND_TAG_BIT_VEC: { | ||||
|             BitVecCommand *bitvecCommand = command->data.bit_vec; | ||||
| 
 | ||||
|             size_t offset = sp_bitveccommand_get_offset(bitvecCommand); | ||||
|             CompressionCode compression = sp_bitveccommand_get_compression(bitvecCommand); | ||||
|             size_t offset = sp_bit_vec_command_get_offset(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; | ||||
|             switch (operation) { | ||||
|                 case BINARY_OPERATION_AND: | ||||
|  | @ -109,8 +109,8 @@ bool log_command(struct GenericCommand *command) { | |||
|                     break; | ||||
|             } | ||||
| 
 | ||||
|             DisplayBitVec *bitvec = sp_bitveccommand_get_bitvec_mut(bitvecCommand); | ||||
|             size_t len = sp_displaybitvec_len(bitvec); | ||||
|             DisplayBitVec *bitvec = sp_bit_vec_command_get_bitvec_mut(bitvecCommand); | ||||
|             size_t len = sp_display_bit_vec_len(bitvec); | ||||
| 
 | ||||
|             printf("-> BitVecCommand with params: offset=%zu, length=%zu, compression=%hu, operation=%s\n", | ||||
|                     offset, len, compression, operationText); | ||||
|  | @ -129,7 +129,7 @@ bool log_command(struct GenericCommand *command) { | |||
|             break; | ||||
|         } | ||||
|         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); | ||||
|             break; | ||||
|         } | ||||
|  | @ -198,10 +198,10 @@ int main(int argc, char **argv) { | |||
|                header->command_code, header->a, header->b, header->c, header->d, | ||||
|                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); | ||||
| 
 | ||||
|         sp_genericcommand_free(command); | ||||
|         sp_generic_command_free(command); | ||||
|     } | ||||
| 
 | ||||
|     close(udp_socket); | ||||
|  |  | |||
|  | @ -10,11 +10,11 @@ | |||
| static UdpSocket *sock = NULL; | ||||
| 
 | ||||
| void sock_free() { | ||||
|     sp_udpsocket_free(sock); | ||||
|     sp_udp_socket_free(sock); | ||||
| } | ||||
| 
 | ||||
| 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);
 | ||||
|     if (sock == NULL) | ||||
|         exit(-1); | ||||
|  |  | |||
|  | @ -13,14 +13,14 @@ int main(void) { | |||
|             sp_bitmap_set(bitmap, (y + x) % PIXEL_WIDTH, y, true); | ||||
|         } | ||||
| 
 | ||||
|         BitmapCommand *command = sp_bitmapcommand_from_bitmap(sp_bitmap_clone(bitmap)); | ||||
|         Packet *packet = sp_bitmapcommand_try_into_packet(command); | ||||
|         BitmapCommand *command = sp_bitmap_command_from_bitmap(sp_bitmap_clone(bitmap)); | ||||
|         Packet *packet = sp_bitmap_command_try_into_packet(command); | ||||
|         if (packet == NULL) { | ||||
|             result = -2; | ||||
|             goto exit; | ||||
|         } | ||||
| 
 | ||||
|         if (!sp_udpsocket_send_packet(sock, packet)) { | ||||
|         if (!sp_udp_socket_send_packet(sock, packet)) { | ||||
|             result = -3; | ||||
|             goto exit; | ||||
|         } | ||||
|  |  | |||
|  | @ -18,6 +18,6 @@ int main(void) { | |||
|     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); | ||||
| 
 | ||||
|     sp_udpsocket_send_packet(sock, packet); | ||||
|     sp_udp_socket_send_packet(sock, packet); | ||||
|     return 0; | ||||
| } | ||||
|  |  | |||
|  | @ -4,9 +4,9 @@ | |||
| 
 | ||||
| /// DO NOT DO ANY OF THIS!
 | ||||
| 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; | ||||
|     sp_bitveccommand_free(bvcmd); | ||||
|     sp_bit_vec_command_free(bvcmd); | ||||
| 
 | ||||
|     uint8_t *data = calloc(1024, 1); | ||||
|     struct GenericCommand generic =  { | ||||
|  | @ -16,7 +16,7 @@ int main(void) { | |||
| 
 | ||||
|     sock_init(); | ||||
| 
 | ||||
|     sp_udpsocket_send_command(sock, &generic); | ||||
|     sp_udp_socket_send_command(sock, &generic); | ||||
| 
 | ||||
|     return 0; | ||||
| } | ||||
|  |  | |||
|  | @ -14,13 +14,13 @@ int main() { | |||
|         } | ||||
| 
 | ||||
|         DisplayBitVec *bitvec = sp_bitmap_into_bitvec(sp_bitmap_clone(enabled_pixels)); | ||||
|         BitVecCommand *command = sp_bitveccommand_new(bitvec, 0, BINARY_OPERATION_AND, COMPRESSION_CODE_LZMA); | ||||
|         Packet *packet = sp_bitveccommand_try_into_packet(command); | ||||
|         BitVecCommand *command = sp_bit_vec_command_new(bitvec, 0, BINARY_OPERATION_AND, COMPRESSION_CODE_LZMA); | ||||
|         Packet *packet = sp_bit_vec_command_try_into_packet(command); | ||||
|         if (packet == NULL) { | ||||
|             result = -2; | ||||
|             goto exit; | ||||
|         } | ||||
|         if (!sp_udpsocket_send_packet(sock, packet)) { | ||||
|         if (!sp_udp_socket_send_packet(sock, packet)) { | ||||
|             result = -3; | ||||
|             goto exit; | ||||
|         } | ||||
|  |  | |||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							|  | @ -46,7 +46,7 @@ macro_rules! wrap_method { | |||
|         $impl:block; | ||||
|     ) => { | ||||
|         paste::paste! { | ||||
|             $crate::macros::wrap_functions!([< $object_type:lower >]; | ||||
|             $crate::macros::wrap_functions!(associate $object_type; | ||||
|                 $(#[$meta])* | ||||
|                 fn $function( | ||||
|                     $instance: $ref_or_mut ::core::ptr::NonNull<$object_type> | ||||
|  | @ -246,7 +246,7 @@ macro_rules! wrap_functions { | |||
|         )+ | ||||
|     ) => { | ||||
|         ::paste::paste! { | ||||
|             $crate::macros::wrap_functions!{[< $object_type:lower >]; | ||||
|             $crate::macros::wrap_functions!{[< $object_type:snake >]; | ||||
|                 $( | ||||
|                     $(#[$meta])+ | ||||
|                     fn $function($($param_name: $param_modifier $param_type),*) $(-> $return_modifier $return_type)? | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vinzenz Schroeter
						Vinzenz Schroeter