update c# binding
This commit is contained in:
		
							parent
							
								
									4cd86d3494
								
							
						
					
					
						commit
						a4189e2a86
					
				
					 6 changed files with 123 additions and 27 deletions
				
			
		|  | @ -167,7 +167,7 @@ namespace ServicePoint.BindGen | |||
| 
 | ||||
|         /// <summary>Allocates a new `Command::CharBrightness` instance. The passed `ByteGrid` gets consumed.  # Safety  The caller has to make sure that:  - `byte_grid` points to a valid instance of `ByteGrid` - `byte_grid` is not used concurrently or after this call - the returned `Command` instance is freed in some way, either by using a consuming function or by explicitly calling `sp_command_dealloc`.</summary> | ||||
|         [DllImport(__DllName, EntryPoint = "sp_command_char_brightness", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] | ||||
|         public static extern Command* sp_command_char_brightness(nuint x, nuint y, BrightnessGrid* byte_grid); | ||||
|         public static extern Command* sp_command_char_brightness(nuint x, nuint y, CBrightnessGrid* byte_grid); | ||||
| 
 | ||||
|         /// <summary>Allocates a new `Command::BitmapLinear` instance. The passed `BitVec` gets consumed.  # Safety  The caller has to make sure that:  - `bit_vec` points to a valid instance of `BitVec` - `bit_vec` is not used concurrently or after this call - `compression` matches one of the allowed enum values - the returned `Command` instance is freed in some way, either by using a consuming function or by explicitly calling `sp_command_dealloc`.</summary> | ||||
|         [DllImport(__DllName, EntryPoint = "sp_command_bitmap_linear", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] | ||||
|  | @ -187,7 +187,7 @@ namespace ServicePoint.BindGen | |||
| 
 | ||||
|         /// <summary>Allocates a new `Command::Cp437Data` instance. The passed `ByteGrid` gets consumed.  # Safety  The caller has to make sure that:  - `byte_grid` points to a valid instance of `ByteGrid` - `byte_grid` is not used concurrently or after this call - the returned `Command` instance is freed in some way, either by using a consuming function or by explicitly calling `sp_command_dealloc`.</summary> | ||||
|         [DllImport(__DllName, EntryPoint = "sp_command_cp437_data", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] | ||||
|         public static extern Command* sp_command_cp437_data(nuint x, nuint y, PrimitiveGrid* byte_grid); | ||||
|         public static extern Command* sp_command_cp437_data(nuint x, nuint y, CCp437Grid* byte_grid); | ||||
| 
 | ||||
|         /// <summary>Allocates a new `Command::BitmapLinearWin` instance. The passed `PixelGrid` gets consumed.  # Safety  The caller has to make sure that:  - `pixel_grid` points to a valid instance of `PixelGrid` - `pixel_grid` is not used concurrently or after this call - `compression` matches one of the allowed enum values - the returned `Command` instance is freed in some way, either by using a consuming function or by explicitly calling `sp_command_dealloc`.</summary> | ||||
|         [DllImport(__DllName, EntryPoint = "sp_command_bitmap_linear_win", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] | ||||
|  | @ -288,11 +288,6 @@ namespace ServicePoint.BindGen | |||
|         public nuint length; | ||||
|     } | ||||
| 
 | ||||
|     [StructLayout(LayoutKind.Sequential)] | ||||
|     public unsafe partial struct PrimitiveGrid | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     [StructLayout(LayoutKind.Sequential)] | ||||
|     public unsafe partial struct Connection | ||||
|     { | ||||
|  |  | |||
							
								
								
									
										103
									
								
								crates/servicepoint_binding_cs/ServicePoint/BrightnessGrid.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										103
									
								
								crates/servicepoint_binding_cs/ServicePoint/BrightnessGrid.cs
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,103 @@ | |||
| using ServicePoint.BindGen; | ||||
| 
 | ||||
| namespace ServicePoint; | ||||
| 
 | ||||
| public sealed class BrightnessGrid : SpNativeInstance<BindGen.CBrightnessGrid> | ||||
| { | ||||
|     public static BrightnessGrid New(int width, int height) | ||||
|     { | ||||
|         unsafe | ||||
|         { | ||||
|             return new BrightnessGrid(NativeMethods.sp_brightness_grid_new((nuint)width, (nuint)height)); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public static BrightnessGrid Load(int width, int height, Span<byte> bytes) | ||||
|     { | ||||
|         unsafe | ||||
|         { | ||||
|             fixed (byte* bytesPtr = bytes) | ||||
|             { | ||||
|                 return new BrightnessGrid(NativeMethods.sp_brightness_grid_load((nuint)width, (nuint)height, bytesPtr, | ||||
|                     (nuint)bytes.Length)); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public BrightnessGrid Clone() | ||||
|     { | ||||
|         unsafe | ||||
|         { | ||||
|             return new BrightnessGrid(NativeMethods.sp_brightness_grid_clone(Instance)); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public byte this[int x, int y] | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             unsafe | ||||
|             { | ||||
|                 return NativeMethods.sp_brightness_grid_get(Instance, (nuint)x, (nuint)y); | ||||
|             } | ||||
|         } | ||||
|         set | ||||
|         { | ||||
|             unsafe | ||||
|             { | ||||
|                 NativeMethods.sp_brightness_grid_set(Instance, (nuint)x, (nuint)y, value); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public void Fill(byte value) | ||||
|     { | ||||
|         unsafe | ||||
|         { | ||||
|             NativeMethods.sp_brightness_grid_fill(Instance, value); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public int Width | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             unsafe | ||||
|             { | ||||
|                 return (int)NativeMethods.sp_brightness_grid_width(Instance); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public int Height | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             unsafe | ||||
|             { | ||||
|                 return (int)NativeMethods.sp_brightness_grid_height(Instance); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public Span<byte> Data | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             unsafe | ||||
|             { | ||||
|                 var slice = NativeMethods.sp_brightness_grid_unsafe_data_ref(Instance); | ||||
|                 return new Span<byte>(slice.start, (int)slice.length); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private unsafe BrightnessGrid(BindGen.CBrightnessGrid* instance) : base(instance) | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     private protected override unsafe void Dealloc() | ||||
|     { | ||||
|         NativeMethods.sp_brightness_grid_dealloc(Instance); | ||||
|     } | ||||
| } | ||||
|  | @ -61,7 +61,7 @@ public sealed class Command : SpNativeInstance<BindGen.Command> | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public static Command CharBrightness(int x, int y, ByteGrid grid) | ||||
|     public static Command CharBrightness(int x, int y, BrightnessGrid grid) | ||||
|     { | ||||
|         unsafe | ||||
|         { | ||||
|  | @ -113,7 +113,7 @@ public sealed class Command : SpNativeInstance<BindGen.Command> | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public static Command Cp437Data(int x, int y, ByteGrid byteGrid) | ||||
|     public static Command Cp437Data(int x, int y, Cp437Grid byteGrid) | ||||
|     { | ||||
|         unsafe | ||||
|         { | ||||
|  |  | |||
|  | @ -3,33 +3,33 @@ using ServicePoint.BindGen; | |||
| 
 | ||||
| namespace ServicePoint; | ||||
| 
 | ||||
| public sealed class ByteGrid : SpNativeInstance<BindGen.ByteGrid> | ||||
| public sealed class Cp437Grid : SpNativeInstance<BindGen.CCp437Grid> | ||||
| { | ||||
|     public static ByteGrid New(int width, int height) | ||||
|     public static Cp437Grid New(int width, int height) | ||||
|     { | ||||
|         unsafe | ||||
|         { | ||||
|             return new ByteGrid(NativeMethods.sp_byte_grid_new((nuint)width, (nuint)height)); | ||||
|             return new Cp437Grid(NativeMethods.sp_cp437_grid_new((nuint)width, (nuint)height)); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public static ByteGrid Load(int width, int height, Span<byte> bytes) | ||||
|     public static Cp437Grid Load(int width, int height, Span<byte> bytes) | ||||
|     { | ||||
|         unsafe | ||||
|         { | ||||
|             fixed (byte* bytesPtr = bytes) | ||||
|             { | ||||
|                 return new ByteGrid(NativeMethods.sp_byte_grid_load((nuint)width, (nuint)height, bytesPtr, | ||||
|                 return new Cp437Grid(NativeMethods.sp_cp437_grid_load((nuint)width, (nuint)height, bytesPtr, | ||||
|                     (nuint)bytes.Length)); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public ByteGrid Clone() | ||||
|     public Cp437Grid Clone() | ||||
|     { | ||||
|         unsafe | ||||
|         { | ||||
|             return new ByteGrid(NativeMethods.sp_byte_grid_clone(Instance)); | ||||
|             return new Cp437Grid(NativeMethods.sp_cp437_grid_clone(Instance)); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | @ -39,14 +39,14 @@ public sealed class ByteGrid : SpNativeInstance<BindGen.ByteGrid> | |||
|         { | ||||
|             unsafe | ||||
|             { | ||||
|                 return NativeMethods.sp_byte_grid_get(Instance, (nuint)x, (nuint)y); | ||||
|                 return NativeMethods.sp_cp437_grid_get(Instance, (nuint)x, (nuint)y); | ||||
|             } | ||||
|         } | ||||
|         set | ||||
|         { | ||||
|             unsafe | ||||
|             { | ||||
|                 NativeMethods.sp_byte_grid_set(Instance, (nuint)x, (nuint)y, value); | ||||
|                 NativeMethods.sp_cp437_grid_set(Instance, (nuint)x, (nuint)y, value); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | @ -85,7 +85,7 @@ public sealed class ByteGrid : SpNativeInstance<BindGen.ByteGrid> | |||
|     { | ||||
|         unsafe | ||||
|         { | ||||
|             NativeMethods.sp_byte_grid_fill(Instance, value); | ||||
|             NativeMethods.sp_cp437_grid_fill(Instance, value); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | @ -95,7 +95,7 @@ public sealed class ByteGrid : SpNativeInstance<BindGen.ByteGrid> | |||
|         { | ||||
|             unsafe | ||||
|             { | ||||
|                 return (int)NativeMethods.sp_byte_grid_width(Instance); | ||||
|                 return (int)NativeMethods.sp_cp437_grid_width(Instance); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | @ -106,7 +106,7 @@ public sealed class ByteGrid : SpNativeInstance<BindGen.ByteGrid> | |||
|         { | ||||
|             unsafe | ||||
|             { | ||||
|                 return (int)NativeMethods.sp_byte_grid_height(Instance); | ||||
|                 return (int)NativeMethods.sp_cp437_grid_height(Instance); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | @ -117,18 +117,18 @@ public sealed class ByteGrid : SpNativeInstance<BindGen.ByteGrid> | |||
|         { | ||||
|             unsafe | ||||
|             { | ||||
|                 var slice = NativeMethods.sp_byte_grid_unsafe_data_ref(Instance); | ||||
|                 var slice = NativeMethods.sp_cp437_grid_unsafe_data_ref(Instance); | ||||
|                 return new Span<byte>(slice.start, (int)slice.length); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private unsafe ByteGrid(BindGen.ByteGrid* instance) : base(instance) | ||||
|     private unsafe Cp437Grid(BindGen.CCp437Grid* instance) : base(instance) | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     private protected override unsafe void Dealloc() | ||||
|     { | ||||
|         NativeMethods.sp_byte_grid_dealloc(Instance); | ||||
|         NativeMethods.sp_cp437_grid_dealloc(Instance); | ||||
|     } | ||||
| } | ||||
|  | @ -7,7 +7,6 @@ | |||
|         <AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||||
| 
 | ||||
|         <DisableFastUpToDateCheck>true</DisableFastUpToDateCheck> | ||||
|         <GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||||
|     </PropertyGroup> | ||||
| 
 | ||||
|     <PropertyGroup> | ||||
|  | @ -35,7 +34,7 @@ | |||
|         <Exec Command="cargo build"/> | ||||
|         <Exec Command="cargo build --manifest-path ../../../crates/servicepoint_binding_c/Cargo.toml"/> | ||||
|     </Target> | ||||
|      | ||||
| 
 | ||||
|     <!-- include native binary in output --> | ||||
|     <ItemGroup Condition="'$(Configuration)'=='Debug'"> | ||||
|         <Content Include="../../../target/debug/libservicepoint_binding_c.so" CopyToOutputDirectory="Always"> | ||||
|  |  | |||
|  | @ -13,7 +13,6 @@ fn main() { | |||
|         .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/primitive_grid.rs") | ||||
|         .input_extern_file("../servicepoint/src/command.rs") | ||||
|         .input_extern_file("../servicepoint/src/connection.rs") | ||||
|         .input_extern_file("../servicepoint/src/pixel_grid.rs") | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vinzenz Schroeter
						Vinzenz Schroeter