move c_api into binding_c crate, update C# binding
This commit is contained in:
parent
edcad6fd03
commit
f759395393
40 changed files with 895 additions and 916 deletions
|
@ -8,8 +8,8 @@ readme = "../../README.md"
|
|||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
servicepoint = { path = "../servicepoint", features = ["c_api"] }
|
||||
|
||||
[build-dependencies]
|
||||
csbindgen = "1.8.0"
|
||||
|
||||
[dependencies]
|
||||
servicepoint_binding_c = { path = "../servicepoint_binding_c" }
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServicePoint", "src/ServicePoint.csproj", "{70EFFA3F-012A-4518-9627-466BEAE4252E}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServicePoint", "ServicePoint/ServicePoint.csproj", "{70EFFA3F-012A-4518-9627-466BEAE4252E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lang-cs", "../examples/lang_cs/lang_cs.csproj", "{DA3B8B6E-993A-47DA-844B-F92AF520FF59}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lang-cs", "../../examples/lang_cs/lang_cs.csproj", "{DA3B8B6E-993A-47DA-844B-F92AF520FF59}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
|
@ -12,218 +12,228 @@ namespace ServicePoint.BindGen
|
|||
{
|
||||
public static unsafe partial class NativeMethods
|
||||
{
|
||||
const string __DllName = "servicepoint";
|
||||
const string __DllName = "servicepoint_binding_c";
|
||||
|
||||
public const nuint TILE_SIZE = 8;
|
||||
public const nuint TILE_WIDTH = 56;
|
||||
public const nuint TILE_HEIGHT = 20;
|
||||
|
||||
|
||||
/// <summary>Creates a new `BitVec` instance. The returned instance has to be freed with `bit_vec_dealloc`.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_bit_vec_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern BitVec* sp2_bit_vec_new(nuint size);
|
||||
[DllImport(__DllName, EntryPoint = "sp_bit_vec_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern BitVec* sp_bit_vec_new(nuint size);
|
||||
|
||||
/// <summary>Loads a `BitVec` from the provided data. The returned instance has to be freed with `bit_vec_dealloc`.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_bit_vec_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern BitVec* sp2_bit_vec_load(byte* data, nuint data_length);
|
||||
[DllImport(__DllName, EntryPoint = "sp_bit_vec_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern BitVec* sp_bit_vec_load(byte* data, nuint data_length);
|
||||
|
||||
/// <summary>Clones a `BitVec`. The returned instance has to be freed with `bit_vec_dealloc`.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_bit_vec_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern BitVec* sp2_bit_vec_clone(BitVec* @this);
|
||||
[DllImport(__DllName, EntryPoint = "sp_bit_vec_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern BitVec* sp_bit_vec_clone(BitVec* @this);
|
||||
|
||||
/// <summary>Deallocates a `BitVec`. Note: do not call this if the grid has been consumed in another way, e.g. to create a command.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_bit_vec_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern void sp2_bit_vec_dealloc(BitVec* @this);
|
||||
[DllImport(__DllName, EntryPoint = "sp_bit_vec_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern void sp_bit_vec_dealloc(BitVec* @this);
|
||||
|
||||
/// <summary>Gets the value of a bit from the `BitVec`.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_bit_vec_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
[DllImport(__DllName, EntryPoint = "sp_bit_vec_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.U1)]
|
||||
public static extern bool sp2_bit_vec_get(BitVec* @this, nuint index);
|
||||
public static extern bool sp_bit_vec_get(BitVec* @this, nuint index);
|
||||
|
||||
/// <summary>Sets the value of a bit in the `BitVec`.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_bit_vec_set", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
[DllImport(__DllName, EntryPoint = "sp_bit_vec_set", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.U1)]
|
||||
public static extern bool sp2_bit_vec_set(BitVec* @this, nuint index, [MarshalAs(UnmanagedType.U1)] bool value);
|
||||
public static extern bool sp_bit_vec_set(BitVec* @this, nuint index, [MarshalAs(UnmanagedType.U1)] bool value);
|
||||
|
||||
/// <summary>Sets the value of all bits in the `BitVec`.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_bit_vec_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern void sp2_bit_vec_fill(BitVec* @this, [MarshalAs(UnmanagedType.U1)] bool value);
|
||||
[DllImport(__DllName, EntryPoint = "sp_bit_vec_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern void sp_bit_vec_fill(BitVec* @this, [MarshalAs(UnmanagedType.U1)] bool value);
|
||||
|
||||
/// <summary>Gets the length of the `BitVec` in bits.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_bit_vec_len", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern nuint sp2_bit_vec_len(BitVec* @this);
|
||||
[DllImport(__DllName, EntryPoint = "sp_bit_vec_len", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern nuint sp_bit_vec_len(BitVec* @this);
|
||||
|
||||
/// <summary>Returns true if length is 0.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_bit_vec_is_empty", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
[DllImport(__DllName, EntryPoint = "sp_bit_vec_is_empty", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.U1)]
|
||||
public static extern bool sp2_bit_vec_is_empty(BitVec* @this);
|
||||
public static extern bool sp_bit_vec_is_empty(BitVec* @this);
|
||||
|
||||
/// <summary>Gets an unsafe reference to the data of the `BitVec` instance. ## Safety The caller has to make sure to never access the returned memory after the `BitVec` instance has been consumed or manually deallocated. Reading and writing concurrently to either the original instance or the returned data will result in undefined behavior.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_bit_vec_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern CByteSlice sp2_bit_vec_unsafe_data_ref(BitVec* @this);
|
||||
[DllImport(__DllName, EntryPoint = "sp_bit_vec_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern CByteSlice sp_bit_vec_unsafe_data_ref(BitVec* @this);
|
||||
|
||||
/// <summary>Creates a new `ByteGrid` instance. The returned instance has to be freed with `byte_grid_dealloc`.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_byte_grid_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern ByteGrid* sp2_byte_grid_new(nuint width, nuint height);
|
||||
[DllImport(__DllName, EntryPoint = "sp_byte_grid_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern ByteGrid* sp_byte_grid_new(nuint width, nuint height);
|
||||
|
||||
/// <summary>Loads a `ByteGrid` with the specified dimensions from the provided data. The returned instance has to be freed with `byte_grid_dealloc`.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_byte_grid_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern ByteGrid* sp2_byte_grid_load(nuint width, nuint height, byte* data, nuint data_length);
|
||||
[DllImport(__DllName, EntryPoint = "sp_byte_grid_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern ByteGrid* sp_byte_grid_load(nuint width, nuint height, byte* data, nuint data_length);
|
||||
|
||||
/// <summary>Clones a `ByteGrid`. The returned instance has to be freed with `byte_grid_dealloc`.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_byte_grid_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern ByteGrid* sp2_byte_grid_clone(ByteGrid* @this);
|
||||
[DllImport(__DllName, EntryPoint = "sp_byte_grid_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern ByteGrid* sp_byte_grid_clone(ByteGrid* @this);
|
||||
|
||||
/// <summary>Deallocates a `ByteGrid`. Note: do not call this if the grid has been consumed in another way, e.g. to create a command.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_byte_grid_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern void sp2_byte_grid_dealloc(ByteGrid* @this);
|
||||
[DllImport(__DllName, EntryPoint = "sp_byte_grid_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern void sp_byte_grid_dealloc(ByteGrid* @this);
|
||||
|
||||
/// <summary>Get the current value at the specified position</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_byte_grid_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern byte sp2_byte_grid_get(ByteGrid* @this, nuint x, nuint y);
|
||||
[DllImport(__DllName, EntryPoint = "sp_byte_grid_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern byte sp_byte_grid_get(ByteGrid* @this, nuint x, nuint y);
|
||||
|
||||
/// <summary>Sets the current value at the specified position</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_byte_grid_set", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern void sp2_byte_grid_set(ByteGrid* @this, nuint x, nuint y, byte value);
|
||||
[DllImport(__DllName, EntryPoint = "sp_byte_grid_set", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern void sp_byte_grid_set(ByteGrid* @this, nuint x, nuint y, byte value);
|
||||
|
||||
/// <summary>Fills the whole `ByteGrid` with the specified value</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_byte_grid_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern void sp2_byte_grid_fill(ByteGrid* @this, byte value);
|
||||
[DllImport(__DllName, EntryPoint = "sp_byte_grid_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern void sp_byte_grid_fill(ByteGrid* @this, byte value);
|
||||
|
||||
/// <summary>Gets the width in pixels of the `ByteGrid` instance.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_byte_grid_width", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern nuint sp2_byte_grid_width(ByteGrid* @this);
|
||||
[DllImport(__DllName, EntryPoint = "sp_byte_grid_width", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern nuint sp_byte_grid_width(ByteGrid* @this);
|
||||
|
||||
/// <summary>Gets the height in pixels of the `ByteGrid` instance.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_byte_grid_height", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern nuint sp2_byte_grid_height(ByteGrid* @this);
|
||||
[DllImport(__DllName, EntryPoint = "sp_byte_grid_height", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern nuint sp_byte_grid_height(ByteGrid* @this);
|
||||
|
||||
/// <summary>Gets an unsafe reference to the data of the `ByteGrid` instance. ## Safety The caller has to make sure to never access the returned memory after the `ByteGrid` instance has been consumed or manually deallocated. Reading and writing concurrently to either the original instance or the returned data will result in undefined behavior.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_byte_grid_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern CByteSlice sp2_byte_grid_unsafe_data_ref(ByteGrid* @this);
|
||||
[DllImport(__DllName, EntryPoint = "sp_byte_grid_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern CByteSlice sp_byte_grid_unsafe_data_ref(ByteGrid* @this);
|
||||
|
||||
/// <summary>Tries to turn a `Packet` into a `Command`. The packet is gets deallocated in the process. Returns: pointer to command or NULL</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_command_try_from_packet", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp2_command_try_from_packet(Packet* packet);
|
||||
[DllImport(__DllName, EntryPoint = "sp_command_try_from_packet", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp_command_try_from_packet(Packet* packet);
|
||||
|
||||
/// <summary>Clones a `Command` instance</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_command_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp2_command_clone(Command* original);
|
||||
[DllImport(__DllName, EntryPoint = "sp_command_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp_command_clone(Command* original);
|
||||
|
||||
/// <summary>Allocates a new `Command::Clear` instance</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_command_clear", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp2_command_clear();
|
||||
[DllImport(__DllName, EntryPoint = "sp_command_clear", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp_command_clear();
|
||||
|
||||
/// <summary>Allocates a new `Command::HardReset` instance</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_command_hard_reset", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp2_command_hard_reset();
|
||||
[DllImport(__DllName, EntryPoint = "sp_command_hard_reset", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp_command_hard_reset();
|
||||
|
||||
/// <summary>Allocates a new `Command::FadeOut` instance</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_command_fade_out", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp2_command_fade_out();
|
||||
[DllImport(__DllName, EntryPoint = "sp_command_fade_out", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp_command_fade_out();
|
||||
|
||||
/// <summary>Allocates a new `Command::Brightness` instance</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_command_brightness", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp2_command_brightness(byte brightness);
|
||||
[DllImport(__DllName, EntryPoint = "sp_command_brightness", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp_command_brightness(byte brightness);
|
||||
|
||||
/// <summary>Allocates a new `Command::CharBrightness` instance. The passed `ByteGrid` gets deallocated in the process.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_command_char_brightness", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp2_command_char_brightness(nuint x, nuint y, ByteGrid* byte_grid);
|
||||
[DllImport(__DllName, EntryPoint = "sp_command_char_brightness", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp_command_char_brightness(nuint x, nuint y, ByteGrid* byte_grid);
|
||||
|
||||
/// <summary>Allocates a new `Command::BitmapLinear` instance. The passed `BitVec` gets deallocated in the process.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_command_bitmap_linear", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp2_command_bitmap_linear(nuint offset, BitVec* bit_vec, CompressionCode compression);
|
||||
[DllImport(__DllName, EntryPoint = "sp_command_bitmap_linear", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp_command_bitmap_linear(nuint offset, BitVec* bit_vec, CompressionCode compression);
|
||||
|
||||
/// <summary>Allocates a new `Command::BitmapLinearAnd` instance. The passed `BitVec` gets deallocated in the process.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_command_bitmap_linear_and", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp2_command_bitmap_linear_and(nuint offset, BitVec* bit_vec, CompressionCode compression);
|
||||
[DllImport(__DllName, EntryPoint = "sp_command_bitmap_linear_and", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp_command_bitmap_linear_and(nuint offset, BitVec* bit_vec, CompressionCode compression);
|
||||
|
||||
/// <summary>Allocates a new `Command::BitmapLinearOr` instance. The passed `BitVec` gets deallocated in the process.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_command_bitmap_linear_or", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp2_command_bitmap_linear_or(nuint offset, BitVec* bit_vec, CompressionCode compression);
|
||||
[DllImport(__DllName, EntryPoint = "sp_command_bitmap_linear_or", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp_command_bitmap_linear_or(nuint offset, BitVec* bit_vec, CompressionCode compression);
|
||||
|
||||
/// <summary>Allocates a new `Command::BitmapLinearXor` instance. The passed `BitVec` gets deallocated in the process.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_command_bitmap_linear_xor", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp2_command_bitmap_linear_xor(nuint offset, BitVec* bit_vec, CompressionCode compression);
|
||||
[DllImport(__DllName, EntryPoint = "sp_command_bitmap_linear_xor", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp_command_bitmap_linear_xor(nuint offset, BitVec* bit_vec, CompressionCode compression);
|
||||
|
||||
/// <summary>Allocates a new `Command::Cp437Data` instance. The passed `ByteGrid` gets deallocated in the process.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_command_cp437_data", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp2_command_cp437_data(nuint x, nuint y, ByteGrid* byte_grid);
|
||||
[DllImport(__DllName, EntryPoint = "sp_command_cp437_data", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp_command_cp437_data(nuint x, nuint y, ByteGrid* byte_grid);
|
||||
|
||||
/// <summary>Allocates a new `Command::BitmapLinearWin` instance. The passed `PixelGrid` gets deallocated in the process.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_command_bitmap_linear_win", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Command* sp2_command_bitmap_linear_win(nuint x, nuint y, PixelGrid* byte_grid, CompressionCode compression_code);
|
||||
[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* byte_grid, CompressionCode compression_code);
|
||||
|
||||
/// <summary>Deallocates a `Command`. Note that connection_send does this implicitly, so you only need to do this if you use the library for parsing commands.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_command_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern void sp2_command_dealloc(Command* ptr);
|
||||
[DllImport(__DllName, EntryPoint = "sp_command_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern void sp_command_dealloc(Command* ptr);
|
||||
|
||||
/// <summary>Creates a new instance of Connection. The returned instance has to be deallocated with `connection_dealloc`. returns: NULL if connection fails or connected instance Panics: bad string encoding</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_connection_open", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Connection* sp2_connection_open(byte* host);
|
||||
[DllImport(__DllName, EntryPoint = "sp_connection_open", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Connection* sp_connection_open(byte* host);
|
||||
|
||||
/// <summary>Sends the command instance. The instance is consumed / destroyed and cannot be used after this call.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_connection_send", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
[DllImport(__DllName, EntryPoint = "sp_connection_send", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.U1)]
|
||||
public static extern bool sp2_connection_send(Connection* connection, Packet* command_ptr);
|
||||
public static extern bool sp_connection_send(Connection* connection, Packet* command_ptr);
|
||||
|
||||
/// <summary>Closes and deallocates a connection instance</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_connection_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern void sp2_connection_dealloc(Connection* ptr);
|
||||
[DllImport(__DllName, EntryPoint = "sp_connection_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern void sp_connection_dealloc(Connection* ptr);
|
||||
|
||||
/// <summary>Creates a new `PixelGrid` instance. The returned instance has to be freed with `pixel_grid_dealloc`.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_pixel_grid_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern PixelGrid* sp2_pixel_grid_new(nuint width, nuint height);
|
||||
[DllImport(__DllName, EntryPoint = "sp_pixel_grid_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern PixelGrid* sp_pixel_grid_new(nuint width, nuint height);
|
||||
|
||||
/// <summary>Loads a `PixelGrid` with the specified dimensions from the provided data. The returned instance has to be freed with `pixel_grid_dealloc`.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_pixel_grid_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern PixelGrid* sp2_pixel_grid_load(nuint width, nuint height, byte* data, nuint data_length);
|
||||
[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);
|
||||
|
||||
/// <summary>Clones a `PixelGrid`. The returned instance has to be freed with `pixel_grid_dealloc`.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_pixel_grid_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern PixelGrid* sp2_pixel_grid_clone(PixelGrid* @this);
|
||||
[DllImport(__DllName, EntryPoint = "sp_pixel_grid_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern PixelGrid* sp_pixel_grid_clone(PixelGrid* @this);
|
||||
|
||||
/// <summary>Deallocates a `PixelGrid`. Note: do not call this if the grid has been consumed in another way, e.g. to create a command.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_pixel_grid_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern void sp2_pixel_grid_dealloc(PixelGrid* @this);
|
||||
[DllImport(__DllName, EntryPoint = "sp_pixel_grid_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern void sp_pixel_grid_dealloc(PixelGrid* @this);
|
||||
|
||||
/// <summary>Get the current value at the specified position</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_pixel_grid_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
[DllImport(__DllName, EntryPoint = "sp_pixel_grid_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.U1)]
|
||||
public static extern bool sp2_pixel_grid_get(PixelGrid* @this, nuint x, nuint y);
|
||||
public static extern bool sp_pixel_grid_get(PixelGrid* @this, nuint x, nuint y);
|
||||
|
||||
/// <summary>Sets the current value at the specified position</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_pixel_grid_set", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern void sp2_pixel_grid_set(PixelGrid* @this, nuint x, nuint y, [MarshalAs(UnmanagedType.U1)] bool value);
|
||||
[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);
|
||||
|
||||
/// <summary>Fills the whole `PixelGrid` with the specified value</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_pixel_grid_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern void sp2_pixel_grid_fill(PixelGrid* @this, [MarshalAs(UnmanagedType.U1)] bool value);
|
||||
[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);
|
||||
|
||||
/// <summary>Gets the width in pixels of the `PixelGrid` instance.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_pixel_grid_width", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern nuint sp2_pixel_grid_width(PixelGrid* @this);
|
||||
[DllImport(__DllName, EntryPoint = "sp_pixel_grid_width", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern nuint sp_pixel_grid_width(PixelGrid* @this);
|
||||
|
||||
/// <summary>Gets the height in pixels of the `PixelGrid` instance.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_pixel_grid_height", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern nuint sp2_pixel_grid_height(PixelGrid* @this);
|
||||
[DllImport(__DllName, EntryPoint = "sp_pixel_grid_height", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern nuint sp_pixel_grid_height(PixelGrid* @this);
|
||||
|
||||
/// <summary>Gets an unsafe reference to the data of the `PixelGrid` instance. ## Safety The caller has to make sure to never access the returned memory after the `PixelGrid` instance has been consumed or manually deallocated. Reading and writing concurrently to either the original instance or the returned data will result in undefined behavior.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_pixel_grid_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern CByteSlice sp2_pixel_grid_unsafe_data_ref(PixelGrid* @this);
|
||||
[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);
|
||||
|
||||
/// <summary>Turns a `Command` into a `Packet`. The command gets deallocated in the process.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_packet_from_command", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Packet* sp2_packet_from_command(Command* command);
|
||||
[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</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_packet_try_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern Packet* sp2_packet_try_load(byte* data, nuint length);
|
||||
[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>Deallocates a `Packet`. Note: do not call this if the instance has been consumed in another way, e.g. by sending it.</summary>
|
||||
[DllImport(__DllName, EntryPoint = "sp2_packet_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern void sp2_packet_dealloc(Packet* @this);
|
||||
[DllImport(__DllName, EntryPoint = "sp_packet_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
public static extern void sp_packet_dealloc(Packet* @this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public unsafe partial struct CByteSlice
|
||||
{
|
||||
public byte* start;
|
||||
public nuint length;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public unsafe partial struct BitVec
|
||||
{
|
||||
|
@ -244,13 +254,6 @@ namespace ServicePoint.BindGen
|
|||
{
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public unsafe partial struct CByteSlice
|
||||
{
|
||||
public byte* start;
|
||||
public nuint length;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public unsafe partial struct Packet
|
||||
{
|
|
@ -8,7 +8,7 @@ public sealed class BitVec : SpNativeInstance<BindGen.BitVec>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return new BitVec(NativeMethods.sp2_bit_vec_new((nuint)size));
|
||||
return new BitVec(NativeMethods.sp_bit_vec_new((nuint)size));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ public sealed class BitVec : SpNativeInstance<BindGen.BitVec>
|
|||
{
|
||||
fixed (byte* bytesPtr = bytes)
|
||||
{
|
||||
return new BitVec(NativeMethods.sp2_bit_vec_load(bytesPtr, (nuint)bytes.Length));
|
||||
return new BitVec(NativeMethods.sp_bit_vec_load(bytesPtr, (nuint)bytes.Length));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public sealed class BitVec : SpNativeInstance<BindGen.BitVec>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return new BitVec(NativeMethods.sp2_bit_vec_clone(Instance));
|
||||
return new BitVec(NativeMethods.sp_bit_vec_clone(Instance));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,14 +37,14 @@ public sealed class BitVec : SpNativeInstance<BindGen.BitVec>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return NativeMethods.sp2_bit_vec_get(Instance, (nuint)index);
|
||||
return NativeMethods.sp_bit_vec_get(Instance, (nuint)index);
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
NativeMethods.sp2_bit_vec_set(Instance, (nuint)index, value);
|
||||
NativeMethods.sp_bit_vec_set(Instance, (nuint)index, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public sealed class BitVec : SpNativeInstance<BindGen.BitVec>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
NativeMethods.sp2_bit_vec_fill(Instance, value);
|
||||
NativeMethods.sp_bit_vec_fill(Instance, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ public sealed class BitVec : SpNativeInstance<BindGen.BitVec>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return (int)NativeMethods.sp2_bit_vec_len(Instance);
|
||||
return (int)NativeMethods.sp_bit_vec_len(Instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public sealed class BitVec : SpNativeInstance<BindGen.BitVec>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
var slice = NativeMethods.sp2_bit_vec_unsafe_data_ref(Instance);
|
||||
var slice = NativeMethods.sp_bit_vec_unsafe_data_ref(Instance);
|
||||
return new Span<byte>(slice.start, (int)slice.length);
|
||||
}
|
||||
}
|
||||
|
@ -86,6 +86,6 @@ public sealed class BitVec : SpNativeInstance<BindGen.BitVec>
|
|||
|
||||
private protected override unsafe void Dealloc()
|
||||
{
|
||||
NativeMethods.sp2_bit_vec_dealloc(Instance);
|
||||
NativeMethods.sp_bit_vec_dealloc(Instance);
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ public sealed class ByteGrid : SpNativeInstance<BindGen.ByteGrid>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return new ByteGrid(NativeMethods.sp2_byte_grid_new((nuint)width, (nuint)height));
|
||||
return new ByteGrid(NativeMethods.sp_byte_grid_new((nuint)width, (nuint)height));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ public sealed class ByteGrid : SpNativeInstance<BindGen.ByteGrid>
|
|||
{
|
||||
fixed (byte* bytesPtr = bytes)
|
||||
{
|
||||
return new ByteGrid(NativeMethods.sp2_byte_grid_load((nuint)width, (nuint)height, bytesPtr,
|
||||
return new ByteGrid(NativeMethods.sp_byte_grid_load((nuint)width, (nuint)height, bytesPtr,
|
||||
(nuint)bytes.Length));
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public sealed class ByteGrid : SpNativeInstance<BindGen.ByteGrid>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return new ByteGrid(NativeMethods.sp2_byte_grid_clone(Instance));
|
||||
return new ByteGrid(NativeMethods.sp_byte_grid_clone(Instance));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,14 +39,14 @@ public sealed class ByteGrid : SpNativeInstance<BindGen.ByteGrid>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return NativeMethods.sp2_byte_grid_get(Instance, (nuint)x, (nuint)y);
|
||||
return NativeMethods.sp_byte_grid_get(Instance, (nuint)x, (nuint)y);
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
NativeMethods.sp2_byte_grid_set(Instance, (nuint)x, (nuint)y, value);
|
||||
NativeMethods.sp_byte_grid_set(Instance, (nuint)x, (nuint)y, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public sealed class ByteGrid : SpNativeInstance<BindGen.ByteGrid>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
NativeMethods.sp2_byte_grid_fill(Instance, value);
|
||||
NativeMethods.sp_byte_grid_fill(Instance, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ public sealed class ByteGrid : SpNativeInstance<BindGen.ByteGrid>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return (int)NativeMethods.sp2_byte_grid_width(Instance);
|
||||
return (int)NativeMethods.sp_byte_grid_width(Instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ public sealed class ByteGrid : SpNativeInstance<BindGen.ByteGrid>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return (int)NativeMethods.sp2_byte_grid_height(Instance);
|
||||
return (int)NativeMethods.sp_byte_grid_height(Instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public sealed class ByteGrid : SpNativeInstance<BindGen.ByteGrid>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
var slice = NativeMethods.sp2_byte_grid_unsafe_data_ref(Instance);
|
||||
var slice = NativeMethods.sp_byte_grid_unsafe_data_ref(Instance);
|
||||
return new Span<byte>(slice.start, (int)slice.length);
|
||||
}
|
||||
}
|
||||
|
@ -129,6 +129,6 @@ public sealed class ByteGrid : SpNativeInstance<BindGen.ByteGrid>
|
|||
|
||||
private protected override unsafe void Dealloc()
|
||||
{
|
||||
NativeMethods.sp2_byte_grid_dealloc(Instance);
|
||||
NativeMethods.sp_byte_grid_dealloc(Instance);
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ public sealed class Command : SpNativeInstance<BindGen.Command>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
var result = NativeMethods.sp2_command_try_from_packet(packet.Into());
|
||||
var result = NativeMethods.sp_command_try_from_packet(packet.Into());
|
||||
if (result == null)
|
||||
{
|
||||
command = null;
|
||||
|
@ -25,7 +25,7 @@ public sealed class Command : SpNativeInstance<BindGen.Command>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return new Command(NativeMethods.sp2_command_clone(Instance));
|
||||
return new Command(NativeMethods.sp_command_clone(Instance));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public sealed class Command : SpNativeInstance<BindGen.Command>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return new Command(NativeMethods.sp2_command_clear());
|
||||
return new Command(NativeMethods.sp_command_clear());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public sealed class Command : SpNativeInstance<BindGen.Command>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return new Command(NativeMethods.sp2_command_hard_reset());
|
||||
return new Command(NativeMethods.sp_command_hard_reset());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public sealed class Command : SpNativeInstance<BindGen.Command>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return new Command(NativeMethods.sp2_command_fade_out());
|
||||
return new Command(NativeMethods.sp_command_fade_out());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ public sealed class Command : SpNativeInstance<BindGen.Command>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return new Command(NativeMethods.sp2_command_brightness(brightness));
|
||||
return new Command(NativeMethods.sp_command_brightness(brightness));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ public sealed class Command : SpNativeInstance<BindGen.Command>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return new Command(NativeMethods.sp2_command_char_brightness((ushort)x, (ushort)y, grid.Into()));
|
||||
return new Command(NativeMethods.sp_command_char_brightness((ushort)x, (ushort)y, grid.Into()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ public sealed class Command : SpNativeInstance<BindGen.Command>
|
|||
unsafe
|
||||
{
|
||||
return new Command(
|
||||
NativeMethods.sp2_command_bitmap_linear((ushort)offset, bitVec.Into(), compressionCode));
|
||||
NativeMethods.sp_command_bitmap_linear((ushort)offset, bitVec.Into(), compressionCode));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ public sealed class Command : SpNativeInstance<BindGen.Command>
|
|||
unsafe
|
||||
{
|
||||
return new Command(
|
||||
NativeMethods.sp2_command_bitmap_linear_and((ushort)offset, bitVec.Into(), compressionCode));
|
||||
NativeMethods.sp_command_bitmap_linear_and((ushort)offset, bitVec.Into(), compressionCode));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ public sealed class Command : SpNativeInstance<BindGen.Command>
|
|||
unsafe
|
||||
{
|
||||
return new Command(
|
||||
NativeMethods.sp2_command_bitmap_linear_or((ushort)offset, bitVec.Into(), compressionCode));
|
||||
NativeMethods.sp_command_bitmap_linear_or((ushort)offset, bitVec.Into(), compressionCode));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ public sealed class Command : SpNativeInstance<BindGen.Command>
|
|||
unsafe
|
||||
{
|
||||
return new Command(
|
||||
NativeMethods.sp2_command_bitmap_linear_xor((ushort)offset, bitVec.Into(), compressionCode));
|
||||
NativeMethods.sp_command_bitmap_linear_xor((ushort)offset, bitVec.Into(), compressionCode));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ public sealed class Command : SpNativeInstance<BindGen.Command>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return new Command(NativeMethods.sp2_command_bitmap_linear_win((ushort)x, (ushort)y, pixelGrid.Into(), compression));
|
||||
return new Command(NativeMethods.sp_command_bitmap_linear_win((ushort)x, (ushort)y, pixelGrid.Into(), compression));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ public sealed class Command : SpNativeInstance<BindGen.Command>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return new Command(NativeMethods.sp2_command_cp437_data((ushort)x, (ushort)y, byteGrid.Into()));
|
||||
return new Command(NativeMethods.sp_command_cp437_data((ushort)x, (ushort)y, byteGrid.Into()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,6 +127,6 @@ public sealed class Command : SpNativeInstance<BindGen.Command>
|
|||
|
||||
private protected override unsafe void Dealloc()
|
||||
{
|
||||
NativeMethods.sp2_command_dealloc(Instance);
|
||||
NativeMethods.sp_command_dealloc(Instance);
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ public sealed class Connection : SpNativeInstance<BindGen.Connection>
|
|||
{
|
||||
fixed (byte* bytePtr = Encoding.UTF8.GetBytes(host))
|
||||
{
|
||||
return new Connection(NativeMethods.sp2_connection_open(bytePtr));
|
||||
return new Connection(NativeMethods.sp_connection_open(bytePtr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,13 +20,13 @@ public sealed class Connection : SpNativeInstance<BindGen.Connection>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return NativeMethods.sp2_connection_send(Instance, packet.Into());
|
||||
return NativeMethods.sp_connection_send(Instance, packet.Into());
|
||||
}
|
||||
}
|
||||
|
||||
private protected override unsafe void Dealloc()
|
||||
{
|
||||
NativeMethods.sp2_connection_dealloc(Instance);
|
||||
NativeMethods.sp_connection_dealloc(Instance);
|
||||
}
|
||||
|
||||
private unsafe Connection(BindGen.Connection* instance) : base(instance)
|
|
@ -9,7 +9,7 @@ public sealed class Packet : SpNativeInstance<BindGen.Packet>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return new Packet(NativeMethods.sp2_packet_from_command(command.Into()));
|
||||
return new Packet(NativeMethods.sp_packet_from_command(command.Into()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ public sealed class Packet : SpNativeInstance<BindGen.Packet>
|
|||
{
|
||||
fixed (byte* bytesPtr = bytes)
|
||||
{
|
||||
var instance = NativeMethods.sp2_packet_try_load(bytesPtr, (nuint)bytes.Length);
|
||||
var instance = NativeMethods.sp_packet_try_load(bytesPtr, (nuint)bytes.Length);
|
||||
packet = instance == null
|
||||
? null
|
||||
: new Packet(instance);
|
||||
|
@ -34,6 +34,6 @@ public sealed class Packet : SpNativeInstance<BindGen.Packet>
|
|||
|
||||
private protected override unsafe void Dealloc()
|
||||
{
|
||||
NativeMethods.sp2_packet_dealloc(Instance);
|
||||
NativeMethods.sp_packet_dealloc(Instance);
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ public sealed class PixelGrid : SpNativeInstance<BindGen.PixelGrid>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return new PixelGrid(NativeMethods.sp2_pixel_grid_new((nuint)width, (nuint)height));
|
||||
return new PixelGrid(NativeMethods.sp_pixel_grid_new((nuint)width, (nuint)height));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ public sealed class PixelGrid : SpNativeInstance<BindGen.PixelGrid>
|
|||
{
|
||||
fixed (byte* bytesPtr = bytes)
|
||||
{
|
||||
return new PixelGrid(NativeMethods.sp2_pixel_grid_load((nuint)width, (nuint)height, bytesPtr,
|
||||
return new PixelGrid(NativeMethods.sp_pixel_grid_load((nuint)width, (nuint)height, bytesPtr,
|
||||
(nuint)bytes.Length));
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public sealed class PixelGrid : SpNativeInstance<BindGen.PixelGrid>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return new PixelGrid(NativeMethods.sp2_pixel_grid_clone(Instance));
|
||||
return new PixelGrid(NativeMethods.sp_pixel_grid_clone(Instance));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,14 +38,14 @@ public sealed class PixelGrid : SpNativeInstance<BindGen.PixelGrid>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return NativeMethods.sp2_pixel_grid_get(Instance, (nuint)x, (nuint)y);
|
||||
return NativeMethods.sp_pixel_grid_get(Instance, (nuint)x, (nuint)y);
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
NativeMethods.sp2_pixel_grid_set(Instance, (nuint)x, (nuint)y, value);
|
||||
NativeMethods.sp_pixel_grid_set(Instance, (nuint)x, (nuint)y, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public sealed class PixelGrid : SpNativeInstance<BindGen.PixelGrid>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
NativeMethods.sp2_pixel_grid_fill(Instance, value);
|
||||
NativeMethods.sp_pixel_grid_fill(Instance, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public sealed class PixelGrid : SpNativeInstance<BindGen.PixelGrid>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return (int)NativeMethods.sp2_pixel_grid_width(Instance);
|
||||
return (int)NativeMethods.sp_pixel_grid_width(Instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public sealed class PixelGrid : SpNativeInstance<BindGen.PixelGrid>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
return (int)NativeMethods.sp2_pixel_grid_height(Instance);
|
||||
return (int)NativeMethods.sp_pixel_grid_height(Instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ public sealed class PixelGrid : SpNativeInstance<BindGen.PixelGrid>
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
var slice = NativeMethods.sp2_pixel_grid_unsafe_data_ref(Instance);
|
||||
var slice = NativeMethods.sp_pixel_grid_unsafe_data_ref(Instance);
|
||||
return new Span<byte>(slice.start, (int)slice.length);
|
||||
}
|
||||
}
|
||||
|
@ -98,6 +98,6 @@ public sealed class PixelGrid : SpNativeInstance<BindGen.PixelGrid>
|
|||
|
||||
private protected override unsafe void Dealloc()
|
||||
{
|
||||
NativeMethods.sp2_pixel_grid_dealloc(Instance);
|
||||
NativeMethods.sp_pixel_grid_dealloc(Instance);
|
||||
}
|
||||
}
|
|
@ -26,45 +26,39 @@
|
|||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="BuildLibrary" Condition="'$(Configuration)'=='Release'" BeforeTargets="Build">
|
||||
<Exec Command="cargo build --manifest-path ../../servicepoint/Cargo.toml --all-features --release"/>
|
||||
</Target>
|
||||
|
||||
<Target Name="BuildLibrary" Condition="'$(Configuration)'=='Debug'" BeforeTargets="Build">
|
||||
<Exec Command="cargo build --manifest-path ../../servicepoint/Cargo.toml --all-features"/>
|
||||
</Target>
|
||||
|
||||
<!-- generate C# bindings -->
|
||||
<Target Name="BuildBindings" Condition="'$(Configuration)'=='Release'" BeforeTargets="Build">
|
||||
<Exec Command="cargo build --release"/>
|
||||
</Target>
|
||||
|
||||
<Target Name="BuildBindings" Condition="'$(Configuration)'=='Debug'" BeforeTargets="Build">
|
||||
<Exec Command="cargo build"/>
|
||||
</Target>
|
||||
|
||||
<!-- build native library to include in output -->
|
||||
<Target Name="BuildLibrary" Condition="'$(Configuration)'=='Release'" BeforeTargets="Build">
|
||||
<Exec Command="cargo build --manifest-path ../../../crates/servicepoint/Cargo.toml --release"/>
|
||||
</Target>
|
||||
<Target Name="BuildLibrary" Condition="'$(Configuration)'=='Debug'" BeforeTargets="Build">
|
||||
<Exec Command="cargo build --manifest-path ../../../crates/servicepoint/Cargo.toml"/>
|
||||
</Target>
|
||||
|
||||
<!-- include native binary in output -->
|
||||
<ItemGroup Condition="'$(Configuration)'=='Debug'">
|
||||
<Content Include="../../target/debug/libservicepoint.so" CopyToOutputDirectory="Always">
|
||||
<Link>libservicepoint.so</Link>
|
||||
<Content Include="../../../target/debug/libservicepoint_binding_c.so" CopyToOutputDirectory="Always">
|
||||
<Link>libservicepoint_binding_c.so</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)'=='Release'">
|
||||
<Content Include="../../target/release/libservicepoint.so" CopyToOutputDirectory="Always">
|
||||
<Link>libservicepoint.so</Link>
|
||||
<Content Include="../../../target/release/libservicepoint_binding_c.so" CopyToOutputDirectory="Always">
|
||||
<Link>libservicepoint_binding_c.so</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- include link to source code at revision -->
|
||||
<None Include="../../README.md" Pack="true" PackagePath="\"/>
|
||||
<None Include="../../../README.md" Pack="true" PackagePath="\"/>
|
||||
<!-- add README.md to package -->
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\build.rs">
|
||||
<Link>build.rs</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -1,19 +1,28 @@
|
|||
fn main() {
|
||||
println!("cargo:rerun-if-changed=DOESNOTEXIST"); // rebuild every time
|
||||
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/byte_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/c_slice.rs")
|
||||
.input_extern_file("../servicepoint_binding_c/src/packet.rs")
|
||||
.input_extern_file("../servicepoint/src/bit_vec.rs")
|
||||
.input_extern_file("../servicepoint/src/byte_grid.rs")
|
||||
.input_extern_file("../servicepoint/src/command.rs")
|
||||
.input_extern_file("../servicepoint/src/compression_code.rs")
|
||||
.input_extern_file("../servicepoint/src/connection.rs")
|
||||
.input_extern_file("../servicepoint/src/pixel_grid.rs")
|
||||
.input_extern_file("../servicepoint/src/lib.rs")
|
||||
.input_extern_file("../servicepoint/src/c_slice.rs")
|
||||
.input_extern_file("../servicepoint/src/packet.rs")
|
||||
.csharp_dll_name("servicepoint")
|
||||
.input_extern_file("../servicepoint/src/compression_code.rs")
|
||||
.csharp_dll_name("servicepoint_binding_c")
|
||||
.csharp_namespace("ServicePoint.BindGen")
|
||||
.csharp_use_nint_types(true)
|
||||
.csharp_class_accessibility("public")
|
||||
.generate_csharp_file("src/BindGen/ServicePoint.g.cs")
|
||||
.csharp_generate_const_filter(|_| true)
|
||||
.generate_csharp_file("ServicePoint/BindGen/ServicePoint.g.cs")
|
||||
.unwrap();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue