From 7a203b0e5f7aaae44795b9b429aed041a27bd6c0 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 15 Jun 2017 17:09:50 +0200 Subject: [PATCH] include: Provide enum flag operators for D3D12_RESOURCE_FLAGS. --- include/d3d12.idl | 1 + include/vkd3d_windows.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/d3d12.idl b/include/d3d12.idl index cd7fcec5..991be73d 100644 --- a/include/d3d12.idl +++ b/include/d3d12.idl @@ -329,6 +329,7 @@ typedef enum D3D12_RESOURCE_FLAGS D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER = 0x10, D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS = 0x20, } D3D12_RESOURCE_FLAGS; +cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(D3D12_RESOURCE_FLAGS);") typedef struct D3D12_RESOURCE_DESC { diff --git a/include/vkd3d_windows.h b/include/vkd3d_windows.h index 2fee8be4..efd2d482 100644 --- a/include/vkd3d_windows.h +++ b/include/vkd3d_windows.h @@ -209,4 +209,22 @@ typedef struct SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES; # define max(a, b) (((a) >= (b)) ? (a) : (b)) #endif +#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 */ + #endif /* __VKD3D_WINDOWS_H */