Share __uuidof<T> and HRESULT macros as well
このコミットが含まれているのは:
1 親
ec7182d105
コミット
4b841afd91
3ファイル変更
+2
-100
検索条件に一致するファイルはありません
@@ -58,7 +58,7 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d3d11shader\ID3D11ShaderReflection.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\dcommon\D2D_VECTOR_2F.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Windows\other\helper-types\HSTRING.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Windows\shared\uuids\Windows.Manual.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)..\ComputeSharp.Win32.D3D12\Windows\shared\uuids\Windows.Manual.cs" Link="Windows\shared\uuids\Windows.Manual.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)..\ComputeSharp.Win32.D3D12\ComPtr`1.cs" Link="ComPtr`1.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d2d1effectauthor\ID2D1DrawInfo.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)..\ComputeSharp.Win32.D3D12\Windows\other\helper-types\HRESULT.cs" Link="Windows\other\helper-types\HRESULT.cs" />
|
||||
@@ -72,6 +72,6 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Windows\shared\winerror\D2DERR.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)..\ComputeSharp.Win32.D3D12\Windows\shared\winerror\E.cs" Link="Windows\shared\winerror\E.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Windows\shared\winerror\RO.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Windows\shared\winerror\Windows.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)..\ComputeSharp.Win32.D3D12\Windows\shared\winerror\Windows.Manual.cs" Link="Windows\shared\winerror\Windows.Manual.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,84 +0,0 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from shared/uuids.h in the Windows SDK for Windows 10.0.20348.0
|
||||
// Original source is Copyright © Microsoft. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace ComputeSharp.Win32;
|
||||
|
||||
internal static partial class Windows
|
||||
{
|
||||
/// <summary>Retrieves the GUID of of a specified type.</summary>
|
||||
/// <param name="value">A value of type <typeparamref name="T"/>.</param>
|
||||
/// <typeparam name="T">The type to retrieve the GUID for.</typeparam>
|
||||
/// <returns>A <see cref="UuidOfType"/> value wrapping a pointer to the GUID data for the input type. This value can be either converted to a <see cref="Guid"/> pointer, or implicitly assigned to a <see cref="Guid"/> value.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe UuidOfType __uuidof<T>(T value) // for type inference similar to C++'s __uuidof
|
||||
where T : unmanaged
|
||||
{
|
||||
return new UuidOfType(UUID<T>.RIID);
|
||||
}
|
||||
|
||||
/// <summary>Retrieves the GUID of of a specified type.</summary>
|
||||
/// <param name="value">A pointer to a value of type <typeparamref name="T"/>.</param>
|
||||
/// <typeparam name="T">The type to retrieve the GUID for.</typeparam>
|
||||
/// <returns>A <see cref="UuidOfType"/> value wrapping a pointer to the GUID data for the input type. This value can be either converted to a <see cref="Guid"/> pointer, or implicitly assigned to a <see cref="Guid"/> value.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe UuidOfType __uuidof<T>(T* value) // for type inference similar to C++'s __uuidof
|
||||
where T : unmanaged
|
||||
{
|
||||
return new UuidOfType(UUID<T>.RIID);
|
||||
}
|
||||
|
||||
/// <summary>Retrieves the GUID of of a specified type.</summary>
|
||||
/// <typeparam name="T">The type to retrieve the GUID for.</typeparam>
|
||||
/// <returns>A <see cref="UuidOfType"/> value wrapping a pointer to the GUID data for the input type. This value can be either converted to a <see cref="Guid"/> pointer, or implicitly assigned to a <see cref="Guid"/> value.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe UuidOfType __uuidof<T>()
|
||||
where T : unmanaged
|
||||
{
|
||||
return new UuidOfType(UUID<T>.RIID);
|
||||
}
|
||||
|
||||
/// <summary>A proxy type that wraps a pointer to GUID data. Values of this type can be implicitly converted to and assigned to <see cref="Guid"/>* or <see cref="Guid"/> parameters.</summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public readonly unsafe ref struct UuidOfType
|
||||
{
|
||||
private readonly Guid* riid;
|
||||
|
||||
internal UuidOfType(Guid* riid)
|
||||
{
|
||||
this.riid = riid;
|
||||
}
|
||||
|
||||
/// <summary>Reads a <see cref="Guid"/> value from the GUID buffer for a given <see cref="UuidOfType"/> instance.</summary>
|
||||
/// <param name="guid">The input <see cref="UuidOfType"/> instance to read data for.</param>
|
||||
public static implicit operator Guid(UuidOfType guid) => *guid.riid;
|
||||
|
||||
/// <summary>Returns the <see cref="Guid"/>* pointer to the GUID buffer for a given <see cref="UuidOfType"/> instance.</summary>
|
||||
/// <param name="guid">The input <see cref="UuidOfType"/> instance to read data for.</param>
|
||||
public static implicit operator Guid*(UuidOfType guid) => guid.riid;
|
||||
}
|
||||
|
||||
/// <summary>A helper type to provide static GUID buffers for specific types.</summary>
|
||||
/// <typeparam name="T">The type to allocate a GUID buffer for.</typeparam>
|
||||
private static unsafe class UUID<T>
|
||||
where T : unmanaged
|
||||
{
|
||||
/// <summary>The pointer to the <see cref="Guid"/> value for the current type.</summary>
|
||||
/// <remarks>The target memory area should never be written to.</remarks>
|
||||
public static readonly Guid* RIID = CreateRIID();
|
||||
|
||||
/// <summary>Allocates memory for a <see cref="Guid"/> value and initializes it.</summary>
|
||||
/// <returns>A pointer to memory holding the <see cref="Guid"/> value for the current type.</returns>
|
||||
private static Guid* CreateRIID()
|
||||
{
|
||||
var p = (Guid*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(T), sizeof(Guid));
|
||||
*p = typeof(T).GUID;
|
||||
return p;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from shared/winerror.h in the Windows SDK for Windows 10.0.22000.0
|
||||
// Original source is Copyright © Microsoft. All rights reserved.
|
||||
|
||||
namespace ComputeSharp.Win32;
|
||||
|
||||
internal static partial class Windows
|
||||
{
|
||||
public static bool SUCCEEDED(HRESULT hr)
|
||||
{
|
||||
return hr >= 0;
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする