regenerate bindings

This commit is contained in:
Vinzenz Schroeter 2024-05-15 23:17:29 +02:00
parent 237ca6d6a2
commit e4c4416b74
2 changed files with 25 additions and 8 deletions

View file

@ -93,7 +93,7 @@ typedef struct sp2_Packet sp2_Packet;
typedef struct sp2_PixelGrid sp2_PixelGrid; typedef struct sp2_PixelGrid sp2_PixelGrid;
/** /**
* Represents a `&mut [u8]` as a struct usable by C code. * Represents a span of memory (`&mut [u8]` ) as a struct usable by C code.
* *
* Usage of this type is inherently unsafe. * Usage of this type is inherently unsafe.
*/ */
@ -145,6 +145,11 @@ void sp2_bit_vec_fill(struct sp2_BitVec *this_, bool value);
*/ */
bool sp2_bit_vec_get(const struct sp2_BitVec *this_, size_t index); bool sp2_bit_vec_get(const struct sp2_BitVec *this_, size_t index);
/**
* Returns true if length is 0.
*/
bool sp2_bit_vec_is_empty(const struct sp2_BitVec *this_);
/** /**
* Gets the length of the `BitVec` in bits. * Gets the length of the `BitVec` in bits.
*/ */
@ -343,13 +348,6 @@ struct sp2_Command *sp2_command_hard_reset(void);
*/ */
struct sp2_Command *sp2_command_try_from_packet(struct sp2_Packet *packet); struct sp2_Command *sp2_command_try_from_packet(struct sp2_Packet *packet);
/**
* Tries to load a `Command` from the passed array with the specified length.
*
* returns: NULL in case of an error, pointer to the allocated command otherwise
*/
struct sp2_Command *sp2_command_try_load(const uint8_t *data, size_t length);
/** /**
* Closes and deallocates a connection instance * Closes and deallocates a connection instance
*/ */
@ -371,11 +369,25 @@ struct sp2_Connection *sp2_connection_open(const char *host);
bool sp2_connection_send(const struct sp2_Connection *connection, bool sp2_connection_send(const struct sp2_Connection *connection,
struct sp2_Packet *command_ptr); struct sp2_Packet *command_ptr);
/**
* Deallocates a `Packet`.
*
* Note: do not call this if the instance has been consumed in another way, e.g. by sending it.
*/
void sp2_packet_dealloc(struct sp2_Packet *this_);
/** /**
* Turns a `Command` into a `Packet`. The command gets deallocated in the process. * Turns a `Command` into a `Packet`. The command gets deallocated in the process.
*/ */
struct sp2_Packet *sp2_packet_from_command(struct sp2_Command *command); struct sp2_Packet *sp2_packet_from_command(struct sp2_Command *command);
/**
* Tries to load a `Packet` from the passed array with the specified length.
*
* returns: NULL in case of an error, pointer to the allocated packet otherwise
*/
struct sp2_Packet *sp2_packet_try_load(const uint8_t *data, size_t length);
/** /**
* Clones a `PixelGrid`. * Clones a `PixelGrid`.
* The returned instance has to be freed with `pixel_grid_dealloc`. * The returned instance has to be freed with `pixel_grid_dealloc`.

View file

@ -50,6 +50,11 @@ namespace ServicePoint2.BindGen
[DllImport(__DllName, EntryPoint = "sp2_bit_vec_len", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport(__DllName, EntryPoint = "sp2_bit_vec_len", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern nuint sp2_bit_vec_len(BitVec* @this); public static extern nuint sp2_bit_vec_len(BitVec* @this);
/// <summary>Returns true if length is 0.</summary>
[DllImport(__DllName, EntryPoint = "sp2_bit_vec_is_empty", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool sp2_bit_vec_is_empty(BitVec* @this);
/// <summary>Gets an unsafe reference to the data of the `BitVec` instance. ## Safety The caller has to make sure to never access the returned memory after the `BitVec` instance has been consumed or manually deallocated. Reading and writing concurrently to either the original instance or the returned data will result in undefined behavior.</summary> /// <summary>Gets an unsafe reference to the data of the `BitVec` instance. ## Safety The caller has to make sure to never access the returned memory after the `BitVec` instance has been consumed or manually deallocated. Reading and writing concurrently to either the original instance or the returned data will result in undefined behavior.</summary>
[DllImport(__DllName, EntryPoint = "sp2_bit_vec_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport(__DllName, EntryPoint = "sp2_bit_vec_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern CByteSlice sp2_bit_vec_unsafe_data_ref(BitVec* @this); public static extern CByteSlice sp2_bit_vec_unsafe_data_ref(BitVec* @this);