mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 14:52:11 +01:00
include: Implement some small utilities in native headers (#3361)
* Add QueryInterface template to IUnknown As described here https://learn.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-queryinterface\(q\)\?source\=recommendations * Implement DEFINE_ENUM_FLAG_OPERATORS * Add REFCLSID to windows_base.h This is used by the latest d3d12 headers for D3D12GetInterface
This commit is contained in:
parent
9ce1c4df0d
commit
b81536458f
@ -12,6 +12,10 @@ struct IUnknown {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
virtual HRESULT QueryInterface(REFIID riid, void** ppvObject) = 0;
|
virtual HRESULT QueryInterface(REFIID riid, void** ppvObject) = 0;
|
||||||
|
template<class Q>
|
||||||
|
HRESULT STDMETHODCALLTYPE QueryInterface(Q **pp) {
|
||||||
|
return QueryInterface(__uuidof(Q), (void **)pp);
|
||||||
|
}
|
||||||
|
|
||||||
virtual ULONG AddRef() = 0;
|
virtual ULONG AddRef() = 0;
|
||||||
virtual ULONG Release() = 0;
|
virtual ULONG Release() = 0;
|
||||||
|
@ -70,9 +70,11 @@ typedef GUID IID;
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#define REFIID const IID&
|
#define REFIID const IID&
|
||||||
#define REFGUID const GUID&
|
#define REFGUID const GUID&
|
||||||
|
#define REFCLSID const GUID&
|
||||||
#else
|
#else
|
||||||
#define REFIID const IID*
|
#define REFIID const IID*
|
||||||
#define REFGUID const GUID*
|
#define REFGUID const GUID*
|
||||||
|
#define REFCLSID const GUID* const
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -332,4 +334,20 @@ typedef struct RGNDATA {
|
|||||||
#define FAILED(hr) ((HRESULT)(hr) < 0)
|
#define FAILED(hr) ((HRESULT)(hr) < 0)
|
||||||
#define SUCCEEDED(hr) ((HRESULT)(hr) >= 0)
|
#define SUCCEEDED(hr) ((HRESULT)(hr) >= 0)
|
||||||
|
|
||||||
#define DEFINE_ENUM_FLAG_OPERATORS(T)
|
#ifndef DEFINE_ENUM_FLAG_OPERATORS
|
||||||
|
#ifdef __cplusplus
|
||||||
|
# define DEFINE_ENUM_FLAG_OPERATORS(type) \
|
||||||
|
extern "C++" \
|
||||||
|
{ \
|
||||||
|
inline type operator &(type x, type y) { return (type)((int)x & (int)y); } \
|
||||||
|
inline type operator &=(type &x, type y) { return (type &)((int &)x &= (int)y); } \
|
||||||
|
inline type operator ~(type x) { return (type)~(int)x; } \
|
||||||
|
inline type operator |(type x, type y) { return (type)((int)x | (int)y); } \
|
||||||
|
inline type operator |=(type &x, type y) { return (type &)((int &)x |= (int)y); } \
|
||||||
|
inline type operator ^(type x, type y) { return (type)((int)x ^ (int)y); } \
|
||||||
|
inline type operator ^=(type &x, type y) { return (type &)((int &)x ^= (int)y); } \
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
# define DEFINE_ENUM_FLAG_OPERATORS(type)
|
||||||
|
#endif
|
||||||
|
#endif /* DEFINE_ENUM_FLAG_OPERATORS */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user