-
-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use SourceGenerator for native code of MagickGeometry and change from…
… double to nint/nuint.
- Loading branch information
Showing
2 changed files
with
23 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,269 +1,30 @@ | ||
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET. | ||
// Licensed under the Apache License, Version 2.0. | ||
// <auto-generated/> | ||
#nullable enable | ||
|
||
using System; | ||
using System.Security; | ||
using System.Runtime.InteropServices; | ||
using ImageMagick.SourceGenerator; | ||
|
||
namespace ImageMagick; | ||
|
||
/// <content /> | ||
public partial class MagickGeometry | ||
{ | ||
[SuppressUnmanagedCodeSecurity] | ||
private static unsafe class NativeMethods | ||
[NativeInterop(NativeToManaged = true)] | ||
private partial class NativeMagickGeometry : NativeInstance | ||
{ | ||
#if PLATFORM_x64 || PLATFORM_AnyCPU | ||
public static class X64 | ||
{ | ||
[DllImport(NativeLibrary.X64Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern IntPtr MagickGeometry_Create(); | ||
[DllImport(NativeLibrary.X64Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern void MagickGeometry_Dispose(IntPtr instance); | ||
[DllImport(NativeLibrary.X64Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern double MagickGeometry_X_Get(IntPtr instance); | ||
[DllImport(NativeLibrary.X64Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern double MagickGeometry_Y_Get(IntPtr instance); | ||
[DllImport(NativeLibrary.X64Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern double MagickGeometry_Width_Get(IntPtr instance); | ||
[DllImport(NativeLibrary.X64Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern double MagickGeometry_Height_Get(IntPtr instance); | ||
[DllImport(NativeLibrary.X64Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern UIntPtr MagickGeometry_Initialize(IntPtr Instance, IntPtr value); | ||
} | ||
#endif | ||
#if PLATFORM_arm64 || PLATFORM_AnyCPU | ||
public static class ARM64 | ||
{ | ||
[DllImport(NativeLibrary.ARM64Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern IntPtr MagickGeometry_Create(); | ||
[DllImport(NativeLibrary.ARM64Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern void MagickGeometry_Dispose(IntPtr instance); | ||
[DllImport(NativeLibrary.ARM64Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern double MagickGeometry_X_Get(IntPtr instance); | ||
[DllImport(NativeLibrary.ARM64Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern double MagickGeometry_Y_Get(IntPtr instance); | ||
[DllImport(NativeLibrary.ARM64Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern double MagickGeometry_Width_Get(IntPtr instance); | ||
[DllImport(NativeLibrary.ARM64Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern double MagickGeometry_Height_Get(IntPtr instance); | ||
[DllImport(NativeLibrary.ARM64Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern UIntPtr MagickGeometry_Initialize(IntPtr Instance, IntPtr value); | ||
} | ||
#endif | ||
#if PLATFORM_x86 || PLATFORM_AnyCPU | ||
public static class X86 | ||
{ | ||
[DllImport(NativeLibrary.X86Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern IntPtr MagickGeometry_Create(); | ||
[DllImport(NativeLibrary.X86Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern void MagickGeometry_Dispose(IntPtr instance); | ||
[DllImport(NativeLibrary.X86Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern double MagickGeometry_X_Get(IntPtr instance); | ||
[DllImport(NativeLibrary.X86Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern double MagickGeometry_Y_Get(IntPtr instance); | ||
[DllImport(NativeLibrary.X86Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern double MagickGeometry_Width_Get(IntPtr instance); | ||
[DllImport(NativeLibrary.X86Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern double MagickGeometry_Height_Get(IntPtr instance); | ||
[DllImport(NativeLibrary.X86Name, CallingConvention = CallingConvention.Cdecl)] | ||
public static extern UIntPtr MagickGeometry_Initialize(IntPtr Instance, IntPtr value); | ||
} | ||
#endif | ||
} | ||
private unsafe sealed partial class NativeMagickGeometry : NativeInstance | ||
{ | ||
static NativeMagickGeometry() { Environment.Initialize(); } | ||
protected override void Dispose(IntPtr instance) | ||
{ | ||
#if PLATFORM_AnyCPU | ||
if (Runtime.IsArm64) | ||
#endif | ||
#if PLATFORM_arm64 || PLATFORM_AnyCPU | ||
NativeMethods.ARM64.MagickGeometry_Dispose(instance); | ||
#endif | ||
#if PLATFORM_AnyCPU | ||
else if (Runtime.Is64Bit) | ||
#endif | ||
#if PLATFORM_x64 || PLATFORM_AnyCPU | ||
NativeMethods.X64.MagickGeometry_Dispose(instance); | ||
#endif | ||
#if PLATFORM_AnyCPU | ||
else | ||
#endif | ||
#if PLATFORM_x86 || PLATFORM_AnyCPU | ||
NativeMethods.X86.MagickGeometry_Dispose(instance); | ||
#endif | ||
} | ||
public NativeMagickGeometry() | ||
{ | ||
#if PLATFORM_AnyCPU | ||
if (Runtime.IsArm64) | ||
#endif | ||
#if PLATFORM_arm64 || PLATFORM_AnyCPU | ||
Instance = NativeMethods.ARM64.MagickGeometry_Create(); | ||
#endif | ||
#if PLATFORM_AnyCPU | ||
else if (Runtime.Is64Bit) | ||
#endif | ||
#if PLATFORM_x64 || PLATFORM_AnyCPU | ||
Instance = NativeMethods.X64.MagickGeometry_Create(); | ||
#endif | ||
#if PLATFORM_AnyCPU | ||
else | ||
#endif | ||
#if PLATFORM_x86 || PLATFORM_AnyCPU | ||
Instance = NativeMethods.X86.MagickGeometry_Create(); | ||
#endif | ||
if (Instance == IntPtr.Zero) | ||
throw new InvalidOperationException(); | ||
} | ||
public NativeMagickGeometry(IntPtr instance) | ||
{ | ||
Instance = instance; | ||
} | ||
protected override string TypeName | ||
{ | ||
get | ||
{ | ||
return nameof(MagickGeometry); | ||
} | ||
} | ||
public double X | ||
{ | ||
get | ||
{ | ||
double result; | ||
#if PLATFORM_AnyCPU | ||
if (Runtime.IsArm64) | ||
#endif | ||
#if PLATFORM_arm64 || PLATFORM_AnyCPU | ||
result = NativeMethods.ARM64.MagickGeometry_X_Get(Instance); | ||
#endif | ||
#if PLATFORM_AnyCPU | ||
else if (Runtime.Is64Bit) | ||
#endif | ||
#if PLATFORM_x64 || PLATFORM_AnyCPU | ||
result = NativeMethods.X64.MagickGeometry_X_Get(Instance); | ||
#endif | ||
#if PLATFORM_AnyCPU | ||
else | ||
#endif | ||
#if PLATFORM_x86 || PLATFORM_AnyCPU | ||
result = NativeMethods.X86.MagickGeometry_X_Get(Instance); | ||
#endif | ||
return result; | ||
} | ||
} | ||
public double Y | ||
{ | ||
get | ||
{ | ||
double result; | ||
#if PLATFORM_AnyCPU | ||
if (Runtime.IsArm64) | ||
#endif | ||
#if PLATFORM_arm64 || PLATFORM_AnyCPU | ||
result = NativeMethods.ARM64.MagickGeometry_Y_Get(Instance); | ||
#endif | ||
#if PLATFORM_AnyCPU | ||
else if (Runtime.Is64Bit) | ||
#endif | ||
#if PLATFORM_x64 || PLATFORM_AnyCPU | ||
result = NativeMethods.X64.MagickGeometry_Y_Get(Instance); | ||
#endif | ||
#if PLATFORM_AnyCPU | ||
else | ||
#endif | ||
#if PLATFORM_x86 || PLATFORM_AnyCPU | ||
result = NativeMethods.X86.MagickGeometry_Y_Get(Instance); | ||
#endif | ||
return result; | ||
} | ||
} | ||
public double Width | ||
{ | ||
get | ||
{ | ||
double result; | ||
#if PLATFORM_AnyCPU | ||
if (Runtime.IsArm64) | ||
#endif | ||
#if PLATFORM_arm64 || PLATFORM_AnyCPU | ||
result = NativeMethods.ARM64.MagickGeometry_Width_Get(Instance); | ||
#endif | ||
#if PLATFORM_AnyCPU | ||
else if (Runtime.Is64Bit) | ||
#endif | ||
#if PLATFORM_x64 || PLATFORM_AnyCPU | ||
result = NativeMethods.X64.MagickGeometry_Width_Get(Instance); | ||
#endif | ||
#if PLATFORM_AnyCPU | ||
else | ||
#endif | ||
#if PLATFORM_x86 || PLATFORM_AnyCPU | ||
result = NativeMethods.X86.MagickGeometry_Width_Get(Instance); | ||
#endif | ||
return result; | ||
} | ||
} | ||
public double Height | ||
{ | ||
get | ||
{ | ||
double result; | ||
#if PLATFORM_AnyCPU | ||
if (Runtime.IsArm64) | ||
#endif | ||
#if PLATFORM_arm64 || PLATFORM_AnyCPU | ||
result = NativeMethods.ARM64.MagickGeometry_Height_Get(Instance); | ||
#endif | ||
#if PLATFORM_AnyCPU | ||
else if (Runtime.Is64Bit) | ||
#endif | ||
#if PLATFORM_x64 || PLATFORM_AnyCPU | ||
result = NativeMethods.X64.MagickGeometry_Height_Get(Instance); | ||
#endif | ||
#if PLATFORM_AnyCPU | ||
else | ||
#endif | ||
#if PLATFORM_x86 || PLATFORM_AnyCPU | ||
result = NativeMethods.X86.MagickGeometry_Height_Get(Instance); | ||
#endif | ||
return result; | ||
} | ||
} | ||
public GeometryFlags Initialize(string value) | ||
{ | ||
using var valueNative = UTF8Marshaler.CreateInstance(value); | ||
UIntPtr result; | ||
#if PLATFORM_AnyCPU | ||
if (Runtime.IsArm64) | ||
#endif | ||
#if PLATFORM_arm64 || PLATFORM_AnyCPU | ||
result = NativeMethods.ARM64.MagickGeometry_Initialize(Instance, valueNative.Instance); | ||
#endif | ||
#if PLATFORM_AnyCPU | ||
else if (Runtime.Is64Bit) | ||
#endif | ||
#if PLATFORM_x64 || PLATFORM_AnyCPU | ||
result = NativeMethods.X64.MagickGeometry_Initialize(Instance, valueNative.Instance); | ||
#endif | ||
#if PLATFORM_AnyCPU | ||
else | ||
#endif | ||
#if PLATFORM_x86 || PLATFORM_AnyCPU | ||
result = NativeMethods.X86.MagickGeometry_Initialize(Instance, valueNative.Instance); | ||
#endif | ||
return (GeometryFlags)result; | ||
} | ||
} | ||
internal static MagickGeometry? CreateInstance(IntPtr instance) | ||
{ | ||
if (instance == IntPtr.Zero) | ||
return null; | ||
using NativeMagickGeometry nativeInstance = new NativeMagickGeometry(instance); | ||
return new MagickGeometry(nativeInstance); | ||
=> Instance = Create(); | ||
|
||
public static partial IntPtr Create(); | ||
|
||
public partial nint X_Get(); | ||
|
||
public partial nint Y_Get(); | ||
|
||
public partial nuint Width_Get(); | ||
|
||
public partial nuint Height_Get(); | ||
|
||
public partial GeometryFlags Initialize(string value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters