type per command, binding generation macros, nix package #4
					 14 changed files with 630 additions and 519 deletions
				
			
		| 
						 | 
					@ -675,6 +675,8 @@ void sp_bitmap_free(struct Bitmap */*notnull*/ instance);
 | 
				
			||||||
 * The provided BitVec gets consumed.
 | 
					 * The provided BitVec gets consumed.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns NULL in case of error.
 | 
					 * Returns NULL in case of error.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_bitmap module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct Bitmap *sp_bitmap_from_bitvec(size_t width, BitVec */*notnull*/ bitvec);
 | 
					struct Bitmap *sp_bitmap_from_bitvec(size_t width, BitVec */*notnull*/ bitvec);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -702,6 +704,8 @@ size_t sp_bitmap_height(struct Bitmap */*notnull*/ instance);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Consumes the Bitmap and returns the contained BitVec.
 | 
					 * Consumes the Bitmap and returns the contained BitVec.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_bitmap module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
BitVec */*notnull*/ sp_bitmap_into_bitvec(struct Bitmap */*notnull*/ bitmap);
 | 
					BitVec */*notnull*/ sp_bitmap_into_bitvec(struct Bitmap */*notnull*/ bitmap);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -711,6 +715,8 @@ BitVec */*notnull*/ sp_bitmap_into_bitvec(struct Bitmap */*notnull*/ bitmap);
 | 
				
			||||||
 * The provided [Bitmap] gets consumed.
 | 
					 * The provided [Bitmap] gets consumed.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns NULL in case of an error.
 | 
					 * Returns NULL in case of an error.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_bitmap module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct Packet *sp_bitmap_into_packet(struct Bitmap */*notnull*/ bitmap,
 | 
					struct Packet *sp_bitmap_into_packet(struct Bitmap */*notnull*/ bitmap,
 | 
				
			||||||
                                     size_t x,
 | 
					                                     size_t x,
 | 
				
			||||||
| 
						 | 
					@ -726,6 +732,8 @@ struct Packet *sp_bitmap_into_packet(struct Bitmap */*notnull*/ bitmap,
 | 
				
			||||||
 * - `height`: size in pixels in y-direction
 | 
					 * - `height`: size in pixels in y-direction
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * returns: [Bitmap] that contains a copy of the provided data, or NULL in case of an error.
 | 
					 * returns: [Bitmap] that contains a copy of the provided data, or NULL in case of an error.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_bitmap module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct Bitmap *sp_bitmap_load(size_t width,
 | 
					struct Bitmap *sp_bitmap_load(size_t width,
 | 
				
			||||||
                              size_t height,
 | 
					                              size_t height,
 | 
				
			||||||
| 
						 | 
					@ -755,6 +763,8 @@ struct Bitmap *sp_bitmap_load(size_t width,
 | 
				
			||||||
 * sp_bitmap_set(grid, 0, 0, false);
 | 
					 * sp_bitmap_set(grid, 0, 0, false);
 | 
				
			||||||
 * sp_bitmap_free(grid);
 | 
					 * sp_bitmap_free(grid);
 | 
				
			||||||
 * ```
 | 
					 * ```
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_bitmap module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct Bitmap *sp_bitmap_new(size_t width, size_t height);
 | 
					struct Bitmap *sp_bitmap_new(size_t width, size_t height);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -762,6 +772,8 @@ struct Bitmap *sp_bitmap_new(size_t width, size_t height);
 | 
				
			||||||
 * Creates a new [Bitmap] with a size matching the screen.
 | 
					 * Creates a new [Bitmap] with a size matching the screen.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * returns: [Bitmap] initialized to all pixels off.
 | 
					 * returns: [Bitmap] initialized to all pixels off.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_bitmap module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct Bitmap */*notnull*/ sp_bitmap_new_max_sized(void);
 | 
					struct Bitmap */*notnull*/ sp_bitmap_new_max_sized(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -845,6 +857,8 @@ bool sp_bitvec_get(BitVec */*notnull*/ instance, size_t index);
 | 
				
			||||||
 * The provided [DisplayBitVec] gets consumed.
 | 
					 * The provided [DisplayBitVec] gets consumed.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns NULL in case of an error.
 | 
					 * Returns NULL in case of an error.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_bitvec module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct Packet *sp_bitvec_into_packet(BitVec */*notnull*/ bitvec,
 | 
					struct Packet *sp_bitvec_into_packet(BitVec */*notnull*/ bitvec,
 | 
				
			||||||
                                     size_t offset,
 | 
					                                     size_t offset,
 | 
				
			||||||
| 
						 | 
					@ -869,6 +883,8 @@ size_t sp_bitvec_len(BitVec */*notnull*/ instance);
 | 
				
			||||||
 * Interpret the data as a series of bits and load then into a new [DisplayBitVec] instance.
 | 
					 * Interpret the data as a series of bits and load then into a new [DisplayBitVec] instance.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * returns: [DisplayBitVec] instance containing data.
 | 
					 * returns: [DisplayBitVec] instance containing data.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_bitvec module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
BitVec */*notnull*/ sp_bitvec_load(struct ByteSlice data);
 | 
					BitVec */*notnull*/ sp_bitvec_load(struct ByteSlice data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -884,6 +900,8 @@ BitVec */*notnull*/ sp_bitvec_load(struct ByteSlice data);
 | 
				
			||||||
 * # Panics
 | 
					 * # Panics
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * - when `size` is not divisible by 8.
 | 
					 * - when `size` is not divisible by 8.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_bitvec module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
BitVec */*notnull*/ sp_bitvec_new(size_t size);
 | 
					BitVec */*notnull*/ sp_bitvec_new(size_t size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -965,6 +983,8 @@ size_t sp_brightness_grid_height(BrightnessGrid */*notnull*/ instance);
 | 
				
			||||||
 * The provided [BrightnessGrid] gets consumed.
 | 
					 * The provided [BrightnessGrid] gets consumed.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns NULL in case of an error.
 | 
					 * Returns NULL in case of an error.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_brightness_grid module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct Packet *sp_brightness_grid_into_packet(BrightnessGrid */*notnull*/ grid,
 | 
					struct Packet *sp_brightness_grid_into_packet(BrightnessGrid */*notnull*/ grid,
 | 
				
			||||||
                                              size_t x,
 | 
					                                              size_t x,
 | 
				
			||||||
| 
						 | 
					@ -976,6 +996,8 @@ struct Packet *sp_brightness_grid_into_packet(BrightnessGrid */*notnull*/ grid,
 | 
				
			||||||
 * Any out of range values will be set to [Brightness::MAX] or [Brightness::MIN].
 | 
					 * Any out of range values will be set to [Brightness::MAX] or [Brightness::MIN].
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * returns: new [BrightnessGrid] instance, or NULL in case of an error.
 | 
					 * returns: new [BrightnessGrid] instance, or NULL in case of an error.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_brightness_grid module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
BrightnessGrid *sp_brightness_grid_load(size_t width,
 | 
					BrightnessGrid *sp_brightness_grid_load(size_t width,
 | 
				
			||||||
                                        size_t height,
 | 
					                                        size_t height,
 | 
				
			||||||
| 
						 | 
					@ -999,6 +1021,8 @@ BrightnessGrid *sp_brightness_grid_load(size_t width,
 | 
				
			||||||
 * TypedCommand *command = sp_command_char_brightness(grid);
 | 
					 * TypedCommand *command = sp_command_char_brightness(grid);
 | 
				
			||||||
 * sp_udp_free(connection);
 | 
					 * sp_udp_free(connection);
 | 
				
			||||||
 * ```
 | 
					 * ```
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_brightness_grid module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
BrightnessGrid */*notnull*/ sp_brightness_grid_new(size_t width, size_t height);
 | 
					BrightnessGrid */*notnull*/ sp_brightness_grid_new(size_t width, size_t height);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1080,6 +1104,8 @@ size_t sp_char_grid_height(CharGrid */*notnull*/ instance);
 | 
				
			||||||
 * The provided [CharGrid] gets consumed.
 | 
					 * The provided [CharGrid] gets consumed.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns NULL in case of an error.
 | 
					 * Returns NULL in case of an error.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_char_grid module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct Packet *sp_char_grid_into_packet(CharGrid */*notnull*/ grid,
 | 
					struct Packet *sp_char_grid_into_packet(CharGrid */*notnull*/ grid,
 | 
				
			||||||
                                        size_t x,
 | 
					                                        size_t x,
 | 
				
			||||||
| 
						 | 
					@ -1089,6 +1115,8 @@ struct Packet *sp_char_grid_into_packet(CharGrid */*notnull*/ grid,
 | 
				
			||||||
 * Loads a [CharGrid] with the specified dimensions from the provided data.
 | 
					 * Loads a [CharGrid] with the specified dimensions from the provided data.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * returns: new CharGrid or NULL in case of an error
 | 
					 * returns: new CharGrid or NULL in case of an error
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_char_grid module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
CharGrid *sp_char_grid_load(size_t width, size_t height, struct ByteSlice data);
 | 
					CharGrid *sp_char_grid_load(size_t width, size_t height, struct ByteSlice data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1105,6 +1133,8 @@ CharGrid *sp_char_grid_load(size_t width, size_t height, struct ByteSlice data);
 | 
				
			||||||
 * sp_char_grid_set(grid, 0, 0, '!');
 | 
					 * sp_char_grid_set(grid, 0, 0, '!');
 | 
				
			||||||
 * sp_char_grid_free(grid);
 | 
					 * sp_char_grid_free(grid);
 | 
				
			||||||
 * ```
 | 
					 * ```
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_char_grid module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
CharGrid */*notnull*/ sp_char_grid_new(size_t width, size_t height);
 | 
					CharGrid */*notnull*/ sp_char_grid_new(size_t width, size_t height);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1152,6 +1182,8 @@ void sp_cmd_bitmap_free(struct BitmapCommand */*notnull*/ instance);
 | 
				
			||||||
 * leaving other fields as their default values.
 | 
					 * leaving other fields as their default values.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Rust equivalent: `BitmapCommand::from(bitmap)`
 | 
					 * Rust equivalent: `BitmapCommand::from(bitmap)`
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cmd_bitmap module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct BitmapCommand */*notnull*/ sp_cmd_bitmap_from_bitmap(struct Bitmap */*notnull*/ bitmap);
 | 
					struct BitmapCommand */*notnull*/ sp_cmd_bitmap_from_bitmap(struct Bitmap */*notnull*/ bitmap);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1183,6 +1215,8 @@ void sp_cmd_bitmap_get_origin(struct BitmapCommand */*notnull*/ command,
 | 
				
			||||||
 * The passed [Bitmap] gets consumed.
 | 
					 * The passed [Bitmap] gets consumed.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns: a new [BitmapCommand] instance.
 | 
					 * Returns: a new [BitmapCommand] instance.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cmd_bitmap module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct BitmapCommand */*notnull*/ sp_cmd_bitmap_new(struct Bitmap */*notnull*/ bitmap,
 | 
					struct BitmapCommand */*notnull*/ sp_cmd_bitmap_new(struct Bitmap */*notnull*/ bitmap,
 | 
				
			||||||
                                                    size_t origin_x,
 | 
					                                                    size_t origin_x,
 | 
				
			||||||
| 
						 | 
					@ -1212,6 +1246,8 @@ void sp_cmd_bitmap_set_origin(struct BitmapCommand */*notnull*/ command,
 | 
				
			||||||
 * Tries to turn a [BitmapCommand] into a [Packet].
 | 
					 * Tries to turn a [BitmapCommand] into a [Packet].
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns: NULL or a [Packet] containing the command.
 | 
					 * Returns: NULL or a [Packet] containing the command.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cmd_bitmap module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct Packet *sp_cmd_bitmap_try_into_packet(struct BitmapCommand */*notnull*/ command);
 | 
					struct Packet *sp_cmd_bitmap_try_into_packet(struct BitmapCommand */*notnull*/ command);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1258,6 +1294,8 @@ BinaryOperation sp_cmd_bitvec_get_operation(struct BitVecCommand */*notnull*/ in
 | 
				
			||||||
 * For example, [`BinaryOperation::Or`] can be used to turn on some pixels without affecting other pixels.
 | 
					 * For example, [`BinaryOperation::Or`] can be used to turn on some pixels without affecting other pixels.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * The contained [`DisplayBitVec`] is always uncompressed.
 | 
					 * The contained [`DisplayBitVec`] is always uncompressed.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cmd_bitvec module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct BitVecCommand */*notnull*/ sp_cmd_bitvec_new(BitVec */*notnull*/ bitvec,
 | 
					struct BitVecCommand */*notnull*/ sp_cmd_bitvec_new(BitVec */*notnull*/ bitvec,
 | 
				
			||||||
                                                    size_t offset,
 | 
					                                                    size_t offset,
 | 
				
			||||||
| 
						 | 
					@ -1292,6 +1330,8 @@ void sp_cmd_bitvec_set_operation(struct BitVecCommand */*notnull*/ instance,
 | 
				
			||||||
 * Tries to turn a [BitVecCommand] into a [Packet].
 | 
					 * Tries to turn a [BitVecCommand] into a [Packet].
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns: NULL or a [Packet] containing the command.
 | 
					 * Returns: NULL or a [Packet] containing the command.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cmd_bitvec module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct Packet *sp_cmd_bitvec_try_into_packet(struct BitVecCommand */*notnull*/ command);
 | 
					struct Packet *sp_cmd_bitvec_try_into_packet(struct BitVecCommand */*notnull*/ command);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1310,12 +1350,19 @@ void sp_cmd_brightness_global_free(struct GlobalBrightnessCommand */*notnull*/ i
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
Brightness sp_cmd_brightness_global_get_brightness(struct GlobalBrightnessCommand */*notnull*/ instance);
 | 
					Brightness sp_cmd_brightness_global_get_brightness(struct GlobalBrightnessCommand */*notnull*/ instance);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Turns the command into a packet
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cmd_brightness_global module.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
struct Packet */*notnull*/ sp_cmd_brightness_global_into_packet(struct GlobalBrightnessCommand */*notnull*/ command);
 | 
					struct Packet */*notnull*/ sp_cmd_brightness_global_into_packet(struct GlobalBrightnessCommand */*notnull*/ command);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Set the brightness of all tiles to the same value.
 | 
					 * Set the brightness of all tiles to the same value.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns: a new [GlobalBrightnessCommand] instance.
 | 
					 * Returns: a new [GlobalBrightnessCommand] instance.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cmd_brightness_global module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct GlobalBrightnessCommand */*notnull*/ sp_cmd_brightness_global_new(Brightness brightness);
 | 
					struct GlobalBrightnessCommand */*notnull*/ sp_cmd_brightness_global_new(Brightness brightness);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1338,6 +1385,8 @@ void sp_cmd_brightness_grid_free(struct BrightnessGridCommand */*notnull*/ insta
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Moves the provided [BrightnessGrid] into a new [BrightnessGridCommand],
 | 
					 * Moves the provided [BrightnessGrid] into a new [BrightnessGridCommand],
 | 
				
			||||||
 * leaving other fields as their default values.
 | 
					 * leaving other fields as their default values.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cmd_brightness_grid module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_from_grid(BrightnessGrid */*notnull*/ grid);
 | 
					struct BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_from_grid(BrightnessGrid */*notnull*/ grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1357,6 +1406,8 @@ void sp_cmd_brightness_grid_get_origin(struct BrightnessGridCommand */*notnull*/
 | 
				
			||||||
 * Tries to turn a [BrightnessGridCommand] into a [Packet].
 | 
					 * Tries to turn a [BrightnessGridCommand] into a [Packet].
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns: NULL or a [Packet] containing the command.
 | 
					 * Returns: NULL or a [Packet] containing the command.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cmd_brightness_grid module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct Packet *sp_cmd_brightness_grid_into_packet(struct BrightnessGridCommand */*notnull*/ command);
 | 
					struct Packet *sp_cmd_brightness_grid_into_packet(struct BrightnessGridCommand */*notnull*/ command);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1366,6 +1417,8 @@ struct Packet *sp_cmd_brightness_grid_into_packet(struct BrightnessGridCommand *
 | 
				
			||||||
 * The passed [BrightnessGrid] gets consumed.
 | 
					 * The passed [BrightnessGrid] gets consumed.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns: a new [BrightnessGridCommand] instance.
 | 
					 * Returns: a new [BrightnessGridCommand] instance.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cmd_brightness_grid module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_new(BrightnessGrid */*notnull*/ grid,
 | 
					struct BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_new(BrightnessGrid */*notnull*/ grid,
 | 
				
			||||||
                                                                     size_t origin_x,
 | 
					                                                                     size_t origin_x,
 | 
				
			||||||
| 
						 | 
					@ -1397,13 +1450,15 @@ void sp_cmd_char_grid_free(struct CharGridCommand */*notnull*/ instance);
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Moves the provided [CharGrid] into a new [CharGridCommand],
 | 
					 * Moves the provided [CharGrid] into a new [CharGridCommand],
 | 
				
			||||||
 * leaving other fields as their default values.
 | 
					 * leaving other fields as their default values.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cmd_char_grid module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct CharGridCommand */*notnull*/ sp_cmd_char_grid_from_grid(CharGrid */*notnull*/ grid);
 | 
					struct CharGridCommand */*notnull*/ sp_cmd_char_grid_from_grid(CharGrid */*notnull*/ grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Returns a pointer to the [CharGrid] contained in the [CharGridCommand].
 | 
					 * Returns a pointer to the [CharGrid] contained in the [CharGridCommand].
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
CharGrid *sp_cmd_char_grid_get(struct CharGridCommand */*notnull*/ command);
 | 
					CharGrid */*notnull*/ sp_cmd_char_grid_get(struct CharGridCommand */*notnull*/ command);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Reads the origin field of the [CharGridCommand].
 | 
					 * Reads the origin field of the [CharGridCommand].
 | 
				
			||||||
| 
						 | 
					@ -1418,6 +1473,8 @@ void sp_cmd_char_grid_get_origin(struct CharGridCommand */*notnull*/ command,
 | 
				
			||||||
 * The passed [CharGrid] gets consumed.
 | 
					 * The passed [CharGrid] gets consumed.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns: a new [CharGridCommand] instance.
 | 
					 * Returns: a new [CharGridCommand] instance.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cmd_char_grid module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct CharGridCommand */*notnull*/ sp_cmd_char_grid_new(CharGrid */*notnull*/ grid,
 | 
					struct CharGridCommand */*notnull*/ sp_cmd_char_grid_new(CharGrid */*notnull*/ grid,
 | 
				
			||||||
                                                         size_t origin_x,
 | 
					                                                         size_t origin_x,
 | 
				
			||||||
| 
						 | 
					@ -1440,6 +1497,8 @@ void sp_cmd_char_grid_set_origin(struct CharGridCommand */*notnull*/ command,
 | 
				
			||||||
 * Tries to turn a [CharGridCommand] into a [Packet].
 | 
					 * Tries to turn a [CharGridCommand] into a [Packet].
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns: NULL or a [Packet] containing the command.
 | 
					 * Returns: NULL or a [Packet] containing the command.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cmd_char_grid module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct Packet *sp_cmd_char_grid_try_into_packet(struct CharGridCommand */*notnull*/ command);
 | 
					struct Packet *sp_cmd_char_grid_try_into_packet(struct CharGridCommand */*notnull*/ command);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1454,6 +1513,8 @@ void sp_cmd_clear_free(struct ClearCommand */*notnull*/ instance);
 | 
				
			||||||
 * Does not affect brightness.
 | 
					 * Does not affect brightness.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns: a new [ClearCommand] instance.
 | 
					 * Returns: a new [ClearCommand] instance.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cmd_clear module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct ClearCommand */*notnull*/ sp_cmd_clear_new(void);
 | 
					struct ClearCommand */*notnull*/ sp_cmd_clear_new(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1470,6 +1531,8 @@ void sp_cmd_cp437_grid_free(struct Cp437GridCommand */*notnull*/ instance);
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Moves the provided [Cp437Grid] into a new [Cp437GridCommand],
 | 
					 * Moves the provided [Cp437Grid] into a new [Cp437GridCommand],
 | 
				
			||||||
 * leaving other fields as their default values.
 | 
					 * leaving other fields as their default values.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cmd_cp437_grid module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_from_grid(Cp437Grid */*notnull*/ grid);
 | 
					struct Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_from_grid(Cp437Grid */*notnull*/ grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1498,6 +1561,8 @@ void sp_cmd_cp437_grid_get_origin(struct Cp437GridCommand */*notnull*/ command,
 | 
				
			||||||
 * The text is sent in the form of a 2D grid of [CP-437] encoded characters.
 | 
					 * The text is sent in the form of a 2D grid of [CP-437] encoded characters.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * The origin is relative to the top-left of the display.
 | 
					 * The origin is relative to the top-left of the display.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cmd_cp437_grid module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_new(Cp437Grid */*notnull*/ grid,
 | 
					struct Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_new(Cp437Grid */*notnull*/ grid,
 | 
				
			||||||
                                                           size_t origin_x,
 | 
					                                                           size_t origin_x,
 | 
				
			||||||
| 
						 | 
					@ -1524,6 +1589,8 @@ void sp_cmd_cp437_grid_set_origin(struct Cp437GridCommand */*notnull*/ command,
 | 
				
			||||||
 * Tries to turn a [Cp437GridCommand] into a [Packet].
 | 
					 * Tries to turn a [Cp437GridCommand] into a [Packet].
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns: NULL or a [Packet] containing the command.
 | 
					 * Returns: NULL or a [Packet] containing the command.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cmd_cp437_grid module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct Packet *sp_cmd_cp437_grid_try_into_packet(struct Cp437GridCommand */*notnull*/ command);
 | 
					struct Packet *sp_cmd_cp437_grid_try_into_packet(struct Cp437GridCommand */*notnull*/ command);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1536,6 +1603,8 @@ void sp_cmd_fade_out_free(struct FadeOutCommand */*notnull*/ instance);
 | 
				
			||||||
 * A yet-to-be-tested command.
 | 
					 * A yet-to-be-tested command.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns: a new [FadeOutCommand] instance.
 | 
					 * Returns: a new [FadeOutCommand] instance.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cmd_fade_out module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct FadeOutCommand */*notnull*/ sp_cmd_fade_out_new(void);
 | 
					struct FadeOutCommand */*notnull*/ sp_cmd_fade_out_new(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1588,6 +1657,8 @@ void sp_cmd_hard_reset_free(struct HardResetCommand */*notnull*/ instance);
 | 
				
			||||||
 * Please do not send this in your normal program flow.
 | 
					 * Please do not send this in your normal program flow.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns: a new [HardResetCommand] instance.
 | 
					 * Returns: a new [HardResetCommand] instance.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cmd_hard_reset module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct HardResetCommand */*notnull*/ sp_cmd_hard_reset_new(void);
 | 
					struct HardResetCommand */*notnull*/ sp_cmd_hard_reset_new(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1650,6 +1721,8 @@ size_t sp_cp437_grid_height(Cp437Grid */*notnull*/ instance);
 | 
				
			||||||
 * The provided [Cp437Grid] gets consumed.
 | 
					 * The provided [Cp437Grid] gets consumed.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns NULL in case of an error.
 | 
					 * Returns NULL in case of an error.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cp437_grid module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct Packet *sp_cp437_grid_into_packet(Cp437Grid */*notnull*/ grid,
 | 
					struct Packet *sp_cp437_grid_into_packet(Cp437Grid */*notnull*/ grid,
 | 
				
			||||||
                                         size_t x,
 | 
					                                         size_t x,
 | 
				
			||||||
| 
						 | 
					@ -1657,6 +1730,8 @@ struct Packet *sp_cp437_grid_into_packet(Cp437Grid */*notnull*/ grid,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Loads a [Cp437Grid] with the specified dimensions from the provided data.
 | 
					 * Loads a [Cp437Grid] with the specified dimensions from the provided data.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cp437_grid module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
Cp437Grid *sp_cp437_grid_load(size_t width,
 | 
					Cp437Grid *sp_cp437_grid_load(size_t width,
 | 
				
			||||||
                              size_t height,
 | 
					                              size_t height,
 | 
				
			||||||
| 
						 | 
					@ -1666,6 +1741,8 @@ Cp437Grid *sp_cp437_grid_load(size_t width,
 | 
				
			||||||
 * Creates a new [Cp437Grid] with the specified dimensions.
 | 
					 * Creates a new [Cp437Grid] with the specified dimensions.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * returns: [Cp437Grid] initialized to 0.
 | 
					 * returns: [Cp437Grid] initialized to 0.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function is part of the sp_cp437_grid module.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
Cp437Grid */*notnull*/ sp_cp437_grid_new(size_t width, size_t height);
 | 
					Cp437Grid */*notnull*/ sp_cp437_grid_new(size_t width, size_t height);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,17 +1,18 @@
 | 
				
			||||||
use crate::{
 | 
					use crate::{
 | 
				
			||||||
    macros::{wrap_clone, wrap_fields, wrap_free},
 | 
					    macros::{wrap_clone, wrap_fields, wrap_free, wrap_functions},
 | 
				
			||||||
    mem::{heap_move_nonnull, heap_move_ok, heap_remove},
 | 
					    mem::{heap_move_nonnull, heap_move_ok, heap_remove},
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use servicepoint::{Bitmap, BitmapCommand, CompressionCode, Origin, Packet};
 | 
					use servicepoint::{Bitmap, BitmapCommand, CompressionCode, Origin, Packet};
 | 
				
			||||||
use std::ptr::NonNull;
 | 
					use std::ptr::NonNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wrap_functions!(sp_cmd_bitmap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Sets a window of pixels to the specified values.
 | 
					    /// Sets a window of pixels to the specified values.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// The passed [Bitmap] gets consumed.
 | 
					    /// The passed [Bitmap] gets consumed.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Returns: a new [BitmapCommand] instance.
 | 
					    /// Returns: a new [BitmapCommand] instance.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn new(
 | 
				
			||||||
pub unsafe extern "C" fn sp_cmd_bitmap_new(
 | 
					 | 
				
			||||||
        bitmap: NonNull<Bitmap>,
 | 
					        bitmap: NonNull<Bitmap>,
 | 
				
			||||||
        origin_x: usize,
 | 
					        origin_x: usize,
 | 
				
			||||||
        origin_y: usize,
 | 
					        origin_y: usize,
 | 
				
			||||||
| 
						 | 
					@ -28,8 +29,7 @@ pub unsafe extern "C" fn sp_cmd_bitmap_new(
 | 
				
			||||||
    /// leaving other fields as their default values.
 | 
					    /// leaving other fields as their default values.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Rust equivalent: `BitmapCommand::from(bitmap)`
 | 
					    /// Rust equivalent: `BitmapCommand::from(bitmap)`
 | 
				
			||||||
#[no_mangle]
 | 
					    fn from_bitmap(
 | 
				
			||||||
pub unsafe extern "C" fn sp_cmd_bitmap_from_bitmap(
 | 
					 | 
				
			||||||
        bitmap: NonNull<Bitmap>,
 | 
					        bitmap: NonNull<Bitmap>,
 | 
				
			||||||
    ) -> NonNull<BitmapCommand> {
 | 
					    ) -> NonNull<BitmapCommand> {
 | 
				
			||||||
        heap_move_nonnull(unsafe { heap_remove(bitmap) }.into())
 | 
					        heap_move_nonnull(unsafe { heap_remove(bitmap) }.into())
 | 
				
			||||||
| 
						 | 
					@ -38,13 +38,14 @@ pub unsafe extern "C" fn sp_cmd_bitmap_from_bitmap(
 | 
				
			||||||
    /// Tries to turn a [BitmapCommand] into a [Packet].
 | 
					    /// Tries to turn a [BitmapCommand] into a [Packet].
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Returns: NULL or a [Packet] containing the command.
 | 
					    /// Returns: NULL or a [Packet] containing the command.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn try_into_packet(
 | 
				
			||||||
pub unsafe extern "C" fn sp_cmd_bitmap_try_into_packet(
 | 
					 | 
				
			||||||
        command: NonNull<BitmapCommand>,
 | 
					        command: NonNull<BitmapCommand>,
 | 
				
			||||||
    ) -> *mut Packet {
 | 
					    ) -> *mut Packet {
 | 
				
			||||||
        heap_move_ok(unsafe { heap_remove(command) }.try_into())
 | 
					        heap_move_ok(unsafe { heap_remove(command) }.try_into())
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wrap_clone!(sp_cmd_bitmap::BitmapCommand);
 | 
					wrap_clone!(sp_cmd_bitmap::BitmapCommand);
 | 
				
			||||||
wrap_free!(sp_cmd_bitmap::BitmapCommand);
 | 
					wrap_free!(sp_cmd_bitmap::BitmapCommand);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
use crate::{
 | 
					use crate::{
 | 
				
			||||||
    macros::{wrap_clone, wrap_fields, wrap_free},
 | 
					    macros::{wrap_clone, wrap_fields, wrap_free, wrap_functions},
 | 
				
			||||||
    mem::{heap_move_nonnull, heap_move_ok, heap_remove},
 | 
					    mem::{heap_move_nonnull, heap_move_ok, heap_remove},
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use servicepoint::{
 | 
					use servicepoint::{
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,8 @@ use servicepoint::{
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use std::ptr::NonNull;
 | 
					use std::ptr::NonNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wrap_functions!(sp_cmd_bitvec;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Set pixel data starting at the pixel offset on screen.
 | 
					    /// Set pixel data starting at the pixel offset on screen.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// The screen will continuously overwrite more pixel data without regarding the offset, meaning
 | 
					    /// The screen will continuously overwrite more pixel data without regarding the offset, meaning
 | 
				
			||||||
| 
						 | 
					@ -20,8 +22,7 @@ use std::ptr::NonNull;
 | 
				
			||||||
    /// For example, [`BinaryOperation::Or`] can be used to turn on some pixels without affecting other pixels.
 | 
					    /// For example, [`BinaryOperation::Or`] can be used to turn on some pixels without affecting other pixels.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// The contained [`DisplayBitVec`] is always uncompressed.
 | 
					    /// The contained [`DisplayBitVec`] is always uncompressed.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn new(
 | 
				
			||||||
pub unsafe extern "C" fn sp_cmd_bitvec_new(
 | 
					 | 
				
			||||||
        bitvec: NonNull<DisplayBitVec>,
 | 
					        bitvec: NonNull<DisplayBitVec>,
 | 
				
			||||||
        offset: usize,
 | 
					        offset: usize,
 | 
				
			||||||
        operation: BinaryOperation,
 | 
					        operation: BinaryOperation,
 | 
				
			||||||
| 
						 | 
					@ -38,13 +39,14 @@ pub unsafe extern "C" fn sp_cmd_bitvec_new(
 | 
				
			||||||
    /// Tries to turn a [BitVecCommand] into a [Packet].
 | 
					    /// Tries to turn a [BitVecCommand] into a [Packet].
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Returns: NULL or a [Packet] containing the command.
 | 
					    /// Returns: NULL or a [Packet] containing the command.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn try_into_packet(
 | 
				
			||||||
pub unsafe extern "C" fn sp_cmd_bitvec_try_into_packet(
 | 
					 | 
				
			||||||
        command: NonNull<BitVecCommand>,
 | 
					        command: NonNull<BitVecCommand>,
 | 
				
			||||||
    ) -> *mut Packet {
 | 
					    ) -> *mut Packet {
 | 
				
			||||||
        heap_move_ok(unsafe { heap_remove(command) }.try_into())
 | 
					        heap_move_ok(unsafe { heap_remove(command) }.try_into())
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wrap_clone!(sp_cmd_bitvec::BitVecCommand);
 | 
					wrap_clone!(sp_cmd_bitvec::BitVecCommand);
 | 
				
			||||||
wrap_free!(sp_cmd_bitvec::BitVecCommand);
 | 
					wrap_free!(sp_cmd_bitvec::BitVecCommand);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,17 +1,18 @@
 | 
				
			||||||
use crate::{
 | 
					use crate::{
 | 
				
			||||||
    macros::{wrap_clone, wrap_free},
 | 
					    macros::{wrap_clone, wrap_free, wrap_functions},
 | 
				
			||||||
    mem::{heap_move_nonnull, heap_move_ok, heap_remove},
 | 
					    mem::{heap_move_nonnull, heap_move_ok, heap_remove},
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use servicepoint::{BrightnessGrid, BrightnessGridCommand, Origin, Packet};
 | 
					use servicepoint::{BrightnessGrid, BrightnessGridCommand, Origin, Packet};
 | 
				
			||||||
use std::ptr::NonNull;
 | 
					use std::ptr::NonNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wrap_functions!(sp_cmd_brightness_grid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Set the brightness of individual tiles in a rectangular area of the display.
 | 
					    /// Set the brightness of individual tiles in a rectangular area of the display.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// The passed [BrightnessGrid] gets consumed.
 | 
					    /// The passed [BrightnessGrid] gets consumed.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Returns: a new [BrightnessGridCommand] instance.
 | 
					    /// Returns: a new [BrightnessGridCommand] instance.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn new(
 | 
				
			||||||
pub unsafe extern "C" fn sp_cmd_brightness_grid_new(
 | 
					 | 
				
			||||||
        grid: NonNull<BrightnessGrid>,
 | 
					        grid: NonNull<BrightnessGrid>,
 | 
				
			||||||
        origin_x: usize,
 | 
					        origin_x: usize,
 | 
				
			||||||
        origin_y: usize,
 | 
					        origin_y: usize,
 | 
				
			||||||
| 
						 | 
					@ -24,8 +25,7 @@ pub unsafe extern "C" fn sp_cmd_brightness_grid_new(
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Moves the provided [BrightnessGrid] into a new [BrightnessGridCommand],
 | 
					    /// Moves the provided [BrightnessGrid] into a new [BrightnessGridCommand],
 | 
				
			||||||
    /// leaving other fields as their default values.
 | 
					    /// leaving other fields as their default values.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn from_grid(
 | 
				
			||||||
pub unsafe extern "C" fn sp_cmd_brightness_grid_from_grid(
 | 
					 | 
				
			||||||
        grid: NonNull<BrightnessGrid>,
 | 
					        grid: NonNull<BrightnessGrid>,
 | 
				
			||||||
    ) -> NonNull<BrightnessGridCommand> {
 | 
					    ) -> NonNull<BrightnessGridCommand> {
 | 
				
			||||||
        heap_move_nonnull(unsafe { heap_remove(grid) }.into())
 | 
					        heap_move_nonnull(unsafe { heap_remove(grid) }.into())
 | 
				
			||||||
| 
						 | 
					@ -34,13 +34,14 @@ pub unsafe extern "C" fn sp_cmd_brightness_grid_from_grid(
 | 
				
			||||||
    /// Tries to turn a [BrightnessGridCommand] into a [Packet].
 | 
					    /// Tries to turn a [BrightnessGridCommand] into a [Packet].
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Returns: NULL or a [Packet] containing the command.
 | 
					    /// Returns: NULL or a [Packet] containing the command.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn into_packet(
 | 
				
			||||||
pub unsafe extern "C" fn sp_cmd_brightness_grid_into_packet(
 | 
					 | 
				
			||||||
        command: NonNull<BrightnessGridCommand>,
 | 
					        command: NonNull<BrightnessGridCommand>,
 | 
				
			||||||
    ) -> *mut Packet {
 | 
					    ) -> *mut Packet {
 | 
				
			||||||
        heap_move_ok(unsafe { heap_remove(command) }.try_into())
 | 
					        heap_move_ok(unsafe { heap_remove(command) }.try_into())
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wrap_clone!(sp_cmd_brightness_grid::BrightnessGridCommand);
 | 
					wrap_clone!(sp_cmd_brightness_grid::BrightnessGridCommand);
 | 
				
			||||||
wrap_free!(sp_cmd_brightness_grid::BrightnessGridCommand);
 | 
					wrap_free!(sp_cmd_brightness_grid::BrightnessGridCommand);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,37 +1,43 @@
 | 
				
			||||||
use crate::{macros::wrap_free, mem::heap_move_nonnull};
 | 
					use crate::{
 | 
				
			||||||
 | 
					    macros::{wrap_free, wrap_functions},
 | 
				
			||||||
 | 
					    mem::heap_move_nonnull,
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
use servicepoint::{ClearCommand, FadeOutCommand, HardResetCommand};
 | 
					use servicepoint::{ClearCommand, FadeOutCommand, HardResetCommand};
 | 
				
			||||||
use std::ptr::NonNull;
 | 
					use std::ptr::NonNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wrap_functions!(sp_cmd_clear;
 | 
				
			||||||
    /// Set all pixels to the off state.
 | 
					    /// Set all pixels to the off state.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Does not affect brightness.
 | 
					    /// Does not affect brightness.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Returns: a new [ClearCommand] instance.
 | 
					    /// Returns: a new [ClearCommand] instance.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn new() -> NonNull<ClearCommand> {
 | 
				
			||||||
pub unsafe extern "C" fn sp_cmd_clear_new() -> NonNull<ClearCommand> {
 | 
					 | 
				
			||||||
        heap_move_nonnull(ClearCommand)
 | 
					        heap_move_nonnull(ClearCommand)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wrap_free!(sp_cmd_clear::ClearCommand);
 | 
					wrap_free!(sp_cmd_clear::ClearCommand);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wrap_functions!(sp_cmd_hard_reset;
 | 
				
			||||||
    /// Kills the udp daemon on the display, which usually results in a restart.
 | 
					    /// Kills the udp daemon on the display, which usually results in a restart.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Please do not send this in your normal program flow.
 | 
					    /// Please do not send this in your normal program flow.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Returns: a new [HardResetCommand] instance.
 | 
					    /// Returns: a new [HardResetCommand] instance.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn new() -> NonNull<HardResetCommand> {
 | 
				
			||||||
pub unsafe extern "C" fn sp_cmd_hard_reset_new() -> NonNull<HardResetCommand> {
 | 
					 | 
				
			||||||
        heap_move_nonnull(HardResetCommand)
 | 
					        heap_move_nonnull(HardResetCommand)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wrap_free!(sp_cmd_hard_reset::HardResetCommand);
 | 
					wrap_free!(sp_cmd_hard_reset::HardResetCommand);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wrap_functions!(sp_cmd_fade_out;
 | 
				
			||||||
    /// A yet-to-be-tested command.
 | 
					    /// A yet-to-be-tested command.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Returns: a new [FadeOutCommand] instance.
 | 
					    /// Returns: a new [FadeOutCommand] instance.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn new() -> NonNull<FadeOutCommand> {
 | 
				
			||||||
pub unsafe extern "C" fn sp_cmd_fade_out_new() -> NonNull<FadeOutCommand> {
 | 
					 | 
				
			||||||
        heap_move_nonnull(FadeOutCommand)
 | 
					        heap_move_nonnull(FadeOutCommand)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wrap_free!(sp_cmd_fade_out::FadeOutCommand);
 | 
					wrap_free!(sp_cmd_fade_out::FadeOutCommand);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,17 +1,18 @@
 | 
				
			||||||
use crate::{
 | 
					use crate::{
 | 
				
			||||||
    macros::{wrap_clone, wrap_free},
 | 
					    macros::{wrap_clone, wrap_free, wrap_functions},
 | 
				
			||||||
    mem::{heap_move_nonnull, heap_move_ok, heap_remove},
 | 
					    mem::{heap_move_nonnull, heap_move_ok, heap_remove},
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use servicepoint::{CharGrid, CharGridCommand, Origin, Packet};
 | 
					use servicepoint::{CharGrid, CharGridCommand, Origin, Packet};
 | 
				
			||||||
use std::ptr::NonNull;
 | 
					use std::ptr::NonNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wrap_functions!(sp_cmd_char_grid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Show UTF-8 encoded text on the screen.
 | 
					    /// Show UTF-8 encoded text on the screen.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// The passed [CharGrid] gets consumed.
 | 
					    /// The passed [CharGrid] gets consumed.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Returns: a new [CharGridCommand] instance.
 | 
					    /// Returns: a new [CharGridCommand] instance.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn new(
 | 
				
			||||||
pub unsafe extern "C" fn sp_cmd_char_grid_new(
 | 
					 | 
				
			||||||
        grid: NonNull<CharGrid>,
 | 
					        grid: NonNull<CharGrid>,
 | 
				
			||||||
        origin_x: usize,
 | 
					        origin_x: usize,
 | 
				
			||||||
        origin_y: usize,
 | 
					        origin_y: usize,
 | 
				
			||||||
| 
						 | 
					@ -24,8 +25,7 @@ pub unsafe extern "C" fn sp_cmd_char_grid_new(
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Moves the provided [CharGrid] into a new [CharGridCommand],
 | 
					    /// Moves the provided [CharGrid] into a new [CharGridCommand],
 | 
				
			||||||
    /// leaving other fields as their default values.
 | 
					    /// leaving other fields as their default values.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn from_grid(
 | 
				
			||||||
pub unsafe extern "C" fn sp_cmd_char_grid_from_grid(
 | 
					 | 
				
			||||||
        grid: NonNull<CharGrid>,
 | 
					        grid: NonNull<CharGrid>,
 | 
				
			||||||
    ) -> NonNull<CharGridCommand> {
 | 
					    ) -> NonNull<CharGridCommand> {
 | 
				
			||||||
        heap_move_nonnull(unsafe { heap_remove(grid) }.into())
 | 
					        heap_move_nonnull(unsafe { heap_remove(grid) }.into())
 | 
				
			||||||
| 
						 | 
					@ -34,13 +34,14 @@ pub unsafe extern "C" fn sp_cmd_char_grid_from_grid(
 | 
				
			||||||
    /// Tries to turn a [CharGridCommand] into a [Packet].
 | 
					    /// Tries to turn a [CharGridCommand] into a [Packet].
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Returns: NULL or a [Packet] containing the command.
 | 
					    /// Returns: NULL or a [Packet] containing the command.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn try_into_packet(
 | 
				
			||||||
pub unsafe extern "C" fn sp_cmd_char_grid_try_into_packet(
 | 
					 | 
				
			||||||
        command: NonNull<CharGridCommand>,
 | 
					        command: NonNull<CharGridCommand>,
 | 
				
			||||||
    ) -> *mut Packet {
 | 
					    ) -> *mut Packet {
 | 
				
			||||||
        heap_move_ok(unsafe { heap_remove(command) }.try_into())
 | 
					        heap_move_ok(unsafe { heap_remove(command) }.try_into())
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wrap_clone!(sp_cmd_char_grid::CharGridCommand);
 | 
					wrap_clone!(sp_cmd_char_grid::CharGridCommand);
 | 
				
			||||||
wrap_free!(sp_cmd_char_grid::CharGridCommand);
 | 
					wrap_free!(sp_cmd_char_grid::CharGridCommand);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -59,8 +60,8 @@ pub unsafe extern "C" fn sp_cmd_char_grid_set(
 | 
				
			||||||
#[no_mangle]
 | 
					#[no_mangle]
 | 
				
			||||||
pub unsafe extern "C" fn sp_cmd_char_grid_get(
 | 
					pub unsafe extern "C" fn sp_cmd_char_grid_get(
 | 
				
			||||||
    mut command: NonNull<CharGridCommand>,
 | 
					    mut command: NonNull<CharGridCommand>,
 | 
				
			||||||
) -> *mut CharGrid {
 | 
					) -> NonNull<CharGrid> {
 | 
				
			||||||
    unsafe { &mut command.as_mut().grid }
 | 
					    unsafe { NonNull::from(&mut command.as_mut().grid) }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Reads the origin field of the [CharGridCommand].
 | 
					/// Reads the origin field of the [CharGridCommand].
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,17 +1,18 @@
 | 
				
			||||||
use crate::{
 | 
					use crate::{
 | 
				
			||||||
    macros::{wrap_clone, wrap_free},
 | 
					    macros::{wrap_clone, wrap_free, wrap_functions},
 | 
				
			||||||
    mem::{heap_move_nonnull, heap_move_ok, heap_remove},
 | 
					    mem::{heap_move_nonnull, heap_move_ok, heap_remove},
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use servicepoint::{Cp437Grid, Cp437GridCommand, Origin, Packet};
 | 
					use servicepoint::{Cp437Grid, Cp437GridCommand, Origin, Packet};
 | 
				
			||||||
use std::ptr::NonNull;
 | 
					use std::ptr::NonNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wrap_functions!(sp_cmd_cp437_grid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Show text on the screen.
 | 
					    /// Show text on the screen.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// The text is sent in the form of a 2D grid of [CP-437] encoded characters.
 | 
					    /// The text is sent in the form of a 2D grid of [CP-437] encoded characters.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// The origin is relative to the top-left of the display.
 | 
					    /// The origin is relative to the top-left of the display.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn new(
 | 
				
			||||||
pub unsafe extern "C" fn sp_cmd_cp437_grid_new(
 | 
					 | 
				
			||||||
        grid: NonNull<Cp437Grid>,
 | 
					        grid: NonNull<Cp437Grid>,
 | 
				
			||||||
        origin_x: usize,
 | 
					        origin_x: usize,
 | 
				
			||||||
        origin_y: usize,
 | 
					        origin_y: usize,
 | 
				
			||||||
| 
						 | 
					@ -24,8 +25,7 @@ pub unsafe extern "C" fn sp_cmd_cp437_grid_new(
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Moves the provided [Cp437Grid] into a new [Cp437GridCommand],
 | 
					    /// Moves the provided [Cp437Grid] into a new [Cp437GridCommand],
 | 
				
			||||||
    /// leaving other fields as their default values.
 | 
					    /// leaving other fields as their default values.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn from_grid(
 | 
				
			||||||
pub unsafe extern "C" fn sp_cmd_cp437_grid_from_grid(
 | 
					 | 
				
			||||||
        grid: NonNull<Cp437Grid>,
 | 
					        grid: NonNull<Cp437Grid>,
 | 
				
			||||||
    ) -> NonNull<Cp437GridCommand> {
 | 
					    ) -> NonNull<Cp437GridCommand> {
 | 
				
			||||||
        heap_move_nonnull(unsafe { heap_remove(grid) }.into())
 | 
					        heap_move_nonnull(unsafe { heap_remove(grid) }.into())
 | 
				
			||||||
| 
						 | 
					@ -34,13 +34,14 @@ pub unsafe extern "C" fn sp_cmd_cp437_grid_from_grid(
 | 
				
			||||||
    /// Tries to turn a [Cp437GridCommand] into a [Packet].
 | 
					    /// Tries to turn a [Cp437GridCommand] into a [Packet].
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Returns: NULL or a [Packet] containing the command.
 | 
					    /// Returns: NULL or a [Packet] containing the command.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn try_into_packet(
 | 
				
			||||||
pub unsafe extern "C" fn sp_cmd_cp437_grid_try_into_packet(
 | 
					 | 
				
			||||||
        command: NonNull<Cp437GridCommand>,
 | 
					        command: NonNull<Cp437GridCommand>,
 | 
				
			||||||
    ) -> *mut Packet {
 | 
					    ) -> *mut Packet {
 | 
				
			||||||
        heap_move_ok(unsafe { heap_remove(command) }.try_into())
 | 
					        heap_move_ok(unsafe { heap_remove(command) }.try_into())
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wrap_clone!(sp_cmd_cp437_grid::Cp437GridCommand);
 | 
					wrap_clone!(sp_cmd_cp437_grid::Cp437GridCommand);
 | 
				
			||||||
wrap_free!(sp_cmd_cp437_grid::Cp437GridCommand);
 | 
					wrap_free!(sp_cmd_cp437_grid::Cp437GridCommand);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,27 +1,26 @@
 | 
				
			||||||
use crate::{
 | 
					use crate::{
 | 
				
			||||||
    macros::{wrap_clone, wrap_fields, wrap_free},
 | 
					    macros::{wrap_clone, wrap_fields, wrap_free, wrap_functions},
 | 
				
			||||||
    mem::{heap_move_nonnull, heap_remove},
 | 
					    mem::{heap_move_nonnull, heap_remove},
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use servicepoint::{Brightness, GlobalBrightnessCommand, Packet};
 | 
					use servicepoint::{Brightness, GlobalBrightnessCommand, Packet};
 | 
				
			||||||
use std::ptr::NonNull;
 | 
					use std::ptr::NonNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wrap_functions!(sp_cmd_brightness_global;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Set the brightness of all tiles to the same value.
 | 
					    /// Set the brightness of all tiles to the same value.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Returns: a new [GlobalBrightnessCommand] instance.
 | 
					    /// Returns: a new [GlobalBrightnessCommand] instance.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn new(brightness: Brightness) -> NonNull<GlobalBrightnessCommand> {
 | 
				
			||||||
pub unsafe extern "C" fn sp_cmd_brightness_global_new(
 | 
					 | 
				
			||||||
    brightness: Brightness,
 | 
					 | 
				
			||||||
) -> NonNull<GlobalBrightnessCommand> {
 | 
					 | 
				
			||||||
        heap_move_nonnull(GlobalBrightnessCommand::from(brightness))
 | 
					        heap_move_nonnull(GlobalBrightnessCommand::from(brightness))
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[no_mangle]
 | 
					    /// Turns the command into a packet
 | 
				
			||||||
pub unsafe extern "C" fn sp_cmd_brightness_global_into_packet(
 | 
					    fn into_packet(command: NonNull<GlobalBrightnessCommand>) -> NonNull<Packet> {
 | 
				
			||||||
    command: NonNull<GlobalBrightnessCommand>,
 | 
					 | 
				
			||||||
) -> NonNull<Packet> {
 | 
					 | 
				
			||||||
        heap_move_nonnull(unsafe { heap_remove(command) }.into())
 | 
					        heap_move_nonnull(unsafe { heap_remove(command) }.into())
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wrap_clone!(sp_cmd_brightness_global::GlobalBrightnessCommand);
 | 
					wrap_clone!(sp_cmd_brightness_global::GlobalBrightnessCommand);
 | 
				
			||||||
wrap_free!(sp_cmd_brightness_global::GlobalBrightnessCommand);
 | 
					wrap_free!(sp_cmd_brightness_global::GlobalBrightnessCommand);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
use crate::{
 | 
					use crate::{
 | 
				
			||||||
    containers::ByteSlice,
 | 
					    containers::ByteSlice,
 | 
				
			||||||
    macros::{wrap_clone, wrap_free, wrap_methods},
 | 
					    macros::{wrap_clone, wrap_free, wrap_functions, wrap_methods},
 | 
				
			||||||
    mem::{heap_move_nonnull, heap_move_ok, heap_move_some, heap_remove},
 | 
					    mem::{heap_move_nonnull, heap_move_ok, heap_move_some, heap_remove},
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use servicepoint::{
 | 
					use servicepoint::{
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,11 @@ use servicepoint::{
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use std::ptr::NonNull;
 | 
					use std::ptr::NonNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wrap_clone!(sp_bitmap::Bitmap);
 | 
				
			||||||
 | 
					wrap_free!(sp_bitmap::Bitmap);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wrap_functions!(sp_bitmap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Creates a new [Bitmap] with the specified dimensions.
 | 
					    /// Creates a new [Bitmap] with the specified dimensions.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// # Arguments
 | 
					    /// # Arguments
 | 
				
			||||||
| 
						 | 
					@ -32,19 +37,14 @@ use std::ptr::NonNull;
 | 
				
			||||||
    /// sp_bitmap_set(grid, 0, 0, false);
 | 
					    /// sp_bitmap_set(grid, 0, 0, false);
 | 
				
			||||||
    /// sp_bitmap_free(grid);
 | 
					    /// sp_bitmap_free(grid);
 | 
				
			||||||
    /// ```
 | 
					    /// ```
 | 
				
			||||||
#[no_mangle]
 | 
					    fn new(width: usize, height: usize) -> *mut Bitmap {
 | 
				
			||||||
pub unsafe extern "C" fn sp_bitmap_new(
 | 
					 | 
				
			||||||
    width: usize,
 | 
					 | 
				
			||||||
    height: usize,
 | 
					 | 
				
			||||||
) -> *mut Bitmap {
 | 
					 | 
				
			||||||
        heap_move_some(Bitmap::new(width, height))
 | 
					        heap_move_some(Bitmap::new(width, height))
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Creates a new [Bitmap] with a size matching the screen.
 | 
					    /// Creates a new [Bitmap] with a size matching the screen.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// returns: [Bitmap] initialized to all pixels off.
 | 
					    /// returns: [Bitmap] initialized to all pixels off.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn new_max_sized() -> NonNull<Bitmap> {
 | 
				
			||||||
pub unsafe extern "C" fn sp_bitmap_new_max_sized() -> NonNull<Bitmap> {
 | 
					 | 
				
			||||||
        heap_move_nonnull(Bitmap::max_sized())
 | 
					        heap_move_nonnull(Bitmap::max_sized())
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -56,8 +56,7 @@ pub unsafe extern "C" fn sp_bitmap_new_max_sized() -> NonNull<Bitmap> {
 | 
				
			||||||
    /// - `height`: size in pixels in y-direction
 | 
					    /// - `height`: size in pixels in y-direction
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// returns: [Bitmap] that contains a copy of the provided data, or NULL in case of an error.
 | 
					    /// returns: [Bitmap] that contains a copy of the provided data, or NULL in case of an error.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn load(
 | 
				
			||||||
pub unsafe extern "C" fn sp_bitmap_load(
 | 
					 | 
				
			||||||
        width: usize,
 | 
					        width: usize,
 | 
				
			||||||
        height: usize,
 | 
					        height: usize,
 | 
				
			||||||
        data: ByteSlice,
 | 
					        data: ByteSlice,
 | 
				
			||||||
| 
						 | 
					@ -71,17 +70,40 @@ pub unsafe extern "C" fn sp_bitmap_load(
 | 
				
			||||||
    /// The provided BitVec gets consumed.
 | 
					    /// The provided BitVec gets consumed.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// Returns NULL in case of error.
 | 
					    /// Returns NULL in case of error.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn from_bitvec(
 | 
				
			||||||
pub unsafe extern "C" fn sp_bitmap_from_bitvec(
 | 
					 | 
				
			||||||
        width: usize,
 | 
					        width: usize,
 | 
				
			||||||
        bitvec: NonNull<DisplayBitVec>,
 | 
					        bitvec: NonNull<DisplayBitVec>,
 | 
				
			||||||
    ) -> *mut Bitmap {
 | 
					    ) -> *mut Bitmap {
 | 
				
			||||||
        let bitvec = unsafe { heap_remove(bitvec) };
 | 
					        let bitvec = unsafe { heap_remove(bitvec) };
 | 
				
			||||||
        heap_move_ok(Bitmap::from_bitvec(width, bitvec))
 | 
					        heap_move_ok(Bitmap::from_bitvec(width, bitvec))
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    /// Consumes the Bitmap and returns the contained BitVec.
 | 
				
			||||||
 | 
					    fn into_bitvec(
 | 
				
			||||||
 | 
					        bitmap: NonNull<Bitmap>
 | 
				
			||||||
 | 
					    ) -> NonNull<DisplayBitVec> {
 | 
				
			||||||
 | 
					        let bitmap = unsafe { heap_remove(bitmap) };
 | 
				
			||||||
 | 
					        heap_move_nonnull(bitmap.into())
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wrap_clone!(sp_bitmap::Bitmap);
 | 
					    /// Creates a [BitmapCommand] and immediately turns that into a [Packet].
 | 
				
			||||||
wrap_free!(sp_bitmap::Bitmap);
 | 
					    ///
 | 
				
			||||||
 | 
					    /// The provided [Bitmap] gets consumed.
 | 
				
			||||||
 | 
					    ///
 | 
				
			||||||
 | 
					    /// Returns NULL in case of an error.
 | 
				
			||||||
 | 
					    fn into_packet(
 | 
				
			||||||
 | 
					        bitmap: NonNull<Bitmap>,
 | 
				
			||||||
 | 
					        x: usize,
 | 
				
			||||||
 | 
					        y: usize,
 | 
				
			||||||
 | 
					        compression: CompressionCode,
 | 
				
			||||||
 | 
					    ) -> *mut Packet {
 | 
				
			||||||
 | 
					        let bitmap = unsafe { heap_remove(bitmap) };
 | 
				
			||||||
 | 
					        heap_move_ok(Packet::try_from(BitmapCommand {
 | 
				
			||||||
 | 
					            bitmap,
 | 
				
			||||||
 | 
					            origin: Origin::new(x, y),
 | 
				
			||||||
 | 
					            compression,
 | 
				
			||||||
 | 
					        }))
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wrap_methods!(
 | 
					wrap_methods!(
 | 
				
			||||||
    sp_bitmap::Bitmap;
 | 
					    sp_bitmap::Bitmap;
 | 
				
			||||||
| 
						 | 
					@ -130,32 +152,3 @@ wrap_methods!(
 | 
				
			||||||
        return(slice) { unsafe { ByteSlice::from_slice(slice) } };
 | 
					        return(slice) { unsafe { ByteSlice::from_slice(slice) } };
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					 | 
				
			||||||
/// Consumes the Bitmap and returns the contained BitVec.
 | 
					 | 
				
			||||||
#[no_mangle]
 | 
					 | 
				
			||||||
pub unsafe extern "C" fn sp_bitmap_into_bitvec(
 | 
					 | 
				
			||||||
    bitmap: NonNull<Bitmap>,
 | 
					 | 
				
			||||||
) -> NonNull<DisplayBitVec> {
 | 
					 | 
				
			||||||
    let bitmap = unsafe { heap_remove(bitmap) };
 | 
					 | 
				
			||||||
    heap_move_nonnull(bitmap.into())
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/// Creates a [BitmapCommand] and immediately turns that into a [Packet].
 | 
					 | 
				
			||||||
///
 | 
					 | 
				
			||||||
/// The provided [Bitmap] gets consumed.
 | 
					 | 
				
			||||||
///
 | 
					 | 
				
			||||||
/// Returns NULL in case of an error.
 | 
					 | 
				
			||||||
#[no_mangle]
 | 
					 | 
				
			||||||
pub unsafe extern "C" fn sp_bitmap_into_packet(
 | 
					 | 
				
			||||||
    bitmap: NonNull<Bitmap>,
 | 
					 | 
				
			||||||
    x: usize,
 | 
					 | 
				
			||||||
    y: usize,
 | 
					 | 
				
			||||||
    compression: CompressionCode,
 | 
					 | 
				
			||||||
) -> *mut Packet {
 | 
					 | 
				
			||||||
    let bitmap = unsafe { heap_remove(bitmap) };
 | 
					 | 
				
			||||||
    heap_move_ok(Packet::try_from(BitmapCommand {
 | 
					 | 
				
			||||||
        bitmap,
 | 
					 | 
				
			||||||
        origin: Origin::new(x, y),
 | 
					 | 
				
			||||||
        compression,
 | 
					 | 
				
			||||||
    }))
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
use crate::{
 | 
					use crate::{
 | 
				
			||||||
    containers::ByteSlice,
 | 
					    containers::ByteSlice,
 | 
				
			||||||
    macros::{wrap_clone, wrap_free, wrap_methods},
 | 
					    macros::{wrap_clone, wrap_free, wrap_functions, wrap_methods},
 | 
				
			||||||
    mem::{heap_move_nonnull, heap_move_ok, heap_remove},
 | 
					    mem::{heap_move_nonnull, heap_move_ok, heap_remove},
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use servicepoint::{
 | 
					use servicepoint::{
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,8 @@ use servicepoint::{
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use std::ptr::NonNull;
 | 
					use std::ptr::NonNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wrap_functions!(sp_bitvec;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Creates a new [DisplayBitVec] instance.
 | 
					    /// Creates a new [DisplayBitVec] instance.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// # Arguments
 | 
					    /// # Arguments
 | 
				
			||||||
| 
						 | 
					@ -19,22 +21,40 @@ use std::ptr::NonNull;
 | 
				
			||||||
    /// # Panics
 | 
					    /// # Panics
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// - when `size` is not divisible by 8.
 | 
					    /// - when `size` is not divisible by 8.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn new(size: usize) -> NonNull<DisplayBitVec> {
 | 
				
			||||||
pub unsafe extern "C" fn sp_bitvec_new(size: usize) -> NonNull<DisplayBitVec> {
 | 
					 | 
				
			||||||
        heap_move_nonnull(DisplayBitVec::repeat(false, size))
 | 
					        heap_move_nonnull(DisplayBitVec::repeat(false, size))
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Interpret the data as a series of bits and load then into a new [DisplayBitVec] instance.
 | 
					    /// Interpret the data as a series of bits and load then into a new [DisplayBitVec] instance.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// returns: [DisplayBitVec] instance containing data.
 | 
					    /// returns: [DisplayBitVec] instance containing data.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn load(data: ByteSlice) -> NonNull<DisplayBitVec> {
 | 
				
			||||||
pub unsafe extern "C" fn sp_bitvec_load(
 | 
					 | 
				
			||||||
    data: ByteSlice,
 | 
					 | 
				
			||||||
) -> NonNull<DisplayBitVec> {
 | 
					 | 
				
			||||||
        let data = unsafe { data.as_slice() };
 | 
					        let data = unsafe { data.as_slice() };
 | 
				
			||||||
        heap_move_nonnull(DisplayBitVec::from_slice(data))
 | 
					        heap_move_nonnull(DisplayBitVec::from_slice(data))
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /// Creates a [BitVecCommand] and immediately turns that into a [Packet].
 | 
				
			||||||
 | 
					    ///
 | 
				
			||||||
 | 
					    /// The provided [DisplayBitVec] gets consumed.
 | 
				
			||||||
 | 
					    ///
 | 
				
			||||||
 | 
					    /// Returns NULL in case of an error.
 | 
				
			||||||
 | 
					    fn into_packet(
 | 
				
			||||||
 | 
					        bitvec: NonNull<DisplayBitVec>,
 | 
				
			||||||
 | 
					        offset: usize,
 | 
				
			||||||
 | 
					        operation: BinaryOperation,
 | 
				
			||||||
 | 
					        compression: CompressionCode,
 | 
				
			||||||
 | 
					    ) -> *mut Packet {
 | 
				
			||||||
 | 
					        let bitvec = unsafe { heap_remove(bitvec) };
 | 
				
			||||||
 | 
					        heap_move_ok(Packet::try_from(BitVecCommand {
 | 
				
			||||||
 | 
					            bitvec,
 | 
				
			||||||
 | 
					            offset,
 | 
				
			||||||
 | 
					            operation,
 | 
				
			||||||
 | 
					            compression,
 | 
				
			||||||
 | 
					        }))
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wrap_clone!(sp_bitvec::DisplayBitVec);
 | 
					wrap_clone!(sp_bitvec::DisplayBitVec);
 | 
				
			||||||
wrap_free!(sp_bitvec::DisplayBitVec);
 | 
					wrap_free!(sp_bitvec::DisplayBitVec);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -90,24 +110,3 @@ wrap_methods!(
 | 
				
			||||||
        return(slice) { unsafe { ByteSlice::from_slice(slice) } };
 | 
					        return(slice) { unsafe { ByteSlice::from_slice(slice) } };
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					 | 
				
			||||||
/// Creates a [BitVecCommand] and immediately turns that into a [Packet].
 | 
					 | 
				
			||||||
///
 | 
					 | 
				
			||||||
/// The provided [DisplayBitVec] gets consumed.
 | 
					 | 
				
			||||||
///
 | 
					 | 
				
			||||||
/// Returns NULL in case of an error.
 | 
					 | 
				
			||||||
#[no_mangle]
 | 
					 | 
				
			||||||
pub unsafe extern "C" fn sp_bitvec_into_packet(
 | 
					 | 
				
			||||||
    bitvec: NonNull<DisplayBitVec>,
 | 
					 | 
				
			||||||
    offset: usize,
 | 
					 | 
				
			||||||
    operation: BinaryOperation,
 | 
					 | 
				
			||||||
    compression: CompressionCode,
 | 
					 | 
				
			||||||
) -> *mut Packet {
 | 
					 | 
				
			||||||
    let bitvec = unsafe { heap_remove(bitvec) };
 | 
					 | 
				
			||||||
    heap_move_ok(Packet::try_from(BitVecCommand {
 | 
					 | 
				
			||||||
        bitvec,
 | 
					 | 
				
			||||||
        offset,
 | 
					 | 
				
			||||||
        operation,
 | 
					 | 
				
			||||||
        compression,
 | 
					 | 
				
			||||||
    }))
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,4 @@
 | 
				
			||||||
 | 
					use crate::macros::wrap_functions;
 | 
				
			||||||
use crate::{
 | 
					use crate::{
 | 
				
			||||||
    containers::ByteSlice,
 | 
					    containers::ByteSlice,
 | 
				
			||||||
    macros::{wrap_clone, wrap_free, wrap_methods},
 | 
					    macros::{wrap_clone, wrap_free, wrap_methods},
 | 
				
			||||||
| 
						 | 
					@ -9,6 +10,8 @@ use servicepoint::{
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use std::{mem::transmute, ptr::NonNull};
 | 
					use std::{mem::transmute, ptr::NonNull};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wrap_functions!(sp_brightness_grid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Creates a new [BrightnessGrid] with the specified dimensions.
 | 
					    /// Creates a new [BrightnessGrid] with the specified dimensions.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// returns: [BrightnessGrid] initialized to 0.
 | 
					    /// returns: [BrightnessGrid] initialized to 0.
 | 
				
			||||||
| 
						 | 
					@ -26,8 +29,7 @@ use std::{mem::transmute, ptr::NonNull};
 | 
				
			||||||
    /// TypedCommand *command = sp_command_char_brightness(grid);
 | 
					    /// TypedCommand *command = sp_command_char_brightness(grid);
 | 
				
			||||||
    /// sp_udp_free(connection);
 | 
					    /// sp_udp_free(connection);
 | 
				
			||||||
    /// ```
 | 
					    /// ```
 | 
				
			||||||
#[no_mangle]
 | 
					    fn new(
 | 
				
			||||||
pub unsafe extern "C" fn sp_brightness_grid_new(
 | 
					 | 
				
			||||||
        width: usize,
 | 
					        width: usize,
 | 
				
			||||||
        height: usize,
 | 
					        height: usize,
 | 
				
			||||||
    ) -> NonNull<BrightnessGrid> {
 | 
					    ) -> NonNull<BrightnessGrid> {
 | 
				
			||||||
| 
						 | 
					@ -39,8 +41,7 @@ pub unsafe extern "C" fn sp_brightness_grid_new(
 | 
				
			||||||
    /// Any out of range values will be set to [Brightness::MAX] or [Brightness::MIN].
 | 
					    /// Any out of range values will be set to [Brightness::MAX] or [Brightness::MIN].
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// returns: new [BrightnessGrid] instance, or NULL in case of an error.
 | 
					    /// returns: new [BrightnessGrid] instance, or NULL in case of an error.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn load(
 | 
				
			||||||
pub unsafe extern "C" fn sp_brightness_grid_load(
 | 
					 | 
				
			||||||
        width: usize,
 | 
					        width: usize,
 | 
				
			||||||
        height: usize,
 | 
					        height: usize,
 | 
				
			||||||
        data: ByteSlice,
 | 
					        data: ByteSlice,
 | 
				
			||||||
| 
						 | 
					@ -52,6 +53,25 @@ pub unsafe extern "C" fn sp_brightness_grid_load(
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /// Creates a [BrightnessGridCommand] and immediately turns that into a [Packet].
 | 
				
			||||||
 | 
					    ///
 | 
				
			||||||
 | 
					    /// The provided [BrightnessGrid] gets consumed.
 | 
				
			||||||
 | 
					    ///
 | 
				
			||||||
 | 
					    /// Returns NULL in case of an error.
 | 
				
			||||||
 | 
					    fn into_packet(
 | 
				
			||||||
 | 
					        grid: NonNull<BrightnessGrid>,
 | 
				
			||||||
 | 
					        x: usize,
 | 
				
			||||||
 | 
					        y: usize,
 | 
				
			||||||
 | 
					    ) -> *mut Packet {
 | 
				
			||||||
 | 
					        let grid = unsafe { heap_remove(grid) };
 | 
				
			||||||
 | 
					        heap_move_ok(Packet::try_from(BrightnessGridCommand {
 | 
				
			||||||
 | 
					            grid,
 | 
				
			||||||
 | 
					            origin: Origin::new(x, y),
 | 
				
			||||||
 | 
					        }))
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wrap_clone!(sp_brightness_grid::BrightnessGrid);
 | 
					wrap_clone!(sp_brightness_grid::BrightnessGrid);
 | 
				
			||||||
wrap_free!(sp_brightness_grid::BrightnessGrid);
 | 
					wrap_free!(sp_brightness_grid::BrightnessGrid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -109,21 +129,3 @@ wrap_methods!(
 | 
				
			||||||
        }};
 | 
					        }};
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					 | 
				
			||||||
/// Creates a [BrightnessGridCommand] and immediately turns that into a [Packet].
 | 
					 | 
				
			||||||
///
 | 
					 | 
				
			||||||
/// The provided [BrightnessGrid] gets consumed.
 | 
					 | 
				
			||||||
///
 | 
					 | 
				
			||||||
/// Returns NULL in case of an error.
 | 
					 | 
				
			||||||
#[no_mangle]
 | 
					 | 
				
			||||||
pub unsafe extern "C" fn sp_brightness_grid_into_packet(
 | 
					 | 
				
			||||||
    grid: NonNull<BrightnessGrid>,
 | 
					 | 
				
			||||||
    x: usize,
 | 
					 | 
				
			||||||
    y: usize,
 | 
					 | 
				
			||||||
) -> *mut Packet {
 | 
					 | 
				
			||||||
    let grid = unsafe { heap_remove(grid) };
 | 
					 | 
				
			||||||
    heap_move_ok(Packet::try_from(BrightnessGridCommand {
 | 
					 | 
				
			||||||
        grid,
 | 
					 | 
				
			||||||
        origin: Origin::new(x, y),
 | 
					 | 
				
			||||||
    }))
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,11 +1,13 @@
 | 
				
			||||||
use crate::{
 | 
					use crate::{
 | 
				
			||||||
    containers::ByteSlice,
 | 
					    containers::ByteSlice,
 | 
				
			||||||
    macros::{wrap_clone, wrap_free, wrap_methods},
 | 
					    macros::{wrap_clone, wrap_free, wrap_functions, wrap_methods},
 | 
				
			||||||
    mem::{heap_move_nonnull, heap_move_ok, heap_remove},
 | 
					    mem::{heap_move_nonnull, heap_move_ok, heap_remove},
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use servicepoint::{CharGrid, CharGridCommand, Grid, Origin, Packet};
 | 
					use servicepoint::{CharGrid, CharGridCommand, Grid, Origin, Packet};
 | 
				
			||||||
use std::ptr::NonNull;
 | 
					use std::ptr::NonNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wrap_functions!(sp_char_grid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Creates a new [CharGrid] with the specified dimensions.
 | 
					    /// Creates a new [CharGrid] with the specified dimensions.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// returns: [CharGrid] initialized to 0.
 | 
					    /// returns: [CharGrid] initialized to 0.
 | 
				
			||||||
| 
						 | 
					@ -18,8 +20,7 @@ use std::ptr::NonNull;
 | 
				
			||||||
    /// sp_char_grid_set(grid, 0, 0, '!');
 | 
					    /// sp_char_grid_set(grid, 0, 0, '!');
 | 
				
			||||||
    /// sp_char_grid_free(grid);
 | 
					    /// sp_char_grid_free(grid);
 | 
				
			||||||
    /// ```
 | 
					    /// ```
 | 
				
			||||||
#[no_mangle]
 | 
					    fn new(
 | 
				
			||||||
pub unsafe extern "C" fn sp_char_grid_new(
 | 
					 | 
				
			||||||
        width: usize,
 | 
					        width: usize,
 | 
				
			||||||
        height: usize,
 | 
					        height: usize,
 | 
				
			||||||
    ) -> NonNull<CharGrid> {
 | 
					    ) -> NonNull<CharGrid> {
 | 
				
			||||||
| 
						 | 
					@ -29,8 +30,7 @@ pub unsafe extern "C" fn sp_char_grid_new(
 | 
				
			||||||
    /// Loads a [CharGrid] with the specified dimensions from the provided data.
 | 
					    /// Loads a [CharGrid] with the specified dimensions from the provided data.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// returns: new CharGrid or NULL in case of an error
 | 
					    /// returns: new CharGrid or NULL in case of an error
 | 
				
			||||||
#[no_mangle]
 | 
					    fn load(
 | 
				
			||||||
pub unsafe extern "C" fn sp_char_grid_load(
 | 
					 | 
				
			||||||
        width: usize,
 | 
					        width: usize,
 | 
				
			||||||
        height: usize,
 | 
					        height: usize,
 | 
				
			||||||
        data: ByteSlice,
 | 
					        data: ByteSlice,
 | 
				
			||||||
| 
						 | 
					@ -39,6 +39,25 @@ pub unsafe extern "C" fn sp_char_grid_load(
 | 
				
			||||||
        heap_move_ok(CharGrid::load_utf8(width, height, data.to_vec()))
 | 
					        heap_move_ok(CharGrid::load_utf8(width, height, data.to_vec()))
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /// Creates a [CharGridCommand] and immediately turns that into a [Packet].
 | 
				
			||||||
 | 
					    ///
 | 
				
			||||||
 | 
					    /// The provided [CharGrid] gets consumed.
 | 
				
			||||||
 | 
					    ///
 | 
				
			||||||
 | 
					    /// Returns NULL in case of an error.
 | 
				
			||||||
 | 
					    fn into_packet(
 | 
				
			||||||
 | 
					        grid: NonNull<CharGrid>,
 | 
				
			||||||
 | 
					        x: usize,
 | 
				
			||||||
 | 
					        y: usize,
 | 
				
			||||||
 | 
					    ) -> *mut Packet {
 | 
				
			||||||
 | 
					        let grid = unsafe { heap_remove(grid) };
 | 
				
			||||||
 | 
					        heap_move_ok(Packet::try_from(CharGridCommand {
 | 
				
			||||||
 | 
					            grid,
 | 
				
			||||||
 | 
					            origin: Origin::new(x, y),
 | 
				
			||||||
 | 
					        }))
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wrap_clone!(sp_char_grid::CharGrid);
 | 
					wrap_clone!(sp_char_grid::CharGrid);
 | 
				
			||||||
wrap_free!(sp_char_grid::CharGrid);
 | 
					wrap_free!(sp_char_grid::CharGrid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -91,21 +110,3 @@ wrap_methods!(
 | 
				
			||||||
    /// Gets the height of the grid.
 | 
					    /// Gets the height of the grid.
 | 
				
			||||||
    ref fn height() -> usize;
 | 
					    ref fn height() -> usize;
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					 | 
				
			||||||
/// Creates a [CharGridCommand] and immediately turns that into a [Packet].
 | 
					 | 
				
			||||||
///
 | 
					 | 
				
			||||||
/// The provided [CharGrid] gets consumed.
 | 
					 | 
				
			||||||
///
 | 
					 | 
				
			||||||
/// Returns NULL in case of an error.
 | 
					 | 
				
			||||||
#[no_mangle]
 | 
					 | 
				
			||||||
pub unsafe extern "C" fn sp_char_grid_into_packet(
 | 
					 | 
				
			||||||
    grid: NonNull<CharGrid>,
 | 
					 | 
				
			||||||
    x: usize,
 | 
					 | 
				
			||||||
    y: usize,
 | 
					 | 
				
			||||||
) -> *mut Packet {
 | 
					 | 
				
			||||||
    let grid = unsafe { heap_remove(grid) };
 | 
					 | 
				
			||||||
    heap_move_ok(Packet::try_from(CharGridCommand {
 | 
					 | 
				
			||||||
        grid,
 | 
					 | 
				
			||||||
        origin: Origin::new(x, y),
 | 
					 | 
				
			||||||
    }))
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,4 @@
 | 
				
			||||||
 | 
					use crate::macros::wrap_functions;
 | 
				
			||||||
use crate::{
 | 
					use crate::{
 | 
				
			||||||
    containers::ByteSlice,
 | 
					    containers::ByteSlice,
 | 
				
			||||||
    macros::{wrap_clone, wrap_free, wrap_methods},
 | 
					    macros::{wrap_clone, wrap_free, wrap_methods},
 | 
				
			||||||
| 
						 | 
					@ -8,11 +9,12 @@ use servicepoint::{
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use std::ptr::NonNull;
 | 
					use std::ptr::NonNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wrap_functions!(sp_cp437_grid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Creates a new [Cp437Grid] with the specified dimensions.
 | 
					    /// Creates a new [Cp437Grid] with the specified dimensions.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// returns: [Cp437Grid] initialized to 0.
 | 
					    /// returns: [Cp437Grid] initialized to 0.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn new(
 | 
				
			||||||
pub unsafe extern "C" fn sp_cp437_grid_new(
 | 
					 | 
				
			||||||
        width: usize,
 | 
					        width: usize,
 | 
				
			||||||
        height: usize,
 | 
					        height: usize,
 | 
				
			||||||
    ) -> NonNull<Cp437Grid> {
 | 
					    ) -> NonNull<Cp437Grid> {
 | 
				
			||||||
| 
						 | 
					@ -20,8 +22,7 @@ pub unsafe extern "C" fn sp_cp437_grid_new(
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Loads a [Cp437Grid] with the specified dimensions from the provided data.
 | 
					    /// Loads a [Cp437Grid] with the specified dimensions from the provided data.
 | 
				
			||||||
#[no_mangle]
 | 
					    fn load(
 | 
				
			||||||
pub unsafe extern "C" fn sp_cp437_grid_load(
 | 
					 | 
				
			||||||
        width: usize,
 | 
					        width: usize,
 | 
				
			||||||
        height: usize,
 | 
					        height: usize,
 | 
				
			||||||
        data: ByteSlice,
 | 
					        data: ByteSlice,
 | 
				
			||||||
| 
						 | 
					@ -30,6 +31,25 @@ pub unsafe extern "C" fn sp_cp437_grid_load(
 | 
				
			||||||
        heap_move_some(Cp437Grid::load(width, height, data))
 | 
					        heap_move_some(Cp437Grid::load(width, height, data))
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /// Creates a [Cp437GridCommand] and immediately turns that into a [Packet].
 | 
				
			||||||
 | 
					    ///
 | 
				
			||||||
 | 
					    /// The provided [Cp437Grid] gets consumed.
 | 
				
			||||||
 | 
					    ///
 | 
				
			||||||
 | 
					    /// Returns NULL in case of an error.
 | 
				
			||||||
 | 
					    fn into_packet(
 | 
				
			||||||
 | 
					        grid: NonNull<Cp437Grid>,
 | 
				
			||||||
 | 
					        x: usize,
 | 
				
			||||||
 | 
					        y: usize,
 | 
				
			||||||
 | 
					    ) -> *mut Packet {
 | 
				
			||||||
 | 
					        let grid = unsafe { heap_remove(grid) };
 | 
				
			||||||
 | 
					        heap_move_ok(Packet::try_from(Cp437GridCommand {
 | 
				
			||||||
 | 
					            grid,
 | 
				
			||||||
 | 
					            origin: Origin::new(x, y),
 | 
				
			||||||
 | 
					        }))
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wrap_clone!(sp_cp437_grid::Cp437Grid);
 | 
					wrap_clone!(sp_cp437_grid::Cp437Grid);
 | 
				
			||||||
wrap_free!(sp_cp437_grid::Cp437Grid);
 | 
					wrap_free!(sp_cp437_grid::Cp437Grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -81,21 +101,3 @@ wrap_methods!(
 | 
				
			||||||
        return(slice) { unsafe { ByteSlice::from_slice(slice) } };
 | 
					        return(slice) { unsafe { ByteSlice::from_slice(slice) } };
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					 | 
				
			||||||
/// Creates a [Cp437GridCommand] and immediately turns that into a [Packet].
 | 
					 | 
				
			||||||
///
 | 
					 | 
				
			||||||
/// The provided [Cp437Grid] gets consumed.
 | 
					 | 
				
			||||||
///
 | 
					 | 
				
			||||||
/// Returns NULL in case of an error.
 | 
					 | 
				
			||||||
#[no_mangle]
 | 
					 | 
				
			||||||
pub unsafe extern "C" fn sp_cp437_grid_into_packet(
 | 
					 | 
				
			||||||
    grid: NonNull<Cp437Grid>,
 | 
					 | 
				
			||||||
    x: usize,
 | 
					 | 
				
			||||||
    y: usize,
 | 
					 | 
				
			||||||
) -> *mut Packet {
 | 
					 | 
				
			||||||
    let grid = unsafe { heap_remove(grid) };
 | 
					 | 
				
			||||||
    heap_move_ok(Packet::try_from(Cp437GridCommand {
 | 
					 | 
				
			||||||
        grid,
 | 
					 | 
				
			||||||
        origin: Origin::new(x, y),
 | 
					 | 
				
			||||||
    }))
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,7 +47,7 @@ macro_rules! wrap_methods {
 | 
				
			||||||
                $(return($it:ident) $return_expr:block;)?
 | 
					                $(return($it:ident) $return_expr:block;)?
 | 
				
			||||||
            })?
 | 
					            })?
 | 
				
			||||||
            ;
 | 
					            ;
 | 
				
			||||||
        )*
 | 
					        )+
 | 
				
			||||||
    ) => {
 | 
					    ) => {
 | 
				
			||||||
        paste::paste! {
 | 
					        paste::paste! {
 | 
				
			||||||
            $(
 | 
					            $(
 | 
				
			||||||
| 
						 | 
					@ -76,7 +76,7 @@ macro_rules! wrap_methods {
 | 
				
			||||||
                )?
 | 
					                )?
 | 
				
			||||||
                return result;
 | 
					                return result;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            )*
 | 
					            )+
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -149,7 +149,33 @@ macro_rules! wrap_fields {
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					macro_rules! wrap_functions {
 | 
				
			||||||
 | 
					    (
 | 
				
			||||||
 | 
					        $prefix:ident;
 | 
				
			||||||
 | 
					        $(
 | 
				
			||||||
 | 
					            $(#[$meta:meta])+
 | 
				
			||||||
 | 
					            fn $function:ident($($param_name:ident: $param_type:ty),*$(,)?)
 | 
				
			||||||
 | 
					            $(-> $return_type:ty)?
 | 
				
			||||||
 | 
					            $block:block
 | 
				
			||||||
 | 
					        )+
 | 
				
			||||||
 | 
					    ) => {
 | 
				
			||||||
 | 
					        ::paste::paste! {
 | 
				
			||||||
 | 
					        $(
 | 
				
			||||||
 | 
					            $(#[$meta])*
 | 
				
			||||||
 | 
					            #[doc = ""]
 | 
				
			||||||
 | 
					            #[doc = concat!(" This function is part of the ", stringify!($prefix), " module.")]
 | 
				
			||||||
 | 
					            #[no_mangle]
 | 
				
			||||||
 | 
					            pub unsafe extern "C" fn [<$prefix _ $function>](
 | 
				
			||||||
 | 
					                $($param_name: $param_type),*
 | 
				
			||||||
 | 
					            ) $(-> $return_type)?
 | 
				
			||||||
 | 
					            $block
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        )+
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub(crate) use {
 | 
					pub(crate) use {
 | 
				
			||||||
    nonnull_as_mut, nonnull_as_ref, wrap_clone, wrap_fields, wrap_free,
 | 
					    nonnull_as_mut, nonnull_as_ref, wrap_clone, wrap_fields, wrap_free,
 | 
				
			||||||
    wrap_methods,
 | 
					    wrap_functions, wrap_methods,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue