Convert all remaining enums to enum classes (!)

This commit is contained in:
Jérôme Leclercq
2021-05-25 00:08:50 +02:00
parent 8cdd0b51cb
commit 874fb3542e
122 changed files with 1082 additions and 2169 deletions

View File

@@ -25,7 +25,7 @@ namespace Nz
Buffer::Buffer(BufferType type, UInt32 size, DataStorage storage, BufferUsageFlags usage) :
Buffer(type)
{
ErrorFlags flags(ErrorFlag_ThrowException, true);
ErrorFlags flags(ErrorMode::ThrowException, true);
Create(size, storage, usage);
}

View File

@@ -30,7 +30,7 @@ namespace Nz
return Ternary::False;
ByteStream byteStream(&stream);
byteStream.SetDataEndianness(Endianness_LittleEndian);
byteStream.SetDataEndianness(Endianness::LittleEndian);
UInt32 magic;
byteStream >> magic;
@@ -43,7 +43,7 @@ namespace Nz
NazaraUnused(parameters);
ByteStream byteStream(&stream);
byteStream.SetDataEndianness(Endianness_LittleEndian);
byteStream.SetDataEndianness(Endianness::LittleEndian);
UInt32 magic;
byteStream >> magic;

View File

@@ -324,7 +324,7 @@ namespace Nz
bool SetFile(const std::filesystem::path& filePath)
{
std::unique_ptr<File> file = std::make_unique<File>();
if (!file->Open(filePath, OpenMode_ReadOnly))
if (!file->Open(filePath, OpenMode::ReadOnly))
{
NazaraError("Failed to open stream from file: " + Error::GetLastError());
return false;

View File

@@ -25,7 +25,7 @@ namespace Nz
MD5AnimParser::~MD5AnimParser()
{
// Reset stream flags
if ((m_streamFlags & StreamOption_Text) == 0)
if ((m_streamFlags & StreamOption::Text) == 0)
m_stream.EnableTextMode(false);
}

View File

@@ -25,7 +25,7 @@ namespace Nz
MD5MeshParser::~MD5MeshParser()
{
// Reset stream flags
if ((m_streamFlags & StreamOption_Text) == 0)
if ((m_streamFlags & StreamOption::Text) == 0)
m_stream.EnableTextMode(false);
}

View File

@@ -35,7 +35,7 @@ namespace Nz
// Force stream in text mode, reset it at the end
Nz::CallOnExit resetTextMode;
if ((stream.GetStreamOptions() & StreamOption_Text) == 0)
if ((stream.GetStreamOptions() & StreamOption::Text) == 0)
{
stream.EnableTextMode(true);
@@ -490,7 +490,7 @@ namespace Nz
// Force stream in text mode, reset it at the end
Nz::CallOnExit resetTextMode;
if ((stream.GetStreamOptions() & StreamOption_Text) == 0)
if ((stream.GetStreamOptions() & StreamOption::Text) == 0)
{
stream.EnableTextMode(true);

View File

@@ -45,7 +45,7 @@ namespace Nz
bool ParseMTL(Mesh& mesh, const std::filesystem::path& filePath, const std::string* materials, const OBJParser::Mesh* meshes, std::size_t meshCount)
{
File file(filePath);
if (!file.Open(OpenMode_ReadOnly | OpenMode_Text))
if (!file.Open(OpenMode::ReadOnly | OpenMode::Text))
{
NazaraError("Failed to open MTL file (" + file.GetPath().generic_u8string() + ')');
return false;
@@ -344,7 +344,7 @@ namespace Nz
std::filesystem::path mtlLib = parser.GetMtlLib();
if (!mtlLib.empty())
{
ErrorFlags flags(ErrorFlag_ThrowExceptionDisabled);
ErrorFlags flags(ErrorMode::ThrowExceptionDisabled);
ParseMTL(*mesh, stream.GetDirectory() / mtlLib, materials, meshes, meshCount);
}

View File

@@ -23,7 +23,7 @@ namespace Nz
// Force stream in text mode, reset it at the end
Nz::CallOnExit resetTextMode;
if ((stream.GetStreamOptions() & StreamOption_Text) == 0)
if ((stream.GetStreamOptions() & StreamOption::Text) == 0)
{
stream.EnableTextMode(true);
@@ -95,7 +95,7 @@ namespace Nz
// Force stream in text mode, reset it at the end
Nz::CallOnExit resetTextMode;
if ((stream.GetStreamOptions() & StreamOption_Text) == 0)
if ((stream.GetStreamOptions() & StreamOption::Text) == 0)
{
stream.EnableTextMode(true);
@@ -493,7 +493,7 @@ namespace Nz
// Force stream in text mode, reset it at the end
Nz::CallOnExit resetTextMode;
if ((stream.GetStreamOptions() & StreamOption_Text) == 0)
if ((stream.GetStreamOptions() & StreamOption::Text) == 0)
{
stream.EnableTextMode(true);

View File

@@ -190,7 +190,7 @@ namespace Nz
if (!mtlPath.empty())
{
File mtlFile(mtlPath, OpenMode_WriteOnly | OpenMode_Truncate);
File mtlFile(mtlPath, OpenMode::WriteOnly | OpenMode::Truncate);
if (mtlFile.IsOpen())
mtlFormat.Save(mtlFile);
}

View File

@@ -47,7 +47,7 @@ namespace Nz
Image::Image(ImageType type, PixelFormat format, unsigned int width, unsigned int height, unsigned int depth, UInt8 levelCount) :
m_sharedImage(&emptyImage)
{
ErrorFlags flags(ErrorFlag_ThrowException);
ErrorFlags flags(ErrorMode::ThrowException);
Create(type, format, width, height, depth, levelCount);
}

View File

@@ -15,19 +15,19 @@ namespace Nz
{
IndexBuffer::IndexBuffer(bool largeIndices, std::shared_ptr<Buffer> buffer)
{
ErrorFlags(ErrorFlag_ThrowException, true);
ErrorFlags(ErrorMode::ThrowException, true);
Reset(largeIndices, std::move(buffer));
}
IndexBuffer::IndexBuffer(bool largeIndices, std::shared_ptr<Buffer> buffer, std::size_t offset, std::size_t size)
{
ErrorFlags(ErrorFlag_ThrowException, true);
ErrorFlags(ErrorMode::ThrowException, true);
Reset(largeIndices, std::move(buffer), offset, size);
}
IndexBuffer::IndexBuffer(bool largeIndices, std::size_t length, DataStorage storage, BufferUsageFlags usage)
{
ErrorFlags(ErrorFlag_ThrowException, true);
ErrorFlags(ErrorMode::ThrowException, true);
Reset(largeIndices, length, storage, usage);
}

View File

@@ -106,7 +106,7 @@ namespace Nz
switch (primitive.type)
{
case PrimitiveType_Box:
case PrimitiveType::Box:
{
unsigned int indexCount;
unsigned int vertexCount;
@@ -128,7 +128,7 @@ namespace Nz
break;
}
case PrimitiveType_Cone:
case PrimitiveType::Cone:
{
unsigned int indexCount;
unsigned int vertexCount;
@@ -150,7 +150,7 @@ namespace Nz
break;
}
case PrimitiveType_Plane:
case PrimitiveType::Plane:
{
unsigned int indexCount;
unsigned int vertexCount;
@@ -172,11 +172,11 @@ namespace Nz
break;
}
case PrimitiveType_Sphere:
case PrimitiveType::Sphere:
{
switch (primitive.sphere.type)
{
case SphereType_Cubic:
case SphereType::Cubic:
{
unsigned int indexCount;
unsigned int vertexCount;
@@ -198,7 +198,7 @@ namespace Nz
break;
}
case SphereType_Ico:
case SphereType::Ico:
{
unsigned int indexCount;
unsigned int vertexCount;
@@ -220,7 +220,7 @@ namespace Nz
break;
}
case SphereType_UV:
case SphereType::UV:
{
unsigned int indexCount;
unsigned int vertexCount;

View File

@@ -3,6 +3,7 @@
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Utility/Node.hpp>
#include <Nazara/Core/Algorithm.hpp>
#include <Nazara/Utility/Debug.hpp>
namespace Nz
@@ -148,17 +149,17 @@ namespace Nz
{
switch (coordSys)
{
case CoordSys_Global:
case CoordSys::Global:
if (!m_derivedUpdated)
UpdateDerived();
return m_derivedPosition;
case CoordSys_Local:
case CoordSys::Local:
return m_position;
}
NazaraError("Coordinate system out of enum (0x" + NumberToString(coordSys, 16) + ')');
NazaraError("Coordinate system out of enum (0x" + NumberToString(UnderlyingCast(coordSys), 16) + ')');
return Vector3f();
}
@@ -174,17 +175,17 @@ namespace Nz
{
switch (coordSys)
{
case CoordSys_Global:
case CoordSys::Global:
if (!m_derivedUpdated)
UpdateDerived();
return m_derivedRotation;
case CoordSys_Local:
case CoordSys::Local:
return m_rotation;
}
NazaraError("Coordinate system out of enum (0x" + NumberToString(coordSys, 16) + ')');
NazaraError("Coordinate system out of enum (0x" + NumberToString(UnderlyingCast(coordSys), 16) + ')');
return Quaternionf();
}
@@ -192,17 +193,17 @@ namespace Nz
{
switch (coordSys)
{
case CoordSys_Global:
case CoordSys::Global:
if (!m_derivedUpdated)
UpdateDerived();
return m_derivedScale;
case CoordSys_Local:
case CoordSys::Local:
return m_scale;
}
NazaraError("Coordinate system out of enum (0x" + NumberToString(coordSys, 16) + ')');
NazaraError("Coordinate system out of enum (0x" + NumberToString(UnderlyingCast(coordSys), 16) + ')');
return Vector3f();
}
@@ -231,7 +232,7 @@ namespace Nz
{
switch (coordSys)
{
case CoordSys_Global:
case CoordSys::Global:
if (!nodeA.m_derivedUpdated)
nodeA.UpdateDerived();
@@ -243,7 +244,7 @@ namespace Nz
m_scale = ToLocalScale(Vector3f::Lerp(nodeA.m_derivedScale, nodeB.m_derivedScale, interpolation));
break;
case CoordSys_Local:
case CoordSys::Local:
m_position = Vector3f::Lerp(nodeA.m_position, nodeB.m_position, interpolation);
m_rotation = Quaternionf::Slerp(nodeA.m_rotation, nodeB.m_rotation, interpolation);
m_scale = Vector3f::Lerp(nodeA.m_scale, nodeB.m_scale, interpolation);
@@ -258,7 +259,7 @@ namespace Nz
{
switch (coordSys)
{
case CoordSys_Global:
case CoordSys::Global:
{
if (m_parent)
{
@@ -273,7 +274,7 @@ namespace Nz
break;
}
case CoordSys_Local:
case CoordSys::Local:
m_position += m_rotation * movement;
break;
}
@@ -295,7 +296,7 @@ namespace Nz
switch (coordSys)
{
case CoordSys_Global:
case CoordSys::Global:
{
if (!m_derivedUpdated)
UpdateDerived();
@@ -304,7 +305,7 @@ namespace Nz
break;
}
case CoordSys_Local:
case CoordSys::Local:
m_rotation *= q;
break;
}
@@ -449,9 +450,9 @@ namespace Nz
if (m_parent)
m_parent->AddChild(this);
SetRotation(m_derivedRotation, CoordSys_Global);
SetScale(m_derivedScale, CoordSys_Global);
SetPosition(m_derivedPosition, CoordSys_Global);
SetRotation(m_derivedRotation, CoordSys::Global);
SetScale(m_derivedScale, CoordSys::Global);
SetPosition(m_derivedPosition, CoordSys::Global);
}
else
{
@@ -477,7 +478,7 @@ namespace Nz
{
switch (coordSys)
{
case CoordSys_Global:
case CoordSys::Global:
if (m_parent && m_inheritPosition)
{
if (!m_parent->m_derivedUpdated)
@@ -489,7 +490,7 @@ namespace Nz
m_position = position - m_initialPosition;
break;
case CoordSys_Local:
case CoordSys::Local:
m_position = position;
break;
}
@@ -510,7 +511,7 @@ namespace Nz
switch (coordSys)
{
case CoordSys_Global:
case CoordSys::Global:
if (m_parent && m_inheritRotation)
{
Quaternionf rot(m_parent->GetRotation() * m_initialRotation);
@@ -522,7 +523,7 @@ namespace Nz
break;
case CoordSys_Local:
case CoordSys::Local:
m_rotation = q;
break;
}
@@ -540,14 +541,14 @@ namespace Nz
{
switch (coordSys)
{
case CoordSys_Global:
case CoordSys::Global:
if (m_parent && m_inheritScale)
m_scale = scale / (m_initialScale * m_parent->GetScale());
else
m_scale = scale / m_initialScale;
break;
case CoordSys_Local:
case CoordSys::Local:
m_scale = scale;
break;
}
@@ -567,9 +568,9 @@ namespace Nz
void Node::SetTransformMatrix(const Matrix4f& matrix)
{
SetPosition(matrix.GetTranslation(), CoordSys_Global);
SetRotation(matrix.GetRotation(), CoordSys_Global);
SetScale(matrix.GetScale(), CoordSys_Global);
SetPosition(matrix.GetTranslation(), CoordSys::Global);
SetRotation(matrix.GetRotation(), CoordSys::Global);
SetScale(matrix.GetScale(), CoordSys::Global);
m_transformMatrix = matrix;
m_transformMatrixUpdated = true;

View File

@@ -155,7 +155,7 @@ namespace Nz
const Joint* jointsA = &skeletonA.m_impl->joints[0];
const Joint* jointsB = &skeletonB.m_impl->joints[0];
for (std::size_t i = 0; i < m_impl->joints.size(); ++i)
m_impl->joints[i].Interpolate(jointsA[i], jointsB[i], interpolation, CoordSys_Local);
m_impl->joints[i].Interpolate(jointsA[i], jointsB[i], interpolation, CoordSys::Local);
InvalidateJoints();
}
@@ -174,7 +174,7 @@ namespace Nz
std::size_t index = indices[i];
NazaraAssert(index < m_impl->joints.size(), "joint index out of range");
m_impl->joints[index].Interpolate(jointsA[index], jointsB[index], interpolation, CoordSys_Local);
m_impl->joints[index].Interpolate(jointsA[index], jointsB[index], interpolation, CoordSys::Local);
}
InvalidateJoints();

View File

@@ -12,19 +12,19 @@ namespace Nz
{
UniformBuffer::UniformBuffer(std::shared_ptr<Buffer> buffer)
{
ErrorFlags(ErrorFlag_ThrowException, true);
ErrorFlags(ErrorMode::ThrowException, true);
Reset(std::move(buffer));
}
UniformBuffer::UniformBuffer(std::shared_ptr<Buffer> buffer, UInt32 offset, UInt32 size)
{
ErrorFlags(ErrorFlag_ThrowException, true);
ErrorFlags(ErrorMode::ThrowException, true);
Reset(std::move(buffer), offset, size);
}
UniformBuffer::UniformBuffer(UInt32 length, DataStorage storage, BufferUsageFlags usage)
{
ErrorFlags(ErrorFlag_ThrowException, true);
ErrorFlags(ErrorMode::ThrowException, true);
Reset(length, storage, usage);
}

View File

@@ -11,19 +11,19 @@ namespace Nz
{
VertexBuffer::VertexBuffer(std::shared_ptr<const VertexDeclaration> vertexDeclaration, std::shared_ptr<Buffer> buffer)
{
ErrorFlags(ErrorFlag_ThrowException, true);
ErrorFlags(ErrorMode::ThrowException, true);
Reset(std::move(vertexDeclaration), std::move(buffer));
}
VertexBuffer::VertexBuffer(std::shared_ptr<const VertexDeclaration> vertexDeclaration, std::shared_ptr<Buffer> buffer, std::size_t offset, std::size_t size)
{
ErrorFlags(ErrorFlag_ThrowException, true);
ErrorFlags(ErrorMode::ThrowException, true);
Reset(std::move(vertexDeclaration), std::move(buffer), offset, size);
}
VertexBuffer::VertexBuffer(std::shared_ptr<const VertexDeclaration> vertexDeclaration, std::size_t length, DataStorage storage, BufferUsageFlags usage)
{
ErrorFlags(ErrorFlag_ThrowException, true);
ErrorFlags(ErrorMode::ThrowException, true);
Reset(std::move(vertexDeclaration), length, storage, usage);
}

View File

@@ -37,7 +37,7 @@ namespace Nz
VertexDeclaration::VertexDeclaration(VertexInputRate inputRate, std::initializer_list<ComponentEntry> components) :
m_inputRate(inputRate)
{
ErrorFlags errFlags(ErrorFlag_ThrowException);
ErrorFlags errFlags(ErrorMode::ThrowException);
std::size_t offset = 0;
m_components.reserve(components.size());
@@ -99,7 +99,7 @@ namespace Nz
{
try
{
ErrorFlags flags(ErrorFlag_Silent | ErrorFlag_ThrowException);
ErrorFlags flags(ErrorMode::Silent | ErrorMode::ThrowException);
auto NewDeclaration = [](VertexInputRate inputRate, std::initializer_list<ComponentEntry> components)
{

View File

@@ -14,7 +14,7 @@ namespace Nz
{
VertexMapper::VertexMapper(SubMesh& subMesh, BufferAccess access)
{
ErrorFlags flags(ErrorFlag_ThrowException, true);
ErrorFlags flags(ErrorMode::ThrowException, true);
std::shared_ptr<VertexBuffer> buffer = nullptr;
switch (subMesh.GetAnimationType())
@@ -44,13 +44,13 @@ namespace Nz
VertexMapper::VertexMapper(VertexBuffer& vertexBuffer, BufferAccess access)
{
ErrorFlags flags(ErrorFlag_ThrowException, true);
ErrorFlags flags(ErrorMode::ThrowException, true);
m_mapper.Map(vertexBuffer, access);
}
VertexMapper::VertexMapper(const SubMesh& subMesh, BufferAccess access)
{
ErrorFlags flags(ErrorFlag_ThrowException, true);
ErrorFlags flags(ErrorMode::ThrowException, true);
std::shared_ptr<VertexBuffer> buffer = nullptr;
switch (subMesh.GetAnimationType())
@@ -80,7 +80,7 @@ namespace Nz
VertexMapper::VertexMapper(const VertexBuffer& vertexBuffer, BufferAccess access)
{
ErrorFlags flags(ErrorFlag_ThrowException, true);
ErrorFlags flags(ErrorMode::ThrowException, true);
m_mapper.Map(vertexBuffer, access);
}