Skip to content

Commit

Permalink
fix: solve multiple clang-tidy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
RiscadoA committed Feb 1, 2024
1 parent 45fca84 commit f4bbe25
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 29 deletions.
2 changes: 1 addition & 1 deletion core/include/cubos/core/ecs/system/arguments/commands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ namespace cubos::core::ecs
{
}

Commands fetch(CommandBuffer& cmdBuffer)
static Commands fetch(CommandBuffer& cmdBuffer)
{
return {cmdBuffer};
}
Expand Down
4 changes: 2 additions & 2 deletions core/include/cubos/core/ecs/system/arguments/world.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace cubos::core::ecs
{
}

void analyze(SystemAccess& access) const
static void analyze(SystemAccess& access)
{
access.usesWorld = true;
}
Expand All @@ -45,7 +45,7 @@ namespace cubos::core::ecs
{
}

void analyze(SystemAccess& access) const
static void analyze(SystemAccess& access)
{
access.usesWorld = true;
}
Expand Down
5 changes: 0 additions & 5 deletions core/include/cubos/core/ecs/system/dispatcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ namespace cubos::core::ecs
public:
~Dispatcher();

/// @brief Constructs.
/// @param world World.
Dispatcher(World& world);

/// @brief Adds a tag, and sets it as the current tag for further settings.
/// @param tag Tag to add.
void addTag(const std::string& tag);
Expand Down Expand Up @@ -187,7 +183,6 @@ namespace cubos::core::ecs
// Variables for holding information after call chain is compiled.

std::vector<System*> mSystems; ///< Compiled order of running systems.
World& mWorld;
};

inline void Dispatcher::tagAddCondition(ecs::System<bool> condition)
Expand Down
9 changes: 7 additions & 2 deletions core/include/cubos/core/ecs/system/fetcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace cubos::core::ecs
{
class World;
class CommandBuffer;
class SystemOptions;
class SystemAccess;
struct SystemOptions;
struct SystemAccess;

/// @brief Type meant to be specialized which implements for each argument type the necessary logic to extract it
/// from the world.
Expand All @@ -18,6 +18,7 @@ namespace cubos::core::ecs
template <typename T>
class SystemFetcher
{
public:
/// @brief Indicates whether this argument type consumes system options.
static inline constexpr bool ConsumesOptions = false;

Expand All @@ -37,6 +38,8 @@ namespace cubos::core::ecs
/// @param[out] access Access patterns to add info to.
void analyze(SystemAccess& access) const
{
(void)access;

// This should never be instantiated. This method is only defined for documentation purposes.
static_assert(AlwaysFalse<T>, "Invalid system argument type");
}
Expand All @@ -45,6 +48,8 @@ namespace cubos::core::ecs
/// @param cmdBuffer Command buffer.
T fetch(CommandBuffer& cmdBuffer)
{
(void)cmdBuffer;

// This should never be instantiated. This method is only defined for documentation purposes.
static_assert(AlwaysFalse<T>, "Invalid system argument type");
}
Expand Down
12 changes: 8 additions & 4 deletions core/include/cubos/core/ecs/system/system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ namespace cubos::core::ecs
/// @param options Options for the system arguments.
static System make(World& world, auto function, const std::vector<SystemOptions>& options = {})
{
using Function = SystemTraits<decltype(function)>::Function;
using Function = typename SystemTraits<decltype(function)>::Function;
return {std::make_unique<Function>(world, std::move(function), options)};
}

/// @brief Move constructs.
/// @param system Other system.
System(System&& system) = default;
System(System&& system) noexcept = default;

/// @brief Runs the system.
/// @param cmdBuffer Command buffer.
Expand All @@ -70,7 +70,7 @@ namespace cubos::core::ecs
/// @brief Specific class for the stored system function type with specific arguments.
/// @tparam As Argument types.
template <typename F, typename... As>
class SystemFunction;
class SystemFunction; // NOLINT(cppcoreguidelines-virtual-class-destructor)

/// @brief Used to get a @ref SystemFunction from any functional type.
/// @tparam F Original function type.
Expand Down Expand Up @@ -116,12 +116,15 @@ namespace cubos::core::ecs
SystemAccess mAccess;
};

// The warning being disabled seems to be an error in clang-tidy, as described in
// https://github.com/llvm/llvm-project/issues/51759
// NOLINTBEGIN(cppcoreguidelines-virtual-class-destructor)
template <typename T>
template <typename F, typename... As>
class System<T>::SystemFunction : public AnySystemFunction
{
public:
virtual ~SystemFunction() final
~SystemFunction() override
{
delete mFetchers;
}
Expand Down Expand Up @@ -182,6 +185,7 @@ namespace cubos::core::ecs
F mFunction;
std::tuple<SystemFetcher<As>...>* mFetchers;
};
// NOLINTEND(cppcoreguidelines-virtual-class-destructor)

template <typename T>
template <typename F, typename... As>
Expand Down
3 changes: 0 additions & 3 deletions core/src/cubos/core/ecs/cubos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,6 @@ Cubos::Cubos()
}

Cubos::Cubos(int argc, char** argv)
: mWorld{}
, mStartupDispatcher{mWorld}
, mMainDispatcher{mWorld}
{
std::vector<std::string> arguments(argv + 1, argv + argc);

Expand Down
5 changes: 0 additions & 5 deletions core/src/cubos/core/ecs/system/dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ Dispatcher::~Dispatcher()
}
}

Dispatcher::Dispatcher(World& world)
: mWorld{world}
{
}

void Dispatcher::addTag(const std::string& tag)
{
ENSURE_TAG_SETTINGS(tag);
Expand Down
3 changes: 2 additions & 1 deletion core/src/cubos/core/ecs/world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ void World::relate(Entity from, Entity to, const reflection::Type& type, void* v
if (row != table.size())
{
// If it is, then call unrelate() to erase the relation.
uint32_t fromIndex, toIndex;
uint32_t fromIndex;
uint32_t toIndex;
table.indices(row, fromIndex, toIndex);
this->unrelate(from, Entity{toIndex, this->generation(toIndex)}, type);
break;
Expand Down
2 changes: 1 addition & 1 deletion core/src/cubos/core/gl/ogl_render_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ OGLRenderDevice::OGLRenderDevice()
{
// Set the debug message callback
// TODO: disable this on release for performance reasons (?)
if (getProperty(Property::ComputeSupported))
if (this->OGLRenderDevice::getProperty(Property::ComputeSupported) != 0)
{
glEnable(GL_DEBUG_OUTPUT);
glDebugMessageCallback(messageCallback, nullptr);
Expand Down
2 changes: 1 addition & 1 deletion core/tests/ecs/dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ TEST_CASE("ecs::Dispatcher")
{
World world{};
CommandBuffer cmdBuffer{world};
Dispatcher dispatcher{world};
Dispatcher dispatcher{};
world.registerResource<std::vector<int>>();

auto wrapSystem = [&](auto f) { return System<void>::make(world, f); };
Expand Down
6 changes: 3 additions & 3 deletions core/tests/ecs/utils/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,15 +444,15 @@ void SingleTargetQueryAction::test(World& world, ExpectedWorld& expected)
for (const auto& [entity, expectedEntity] : expected.aliveEntities)
{
bool shouldMatch = true;
for (auto* type : mWith)
for (const auto* type : mWith)
{
if (!expectedEntity.components.contains(type))
{
shouldMatch = false;
break;
}
}
for (auto* type : mWithout)
for (const auto* type : mWithout)
{
if (expectedEntity.components.contains(type))
{
Expand Down Expand Up @@ -739,7 +739,7 @@ void SingleRelationQueryAction::test(World& world, ExpectedWorld& expected)
}
}

for (auto* type : mWithoutB)
for (const auto* type : mWithoutB)
{
if (toExpectedEntity.components.contains(type))
{
Expand Down
3 changes: 2 additions & 1 deletion engine/src/cubos/engine/assets/assets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ bool Assets::update(AnyAsset& handle) const
handle.mVersion = assetEntry->version;
return true;
}
else if (assetEntry->version > handle.getVersion())

if (assetEntry->version > handle.getVersion())
{
handle.mVersion = assetEntry->version;
return true;
Expand Down

0 comments on commit f4bbe25

Please sign in to comment.