forked from UbiquityDotNET/Llvm.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLLVMMetadataRef.g.cs
More file actions
76 lines (67 loc) · 3.52 KB
/
Copy pathLLVMMetadataRef.g.cs
File metadata and controls
76 lines (67 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool. [LlvmBindingsGenerator]
// Tool Version: 20.1.9-epsilon.0.0.ci.618434732.ZZZ
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
#nullable enable
using System;
using System.CodeDom.Compiler;
using System.Runtime.InteropServices.Marshalling;
namespace Ubiquity.NET.Llvm.Interop
{
/// <summary>Simple type safe handle to wrap an opaque pointer for interop with "C" API exported from LibLLVM</summary>
/// <remarks>
/// <para>This is not, nor can it ever be a `ref struct` as such things are not usable in an array. Many LLVM APIs
/// deal with arrays of handles which requires heap allocated location of the handle value not allowed by `ref struct`.
/// This is an important performance distinction as an array of handles, once pinned, is castable to a pointer to the
/// underlying native form. The structs are bit compatible with the underlying form. They are essentially a managed code
/// variant on a type alias. They provide type specific insurance for an opaque native pointer.</para>
/// This handle is owned by it's container and therefore isn't disposable
///
/// <note type="important">
/// Since the object this handle refers to is not owned by the App, the object is
/// destroyed whenever it's container is destroyed, which will invalidate this handle.
/// Use of this handle after the container is destroyed will produce undefined
/// behavior, including, and most likely, memory access violations.
/// </note>
/// </remarks>
[GeneratedCode("LlvmBindingsGenerator","20.1.9-epsilon.0.0.ci.618434732.ZZZ")]
[NativeMarshalling(typeof(WrappedHandleMarshaller<LLVMMetadataRef>))]
public readonly record struct LLVMMetadataRef
: IWrappedHandle<LLVMMetadataRef>
, IFormattable
{
/// <summary>Gets a value indicating if this handle is a <see langword="null"/> value</summary>
public bool IsNull => Handle == nint.Zero;
/// <summary>Gets the handle as an <see cref="nint"/> suitable for passing to native code</summary>
/// <returns>The handle as an <see cref="nint"/></returns>
public nint DangerousGetHandle() => Handle;
/// <inheritdoc/>
public override string ToString( )
{
return Handle.ToString();
}
/// <inheritdoc/>
public string ToString( string? format, IFormatProvider? formatProvider )
{
return Handle.ToString(format, formatProvider);
}
/// <summary>Interface defined factory for an instance of <see cref="LLVMMetadataRef"/></summary>
/// <param name="abiValue">Native ABI value of the handle</param>
/// <returns>Type specific wrapper around the native ABI handle</returns>
public static LLVMMetadataRef FromABI(nint abiValue) => new(abiValue);
/// <summary>Gets the handle as an <see cref="nint"/> suitable for passing to native code</summary>
/// <param name="value">Handle to convert</param>
/// <returns>The handle as an <see cref="nint"/></returns>
public static implicit operator nint(LLVMMetadataRef value) => value.Handle;
internal LLVMMetadataRef( nint p )
{
Handle = p;
}
private readonly nint Handle;
}
}