Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/doitsujin/dxvk.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEllie Hermaszewska <github@sub.monoid.al>2023-05-03 14:39:51 +0300
committerGitHub <noreply@github.com>2023-05-03 14:39:51 +0300
commitb81536458f52f1c09dbedef2c269832128089c51 (patch)
treeee01d82b05d36db534c45f5ccf3b570e4c803e26 /include
parent9ce1c4df0d66a6abdd8a70fc452d00ad03e26b92 (diff)
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
Diffstat (limited to 'include')
-rw-r--r--include/native/windows/unknwn.h4
-rw-r--r--include/native/windows/windows_base.h20
2 files changed, 23 insertions, 1 deletions
diff --git a/include/native/windows/unknwn.h b/include/native/windows/unknwn.h
index 75722678..71216db9 100644
--- a/include/native/windows/unknwn.h
+++ b/include/native/windows/unknwn.h
@@ -12,6 +12,10 @@ struct IUnknown {
public:
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 Release() = 0;
diff --git a/include/native/windows/windows_base.h b/include/native/windows/windows_base.h
index 7ec0353c..3be09a1b 100644
--- a/include/native/windows/windows_base.h
+++ b/include/native/windows/windows_base.h
@@ -70,9 +70,11 @@ typedef GUID IID;
#ifdef __cplusplus
#define REFIID const IID&
#define REFGUID const GUID&
+#define REFCLSID const GUID&
#else
#define REFIID const IID*
#define REFGUID const GUID*
+#define REFCLSID const GUID* const
#endif // __cplusplus
#ifdef __cplusplus
@@ -332,4 +334,20 @@ typedef struct RGNDATA {
#define FAILED(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 */