From 9553d9fe421b661a79e282b6c77bb9b78abe1a04 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Tue, 5 Nov 2024 22:39:10 +0100 Subject: [PATCH] add uniffi CP437Grid, equals add equals method add uniffi copy_raw method --- .../servicepoint_binding_uniffi.cs | 460 ++++++++++++++++++ .../servicepoint_binding_uniffi/src/bitmap.rs | 12 +- .../servicepoint_binding_uniffi/src/bitvec.rs | 10 + .../src/brightness_grid.rs | 12 +- .../src/command.rs | 17 + .../src/cp437_grid.rs | 76 +++ crates/servicepoint_binding_uniffi/src/lib.rs | 1 + 7 files changed, 586 insertions(+), 2 deletions(-) create mode 100644 crates/servicepoint_binding_uniffi/src/cp437_grid.rs diff --git a/crates/servicepoint_binding_uniffi/libraries/csharp/ServicePoint/servicepoint_binding_uniffi.cs b/crates/servicepoint_binding_uniffi/libraries/csharp/ServicePoint/servicepoint_binding_uniffi.cs index cd0eda5..2a7679c 100644 --- a/crates/servicepoint_binding_uniffi/libraries/csharp/ServicePoint/servicepoint_binding_uniffi.cs +++ b/crates/servicepoint_binding_uniffi/libraries/csharp/ServicePoint/servicepoint_binding_uniffi.cs @@ -445,6 +445,14 @@ static class _UniFFILib { public static extern BitVecSafeHandle uniffi_servicepoint_binding_uniffi_fn_constructor_bitvec_new(ulong @size,ref RustCallStatus _uniffi_out_err ); + [DllImport("servicepoint_binding_uniffi")] + public static extern RustBuffer uniffi_servicepoint_binding_uniffi_fn_method_bitvec_copy_raw(BitVecSafeHandle @ptr,ref RustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern sbyte uniffi_servicepoint_binding_uniffi_fn_method_bitvec_equals(BitVecSafeHandle @ptr,BitVecSafeHandle @other,ref RustCallStatus _uniffi_out_err + ); + [DllImport("servicepoint_binding_uniffi")] public static extern void uniffi_servicepoint_binding_uniffi_fn_method_bitvec_fill(BitVecSafeHandle @ptr,sbyte @value,ref RustCallStatus _uniffi_out_err ); @@ -482,6 +490,14 @@ static class _UniFFILib { public static extern BitmapSafeHandle uniffi_servicepoint_binding_uniffi_fn_constructor_bitmap_new_max_sized(ref RustCallStatus _uniffi_out_err ); + [DllImport("servicepoint_binding_uniffi")] + public static extern RustBuffer uniffi_servicepoint_binding_uniffi_fn_method_bitmap_copy_raw(BitmapSafeHandle @ptr,ref RustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern sbyte uniffi_servicepoint_binding_uniffi_fn_method_bitmap_equals(BitmapSafeHandle @ptr,BitmapSafeHandle @other,ref RustCallStatus _uniffi_out_err + ); + [DllImport("servicepoint_binding_uniffi")] public static extern void uniffi_servicepoint_binding_uniffi_fn_method_bitmap_fill(BitmapSafeHandle @ptr,sbyte @value,ref RustCallStatus _uniffi_out_err ); @@ -519,6 +535,14 @@ static class _UniFFILib { public static extern BrightnessGridSafeHandle uniffi_servicepoint_binding_uniffi_fn_constructor_brightnessgrid_new(ulong @width,ulong @height,ref RustCallStatus _uniffi_out_err ); + [DllImport("servicepoint_binding_uniffi")] + public static extern RustBuffer uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_copy_raw(BrightnessGridSafeHandle @ptr,ref RustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern sbyte uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_equals(BrightnessGridSafeHandle @ptr,BrightnessGridSafeHandle @other,ref RustCallStatus _uniffi_out_err + ); + [DllImport("servicepoint_binding_uniffi")] public static extern void uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_fill(BrightnessGridSafeHandle @ptr,byte @value,ref RustCallStatus _uniffi_out_err ); @@ -580,6 +604,10 @@ static class _UniFFILib { public static extern CommandSafeHandle uniffi_servicepoint_binding_uniffi_fn_constructor_command_clone(CommandSafeHandle @other,ref RustCallStatus _uniffi_out_err ); + [DllImport("servicepoint_binding_uniffi")] + public static extern CommandSafeHandle uniffi_servicepoint_binding_uniffi_fn_constructor_command_cp437_data(ulong @offsetX,ulong @offsetY,Cp437GridSafeHandle @grid,ref RustCallStatus _uniffi_out_err + ); + [DllImport("servicepoint_binding_uniffi")] public static extern CommandSafeHandle uniffi_servicepoint_binding_uniffi_fn_constructor_command_fade_out(ref RustCallStatus _uniffi_out_err ); @@ -588,6 +616,10 @@ static class _UniFFILib { public static extern CommandSafeHandle uniffi_servicepoint_binding_uniffi_fn_constructor_command_hard_reset(ref RustCallStatus _uniffi_out_err ); + [DllImport("servicepoint_binding_uniffi")] + public static extern sbyte uniffi_servicepoint_binding_uniffi_fn_method_command_equals(CommandSafeHandle @ptr,CommandSafeHandle @other,ref RustCallStatus _uniffi_out_err + ); + [DllImport("servicepoint_binding_uniffi")] public static extern void uniffi_servicepoint_binding_uniffi_fn_free_connection( IntPtr ptr,ref RustCallStatus _uniffi_out_err @@ -605,6 +637,51 @@ static class _UniFFILib { public static extern void uniffi_servicepoint_binding_uniffi_fn_method_connection_send(ConnectionSafeHandle @ptr,CommandSafeHandle @command,ref RustCallStatus _uniffi_out_err ); + [DllImport("servicepoint_binding_uniffi")] + public static extern void uniffi_servicepoint_binding_uniffi_fn_free_cp437grid( + IntPtr ptr,ref RustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern Cp437GridSafeHandle uniffi_servicepoint_binding_uniffi_fn_constructor_cp437grid_clone(Cp437GridSafeHandle @other,ref RustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern Cp437GridSafeHandle uniffi_servicepoint_binding_uniffi_fn_constructor_cp437grid_load(ulong @width,ulong @height,RustBuffer @data,ref RustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern Cp437GridSafeHandle uniffi_servicepoint_binding_uniffi_fn_constructor_cp437grid_new(ulong @width,ulong @height,ref RustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern RustBuffer uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_copy_raw(Cp437GridSafeHandle @ptr,ref RustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern sbyte uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_equals(Cp437GridSafeHandle @ptr,Cp437GridSafeHandle @other,ref RustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern void uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_fill(Cp437GridSafeHandle @ptr,byte @value,ref RustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern byte uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_get(Cp437GridSafeHandle @ptr,ulong @x,ulong @y,ref RustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern ulong uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_height(Cp437GridSafeHandle @ptr,ref RustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern void uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_set(Cp437GridSafeHandle @ptr,ulong @x,ulong @y,byte @value,ref RustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern ulong uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_width(Cp437GridSafeHandle @ptr,ref RustCallStatus _uniffi_out_err + ); + [DllImport("servicepoint_binding_uniffi")] public static extern RustBuffer ffi_servicepoint_binding_uniffi_rustbuffer_alloc(int @size,ref RustCallStatus _uniffi_out_err ); @@ -833,6 +910,14 @@ static class _UniFFILib { public static extern void ffi_servicepoint_binding_uniffi_rust_future_complete_void(IntPtr @handle,ref RustCallStatus _uniffi_out_err ); + [DllImport("servicepoint_binding_uniffi")] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_bitvec_copy_raw( + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_bitvec_equals( + ); + [DllImport("servicepoint_binding_uniffi")] public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_bitvec_fill( ); @@ -849,6 +934,14 @@ static class _UniFFILib { public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_bitvec_set( ); + [DllImport("servicepoint_binding_uniffi")] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_bitmap_copy_raw( + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_bitmap_equals( + ); + [DllImport("servicepoint_binding_uniffi")] public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_bitmap_fill( ); @@ -869,6 +962,14 @@ static class _UniFFILib { public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_bitmap_width( ); + [DllImport("servicepoint_binding_uniffi")] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_copy_raw( + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_equals( + ); + [DllImport("servicepoint_binding_uniffi")] public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_fill( ); @@ -889,10 +990,42 @@ static class _UniFFILib { public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_width( ); + [DllImport("servicepoint_binding_uniffi")] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_command_equals( + ); + [DllImport("servicepoint_binding_uniffi")] public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_connection_send( ); + [DllImport("servicepoint_binding_uniffi")] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_copy_raw( + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_equals( + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_fill( + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_get( + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_height( + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_set( + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_width( + ); + [DllImport("servicepoint_binding_uniffi")] public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_bitvec_clone( ); @@ -969,6 +1102,10 @@ static class _UniFFILib { public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_command_clone( ); + [DllImport("servicepoint_binding_uniffi")] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_command_cp437_data( + ); + [DllImport("servicepoint_binding_uniffi")] public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_command_fade_out( ); @@ -985,6 +1122,18 @@ static class _UniFFILib { public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_connection_new_fake( ); + [DllImport("servicepoint_binding_uniffi")] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_cp437grid_clone( + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_cp437grid_load( + ); + + [DllImport("servicepoint_binding_uniffi")] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_cp437grid_new( + ); + [DllImport("servicepoint_binding_uniffi")] public static extern uint ffi_servicepoint_binding_uniffi_uniffi_contract_version( ); @@ -999,6 +1148,18 @@ static class _UniFFILib { } static void uniffiCheckApiChecksums() { + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_bitvec_copy_raw(); + if (checksum != 12617) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_bitvec_copy_raw` checksum `12617`, library returned `{checksum}`"); + } + } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_bitvec_equals(); + if (checksum != 1191) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_bitvec_equals` checksum `1191`, library returned `{checksum}`"); + } + } { var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_bitvec_fill(); if (checksum != 12255) { @@ -1023,6 +1184,18 @@ static class _UniFFILib { throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_bitvec_set` checksum `16307`, library returned `{checksum}`"); } } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_bitmap_copy_raw(); + if (checksum != 3467) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_bitmap_copy_raw` checksum `3467`, library returned `{checksum}`"); + } + } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_bitmap_equals(); + if (checksum != 420) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_bitmap_equals` checksum `420`, library returned `{checksum}`"); + } + } { var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_bitmap_fill(); if (checksum != 43887) { @@ -1053,6 +1226,18 @@ static class _UniFFILib { throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_bitmap_width` checksum `30837`, library returned `{checksum}`"); } } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_copy_raw(); + if (checksum != 28155) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_copy_raw` checksum `28155`, library returned `{checksum}`"); + } + } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_equals(); + if (checksum != 13314) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_equals` checksum `13314`, library returned `{checksum}`"); + } + } { var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_fill(); if (checksum != 63376) { @@ -1083,12 +1268,60 @@ static class _UniFFILib { throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_width` checksum `26384`, library returned `{checksum}`"); } } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_command_equals(); + if (checksum != 20763) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_command_equals` checksum `20763`, library returned `{checksum}`"); + } + } { var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_connection_send(); if (checksum != 23796) { throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_connection_send` checksum `23796`, library returned `{checksum}`"); } } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_copy_raw(); + if (checksum != 50937) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_copy_raw` checksum `50937`, library returned `{checksum}`"); + } + } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_equals(); + if (checksum != 21544) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_equals` checksum `21544`, library returned `{checksum}`"); + } + } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_fill(); + if (checksum != 46422) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_fill` checksum `46422`, library returned `{checksum}`"); + } + } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_get(); + if (checksum != 1945) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_get` checksum `1945`, library returned `{checksum}`"); + } + } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_height(); + if (checksum != 45951) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_height` checksum `45951`, library returned `{checksum}`"); + } + } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_set(); + if (checksum != 8371) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_set` checksum `8371`, library returned `{checksum}`"); + } + } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_width(); + if (checksum != 36872) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_width` checksum `36872`, library returned `{checksum}`"); + } + } { var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_constructor_bitvec_clone(); if (checksum != 123) { @@ -1203,6 +1436,12 @@ static class _UniFFILib { throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_constructor_command_clone` checksum `42249`, library returned `{checksum}`"); } } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_constructor_command_cp437_data(); + if (checksum != 33157) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_constructor_command_cp437_data` checksum `33157`, library returned `{checksum}`"); + } + } { var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_constructor_command_fade_out(); if (checksum != 49231) { @@ -1227,6 +1466,24 @@ static class _UniFFILib { throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_constructor_connection_new_fake` checksum `54331`, library returned `{checksum}`"); } } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_constructor_cp437grid_clone(); + if (checksum != 28173) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_constructor_cp437grid_clone` checksum `28173`, library returned `{checksum}`"); + } + } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_constructor_cp437grid_load(); + if (checksum != 62136) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_constructor_cp437grid_load` checksum `62136`, library returned `{checksum}`"); + } + } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_constructor_cp437grid_new(); + if (checksum != 17350) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_constructor_cp437grid_new` checksum `17350`, library returned `{checksum}`"); + } + } } } @@ -1470,6 +1727,10 @@ static class FFIObjectUtil { } public interface IBitVec { + byte[] CopyRaw(); + + bool Equals(BitVec @other); + void Fill(bool @value); bool Get(ulong @index); @@ -1501,6 +1762,20 @@ public class BitVec: FFIObject, IBitVec { )) {} + public byte[] CopyRaw() { + return FfiConverterByteArray.INSTANCE.Lift( + _UniffiHelpers.RustCall( (ref RustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_bitvec_copy_raw(this.GetHandle(), ref _status) +)); + } + + public bool Equals(BitVec @other) { + return FfiConverterBoolean.INSTANCE.Lift( + _UniffiHelpers.RustCall( (ref RustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_bitvec_equals(this.GetHandle(), FfiConverterTypeBitVec.INSTANCE.Lower(@other), ref _status) +)); + } + public void Fill(bool @value) { _UniffiHelpers.RustCall( (ref RustCallStatus _status) => _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_bitvec_fill(this.GetHandle(), FfiConverterBoolean.INSTANCE.Lower(@value), ref _status) @@ -1576,6 +1851,10 @@ class FfiConverterTypeBitVec: FfiConverter { public interface IBitmap { + byte[] CopyRaw(); + + bool Equals(Bitmap @other); + void Fill(bool @value); bool Get(ulong @x, ulong @y); @@ -1609,6 +1888,20 @@ public class Bitmap: FFIObject, IBitmap { )) {} + public byte[] CopyRaw() { + return FfiConverterByteArray.INSTANCE.Lift( + _UniffiHelpers.RustCall( (ref RustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_bitmap_copy_raw(this.GetHandle(), ref _status) +)); + } + + public bool Equals(Bitmap @other) { + return FfiConverterBoolean.INSTANCE.Lift( + _UniffiHelpers.RustCall( (ref RustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_bitmap_equals(this.GetHandle(), FfiConverterTypeBitmap.INSTANCE.Lower(@other), ref _status) +)); + } + public void Fill(bool @value) { _UniffiHelpers.RustCall( (ref RustCallStatus _status) => _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_bitmap_fill(this.GetHandle(), FfiConverterBoolean.INSTANCE.Lower(@value), ref _status) @@ -1698,6 +1991,10 @@ class FfiConverterTypeBitmap: FfiConverter { public interface IBrightnessGrid { + byte[] CopyRaw(); + + bool Equals(BrightnessGrid @other); + void Fill(byte @value); byte Get(ulong @x, ulong @y); @@ -1731,6 +2028,20 @@ public class BrightnessGrid: FFIObject, IBrightnessGri )) {} + public byte[] CopyRaw() { + return FfiConverterByteArray.INSTANCE.Lift( + _UniffiHelpers.RustCall( (ref RustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_copy_raw(this.GetHandle(), ref _status) +)); + } + + public bool Equals(BrightnessGrid @other) { + return FfiConverterBoolean.INSTANCE.Lift( + _UniffiHelpers.RustCall( (ref RustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_equals(this.GetHandle(), FfiConverterTypeBrightnessGrid.INSTANCE.Lower(@other), ref _status) +)); + } + public void Fill(byte @value) { _UniffiHelpers.RustCall( (ref RustCallStatus _status) => _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_fill(this.GetHandle(), FfiConverterUInt8.INSTANCE.Lower(@value), ref _status) @@ -1813,6 +2124,8 @@ class FfiConverterTypeBrightnessGrid: FfiConverter, ICommand { public Command(CommandSafeHandle pointer): base(pointer) {} + public bool Equals(Command @other) { + return FfiConverterBoolean.INSTANCE.Lift( + _UniffiHelpers.RustCall( (ref RustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_command_equals(this.GetHandle(), FfiConverterTypeCommand.INSTANCE.Lower(@other), ref _status) +)); + } + public static Command BitmapLinear(ulong @offset, BitVec @bitmap, CompressionCode @compression) { @@ -1897,6 +2217,13 @@ public class Command: FFIObject, ICommand { )); } + public static Command Cp437Data(ulong @offsetX, ulong @offsetY, Cp437Grid @grid) { + return new Command( + _UniffiHelpers.RustCall( (ref RustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_constructor_command_cp437_data(FfiConverterUInt64.INSTANCE.Lower(@offsetX), FfiConverterUInt64.INSTANCE.Lower(@offsetY), FfiConverterTypeCp437Grid.INSTANCE.Lower(@grid), ref _status) +)); + } + public static Command FadeOut() { return new Command( _UniffiHelpers.RustCall( (ref RustCallStatus _status) => @@ -2014,6 +2341,139 @@ class FfiConverterTypeConnection: FfiConverter +public interface ICp437Grid { + + byte[] CopyRaw(); + + bool Equals(Cp437Grid @other); + + void Fill(byte @value); + + byte Get(ulong @x, ulong @y); + + ulong Height(); + + void Set(ulong @x, ulong @y, byte @value); + + ulong Width(); + +} + +public class Cp437GridSafeHandle: FFISafeHandle { + public Cp437GridSafeHandle(): base() { + } + public Cp437GridSafeHandle(IntPtr pointer): base(pointer) { + } + override protected bool ReleaseHandle() { + _UniffiHelpers.RustCall((ref RustCallStatus status) => { + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_free_cp437grid(this.handle, ref status); + }); + return true; + } +} +public class Cp437Grid: FFIObject, ICp437Grid { + public Cp437Grid(Cp437GridSafeHandle pointer): base(pointer) {} + public Cp437Grid(ulong @width, ulong @height) : + this( + _UniffiHelpers.RustCall( (ref RustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_constructor_cp437grid_new(FfiConverterUInt64.INSTANCE.Lower(@width), FfiConverterUInt64.INSTANCE.Lower(@height), ref _status) +)) {} + + + public byte[] CopyRaw() { + return FfiConverterByteArray.INSTANCE.Lift( + _UniffiHelpers.RustCall( (ref RustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_copy_raw(this.GetHandle(), ref _status) +)); + } + + public bool Equals(Cp437Grid @other) { + return FfiConverterBoolean.INSTANCE.Lift( + _UniffiHelpers.RustCall( (ref RustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_equals(this.GetHandle(), FfiConverterTypeCp437Grid.INSTANCE.Lower(@other), ref _status) +)); + } + + public void Fill(byte @value) { + _UniffiHelpers.RustCall( (ref RustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_fill(this.GetHandle(), FfiConverterUInt8.INSTANCE.Lower(@value), ref _status) +); + } + + + public byte Get(ulong @x, ulong @y) { + return FfiConverterUInt8.INSTANCE.Lift( + _UniffiHelpers.RustCall( (ref RustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_get(this.GetHandle(), FfiConverterUInt64.INSTANCE.Lower(@x), FfiConverterUInt64.INSTANCE.Lower(@y), ref _status) +)); + } + + public ulong Height() { + return FfiConverterUInt64.INSTANCE.Lift( + _UniffiHelpers.RustCall( (ref RustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_height(this.GetHandle(), ref _status) +)); + } + + public void Set(ulong @x, ulong @y, byte @value) { + _UniffiHelpers.RustCall( (ref RustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_set(this.GetHandle(), FfiConverterUInt64.INSTANCE.Lower(@x), FfiConverterUInt64.INSTANCE.Lower(@y), FfiConverterUInt8.INSTANCE.Lower(@value), ref _status) +); + } + + + public ulong Width() { + return FfiConverterUInt64.INSTANCE.Lift( + _UniffiHelpers.RustCall( (ref RustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_width(this.GetHandle(), ref _status) +)); + } + + + + public static Cp437Grid Clone(Cp437Grid @other) { + return new Cp437Grid( + _UniffiHelpers.RustCall( (ref RustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_constructor_cp437grid_clone(FfiConverterTypeCp437Grid.INSTANCE.Lower(@other), ref _status) +)); + } + + public static Cp437Grid Load(ulong @width, ulong @height, byte[] @data) { + return new Cp437Grid( + _UniffiHelpers.RustCall( (ref RustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_constructor_cp437grid_load(FfiConverterUInt64.INSTANCE.Lower(@width), FfiConverterUInt64.INSTANCE.Lower(@height), FfiConverterByteArray.INSTANCE.Lower(@data), ref _status) +)); + } + + +} + +class FfiConverterTypeCp437Grid: FfiConverter { + public static FfiConverterTypeCp437Grid INSTANCE = new FfiConverterTypeCp437Grid(); + + public override Cp437GridSafeHandle Lower(Cp437Grid value) { + return value.GetHandle(); + } + + public override Cp437Grid Lift(Cp437GridSafeHandle value) { + return new Cp437Grid(value); + } + + public override Cp437Grid Read(BigEndianStream stream) { + return Lift(new Cp437GridSafeHandle(new IntPtr(stream.ReadLong()))); + } + + public override int AllocationSize(Cp437Grid value) { + return 8; + } + + public override void Write(Cp437Grid value, BigEndianStream stream) { + stream.WriteLong(Lower(value).DangerousGetRawFfiValue().ToInt64()); + } +} + + + public enum CompressionCode: int { diff --git a/crates/servicepoint_binding_uniffi/src/bitmap.rs b/crates/servicepoint_binding_uniffi/src/bitmap.rs index 881d628..394b8a0 100644 --- a/crates/servicepoint_binding_uniffi/src/bitmap.rs +++ b/crates/servicepoint_binding_uniffi/src/bitmap.rs @@ -1,4 +1,4 @@ -use servicepoint::Grid; +use servicepoint::{DataRef, Grid}; use std::sync::{Arc, RwLock}; #[derive(uniffi::Object)] @@ -64,4 +64,14 @@ impl Bitmap { pub fn height(&self) -> u64 { self.actual.read().unwrap().height() as u64 } + + pub fn equals(&self, other: &Bitmap) -> bool { + let a = self.actual.read().unwrap(); + let b = other.actual.read().unwrap(); + *a == *b + } + + pub fn copy_raw(&self) -> Vec { + self.actual.read().unwrap().data_ref().to_vec() + } } diff --git a/crates/servicepoint_binding_uniffi/src/bitvec.rs b/crates/servicepoint_binding_uniffi/src/bitvec.rs index 53c9bf4..1ad7751 100644 --- a/crates/servicepoint_binding_uniffi/src/bitvec.rs +++ b/crates/servicepoint_binding_uniffi/src/bitvec.rs @@ -48,4 +48,14 @@ impl BitVec { pub fn len(&self) -> u64 { self.actual.read().unwrap().len() as u64 } + + pub fn equals(&self, other: &BitVec) -> bool { + let a = self.actual.read().unwrap(); + let b = other.actual.read().unwrap(); + *a == *b + } + + pub fn copy_raw(&self) -> Vec { + self.actual.read().unwrap().clone().into_vec() + } } diff --git a/crates/servicepoint_binding_uniffi/src/brightness_grid.rs b/crates/servicepoint_binding_uniffi/src/brightness_grid.rs index c6562bc..6660fdf 100644 --- a/crates/servicepoint_binding_uniffi/src/brightness_grid.rs +++ b/crates/servicepoint_binding_uniffi/src/brightness_grid.rs @@ -1,4 +1,4 @@ -use servicepoint::{Brightness, Grid}; +use servicepoint::{Brightness, DataRef, Grid}; use std::sync::{Arc, RwLock}; #[derive(uniffi::Object)] @@ -67,4 +67,14 @@ impl BrightnessGrid { pub fn height(&self) -> u64 { self.actual.read().unwrap().height() as u64 } + + pub fn equals(&self, other: &BrightnessGrid) -> bool { + let a = self.actual.read().unwrap(); + let b = other.actual.read().unwrap(); + *a == *b + } + + pub fn copy_raw(&self) -> Vec { + self.actual.read().unwrap().data_ref().iter().map(u8::from).collect() + } } diff --git a/crates/servicepoint_binding_uniffi/src/command.rs b/crates/servicepoint_binding_uniffi/src/command.rs index be2bbcc..b9b399b 100644 --- a/crates/servicepoint_binding_uniffi/src/command.rs +++ b/crates/servicepoint_binding_uniffi/src/command.rs @@ -2,6 +2,7 @@ use crate::bitmap::Bitmap; use crate::bitvec::BitVec; use crate::brightness_grid::BrightnessGrid; use crate::compression_code::CompressionCode; +use crate::cp437_grid::Cp437Grid; use crate::errors::ServicePointError; use servicepoint::Origin; use std::sync::Arc; @@ -138,8 +139,24 @@ impl Command { Self::internal_new(actual) } + #[uniffi::constructor] + pub fn cp437_data( + offset_x: u64, + offset_y: u64, + grid: &Arc, + ) -> Arc { + let origin = Origin::new(offset_x as usize, offset_y as usize); + let grid = grid.actual.read().unwrap().clone(); + let actual = servicepoint::Command::Cp437Data(origin, grid); + Self::internal_new(actual) + } + #[uniffi::constructor] pub fn clone(other: &Arc) -> Arc { Self::internal_new(other.actual.clone()) } + + pub fn equals(&self, other: &Command) -> bool { + self.actual == other.actual + } } diff --git a/crates/servicepoint_binding_uniffi/src/cp437_grid.rs b/crates/servicepoint_binding_uniffi/src/cp437_grid.rs new file mode 100644 index 0000000..fa11d92 --- /dev/null +++ b/crates/servicepoint_binding_uniffi/src/cp437_grid.rs @@ -0,0 +1,76 @@ +use servicepoint::{DataRef, Grid}; +use std::sync::{Arc, RwLock}; + +#[derive(uniffi::Object)] +pub struct Cp437Grid { + pub(crate) actual: RwLock, +} + +impl Cp437Grid { + fn internal_new(actual: servicepoint::Cp437Grid) -> Arc { + Arc::new(Self { + actual: RwLock::new(actual), + }) + } +} + +#[uniffi::export] +impl Cp437Grid { + #[uniffi::constructor] + pub fn new(width: u64, height: u64) -> Arc { + Self::internal_new(servicepoint::Cp437Grid::new( + width as usize, + height as usize, + )) + } + + #[uniffi::constructor] + pub fn load(width: u64, height: u64, data: Vec) -> Arc { + Self::internal_new(servicepoint::Cp437Grid::load( + width as usize, + height as usize, + &data, + )) + } + + #[uniffi::constructor] + pub fn clone(other: &Arc) -> Arc { + Self::internal_new(other.actual.read().unwrap().clone()) + } + + pub fn set(&self, x: u64, y: u64, value: u8) { + self.actual + .write() + .unwrap() + .set(x as usize, y as usize, value) + } + + pub fn get(&self, x: u64, y: u64) -> u8 { + self.actual + .read() + .unwrap() + .get(x as usize, y as usize) + .into() + } + + pub fn fill(&self, value: u8) { + self.actual.write().unwrap().fill(value) + } + pub fn width(&self) -> u64 { + self.actual.read().unwrap().width() as u64 + } + + pub fn height(&self) -> u64 { + self.actual.read().unwrap().height() as u64 + } + + pub fn equals(&self, other: &Cp437Grid) -> bool { + let a = self.actual.read().unwrap(); + let b = other.actual.read().unwrap(); + *a == *b + } + + pub fn copy_raw(&self) -> Vec { + self.actual.read().unwrap().data_ref().to_vec() + } +} diff --git a/crates/servicepoint_binding_uniffi/src/lib.rs b/crates/servicepoint_binding_uniffi/src/lib.rs index 975cd9c..702cd00 100644 --- a/crates/servicepoint_binding_uniffi/src/lib.rs +++ b/crates/servicepoint_binding_uniffi/src/lib.rs @@ -6,4 +6,5 @@ mod brightness_grid; mod command; mod compression_code; mod connection; +mod cp437_grid; mod errors;