Skip to content

Commit

Permalink
Minor style improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-johansson committed Dec 15, 2023
1 parent f3e6124 commit a863492
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 81 deletions.
9 changes: 3 additions & 6 deletions modules/core/inc/tactile/core/map/layer/layer_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,21 @@ class ILayerVisitor {
*
* \param layer the visited layer.
*/
virtual void visit([[maybe_unused]] TileLayer& layer)
{}
virtual void visit([[maybe_unused]] TileLayer& layer) {}

/**
* \brief Visits an object layer.
*
* \param layer the visited layer.
*/
virtual void visit([[maybe_unused]] ObjectLayer& layer)
{}
virtual void visit([[maybe_unused]] ObjectLayer& layer) {}

/**
* \brief Visits a group layer.
*
* \param layer the visited layer.
*/
virtual void visit([[maybe_unused]] GroupLayer& layer)
{}
virtual void visit([[maybe_unused]] GroupLayer& layer) {}
};

/**
Expand Down
45 changes: 9 additions & 36 deletions modules/core/test/testutil/meta_context_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,23 @@ class MetaContextVisitorTester final : public IMetaContextVisitor {
int tileset_count {0};
int tile_count {0};

void visit([[maybe_unused]] OrthogonalMap& map) override
{
++orthogonal_map_count;
}
void visit([[maybe_unused]] OrthogonalMap& map) override { ++orthogonal_map_count; }

void visit([[maybe_unused]] IsometricMap& map) override
{
++isometric_map_count;
}
void visit([[maybe_unused]] IsometricMap& map) override { ++isometric_map_count; }

void visit([[maybe_unused]] HexagonalMap& map) override
{
++hexagonal_map_count;
}
void visit([[maybe_unused]] HexagonalMap& map) override { ++hexagonal_map_count; }

void visit([[maybe_unused]] GroupLayer& layer) override
{
++group_layer_count;
}
void visit([[maybe_unused]] GroupLayer& layer) override { ++group_layer_count; }

void visit([[maybe_unused]] TileLayer& layer) override
{
++tile_layer_count;
}
void visit([[maybe_unused]] TileLayer& layer) override { ++tile_layer_count; }

void visit([[maybe_unused]] ObjectLayer& layer) override
{
++object_layer_count;
}
void visit([[maybe_unused]] ObjectLayer& layer) override { ++object_layer_count; }

void visit([[maybe_unused]] Object& object) override
{
++object_count;
}
void visit([[maybe_unused]] Object& object) override { ++object_count; }

void visit([[maybe_unused]] Tileset& tileset) override
{
++tileset_count;
}
void visit([[maybe_unused]] Tileset& tileset) override { ++tileset_count; }

void visit([[maybe_unused]] Tile& tile) override
{
++tile_count;
}
void visit([[maybe_unused]] Tile& tile) override { ++tile_count; }
};

} // namespace tactile::testutil
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <unordered_map> // unordered_map

#include "tactile/foundation/api.hpp"
#include "tactile/foundation/prelude.hpp"
#include "tactile/foundation/container/string.hpp"
#include "tactile/foundation/prelude.hpp"

namespace tactile {

Expand Down
15 changes: 7 additions & 8 deletions modules/foundation/inc/tactile/foundation/functional/hash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ void hash_combine(usize& seed, const T& value) noexcept

} // namespace tactile

#define TACTILE_IMPLEMENT_HASH(Type, ...) \
template <> \
struct std::hash<Type> final { \
[[nodiscard]] auto operator()(const Type& value) const noexcept \
-> tactile::usize \
{ \
return tactile::hash_combine(__VA_ARGS__); \
} \
#define TACTILE_IMPLEMENT_HASH(Type, ...) \
template <> \
struct std::hash<Type> final { \
[[nodiscard]] auto operator()(const Type& value) const noexcept -> tactile::usize \
{ \
return tactile::hash_combine(__VA_ARGS__); \
} \
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GenericErrorCategory final : public std::error_category {
case GenericError::kIOError: return "unknown I/O error";
}

return "unknown";
return "?";
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CompressionErrorCategory final : public std::error_category {
case CompressionError::kInvalidMode: return "detected an invalid compression mode";
}

return "unknown";
return "?";
}
};

Expand Down
4 changes: 2 additions & 2 deletions modules/foundation/src/tactile/foundation/io/ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ auto get_attribute_type(const Component& component, StringView attr_name)
const auto attribute_iter =
std::find_if(component.attributes.begin(),
component.attributes.end(),
[attr_name](const ir::NamedAttribute& attribute) {
return attribute.name == attr_name;
[attr_name](const ir::NamedAttribute& stored_attribute) {
return stored_attribute.name == attr_name;
});

if (attribute_iter != component.attributes.end()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ class UnixDynamicLibrary final : public IDynamicLibrary {
return dlsym(mHandle, name);
}

[[nodiscard]] auto get_path() const -> const FilePath& override
{
return mPath;
}
[[nodiscard]] auto get_path() const -> const FilePath& override { return mPath; }

private:
FilePath mPath;
Expand Down Expand Up @@ -96,10 +93,7 @@ class Win32DynamicLibrary final : public IDynamicLibrary {
return static_cast<void*>(GetProcAddress(mHandle, name));
}

[[nodiscard]] auto get_path() const -> const FilePath& override
{
return mPath;
}
[[nodiscard]] auto get_path() const -> const FilePath& override { return mPath; }

private:
FilePath mPath;
Expand Down
4 changes: 2 additions & 2 deletions modules/foundation/test/io/filesystem_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ TEST(Filesystem, GetPersistentStorageDirectory)
EXPECT_NO_THROW((void) get_persistent_storage_directory());
}


/// \tests tactile::normalize_path
TEST(Filesystem, NormalizePath)
{
Expand All @@ -39,7 +38,8 @@ TEST(Filesystem, ShortenHomeDirectoryPrefix)

EXPECT_EQ(shorten_home_directory_prefix(home), "~");
EXPECT_EQ(shorten_home_directory_prefix(home.string() + "/foo/"), "~/foo/");
EXPECT_EQ(shorten_home_directory_prefix(home.string() + "/foo/bar.txt"), "~/foo/bar.txt");
EXPECT_EQ(shorten_home_directory_prefix(home.string() + "/foo/bar.txt"),
"~/foo/bar.txt");
EXPECT_EQ(shorten_home_directory_prefix(home.string() + '/'), "~/");

EXPECT_FALSE(shorten_home_directory_prefix("/a/b").has_value());
Expand Down
4 changes: 2 additions & 2 deletions modules/foundation/test/io/save/save_format_context_test.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (C) 2023 Albin Johansson (GNU General Public License v3.0)

#include "tactile/foundation/io/save/save_format_context.hpp"

#include <gmock/gmock.h>
#include <gtest/gtest.h>

#include "tactile/foundation/io/save/save_format_context.hpp"

using namespace tactile;
using testing::Return;

Expand Down
20 changes: 10 additions & 10 deletions modules/opengl/src/tactile/opengl/opengl_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ class OpenGLErrorCategory final : public std::error_category {
auto message(const int value) const -> std::string override
{
switch (OpenGLError {value}) {
case OpenGLError::kUnknown: return "unknown";
case OpenGLError::kInvalidEnum: return "invalid enum";
case OpenGLError::kInvalidValue: return "invalid value";
case OpenGLError::kInvalidOperation: return "invalid operation";
case OpenGLError::kStackOverflow: return "stack overflow";
case OpenGLError::kStackUnderflow: return "stack underflow";
case OpenGLError::kOutOfMemory: return "out of memory";
case OpenGLError::kInvalidFramebufferOperation:
return "invalid framebuffer operation";
using enum OpenGLError;
case kUnknown: return "unknown";
case kInvalidEnum: return "invalid enum";
case kInvalidValue: return "invalid value";
case kInvalidOperation: return "invalid operation";
case kStackOverflow: return "stack overflow";
case kStackUnderflow: return "stack underflow";
case kOutOfMemory: return "out of memory";
case kInvalidFramebufferOperation: return "invalid framebuffer operation";
}

return "unknown";
return "?";
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ TACTILE_YML_FORMAT_API void emit(YAML::Emitter& emitter, const Attribute& value)
TACTILE_YML_FORMAT_API void emit_metadata(YAML::Emitter& emitter,
const ir::Metadata& metadata);

} // namespace tactile
} // namespace tactile::yml_format
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ TACTILE_TMJ_API auto parse_property(const JSON& json) -> Result<ir::NamedAttribu
[[nodiscard]]
TACTILE_TMJ_API auto parse_metadata(const JSON& json, ir::Metadata& meta) -> Result<void>;

} // namespace tactile
} // namespace tactile::tmj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#include <fmt/std.h>

#include "tactile/foundation/log/logger.hpp"
#include "tactile/foundation/io/save/save_format_error.hpp"
#include "tactile/foundation/log/logger.hpp"
#include "tactile/tmj-format/common/json.hpp"
#include "tactile/tmj-format/load/tmj_layer_parser.hpp"
#include "tactile/tmj-format/load/tmj_meta_parser.hpp"
Expand Down
1 change: 0 additions & 1 deletion modules/tmj-format/test/emit/tmj_object_emitter_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,3 @@ TEST_P(ParameterizedTmjObjectEmitterTest, EmitObject)
EXPECT_EQ(object_json.at("properties").at(1).at("type"), "string");
EXPECT_EQ(object_json.at("properties").at(1).at("value"), "XYZ");
}

0 comments on commit a863492

Please sign in to comment.