Skip to content

Commit

Permalink
More fixes for warnings from clang-tidy, in src/cheat and `src/comm…
Browse files Browse the repository at this point in the history
…on`.
  • Loading branch information
sa666666 committed Aug 1, 2024
1 parent 2fd4756 commit c48f03b
Show file tree
Hide file tree
Showing 65 changed files with 306 additions and 289 deletions.
2 changes: 1 addition & 1 deletion src/cheat/Cheat.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Cheat
public:
Cheat(OSystem& osystem, string_view name, string_view code)
: myOSystem{osystem},
myName{name == "" ? code : name},
myName{name.empty() ? code : name},
myCode{code} { }
virtual ~Cheat() = default;

Expand Down
1 change: 1 addition & 0 deletions src/cheat/CheatManager.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class CheatManager
{
public:
explicit CheatManager(OSystem& osystem);
~CheatManager() = default;

/**
Adds the specified cheat to an internal list.
Expand Down
2 changes: 1 addition & 1 deletion src/common/AudioQueue.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class AudioQueue
@param isStereo Whether samples are stereo or mono.
*/
AudioQueue(uInt32 fragmentSize, uInt32 capacity, bool isStereo);
~AudioQueue() = default;

/**
Capacity getter.
Expand Down Expand Up @@ -133,7 +134,6 @@ class AudioQueue
StaggeredLogger myOverflowLogger{"audio buffer overflow", Logger::Level::INFO};

private:

AudioQueue() = delete;
AudioQueue(const AudioQueue&) = delete;
AudioQueue(AudioQueue&&) = delete;
Expand Down
4 changes: 2 additions & 2 deletions src/common/AudioSettings.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ class AudioSettings
{
public:

enum class Preset {
enum class Preset: uInt8 {
custom = 1,
lowQualityMediumLag = 2,
highQualityMediumLag = 3,
highQualityLowLag = 4,
ultraQualityMinimalLag = 5
};

enum class ResamplingQuality {
enum class ResamplingQuality: uInt8 {
nearestNeighbour = 1,
lanczos_2 = 2,
lanczos_3 = 3
Expand Down
2 changes: 1 addition & 1 deletion src/common/Base.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ string Base::toString(int value, Common::Base::Fmt outputBase)
{
static char vToS_buf[32]; // NOLINT : One place where C-style is acceptable

if(outputBase == Base::Fmt::_DEFAULT)
if(outputBase == Base::Fmt::DEFAULT)
outputBase = myDefaultBase;

switch(outputBase)
Expand Down
17 changes: 9 additions & 8 deletions src/common/Base.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Base
// The base to use for conversion from integers to strings
// Note that the actual number of places will be determined by
// the magnitude of the value itself in the general case
enum class Fmt {
enum class Fmt: uInt8 {
_16, // base 16: 2, 4, 8 bytes (depending on value)
_16_1, // base 16: 1 byte wide
_16_2, // base 16: 2 bytes wide
Expand All @@ -56,7 +56,7 @@ class Base
_2, // base 2: 8 or 16 bits (depending on value)
_2_8, // base 2: 1 byte (8 bits) wide
_2_16, // base 2: 2 bytes (16 bits) wide
_DEFAULT
DEFAULT
};

public:
Expand All @@ -72,31 +72,31 @@ class Base
static bool hexUppercase() { return myHexflags & std::ios_base::uppercase; }

/** Output HEX digits in 0.5/1/2/4 byte format */
static inline std::ostream& HEX1(std::ostream& os) {
static std::ostream& HEX1(std::ostream& os) {
os.flags(myHexflags);
return os << std::setw(1);
}
static inline std::ostream& HEX2(std::ostream& os) {
static std::ostream& HEX2(std::ostream& os) {
os.flags(myHexflags);
return os << std::setw(2) << std::setfill('0');
}
static inline std::ostream& HEX3(std::ostream& os)
static std::ostream& HEX3(std::ostream& os)
{
os.flags(myHexflags);
return os << std::setw(3) << std::setfill('0');
}
static inline std::ostream& HEX4(std::ostream& os) {
static std::ostream& HEX4(std::ostream& os) {
os.flags(myHexflags);
return os << std::setw(4) << std::setfill('0');
}
static inline std::ostream& HEX8(std::ostream& os) {
static std::ostream& HEX8(std::ostream& os) {
os.flags(myHexflags);
return os << std::setw(8) << std::setfill('0');
}

/** Convert integer to a string in the given base format */
static string toString(int value,
Common::Base::Fmt outputBase = Common::Base::Fmt::_DEFAULT);
Common::Base::Fmt outputBase = Common::Base::Fmt::DEFAULT);

private:
// Default format to use when none is specified
Expand All @@ -108,6 +108,7 @@ class Base
private:
// Following constructors and assignment operators not supported
Base() = delete;
~Base() = delete;
Base(const Base&) = delete;
Base(Base&&) = delete;
Base& operator=(const Base&) = delete;
Expand Down
4 changes: 3 additions & 1 deletion src/common/DevSettingsHandler.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
class OSystem;

#include <array>
#include "bspf.hxx"

/**
This class takes care of developer settings sets.
Expand All @@ -30,13 +31,14 @@ class OSystem;
class DevSettingsHandler
{
public:
enum SettingsSet {
enum SettingsSet: uInt8 {
player,
developer,
numSets
};

explicit DevSettingsHandler(OSystem& osystem);
~DevSettingsHandler() = default;

void loadSettings(SettingsSet set);
void saveSettings(SettingsSet set);
Expand Down
4 changes: 2 additions & 2 deletions src/common/FBBackendSDL2.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class FBBackendSDL2 : public FBBackend
@param g The green component of the color.
@param b The blue component of the color.
*/
inline uInt32 mapRGB(uInt8 r, uInt8 g, uInt8 b) const override
uInt32 mapRGB(uInt8 r, uInt8 g, uInt8 b) const override
{ return SDL_MapRGB(myPixelFormat, r, g, b); }

/**
Expand All @@ -131,7 +131,7 @@ class FBBackendSDL2 : public FBBackend
@param b The blue component of the color.
@param a The alpha component of the color.
*/
inline uInt32 mapRGBA(uInt8 r, uInt8 g, uInt8 b, uInt8 a) const override
uInt32 mapRGBA(uInt8 r, uInt8 g, uInt8 b, uInt8 a) const override
{ return SDL_MapRGBA(myPixelFormat, r, g, b, a); }

/**
Expand Down
8 changes: 4 additions & 4 deletions src/common/FBSurfaceSDL2.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class FBSurfaceSDL2 : public FBSurface
void applyAttributes() override;

private:
inline bool setSrcPosInternal(uInt32 x, uInt32 y) {
bool setSrcPosInternal(uInt32 x, uInt32 y) {
if(x != static_cast<uInt32>(mySrcR.x) || y != static_cast<uInt32>(mySrcR.y))
{
mySrcR.x = x; mySrcR.y = y;
Expand All @@ -78,7 +78,7 @@ class FBSurfaceSDL2 : public FBSurface
}
return false;
}
inline bool setSrcSizeInternal(uInt32 w, uInt32 h) {
bool setSrcSizeInternal(uInt32 w, uInt32 h) {
if(w != static_cast<uInt32>(mySrcR.w) || h != static_cast<uInt32>(mySrcR.h))
{
mySrcR.w = w; mySrcR.h = h;
Expand All @@ -87,7 +87,7 @@ class FBSurfaceSDL2 : public FBSurface
}
return false;
}
inline bool setDstPosInternal(uInt32 x, uInt32 y) {
bool setDstPosInternal(uInt32 x, uInt32 y) {
if(x != static_cast<uInt32>(myDstR.x) || y != static_cast<uInt32>(myDstR.y))
{
myDstR.x = x; myDstR.y = y;
Expand All @@ -96,7 +96,7 @@ class FBSurfaceSDL2 : public FBSurface
}
return false;
}
inline bool setDstSizeInternal(uInt32 w, uInt32 h) {
bool setDstSizeInternal(uInt32 w, uInt32 h) {
if(w != static_cast<uInt32>(myDstR.w) || h != static_cast<uInt32>(myDstR.h))
{
myDstR.w = w; myDstR.h = h;
Expand Down
3 changes: 2 additions & 1 deletion src/common/FSNodeFactory.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class AbstractFSNode;
class FSNodeFactory
{
public:
enum class Type { SYSTEM, ZIP };
enum class Type: uInt8 { SYSTEM, ZIP };

public:
static unique_ptr<AbstractFSNode> create(string_view path, Type type)
Expand Down Expand Up @@ -71,6 +71,7 @@ class FSNodeFactory
private:
// Following constructors and assignment operators not supported
FSNodeFactory() = delete;
~FSNodeFactory() = delete;
FSNodeFactory(const FSNodeFactory&) = delete;
FSNodeFactory(FSNodeFactory&&) = delete;
FSNodeFactory& operator=(const FSNodeFactory&) = delete;
Expand Down
2 changes: 1 addition & 1 deletion src/common/FSNodeZIP.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class FSNodeZIP : public AbstractFSNode

private:
/* Error types */
enum class zip_error
enum class zip_error: uInt8
{
NONE,
NOT_A_FILE,
Expand Down
1 change: 1 addition & 0 deletions src/common/FpsMeter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class FpsMeter
public:

explicit FpsMeter(uInt32 queueSize);
~FpsMeter() = default;

void reset(uInt32 garbageFrameLimit = 0);

Expand Down
4 changes: 4 additions & 0 deletions src/common/JPGLibrary.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
class OSystem;
class FBSurface;

#include "Variant.hxx"
#include "bspf.hxx"

/**
This class implements a thin wrapper around the nanojpeg library, and
abstracts all the irrelevant details other loading an actual image.
Expand All @@ -33,6 +36,7 @@ class JPGLibrary
{
public:
explicit JPGLibrary(OSystem& osystem);
~JPGLibrary() = default;

/**
Read a JPG image from the specified file into a FBSurface structure,
Expand Down
46 changes: 22 additions & 24 deletions src/common/JoyMap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,21 @@
using json = nlohmann::json;

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void JoyMap::add(const Event::Type event, const JoyMapping& mapping)
void JoyMap::add(Event::Type event, const JoyMapping& mapping)
{
myMap[mapping] = event;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void JoyMap::add(const Event::Type event, const EventMode mode, const int button,
const JoyAxis axis, const JoyDir adir,
const int hat, const JoyHatDir hdir)
void JoyMap::add(Event::Type event, EventMode mode, int button,
JoyAxis axis, JoyDir adir, int hat, JoyHatDir hdir)
{
add(event, JoyMapping(mode, button, axis, adir, hat, hdir));
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void JoyMap::add(const Event::Type event, const EventMode mode, const int button,
const int hat, const JoyHatDir hdir)
void JoyMap::add(Event::Type event, EventMode mode, int button,
int hat, JoyHatDir hdir)
{
add(event, JoyMapping(mode, button, hat, hdir));
}
Expand All @@ -49,15 +48,13 @@ void JoyMap::erase(const JoyMapping& mapping)
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void JoyMap::erase(const EventMode mode, const int button,
const JoyAxis axis, const JoyDir adir)
void JoyMap::erase(EventMode mode, int button, JoyAxis axis, JoyDir adir)
{
erase(JoyMapping(mode, button, axis, adir));
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void JoyMap::erase(const EventMode mode, const int button,
const int hat, const JoyHatDir hdir)
void JoyMap::erase(EventMode mode, int button, int hat, JoyHatDir hdir)
{
erase(JoyMapping(mode, button, hat, hdir));
}
Expand All @@ -82,15 +79,15 @@ Event::Type JoyMap::get(const JoyMapping& mapping) const
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event::Type JoyMap::get(const EventMode mode, const int button,
const JoyAxis axis, const JoyDir adir) const
Event::Type JoyMap::get(EventMode mode, int button,
JoyAxis axis, JoyDir adir) const
{
return get(JoyMapping(mode, button, axis, adir));
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event::Type JoyMap::get(const EventMode mode, const int button,
const int hat, const JoyHatDir hdir) const
Event::Type JoyMap::get(EventMode mode, int button,
int hat, JoyHatDir hdir) const
{
return get(JoyMapping(mode, button, hat, hdir));
}
Expand All @@ -102,15 +99,14 @@ bool JoyMap::check(const JoyMapping& mapping) const
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool JoyMap::check(const EventMode mode, const int button,
const JoyAxis axis, const JoyDir adir,
const int hat, const JoyHatDir hdir) const
bool JoyMap::check(EventMode mode, int button, JoyAxis axis, JoyDir adir,
int hat, JoyHatDir hdir) const
{
return check(JoyMapping(mode, button, axis, adir, hat, hdir));
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string JoyMap::getDesc(const Event::Type event, const JoyMapping& mapping)
string JoyMap::getDesc(Event::Type event, const JoyMapping& mapping)
{
ostringstream buf;

Expand Down Expand Up @@ -156,7 +152,8 @@ string JoyMap::getDesc(const Event::Type event, const JoyMapping& mapping)
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string JoyMap::getEventMappingDesc(int stick, const Event::Type event, const EventMode mode) const
string JoyMap::getEventMappingDesc(int stick, Event::Type event,
EventMode mode) const
{
ostringstream buf;

Expand All @@ -173,7 +170,8 @@ string JoyMap::getEventMappingDesc(int stick, const Event::Type event, const Eve
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
JoyMap::JoyMappingArray JoyMap::getEventMapping(const Event::Type event, const EventMode mode) const
JoyMap::JoyMappingArray JoyMap::getEventMapping(Event::Type event,
EventMode mode) const
{
JoyMappingArray map;

Expand All @@ -185,7 +183,7 @@ JoyMap::JoyMappingArray JoyMap::getEventMapping(const Event::Type event, const E
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
json JoyMap::saveMapping(const EventMode mode) const
json JoyMap::saveMapping(EventMode mode) const
{
using MapType = std::pair<JoyMapping, Event::Type>;
std::vector<MapType> sortedMap(myMap.begin(), myMap.end());
Expand Down Expand Up @@ -241,7 +239,7 @@ json JoyMap::saveMapping(const EventMode mode) const
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int JoyMap::loadMapping(const json& eventMappings, const EventMode mode)
int JoyMap::loadMapping(const json& eventMappings, EventMode mode)
{
int i = 0;

Expand Down Expand Up @@ -327,7 +325,7 @@ json JoyMap::convertLegacyMapping(string list)
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void JoyMap::eraseMode(const EventMode mode)
void JoyMap::eraseMode(EventMode mode)
{
for(auto item = myMap.begin(); item != myMap.end();)
if(item->first.mode == mode) {
Expand All @@ -338,7 +336,7 @@ void JoyMap::eraseMode(const EventMode mode)
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void JoyMap::eraseEvent(const Event::Type event, const EventMode mode)
void JoyMap::eraseEvent(Event::Type event, EventMode mode)
{
for(auto item = myMap.begin(); item != myMap.end();)
if(item->second == event && item->first.mode == mode) {
Expand Down
Loading

0 comments on commit c48f03b

Please sign in to comment.