regenerate C# bindings, apparently Cp437Grid has been missing

This commit is contained in:
Vinzenz Schroeter 2024-09-07 13:34:13 +02:00
parent 341c0ef2cd
commit cec31ad5b5
2 changed files with 256 additions and 255 deletions

View file

@ -371,180 +371,6 @@ namespace ServicePoint.BindGen
[DllImport(__DllName, EntryPoint = "sp_brightness_grid_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport(__DllName, EntryPoint = "sp_brightness_grid_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ByteSlice sp_brightness_grid_unsafe_data_ref(BrightnessGrid* @this); public static extern ByteSlice sp_brightness_grid_unsafe_data_ref(BrightnessGrid* @this);
/// <summary>
/// Creates a new `Cp437Grid` with the specified dimensions.
///
/// returns: `Cp437Grid` initialized to 0.
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - the returned instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_cp437_grid_dealloc`.
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern Cp437Grid* sp_cp437_grid_new(nuint width, nuint height);
/// <summary>
/// Loads a `Cp437Grid` with the specified dimensions from the provided data.
///
/// # Panics
///
/// When the provided `data_length` is not sufficient for the `height` and `width`
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `data` points to a valid memory location of at least `data_length`
/// bytes in size.
/// - the returned instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_cp437_grid_dealloc`.
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern Cp437Grid* sp_cp437_grid_load(nuint width, nuint height, byte* data, nuint data_length);
/// <summary>
/// Clones a `Cp437Grid`.
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `Cp437Grid`
/// - `this` is not written to concurrently
/// - the returned instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_cp437_grid_dealloc`.
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern Cp437Grid* sp_cp437_grid_clone(Cp437Grid* @this);
/// <summary>
/// Deallocates a `Cp437Grid`.
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `Cp437Grid`
/// - `this` is not used concurrently or after this call
/// - `this` was not passed to another consuming function, e.g. to create a `Command`
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_cp437_grid_dealloc(Cp437Grid* @this);
/// <summary>
/// Gets the current value at the specified position.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `x` and `y`: position of the cell to read
///
/// # Panics
///
/// When accessing `x` or `y` out of bounds.
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `Cp437Grid`
/// - `this` is not written to concurrently
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte sp_cp437_grid_get(Cp437Grid* @this, nuint x, nuint y);
/// <summary>
/// Sets the value of the specified position in the `Cp437Grid`.
///
/// # Arguments
///
/// - `this`: instance to write to
/// - `x` and `y`: position of the cell
/// - `value`: the value to write to the cell
///
/// returns: old value of the cell
///
/// # Panics
///
/// When accessing `x` or `y` out of bounds.
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `BitVec`
/// - `this` is not written to or read from concurrently
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_set", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_cp437_grid_set(Cp437Grid* @this, nuint x, nuint y, byte value);
/// <summary>
/// Sets the value of all cells in the `Cp437Grid`.
///
/// # Arguments
///
/// - `this`: instance to write to
/// - `value`: the value to set all cells to
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `Cp437Grid`
/// - `this` is not written to or read from concurrently
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_cp437_grid_fill(Cp437Grid* @this, byte value);
/// <summary>
/// Gets the width of the `Cp437Grid` instance.
///
/// # Arguments
///
/// - `this`: instance to read from
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `Cp437Grid`
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_width", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern nuint sp_cp437_grid_width(Cp437Grid* @this);
/// <summary>
/// Gets the height of the `Cp437Grid` instance.
///
/// # Arguments
///
/// - `this`: instance to read from
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `Cp437Grid`
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_height", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern nuint sp_cp437_grid_height(Cp437Grid* @this);
/// <summary>
/// Gets an unsafe reference to the data of the `Cp437Grid` instance.
///
/// ## Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `Cp437Grid`
/// - the returned memory range is never accessed after the passed `Cp437Grid` has been freed
/// - the returned memory range is never accessed concurrently, either via the `Cp437Grid` or directly
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ByteSlice sp_cp437_grid_unsafe_data_ref(Cp437Grid* @this);
/// <summary> /// <summary>
/// Tries to turn a `SPPacket` into a `SPCommand`. The packet is deallocated in the process. /// Tries to turn a `SPPacket` into a `SPCommand`. The packet is deallocated in the process.
/// ///
@ -873,6 +699,241 @@ namespace ServicePoint.BindGen
[DllImport(__DllName, EntryPoint = "sp_connection_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport(__DllName, EntryPoint = "sp_connection_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_connection_dealloc(Connection* ptr); public static extern void sp_connection_dealloc(Connection* ptr);
/// <summary>
/// Creates a new `Cp437Grid` with the specified dimensions.
///
/// returns: `Cp437Grid` initialized to 0.
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - the returned instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_cp437_grid_dealloc`.
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern Cp437Grid* sp_cp437_grid_new(nuint width, nuint height);
/// <summary>
/// Loads a `Cp437Grid` with the specified dimensions from the provided data.
///
/// # Panics
///
/// When the provided `data_length` is not sufficient for the `height` and `width`
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `data` points to a valid memory location of at least `data_length`
/// bytes in size.
/// - the returned instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_cp437_grid_dealloc`.
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern Cp437Grid* sp_cp437_grid_load(nuint width, nuint height, byte* data, nuint data_length);
/// <summary>
/// Clones a `Cp437Grid`.
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `Cp437Grid`
/// - `this` is not written to concurrently
/// - the returned instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_cp437_grid_dealloc`.
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern Cp437Grid* sp_cp437_grid_clone(Cp437Grid* @this);
/// <summary>
/// Deallocates a `Cp437Grid`.
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `Cp437Grid`
/// - `this` is not used concurrently or after this call
/// - `this` was not passed to another consuming function, e.g. to create a `Command`
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_cp437_grid_dealloc(Cp437Grid* @this);
/// <summary>
/// Gets the current value at the specified position.
///
/// # Arguments
///
/// - `this`: instance to read from
/// - `x` and `y`: position of the cell to read
///
/// # Panics
///
/// When accessing `x` or `y` out of bounds.
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `Cp437Grid`
/// - `this` is not written to concurrently
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern byte sp_cp437_grid_get(Cp437Grid* @this, nuint x, nuint y);
/// <summary>
/// Sets the value of the specified position in the `Cp437Grid`.
///
/// # Arguments
///
/// - `this`: instance to write to
/// - `x` and `y`: position of the cell
/// - `value`: the value to write to the cell
///
/// returns: old value of the cell
///
/// # Panics
///
/// When accessing `x` or `y` out of bounds.
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `BitVec`
/// - `this` is not written to or read from concurrently
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_set", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_cp437_grid_set(Cp437Grid* @this, nuint x, nuint y, byte value);
/// <summary>
/// Sets the value of all cells in the `Cp437Grid`.
///
/// # Arguments
///
/// - `this`: instance to write to
/// - `value`: the value to set all cells to
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `Cp437Grid`
/// - `this` is not written to or read from concurrently
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_cp437_grid_fill(Cp437Grid* @this, byte value);
/// <summary>
/// Gets the width of the `Cp437Grid` instance.
///
/// # Arguments
///
/// - `this`: instance to read from
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `Cp437Grid`
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_width", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern nuint sp_cp437_grid_width(Cp437Grid* @this);
/// <summary>
/// Gets the height of the `Cp437Grid` instance.
///
/// # Arguments
///
/// - `this`: instance to read from
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `Cp437Grid`
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_height", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern nuint sp_cp437_grid_height(Cp437Grid* @this);
/// <summary>
/// Gets an unsafe reference to the data of the `Cp437Grid` instance.
///
/// ## Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `Cp437Grid`
/// - the returned memory range is never accessed after the passed `Cp437Grid` has been freed
/// - the returned memory range is never accessed concurrently, either via the `Cp437Grid` or directly
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ByteSlice sp_cp437_grid_unsafe_data_ref(Cp437Grid* @this);
/// <summary>
/// Turns a `Command` into a `Packet`.
/// The `Command` gets consumed.
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `command` points to a valid instance of `Command`
/// - `command` is not used concurrently or after this call
/// - the returned `Packet` instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_packet_dealloc`.
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_packet_from_command", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern Packet* sp_packet_from_command(Command* command);
/// <summary>
/// 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
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `data` points to a valid memory region of at least `length` bytes
/// - `data` is not written to concurrently
/// - the returned `Packet` instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_packet_dealloc`.
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_packet_try_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern Packet* sp_packet_try_load(byte* data, nuint length);
/// <summary>
/// Clones a `Packet`.
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `Packet`
/// - `this` is not written to concurrently
/// - the returned instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_packet_dealloc`.
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_packet_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern Packet* sp_packet_clone(Packet* @this);
/// <summary>
/// Deallocates a `Packet`.
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `Packet`
/// - `this` is not used concurrently or after this call
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_packet_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_packet_dealloc(Packet* @this);
/// <summary> /// <summary>
/// Creates a new `PixelGrid` with the specified dimensions. /// Creates a new `PixelGrid` with the specified dimensions.
/// ///
@ -1064,67 +1125,6 @@ namespace ServicePoint.BindGen
[DllImport(__DllName, EntryPoint = "sp_pixel_grid_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [DllImport(__DllName, EntryPoint = "sp_pixel_grid_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ByteSlice sp_pixel_grid_unsafe_data_ref(PixelGrid* @this); public static extern ByteSlice sp_pixel_grid_unsafe_data_ref(PixelGrid* @this);
/// <summary>
/// Turns a `Command` into a `Packet`.
/// The `Command` gets consumed.
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `command` points to a valid instance of `Command`
/// - `command` is not used concurrently or after this call
/// - the returned `Packet` instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_packet_dealloc`.
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_packet_from_command", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern Packet* sp_packet_from_command(Command* command);
/// <summary>
/// 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
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `data` points to a valid memory region of at least `length` bytes
/// - `data` is not written to concurrently
/// - the returned `Packet` instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_packet_dealloc`.
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_packet_try_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern Packet* sp_packet_try_load(byte* data, nuint length);
/// <summary>
/// Clones a `Packet`.
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `Packet`
/// - `this` is not written to concurrently
/// - the returned instance is freed in some way, either by using a consuming function or
/// by explicitly calling `sp_packet_dealloc`.
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_packet_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern Packet* sp_packet_clone(Packet* @this);
/// <summary>
/// Deallocates a `Packet`.
///
/// # Safety
///
/// The caller has to make sure that:
///
/// - `this` points to a valid `Packet`
/// - `this` is not used concurrently or after this call
/// </summary>
[DllImport(__DllName, EntryPoint = "sp_packet_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void sp_packet_dealloc(Packet* @this);
} }
@ -1139,8 +1139,10 @@ namespace ServicePoint.BindGen
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Cp437Grid public unsafe partial struct ByteSlice
{ {
public byte* start;
public nuint length;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
@ -1154,22 +1156,20 @@ namespace ServicePoint.BindGen
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public unsafe partial struct PixelGrid public unsafe partial struct Cp437Grid
{ {
} }
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct ByteSlice
{
public byte* start;
public nuint length;
}
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Packet public unsafe partial struct Packet
{ {
} }
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct PixelGrid
{
}
public enum CompressionCode : ushort public enum CompressionCode : ushort
{ {

View file

@ -1,19 +1,20 @@
//! Build script generating the C# code needed to call methods from the `servicepoint` C library. //! Build script generating the C# code needed to call methods from the `servicepoint` C library.
use std::fs;
fn main() { fn main() {
println!("cargo::rerun-if-changed=../servicepoint_binding_c/src"); println!("cargo::rerun-if-changed=../servicepoint_binding_c/src");
println!("cargo::rerun-if-changed=build.rs"); println!("cargo::rerun-if-changed=build.rs");
csbindgen::Builder::default()
.input_extern_file("../servicepoint_binding_c/src/bit_vec.rs") let mut builder = csbindgen::Builder::default();
.input_extern_file("../servicepoint_binding_c/src/brightness_grid.rs")
.input_extern_file("../servicepoint_binding_c/src/cp437_grid.rs") for source in fs::read_dir("../servicepoint_binding_c/src").unwrap() {
.input_extern_file("../servicepoint_binding_c/src/command.rs") let path = source.unwrap().path();
.input_extern_file("../servicepoint_binding_c/src/connection.rs") println!("cargo:rerun-if-changed={}", path.display());
.input_extern_file("../servicepoint_binding_c/src/pixel_grid.rs") builder = builder.input_extern_file(path);
.input_extern_file("../servicepoint_binding_c/src/lib.rs") }
.input_extern_file("../servicepoint_binding_c/src/byte_slice.rs")
.input_extern_file("../servicepoint_binding_c/src/packet.rs") builder
.input_extern_file("../servicepoint_binding_c/src/constants.rs")
.csharp_dll_name("servicepoint_binding_c") .csharp_dll_name("servicepoint_binding_c")
.csharp_namespace("ServicePoint.BindGen") .csharp_namespace("ServicePoint.BindGen")
.csharp_use_nint_types(true) .csharp_use_nint_types(true)