diff --git a/crates/servicepoint_binding_cs/ServicePoint/BindGen/ServicePoint.g.cs b/crates/servicepoint_binding_cs/ServicePoint/BindGen/ServicePoint.g.cs
index cd73a1a..fd7e1d3 100644
--- a/crates/servicepoint_binding_cs/ServicePoint/BindGen/ServicePoint.g.cs
+++ b/crates/servicepoint_binding_cs/ServicePoint/BindGen/ServicePoint.g.cs
@@ -371,180 +371,6 @@ namespace ServicePoint.BindGen
[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);
- ///
- /// 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`.
- ///
- [DllImport(__DllName, EntryPoint = "sp_cp437_grid_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
- public static extern Cp437Grid* sp_cp437_grid_new(nuint width, nuint height);
-
- ///
- /// 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`.
- ///
- [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);
-
- ///
- /// 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`.
- ///
- [DllImport(__DllName, EntryPoint = "sp_cp437_grid_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
- public static extern Cp437Grid* sp_cp437_grid_clone(Cp437Grid* @this);
-
- ///
- /// 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`
- ///
- [DllImport(__DllName, EntryPoint = "sp_cp437_grid_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
- public static extern void sp_cp437_grid_dealloc(Cp437Grid* @this);
-
- ///
- /// 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
- ///
- [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);
-
- ///
- /// 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
- ///
- [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);
-
- ///
- /// 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
- ///
- [DllImport(__DllName, EntryPoint = "sp_cp437_grid_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
- public static extern void sp_cp437_grid_fill(Cp437Grid* @this, byte value);
-
- ///
- /// 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`
- ///
- [DllImport(__DllName, EntryPoint = "sp_cp437_grid_width", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
- public static extern nuint sp_cp437_grid_width(Cp437Grid* @this);
-
- ///
- /// 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`
- ///
- [DllImport(__DllName, EntryPoint = "sp_cp437_grid_height", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
- public static extern nuint sp_cp437_grid_height(Cp437Grid* @this);
-
- ///
- /// 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
- ///
- [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);
-
///
/// 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)]
public static extern void sp_connection_dealloc(Connection* ptr);
+ ///
+ /// 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`.
+ ///
+ [DllImport(__DllName, EntryPoint = "sp_cp437_grid_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ public static extern Cp437Grid* sp_cp437_grid_new(nuint width, nuint height);
+
+ ///
+ /// 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`.
+ ///
+ [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);
+
+ ///
+ /// 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`.
+ ///
+ [DllImport(__DllName, EntryPoint = "sp_cp437_grid_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ public static extern Cp437Grid* sp_cp437_grid_clone(Cp437Grid* @this);
+
+ ///
+ /// 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`
+ ///
+ [DllImport(__DllName, EntryPoint = "sp_cp437_grid_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ public static extern void sp_cp437_grid_dealloc(Cp437Grid* @this);
+
+ ///
+ /// 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
+ ///
+ [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);
+
+ ///
+ /// 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
+ ///
+ [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);
+
+ ///
+ /// 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
+ ///
+ [DllImport(__DllName, EntryPoint = "sp_cp437_grid_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ public static extern void sp_cp437_grid_fill(Cp437Grid* @this, byte value);
+
+ ///
+ /// 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`
+ ///
+ [DllImport(__DllName, EntryPoint = "sp_cp437_grid_width", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ public static extern nuint sp_cp437_grid_width(Cp437Grid* @this);
+
+ ///
+ /// 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`
+ ///
+ [DllImport(__DllName, EntryPoint = "sp_cp437_grid_height", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ public static extern nuint sp_cp437_grid_height(Cp437Grid* @this);
+
+ ///
+ /// 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
+ ///
+ [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);
+
+ ///
+ /// 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`.
+ ///
+ [DllImport(__DllName, EntryPoint = "sp_packet_from_command", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ public static extern Packet* sp_packet_from_command(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
+ ///
+ /// # 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`.
+ ///
+ [DllImport(__DllName, EntryPoint = "sp_packet_try_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ public static extern Packet* sp_packet_try_load(byte* data, nuint length);
+
+ ///
+ /// 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`.
+ ///
+ [DllImport(__DllName, EntryPoint = "sp_packet_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ public static extern Packet* sp_packet_clone(Packet* @this);
+
+ ///
+ /// 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
+ ///
+ [DllImport(__DllName, EntryPoint = "sp_packet_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ public static extern void sp_packet_dealloc(Packet* @this);
+
///
/// 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)]
public static extern ByteSlice sp_pixel_grid_unsafe_data_ref(PixelGrid* @this);
- ///
- /// 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`.
- ///
- [DllImport(__DllName, EntryPoint = "sp_packet_from_command", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
- public static extern Packet* sp_packet_from_command(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
- ///
- /// # 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`.
- ///
- [DllImport(__DllName, EntryPoint = "sp_packet_try_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
- public static extern Packet* sp_packet_try_load(byte* data, nuint length);
-
- ///
- /// 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`.
- ///
- [DllImport(__DllName, EntryPoint = "sp_packet_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
- public static extern Packet* sp_packet_clone(Packet* @this);
-
- ///
- /// 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
- ///
- [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)]
- public unsafe partial struct Cp437Grid
+ public unsafe partial struct ByteSlice
{
+ public byte* start;
+ public nuint length;
}
[StructLayout(LayoutKind.Sequential)]
@@ -1154,22 +1156,20 @@ namespace ServicePoint.BindGen
}
[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)]
public unsafe partial struct Packet
{
}
+ [StructLayout(LayoutKind.Sequential)]
+ public unsafe partial struct PixelGrid
+ {
+ }
+
public enum CompressionCode : ushort
{
diff --git a/crates/servicepoint_binding_cs/build.rs b/crates/servicepoint_binding_cs/build.rs
index e8fe1f5..5287698 100644
--- a/crates/servicepoint_binding_cs/build.rs
+++ b/crates/servicepoint_binding_cs/build.rs
@@ -1,19 +1,20 @@
//! Build script generating the C# code needed to call methods from the `servicepoint` C library.
+use std::fs;
+
fn main() {
println!("cargo::rerun-if-changed=../servicepoint_binding_c/src");
println!("cargo::rerun-if-changed=build.rs");
- csbindgen::Builder::default()
- .input_extern_file("../servicepoint_binding_c/src/bit_vec.rs")
- .input_extern_file("../servicepoint_binding_c/src/brightness_grid.rs")
- .input_extern_file("../servicepoint_binding_c/src/cp437_grid.rs")
- .input_extern_file("../servicepoint_binding_c/src/command.rs")
- .input_extern_file("../servicepoint_binding_c/src/connection.rs")
- .input_extern_file("../servicepoint_binding_c/src/pixel_grid.rs")
- .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")
- .input_extern_file("../servicepoint_binding_c/src/constants.rs")
+
+ let mut builder = csbindgen::Builder::default();
+
+ for source in fs::read_dir("../servicepoint_binding_c/src").unwrap() {
+ let path = source.unwrap().path();
+ println!("cargo:rerun-if-changed={}", path.display());
+ builder = builder.input_extern_file(path);
+ }
+
+ builder
.csharp_dll_name("servicepoint_binding_c")
.csharp_namespace("ServicePoint.BindGen")
.csharp_use_nint_types(true)