Skip to content

Commit

Permalink
Migrate debug utilities to base
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-johansson committed Oct 29, 2024
1 parent 3524040 commit bfd8d38
Show file tree
Hide file tree
Showing 52 changed files with 90 additions and 144 deletions.
2 changes: 2 additions & 0 deletions source/base/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ target_sources(tactile-base
"inc/tactile/base/container/lookup.hpp"
"inc/tactile/base/container/string.hpp"
"inc/tactile/base/container/string_map.hpp"
"inc/tactile/base/debug/error_code.hpp"
"inc/tactile/base/debug/validation.hpp"
"inc/tactile/base/document/component_view.hpp"
"inc/tactile/base/document/document.hpp"
"inc/tactile/base/document/document_visitor.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

#pragma once

#include "tactile/base/prelude.hpp"
#include "tactile/core/debug/exception.hpp"
#include <stdexcept> // invalid_argument

namespace tactile::core {
namespace tactile {

/**
* Throws an exception if the provided pointer is null, returns it if not.
Expand All @@ -21,23 +20,23 @@ namespace tactile::core {
* {}
* \endcode
*
* \tparam PointerType A pointer-like type.
* \tparam Pointer A pointer-like type.
*
* \param ptr The pointer to validate.
* \param error_message An error message used if the pointer is null.
*
* \return
* The provided pointer.
*/
template <typename PointerType>
[[nodiscard]] auto require_not_null(PointerType ptr,
const char* error_message = "null pointer") -> PointerType
template <typename Pointer>
[[nodiscard]] auto require_not_null(Pointer ptr, const char* error_message = "null pointer")
-> Pointer
{
if (ptr == nullptr) [[unlikely]] {
throw Exception {error_message};
throw std::invalid_argument {error_message};
}

return ptr;
}

} // namespace tactile::core
} // namespace tactile
3 changes: 0 additions & 3 deletions source/core/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ target_sources(tactile-core
"src/cmd/tile/remove_tileset_command.cpp"
"src/cmd/command_stack.cpp"
"src/debug/assert.cpp"
"src/debug/exception.cpp"
"src/debug/performance.cpp"
"src/debug/stacktrace.cpp"
"src/debug/terminate.cpp"
Expand Down Expand Up @@ -132,11 +131,9 @@ target_sources(tactile-core
"inc/tactile/core/cmd/command.hpp"
"inc/tactile/core/cmd/command_stack.hpp"
"inc/tactile/core/debug/assert.hpp"
"inc/tactile/core/debug/exception.hpp"
"inc/tactile/core/debug/performance.hpp"
"inc/tactile/core/debug/stacktrace.hpp"
"inc/tactile/core/debug/terminate.hpp"
"inc/tactile/core/debug/validation.hpp"
"inc/tactile/core/document/document_info.hpp"
"inc/tactile/core/document/document_manager.hpp"
"inc/tactile/core/document/layer_view_impl.hpp"
Expand Down
29 changes: 0 additions & 29 deletions source/core/lib/inc/tactile/core/debug/exception.hpp

This file was deleted.

16 changes: 8 additions & 8 deletions source/core/lib/inc/tactile/core/entity/registry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

#pragma once

#include <cstddef> // size_t
#include <optional> // optional, nullopt
#include <utility> // forward, move
#include <cstddef> // size_t
#include <optional> // optional, nullopt
#include <stdexcept> // out_of_range
#include <utility> // forward, move

#include <entt/entity/registry.hpp>

#include "tactile/base/prelude.hpp"
#include "tactile/core/debug/assert.hpp"
#include "tactile/core/debug/exception.hpp"
#include "tactile/core/entity/entity.hpp"

namespace tactile::core {
Expand Down Expand Up @@ -130,7 +130,7 @@ class Registry final
return *component;
}

throw Exception {"missing context component"};
throw std::out_of_range {"missing context component"};
}

/**
Expand All @@ -143,7 +143,7 @@ class Registry final
return *component;
}

throw Exception {"missing context component"};
throw std::out_of_range {"missing context component"};
}

/**
Expand All @@ -163,7 +163,7 @@ class Registry final
return *component;
}

throw Exception {"bad entity"};
throw std::out_of_range {"bad entity"};
}

/**
Expand All @@ -176,7 +176,7 @@ class Registry final
return *component;
}

throw Exception {"bad entity"};
throw std::out_of_range {"bad entity"};
}

/**
Expand Down
10 changes: 5 additions & 5 deletions source/core/lib/inc/tactile/core/ui/imgui_compat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

#pragma once

#include <concepts> // signed_integral, unsigned_integral, floating_point
#include <concepts> // signed_integral, unsigned_integral, floating_point
#include <stdexcept> // runtime_error

#include <imgui.h>

#include "tactile/base/numeric/vec.hpp"
#include "tactile/base/prelude.hpp"
#include "tactile/base/util/concepts.hpp"
#include "tactile/core/debug/exception.hpp"

namespace tactile::core {

Expand Down Expand Up @@ -117,7 +117,7 @@ template <std::signed_integral T>
case sizeof(std::int16_t): return ImGuiDataType_S16;
case sizeof(std::int32_t): return ImGuiDataType_S32;
case sizeof(std::int64_t): return ImGuiDataType_S64;
default: throw Exception {"unsupported signed integer size"};
default: throw std::runtime_error {"unsupported signed integer size"};
}
}

Expand All @@ -137,7 +137,7 @@ template <std::unsigned_integral T>
case sizeof(std::uint16_t): return ImGuiDataType_U16;
case sizeof(std::uint32_t): return ImGuiDataType_U32;
case sizeof(std::uint64_t): return ImGuiDataType_U64;
default: throw Exception {"unsupported unsigned integer size"};
default: throw std::runtime_error {"unsupported unsigned integer size"};
}
}

Expand All @@ -155,7 +155,7 @@ template <std::floating_point T>
switch (sizeof(T)) {
case sizeof(float): return ImGuiDataType_Float;
case sizeof(double): return ImGuiDataType_Double;
default: throw Exception {"unsupported float size"};
default: throw std::runtime_error {"unsupported float size"};
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/core/lib/src/cmd/layer/create_layer_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "tactile/core/cmd/layer/create_layer_command.hpp"

#include "tactile/core/debug/validation.hpp"
#include "tactile/base/debug/validation.hpp"
#include "tactile/core/document/document_info.hpp"
#include "tactile/core/document/map_document.hpp"
#include "tactile/core/entity/registry.hpp"
Expand Down
2 changes: 1 addition & 1 deletion source/core/lib/src/cmd/layer/duplicate_layer_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "tactile/core/cmd/layer/duplicate_layer_command.hpp"

#include "tactile/core/debug/validation.hpp"
#include "tactile/base/debug/validation.hpp"
#include "tactile/core/document/document_info.hpp"
#include "tactile/core/document/map_document.hpp"
#include "tactile/core/entity/registry.hpp"
Expand Down
2 changes: 1 addition & 1 deletion source/core/lib/src/cmd/layer/move_layer_down_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "tactile/core/cmd/layer/move_layer_down_command.hpp"

#include "tactile/core/debug/validation.hpp"
#include "tactile/base/debug/validation.hpp"
#include "tactile/core/document/document_info.hpp"
#include "tactile/core/document/map_document.hpp"
#include "tactile/core/entity/registry.hpp"
Expand Down
2 changes: 1 addition & 1 deletion source/core/lib/src/cmd/layer/move_layer_up_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "tactile/core/cmd/layer/move_layer_up_command.hpp"

#include "tactile/core/debug/validation.hpp"
#include "tactile/base/debug/validation.hpp"
#include "tactile/core/document/document_info.hpp"
#include "tactile/core/document/map_document.hpp"
#include "tactile/core/entity/registry.hpp"
Expand Down
2 changes: 1 addition & 1 deletion source/core/lib/src/cmd/layer/remove_layer_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "tactile/core/cmd/layer/remove_layer_command.hpp"

#include "tactile/core/debug/validation.hpp"
#include "tactile/base/debug/validation.hpp"
#include "tactile/core/document/document_info.hpp"
#include "tactile/core/document/map_document.hpp"
#include "tactile/core/entity/registry.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <utility> // exchange

#include "tactile/core/debug/validation.hpp"
#include "tactile/base/debug/validation.hpp"
#include "tactile/core/document/map_document.hpp"
#include "tactile/core/entity/registry.hpp"
#include "tactile/core/layer/layer_types.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <utility> // exchange

#include "tactile/core/debug/validation.hpp"
#include "tactile/base/debug/validation.hpp"
#include "tactile/core/document/map_document.hpp"
#include "tactile/core/entity/registry.hpp"
#include "tactile/core/layer/layer_types.hpp"
Expand Down
2 changes: 1 addition & 1 deletion source/core/lib/src/cmd/meta/create_property_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "tactile/base/container/lookup.hpp"
#include "tactile/base/document/document.hpp"
#include "tactile/core/debug/validation.hpp"
#include "tactile/base/debug/validation.hpp"
#include "tactile/core/entity/registry.hpp"
#include "tactile/core/logging.hpp"
#include "tactile/core/meta/meta.hpp"
Expand Down
2 changes: 1 addition & 1 deletion source/core/lib/src/cmd/meta/remove_property_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "tactile/base/container/lookup.hpp"
#include "tactile/base/document/document.hpp"
#include "tactile/core/debug/validation.hpp"
#include "tactile/base/debug/validation.hpp"
#include "tactile/core/entity/registry.hpp"
#include "tactile/core/logging.hpp"
#include "tactile/core/meta/meta.hpp"
Expand Down
2 changes: 1 addition & 1 deletion source/core/lib/src/cmd/meta/rename_property_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "tactile/base/container/lookup.hpp"
#include "tactile/base/document/document.hpp"
#include "tactile/core/debug/assert.hpp"
#include "tactile/core/debug/validation.hpp"
#include "tactile/base/debug/validation.hpp"
#include "tactile/core/entity/registry.hpp"
#include "tactile/core/logging.hpp"
#include "tactile/core/meta/meta.hpp"
Expand Down
2 changes: 1 addition & 1 deletion source/core/lib/src/cmd/meta/update_property_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "tactile/base/container/lookup.hpp"
#include "tactile/base/document/document.hpp"
#include "tactile/core/debug/validation.hpp"
#include "tactile/base/debug/validation.hpp"
#include "tactile/core/entity/registry.hpp"
#include "tactile/core/logging.hpp"
#include "tactile/core/meta/meta.hpp"
Expand Down
2 changes: 1 addition & 1 deletion source/core/lib/src/cmd/object/create_object_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "tactile/core/cmd/object/create_object_command.hpp"

#include "tactile/core/debug/validation.hpp"
#include "tactile/base/debug/validation.hpp"
#include "tactile/core/document/document_info.hpp"
#include "tactile/core/document/map_document.hpp"
#include "tactile/core/entity/registry.hpp"
Expand Down
2 changes: 1 addition & 1 deletion source/core/lib/src/cmd/object/move_object_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "tactile/base/document/document.hpp"
#include "tactile/base/numeric/vec_format.hpp"
#include "tactile/core/debug/validation.hpp"
#include "tactile/base/debug/validation.hpp"
#include "tactile/core/entity/registry.hpp"
#include "tactile/core/layer/layer_types.hpp"
#include "tactile/core/logging.hpp"
Expand Down
2 changes: 1 addition & 1 deletion source/core/lib/src/cmd/object/remove_object_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "tactile/core/cmd/object/remove_object_command.hpp"

#include "tactile/core/debug/validation.hpp"
#include "tactile/base/debug/validation.hpp"
#include "tactile/core/document/map_document.hpp"
#include "tactile/core/entity/registry.hpp"
#include "tactile/core/layer/layer_types.hpp"
Expand Down
2 changes: 1 addition & 1 deletion source/core/lib/src/cmd/object/set_object_tag_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <utility> // move, exchange

#include "tactile/base/document/document.hpp"
#include "tactile/core/debug/validation.hpp"
#include "tactile/base/debug/validation.hpp"
#include "tactile/core/entity/registry.hpp"
#include "tactile/core/layer/layer_types.hpp"
#include "tactile/core/logging.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <utility> // exchange

#include "tactile/base/document/document.hpp"
#include "tactile/core/debug/validation.hpp"
#include "tactile/base/debug/validation.hpp"
#include "tactile/core/entity/registry.hpp"
#include "tactile/core/layer/layer_types.hpp"
#include "tactile/core/logging.hpp"
Expand Down
2 changes: 1 addition & 1 deletion source/core/lib/src/cmd/tile/add_tileset_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <exception> // exception
#include <utility> // move

#include "tactile/core/debug/validation.hpp"
#include "tactile/base/debug/validation.hpp"
#include "tactile/core/document/document_info.hpp"
#include "tactile/core/document/map_document.hpp"
#include "tactile/core/entity/registry.hpp"
Expand Down
2 changes: 1 addition & 1 deletion source/core/lib/src/cmd/tile/remove_tileset_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "tactile/core/cmd/tile/remove_tileset_command.hpp"

#include "tactile/core/debug/validation.hpp"
#include "tactile/base/debug/validation.hpp"
#include "tactile/core/document/document_info.hpp"
#include "tactile/core/document/map_document.hpp"
#include "tactile/core/entity/registry.hpp"
Expand Down
26 changes: 0 additions & 26 deletions source/core/lib/src/debug/exception.cpp

This file was deleted.

Loading

0 comments on commit bfd8d38

Please sign in to comment.