From a91e0e6eed56cf6e8fc592f6b0fe8c5d6f3f19fd Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Thu, 29 Aug 2024 20:03:07 +0200 Subject: [PATCH] update csbindgen to improve comment formatting --- Cargo.lock | 6 +- crates/servicepoint_binding_cs/Cargo.toml | 2 +- .../ServicePoint/BindGen/ServicePoint.g.cs | 926 ++++++++++++++++-- 3 files changed, 854 insertions(+), 80 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0feeed0..9192eeb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -245,12 +245,12 @@ dependencies = [ [[package]] name = "csbindgen" -version = "1.9.1" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf70eb656f35e0e6956cbde31c66431c53d8a546823489719099c71525767a9c" +checksum = "c26b9831049b947d154bba920e4124053def72447be6fb106a96f483874b482a" dependencies = [ "regex", - "syn 1.0.109", + "syn 2.0.68", ] [[package]] diff --git a/crates/servicepoint_binding_cs/Cargo.toml b/crates/servicepoint_binding_cs/Cargo.toml index e93b557..fe3c106 100644 --- a/crates/servicepoint_binding_cs/Cargo.toml +++ b/crates/servicepoint_binding_cs/Cargo.toml @@ -10,7 +10,7 @@ crate-type = ["cdylib"] test = false [build-dependencies] -csbindgen = "1.8.0" +csbindgen = "1.9.3" [dependencies] servicepoint_binding_c = { version = "0.7.0", path = "../servicepoint_binding_c" } diff --git a/crates/servicepoint_binding_cs/ServicePoint/BindGen/ServicePoint.g.cs b/crates/servicepoint_binding_cs/ServicePoint/BindGen/ServicePoint.g.cs index 1751f84..cf9fb4e 100644 --- a/crates/servicepoint_binding_cs/ServicePoint/BindGen/ServicePoint.g.cs +++ b/crates/servicepoint_binding_cs/ServicePoint/BindGen/ServicePoint.g.cs @@ -19,247 +19,1037 @@ namespace ServicePoint.BindGen public const nuint TILE_HEIGHT = 20; - /// Creates a new `BitVec` instance. # Arguments * `size`: size in bits. returns: `BitVec` with all bits set to false. # Panics When `size` is not divisible by 8. # 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_bit_vec_dealloc`. + /// + /// Creates a new `BitVec` instance. + /// + /// # Arguments + /// + /// - `size`: size in bits. + /// + /// returns: `BitVec` with all bits set to false. + /// + /// # Panics + /// + /// When `size` is not divisible by 8. + /// + /// # 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_bit_vec_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_bit_vec_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern CBitVec* sp_bit_vec_new(nuint size); - /// Interpret the data as a series of bits and load then into a new `BitVec` instance. # 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_bit_vec_dealloc`. + /// + /// Interpret the data as a series of bits and load then into a new `BitVec` instance. + /// + /// # 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_bit_vec_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_bit_vec_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern CBitVec* sp_bit_vec_load(byte* data, nuint data_length); - /// Clones a `BitVec`. # Safety The caller has to make sure that: - `this` points to a valid `BitVec` - `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_bit_vec_dealloc`. + /// + /// Clones a `BitVec`. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid `BitVec` + /// - `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_bit_vec_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_bit_vec_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern CBitVec* sp_bit_vec_clone(CBitVec* @this); - /// Deallocates a `BitVec`. # Safety The caller has to make sure that: - `this` points to a valid `BitVec` - `this` is not used concurrently or after this call - `this` was not passed to another consuming function, e.g. to create a `Command` + /// + /// Deallocates a `BitVec`. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid `BitVec` + /// - `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_bit_vec_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void sp_bit_vec_dealloc(CBitVec* @this); - /// Gets the value of a bit from the `BitVec`. # Arguments * `this`: instance to read from * `index`: the bit index to read returns: value of the bit # Panics When accessing `index` out of bounds. # Safety The caller has to make sure that: - `this` points to a valid `BitVec` - `this` is not written to concurrently + /// + /// Gets the value of a bit from the `BitVec`. + /// + /// # Arguments + /// + /// - `this`: instance to read from + /// - `index`: the bit index to read + /// + /// returns: value of the bit + /// + /// # Panics + /// + /// When accessing `index` out of bounds. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid `BitVec` + /// - `this` is not written to concurrently + /// [DllImport(__DllName, EntryPoint = "sp_bit_vec_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool sp_bit_vec_get(CBitVec* @this, nuint index); - /// Sets the value of a bit in the `BitVec`. # Arguments * `this`: instance to write to * `index`: the bit index to edit * `value`: the value to set the bit to returns: old value of the bit # Panics When accessing `index` 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 + /// + /// Sets the value of a bit in the `BitVec`. + /// + /// # Arguments + /// + /// - `this`: instance to write to + /// - `index`: the bit index to edit + /// - `value`: the value to set the bit to + /// + /// returns: old value of the bit + /// + /// # Panics + /// + /// When accessing `index` 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_bit_vec_set", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void sp_bit_vec_set(CBitVec* @this, nuint index, [MarshalAs(UnmanagedType.U1)] bool value); - /// Sets the value of all bits in the `BitVec`. # Arguments * `value`: the value to set all bits to # Safety The caller has to make sure that: - `this` points to a valid `BitVec` - `this` is not written to or read from concurrently + /// + /// Sets the value of all bits in the `BitVec`. + /// + /// # Arguments + /// + /// - `value`: the value to set all bits to + /// + /// # 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_bit_vec_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void sp_bit_vec_fill(CBitVec* @this, [MarshalAs(UnmanagedType.U1)] bool value); - /// Gets the length of the `BitVec` in bits. # Safety The caller has to make sure that: - `this` points to a valid `BitVec` + /// + /// Gets the length of the `BitVec` in bits. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid `BitVec` + /// [DllImport(__DllName, EntryPoint = "sp_bit_vec_len", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern nuint sp_bit_vec_len(CBitVec* @this); - /// Returns true if length is 0. # Safety The caller has to make sure that: - `this` points to a valid `BitVec` + /// + /// Returns true if length is 0. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid `BitVec` + /// [DllImport(__DllName, EntryPoint = "sp_bit_vec_is_empty", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool sp_bit_vec_is_empty(CBitVec* @this); - /// Gets an unsafe reference to the data of the `BitVec` instance. ## Safety The caller has to make sure that: - `this` points to a valid `BitVec` - the returned memory range is never accessed after the passed `BitVec` has been freed - the returned memory range is never accessed concurrently, either via the `BitVec` or directly + /// + /// Gets an unsafe reference to the data of the `BitVec` instance. + /// + /// ## Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid `BitVec` + /// - the returned memory range is never accessed after the passed `BitVec` has been freed + /// - the returned memory range is never accessed concurrently, either via the `BitVec` or directly + /// [DllImport(__DllName, EntryPoint = "sp_bit_vec_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern CByteSlice sp_bit_vec_unsafe_data_ref(CBitVec* @this); - /// Creates a new `BrightnessGrid` with the specified dimensions. returns: `BrightnessGrid` 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_brightness_grid_dealloc`. + /// + /// Creates a new `BrightnessGrid` with the specified dimensions. + /// + /// returns: `BrightnessGrid` 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_brightness_grid_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_brightness_grid_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern CBrightnessGrid* sp_brightness_grid_new(nuint width, nuint height); - /// Loads a `BrightnessGrid` 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_brightness_grid_dealloc`. + /// + /// Loads a `BrightnessGrid` 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_brightness_grid_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_brightness_grid_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern CBrightnessGrid* sp_brightness_grid_load(nuint width, nuint height, byte* data, nuint data_length); - /// Clones a `BrightnessGrid`. # Safety The caller has to make sure that: - `this` points to a valid `BrightnessGrid` - `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_brightness_grid_dealloc`. + /// + /// Clones a `BrightnessGrid`. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid `BrightnessGrid` + /// - `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_brightness_grid_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_brightness_grid_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern CBrightnessGrid* sp_brightness_grid_clone(CBrightnessGrid* @this); - /// Deallocates a `BrightnessGrid`. # Safety The caller has to make sure that: - `this` points to a valid `BrightnessGrid` - `this` is not used concurrently or after this call - `this` was not passed to another consuming function, e.g. to create a `Command` + /// + /// Deallocates a `BrightnessGrid`. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid `BrightnessGrid` + /// - `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_brightness_grid_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void sp_brightness_grid_dealloc(CBrightnessGrid* @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 `BrightnessGrid` - `this` is not written to concurrently + /// + /// 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 `BrightnessGrid` + /// - `this` is not written to concurrently + /// [DllImport(__DllName, EntryPoint = "sp_brightness_grid_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern byte sp_brightness_grid_get(CBrightnessGrid* @this, nuint x, nuint y); - /// Sets the value of the specified position in the `BrightnessGrid`. # 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. - When providing an invalid brightness value # Safety The caller has to make sure that: - `this` points to a valid `BitVec` - `this` is not written to or read from concurrently + /// + /// Sets the value of the specified position in the `BrightnessGrid`. + /// + /// # 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. + /// - When providing an invalid brightness value + /// + /// # 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_brightness_grid_set", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void sp_brightness_grid_set(CBrightnessGrid* @this, nuint x, nuint y, byte value); - /// Sets the value of all cells in the `BrightnessGrid`. # Arguments * `this`: instance to write to * `value`: the value to set all cells to # Panics - When providing an invalid brightness value # Safety The caller has to make sure that: - `this` points to a valid `BrightnessGrid` - `this` is not written to or read from concurrently + /// + /// Sets the value of all cells in the `BrightnessGrid`. + /// + /// # Arguments + /// + /// - `this`: instance to write to + /// - `value`: the value to set all cells to + /// + /// # Panics + /// + /// - When providing an invalid brightness value + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid `BrightnessGrid` + /// - `this` is not written to or read from concurrently + /// [DllImport(__DllName, EntryPoint = "sp_brightness_grid_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void sp_brightness_grid_fill(CBrightnessGrid* @this, byte value); - /// Gets the width of the `BrightnessGrid` instance. # Arguments * `this`: instance to read from # Safety The caller has to make sure that: - `this` points to a valid `BrightnessGrid` + /// + /// Gets the width of the `BrightnessGrid` instance. + /// + /// # Arguments + /// + /// - `this`: instance to read from + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid `BrightnessGrid` + /// [DllImport(__DllName, EntryPoint = "sp_brightness_grid_width", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern nuint sp_brightness_grid_width(CBrightnessGrid* @this); - /// Gets the height of the `BrightnessGrid` instance. # Arguments * `this`: instance to read from # Safety The caller has to make sure that: - `this` points to a valid `BrightnessGrid` + /// + /// Gets the height of the `BrightnessGrid` instance. + /// + /// # Arguments + /// + /// - `this`: instance to read from + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid `BrightnessGrid` + /// [DllImport(__DllName, EntryPoint = "sp_brightness_grid_height", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern nuint sp_brightness_grid_height(CBrightnessGrid* @this); - /// Gets an unsafe reference to the data of the `BrightnessGrid` instance. ## Safety The caller has to make sure that: - `this` points to a valid `BrightnessGrid` - the returned memory range is never accessed after the passed `BrightnessGrid` has been freed - the returned memory range is never accessed concurrently, either via the `BrightnessGrid` or directly + /// + /// Gets an unsafe reference to the data of the `BrightnessGrid` instance. + /// + /// ## Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid `BrightnessGrid` + /// - the returned memory range is never accessed after the passed `BrightnessGrid` has been freed + /// - the returned memory range is never accessed concurrently, either via the `BrightnessGrid` or directly + /// [DllImport(__DllName, EntryPoint = "sp_brightness_grid_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern CByteSlice sp_brightness_grid_unsafe_data_ref(CBrightnessGrid* @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`. + /// + /// 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 CCp437Grid* 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`. + /// + /// 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 CCp437Grid* 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`. + /// + /// 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 CCp437Grid* sp_cp437_grid_clone(CCp437Grid* @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` + /// + /// 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(CCp437Grid* @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 + /// + /// 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(CCp437Grid* @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 + /// + /// 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(CCp437Grid* @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 + /// + /// 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(CCp437Grid* @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` + /// + /// 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(CCp437Grid* @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` + /// + /// 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(CCp437Grid* @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 + /// + /// 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 CByteSlice sp_cp437_grid_unsafe_data_ref(CCp437Grid* @this); - /// Tries to turn a `Packet` into a `Command`. The packet is deallocated in the process. Returns: pointer to new `Command` instance or NULL # Safety The caller has to make sure that: - `packet` points to a valid instance of `Packet` - `packet` is not used concurrently or after this call - the result is checked for NULL - the returned `Command` instance is freed in some way, either by using a consuming function or by explicitly calling `sp_command_dealloc`. + /// + /// Tries to turn a `Packet` into a `Command`. The packet is deallocated in the process. + /// + /// Returns: pointer to new `Command` instance or NULL + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `packet` points to a valid instance of `Packet` + /// - `packet` is not used concurrently or after this call + /// - the result is checked for NULL + /// - the returned `Command` instance is freed in some way, either by using a consuming function or + /// by explicitly calling `sp_command_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_command_try_from_packet", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Command* sp_command_try_from_packet(Packet* packet); - /// Clones a `Command` instance. # Safety The caller has to make sure that: - `this` points to a valid instance of `Command` - `this` is not written to concurrently - the returned `Command` instance is freed in some way, either by using a consuming function or by explicitly calling `sp_command_dealloc`. + /// + /// Clones a `Command` instance. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid instance of `Command` + /// - `this` is not written to concurrently + /// - the returned `Command` instance is freed in some way, either by using a consuming function or + /// by explicitly calling `sp_command_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_command_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Command* sp_command_clone(Command* original); - /// Allocates a new `Command::Clear` instance. # Safety The caller has to make sure that: - the returned `Command` instance is freed in some way, either by using a consuming function or by explicitly calling `sp_command_dealloc`. + /// + /// Allocates a new `Command::Clear` instance. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - the returned `Command` instance is freed in some way, either by using a consuming function or + /// by explicitly calling `sp_command_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_command_clear", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Command* sp_command_clear(); - /// Allocates a new `Command::HardReset` instance. # Safety The caller has to make sure that: - the returned `Command` instance is freed in some way, either by using a consuming function or by explicitly calling `sp_command_dealloc`. + /// + /// Allocates a new `Command::HardReset` instance. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - the returned `Command` instance is freed in some way, either by using a consuming function or + /// by explicitly calling `sp_command_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_command_hard_reset", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Command* sp_command_hard_reset(); - /// Allocates a new `Command::FadeOut` instance. # Safety The caller has to make sure that: - the returned `Command` instance is freed in some way, either by using a consuming function or by explicitly calling `sp_command_dealloc`. + /// + /// Allocates a new `Command::FadeOut` instance. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - the returned `Command` instance is freed in some way, either by using a consuming function or + /// by explicitly calling `sp_command_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_command_fade_out", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Command* sp_command_fade_out(); - /// Allocates a new `Command::Brightness` instance for setting the brightness of all tiles to the same value. # Panics - When the provided brightness value is out of range (0-11). # Safety The caller has to make sure that: - the returned `Command` instance is freed in some way, either by using a consuming function or by explicitly calling `sp_command_dealloc`. + /// + /// Allocates a new `Command::Brightness` instance for setting the brightness of all tiles to the + /// same value. + /// + /// # Panics + /// + /// - When the provided brightness value is out of range (0-11). + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - the returned `Command` instance is freed in some way, either by using a consuming function or + /// by explicitly calling `sp_command_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_command_brightness", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Command* sp_command_brightness(byte brightness); - /// Allocates a new `Command::CharBrightness` instance. The passed `ByteGrid` gets consumed. # Safety The caller has to make sure that: - `byte_grid` points to a valid instance of `ByteGrid` - `byte_grid` is not used concurrently or after this call - the returned `Command` instance is freed in some way, either by using a consuming function or by explicitly calling `sp_command_dealloc`. + /// + /// Allocates a new `Command::CharBrightness` instance. + /// The passed `ByteGrid` gets consumed. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `byte_grid` points to a valid instance of `ByteGrid` + /// - `byte_grid` is not used concurrently or after this call + /// - the returned `Command` instance is freed in some way, either by using a consuming function or + /// by explicitly calling `sp_command_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_command_char_brightness", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Command* sp_command_char_brightness(nuint x, nuint y, CBrightnessGrid* byte_grid); - /// Allocates a new `Command::BitmapLinear` instance. The passed `BitVec` gets consumed. # Safety The caller has to make sure that: - `bit_vec` points to a valid instance of `BitVec` - `bit_vec` is not used concurrently or after this call - `compression` matches one of the allowed enum values - the returned `Command` instance is freed in some way, either by using a consuming function or by explicitly calling `sp_command_dealloc`. + /// + /// Allocates a new `Command::BitmapLinear` instance. + /// The passed `BitVec` gets consumed. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `bit_vec` points to a valid instance of `BitVec` + /// - `bit_vec` is not used concurrently or after this call + /// - `compression` matches one of the allowed enum values + /// - the returned `Command` instance is freed in some way, either by using a consuming function or + /// by explicitly calling `sp_command_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_command_bitmap_linear", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Command* sp_command_bitmap_linear(nuint offset, CBitVec* bit_vec, CompressionCode compression); - /// Allocates a new `Command::BitmapLinearAnd` instance. The passed `BitVec` gets consumed. # Safety The caller has to make sure that: - `bit_vec` points to a valid instance of `BitVec` - `bit_vec` is not used concurrently or after this call - `compression` matches one of the allowed enum values - the returned `Command` instance is freed in some way, either by using a consuming function or by explicitly calling `sp_command_dealloc`. + /// + /// Allocates a new `Command::BitmapLinearAnd` instance. + /// The passed `BitVec` gets consumed. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `bit_vec` points to a valid instance of `BitVec` + /// - `bit_vec` is not used concurrently or after this call + /// - `compression` matches one of the allowed enum values + /// - the returned `Command` instance is freed in some way, either by using a consuming function or + /// by explicitly calling `sp_command_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_command_bitmap_linear_and", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Command* sp_command_bitmap_linear_and(nuint offset, CBitVec* bit_vec, CompressionCode compression); - /// Allocates a new `Command::BitmapLinearOr` instance. The passed `BitVec` gets consumed. # Safety The caller has to make sure that: - `bit_vec` points to a valid instance of `BitVec` - `bit_vec` is not used concurrently or after this call - `compression` matches one of the allowed enum values - the returned `Command` instance is freed in some way, either by using a consuming function or by explicitly calling `sp_command_dealloc`. + /// + /// Allocates a new `Command::BitmapLinearOr` instance. + /// The passed `BitVec` gets consumed. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `bit_vec` points to a valid instance of `BitVec` + /// - `bit_vec` is not used concurrently or after this call + /// - `compression` matches one of the allowed enum values + /// - the returned `Command` instance is freed in some way, either by using a consuming function or + /// by explicitly calling `sp_command_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_command_bitmap_linear_or", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Command* sp_command_bitmap_linear_or(nuint offset, CBitVec* bit_vec, CompressionCode compression); - /// Allocates a new `Command::BitmapLinearXor` instance. The passed `BitVec` gets consumed. # Safety The caller has to make sure that: - `bit_vec` points to a valid instance of `BitVec` - `bit_vec` is not used concurrently or after this call - `compression` matches one of the allowed enum values - the returned `Command` instance is freed in some way, either by using a consuming function or by explicitly calling `sp_command_dealloc`. + /// + /// Allocates a new `Command::BitmapLinearXor` instance. + /// The passed `BitVec` gets consumed. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `bit_vec` points to a valid instance of `BitVec` + /// - `bit_vec` is not used concurrently or after this call + /// - `compression` matches one of the allowed enum values + /// - the returned `Command` instance is freed in some way, either by using a consuming function or + /// by explicitly calling `sp_command_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_command_bitmap_linear_xor", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Command* sp_command_bitmap_linear_xor(nuint offset, CBitVec* bit_vec, CompressionCode compression); - /// Allocates a new `Command::Cp437Data` instance. The passed `ByteGrid` gets consumed. # Safety The caller has to make sure that: - `byte_grid` points to a valid instance of `ByteGrid` - `byte_grid` is not used concurrently or after this call - the returned `Command` instance is freed in some way, either by using a consuming function or by explicitly calling `sp_command_dealloc`. + /// + /// Allocates a new `Command::Cp437Data` instance. + /// The passed `ByteGrid` gets consumed. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `byte_grid` points to a valid instance of `ByteGrid` + /// - `byte_grid` is not used concurrently or after this call + /// - the returned `Command` instance is freed in some way, either by using a consuming function or + /// by explicitly calling `sp_command_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_command_cp437_data", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Command* sp_command_cp437_data(nuint x, nuint y, CCp437Grid* byte_grid); - /// Allocates a new `Command::BitmapLinearWin` instance. The passed `PixelGrid` gets consumed. # Safety The caller has to make sure that: - `pixel_grid` points to a valid instance of `PixelGrid` - `pixel_grid` is not used concurrently or after this call - `compression` matches one of the allowed enum values - the returned `Command` instance is freed in some way, either by using a consuming function or by explicitly calling `sp_command_dealloc`. + /// + /// Allocates a new `Command::BitmapLinearWin` instance. + /// The passed `PixelGrid` gets consumed. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `pixel_grid` points to a valid instance of `PixelGrid` + /// - `pixel_grid` is not used concurrently or after this call + /// - `compression` matches one of the allowed enum values + /// - the returned `Command` instance is freed in some way, either by using a consuming function or + /// by explicitly calling `sp_command_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_command_bitmap_linear_win", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Command* sp_command_bitmap_linear_win(nuint x, nuint y, PixelGrid* pixel_grid, CompressionCode compression_code); - /// Deallocates a `Command`. # Safety The caller has to make sure that: - `this` points to a valid `Command` - `this` is not used concurrently or after this call - `this` was not passed to another consuming function, e.g. to create a `Packet` + /// + /// Deallocates a `Command`. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid `Command` + /// - `this` is not used concurrently or after this call + /// - `this` was not passed to another consuming function, e.g. to create a `Packet` + /// [DllImport(__DllName, EntryPoint = "sp_command_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void sp_command_dealloc(Command* ptr); - /// Creates a new instance of `Connection`. returns: NULL if connection fails, or connected instance # Panics Bad string encoding # 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_connection_dealloc`. + /// + /// Creates a new instance of `Connection`. + /// + /// returns: NULL if connection fails, or connected instance + /// + /// # Panics + /// + /// Bad string encoding + /// + /// # 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_connection_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_connection_open", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Connection* sp_connection_open(byte* host); - /// Sends a `Packet` to the display using the `Connection`. The passed `Packet` gets consumed. returns: true in case of success # Safety The caller has to make sure that: - `connection` points to a valid instance of `Connection` - `packet` points to a valid instance of `Packet` - `packet` is not used concurrently or after this call + /// + /// Sends a `Packet` to the display using the `Connection`. + /// The passed `Packet` gets consumed. + /// + /// returns: true in case of success + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `connection` points to a valid instance of `Connection` + /// - `packet` points to a valid instance of `Packet` + /// - `packet` is not used concurrently or after this call + /// [DllImport(__DllName, EntryPoint = "sp_connection_send", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool sp_connection_send(Connection* connection, Packet* packet); - /// Closes and deallocates a `Connection`. # Safety The caller has to make sure that: - `this` points to a valid `Connection` - `this` is not used concurrently or after this call + /// + /// Closes and deallocates a `Connection`. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid `Connection` + /// - `this` is not used concurrently or after this call + /// [DllImport(__DllName, EntryPoint = "sp_connection_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void sp_connection_dealloc(Connection* ptr); - /// Creates a new `PixelGrid` with the specified dimensions. # Arguments * `width`: size in pixels in x-direction * `height`: size in pixels in y-direction returns: `PixelGrid` initialized to all pixels off # Panics - when the width is not dividable by 8 # 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_pixel_grid_dealloc`. + /// + /// Creates a new `PixelGrid` with the specified dimensions. + /// + /// # Arguments + /// + /// - `width`: size in pixels in x-direction + /// - `height`: size in pixels in y-direction + /// + /// returns: `PixelGrid` initialized to all pixels off + /// + /// # Panics + /// + /// - when the width is not dividable by 8 + /// + /// # 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_pixel_grid_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_pixel_grid_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern PixelGrid* sp_pixel_grid_new(nuint width, nuint height); - /// Loads a `PixelGrid` with the specified dimensions from the provided data. # Arguments * `width`: size in pixels in x-direction * `height`: size in pixels in y-direction returns: `PixelGrid` that contains a copy of the provided data # Panics - when the dimensions and data size do not match exactly. - when the width is not dividable by 8 # 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_pixel_grid_dealloc`. + /// + /// Loads a `PixelGrid` with the specified dimensions from the provided data. + /// + /// # Arguments + /// + /// - `width`: size in pixels in x-direction + /// - `height`: size in pixels in y-direction + /// + /// returns: `PixelGrid` that contains a copy of the provided data + /// + /// # Panics + /// + /// - when the dimensions and data size do not match exactly. + /// - when the width is not dividable by 8 + /// + /// # 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_pixel_grid_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_pixel_grid_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern PixelGrid* sp_pixel_grid_load(nuint width, nuint height, byte* data, nuint data_length); - /// Clones a `PixelGrid`. # Safety The caller has to make sure that: - `this` points to a valid `PixelGrid` - `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_pixel_grid_dealloc`. + /// + /// Clones a `PixelGrid`. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid `PixelGrid` + /// - `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_pixel_grid_dealloc`. + /// [DllImport(__DllName, EntryPoint = "sp_pixel_grid_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern PixelGrid* sp_pixel_grid_clone(PixelGrid* @this); - /// Deallocates a `PixelGrid`. # Safety The caller has to make sure that: - `this` points to a valid `PixelGrid` - `this` is not used concurrently or after this call - `this` was not passed to another consuming function, e.g. to create a `Command` + /// + /// Deallocates a `PixelGrid`. + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid `PixelGrid` + /// - `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_pixel_grid_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void sp_pixel_grid_dealloc(PixelGrid* @this); - /// Gets the current value at the specified position in the `PixelGrid`. # 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 `PixelGrid` - `this` is not written to concurrently + /// + /// Gets the current value at the specified position in the `PixelGrid`. + /// + /// # 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 `PixelGrid` + /// - `this` is not written to concurrently + /// [DllImport(__DllName, EntryPoint = "sp_pixel_grid_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool sp_pixel_grid_get(PixelGrid* @this, nuint x, nuint y); - /// Sets the value of the specified position in the `PixelGrid`. # 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 `PixelGrid` - `this` is not written to or read from concurrently + /// + /// Sets the value of the specified position in the `PixelGrid`. + /// + /// # 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 `PixelGrid` + /// - `this` is not written to or read from concurrently + /// [DllImport(__DllName, EntryPoint = "sp_pixel_grid_set", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void sp_pixel_grid_set(PixelGrid* @this, nuint x, nuint y, [MarshalAs(UnmanagedType.U1)] bool value); - /// Sets the state of all pixels in the `PixelGrid`. # Arguments * `this`: instance to write to * `value`: the value to set all pixels to # Safety The caller has to make sure that: - `this` points to a valid `PixelGrid` - `this` is not written to or read from concurrently + /// + /// Sets the state of all pixels in the `PixelGrid`. + /// + /// # Arguments + /// + /// - `this`: instance to write to + /// - `value`: the value to set all pixels to + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid `PixelGrid` + /// - `this` is not written to or read from concurrently + /// [DllImport(__DllName, EntryPoint = "sp_pixel_grid_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void sp_pixel_grid_fill(PixelGrid* @this, [MarshalAs(UnmanagedType.U1)] bool value); - /// Gets the width in pixels of the `PixelGrid` instance. # Arguments * `this`: instance to read from # Safety The caller has to make sure that: - `this` points to a valid `PixelGrid` + /// + /// Gets the width in pixels of the `PixelGrid` instance. + /// + /// # Arguments + /// + /// - `this`: instance to read from + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid `PixelGrid` + /// [DllImport(__DllName, EntryPoint = "sp_pixel_grid_width", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern nuint sp_pixel_grid_width(PixelGrid* @this); - /// Gets the height in pixels of the `PixelGrid` instance. # Arguments * `this`: instance to read from # Safety The caller has to make sure that: - `this` points to a valid `PixelGrid` + /// + /// Gets the height in pixels of the `PixelGrid` instance. + /// + /// # Arguments + /// + /// - `this`: instance to read from + /// + /// # Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid `PixelGrid` + /// [DllImport(__DllName, EntryPoint = "sp_pixel_grid_height", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern nuint sp_pixel_grid_height(PixelGrid* @this); - /// Gets an unsafe reference to the data of the `PixelGrid` instance. ## Safety The caller has to make sure that: - `this` points to a valid `PixelGrid` - the returned memory range is never accessed after the passed `PixelGrid` has been freed - the returned memory range is never accessed concurrently, either via the `PixelGrid` or directly + /// + /// Gets an unsafe reference to the data of the `PixelGrid` instance. + /// + /// ## Safety + /// + /// The caller has to make sure that: + /// + /// - `this` points to a valid `PixelGrid` + /// - the returned memory range is never accessed after the passed `PixelGrid` has been freed + /// - the returned memory range is never accessed concurrently, either via the `PixelGrid` or directly + /// [DllImport(__DllName, EntryPoint = "sp_pixel_grid_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern CByteSlice 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`. + /// + /// 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`. + /// + /// 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); - /// 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 + /// + /// 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); @@ -304,22 +1094,6 @@ namespace ServicePoint.BindGen } - public enum Command - { - Clear, - Cp437Data, - BitmapLinearWin, - Brightness, - CharBrightness, - BitmapLinear, - BitmapLinearAnd, - BitmapLinearOr, - BitmapLinearXor, - HardReset, - FadeOut, - BitmapLegacy, - } - public enum CompressionCode : ushort { Uncompressed = 0,