Remove redundant virtual keywords

This commit performs code cleanup to improve
code clarity and consistency:

Remove redundant 'virtual' keywords from methods that are already marked
with 'final' or 'override', as well as reducing redundant 'override
final's to 'final'.
This commit is contained in:
animus 2026-01-16 23:14:58 +02:00 committed by phosit
parent 6fc47e2997
commit ac62e7a42b
No known key found for this signature in database
GPG key ID: C9430B600671C268
5 changed files with 47 additions and 47 deletions

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2025 Wildfire Games.
/* Copyright (C) 2026 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -169,52 +169,52 @@ protected:
// BaseProxyHandler interface below
// Handler for `object.x`
virtual bool get(JSContext* cx, JS::HandleObject proxy, JS::HandleValue receiver, JS::HandleId id, JS::MutableHandleValue vp) const override final;
bool get(JSContext* cx, JS::HandleObject proxy, JS::HandleValue receiver, JS::HandleId id, JS::MutableHandleValue vp) const final;
// Handler for `object.x = y;`
virtual bool set(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::HandleValue vp,
bool set(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::HandleValue vp,
JS::HandleValue receiver, JS::ObjectOpResult& result) const final;
// Handler for `delete object.x;`
virtual bool delete_(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::ObjectOpResult& result) const override final;
bool delete_(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::ObjectOpResult& result) const final;
// The following methods are not provided by BaseProxyHandler.
// We provide defaults that do nothing (some raise JS exceptions).
virtual bool getOwnPropertyDescriptor(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::MutableHandle<mozilla::Maybe<JS::PropertyDescriptor>> desc) const override final;
bool getOwnPropertyDescriptor(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::MutableHandle<mozilla::Maybe<JS::PropertyDescriptor>> desc) const final;
// Throw an exception is JS code attempts defining a property.
virtual bool defineProperty(JSContext*, JS::HandleObject /*proxy*/, JS::HandleId,
bool defineProperty(JSContext*, JS::HandleObject /*proxy*/, JS::HandleId,
JS::Handle<JS::PropertyDescriptor>, JS::ObjectOpResult& /*result*/) const override
{
return false;
}
virtual bool ownPropertyKeys(JSContext* cx, JS::HandleObject proxy, JS::MutableHandleIdVector props) const override final;
bool ownPropertyKeys(JSContext* cx, JS::HandleObject proxy, JS::MutableHandleIdVector props) const final;
// Nothing to enumerate.
virtual bool enumerate(JSContext*, JS::HandleObject /*proxy*/,
bool enumerate(JSContext*, JS::HandleObject /*proxy*/,
JS::MutableHandleIdVector /*props*/) const override
{
return true;
}
// Throw an exception is JS attempts to query the prototype.
virtual bool getPrototypeIfOrdinary(JSContext*, JS::HandleObject /*proxy*/, bool* /*isOrdinary*/,
bool getPrototypeIfOrdinary(JSContext*, JS::HandleObject /*proxy*/, bool* /*isOrdinary*/,
JS::MutableHandleObject /*protop*/) const override
{
return false;
}
// Throw an exception - no prototype to set.
virtual bool setImmutablePrototype(JSContext*, JS::HandleObject /*proxy*/,
bool setImmutablePrototype(JSContext*, JS::HandleObject /*proxy*/,
bool* /*succeeded*/) const override
{
return false;
}
// We are not extensible.
virtual bool preventExtensions(JSContext*, JS::HandleObject /*proxy*/,
bool preventExtensions(JSContext*, JS::HandleObject /*proxy*/,
JS::ObjectOpResult& /*result*/) const override
{
return true;
}
virtual bool isExtensible(JSContext*, JS::HandleObject /*proxy*/, bool* extensible) const override
bool isExtensible(JSContext*, JS::HandleObject /*proxy*/, bool* extensible) const override
{
*extensible = false;
return true;

View file

@ -87,23 +87,23 @@ class MapCache : public GUIProxyProps
public:
virtual ~MapCache() {};
virtual bool has(const std::string& name) const override
bool has(const std::string& name) const override
{
return m_Functions.find(name) != m_Functions.end();
}
virtual JSObject* get(const std::string& name) const override
JSObject* get(const std::string& name) const override
{
return m_Functions.at(name).get();
}
virtual bool setFunction(const ScriptRequest& rq, const std::string& name, JSFunction* function) override
bool setFunction(const ScriptRequest& rq, const std::string& name, JSFunction* function) override
{
m_Functions[name].init(rq.cx, JS_GetFunctionObject(function));
return true;
}
virtual std::vector<std::string_view> getPropsNames() const override
std::vector<std::string_view> getPropsNames() const override
{
std::vector<std::string_view> result;
result.reserve(m_Functions.size());

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2025 Wildfire Games.
/* Copyright (C) 2026 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -141,7 +141,7 @@ public:
return mask;
}
virtual bool IsMouseOver(const CVector2D& mousePos, const CRect& objectSize) const override
bool IsMouseOver(const CVector2D& mousePos, const CRect& objectSize) const override
{
if (m_Data.empty())
return false;

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2025 Wildfire Games.
/* Copyright (C) 2026 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -64,35 +64,35 @@ public:
// Test data
Grid<NavcellData> m_PassabilityGrid;
virtual pass_class_t GetPassabilityClass(const std::string&) const override { return 0; }
virtual const Grid<NavcellData>& GetPassabilityGrid() override { return m_PassabilityGrid; }
pass_class_t GetPassabilityClass(const std::string&) const override { return 0; }
const Grid<NavcellData>& GetPassabilityGrid() override { return m_PassabilityGrid; }
// Irrelevant part of the mock.
virtual void GetPassabilityClasses(std::map<std::string, pass_class_t>&) const override {}
virtual void GetPassabilityClasses(std::map<std::string, pass_class_t>&, std::map<std::string, pass_class_t>&) const override {}
virtual entity_pos_t GetClearance(pass_class_t) const override { return entity_pos_t::FromInt(1); }
virtual entity_pos_t GetMaximumClearance() const override { return entity_pos_t::FromInt(1); }
virtual const GridUpdateInformation& GetAIPathfinderDirtinessInformation() const override { static GridUpdateInformation gridInfo; return gridInfo; }
virtual void FlushAIPathfinderDirtinessInformation() override {}
virtual Grid<u16> ComputeShoreGrid(bool = false) override { return Grid<u16> {}; }
virtual u32 ComputePathAsync(entity_pos_t, entity_pos_t, const PathGoal&, pass_class_t, entity_id_t) override { return 1; }
virtual void ComputePathImmediate(entity_pos_t, entity_pos_t, const PathGoal&, pass_class_t, WaypointPath&) const override {}
virtual u32 ComputeShortPathAsync(entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, const PathGoal&, pass_class_t, bool, entity_id_t, entity_id_t) override { return 1; }
virtual WaypointPath ComputeShortPathImmediate(const ShortPathRequest&) const override { return WaypointPath(); }
virtual void SetDebugPath(entity_pos_t, entity_pos_t, const PathGoal&, pass_class_t) override {}
virtual bool IsGoalReachable(entity_pos_t, entity_pos_t, const PathGoal&, pass_class_t) override { return false; }
virtual std::vector<CFixedVector2D> DistributeAround(std::vector<entity_id_t>, entity_pos_t, entity_pos_t) const override { return {}; }
virtual bool CheckMovement(const IObstructionTestFilter&, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, pass_class_t) const override { return false; }
virtual ICmpObstruction::EFoundationCheck CheckUnitPlacement(const IObstructionTestFilter&, entity_pos_t, entity_pos_t, entity_pos_t, pass_class_t, bool = false) const override { return ICmpObstruction::FOUNDATION_CHECK_SUCCESS; }
virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter&, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_id_t, pass_class_t) const override { return ICmpObstruction::FOUNDATION_CHECK_SUCCESS; }
virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter&, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_id_t, pass_class_t, bool) const override { return ICmpObstruction::FOUNDATION_CHECK_SUCCESS; }
virtual void SetDebugOverlay(bool) override {}
virtual void SetHierDebugOverlay(bool) override {}
virtual void SendRequestedPaths() override {}
virtual void StartProcessingMoves(bool) override {}
virtual void UpdateGrid() override {}
virtual void GetDebugData(u32&, double&, Grid<u8>&) const override {}
virtual void SetAtlasOverlay(bool, pass_class_t = 0) override {}
void GetPassabilityClasses(std::map<std::string, pass_class_t>&) const override {}
void GetPassabilityClasses(std::map<std::string, pass_class_t>&, std::map<std::string, pass_class_t>&) const override {}
entity_pos_t GetClearance(pass_class_t) const override { return entity_pos_t::FromInt(1); }
entity_pos_t GetMaximumClearance() const override { return entity_pos_t::FromInt(1); }
const GridUpdateInformation& GetAIPathfinderDirtinessInformation() const override { static GridUpdateInformation gridInfo; return gridInfo; }
void FlushAIPathfinderDirtinessInformation() override {}
Grid<u16> ComputeShoreGrid(bool = false) override { return Grid<u16> {}; }
u32 ComputePathAsync(entity_pos_t, entity_pos_t, const PathGoal&, pass_class_t, entity_id_t) override { return 1; }
void ComputePathImmediate(entity_pos_t, entity_pos_t, const PathGoal&, pass_class_t, WaypointPath&) const override {}
u32 ComputeShortPathAsync(entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, const PathGoal&, pass_class_t, bool, entity_id_t, entity_id_t) override { return 1; }
WaypointPath ComputeShortPathImmediate(const ShortPathRequest&) const override { return WaypointPath(); }
void SetDebugPath(entity_pos_t, entity_pos_t, const PathGoal&, pass_class_t) override {}
bool IsGoalReachable(entity_pos_t, entity_pos_t, const PathGoal&, pass_class_t) override { return false; }
std::vector<CFixedVector2D> DistributeAround(std::vector<entity_id_t>, entity_pos_t, entity_pos_t) const override { return {}; }
bool CheckMovement(const IObstructionTestFilter&, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, pass_class_t) const override { return false; }
ICmpObstruction::EFoundationCheck CheckUnitPlacement(const IObstructionTestFilter&, entity_pos_t, entity_pos_t, entity_pos_t, pass_class_t, bool = false) const override { return ICmpObstruction::FOUNDATION_CHECK_SUCCESS; }
ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter&, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_id_t, pass_class_t) const override { return ICmpObstruction::FOUNDATION_CHECK_SUCCESS; }
ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter&, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_id_t, pass_class_t, bool) const override { return ICmpObstruction::FOUNDATION_CHECK_SUCCESS; }
void SetDebugOverlay(bool) override {}
void SetHierDebugOverlay(bool) override {}
void SendRequestedPaths() override {}
void StartProcessingMoves(bool) override {}
void UpdateGrid() override {}
void GetDebugData(u32&, double&, Grid<u8>&) const override {}
void SetAtlasOverlay(bool, pass_class_t = 0) override {}
};
class MockPlayerMgrTerrMan : public ICmpPlayerManager

View file

@ -43,7 +43,7 @@ public:
protected:
void NotifyFinishedOwnCommands(u32 turn) override;
virtual void NotifyFinishedUpdate(u32 turn, const UpdateCallback& sendEventToAll) override;
void NotifyFinishedUpdate(u32 turn, const UpdateCallback& sendEventToAll) override;
};
#endif // INCLUDED_LOCALTURNMANAGER