2024-10-16 21:59:35 +02:00
|
|
|
// <auto-generated>
|
|
|
|
// This code is generated by csbindgen.
|
|
|
|
// DON'T CHANGE THIS DIRECTLY.
|
|
|
|
// </auto-generated>
|
|
|
|
#pragma warning disable CS8500
|
|
|
|
#pragma warning disable CS8981
|
|
|
|
using System;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
2024-10-19 14:21:50 +02:00
|
|
|
namespace ServicePoint
|
2024-10-16 21:59:35 +02:00
|
|
|
{
|
2024-10-19 14:21:50 +02:00
|
|
|
|
|
|
|
public unsafe sealed partial class Cp437Grid: IDisposable
|
2024-10-16 21:59:35 +02:00
|
|
|
{
|
2024-10-19 14:21:50 +02:00
|
|
|
#nullable enable
|
2024-10-16 21:59:35 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Creates a new [SPCp437Grid] with the specified dimensions.
|
|
|
|
///
|
|
|
|
/// returns: [SPCp437Grid] initialized to 0. Will never return NULL.
|
|
|
|
///
|
|
|
|
/// # 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_free`.
|
|
|
|
/// </summary>
|
2024-10-19 14:35:03 +02:00
|
|
|
public Cp437Grid(nuint width, nuint height) : this(sp_cp437_grid_new(width, height)) {}
|
2024-10-16 21:59:35 +02:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Loads a [SPCp437Grid] with the specified dimensions from the provided data.
|
|
|
|
///
|
|
|
|
/// Will never return NULL.
|
|
|
|
///
|
|
|
|
/// # Panics
|
|
|
|
///
|
|
|
|
/// - when `data` is NULL
|
|
|
|
/// - when the provided `data_length` does not match `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_free`.
|
|
|
|
/// </summary>
|
2024-10-19 16:19:09 +02:00
|
|
|
[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
2024-10-19 14:35:03 +02:00
|
|
|
public static Cp437Grid Load(nuint width, nuint height, byte* data, nuint data_length)
|
|
|
|
{
|
|
|
|
return new Cp437Grid(Cp437Grid.sp_cp437_grid_load(width, height, data, data_length));
|
|
|
|
}
|
2024-10-16 21:59:35 +02:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Clones a [SPCp437Grid].
|
|
|
|
///
|
|
|
|
/// Will never return NULL.
|
|
|
|
///
|
|
|
|
/// # Panics
|
|
|
|
///
|
|
|
|
/// - when `cp437_grid` is NULL
|
|
|
|
///
|
|
|
|
/// # Safety
|
|
|
|
///
|
|
|
|
/// The caller has to make sure that:
|
|
|
|
///
|
|
|
|
/// - `cp437_grid` points to a valid [SPCp437Grid]
|
|
|
|
/// - `cp437_grid` 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_free`.
|
|
|
|
/// </summary>
|
2024-10-19 16:19:09 +02:00
|
|
|
[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
2024-10-19 14:35:03 +02:00
|
|
|
public Cp437Grid Clone()
|
|
|
|
{
|
2024-10-19 15:31:54 +02:00
|
|
|
return new Cp437Grid(Cp437Grid.sp_cp437_grid_clone(this.Instance));
|
2024-10-19 14:35:03 +02:00
|
|
|
}
|
2024-10-16 21:59:35 +02:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the current value at the specified position.
|
|
|
|
///
|
|
|
|
/// # Arguments
|
|
|
|
///
|
|
|
|
/// - `cp437_grid`: instance to read from
|
|
|
|
/// - `x` and `y`: position of the cell to read
|
|
|
|
///
|
|
|
|
/// # Panics
|
|
|
|
///
|
|
|
|
/// - when `cp437_grid` is NULL
|
|
|
|
/// - when accessing `x` or `y` out of bounds
|
|
|
|
///
|
|
|
|
/// # Safety
|
|
|
|
///
|
|
|
|
/// The caller has to make sure that:
|
|
|
|
///
|
|
|
|
/// - `cp437_grid` points to a valid [SPCp437Grid]
|
|
|
|
/// - `cp437_grid` is not written to concurrently
|
|
|
|
/// </summary>
|
2024-10-19 16:19:09 +02:00
|
|
|
[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
2024-10-19 14:35:03 +02:00
|
|
|
public byte Get(nuint x, nuint y)
|
|
|
|
{
|
2024-10-19 15:31:54 +02:00
|
|
|
return Cp437Grid.sp_cp437_grid_get(this.Instance, x, y);
|
2024-10-19 14:35:03 +02:00
|
|
|
}
|
2024-10-16 21:59:35 +02:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sets the value of the specified position in the [SPCp437Grid].
|
|
|
|
///
|
|
|
|
/// # Arguments
|
|
|
|
///
|
|
|
|
/// - `cp437_grid`: 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 `cp437_grid` is NULL
|
|
|
|
/// - when accessing `x` or `y` out of bounds
|
|
|
|
///
|
|
|
|
/// # Safety
|
|
|
|
///
|
|
|
|
/// The caller has to make sure that:
|
|
|
|
///
|
|
|
|
/// - `cp437_grid` points to a valid [SPBitVec]
|
|
|
|
/// - `cp437_grid` is not written to or read from concurrently
|
|
|
|
/// </summary>
|
2024-10-19 16:19:09 +02:00
|
|
|
[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
2024-10-19 14:35:03 +02:00
|
|
|
public void Set(nuint x, nuint y, byte value)
|
|
|
|
{
|
2024-10-19 15:31:54 +02:00
|
|
|
Cp437Grid.sp_cp437_grid_set(this.Instance, x, y, value);
|
2024-10-19 14:35:03 +02:00
|
|
|
}
|
2024-10-16 21:59:35 +02:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sets the value of all cells in the [SPCp437Grid].
|
|
|
|
///
|
|
|
|
/// # Arguments
|
|
|
|
///
|
|
|
|
/// - `cp437_grid`: instance to write to
|
|
|
|
/// - `value`: the value to set all cells to
|
|
|
|
///
|
|
|
|
/// # Panics
|
|
|
|
///
|
|
|
|
/// - when `cp437_grid` is NULL
|
|
|
|
///
|
|
|
|
/// # Safety
|
|
|
|
///
|
|
|
|
/// The caller has to make sure that:
|
|
|
|
///
|
|
|
|
/// - `cp437_grid` points to a valid [SPCp437Grid]
|
|
|
|
/// - `cp437_grid` is not written to or read from concurrently
|
|
|
|
/// </summary>
|
2024-10-19 16:19:09 +02:00
|
|
|
[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
2024-10-19 14:35:03 +02:00
|
|
|
public void Fill(byte value)
|
|
|
|
{
|
2024-10-19 15:31:54 +02:00
|
|
|
Cp437Grid.sp_cp437_grid_fill(this.Instance, value);
|
2024-10-19 14:35:03 +02:00
|
|
|
}
|
2024-10-16 21:59:35 +02:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the width of the [SPCp437Grid] instance.
|
|
|
|
///
|
|
|
|
/// # Arguments
|
|
|
|
///
|
|
|
|
/// - `cp437_grid`: instance to read from
|
|
|
|
///
|
|
|
|
/// # Panics
|
|
|
|
///
|
|
|
|
/// - when `cp437_grid` is NULL
|
|
|
|
///
|
|
|
|
/// # Safety
|
|
|
|
///
|
|
|
|
/// The caller has to make sure that:
|
|
|
|
///
|
|
|
|
/// - `cp437_grid` points to a valid [SPCp437Grid]
|
|
|
|
/// </summary>
|
2024-10-19 16:19:09 +02:00
|
|
|
[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
2024-10-19 14:35:03 +02:00
|
|
|
public nuint Width()
|
|
|
|
{
|
2024-10-19 15:31:54 +02:00
|
|
|
return Cp437Grid.sp_cp437_grid_width(this.Instance);
|
2024-10-19 14:35:03 +02:00
|
|
|
}
|
2024-10-16 21:59:35 +02:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the height of the [SPCp437Grid] instance.
|
|
|
|
///
|
|
|
|
/// # Arguments
|
|
|
|
///
|
|
|
|
/// - `cp437_grid`: instance to read from
|
|
|
|
///
|
|
|
|
/// # Panics
|
|
|
|
///
|
|
|
|
/// - when `cp437_grid` is NULL
|
|
|
|
///
|
|
|
|
/// # Safety
|
|
|
|
///
|
|
|
|
/// The caller has to make sure that:
|
|
|
|
///
|
|
|
|
/// - `cp437_grid` points to a valid [SPCp437Grid]
|
|
|
|
/// </summary>
|
2024-10-19 16:19:09 +02:00
|
|
|
[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
2024-10-19 14:35:03 +02:00
|
|
|
public nuint Height()
|
|
|
|
{
|
2024-10-19 15:31:54 +02:00
|
|
|
return Cp437Grid.sp_cp437_grid_height(this.Instance);
|
2024-10-19 14:35:03 +02:00
|
|
|
}
|
2024-10-16 21:59:35 +02:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets an unsafe reference to the data of the [SPCp437Grid] instance.
|
|
|
|
///
|
|
|
|
/// Will never return NULL.
|
|
|
|
///
|
|
|
|
/// # Panics
|
|
|
|
///
|
|
|
|
/// - when `cp437_grid` is NULL
|
|
|
|
///
|
|
|
|
/// ## Safety
|
|
|
|
///
|
|
|
|
/// The caller has to make sure that:
|
|
|
|
///
|
|
|
|
/// - `cp437_grid` points to a valid [SPCp437Grid]
|
|
|
|
/// - the returned memory range is never accessed after the passed [SPCp437Grid] has been freed
|
|
|
|
/// - the returned memory range is never accessed concurrently, either via the [SPCp437Grid] or directly
|
|
|
|
/// </summary>
|
2024-10-19 16:19:09 +02:00
|
|
|
[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
2024-10-19 14:35:03 +02:00
|
|
|
public SPByteSlice UnsafeDataRef()
|
|
|
|
{
|
2024-10-19 15:31:54 +02:00
|
|
|
return Cp437Grid.sp_cp437_grid_unsafe_data_ref(this.Instance);
|
2024-10-19 14:35:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-10-19 15:31:54 +02:00
|
|
|
#region internal machinery
|
2024-10-19 14:35:03 +02:00
|
|
|
private SPCp437Grid* _instance;
|
|
|
|
internal SPCp437Grid* Instance
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
if (_instance == null)
|
|
|
|
throw new NullReferenceException("instance is null");
|
|
|
|
return _instance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private Cp437Grid(SPCp437Grid* instance)
|
|
|
|
{
|
|
|
|
ArgumentNullException.ThrowIfNull(instance);
|
|
|
|
_instance = instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
internal SPCp437Grid* Into()
|
|
|
|
{
|
|
|
|
var instance = Instance;
|
|
|
|
_instance = null;
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Free()
|
|
|
|
{
|
|
|
|
if (_instance != null)
|
|
|
|
Cp437Grid.sp_cp437_grid_free(Into());
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
Free();
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
~Cp437Grid() => Free();
|
|
|
|
|
2024-10-19 15:31:54 +02:00
|
|
|
#endregion
|
|
|
|
|
2024-10-19 14:35:03 +02:00
|
|
|
#nullable restore
|
2024-10-19 15:31:54 +02:00
|
|
|
#region native methods
|
|
|
|
const string __DllName = "servicepoint_binding_c";
|
2024-10-19 14:35:03 +02:00
|
|
|
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
|
|
|
private static extern SPCp437Grid* sp_cp437_grid_new(nuint width, nuint height);
|
|
|
|
|
|
|
|
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
|
|
|
private static extern SPCp437Grid* sp_cp437_grid_load(nuint width, nuint height, byte* data, nuint data_length);
|
|
|
|
|
|
|
|
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
|
|
|
private static extern SPCp437Grid* sp_cp437_grid_clone(SPCp437Grid* cp437_grid);
|
|
|
|
|
|
|
|
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_free", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
|
|
|
private static extern void sp_cp437_grid_free(SPCp437Grid* cp437_grid);
|
|
|
|
|
|
|
|
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
|
|
|
private static extern byte sp_cp437_grid_get(SPCp437Grid* cp437_grid, nuint x, nuint y);
|
|
|
|
|
|
|
|
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_set", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
|
|
|
private static extern void sp_cp437_grid_set(SPCp437Grid* cp437_grid, nuint x, nuint y, byte value);
|
|
|
|
|
|
|
|
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
|
|
|
private static extern void sp_cp437_grid_fill(SPCp437Grid* cp437_grid, byte value);
|
|
|
|
|
|
|
|
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_width", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
|
|
|
private static extern nuint sp_cp437_grid_width(SPCp437Grid* cp437_grid);
|
|
|
|
|
|
|
|
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_height", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
|
|
|
private static extern nuint sp_cp437_grid_height(SPCp437Grid* cp437_grid);
|
|
|
|
|
2024-10-16 21:59:35 +02:00
|
|
|
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
2024-10-19 14:21:50 +02:00
|
|
|
private static extern SPByteSlice sp_cp437_grid_unsafe_data_ref(SPCp437Grid* cp437_grid);
|
2024-10-16 21:59:35 +02:00
|
|
|
|
|
|
|
|
2024-10-19 15:31:54 +02:00
|
|
|
#endregion
|
2024-10-16 21:59:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
2024-10-19 14:21:50 +02:00
|
|
|
public unsafe partial struct SPCp437Grid
|
2024-10-16 21:59:35 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|