expose new command to uniffi API
This commit is contained in:
		
							parent
							
								
									2f2160f246
								
							
						
					
					
						commit
						2a6005fff9
					
				
					 3 changed files with 49 additions and 0 deletions
				
			
		|  | @ -681,6 +681,10 @@ static class _UniFFILib { | ||||||
|     public static extern CommandSafeHandle uniffi_servicepoint_binding_uniffi_fn_constructor_command_hard_reset(ref RustCallStatus _uniffi_out_err |     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 CommandSafeHandle uniffi_servicepoint_binding_uniffi_fn_constructor_command_utf8_data(ulong @offsetX,ulong @offsetY,CharGridSafeHandle @grid,ref RustCallStatus _uniffi_out_err | ||||||
|  |     ); | ||||||
|  | 
 | ||||||
|     [DllImport("servicepoint_binding_uniffi")] |     [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 |     public static extern sbyte uniffi_servicepoint_binding_uniffi_fn_method_command_equals(CommandSafeHandle @ptr,CommandSafeHandle @other,ref RustCallStatus _uniffi_out_err | ||||||
|     ); |     ); | ||||||
|  | @ -1255,6 +1259,10 @@ static class _UniFFILib { | ||||||
|     public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_command_hard_reset( |     public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_command_hard_reset( | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
|  |     [DllImport("servicepoint_binding_uniffi")] | ||||||
|  |     public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_command_utf8_data( | ||||||
|  |     ); | ||||||
|  | 
 | ||||||
|     [DllImport("servicepoint_binding_uniffi")] |     [DllImport("servicepoint_binding_uniffi")] | ||||||
|     public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_connection_new( |     public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_connection_new( | ||||||
|     ); |     ); | ||||||
|  | @ -1697,6 +1705,12 @@ static class _UniFFILib { | ||||||
|                 throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_constructor_command_hard_reset` checksum `62130`, library returned `{checksum}`"); |                 throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_constructor_command_hard_reset` checksum `62130`, library returned `{checksum}`"); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |         { | ||||||
|  |             var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_constructor_command_utf8_data(); | ||||||
|  |             if (checksum != 2263) { | ||||||
|  |                 throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_constructor_command_utf8_data` checksum `2263`, library returned `{checksum}`"); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|         { |         { | ||||||
|             var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_constructor_connection_new(); |             var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_constructor_connection_new(); | ||||||
|             if (checksum != 30445) { |             if (checksum != 30445) { | ||||||
|  | @ -2671,6 +2685,13 @@ public class Command: FFIObject<CommandSafeHandle>, ICommand { | ||||||
| )); | )); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  |     public static Command Utf8Data(ulong @offsetX, ulong @offsetY, CharGrid @grid) { | ||||||
|  |         return new Command( | ||||||
|  |     _UniffiHelpers.RustCall( (ref RustCallStatus _status) => | ||||||
|  |     _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_constructor_command_utf8_data(FfiConverterUInt64.INSTANCE.Lower(@offsetX), FfiConverterUInt64.INSTANCE.Lower(@offsetY), FfiConverterTypeCharGrid.INSTANCE.Lower(@grid), ref _status) | ||||||
|  | )); | ||||||
|  |     } | ||||||
|  |      | ||||||
|      |      | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -918,6 +918,9 @@ module UniFFILib | ||||||
|   attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_command_hard_reset, |   attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_command_hard_reset, | ||||||
|     [RustCallStatus.by_ref], |     [RustCallStatus.by_ref], | ||||||
|     :pointer |     :pointer | ||||||
|  |   attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_command_utf8_data, | ||||||
|  |     [:uint64, :uint64, :pointer, RustCallStatus.by_ref], | ||||||
|  |     :pointer | ||||||
|   attach_function :uniffi_servicepoint_binding_uniffi_fn_method_command_equals, |   attach_function :uniffi_servicepoint_binding_uniffi_fn_method_command_equals, | ||||||
|     [:pointer, :pointer, RustCallStatus.by_ref], |     [:pointer, :pointer, RustCallStatus.by_ref], | ||||||
|     :int8 |     :int8 | ||||||
|  | @ -1188,6 +1191,9 @@ module UniFFILib | ||||||
|   attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_command_hard_reset, |   attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_command_hard_reset, | ||||||
|     [RustCallStatus.by_ref], |     [RustCallStatus.by_ref], | ||||||
|     :uint16 |     :uint16 | ||||||
|  |   attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_command_utf8_data, | ||||||
|  |     [RustCallStatus.by_ref], | ||||||
|  |     :uint16 | ||||||
|   attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_connection_new, |   attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_connection_new, | ||||||
|     [RustCallStatus.by_ref], |     [RustCallStatus.by_ref], | ||||||
|     :uint16 |     :uint16 | ||||||
|  | @ -1817,6 +1823,15 @@ end | ||||||
|     # and just create a new instance with the required pointer. |     # and just create a new instance with the required pointer. | ||||||
|     return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_command_hard_reset,)) |     return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_command_hard_reset,)) | ||||||
|   end |   end | ||||||
|  |   def self.utf8_data(offset_x, offset_y, grid) | ||||||
|  |         offset_x = ServicepointBindingUniffi::uniffi_in_range(offset_x, "u64", 0, 2**64) | ||||||
|  |         offset_y = ServicepointBindingUniffi::uniffi_in_range(offset_y, "u64", 0, 2**64) | ||||||
|  |         grid = grid | ||||||
|  |     # Call the (fallible) function before creating any half-baked object instances. | ||||||
|  |     # Lightly yucky way to bypass the usual "initialize" logic | ||||||
|  |     # and just create a new instance with the required pointer. | ||||||
|  |     return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_command_utf8_data,offset_x,offset_y,(CharGrid._uniffi_lower grid))) | ||||||
|  |   end | ||||||
|    |    | ||||||
| 
 | 
 | ||||||
|   def equals(other) |   def equals(other) | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| use crate::bitmap::Bitmap; | use crate::bitmap::Bitmap; | ||||||
| use crate::bitvec::BitVec; | use crate::bitvec::BitVec; | ||||||
| use crate::brightness_grid::BrightnessGrid; | use crate::brightness_grid::BrightnessGrid; | ||||||
|  | use crate::char_grid::CharGrid; | ||||||
| use crate::compression_code::CompressionCode; | use crate::compression_code::CompressionCode; | ||||||
| use crate::cp437_grid::Cp437Grid; | use crate::cp437_grid::Cp437Grid; | ||||||
| use crate::errors::ServicePointError; | use crate::errors::ServicePointError; | ||||||
|  | @ -151,6 +152,18 @@ impl Command { | ||||||
|         Self::internal_new(actual) |         Self::internal_new(actual) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     #[uniffi::constructor] | ||||||
|  |     pub fn utf8_data( | ||||||
|  |         offset_x: u64, | ||||||
|  |         offset_y: u64, | ||||||
|  |         grid: &Arc<CharGrid>, | ||||||
|  |     ) -> Arc<Self> { | ||||||
|  |         let origin = Origin::new(offset_x as usize, offset_y as usize); | ||||||
|  |         let grid = grid.actual.read().unwrap().clone(); | ||||||
|  |         let actual = servicepoint::Command::Utf8Data(origin, grid); | ||||||
|  |         Self::internal_new(actual) | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     #[uniffi::constructor] |     #[uniffi::constructor] | ||||||
|     pub fn clone(other: &Arc<Self>) -> Arc<Self> { |     pub fn clone(other: &Arc<Self>) -> Arc<Self> { | ||||||
|         Self::internal_new(other.actual.clone()) |         Self::internal_new(other.actual.clone()) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vinzenz Schroeter
						Vinzenz Schroeter