diff --git a/crates/servicepoint_binding_cs/ServicePoint/BitVec.cs b/crates/servicepoint_binding_cs/ServicePoint/BitVec.cs index ab697e0..158b1a9 100644 --- a/crates/servicepoint_binding_cs/ServicePoint/BitVec.cs +++ b/crates/servicepoint_binding_cs/ServicePoint/BitVec.cs @@ -4,11 +4,11 @@ namespace ServicePoint; public sealed class BitVec : SpNativeInstance { - public static BitVec New(int size) + public static BitVec New(nuint size) { unsafe { - return new BitVec(NativeMethods.sp_bitvec_new((nuint)size)); + return new BitVec(NativeMethods.sp_bitvec_new(size)); } } @@ -31,20 +31,20 @@ public sealed class BitVec : SpNativeInstance } } - public bool this[int index] + public bool this[nuint index] { get { unsafe { - return NativeMethods.sp_bitvec_get(Instance, (nuint)index); + return NativeMethods.sp_bitvec_get(Instance, index); } } set { unsafe { - NativeMethods.sp_bitvec_set(Instance, (nuint)index, value); + NativeMethods.sp_bitvec_set(Instance, index, value); } } } @@ -57,13 +57,13 @@ public sealed class BitVec : SpNativeInstance } } - public int Length + public nuint Length { get { unsafe { - return (int)NativeMethods.sp_bitvec_len(Instance); + return NativeMethods.sp_bitvec_len(Instance); } } } diff --git a/crates/servicepoint_binding_cs/ServicePoint/Bitmap.cs b/crates/servicepoint_binding_cs/ServicePoint/Bitmap.cs index 6747483..cbef9d1 100644 --- a/crates/servicepoint_binding_cs/ServicePoint/Bitmap.cs +++ b/crates/servicepoint_binding_cs/ServicePoint/Bitmap.cs @@ -4,21 +4,21 @@ namespace ServicePoint; public sealed class Bitmap : SpNativeInstance { - public static Bitmap New(int width, int height) + public static Bitmap New(nuint width, nuint height) { unsafe { - return new Bitmap(NativeMethods.sp_bitmap_new((nuint)width, (nuint)height)); + return new Bitmap(NativeMethods.sp_bitmap_new(width, height)); } } - public static Bitmap Load(int width, int height, Span bytes) + public static Bitmap Load(nuint width, nuint height, Span bytes) { unsafe { fixed (byte* bytesPtr = bytes) { - return new Bitmap(NativeMethods.sp_bitmap_load((nuint)width, (nuint)height, bytesPtr, + return new Bitmap(NativeMethods.sp_bitmap_load(width, height, bytesPtr, (nuint)bytes.Length)); } } @@ -32,20 +32,20 @@ public sealed class Bitmap : SpNativeInstance } } - public bool this[int x, int y] + public bool this[nuint x, nuint y] { get { unsafe { - return NativeMethods.sp_bitmap_get(Instance, (nuint)x, (nuint)y); + return NativeMethods.sp_bitmap_get(Instance, x, y); } } set { unsafe { - NativeMethods.sp_bitmap_set(Instance, (nuint)x, (nuint)y, value); + NativeMethods.sp_bitmap_set(Instance, x, y, value); } } } @@ -58,24 +58,24 @@ public sealed class Bitmap : SpNativeInstance } } - public int Width + public nuint Width { get { unsafe { - return (int)NativeMethods.sp_bitmap_width(Instance); + return NativeMethods.sp_bitmap_width(Instance); } } } - public int Height + public nuint Height { get { unsafe { - return (int)NativeMethods.sp_bitmap_height(Instance); + return NativeMethods.sp_bitmap_height(Instance); } } } diff --git a/crates/servicepoint_binding_cs/ServicePoint/BrightnessGrid.cs b/crates/servicepoint_binding_cs/ServicePoint/BrightnessGrid.cs index 53970b5..f2a3262 100644 --- a/crates/servicepoint_binding_cs/ServicePoint/BrightnessGrid.cs +++ b/crates/servicepoint_binding_cs/ServicePoint/BrightnessGrid.cs @@ -4,21 +4,21 @@ namespace ServicePoint; public sealed class BrightnessGrid : SpNativeInstance { - public static BrightnessGrid New(int width, int height) + public static BrightnessGrid New(nuint width, nuint height) { unsafe { - return new BrightnessGrid(NativeMethods.sp_brightness_grid_new((nuint)width, (nuint)height)); + return new BrightnessGrid(NativeMethods.sp_brightness_grid_new(width, height)); } } - public static BrightnessGrid Load(int width, int height, Span bytes) + public static BrightnessGrid Load(nuint width, nuint height, Span bytes) { unsafe { fixed (byte* bytesPtr = bytes) { - return new BrightnessGrid(NativeMethods.sp_brightness_grid_load((nuint)width, (nuint)height, bytesPtr, + return new BrightnessGrid(NativeMethods.sp_brightness_grid_load(width, height, bytesPtr, (nuint)bytes.Length)); } } @@ -32,20 +32,20 @@ public sealed class BrightnessGrid : SpNativeInstance } } - public byte this[int x, int y] + public byte this[nuint x, nuint y] { get { unsafe { - return NativeMethods.sp_brightness_grid_get(Instance, (nuint)x, (nuint)y); + return NativeMethods.sp_brightness_grid_get(Instance, x, y); } } set { unsafe { - NativeMethods.sp_brightness_grid_set(Instance, (nuint)x, (nuint)y, value); + NativeMethods.sp_brightness_grid_set(Instance, x, y, value); } } } @@ -58,24 +58,24 @@ public sealed class BrightnessGrid : SpNativeInstance } } - public int Width + public nuint Width { get { unsafe { - return (int)NativeMethods.sp_brightness_grid_width(Instance); + return NativeMethods.sp_brightness_grid_width(Instance); } } } - public int Height + public nuint Height { get { unsafe { - return (int)NativeMethods.sp_brightness_grid_height(Instance); + return NativeMethods.sp_brightness_grid_height(Instance); } } } diff --git a/crates/servicepoint_binding_cs/ServicePoint/Command.cs b/crates/servicepoint_binding_cs/ServicePoint/Command.cs index b62d511..cf770cb 100644 --- a/crates/servicepoint_binding_cs/ServicePoint/Command.cs +++ b/crates/servicepoint_binding_cs/ServicePoint/Command.cs @@ -61,63 +61,63 @@ public sealed class Command : SpNativeInstance } } - public static Command CharBrightness(int x, int y, BrightnessGrid grid) + public static Command CharBrightness(ushort x, ushort y, BrightnessGrid grid) { unsafe { - return new Command(NativeMethods.sp_command_char_brightness((ushort)x, (ushort)y, grid.Into())); + return new Command(NativeMethods.sp_command_char_brightness(x, y, grid.Into())); } } - public static Command BitmapLinear(int offset, BitVec bitVec, CompressionCode compressionCode) + public static Command BitmapLinear(ushort offset, BitVec bitVec, CompressionCode compressionCode) { unsafe { return new Command( - NativeMethods.sp_command_bitmap_linear((ushort)offset, bitVec.Into(), compressionCode)); + NativeMethods.sp_command_bitmap_linear(offset, bitVec.Into(), compressionCode)); } } - public static Command BitmapLinearAnd(int offset, BitVec bitVec, CompressionCode compressionCode) + public static Command BitmapLinearAnd(ushort offset, BitVec bitVec, CompressionCode compressionCode) { unsafe { return new Command( - NativeMethods.sp_command_bitmap_linear_and((ushort)offset, bitVec.Into(), compressionCode)); + NativeMethods.sp_command_bitmap_linear_and(offset, bitVec.Into(), compressionCode)); } } - public static Command BitmapLinearOr(int offset, BitVec bitVec, CompressionCode compressionCode) + public static Command BitmapLinearOr(ushort offset, BitVec bitVec, CompressionCode compressionCode) { unsafe { return new Command( - NativeMethods.sp_command_bitmap_linear_or((ushort)offset, bitVec.Into(), compressionCode)); + NativeMethods.sp_command_bitmap_linear_or(offset, bitVec.Into(), compressionCode)); } } - public static Command BitmapLinearXor(int offset, BitVec bitVec, CompressionCode compressionCode) + public static Command BitmapLinearXor(ushort offset, BitVec bitVec, CompressionCode compressionCode) { unsafe { return new Command( - NativeMethods.sp_command_bitmap_linear_xor((ushort)offset, bitVec.Into(), compressionCode)); + NativeMethods.sp_command_bitmap_linear_xor(offset, bitVec.Into(), compressionCode)); } } - public static Command BitmapLinearWin(int x, int y, Bitmap bitmap, CompressionCode compression) + public static Command BitmapLinearWin(ushort x, ushort y, Bitmap bitmap, CompressionCode compression) { unsafe { - return new Command(NativeMethods.sp_command_bitmap_linear_win((ushort)x, (ushort)y, bitmap.Into(), compression)); + return new Command(NativeMethods.sp_command_bitmap_linear_win(x, y, bitmap.Into(), compression)); } } - public static Command Cp437Data(int x, int y, Cp437Grid byteGrid) + public static Command Cp437Data(ushort x, ushort y, Cp437Grid byteGrid) { unsafe { - return new Command(NativeMethods.sp_command_cp437_data((ushort)x, (ushort)y, byteGrid.Into())); + return new Command(NativeMethods.sp_command_cp437_data(x, y, byteGrid.Into())); } } diff --git a/crates/servicepoint_binding_cs/examples/lang_cs/Program.cs b/crates/servicepoint_binding_cs/examples/lang_cs/Program.cs index 89c0eef..a1ff7fe 100644 --- a/crates/servicepoint_binding_cs/examples/lang_cs/Program.cs +++ b/crates/servicepoint_binding_cs/examples/lang_cs/Program.cs @@ -8,11 +8,11 @@ connection.Send(Command.Brightness(128).IntoPacket()); using var pixels = Bitmap.New(Constants.PixelWidth, Constants.PixelHeight); -for (var offset = 0; offset < int.MaxValue; offset++) +for (nuint offset = 0; offset < nuint.MaxValue; offset++) { pixels.Fill(false); - for (var y = 0; y < pixels.Height; y++) + for (nuint y = 0; y < pixels.Height; y++) pixels[(y + offset) % Constants.PixelWidth, y] = true; connection.Send(Command.BitmapLinearWin(0, 0, pixels.Clone(), CompressionCode.Lzma).IntoPacket());