add constants
This commit is contained in:
		
							parent
							
								
									b693e9e1c9
								
							
						
					
					
						commit
						666a0e6c01
					
				
					 4 changed files with 180 additions and 0 deletions
				
			
		|  | @ -751,6 +751,10 @@ static class _UniFFILib { | |||
|     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 uniffi_servicepoint_binding_uniffi_fn_func_get_constants(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 | ||||
|     ); | ||||
|  | @ -979,6 +983,10 @@ 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_func_get_constants( | ||||
|     ); | ||||
| 
 | ||||
|     [DllImport("servicepoint_binding_uniffi")] | ||||
|     public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_method_bitvec_copy_raw( | ||||
|     ); | ||||
|  | @ -1281,6 +1289,12 @@ static class _UniFFILib { | |||
|     } | ||||
| 
 | ||||
|     static void uniffiCheckApiChecksums() { | ||||
|         { | ||||
|             var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_func_get_constants(); | ||||
|             if (checksum != 41584) { | ||||
|                 throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_func_get_constants` checksum `41584`, library returned `{checksum}`"); | ||||
|             } | ||||
|         } | ||||
|         { | ||||
|             var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_bitvec_copy_raw(); | ||||
|             if (checksum != 12617) { | ||||
|  | @ -2902,6 +2916,52 @@ class FfiConverterTypeCp437Grid: FfiConverter<Cp437Grid, Cp437GridSafeHandle> { | |||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| public record Constants ( | ||||
|     ulong @tileSize,  | ||||
|     ulong @tileWidth,  | ||||
|     ulong @tileHeight,  | ||||
|     ulong @pixelWidth,  | ||||
|     ulong @pixelHeight,  | ||||
|     ulong @pixelCount | ||||
| ) { | ||||
| } | ||||
| 
 | ||||
| class FfiConverterTypeConstants: FfiConverterRustBuffer<Constants> { | ||||
|     public static FfiConverterTypeConstants INSTANCE = new FfiConverterTypeConstants(); | ||||
| 
 | ||||
|     public override Constants Read(BigEndianStream stream) { | ||||
|         return new Constants( | ||||
|             @tileSize: FfiConverterUInt64.INSTANCE.Read(stream), | ||||
|             @tileWidth: FfiConverterUInt64.INSTANCE.Read(stream), | ||||
|             @tileHeight: FfiConverterUInt64.INSTANCE.Read(stream), | ||||
|             @pixelWidth: FfiConverterUInt64.INSTANCE.Read(stream), | ||||
|             @pixelHeight: FfiConverterUInt64.INSTANCE.Read(stream), | ||||
|             @pixelCount: FfiConverterUInt64.INSTANCE.Read(stream) | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
|     public override int AllocationSize(Constants value) { | ||||
|         return | ||||
|             FfiConverterUInt64.INSTANCE.AllocationSize(value.@tileSize) + | ||||
|             FfiConverterUInt64.INSTANCE.AllocationSize(value.@tileWidth) + | ||||
|             FfiConverterUInt64.INSTANCE.AllocationSize(value.@tileHeight) + | ||||
|             FfiConverterUInt64.INSTANCE.AllocationSize(value.@pixelWidth) + | ||||
|             FfiConverterUInt64.INSTANCE.AllocationSize(value.@pixelHeight) + | ||||
|             FfiConverterUInt64.INSTANCE.AllocationSize(value.@pixelCount); | ||||
|     } | ||||
| 
 | ||||
|     public override void Write(Constants value, BigEndianStream stream) { | ||||
|             FfiConverterUInt64.INSTANCE.Write(value.@tileSize, stream); | ||||
|             FfiConverterUInt64.INSTANCE.Write(value.@tileWidth, stream); | ||||
|             FfiConverterUInt64.INSTANCE.Write(value.@tileHeight, stream); | ||||
|             FfiConverterUInt64.INSTANCE.Write(value.@pixelWidth, stream); | ||||
|             FfiConverterUInt64.INSTANCE.Write(value.@pixelHeight, stream); | ||||
|             FfiConverterUInt64.INSTANCE.Write(value.@pixelCount, stream); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| public class CharGridException: UniffiException { | ||||
|  | @ -3133,5 +3193,12 @@ class FfiConverterTypeServicePointException : FfiConverterRustBuffer<ServicePoin | |||
| } | ||||
| #pragma warning restore 8625 | ||||
| public static class ServicepointBindingUniffiMethods { | ||||
|     public static Constants GetConstants() { | ||||
|         return FfiConverterTypeConstants.INSTANCE.Lift( | ||||
|     _UniffiHelpers.RustCall( (ref RustCallStatus _status) => | ||||
|     _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_func_get_constants( ref _status) | ||||
| )); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -126,6 +126,21 @@ end | |||
|     end | ||||
|   end | ||||
| 
 | ||||
|   # The Record type Constants. | ||||
| 
 | ||||
|   def self.alloc_from_TypeConstants(v) | ||||
|     RustBuffer.allocWithBuilder do |builder| | ||||
|       builder.write_TypeConstants(v) | ||||
|       return builder.finalize | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|   def consumeIntoTypeConstants | ||||
|     consumeWithStream do |stream| | ||||
|       return stream.readTypeConstants | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|    | ||||
| 
 | ||||
|   # The Enum type CompressionCode. | ||||
|  | @ -274,6 +289,19 @@ class RustBufferStream | |||
|     return Cp437Grid._uniffi_allocate(pointer) | ||||
|   end | ||||
| 
 | ||||
|   # The Record type Constants. | ||||
| 
 | ||||
|   def readTypeConstants | ||||
|     Constants.new( | ||||
|       readU64, | ||||
|       readU64, | ||||
|       readU64, | ||||
|       readU64, | ||||
|       readU64, | ||||
|       readU64 | ||||
|     ) | ||||
|   end | ||||
| 
 | ||||
|    | ||||
| 
 | ||||
|    | ||||
|  | @ -478,6 +506,17 @@ class RustBufferBuilder | |||
|     pack_into(8, 'Q>', pointer.address) | ||||
|   end | ||||
| 
 | ||||
|   # The Record type Constants. | ||||
| 
 | ||||
|   def write_TypeConstants(v) | ||||
|     self.write_U64(v.tile_size) | ||||
|     self.write_U64(v.tile_width) | ||||
|     self.write_U64(v.tile_height) | ||||
|     self.write_U64(v.pixel_width) | ||||
|     self.write_U64(v.pixel_height) | ||||
|     self.write_U64(v.pixel_count) | ||||
|   end | ||||
| 
 | ||||
|    | ||||
| 
 | ||||
|   # The Enum type CompressionCode. | ||||
|  | @ -930,6 +969,9 @@ module UniFFILib | |||
|   attach_function :uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_width, | ||||
|     [:pointer, RustCallStatus.by_ref], | ||||
|     :uint64 | ||||
|   attach_function :uniffi_servicepoint_binding_uniffi_fn_func_get_constants, | ||||
|     [RustCallStatus.by_ref], | ||||
|     RustBuffer.by_value | ||||
|   attach_function :ffi_servicepoint_binding_uniffi_rustbuffer_alloc, | ||||
|     [:int32, RustCallStatus.by_ref], | ||||
|     RustBuffer.by_value | ||||
|  | @ -942,6 +984,9 @@ module UniFFILib | |||
|   attach_function :ffi_servicepoint_binding_uniffi_rustbuffer_reserve, | ||||
|     [RustBuffer.by_value, :int32, RustCallStatus.by_ref], | ||||
|     RustBuffer.by_value | ||||
|   attach_function :uniffi_servicepoint_binding_uniffi_checksum_func_get_constants, | ||||
|     [RustCallStatus.by_ref], | ||||
|     :uint16 | ||||
|   attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_bitvec_copy_raw, | ||||
|     [RustCallStatus.by_ref], | ||||
|     :uint16 | ||||
|  | @ -1183,6 +1228,52 @@ end | |||
| 
 | ||||
|    | ||||
|    | ||||
|   # Record type Constants | ||||
| class Constants | ||||
|   attr_reader :tile_size, :tile_width, :tile_height, :pixel_width, :pixel_height, :pixel_count | ||||
| 
 | ||||
|   def initialize(tile_size, tile_width, tile_height, pixel_width, pixel_height, pixel_count) | ||||
|     @tile_size = tile_size | ||||
|     @tile_width = tile_width | ||||
|     @tile_height = tile_height | ||||
|     @pixel_width = pixel_width | ||||
|     @pixel_height = pixel_height | ||||
|     @pixel_count = pixel_count | ||||
|   end | ||||
| 
 | ||||
|   def ==(other) | ||||
|     if @tile_size != other.tile_size | ||||
|       return false | ||||
|     end | ||||
|     if @tile_width != other.tile_width | ||||
|       return false | ||||
|     end | ||||
|     if @tile_height != other.tile_height | ||||
|       return false | ||||
|     end | ||||
|     if @pixel_width != other.pixel_width | ||||
|       return false | ||||
|     end | ||||
|     if @pixel_height != other.pixel_height | ||||
|       return false | ||||
|     end | ||||
|     if @pixel_count != other.pixel_count | ||||
|       return false | ||||
|     end | ||||
| 
 | ||||
|     true | ||||
|   end | ||||
| end | ||||
|    | ||||
| 
 | ||||
|    | ||||
|    | ||||
| 
 | ||||
| def self.get_constants() | ||||
|   result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_func_get_constants,) | ||||
|   return result.consumeIntoTypeConstants | ||||
| end | ||||
| 
 | ||||
| 
 | ||||
|    | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										21
									
								
								crates/servicepoint_binding_uniffi/src/constants.rs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								crates/servicepoint_binding_uniffi/src/constants.rs
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,21 @@ | |||
| #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, uniffi::Record)] | ||||
| pub struct Constants { | ||||
|     pub tile_size: u64, | ||||
|     pub tile_width: u64, | ||||
|     pub tile_height: u64, | ||||
|     pub pixel_width: u64, | ||||
|     pub pixel_height: u64, | ||||
|     pub pixel_count: u64, | ||||
| } | ||||
| 
 | ||||
| #[uniffi::export] | ||||
| fn get_constants() -> Constants { | ||||
| Constants { | ||||
|         tile_size: servicepoint::TILE_SIZE as u64, | ||||
|         tile_width: servicepoint::TILE_WIDTH as u64, | ||||
|         tile_height: servicepoint::TILE_HEIGHT as u64, | ||||
|         pixel_width: servicepoint::PIXEL_WIDTH as u64, | ||||
|         pixel_height: servicepoint::PIXEL_HEIGHT as u64, | ||||
|         pixel_count: servicepoint::PIXEL_COUNT as u64, | ||||
|     } | ||||
| } | ||||
|  | @ -9,3 +9,4 @@ mod compression_code; | |||
| mod connection; | ||||
| mod cp437_grid; | ||||
| mod errors; | ||||
| mod constants; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vinzenz Schroeter
						Vinzenz Schroeter