From 766f24d6b9c6328a2508168509ed00cf289f30e3 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Thu, 22 Sep 2022 00:21:50 +0200 Subject: [PATCH] Engine: Switch to ASSERT macro to ruc's VERIFY --- src/inferno.h | 1 - src/inferno/application.cpp | 4 +- src/inferno/component/nativescriptcomponent.h | 7 +- src/inferno/io/file.cpp | 9 +-- src/inferno/io/file.h | 6 +- src/inferno/io/gltffile.cpp | 21 +++--- src/inferno/io/log.cpp | 11 +-- src/inferno/keycodes.cpp | 6 +- src/inferno/render/buffer.cpp | 12 ++-- src/inferno/render/context.cpp | 12 ++-- src/inferno/render/font.cpp | 9 +-- src/inferno/render/gltf.cpp | 68 +++++++++---------- src/inferno/render/renderer.cpp | 1 - src/inferno/render/shader.cpp | 14 ++-- src/inferno/render/texture.cpp | 7 +- src/inferno/scene/scene.cpp | 7 +- src/inferno/script/luascript.cpp | 6 +- src/inferno/script/luascript.h | 5 +- src/inferno/singleton.h | 8 +-- src/inferno/system/camerasystem.cpp | 6 +- src/inferno/system/rendersystem.cpp | 3 +- src/inferno/system/scriptsystem.cpp | 4 +- src/inferno/system/textareasystem.cpp | 5 +- src/inferno/system/transformsystem.cpp | 3 +- src/inferno/util/integer.h | 4 +- src/inferno/util/json.h | 13 ++-- src/inferno/window.cpp | 4 +- 27 files changed, 128 insertions(+), 128 deletions(-) diff --git a/src/inferno.h b/src/inferno.h index 02bcf1d..60aa1a8 100644 --- a/src/inferno.h +++ b/src/inferno.h @@ -7,7 +7,6 @@ #include "inferno/core.h" #include "inferno/application.h" -#include "inferno/assert.h" #include "inferno/io/log.h" // ----------------------------------------- diff --git a/src/inferno/application.cpp b/src/inferno/application.cpp index 3e6a76b..22089fc 100644 --- a/src/inferno/application.cpp +++ b/src/inferno/application.cpp @@ -1,7 +1,7 @@ #include "glm/gtc/type_ptr.hpp" // glm::make_mat4 +#include "ruc/meta/assert.h" #include "inferno/application.h" -#include "inferno/assert.h" #include "inferno/core.h" #include "inferno/event/applicationevent.h" #include "inferno/event/event.h" @@ -91,7 +91,7 @@ namespace Inferno { uint32_t textureWidth = f->texture()->width(); uint32_t textureHeight = f->texture()->height(); - ASSERT(textureWidth == textureHeight, "Invalid font texture!"); + VERIFY(textureWidth == textureHeight, "Invalid font texture!"); float quadWidth = (c->size.x / (float)textureWidth) - 0.04; // @Todo something wrong with the width float quadHeight = c->size.y / (float)textureHeight; diff --git a/src/inferno/component/nativescriptcomponent.h b/src/inferno/component/nativescriptcomponent.h index 3badef6..8955148 100644 --- a/src/inferno/component/nativescriptcomponent.h +++ b/src/inferno/component/nativescriptcomponent.h @@ -1,6 +1,7 @@ #pragma once -#include "inferno/assert.h" +#include "ruc/meta/assert.h" + #include "inferno/script/nativescript.h" namespace Inferno { @@ -16,12 +17,12 @@ namespace Inferno { template void bind() { - ASSERT(instance == nullptr, "NativeScript already bound"); + VERIFY(instance == nullptr, "NativeScript already bound"); initialize = []() { return static_cast(new T()); }; } void destroy() { - ASSERT(instance, "Attempting to destroy an uninitialized NativeScript"); + VERIFY(instance, "Attempting to destroy an uninitialized NativeScript"); delete instance; instance = nullptr; } diff --git a/src/inferno/io/file.cpp b/src/inferno/io/file.cpp index 5ba6142..86d6a10 100644 --- a/src/inferno/io/file.cpp +++ b/src/inferno/io/file.cpp @@ -1,7 +1,8 @@ #include // std::ios #include // std::make_unique -#include "inferno/assert.h" +#include "ruc/meta/assert.h" + #include "inferno/io/file.h" namespace Inferno { @@ -10,7 +11,7 @@ namespace Inferno { { // Create input stream object and open file std::ifstream file(path); - ASSERT(file.is_open(), "File could not open '{}'", path); + VERIFY(file.is_open(), "File could not open '{}'", path); // Get length of the file int32_t length = File::length(path, file); @@ -39,9 +40,9 @@ namespace Inferno { file.seekg(0, std::ios::end); int32_t length = file.tellg(); file.seekg(0, std::ios::beg); - ASSERT(length != -1, "File could not determine length '{}'", path); + VERIFY(length != -1, "File could not determine length '{}'", path); return length; } -} +} // namespace Inferno diff --git a/src/inferno/io/file.h b/src/inferno/io/file.h index b431674..e0c1a43 100644 --- a/src/inferno/io/file.h +++ b/src/inferno/io/file.h @@ -5,9 +5,9 @@ #include // std::shared_ptr #include // std::string -#include "inferno/assert.h" #include "inferno/core.h" #include "inferno/io/log.h" +#include "ruc/meta/assert.h" namespace Inferno { @@ -21,7 +21,7 @@ namespace Inferno { static bool ioRead(T* t, const std::string& path) { std::ifstream file(path); - ASSERT(file.is_open(), "File could not open '{}'", path); + VERIFY(file.is_open(), "File could not open '{}'", path); if (!file.is_open()) { return false; @@ -41,7 +41,7 @@ namespace Inferno { static bool ioWrite(T* t, const std::string& path) { std::ofstream file (path); - ASSERT(file.is_open(), "File could not open! {}", path); + VERIFY(file.is_open(), "File could not open! {}", path); if (!file.is_open()) { return false; diff --git a/src/inferno/io/gltffile.cpp b/src/inferno/io/gltffile.cpp index 42145fe..22425b4 100644 --- a/src/inferno/io/gltffile.cpp +++ b/src/inferno/io/gltffile.cpp @@ -2,12 +2,13 @@ #include // std::ifstream #include // std::ios -#include "inferno/assert.h" +#include "ruc/meta/assert.h" + #include "inferno/io/file.h" #include "inferno/io/gltffile.h" #include "inferno/io/log.h" -#include "inferno/util/string.h" #include "inferno/util/json.h" +#include "inferno/util/string.h" namespace Inferno { @@ -22,7 +23,7 @@ namespace Inferno { return { File::raw(path), nullptr }; } - ASSERT(false, "GltfFile unknown file extension!"); + VERIFY(false, "GltfFile unknown file extension!"); return {}; } @@ -30,7 +31,7 @@ namespace Inferno { { // Create input stream object and open file std::ifstream glb(path, std::ios::in | std::ios::binary); - ASSERT(glb.is_open(), "GltfFile could not open '{}'", path); + VERIFY(glb.is_open(), "GltfFile could not open '{}'", path); constexpr uint32_t size = 4; constexpr uint32_t header = 12; @@ -38,7 +39,7 @@ namespace Inferno { // Get the actual length of the file uint32_t length = static_cast(File::length(path, glb)); - ASSERT(length > header + json, "GltfFile too small to be valid '{}'", path); + VERIFY(length > header + json, "GltfFile too small to be valid '{}'", path); // Read header @@ -55,17 +56,17 @@ namespace Inferno { // Validate header uint32_t magicInt = *reinterpret_cast(magic); - ASSERT(magicInt == 0x46546c67, "Gltf invalid header magic '{}'", magic); + VERIFY(magicInt == 0x46546c67, "Gltf invalid header magic '{}'", magic); uint32_t versionInt = *reinterpret_cast(version); - ASSERT(versionInt == 2, "Gltf unsupported version '{}'", versionInt); + VERIFY(versionInt == 2, "Gltf unsupported version '{}'", versionInt); uint32_t fileLengthInt = *reinterpret_cast(fileLength); - ASSERT(fileLengthInt == length, "Gltf file and reported byte size mismatch '{}' '{}'", length, fileLengthInt); + VERIFY(fileLengthInt == length, "Gltf file and reported byte size mismatch '{}' '{}'", length, fileLengthInt); // Read JSON data auto jsonChunk = readChunk(glb, header, 0x4e4f534a); - ASSERT(jsonChunk.second >= json, "Gltf file invalid JSON content length '{}'", jsonChunk.second); + VERIFY(jsonChunk.second >= json, "Gltf file invalid JSON content length '{}'", jsonChunk.second); // Read binary data auto binaryChunk = readChunk(glb, header + size * 2 + jsonChunk.second, 0x004e4942); @@ -88,7 +89,7 @@ namespace Inferno { ifstream.read(chunkType, size); uint32_t chunkTypeInt = *reinterpret_cast(chunkType); - ASSERT(chunkTypeInt == type, "Gltf invalid chunk type '{}' != '{}'", chunkType, intToHex(type)); + VERIFY(chunkTypeInt == type, "Gltf invalid chunk type '{}' != '{}'", chunkType, intToHex(type)); uint32_t chunkLengthInt = *reinterpret_cast(chunkLength); // Allocate memory filled with zeros diff --git a/src/inferno/io/log.cpp b/src/inferno/io/log.cpp index a927cff..3af6209 100644 --- a/src/inferno/io/log.cpp +++ b/src/inferno/io/log.cpp @@ -1,6 +1,3 @@ -#include "inferno/assert.h" -#include "inferno/io/log.h" - #include // size_t #include // fwrite, snprintf #include // malloc, free @@ -8,6 +5,10 @@ #include // std::string #include // std::string_view +#include "ruc/meta/assert.h" + +#include "inferno/io/log.h" + namespace Inferno { BufferedLogStream::~BufferedLogStream() @@ -231,7 +232,7 @@ namespace Inferno { case Log::Comment: return stream << "Comment"; default: - ASSERT_NOT_REACHED(); + VERIFY_NOT_REACHED(); return stream; } } @@ -317,4 +318,4 @@ namespace Inferno { return StringLogStream(fill); } -} +} // namespace Inferno diff --git a/src/inferno/keycodes.cpp b/src/inferno/keycodes.cpp index a46d108..6284e78 100644 --- a/src/inferno/keycodes.cpp +++ b/src/inferno/keycodes.cpp @@ -2,8 +2,8 @@ #include // std::unordered_map #include "GLFW/glfw3.h" +#include "ruc/meta/assert.h" -#include "inferno/assert.h" #include "inferno/keycodes.h" namespace Inferno { @@ -136,8 +136,8 @@ namespace Inferno { int keyCode(const char* name) { - ASSERT(keys.find(name) != keys.end(), "keyCode could not find '{}'", name); + VERIFY(keys.find(name) != keys.end(), "keyCode could not find '{}'", name); return keys.at(name); } -} +} // namespace Inferno diff --git a/src/inferno/render/buffer.cpp b/src/inferno/render/buffer.cpp index 1ef9b49..123ced2 100644 --- a/src/inferno/render/buffer.cpp +++ b/src/inferno/render/buffer.cpp @@ -1,6 +1,6 @@ #include "glad/glad.h" -#include "inferno/assert.h" +#include "ruc/meta/assert.h" #include "inferno/core.h" #include "inferno/io/log.h" #include "inferno/render/buffer.h" @@ -64,7 +64,7 @@ namespace Inferno { case BufferElementType::DoubleMat4: return sizeof(double) * 4 * 4; }; - ASSERT(false, "BufferElement unknown BufferElementType size!"); + VERIFY(false, "BufferElement unknown BufferElementType size!"); return 0; } @@ -100,7 +100,7 @@ namespace Inferno { case BufferElementType::DoubleMat4: return 4 * 4; }; - ASSERT(false, "BufferElement unknown BufferElementType count!"); + VERIFY(false, "BufferElement unknown BufferElementType count!"); return 0; } @@ -136,7 +136,7 @@ namespace Inferno { case BufferElementType::DoubleMat4: return GL_DOUBLE; }; - ASSERT(false, "BufferElement unknown BufferElementType GL!"); + VERIFY(false, "BufferElement unknown BufferElementType GL!"); return 0; } @@ -260,7 +260,7 @@ namespace Inferno { void VertexArray::addVertexBuffer(std::shared_ptr vertexBuffer) { const auto& layout = vertexBuffer->getLayout(); - ASSERT(layout.getElements().size(), "VertexBuffer has no layout"); + VERIFY(layout.getElements().size(), "VertexBuffer has no layout"); bind(); vertexBuffer->bind(); @@ -295,4 +295,4 @@ namespace Inferno { indexBuffer->unbind(); } -} +} // namespace Inferno diff --git a/src/inferno/render/context.cpp b/src/inferno/render/context.cpp index b52956f..744da79 100644 --- a/src/inferno/render/context.cpp +++ b/src/inferno/render/context.cpp @@ -1,7 +1,7 @@ #include "glad/glad.h" #include "GLFW/glfw3.h" +#include "ruc/meta/assert.h" -#include "inferno/assert.h" #include "inferno/core.h" #include "inferno/io/log.h" #include "inferno/render/context.h" @@ -12,7 +12,7 @@ namespace Inferno { Context::Context(GLFWwindow* window) : m_window(window) { - ASSERT(window, "Context window is nullptr!"); + VERIFY(window, "Context window is nullptr!"); } void Context::initialize() @@ -21,7 +21,7 @@ namespace Inferno { // Initialize glad int glad = gladLoadGLLoader((GLADloadproc)glfwGetProcAddress); - ASSERT(glad, "Failed to initialize glad!"); + VERIFY(glad, "Failed to initialize glad!"); // Log OpenGL properties comment() << "OpenGL Info:"; @@ -30,8 +30,8 @@ namespace Inferno { comment() << " Version: " << glGetString(GL_VERSION); // Check OpenGL version - ASSERT(GLVersion.major > 4 || (GLVersion.major == 4 && GLVersion.minor >= 5), - "Inferno requires at least OpenGL version 4.5!"); + VERIFY(GLVersion.major > 4 || (GLVersion.major == 4 && GLVersion.minor >= 5), + "Inferno requires at least OpenGL version 4.5!"); } void Context::destroy() @@ -49,4 +49,4 @@ namespace Inferno { glfwMakeContextCurrent(m_window); } -} +} // namespace Inferno diff --git a/src/inferno/render/font.cpp b/src/inferno/render/font.cpp index 499546a..8fdca38 100644 --- a/src/inferno/render/font.cpp +++ b/src/inferno/render/font.cpp @@ -2,7 +2,8 @@ #include // std::getline, std::stoi #include // std::move -#include "inferno/assert.h" +#include "ruc/meta/assert.h" + #include "inferno/io/file.h" #include "inferno/render/font.h" #include "inferno/render/texture.h" @@ -82,7 +83,7 @@ namespace Inferno { } } - ASSERT(!elements.empty(), "Font file did not find any columns"); + VERIFY(!elements.empty(), "Font file did not find any columns"); return elements; } @@ -97,7 +98,7 @@ namespace Inferno { } } - ASSERT(false, "Font file did not contain key '{}'", key); + VERIFY(false, "Font file did not contain key '{}'", key); return ""; } @@ -160,4 +161,4 @@ namespace Inferno { return stream << "{ " << value.x << ", " << value.y << " }"; } -} +} // namespace Inferno diff --git a/src/inferno/render/gltf.cpp b/src/inferno/render/gltf.cpp index c74b985..684f81e 100644 --- a/src/inferno/render/gltf.cpp +++ b/src/inferno/render/gltf.cpp @@ -3,8 +3,8 @@ #include // std::move #include "nlohmann/json.hpp" +#include "ruc/meta/assert.h" -#include "inferno/assert.h" #include "inferno/io/file.h" #include "inferno/io/gltffile.h" #include "inferno/io/log.h" @@ -17,7 +17,7 @@ namespace Inferno { : m_path(std::move(path)) { auto gltf = GltfFile::read(path); - ASSERT(gltf.first, "Gltf model invalid JSON content '{}'", path); + VERIFY(gltf.first, "Gltf model invalid JSON content '{}'", path); json json = json::parse(gltf.first.get()); @@ -31,9 +31,9 @@ namespace Inferno { // Asset // --------------------------------- - ASSERT(Json::hasProperty(json, "asset"), "GlTF model missing required property 'asset'"); + VERIFY(Json::hasProperty(json, "asset"), "GlTF model missing required property 'asset'"); auto asset = json["asset"]; - ASSERT(asset.is_object(), "Gltf model invalid property type 'asset'"); + VERIFY(asset.is_object(), "Gltf model invalid property type 'asset'"); parseAsset(&m_model.asset, asset); @@ -43,7 +43,7 @@ namespace Inferno { if (Json::hasProperty(json, "scenes")) { auto scenes = json["scenes"]; - ASSERT(scenes.is_array(), "Gltf model invalid property type 'scenes'"); + VERIFY(scenes.is_array(), "Gltf model invalid property type 'scenes'"); for (auto& [key, object] : scenes.items()) { glTF::Scene scene; @@ -58,7 +58,7 @@ namespace Inferno { if (Json::hasProperty(json, "nodes")) { auto nodes = json["nodes"]; - ASSERT(nodes.is_array(), "Gltf model invalid property type 'nodes'"); + VERIFY(nodes.is_array(), "Gltf model invalid property type 'nodes'"); for (auto& [key, object] : nodes.items()) { glTF::Node node; @@ -73,7 +73,7 @@ namespace Inferno { if (Json::hasProperty(json, "meshes")) { auto meshes = json["meshes"]; - ASSERT(meshes.is_array(), "Gltf model invalid property type 'meshes'"); + VERIFY(meshes.is_array(), "Gltf model invalid property type 'meshes'"); for (auto& [key, object] : meshes.items()) { glTF::Mesh mesh; @@ -88,7 +88,7 @@ namespace Inferno { if (Json::hasProperty(json, "accessors")) { auto accessors = json["accessors"]; - ASSERT(accessors.is_array(), "Gltf model invalid property type 'accessors'"); + VERIFY(accessors.is_array(), "Gltf model invalid property type 'accessors'"); for (auto& [key, object] : accessors.items()) { glTF::Accessor accessor; @@ -103,7 +103,7 @@ namespace Inferno { if (Json::hasProperty(json, "bufferViews")) { auto bufferViews = json["bufferViews"]; - ASSERT(bufferViews.is_array(), "Gltf model invalid property type 'bufferViews'"); + VERIFY(bufferViews.is_array(), "Gltf model invalid property type 'bufferViews'"); for (auto& [key, object] : bufferViews.items()) { glTF::BufferView bufferView; @@ -118,7 +118,7 @@ namespace Inferno { if (Json::hasProperty(json, "buffers")) { auto buffers = json["buffers"]; - ASSERT(buffers.is_array(), "Gltf model invalid property type 'buffers'"); + VERIFY(buffers.is_array(), "Gltf model invalid property type 'buffers'"); for (auto& [key, object] : buffers.items()) { glTF::Buffer buffer; @@ -140,8 +140,8 @@ namespace Inferno { auto generator = Json::parseStringProperty(object, "generator", false); auto version = Json::parseStringProperty(object, "version", true); - ASSERT(version, "GlTF model missing required property 'version'"); - ASSERT(version.value().compare("2.0") == 0, "GlTF version unsupported '{}'", version.value()); + VERIFY(version, "GlTF model missing required property 'version'"); + VERIFY(version.value().compare("2.0") == 0, "GlTF version unsupported '{}'", version.value()); auto minVersion = Json::parseStringProperty(object, "minVersion", false); @@ -154,7 +154,7 @@ namespace Inferno { void Gltf::parseScene(glTF::Scene* scene, const std::string& key, const json& object) { auto nodes = Json::parseFloatArrayProperty(object, "nodes", false); - ASSERT(!nodes || nodes.value().size() > 0, "Gltf scene '{}' empty 'nodes' property", key); + VERIFY(!nodes || nodes.value().size() > 0, "Gltf scene '{}' empty 'nodes' property", key); auto name = Json::parseStringProperty(object, "name", false); @@ -166,26 +166,26 @@ namespace Inferno { auto camera = Json::parseUnsignedProperty(object, "camera", false); auto children = Json::parseUnsignedArrayProperty(object, "children", false); - ASSERT(!children || children.value().size() > 0, "Gltf node '{}' empty property 'children'", key); + VERIFY(!children || children.value().size() > 0, "Gltf node '{}' empty property 'children'", key); auto skin = Json::parseUnsignedProperty(object, "skin", false); auto matrix = Json::parseFloatArrayProperty(object, "matrix", false); - ASSERT(!matrix || matrix.value().size() == 16, "Gltf node '{}' property 'matrix' invalid size", key); + VERIFY(!matrix || matrix.value().size() == 16, "Gltf node '{}' property 'matrix' invalid size", key); auto mesh = Json::parseUnsignedProperty(object, "mesh", false); auto rotation = Json::parseFloatArrayProperty(object, "rotation", false); - ASSERT(!rotation || rotation.value().size() == 4, "Gltf node '{}' property 'rotation' invalid size", key); + VERIFY(!rotation || rotation.value().size() == 4, "Gltf node '{}' property 'rotation' invalid size", key); auto scale = Json::parseFloatArrayProperty(object, "scale", false); - ASSERT(!scale || scale.value().size() == 3, "Gltf node '{}' property 'scale' invalid size", key); + VERIFY(!scale || scale.value().size() == 3, "Gltf node '{}' property 'scale' invalid size", key); auto translation = Json::parseFloatArrayProperty(object, "translation", false); - ASSERT(!translation || translation.value().size() == 3, "Gltf node '{}' property 'translation' invalid size", key); + VERIFY(!translation || translation.value().size() == 3, "Gltf node '{}' property 'translation' invalid size", key); auto weights = Json::parseFloatArrayProperty(object, "weights", false); - ASSERT(!weights || weights.value().size() > 0, "Gltf node '{}' empty property 'weights'", key); + VERIFY(!weights || weights.value().size() > 0, "Gltf node '{}' empty property 'weights'", key); auto name = Json::parseStringProperty(object, "name", false); @@ -204,7 +204,7 @@ namespace Inferno { void Gltf::parsePrimitive(glTF::Primitive* primitive, const std::string& key, const json& object) { auto attributes = Json::parseUnsignedObjectProperty(object, "attributes", true); - ASSERT(attributes && attributes.value().size() > 0, "Gltf primitive '{}' empty property 'attributes'", key); + VERIFY(attributes && attributes.value().size() > 0, "Gltf primitive '{}' empty property 'attributes'", key); auto indices = Json::parseUnsignedProperty(object, "indices", false); @@ -215,7 +215,7 @@ namespace Inferno { if (Json::hasProperty(object, "targets")) { auto targets = object["targets"]; - ASSERT(targets.is_array(), "Gltf primitive '{}' property 'targets' invalid type", key); + VERIFY(targets.is_array(), "Gltf primitive '{}' property 'targets' invalid type", key); for (auto& targetObject : targets) { @@ -226,7 +226,7 @@ namespace Inferno { if (value) target.emplace(std::move(key), value.value()); } - ASSERT(target.size() > 0, "Gltf primitive '{}' empty 'target' object", key); + VERIFY(target.size() > 0, "Gltf primitive '{}' empty 'target' object", key); primitive->targets.emplace_back(std::move(target)); } } @@ -239,9 +239,9 @@ namespace Inferno { void Gltf::parseMesh(glTF::Mesh* mesh, const std::string& key, const json& object) { - ASSERT(Json::hasProperty(object, "primitives"), "Gltf mesh '{}' missing required property 'primitives'", key); + VERIFY(Json::hasProperty(object, "primitives"), "Gltf mesh '{}' missing required property 'primitives'", key); auto primitives = object["primitives"]; - ASSERT(primitives.is_array(), "Gltf mesh '{}' property 'primitives' invalid type", key); + VERIFY(primitives.is_array(), "Gltf mesh '{}' property 'primitives' invalid type", key); for (auto& primitiveObject : primitives) { glTF::Primitive primitive; @@ -250,7 +250,7 @@ namespace Inferno { } auto weights = Json::parseFloatArrayProperty(object, "weights", false); - ASSERT(!weights || weights.value().size() > 0, "Gltf mesh '{}' empty property 'weights'", key); + VERIFY(!weights || weights.value().size() > 0, "Gltf mesh '{}' empty property 'weights'", key); auto name = Json::parseStringProperty(object, "name", false); @@ -265,21 +265,21 @@ namespace Inferno { auto byteOffset = Json::parseUnsignedProperty(object, "byteOffset", false); auto componentType = Json::parseUnsignedProperty(object, "componentType", true); - ASSERT(componentType, "Gltf accessor '{}' missing required property 'componentType'", key); + VERIFY(componentType, "Gltf accessor '{}' missing required property 'componentType'", key); auto normalized = Json::parseBoolProperty(object, "normalized", false); auto count = Json::parseUnsignedProperty(object, "count", true); - ASSERT(count, "Gltf accessor '{}' missing required property 'count'", key); + VERIFY(count, "Gltf accessor '{}' missing required property 'count'", key); auto type = Json::parseStringProperty(object, "type", true); - ASSERT(type, "Gltf accessor '{}' missing required property 'type'", key); + VERIFY(type, "Gltf accessor '{}' missing required property 'type'", key); auto max = Json::parseFloatArrayProperty(object, "max", false); - ASSERT(!max || max.value().size() > 0, "Gltf accessor '{}' empty property 'max'", key); + VERIFY(!max || max.value().size() > 0, "Gltf accessor '{}' empty property 'max'", key); auto min = Json::parseFloatArrayProperty(object, "min", false); - ASSERT(!min || min.value().size() > 0, "Gltf accessor '{}' empty property 'min'", key); + VERIFY(!min || min.value().size() > 0, "Gltf accessor '{}' empty property 'min'", key); auto name = Json::parseStringProperty(object, "name", false); @@ -296,12 +296,12 @@ namespace Inferno { void Gltf::parseBufferView(glTF::BufferView* bufferView, const std::string& key, const json& object) { auto buffer = Json::parseUnsignedProperty(object, "buffer", false); - ASSERT(buffer, "Gltf bufferView '{}' missing required property 'buffer'", key); + VERIFY(buffer, "Gltf bufferView '{}' missing required property 'buffer'", key); auto byteOffset = Json::parseUnsignedProperty(object, "byteOffset", false); auto byteLength = Json::parseUnsignedProperty(object, "byteLength", true); - ASSERT(byteLength, "Gltf bufferView '{}' missing required property 'byteLength'", key); + VERIFY(byteLength, "Gltf bufferView '{}' missing required property 'byteLength'", key); auto byteStride = Json::parseUnsignedProperty(object, "byteStride", false); @@ -323,12 +323,12 @@ namespace Inferno { // Load external binary data if (uri) { - ASSERT(uri.value().find("data:", 0) == std::string::npos, "GltfFile embedded binary data is unsupported"); + VERIFY(uri.value().find("data:", 0) == std::string::npos, "GltfFile embedded binary data is unsupported"); data->emplace(std::stou(key), File::raw("assets/gltf/" + uri.value())); } auto byteLength = Json::parseUnsignedProperty(object, "byteLength", true); - ASSERT(byteLength, "Gltf buffer '{}' missing required property 'byteLength'", key); + VERIFY(byteLength, "Gltf buffer '{}' missing required property 'byteLength'", key); auto name = Json::parseStringProperty(object, "name", false); diff --git a/src/inferno/render/renderer.cpp b/src/inferno/render/renderer.cpp index 1748e58..26a4322 100644 --- a/src/inferno/render/renderer.cpp +++ b/src/inferno/render/renderer.cpp @@ -3,7 +3,6 @@ #include "glad/glad.h" -#include "inferno/assert.h" #include "inferno/render/buffer.h" #include "inferno/render/renderer.h" #include "inferno/render/shader.h" diff --git a/src/inferno/render/shader.cpp b/src/inferno/render/shader.cpp index 963f468..a04661a 100644 --- a/src/inferno/render/shader.cpp +++ b/src/inferno/render/shader.cpp @@ -3,8 +3,8 @@ #include "glad/glad.h" #include "glm/gtc/type_ptr.hpp" // glm::value_ptr +#include "ruc/meta/assert.h" -#include "inferno/assert.h" #include "inferno/core.h" #include "inferno/io/file.h" #include "inferno/io/log.h" @@ -44,7 +44,7 @@ namespace Inferno { int32_t Shader::findUniform(const std::string& name) const { int32_t location = glGetUniformLocation(m_id, name.c_str()); - ASSERT(location != -1, "Shader could not find uniform '{}'", name); + VERIFY(location != -1, "Shader could not find uniform '{}'", name); return location; } @@ -186,7 +186,7 @@ namespace Inferno { warn() << "Shader " << infoLog.data(); } - ASSERT(success == GL_TRUE, "Shader program creation failed!"); + VERIFY(success == GL_TRUE, "Shader program creation failed!"); return success; } @@ -256,15 +256,15 @@ namespace Inferno { auto vertexPos = vertexSource.find_last_of('.'); auto fragmentPos = fragmentSource.find_last_of('.'); - ASSERT(vertexPos != std::string::npos, "Shader did not have file extension: '{}'", vertexSource); - ASSERT(fragmentPos != std::string::npos, "Shader did not have file extension: '{}'", fragmentSource); + VERIFY(vertexPos != std::string::npos, "Shader did not have file extension: '{}'", vertexSource); + VERIFY(fragmentPos != std::string::npos, "Shader did not have file extension: '{}'", fragmentSource); auto vertexName = vertexSource.substr(0, vertexPos); auto fragmentName = vertexSource.substr(0, fragmentPos); - ASSERT(vertexName == fragmentName, "Shader names did not match: {} {}", vertexSource, fragmentSource); + VERIFY(vertexName == fragmentName, "Shader names did not match: {} {}", vertexSource, fragmentSource); return vertexName; } -} +} // namespace Inferno diff --git a/src/inferno/render/texture.cpp b/src/inferno/render/texture.cpp index 30e3bec..841edc3 100644 --- a/src/inferno/render/texture.cpp +++ b/src/inferno/render/texture.cpp @@ -3,10 +3,11 @@ #include // std::move #include "glad/glad.h" +#include "ruc/meta/assert.h" #define STB_IMAGE_IMPLEMENTATION #include "stb/stb_image.h" -#include "inferno/assert.h" +#include "inferno/io/log.h" #include "inferno/render/texture.h" namespace Inferno { @@ -22,7 +23,7 @@ namespace Inferno { stbi_set_flip_vertically_on_load(1); unsigned char* data = stbi_load(path.c_str(), &width, &height, &channels, STBI_default); - ASSERT(data, "Failed to load image: '{}'", path); + VERIFY(data, "Failed to load image: '{}'", path); m_width = width; m_height = height; @@ -153,4 +154,4 @@ namespace Inferno { } } -} +} // namespace Inferno diff --git a/src/inferno/scene/scene.cpp b/src/inferno/scene/scene.cpp index c363930..a659a1a 100644 --- a/src/inferno/scene/scene.cpp +++ b/src/inferno/scene/scene.cpp @@ -1,11 +1,12 @@ -#include "inferno/scene/scene.h" -#include "inferno/assert.h" +#include "ruc/meta/assert.h" + #include "inferno/component/cameracomponent.h" #include "inferno/component/luascriptcomponent.h" #include "inferno/component/nativescriptcomponent.h" #include "inferno/component/spritecomponent.h" #include "inferno/component/tagcomponent.h" #include "inferno/component/textareacomponent.h" +#include "inferno/scene/scene.h" #include "inferno/script/cameracontroller.h" #include "inferno/script/nativescript.h" #include "inferno/system/camerasystem.h" @@ -113,7 +114,7 @@ namespace Inferno { void Scene::validEntity(uint32_t entity) const { - ASSERT(m_registry->valid(entt::entity { entity }), "Entity is not valid"); + VERIFY(m_registry->valid(entt::entity { entity }), "Entity is not valid"); } // ------------------------------------- diff --git a/src/inferno/script/luascript.cpp b/src/inferno/script/luascript.cpp index 4167ff6..50847fb 100644 --- a/src/inferno/script/luascript.cpp +++ b/src/inferno/script/luascript.cpp @@ -66,14 +66,14 @@ namespace Inferno { std::string script = File::read(m_path); auto result = m_state.script(script.c_str(), [](lua_State*, sol::protected_function_result pfr) { return pfr; }); - ASSERT(result.valid(), "LuaScript {}", ((sol::error)result).what()); + VERIFY(result.valid(), "LuaScript {}", ((sol::error)result).what()); } sol::table LuaScript::getTable(const char* name) { sol::table table = m_state[name]; - ASSERT(table.valid(), "LuaScript table does not exist"); + VERIFY(table.valid(), "LuaScript table does not exist"); return table; } -} +} // namespace Inferno diff --git a/src/inferno/script/luascript.h b/src/inferno/script/luascript.h index f2f9cea..4c22eef 100644 --- a/src/inferno/script/luascript.h +++ b/src/inferno/script/luascript.h @@ -3,14 +3,13 @@ #include // uint32_t #include // std::string +#include "ruc/meta/assert.h" #define SOL_ALL_SAFETIES_ON 1 #include "sol/protected_function.hpp" #include "sol/protected_function_result.hpp" #include "sol/state.hpp" #include "sol/table.hpp" -#include "inferno/assert.h" - namespace Inferno { struct TransformComponent; @@ -37,7 +36,7 @@ namespace Inferno { // Only call function if it exists if (solFunction.valid()) { sol::protected_function_result result = solFunction(solTable, parameters...); - ASSERT(result.valid(), "Lua function {}", ((sol::error)result).what()); + VERIFY(result.valid(), "Lua function {}", ((sol::error)result).what()); } } diff --git a/src/inferno/singleton.h b/src/inferno/singleton.h index 04fcaab..0275a9c 100644 --- a/src/inferno/singleton.h +++ b/src/inferno/singleton.h @@ -1,6 +1,6 @@ #pragma once -#include "inferno/assert.h" +#include "ruc/meta/assert.h" namespace Inferno { @@ -12,20 +12,20 @@ namespace Inferno { public: static inline void initialize() { - ASSERT(!s_instance, "singleton already exists"); + VERIFY(!s_instance, "singleton already exists"); s_instance = new T { s {} }; } static inline void destroy() { - ASSERT(s_instance, "singleton does not exist"); + VERIFY(s_instance, "singleton does not exist"); delete s_instance; s_instance = nullptr; } static inline T& the() { - ASSERT(s_instance, "singleton does not exist"); + VERIFY(s_instance, "singleton does not exist"); return *s_instance; } diff --git a/src/inferno/system/camerasystem.cpp b/src/inferno/system/camerasystem.cpp index c527976..b7db0da 100644 --- a/src/inferno/system/camerasystem.cpp +++ b/src/inferno/system/camerasystem.cpp @@ -1,8 +1,8 @@ #include "glm/ext/matrix_clip_space.hpp" // glm::perspective, glm::ortho #include "glm/ext/matrix_transform.hpp" // glm::radians, glm::lookAt +#include "ruc/meta/assert.h" #include "inferno/application.h" -#include "inferno/assert.h" #include "inferno/component/cameracomponent.h" #include "inferno/component/transformcomponent.h" #include "inferno/io/input.h" @@ -44,7 +44,7 @@ namespace Inferno { return camera.projection * transform.transform; } - ASSERT_NOT_REACHED(); + VERIFY_NOT_REACHED(); return glm::mat4 { 1.0f }; } @@ -94,4 +94,4 @@ namespace Inferno { // Souce: https://learnopengl.com/img/getting-started/coordinate_systems.png } -} +} // namespace Inferno diff --git a/src/inferno/system/rendersystem.cpp b/src/inferno/system/rendersystem.cpp index 4ffc304..7b54894 100644 --- a/src/inferno/system/rendersystem.cpp +++ b/src/inferno/system/rendersystem.cpp @@ -1,6 +1,5 @@ #include "glm/ext/matrix_transform.hpp" // glm::translate, glm::rotate, glm::scale, glm::radians -#include "inferno/assert.h" #include "inferno/component/spritecomponent.h" #include "inferno/component/transformcomponent.h" #include "inferno/io/log.h" @@ -27,4 +26,4 @@ namespace Inferno { } } -} +} // namespace Inferno diff --git a/src/inferno/system/scriptsystem.cpp b/src/inferno/system/scriptsystem.cpp index 37d0a53..c804d13 100644 --- a/src/inferno/system/scriptsystem.cpp +++ b/src/inferno/system/scriptsystem.cpp @@ -1,6 +1,5 @@ #include "entt/entity/registry.hpp" // entt::entity, entt::registry -#include "inferno/assert.h" #include "inferno/component/luascriptcomponent.h" #include "inferno/component/nativescriptcomponent.h" #include "inferno/component/transformcomponent.h" @@ -68,7 +67,6 @@ namespace Inferno { luaScript.instance->update(deltaTime); } - } void ScriptSystem::cleanup(uint32_t entity) @@ -100,4 +98,4 @@ namespace Inferno { } } -} +} // namespace Inferno diff --git a/src/inferno/system/textareasystem.cpp b/src/inferno/system/textareasystem.cpp index 61db0bd..34a619f 100644 --- a/src/inferno/system/textareasystem.cpp +++ b/src/inferno/system/textareasystem.cpp @@ -1,5 +1,6 @@ +#include "ruc/meta/assert.h" + #include "inferno/application.h" -#include "inferno/assert.h" #include "inferno/component/textareacomponent.h" #include "inferno/render/font.h" #include "inferno/render/renderer.h" @@ -60,7 +61,7 @@ namespace Inferno { float textureWidth = static_cast(font->texture()->width()); float textureHeight = static_cast(font->texture()->height()); - ASSERT(textureWidth == textureHeight, "TextAreaSystem read invalid font texture"); + VERIFY(textureWidth == textureHeight, "TextAreaSystem read invalid font texture"); // Skip empty characters if (c->size.x == 0 || c->size.y == 0) { diff --git a/src/inferno/system/transformsystem.cpp b/src/inferno/system/transformsystem.cpp index edb9376..1cc4e3b 100644 --- a/src/inferno/system/transformsystem.cpp +++ b/src/inferno/system/transformsystem.cpp @@ -1,6 +1,5 @@ #include "glm/ext/matrix_transform.hpp" // glm::translate, glm::rotate, glm::scale, glm::radians -#include "inferno/assert.h" #include "inferno/component/transformcomponent.h" #include "inferno/io/log.h" #include "inferno/system/transformsystem.h" @@ -40,4 +39,4 @@ namespace Inferno { } } -} +} // namespace Inferno diff --git a/src/inferno/util/integer.h b/src/inferno/util/integer.h index cd5b1b7..9b7b87f 100644 --- a/src/inferno/util/integer.h +++ b/src/inferno/util/integer.h @@ -3,7 +3,7 @@ #include // std::numeric_limits #include // std::string, std::stoul -#include "inferno/assert.h" +#include "ruc/meta/assert.h" namespace std { @@ -12,7 +12,7 @@ namespace std { inline uint32_t stou(const std::string& string) { unsigned long size = std::stoul(string); - ASSERT(size <= std::numeric_limits::max(), "String util not in uint32_t range '{}'", string); + VERIFY(size <= std::numeric_limits::max(), "String util not in uint32_t range '{}'", string); return static_cast(size); } diff --git a/src/inferno/util/json.h b/src/inferno/util/json.h index 7fcdf32..736d2e6 100644 --- a/src/inferno/util/json.h +++ b/src/inferno/util/json.h @@ -6,8 +6,7 @@ #include // std::vector #include "nlohmann/json.hpp" - -#include "inferno/assert.h" +#include "ruc/meta/assert.h" namespace Inferno { @@ -81,7 +80,7 @@ namespace Inferno { // Has property exists = hasProperty(json, it, property); - ASSERT(!required || (required && exists), "Json could not find required property '{}'", property); + VERIFY(!required || (required && exists), "Json could not find required property '{}'", property); if (!exists) { return {}; @@ -105,14 +104,14 @@ namespace Inferno { // Has property exists = hasProperty(json, it, property); - ASSERT(!required || (required && exists), "Json could not find required property '{}'", property); + VERIFY(!required || (required && exists), "Json could not find required property '{}'", property); if (!exists) { return {}; } // Check if property is array [] - ASSERT(getValue(it).is_array(), "Json property is not an array '{}'", property); + VERIFY(getValue(it).is_array(), "Json property is not an array '{}'", property); // Fill array with values std::vector values; @@ -145,14 +144,14 @@ namespace Inferno { // Has property exists = hasProperty(json, it, property); - ASSERT(!required || (required && exists), "Json could not find required property '{}'", property); + VERIFY(!required || (required && exists), "Json could not find required property '{}'", property); if (!exists) { return {}; } // Check if property is an object {} - ASSERT(getValue(it).is_object(), "Json property is not an array '{}'", property); + VERIFY(getValue(it).is_object(), "Json property is not an array '{}'", property); std::map values; for (auto& [key, value] : getValue(it).items()) { diff --git a/src/inferno/window.cpp b/src/inferno/window.cpp index c05614e..5b93e39 100644 --- a/src/inferno/window.cpp +++ b/src/inferno/window.cpp @@ -1,9 +1,9 @@ #include // signal #include "GLFW/glfw3.h" +#include "ruc/meta/assert.h" #include "inferno/application.h" -#include "inferno/assert.h" #include "inferno/core.h" #include "inferno/event/applicationevent.h" #include "inferno/event/keyevent.h" @@ -61,7 +61,7 @@ namespace Inferno { // Create GLFW window m_window = glfwCreateWindow(width, height, title.c_str(), nullptr, nullptr); s_windowCount++; - ASSERT(m_window, "Failed to create GLFW window!"); + VERIFY(m_window, "Failed to create GLFW window!"); // Set windowed/fullscreen/borderless this->setWindowMonitor();