Description
Originally posted by @mrshannon in #158 (comment):
Any idea on how to improve WGPUBufferUsage vs. WGPUBufferUsageFlags?
You technically don't need
WGPUBufferUsageFlags
asWGPUBufferUsage
will > always be wide enough for the bitwise combination because we haveWGPUBufferUsage_Force32 = 0x7FFFFFFF
which is effectively doing what is done for the C++ headers with:enum class BufferUsage : uint32_t {
This is strictly true, but in Dawn's C++ bindings we also have operator overloads, so when you do wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst
you get a wgpu::BufferUsage
value. In C WGPUBufferUsage_CopySrc | WGPUBufferUsage_CopyDst
will give you an int of some kind. So this would force callers of the API to cast back to the appropriate type.
desc.usage = static_cast<WGPUBufferUsage>(WGPUBufferUsage_CopySrc | WGPUBufferUsage_CopyDst);
Apparently, the cast is only needed in C++. C seems happy without a cast. So I guess we could define operator overloads for these types behind #ifdef __cplusplus
...?