mirror of
https://github.com/DumbDev69420/EscapeTheBackrooms_Internal.git
synced 2025-06-29 18:22:32 +08:00
Made Project Buildable. Just realized Project cant be Build for Others
This commit is contained in:
405
EscapeTheBackroomsGUiTest/vcpkg_Out/include/wsl/stubs/basetsd.h
Normal file
405
EscapeTheBackroomsGUiTest/vcpkg_Out/include/wsl/stubs/basetsd.h
Normal file
@ -0,0 +1,405 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
// These #defines prevent the idl-generated headers from trying to include
|
||||
// Windows.h from the SDK rather than this one.
|
||||
#define RPC_NO_WINDOWS_H
|
||||
#define COM_NO_WINDOWS_H
|
||||
|
||||
// Allcaps type definitions
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
// Note: using fixed-width here to match Windows widths
|
||||
// Specifically this is different for 'long' vs 'LONG'
|
||||
typedef uint8_t UINT8;
|
||||
typedef int8_t INT8;
|
||||
typedef uint16_t UINT16;
|
||||
typedef int16_t INT16;
|
||||
typedef uint32_t UINT32, UINT, ULONG, DWORD, BOOL, WINBOOL;
|
||||
typedef int32_t INT32, INT, LONG;
|
||||
typedef uint64_t UINT64, ULONG_PTR;
|
||||
typedef int64_t INT64, LONG_PTR;
|
||||
typedef void VOID, *HANDLE, *RPC_IF_HANDLE, *LPVOID;
|
||||
typedef const void *LPCVOID;
|
||||
typedef size_t SIZE_T;
|
||||
typedef float FLOAT;
|
||||
typedef double DOUBLE;
|
||||
typedef unsigned char BYTE;
|
||||
typedef int HWND;
|
||||
typedef int PALETTEENTRY;
|
||||
typedef int HDC;
|
||||
typedef uint16_t WORD;
|
||||
typedef void* PVOID;
|
||||
typedef char BOOLEAN;
|
||||
typedef uint64_t ULONGLONG;
|
||||
typedef uint16_t USHORT, *PUSHORT;
|
||||
typedef int64_t LONGLONG, *PLONGLONG;
|
||||
typedef int64_t LONG_PTR, *PLONG_PTR;
|
||||
typedef int64_t LONG64, *PLONG64;
|
||||
typedef uint64_t ULONG64, *PULONG64;
|
||||
typedef wchar_t WCHAR, *PWSTR;
|
||||
typedef uint8_t UCHAR, *PUCHAR;
|
||||
typedef uint64_t ULONG_PTR, *PULONG_PTR;
|
||||
typedef uint64_t UINT_PTR, *PUINT_PTR;
|
||||
typedef int64_t INT_PTR, *PINT_PTR;
|
||||
|
||||
// Note: WCHAR is not the same between Windows and Linux, to enable
|
||||
// string manipulation APIs to work with resulting strings.
|
||||
// APIs to D3D/DXCore will work on Linux wchars, but beware with
|
||||
// interactions directly with the Windows kernel.
|
||||
typedef char CHAR, *PSTR, *LPSTR, TCHAR, *PTSTR;
|
||||
typedef const char *LPCSTR, *PCSTR, *LPCTSTR, *PCTSTR;
|
||||
typedef wchar_t WCHAR, *PWSTR, *LPWSTR, *PWCHAR;
|
||||
typedef const wchar_t *LPCWSTR, *PCWSTR;
|
||||
|
||||
#undef LONG_MAX
|
||||
#define LONG_MAX INT_MAX
|
||||
#undef ULONG_MAX
|
||||
#define ULONG_MAX UINT_MAX
|
||||
|
||||
// Misc defines
|
||||
#define MIDL_INTERFACE(x) interface
|
||||
#define __analysis_assume(x)
|
||||
#define TRUE 1u
|
||||
#define FALSE 0u
|
||||
#define DECLSPEC_UUID(x)
|
||||
#define DECLSPEC_NOVTABLE
|
||||
#define DECLSPEC_SELECTANY
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN_C extern "C"
|
||||
#else
|
||||
#define EXTERN_C extern
|
||||
#endif
|
||||
#define APIENTRY
|
||||
#define OUT
|
||||
#define IN
|
||||
#define CONST const
|
||||
#define MAX_PATH 260
|
||||
#define GENERIC_ALL 0x10000000L
|
||||
#define C_ASSERT(expr) static_assert((expr))
|
||||
#define _countof(a) (sizeof(a) / sizeof(*(a)))
|
||||
|
||||
typedef struct tagRECTL
|
||||
{
|
||||
LONG left;
|
||||
LONG top;
|
||||
LONG right;
|
||||
LONG bottom;
|
||||
} RECTL;
|
||||
|
||||
typedef struct tagPOINT
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
} POINT;
|
||||
|
||||
typedef struct _GUID {
|
||||
uint32_t Data1;
|
||||
uint16_t Data2;
|
||||
uint16_t Data3;
|
||||
uint8_t Data4[ 8 ];
|
||||
} GUID;
|
||||
|
||||
#ifdef INITGUID
|
||||
#ifdef __cplusplus
|
||||
#define DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) EXTERN_C const GUID DECLSPEC_SELECTANY name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
|
||||
#else
|
||||
#define DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) const GUID DECLSPEC_SELECTANY name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
|
||||
#endif
|
||||
#else
|
||||
#define DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) EXTERN_C const GUID name
|
||||
#endif
|
||||
|
||||
typedef GUID IID;
|
||||
typedef GUID UUID;
|
||||
typedef GUID CLSID;
|
||||
#ifdef __cplusplus
|
||||
#define REFGUID const GUID &
|
||||
#define REFIID const IID &
|
||||
#define REFCLSID const IID &
|
||||
|
||||
__inline int InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
|
||||
{
|
||||
return (
|
||||
((uint32_t *)&rguid1)[0] == ((uint32_t *)&rguid2)[0] &&
|
||||
((uint32_t *)&rguid1)[1] == ((uint32_t *)&rguid2)[1] &&
|
||||
((uint32_t *)&rguid1)[2] == ((uint32_t *)&rguid2)[2] &&
|
||||
((uint32_t *)&rguid1)[3] == ((uint32_t *)&rguid2)[3]);
|
||||
}
|
||||
|
||||
inline bool operator==(REFGUID guidOne, REFGUID guidOther)
|
||||
{
|
||||
return !!InlineIsEqualGUID(guidOne, guidOther);
|
||||
}
|
||||
|
||||
inline bool operator!=(REFGUID guidOne, REFGUID guidOther)
|
||||
{
|
||||
return !(guidOne == guidOther);
|
||||
}
|
||||
|
||||
#else
|
||||
#define REFGUID const GUID *
|
||||
#define REFIID const IID *
|
||||
#define REFCLSID const IID *
|
||||
#endif
|
||||
|
||||
// SAL annotations
|
||||
#define _In_
|
||||
#define _In_z_
|
||||
#define _In_opt_
|
||||
#define _In_opt_z_
|
||||
#define _In_reads_(x)
|
||||
#define _In_reads_opt_(x)
|
||||
#define _In_reads_bytes_(x)
|
||||
#define _In_reads_bytes_opt_(x)
|
||||
#define _In_range_(x, y)
|
||||
#define _In_bytecount_(x)
|
||||
#define _Out_
|
||||
#define _Out_opt_
|
||||
#define _Outptr_
|
||||
#define _Outptr_opt_result_z_
|
||||
#define _Outptr_opt_result_bytebuffer_(x)
|
||||
#define _COM_Outptr_
|
||||
#define _COM_Outptr_result_maybenull_
|
||||
#define _COM_Outptr_opt_
|
||||
#define _COM_Outptr_opt_result_maybenull_
|
||||
#define _Out_writes_(x)
|
||||
#define _Out_writes_z_(x)
|
||||
#define _Out_writes_opt_(x)
|
||||
#define _Out_writes_all_(x)
|
||||
#define _Out_writes_all_opt_(x)
|
||||
#define _Out_writes_to_opt_(x, y)
|
||||
#define _Out_writes_bytes_(x)
|
||||
#define _Out_writes_bytes_all_(x)
|
||||
#define _Out_writes_bytes_all_opt_(x)
|
||||
#define _Out_writes_bytes_opt_(x)
|
||||
#define _Inout_
|
||||
#define _Inout_opt_
|
||||
#define _Inout_updates_(x)
|
||||
#define _Inout_updates_bytes_(x)
|
||||
#define _Field_size_(x)
|
||||
#define _Field_size_opt_(x)
|
||||
#define _Field_size_bytes_(x)
|
||||
#define _Field_size_full_(x)
|
||||
#define _Field_size_full_opt_(x)
|
||||
#define _Field_size_bytes_full_(x)
|
||||
#define _Field_size_bytes_full_opt_(x)
|
||||
#define _Field_size_bytes_part_(x, y)
|
||||
#define _Field_range_(x, y)
|
||||
#define _Field_z_
|
||||
#define _Check_return_
|
||||
#define _IRQL_requires_(x)
|
||||
#define _IRQL_requires_min_(x)
|
||||
#define _IRQL_requires_max_(x)
|
||||
#define _At_(x, y)
|
||||
#define _Always_(x)
|
||||
#define _Return_type_success_(x)
|
||||
#define _Translates_Win32_to_HRESULT_(x)
|
||||
#define _Maybenull_
|
||||
#define _Outptr_result_maybenull_
|
||||
#define _Outptr_result_nullonfailure_
|
||||
#define _Analysis_assume_(x)
|
||||
#define _Success_(x)
|
||||
#define _In_count_(x)
|
||||
#define _In_opt_count_(x)
|
||||
#define _Use_decl_annotations_
|
||||
#define _Null_terminated_
|
||||
|
||||
// Calling conventions
|
||||
#define __cdecl
|
||||
#define __stdcall
|
||||
#define STDMETHODCALLTYPE
|
||||
#define STDAPICALLTYPE
|
||||
#define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
|
||||
#define WINAPI
|
||||
|
||||
#define interface struct
|
||||
#if defined (__cplusplus) && !defined (CINTERFACE)
|
||||
#define STDMETHOD(method) virtual HRESULT STDMETHODCALLTYPE method
|
||||
#define STDMETHOD_(type, method) virtual type STDMETHODCALLTYPE method
|
||||
#define PURE = 0
|
||||
#define THIS_
|
||||
#define THIS void
|
||||
#define DECLARE_INTERFACE(iface) interface DECLSPEC_NOVTABLE iface
|
||||
#define DECLARE_INTERFACE_(iface, baseiface) interface DECLSPEC_NOVTABLE iface : public baseiface
|
||||
|
||||
interface IUnknown;
|
||||
extern "C++"
|
||||
{
|
||||
template<typename T> void** IID_PPV_ARGS_Helper(T** pp)
|
||||
{
|
||||
(void)static_cast<IUnknown*>(*pp);
|
||||
return reinterpret_cast<void**>(pp);
|
||||
}
|
||||
}
|
||||
#define IID_PPV_ARGS(ppType) __uuidof (**(ppType)), IID_PPV_ARGS_Helper (ppType)
|
||||
#else
|
||||
#define STDMETHOD(method) HRESULT (STDMETHODCALLTYPE *method)
|
||||
#define STDMETHOD_(type, method) type (STDMETHODCALLTYPE *method)
|
||||
#define PURE
|
||||
#define THIS_ INTERFACE *This,
|
||||
#define THIS INTERFACE *This
|
||||
#ifdef CONST_VTABLE
|
||||
#define DECLARE_INTERFACE(iface) typedef interface iface { const struct iface##Vtbl *lpVtbl; } iface; typedef const struct iface##Vtbl iface##Vtbl; const struct iface##Vtbl
|
||||
#else
|
||||
#define DECLARE_INTERFACE(iface) typedef interface iface { struct iface##Vtbl *lpVtbl; } iface; typedef struct iface##Vtbl iface##Vtbl; struct iface##Vtbl
|
||||
#endif
|
||||
#define DECLARE_INTERFACE_(iface, baseiface) DECLARE_INTERFACE (iface)
|
||||
#endif
|
||||
|
||||
#define IFACEMETHOD(method) /*override*/ STDMETHOD (method)
|
||||
#define IFACEMETHOD_(type, method) /*override*/ STDMETHOD_(type, method)
|
||||
#ifndef BEGIN_INTERFACE
|
||||
#define BEGIN_INTERFACE
|
||||
#define END_INTERFACE
|
||||
#endif
|
||||
|
||||
// Error codes
|
||||
typedef LONG HRESULT;
|
||||
#define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0)
|
||||
#define FAILED(hr) (((HRESULT)(hr)) < 0)
|
||||
#define S_OK ((HRESULT)0L)
|
||||
#define S_FALSE ((HRESULT)1L)
|
||||
#define E_NOTIMPL ((HRESULT)0x80004001L)
|
||||
#define E_OUTOFMEMORY ((HRESULT)0x8007000EL)
|
||||
#define E_INVALIDARG ((HRESULT)0x80070057L)
|
||||
#define E_NOINTERFACE ((HRESULT)0x80004002L)
|
||||
#define E_POINTER ((HRESULT)0x80004003L)
|
||||
#define E_HANDLE ((HRESULT)0x80070006L)
|
||||
#define E_ABORT ((HRESULT)0x80004004L)
|
||||
#define E_FAIL ((HRESULT)0x80004005L)
|
||||
#define E_ACCESSDENIED ((HRESULT)0x80070005L)
|
||||
#define E_UNEXPECTED ((HRESULT)0x8000FFFFL)
|
||||
#define DXGI_ERROR_INVALID_CALL ((HRESULT)0x887A0001L)
|
||||
#define DXGI_ERROR_NOT_FOUND ((HRESULT)0x887A0002L)
|
||||
#define DXGI_ERROR_MORE_DATA ((HRESULT)0x887A0003L)
|
||||
#define DXGI_ERROR_UNSUPPORTED ((HRESULT)0x887A0004L)
|
||||
#define DXGI_ERROR_DEVICE_REMOVED ((HRESULT)0x887A0005L)
|
||||
#define DXGI_ERROR_DEVICE_HUNG ((HRESULT)0x887A0006L)
|
||||
#define DXGI_ERROR_DEVICE_RESET ((HRESULT)0x887A0007L)
|
||||
#define DXGI_ERROR_DRIVER_INTERNAL_ERROR ((HRESULT)0x887A0020L)
|
||||
|
||||
typedef struct _LUID
|
||||
{
|
||||
ULONG LowPart;
|
||||
LONG HighPart;
|
||||
} LUID;
|
||||
|
||||
typedef struct _RECT
|
||||
{
|
||||
int left;
|
||||
int top;
|
||||
int right;
|
||||
int bottom;
|
||||
} RECT;
|
||||
|
||||
typedef union _LARGE_INTEGER {
|
||||
struct {
|
||||
uint32_t LowPart;
|
||||
uint32_t HighPart;
|
||||
} u;
|
||||
int64_t QuadPart;
|
||||
} LARGE_INTEGER;
|
||||
typedef LARGE_INTEGER *PLARGE_INTEGER;
|
||||
|
||||
typedef union _ULARGE_INTEGER {
|
||||
struct {
|
||||
uint32_t LowPart;
|
||||
uint32_t HighPart;
|
||||
} u;
|
||||
uint64_t QuadPart;
|
||||
} ULARGE_INTEGER;
|
||||
typedef ULARGE_INTEGER *PULARGE_INTEGER;
|
||||
|
||||
#define DECLARE_HANDLE(name) \
|
||||
struct name##__ { \
|
||||
int unused; \
|
||||
}; \
|
||||
typedef struct name##__ *name
|
||||
|
||||
typedef struct _SECURITY_ATTRIBUTES {
|
||||
DWORD nLength;
|
||||
LPVOID lpSecurityDescriptor;
|
||||
WINBOOL bInheritHandle;
|
||||
} SECURITY_ATTRIBUTES;
|
||||
|
||||
struct STATSTG;
|
||||
|
||||
#ifdef __cplusplus
|
||||
// ENUM_FLAG_OPERATORS
|
||||
// Define operator overloads to enable bit operations on enum values that are
|
||||
// used to define flags. Use DEFINE_ENUM_FLAG_OPERATORS(YOUR_TYPE) to enable these
|
||||
// operators on YOUR_TYPE.
|
||||
extern "C++" {
|
||||
template <size_t S>
|
||||
struct _ENUM_FLAG_INTEGER_FOR_SIZE;
|
||||
|
||||
template <>
|
||||
struct _ENUM_FLAG_INTEGER_FOR_SIZE<1>
|
||||
{
|
||||
typedef int8_t type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct _ENUM_FLAG_INTEGER_FOR_SIZE<2>
|
||||
{
|
||||
typedef int16_t type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct _ENUM_FLAG_INTEGER_FOR_SIZE<4>
|
||||
{
|
||||
typedef int32_t type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct _ENUM_FLAG_INTEGER_FOR_SIZE<8>
|
||||
{
|
||||
typedef int64_t type;
|
||||
};
|
||||
|
||||
// used as an approximation of std::underlying_type<T>
|
||||
template <class T>
|
||||
struct _ENUM_FLAG_SIZED_INTEGER
|
||||
{
|
||||
typedef typename _ENUM_FLAG_INTEGER_FOR_SIZE<sizeof(T)>::type type;
|
||||
};
|
||||
|
||||
}
|
||||
#define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \
|
||||
extern "C++" { \
|
||||
inline constexpr ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) | ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
|
||||
inline ENUMTYPE &operator |= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) |= ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
|
||||
inline constexpr ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) & ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
|
||||
inline ENUMTYPE &operator &= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) &= ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
|
||||
inline constexpr ENUMTYPE operator ~ (ENUMTYPE a) { return ENUMTYPE(~((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a)); } \
|
||||
inline constexpr ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) ^ ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
|
||||
inline ENUMTYPE &operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) ^= ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
|
||||
}
|
||||
#else
|
||||
#define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) /* */
|
||||
#endif
|
||||
|
||||
// D3DX12 uses these
|
||||
#include <stdlib.h>
|
||||
#define HeapAlloc(heap, flags, size) malloc(size)
|
||||
#define HeapFree(heap, flags, ptr) free(ptr)
|
||||
|
||||
#if defined(lint)
|
||||
// Note: lint -e530 says don't complain about uninitialized variables for
|
||||
// this variable. Error 527 has to do with unreachable code.
|
||||
// -restore restores checking to the -save state
|
||||
#define UNREFERENCED_PARAMETER(P) \
|
||||
/*lint -save -e527 -e530 */ \
|
||||
{ \
|
||||
(P) = (P); \
|
||||
} \
|
||||
/*lint -restore */
|
||||
#else
|
||||
#define UNREFERENCED_PARAMETER(P) (P)
|
||||
#endif
|
@ -0,0 +1,5 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// Stub header to satisfy d3d12.h include
|
||||
#pragma once
|
@ -0,0 +1,5 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// Stub header to satisfy d3d12.h include
|
||||
#pragma once
|
@ -0,0 +1,5 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// Stub header to satisfy d3d12.h include
|
||||
#pragma once
|
@ -0,0 +1,78 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// Stub header to satisfy d3d12.h include
|
||||
#pragma once
|
||||
|
||||
#include "basetsd.h"
|
||||
|
||||
#define __RPCNDR_H_VERSION__
|
||||
|
||||
#ifdef CONST_VTABLE
|
||||
#define CONST_VTBL const
|
||||
#else
|
||||
#define CONST_VTBL
|
||||
#endif
|
||||
|
||||
/* Macros for __uuidof template-based emulation */
|
||||
#if defined(__cplusplus)
|
||||
#if __cpp_constexpr >= 200704l && __cpp_inline_variables >= 201606L
|
||||
#define __wsl_stub_uuidof_use_constexpr 1
|
||||
#else
|
||||
#define __wsl_stub_uuidof_use_constexpr 0
|
||||
#endif
|
||||
#ifndef __GNUC__
|
||||
#error "Only support for compilers that support for `GNU C++ extension`"
|
||||
#endif
|
||||
extern "C++" {
|
||||
#if __wsl_stub_uuidof_use_constexpr
|
||||
__extension__ template<typename T> struct __wsl_stub_uuidof_s;
|
||||
__extension__ template<typename T> constexpr const GUID &__wsl_stub_uuidof();
|
||||
#else
|
||||
__extension__ template<typename T> const GUID &__wsl_stub_uuidof();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if __wsl_stub_uuidof_use_constexpr
|
||||
#define __CRT_UUID_DECL(type, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
|
||||
extern "C++" \
|
||||
{ \
|
||||
template <> \
|
||||
struct __wsl_stub_uuidof_s<type> \
|
||||
{ \
|
||||
static constexpr IID __uuid_inst = { \
|
||||
l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}; \
|
||||
}; \
|
||||
template <> \
|
||||
constexpr const GUID &__wsl_stub_uuidof<type>() \
|
||||
{ \
|
||||
return __wsl_stub_uuidof_s<type>::__uuid_inst; \
|
||||
} \
|
||||
template <> \
|
||||
constexpr const GUID &__wsl_stub_uuidof<type *>() \
|
||||
{ \
|
||||
return __wsl_stub_uuidof_s<type>::__uuid_inst; \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define __CRT_UUID_DECL(type, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
|
||||
extern "C++" \
|
||||
{ \
|
||||
template <> \
|
||||
inline const GUID &__wsl_stub_uuidof<type>() \
|
||||
{ \
|
||||
static const IID __uuid_inst = { \
|
||||
l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}; \
|
||||
return __uuid_inst; \
|
||||
} \
|
||||
template <> \
|
||||
inline const GUID &__wsl_stub_uuidof<type *>() \
|
||||
{ \
|
||||
return __wsl_stub_uuidof<type>(); \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
#define __uuidof(type) __wsl_stub_uuidof<__typeof(type)>()
|
||||
#else
|
||||
#define __CRT_UUID_DECL(type, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
|
||||
#endif
|
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "unknwnbase.h"
|
@ -0,0 +1,124 @@
|
||||
/*-------------------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) Microsoft Corporation
|
||||
* Licensed under the MIT license
|
||||
*
|
||||
*-------------------------------------------------------------------------------------*/
|
||||
|
||||
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
|
||||
|
||||
/* File created by MIDL compiler version 8.01.0627 */
|
||||
|
||||
/* verify that the <rpcndr.h> version is high enough to compile this file*/
|
||||
#ifndef __REQUIRED_RPCNDR_H_VERSION__
|
||||
#define __REQUIRED_RPCNDR_H_VERSION__ 500
|
||||
#endif
|
||||
|
||||
/* verify that the <rpcsal.h> version is high enough to compile this file*/
|
||||
#ifndef __REQUIRED_RPCSAL_H_VERSION__
|
||||
#define __REQUIRED_RPCSAL_H_VERSION__ 100
|
||||
#endif
|
||||
|
||||
#include "rpc.h"
|
||||
#include "rpcndr.h"
|
||||
|
||||
#ifndef __RPCNDR_H_VERSION__
|
||||
#error this stub requires an updated version of <rpcndr.h>
|
||||
#endif /* __RPCNDR_H_VERSION__ */
|
||||
|
||||
#ifndef COM_NO_WINDOWS_H
|
||||
#include "windows.h"
|
||||
#include "ole2.h"
|
||||
#endif /*COM_NO_WINDOWS_H*/
|
||||
|
||||
#ifndef __unknwnbase_h__
|
||||
#define __unknwnbase_h__
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
/* Forward Declarations */
|
||||
|
||||
#ifndef __IUnknown_FWD_DEFINED__
|
||||
#define __IUnknown_FWD_DEFINED__
|
||||
typedef interface IUnknown IUnknown;
|
||||
|
||||
#endif /* __IUnknown_FWD_DEFINED__ */
|
||||
|
||||
#ifndef __IUnknown_INTERFACE_DEFINED__
|
||||
#define __IUnknown_INTERFACE_DEFINED__
|
||||
|
||||
/* interface IUnknown */
|
||||
/* [unique][uuid][object][local] */
|
||||
|
||||
typedef /* [unique] */ IUnknown *LPUNKNOWN;
|
||||
|
||||
EXTERN_C const IID IID_IUnknown;
|
||||
|
||||
#if defined(__cplusplus) && !defined(CINTERFACE)
|
||||
extern "C++"
|
||||
{
|
||||
MIDL_INTERFACE("00000000-0000-0000-c000-000000000046")
|
||||
IUnknown
|
||||
{
|
||||
BEGIN_INTERFACE
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE QueryInterface(
|
||||
REFIID riid,
|
||||
void **ppvObject) = 0;
|
||||
|
||||
virtual ULONG STDMETHODCALLTYPE AddRef() = 0;
|
||||
|
||||
virtual ULONG STDMETHODCALLTYPE Release() = 0;
|
||||
|
||||
template <class Q>
|
||||
HRESULT
|
||||
STDMETHODCALLTYPE
|
||||
QueryInterface(_COM_Outptr_ Q * *pp)
|
||||
{
|
||||
return QueryInterface(__uuidof(Q), (void **)pp);
|
||||
}
|
||||
END_INTERFACE
|
||||
};
|
||||
}
|
||||
#ifdef __CRT_UUID_DECL
|
||||
__CRT_UUID_DECL(IUnknown, 0x00000000, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46)
|
||||
#endif
|
||||
#else
|
||||
typedef struct IUnknownVtbl {
|
||||
BEGIN_INTERFACE
|
||||
|
||||
/*** IUnknown methods ***/
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(
|
||||
IUnknown *This,
|
||||
REFIID riid,
|
||||
void **ppvObject);
|
||||
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(
|
||||
IUnknown *This);
|
||||
|
||||
ULONG (STDMETHODCALLTYPE *Release)(
|
||||
IUnknown *This);
|
||||
|
||||
END_INTERFACE
|
||||
} IUnknownVtbl;
|
||||
|
||||
interface IUnknown {
|
||||
CONST_VTBL IUnknownVtbl* lpVtbl;
|
||||
};
|
||||
|
||||
#ifdef COBJMACROS
|
||||
/*** IUnknown methods ***/
|
||||
#define IUnknown_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject)
|
||||
#define IUnknown_AddRef(This) (This)->lpVtbl->AddRef(This)
|
||||
#define IUnknown_Release(This) (This)->lpVtbl->Release(This)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* __IUnknown_INTERFACE_DEFINED__ */
|
||||
|
||||
DEFINE_GUID(IID_IUnknown, 0x00000000, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46);
|
||||
|
||||
#endif /* __unknwnbase_h__ */
|
@ -0,0 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// Stub header to satisfy d3d12.h include. Unconditionally light up all APIs.
|
||||
#pragma once
|
||||
#define WINAPI_FAMILY_PARTITION(Partitions) 1
|
@ -0,0 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// Stub to satisfy d3dx12.h include
|
||||
#pragma once
|
||||
#include <wsl/wrladapter.h>
|
@ -0,0 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// Stub to satisfy DML TF runtime includes
|
||||
#pragma once
|
||||
#include <wsl/wrladapter.h>
|
@ -0,0 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <unknwn.h>
|
803
EscapeTheBackroomsGUiTest/vcpkg_Out/include/wsl/wrladapter.h
Normal file
803
EscapeTheBackroomsGUiTest/vcpkg_Out/include/wsl/wrladapter.h
Normal file
@ -0,0 +1,803 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "winadapter.h"
|
||||
|
||||
// defined by winadapter.h and needed by some windows headers, but conflicts
|
||||
// with some libc++ implementation headers
|
||||
#ifdef __in
|
||||
#undef __in
|
||||
#endif
|
||||
#ifdef __out
|
||||
#undef __out
|
||||
#endif
|
||||
|
||||
#include <type_traits>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <new>
|
||||
#include <climits>
|
||||
#include <cassert>
|
||||
|
||||
namespace Microsoft
|
||||
{
|
||||
namespace WRL
|
||||
{
|
||||
namespace Details
|
||||
{
|
||||
struct BoolStruct { int Member; };
|
||||
typedef int BoolStruct::* BoolType;
|
||||
|
||||
template <typename T> // T should be the ComPtr<T> or a derived type of it, not just the interface
|
||||
class ComPtrRefBase
|
||||
{
|
||||
public:
|
||||
typedef typename T::InterfaceType InterfaceType;
|
||||
|
||||
operator IUnknown**() const throw()
|
||||
{
|
||||
static_assert(__is_base_of(IUnknown, InterfaceType), "Invalid cast: InterfaceType does not derive from IUnknown");
|
||||
return reinterpret_cast<IUnknown**>(ptr_->ReleaseAndGetAddressOf());
|
||||
}
|
||||
|
||||
protected:
|
||||
T* ptr_;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class ComPtrRef : public Details::ComPtrRefBase<T> // T should be the ComPtr<T> or a derived type of it, not just the interface
|
||||
{
|
||||
using Super = Details::ComPtrRefBase<T>;
|
||||
using InterfaceType = typename Super::InterfaceType;
|
||||
public:
|
||||
ComPtrRef(_In_opt_ T* ptr) throw()
|
||||
{
|
||||
this->ptr_ = ptr;
|
||||
}
|
||||
|
||||
// Conversion operators
|
||||
operator void**() const throw()
|
||||
{
|
||||
return reinterpret_cast<void**>(this->ptr_->ReleaseAndGetAddressOf());
|
||||
}
|
||||
|
||||
// This is our operator ComPtr<U> (or the latest derived class from ComPtr (e.g. WeakRef))
|
||||
operator T*() throw()
|
||||
{
|
||||
*this->ptr_ = nullptr;
|
||||
return this->ptr_;
|
||||
}
|
||||
|
||||
// We define operator InterfaceType**() here instead of on ComPtrRefBase<T>, since
|
||||
// if InterfaceType is IUnknown or IInspectable, having it on the base will collide.
|
||||
operator InterfaceType**() throw()
|
||||
{
|
||||
return this->ptr_->ReleaseAndGetAddressOf();
|
||||
}
|
||||
|
||||
// This is used for IID_PPV_ARGS in order to do __uuidof(**(ppType)).
|
||||
// It does not need to clear ptr_ at this point, it is done at IID_PPV_ARGS_Helper(ComPtrRef&) later in this file.
|
||||
InterfaceType* operator *() throw()
|
||||
{
|
||||
return this->ptr_->Get();
|
||||
}
|
||||
|
||||
// Explicit functions
|
||||
InterfaceType* const * GetAddressOf() const throw()
|
||||
{
|
||||
return this->ptr_->GetAddressOf();
|
||||
}
|
||||
|
||||
InterfaceType** ReleaseAndGetAddressOf() throw()
|
||||
{
|
||||
return this->ptr_->ReleaseAndGetAddressOf();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
class ComPtr
|
||||
{
|
||||
public:
|
||||
typedef T InterfaceType;
|
||||
|
||||
protected:
|
||||
InterfaceType *ptr_;
|
||||
template<class U> friend class ComPtr;
|
||||
|
||||
void InternalAddRef() const throw()
|
||||
{
|
||||
if (ptr_ != nullptr)
|
||||
{
|
||||
ptr_->AddRef();
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long InternalRelease() throw()
|
||||
{
|
||||
unsigned long ref = 0;
|
||||
T* temp = ptr_;
|
||||
|
||||
if (temp != nullptr)
|
||||
{
|
||||
ptr_ = nullptr;
|
||||
ref = temp->Release();
|
||||
}
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
public:
|
||||
ComPtr() throw() : ptr_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
ComPtr(decltype(nullptr)) throw() : ptr_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
template<class U>
|
||||
ComPtr(_In_opt_ U *other) throw() : ptr_(other)
|
||||
{
|
||||
InternalAddRef();
|
||||
}
|
||||
|
||||
ComPtr(const ComPtr& other) throw() : ptr_(other.ptr_)
|
||||
{
|
||||
InternalAddRef();
|
||||
}
|
||||
|
||||
// copy constructor that allows to instantiate class when U* is convertible to T*
|
||||
template<class U>
|
||||
ComPtr(const ComPtr<U> &other, typename std::enable_if<std::is_convertible<U*, T*>::value, void *>::type * = 0) throw() :
|
||||
ptr_(other.ptr_)
|
||||
{
|
||||
InternalAddRef();
|
||||
}
|
||||
|
||||
ComPtr(_Inout_ ComPtr &&other) throw() : ptr_(nullptr)
|
||||
{
|
||||
if (this != reinterpret_cast<ComPtr*>(&reinterpret_cast<unsigned char&>(other)))
|
||||
{
|
||||
Swap(other);
|
||||
}
|
||||
}
|
||||
|
||||
// Move constructor that allows instantiation of a class when U* is convertible to T*
|
||||
template<class U>
|
||||
ComPtr(_Inout_ ComPtr<U>&& other, typename std::enable_if<std::is_convertible<U*, T*>::value, void *>::type * = 0) throw() :
|
||||
ptr_(other.ptr_)
|
||||
{
|
||||
other.ptr_ = nullptr;
|
||||
}
|
||||
|
||||
~ComPtr() throw()
|
||||
{
|
||||
InternalRelease();
|
||||
}
|
||||
|
||||
ComPtr& operator=(decltype(nullptr)) throw()
|
||||
{
|
||||
InternalRelease();
|
||||
return *this;
|
||||
}
|
||||
|
||||
ComPtr& operator=(_In_opt_ T *other) throw()
|
||||
{
|
||||
if (ptr_ != other)
|
||||
{
|
||||
ComPtr(other).Swap(*this);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
ComPtr& operator=(_In_opt_ U *other) throw()
|
||||
{
|
||||
ComPtr(other).Swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ComPtr& operator=(const ComPtr &other) throw()
|
||||
{
|
||||
if (ptr_ != other.ptr_)
|
||||
{
|
||||
ComPtr(other).Swap(*this);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class U>
|
||||
ComPtr& operator=(const ComPtr<U>& other) throw()
|
||||
{
|
||||
ComPtr(other).Swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ComPtr& operator=(_Inout_ ComPtr &&other) throw()
|
||||
{
|
||||
ComPtr(static_cast<ComPtr&&>(other)).Swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class U>
|
||||
ComPtr& operator=(_Inout_ ComPtr<U>&& other) throw()
|
||||
{
|
||||
ComPtr(static_cast<ComPtr<U>&&>(other)).Swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Swap(_Inout_ ComPtr&& r) throw()
|
||||
{
|
||||
T* tmp = ptr_;
|
||||
ptr_ = r.ptr_;
|
||||
r.ptr_ = tmp;
|
||||
}
|
||||
|
||||
void Swap(_Inout_ ComPtr& r) throw()
|
||||
{
|
||||
T* tmp = ptr_;
|
||||
ptr_ = r.ptr_;
|
||||
r.ptr_ = tmp;
|
||||
}
|
||||
|
||||
operator Details::BoolType() const throw()
|
||||
{
|
||||
return Get() != nullptr ? &Details::BoolStruct::Member : nullptr;
|
||||
}
|
||||
|
||||
T* Get() const throw()
|
||||
{
|
||||
return ptr_;
|
||||
}
|
||||
|
||||
InterfaceType* operator->() const throw()
|
||||
{
|
||||
return ptr_;
|
||||
}
|
||||
|
||||
Details::ComPtrRef<ComPtr<T>> operator&() throw()
|
||||
{
|
||||
return Details::ComPtrRef<ComPtr<T>>(this);
|
||||
}
|
||||
|
||||
const Details::ComPtrRef<const ComPtr<T>> operator&() const throw()
|
||||
{
|
||||
return Details::ComPtrRef<const ComPtr<T>>(this);
|
||||
}
|
||||
|
||||
T* const* GetAddressOf() const throw()
|
||||
{
|
||||
return &ptr_;
|
||||
}
|
||||
|
||||
T** GetAddressOf() throw()
|
||||
{
|
||||
return &ptr_;
|
||||
}
|
||||
|
||||
T** ReleaseAndGetAddressOf() throw()
|
||||
{
|
||||
InternalRelease();
|
||||
return &ptr_;
|
||||
}
|
||||
|
||||
T* Detach() throw()
|
||||
{
|
||||
T* ptr = ptr_;
|
||||
ptr_ = nullptr;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void Attach(_In_opt_ InterfaceType* other) throw()
|
||||
{
|
||||
if (ptr_ != nullptr)
|
||||
{
|
||||
auto ref = ptr_->Release();
|
||||
// DBG_UNREFERENCED_LOCAL_VARIABLE(ref);
|
||||
// Attaching to the same object only works if duplicate references are being coalesced. Otherwise
|
||||
// re-attaching will cause the pointer to be released and may cause a crash on a subsequent dereference.
|
||||
assert(ref != 0 || ptr_ != other);
|
||||
}
|
||||
|
||||
ptr_ = other;
|
||||
}
|
||||
|
||||
unsigned long Reset()
|
||||
{
|
||||
return InternalRelease();
|
||||
}
|
||||
|
||||
// Previously, unsafe behavior could be triggered when 'this' is ComPtr<IInspectable> or ComPtr<IUnknown> and CopyTo is used to copy to another type U.
|
||||
// The user will use operator& to convert the destination into a ComPtrRef, which can then implicit cast to IInspectable** and IUnknown**.
|
||||
// If this overload of CopyTo is not present, it will implicitly cast to IInspectable or IUnknown and match CopyTo(InterfaceType**) instead.
|
||||
// A valid polymoprhic downcast requires run-time type checking via QueryInterface, so CopyTo(InterfaceType**) will break type safety.
|
||||
// This overload matches ComPtrRef before the implicit cast takes place, preventing the unsafe downcast.
|
||||
template <typename U>
|
||||
HRESULT CopyTo(Details::ComPtrRef<ComPtr<U>> ptr, typename std::enable_if<
|
||||
(std::is_same<T, IUnknown>::value)
|
||||
&& !std::is_same<U*, T*>::value, void *>::type * = 0) const throw()
|
||||
{
|
||||
return ptr_->QueryInterface(__uuidof(U), ptr);
|
||||
}
|
||||
|
||||
HRESULT CopyTo(_Outptr_result_maybenull_ InterfaceType** ptr) const throw()
|
||||
{
|
||||
InternalAddRef();
|
||||
*ptr = ptr_;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CopyTo(REFIID riid, _Outptr_result_nullonfailure_ void** ptr) const throw()
|
||||
{
|
||||
return ptr_->QueryInterface(riid, ptr);
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
HRESULT CopyTo(_Outptr_result_nullonfailure_ U** ptr) const throw()
|
||||
{
|
||||
return ptr_->QueryInterface(__uuidof(U), reinterpret_cast<void**>(ptr));
|
||||
}
|
||||
|
||||
// query for U interface
|
||||
template<typename U>
|
||||
HRESULT As(_Inout_ Details::ComPtrRef<ComPtr<U>> p) const throw()
|
||||
{
|
||||
return ptr_->QueryInterface(__uuidof(U), p);
|
||||
}
|
||||
|
||||
// query for U interface
|
||||
template<typename U>
|
||||
HRESULT As(_Out_ ComPtr<U>* p) const throw()
|
||||
{
|
||||
return ptr_->QueryInterface(__uuidof(U), reinterpret_cast<void**>(p->ReleaseAndGetAddressOf()));
|
||||
}
|
||||
|
||||
// query for riid interface and return as IUnknown
|
||||
HRESULT AsIID(REFIID riid, _Out_ ComPtr<IUnknown>* p) const throw()
|
||||
{
|
||||
return ptr_->QueryInterface(riid, reinterpret_cast<void**>(p->ReleaseAndGetAddressOf()));
|
||||
}
|
||||
|
||||
}; // ComPtr
|
||||
|
||||
|
||||
namespace Details
|
||||
{
|
||||
// Empty struct used as default template parameter
|
||||
class Nil
|
||||
{
|
||||
};
|
||||
|
||||
// Empty struct used for validating template parameter types in Implements
|
||||
struct ImplementsBase
|
||||
{
|
||||
};
|
||||
|
||||
class RuntimeClassBase
|
||||
{
|
||||
protected:
|
||||
template<typename T>
|
||||
static HRESULT AsIID(_In_ T* implements, REFIID riid, _Outptr_result_nullonfailure_ void **ppvObject) noexcept
|
||||
{
|
||||
*ppvObject = nullptr;
|
||||
bool isRefDelegated = false;
|
||||
// Prefer InlineIsEqualGUID over other forms since it's better perf on 4-byte aligned data, which is almost always the case.
|
||||
if (InlineIsEqualGUID(riid, __uuidof(IUnknown)))
|
||||
{
|
||||
*ppvObject = implements->CastToUnknown();
|
||||
static_cast<IUnknown*>(*ppvObject)->AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT hr = implements->CanCastTo(riid, ppvObject, &isRefDelegated);
|
||||
if (SUCCEEDED(hr) && !isRefDelegated)
|
||||
{
|
||||
static_cast<IUnknown*>(*ppvObject)->AddRef();
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 6102) // '*ppvObject' is used but may not be initialized
|
||||
#endif
|
||||
_Analysis_assume_(SUCCEEDED(hr) || (*ppvObject == nullptr));
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
return hr;
|
||||
}
|
||||
|
||||
public:
|
||||
HRESULT RuntimeClassInitialize() noexcept
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
};
|
||||
|
||||
// Interface traits provides casting and filling iids methods helpers
|
||||
template<typename I0>
|
||||
struct InterfaceTraits
|
||||
{
|
||||
typedef I0 Base;
|
||||
|
||||
template<typename T>
|
||||
static Base* CastToBase(_In_ T* ptr) noexcept
|
||||
{
|
||||
return static_cast<Base*>(ptr);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static IUnknown* CastToUnknown(_In_ T* ptr) noexcept
|
||||
{
|
||||
return static_cast<IUnknown*>(static_cast<Base*>(ptr));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
_Success_(return == true)
|
||||
static bool CanCastTo(_In_ T* ptr, REFIID riid, _Outptr_ void **ppv) noexcept
|
||||
{
|
||||
// Prefer InlineIsEqualGUID over other forms since it's better perf on 4-byte aligned data, which is almost always the case.
|
||||
if (InlineIsEqualGUID(riid, __uuidof(Base)))
|
||||
{
|
||||
*ppv = static_cast<Base*>(ptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// Specialization for Nil parameter
|
||||
template<>
|
||||
struct InterfaceTraits<Nil>
|
||||
{
|
||||
typedef Nil Base;
|
||||
|
||||
template <typename T>
|
||||
_Success_(return == true)
|
||||
static bool CanCastTo(_In_ T*, REFIID, _Outptr_ void **) noexcept
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// ChainInterfaces - template allows specifying a derived COM interface along with its class hierarchy to allow QI for the base interfaces
|
||||
template <typename I0, typename I1, typename I2 = Nil, typename I3 = Nil,
|
||||
typename I4 = Nil, typename I5 = Nil, typename I6 = Nil,
|
||||
typename I7 = Nil, typename I8 = Nil, typename I9 = Nil>
|
||||
struct ChainInterfaces : I0
|
||||
{
|
||||
protected:
|
||||
HRESULT CanCastTo(REFIID riid, _Outptr_ void **ppv) throw()
|
||||
{
|
||||
typename InterfaceTraits<I0>::Base* ptr = InterfaceTraits<I0>::CastToBase(this);
|
||||
|
||||
return (InterfaceTraits<I0>::CanCastTo(this, riid, ppv) ||
|
||||
InterfaceTraits<I1>::CanCastTo(ptr, riid, ppv) ||
|
||||
InterfaceTraits<I2>::CanCastTo(ptr, riid, ppv) ||
|
||||
InterfaceTraits<I3>::CanCastTo(ptr, riid, ppv) ||
|
||||
InterfaceTraits<I4>::CanCastTo(ptr, riid, ppv) ||
|
||||
InterfaceTraits<I5>::CanCastTo(ptr, riid, ppv) ||
|
||||
InterfaceTraits<I6>::CanCastTo(ptr, riid, ppv) ||
|
||||
InterfaceTraits<I7>::CanCastTo(ptr, riid, ppv) ||
|
||||
InterfaceTraits<I8>::CanCastTo(ptr, riid, ppv) ||
|
||||
InterfaceTraits<I9>::CanCastTo(ptr, riid, ppv)) ? S_OK : E_NOINTERFACE;
|
||||
}
|
||||
|
||||
IUnknown* CastToUnknown() throw()
|
||||
{
|
||||
return InterfaceTraits<I0>::CastToUnknown(this);
|
||||
}
|
||||
};
|
||||
|
||||
// Helper template used by Implements. This template traverses a list of interfaces and adds them as base class and information
|
||||
// to enable QI.
|
||||
template <typename ...TInterfaces>
|
||||
struct ImplementsHelper;
|
||||
|
||||
template <typename T>
|
||||
struct ImplementsMarker
|
||||
{};
|
||||
|
||||
template <typename I0, bool isImplements>
|
||||
struct MarkImplements;
|
||||
|
||||
template <typename I0>
|
||||
struct MarkImplements<I0, false>
|
||||
{
|
||||
typedef I0 Type;
|
||||
};
|
||||
|
||||
template <typename I0>
|
||||
struct MarkImplements<I0, true>
|
||||
{
|
||||
typedef ImplementsMarker<I0> Type;
|
||||
};
|
||||
|
||||
// AdjustImplements pre-processes the type list for more efficient builds.
|
||||
template <typename ...Bases>
|
||||
struct AdjustImplements;
|
||||
|
||||
template <typename I0, typename ...Bases>
|
||||
struct AdjustImplements<I0, Bases...>
|
||||
{
|
||||
typedef ImplementsHelper<typename MarkImplements<I0, std::is_base_of<ImplementsBase, I0>::value>::Type, Bases...> Type;
|
||||
};
|
||||
|
||||
// Use AdjustImplements to remove instances of "Nil" from the type list.
|
||||
template <typename ...Bases>
|
||||
struct AdjustImplements<Nil, Bases...>
|
||||
{
|
||||
typedef typename AdjustImplements<Bases...>::Type Type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct AdjustImplements<>
|
||||
{
|
||||
typedef ImplementsHelper<> Type;
|
||||
};
|
||||
|
||||
// Specialization handles unadorned interfaces
|
||||
template <typename I0, typename ...TInterfaces>
|
||||
struct ImplementsHelper<I0, TInterfaces...> :
|
||||
I0,
|
||||
AdjustImplements<TInterfaces...>::Type
|
||||
{
|
||||
template <typename ...> friend struct ImplementsHelper;
|
||||
friend class RuntimeClassBase;
|
||||
|
||||
protected:
|
||||
|
||||
HRESULT CanCastTo(REFIID riid, _Outptr_ void **ppv, bool *pRefDelegated = nullptr) noexcept
|
||||
{
|
||||
// Prefer InlineIsEqualGUID over other forms since it's better perf on 4-byte aligned data, which is almost always the case.
|
||||
if (InlineIsEqualGUID(riid, __uuidof(I0)))
|
||||
{
|
||||
*ppv = reinterpret_cast<I0*>(reinterpret_cast<void*>(this));
|
||||
return S_OK;
|
||||
}
|
||||
return AdjustImplements<TInterfaces...>::Type::CanCastTo(riid, ppv, pRefDelegated);
|
||||
}
|
||||
|
||||
IUnknown* CastToUnknown() noexcept
|
||||
{
|
||||
return reinterpret_cast<I0*>(reinterpret_cast<void*>(this));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Selector is used to "tag" base interfaces to be used in casting, since a runtime class may indirectly derive from
|
||||
// the same interface or Implements<> template multiple times
|
||||
template <typename base, typename disciminator>
|
||||
struct Selector : public base
|
||||
{
|
||||
};
|
||||
|
||||
// Specialization handles types that derive from ImplementsHelper (e.g. nested Implements).
|
||||
template <typename I0, typename ...TInterfaces>
|
||||
struct ImplementsHelper<ImplementsMarker<I0>, TInterfaces...> :
|
||||
Selector<I0, ImplementsHelper<ImplementsMarker<I0>, TInterfaces...>>,
|
||||
Selector<typename AdjustImplements<TInterfaces...>::Type, ImplementsHelper<ImplementsMarker<I0>, TInterfaces...>>
|
||||
{
|
||||
template <typename ...> friend struct ImplementsHelper;
|
||||
friend class RuntimeClassBase;
|
||||
|
||||
protected:
|
||||
typedef Selector<I0, ImplementsHelper<ImplementsMarker<I0>, TInterfaces...>> CurrentType;
|
||||
typedef Selector<typename AdjustImplements<TInterfaces...>::Type, ImplementsHelper<ImplementsMarker<I0>, TInterfaces...>> BaseType;
|
||||
|
||||
HRESULT CanCastTo(REFIID riid, _Outptr_ void **ppv, bool *pRefDelegated = nullptr) noexcept
|
||||
{
|
||||
HRESULT hr = CurrentType::CanCastTo(riid, ppv);
|
||||
if (hr == E_NOINTERFACE)
|
||||
{
|
||||
hr = BaseType::CanCastTo(riid, ppv, pRefDelegated);
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
||||
IUnknown* CastToUnknown() noexcept
|
||||
{
|
||||
// First in list wins.
|
||||
return CurrentType::CastToUnknown();
|
||||
}
|
||||
};
|
||||
|
||||
// terminal case specialization.
|
||||
template <>
|
||||
struct ImplementsHelper<>
|
||||
{
|
||||
template <typename ...> friend struct ImplementsHelper;
|
||||
friend class RuntimeClassBase;
|
||||
|
||||
protected:
|
||||
HRESULT CanCastTo(_In_ REFIID /*riid*/, _Outptr_ void ** /*ppv*/, bool * /*pRefDelegated*/ = nullptr) noexcept
|
||||
{
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
// IUnknown* CastToUnknown() noexcept; // not defined for terminal case.
|
||||
};
|
||||
|
||||
// Specialization handles chaining interfaces
|
||||
template <typename C0, typename C1, typename C2, typename C3, typename C4, typename C5, typename C6, typename C7, typename C8, typename C9, typename ...TInterfaces>
|
||||
struct ImplementsHelper<ChainInterfaces<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>, TInterfaces...> :
|
||||
ChainInterfaces<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>,
|
||||
AdjustImplements<TInterfaces...>::Type
|
||||
{
|
||||
template <typename ...> friend struct ImplementsHelper;
|
||||
friend class RuntimeClassBase;
|
||||
|
||||
protected:
|
||||
typedef typename AdjustImplements<TInterfaces...>::Type BaseType;
|
||||
|
||||
HRESULT CanCastTo(REFIID riid, _Outptr_ void **ppv, bool *pRefDelegated = nullptr) noexcept
|
||||
{
|
||||
HRESULT hr = ChainInterfaces<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>::CanCastTo(riid, ppv);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
hr = BaseType::CanCastTo(riid, ppv, pRefDelegated);
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
IUnknown* CastToUnknown() noexcept
|
||||
{
|
||||
return ChainInterfaces<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>::CastToUnknown();
|
||||
}
|
||||
};
|
||||
|
||||
// Implements - template implementing QI using the information provided through its template parameters
|
||||
// Each template parameter has to be one of the following:
|
||||
// * COM Interface
|
||||
// * A class that implements one or more COM interfaces
|
||||
// * ChainInterfaces template
|
||||
template <typename I0, typename ...TInterfaces>
|
||||
struct Implements :
|
||||
AdjustImplements<I0, TInterfaces...>::Type,
|
||||
ImplementsBase
|
||||
{
|
||||
public:
|
||||
typedef I0 FirstInterface;
|
||||
protected:
|
||||
typedef typename AdjustImplements<I0, TInterfaces...>::Type BaseType;
|
||||
template <typename ...> friend struct ImplementsHelper;
|
||||
friend class RuntimeClassBase;
|
||||
|
||||
HRESULT CanCastTo(REFIID riid, _Outptr_ void **ppv) noexcept
|
||||
{
|
||||
return BaseType::CanCastTo(riid, ppv);
|
||||
}
|
||||
|
||||
IUnknown* CastToUnknown() noexcept
|
||||
{
|
||||
return BaseType::CastToUnknown();
|
||||
}
|
||||
};
|
||||
|
||||
// Used on RuntimeClass to protect it from being constructed with new
|
||||
class DontUseNewUseMake
|
||||
{
|
||||
private:
|
||||
void* operator new(size_t) noexcept
|
||||
{
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public:
|
||||
void* operator new(size_t, _In_ void* placement) noexcept
|
||||
{
|
||||
return placement;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename ...TInterfaces>
|
||||
class RuntimeClassImpl :
|
||||
public AdjustImplements<TInterfaces...>::Type,
|
||||
public RuntimeClassBase,
|
||||
public DontUseNewUseMake
|
||||
{
|
||||
public:
|
||||
STDMETHOD(QueryInterface)(REFIID riid, _Outptr_result_nullonfailure_ void **ppvObject)
|
||||
{
|
||||
return Super::AsIID(this, riid, ppvObject);
|
||||
}
|
||||
|
||||
STDMETHOD_(ULONG, AddRef)()
|
||||
{
|
||||
return InternalAddRef();
|
||||
}
|
||||
|
||||
STDMETHOD_(ULONG, Release)()
|
||||
{
|
||||
ULONG ref = InternalRelease();
|
||||
if (ref == 0)
|
||||
{
|
||||
this->~RuntimeClassImpl();
|
||||
delete[] reinterpret_cast<char*>(this);
|
||||
}
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
protected:
|
||||
using Super = RuntimeClassBase;
|
||||
static const LONG c_lProtectDestruction = -(LONG_MAX / 2);
|
||||
|
||||
RuntimeClassImpl() noexcept = default;
|
||||
|
||||
virtual ~RuntimeClassImpl() noexcept
|
||||
{
|
||||
// Set refcount_ to -(LONG_MAX/2) to protect destruction and
|
||||
// also catch mismatched Release in debug builds
|
||||
refcount_ = static_cast<ULONG>(c_lProtectDestruction);
|
||||
}
|
||||
|
||||
ULONG InternalAddRef() noexcept
|
||||
{
|
||||
return ++refcount_;
|
||||
}
|
||||
|
||||
ULONG InternalRelease() noexcept
|
||||
{
|
||||
return --refcount_;
|
||||
}
|
||||
|
||||
unsigned long GetRefCount() const noexcept
|
||||
{
|
||||
return refcount_;
|
||||
}
|
||||
|
||||
std::atomic<ULONG> refcount_{1};
|
||||
};
|
||||
}
|
||||
|
||||
template <typename ...TInterfaces>
|
||||
class Base : public Details::RuntimeClassImpl<TInterfaces...>
|
||||
{
|
||||
Base(const Base&) = delete;
|
||||
Base& operator=(const Base&) = delete;
|
||||
|
||||
protected:
|
||||
HRESULT CustomQueryInterface(REFIID /*riid*/, _Outptr_result_nullonfailure_ void** /*ppvObject*/, _Out_ bool *handled)
|
||||
{
|
||||
*handled = false;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
public:
|
||||
Base() throw() = default;
|
||||
typedef Base RuntimeClassT;
|
||||
};
|
||||
|
||||
// Creates a Nano-COM object wrapped in a smart pointer.
|
||||
template <typename T, typename ...TArgs>
|
||||
ComPtr<T> Make(TArgs&&... args)
|
||||
{
|
||||
std::unique_ptr<char[]> buffer(new(std::nothrow) char[sizeof(T)]);
|
||||
ComPtr<T> object;
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
T* ptr = new (buffer.get())T(std::forward<TArgs>(args)...);
|
||||
object.Attach(ptr);
|
||||
buffer.release();
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
using Details::ChainInterfaces;
|
||||
}
|
||||
}
|
||||
|
||||
// Overloaded global function to provide to IID_PPV_ARGS that support Details::ComPtrRef
|
||||
template<typename T>
|
||||
void** IID_PPV_ARGS_Helper(Microsoft::WRL::Details::ComPtrRef<T> pp) throw()
|
||||
{
|
||||
return pp;
|
||||
}
|
Reference in New Issue
Block a user