diff --git a/include/native/windows/unknwn.h b/include/native/windows/unknwn.h index 757226787..71216db9e 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 + 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 7ec0353c1..3be09a1b2 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 */