Skip to content

Commit

Permalink
Fixes from clang-tidy for the entire codebase, including header files.
Browse files Browse the repository at this point in the history
  • Loading branch information
sa666666 committed Aug 3, 2024
1 parent 6c0e659 commit 67974a9
Show file tree
Hide file tree
Showing 149 changed files with 433 additions and 389 deletions.
2 changes: 1 addition & 1 deletion src/common/AudioSettings.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class AudioSettings

private:

Settings& mySettings;
Settings& mySettings; // NOLINT: we want a reference here

Preset myPreset{Preset::custom};

Expand Down
38 changes: 18 additions & 20 deletions src/common/PJoystickHandler.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,7 @@ bool PhysicalJoystickHandler::hasStelladaptors() const
// 2. reset all events to default (event == Event::NoType, updateDefault == false)
// 3. reset one event to default (event != Event::NoType)
void PhysicalJoystickHandler::setDefaultAction(int stick,
EventMapping map, Event::Type event,
EventMode mode, bool updateDefaults)
EventMapping map, Event::Type event, EventMode mode, bool updateDefaults)
{
const PhysicalJoystickPtr j = joy(stick);

Expand Down Expand Up @@ -406,11 +405,11 @@ void PhysicalJoystickHandler::setStickDefaultMapping(
setDefaultAction(stick, item, event, EventMode::kDrivingMode, updateDefaults);
}

#if defined(RETRON77)
#if defined(RETRON77)
constexpr bool retron77 = true;
#else
#else
constexpr bool retron77 = false;
#endif
#endif

// Regular joysticks can only be used by one player at a time,
// so we need to separate the paddles onto different
Expand Down Expand Up @@ -501,7 +500,7 @@ void PhysicalJoystickHandler::setDefaultMapping(Event::Type event, EventMode mod

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalJoystickHandler::defineControllerMappings(
const Controller::Type type, Controller::Jack port, const Properties& properties,
Controller::Type type, Controller::Jack port, const Properties& properties,
Controller::Type qtType1, Controller::Type qtType2)
{
// Determine controller events to use
Expand Down Expand Up @@ -531,7 +530,7 @@ void PhysicalJoystickHandler::defineControllerMappings(

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventMode PhysicalJoystickHandler::getMode(const Properties& properties,
const PropType propType)
PropType propType)
{
const string& propName = properties.get(propType);

Expand All @@ -542,7 +541,7 @@ EventMode PhysicalJoystickHandler::getMode(const Properties& properties,
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventMode PhysicalJoystickHandler::getMode(const Controller::Type type)
EventMode PhysicalJoystickHandler::getMode(Controller::Type type)
{
switch(type)
{
Expand Down Expand Up @@ -671,7 +670,7 @@ void PhysicalJoystickHandler::enableMappings(const Event::EventSet& events, Even
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalJoystickHandler::enableMapping(const Event::Type event, EventMode mode)
void PhysicalJoystickHandler::enableMapping(Event::Type event, EventMode mode)
{
// copy from controller mode into emulation mode
for (auto& stick : mySticks)
Expand All @@ -687,8 +686,7 @@ void PhysicalJoystickHandler::enableMapping(const Event::Type event, EventMode m
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventMode PhysicalJoystickHandler::getEventMode(const Event::Type event,
const EventMode mode)
EventMode PhysicalJoystickHandler::getEventMode(Event::Type event, EventMode mode)
{
if(mode == EventMode::kEmulationMode)
{
Expand All @@ -712,7 +710,7 @@ EventMode PhysicalJoystickHandler::getEventMode(const Event::Type event,
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalJoystickHandler::isJoystickEvent(const Event::Type event)
bool PhysicalJoystickHandler::isJoystickEvent(Event::Type event)
{
return LeftJoystickEvents.contains(event)
|| QTJoystick3Events.contains(event)
Expand All @@ -721,7 +719,7 @@ bool PhysicalJoystickHandler::isJoystickEvent(const Event::Type event)
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalJoystickHandler::isPaddleEvent(const Event::Type event)
bool PhysicalJoystickHandler::isPaddleEvent(Event::Type event)
{
return LeftPaddlesEvents.contains(event)
|| QTPaddles3Events.contains(event)
Expand All @@ -730,21 +728,21 @@ bool PhysicalJoystickHandler::isPaddleEvent(const Event::Type event)
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalJoystickHandler::isKeyboardEvent(const Event::Type event)
bool PhysicalJoystickHandler::isKeyboardEvent(Event::Type event)
{
return LeftKeyboardEvents.contains(event)
|| RightKeyboardEvents.contains(event);
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalJoystickHandler::isDrivingEvent(const Event::Type event)
bool PhysicalJoystickHandler::isDrivingEvent(Event::Type event)
{
return LeftDrivingEvents.contains(event)
|| RightDrivingEvents.contains(event);
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalJoystickHandler::isCommonEvent(const Event::Type event)
bool PhysicalJoystickHandler::isCommonEvent(Event::Type event)
{
return !(isJoystickEvent(event) || isPaddleEvent(event)
|| isKeyboardEvent(event) || isDrivingEvent(event));
Expand Down Expand Up @@ -820,8 +818,8 @@ string PhysicalJoystickHandler::getMappingDesc(Event::Type event, EventMode mode
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalJoystickHandler::addJoyMapping(Event::Type event, EventMode mode, int stick,
int button, JoyAxis axis, JoyDir adir)
bool PhysicalJoystickHandler::addJoyMapping(Event::Type event, EventMode mode,
int stick, int button, JoyAxis axis, JoyDir adir)
{
const PhysicalJoystickPtr j = joy(stick);

Expand Down Expand Up @@ -861,8 +859,8 @@ bool PhysicalJoystickHandler::addJoyMapping(Event::Type event, EventMode mode, i
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalJoystickHandler::addJoyHatMapping(Event::Type event, EventMode mode, int stick,
int button, int hat, JoyHatDir hdir)
bool PhysicalJoystickHandler::addJoyHatMapping(Event::Type event, EventMode mode,
int stick, int button, int hat, JoyHatDir hdir)
{
const PhysicalJoystickPtr j = joy(stick);

Expand Down
38 changes: 20 additions & 18 deletions src/common/PJoystickHandler.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class PhysicalJoystickHandler
int ID;
PhysicalJoystick::Port port;

explicit MinStrickInfo(string _name, int _id, PhysicalJoystick::Port _port)
explicit MinStrickInfo(string_view _name, int _id, PhysicalJoystick::Port _port)
: name{_name}, ID{_id}, port{_port} {}
};
using MinStrickInfoList = std::vector<MinStrickInfo>;
Expand All @@ -66,7 +66,7 @@ class PhysicalJoystickHandler
// on the 'mapping' instance variable; there lay dragons ...
// https://json.nlohmann.me/home/faq/#brace-initialization-yields-arrays
explicit StickInfo(nlohmann::json map, PhysicalJoystickPtr stick = nullptr)
: mapping(map), joy{std::move(stick)} {}
: mapping(map), joy{std::move(stick)} {} // NOLINT

nlohmann::json mapping;
PhysicalJoystickPtr joy;
Expand All @@ -92,7 +92,7 @@ class PhysicalJoystickHandler
void setDefaultMapping(Event::Type event, EventMode mode);

/** define mappings for current controllers */
void defineControllerMappings(const Controller::Type type, Controller::Jack port,
void defineControllerMappings(Controller::Type type, Controller::Jack port,
const Properties& properties,
Controller::Type qtType1 = Controller::Type::Unknown,
Controller::Type qtType2 = Controller::Type::Unknown);
Expand Down Expand Up @@ -145,9 +145,9 @@ class PhysicalJoystickHandler
using StickDatabase = std::map<string, StickInfo, std::less<>>;
using StickList = std::map<int, PhysicalJoystickPtr>;

OSystem& myOSystem;
EventHandler& myHandler;
Event& myEvent;
OSystem& myOSystem; // NOLINT: we want a reference here
EventHandler& myHandler; // NOLINT: we want a reference here
Event& myEvent; // NOLINT: we want a reference here

// Contains all joysticks that Stella knows about, indexed by name
StickDatabase myDatabase;
Expand All @@ -157,7 +157,7 @@ class PhysicalJoystickHandler

// Get joystick corresponding to given id (or nullptr if it doesn't exist)
// Make this inline so it's as fast as possible
const PhysicalJoystickPtr joy(int id) const {
PhysicalJoystickPtr joy(int id) const {
const auto& i = mySticks.find(id);
return i != mySticks.cend() ? i->second : nullptr;
}
Expand All @@ -171,8 +171,10 @@ class PhysicalJoystickHandler

friend ostream& operator<<(ostream& os, const PhysicalJoystickHandler& jh);

JoyDir convertAxisValue(int value) const {
return value == int(JoyDir::NONE) ? JoyDir::NONE : value > 0 ? JoyDir::POS : JoyDir::NEG;
static constexpr JoyDir convertAxisValue(int value) {
return value == static_cast<int>(JoyDir::NONE)
? JoyDir::NONE
: value > 0 ? JoyDir::POS : JoyDir::NEG;
}

// Handle regular axis events (besides special Stelladaptor handling)
Expand All @@ -196,23 +198,23 @@ class PhysicalJoystickHandler
bool updateDefaults = false);

/** return event mode for given property */
static EventMode getMode(const Properties& properties, const PropType propType);
static EventMode getMode(const Properties& properties, PropType propType);
/** return event mode for given controller type */
static EventMode getMode(const Controller::Type type);
static EventMode getMode(Controller::Type type);

/** returns the event's controller mode */
static EventMode getEventMode(const Event::Type event, const EventMode mode);
static EventMode getEventMode(Event::Type event, EventMode mode);
/** Checks event type. */
static bool isJoystickEvent(const Event::Type event);
static bool isPaddleEvent(const Event::Type event);
static bool isKeyboardEvent(const Event::Type event);
static bool isDrivingEvent(const Event::Type event);
static bool isCommonEvent(const Event::Type event);
static bool isJoystickEvent(Event::Type event);
static bool isPaddleEvent(Event::Type event);
static bool isKeyboardEvent(Event::Type event);
static bool isDrivingEvent(Event::Type event);
static bool isCommonEvent(Event::Type event);

void enableCommonMappings();

void enableMappings(const Event::EventSet& events, EventMode mode);
void enableMapping(const Event::Type event, EventMode mode);
void enableMapping(Event::Type event, EventMode mode);

private:
EventMode myLeftMode{EventMode::kEmulationMode};
Expand Down
4 changes: 2 additions & 2 deletions src/common/StellaKeys.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*/

// This comes directly from SDL_scancode.h
enum StellaKey
enum StellaKey // NOLINT: use 32-bit, even though 16-bit is sufficient
{
KBDK_UNKNOWN = 0,

Expand Down Expand Up @@ -393,7 +393,7 @@ enum StellaKey
};

// This comes directly from SDL_keycode.h
enum StellaMod
enum StellaMod: uInt16
{
KBDM_NONE = 0x0000,
KBDM_LSHIFT = 0x0001,
Expand Down
2 changes: 2 additions & 0 deletions src/common/Variant.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
@author Stephen Anthony
*/
// NOLINTBEGIN: c'tors cannot be explicit here
class Variant
{
private:
Expand Down Expand Up @@ -91,4 +92,5 @@ namespace VarList {
}
} // namespace VarList

// NOLINTEND
#endif
2 changes: 1 addition & 1 deletion src/common/ZipHandler.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class ZipHandler
}

private:
const uInt8* const myBuf{nullptr};
const uInt8* const myBuf{nullptr}; // NOLINT: we want const here
};

class LocalFileHeaderReader : public ReaderBase
Expand Down
2 changes: 1 addition & 1 deletion src/common/bspf.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ namespace BSPF
// starting from 'startpos' in the first string
static size_t findIgnoreCase(string_view s1, string_view s2, size_t startpos = 0)
{
const auto pos = std::search(s1.cbegin()+startpos, s1.cend(),
const auto pos = std::search(s1.cbegin()+startpos, s1.cend(), // NOLINT
s2.cbegin(), s2.cend(), [](char ch1, char ch2) {
return toupper(static_cast<uInt8>(ch1)) == toupper(static_cast<uInt8>(ch2));
});
Expand Down
5 changes: 5 additions & 0 deletions src/common/jsonDefinitions.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#ifndef JSON_DEFINITIONS_HXX
#define JSON_DEFINITIONS_HXX

// NOLINTBEGIN: NLOHMANN_JSON_SERIALIZE_ENUM
// warning: use c++17 style variable templates [modernize-type-traits]

#include "EventHandlerConstants.hxx"
#include "Event.hxx"
#include "json_lib.hxx"
Expand Down Expand Up @@ -769,4 +772,6 @@ NLOHMANN_JSON_SERIALIZE_ENUM(StellaMod, {
{StellaMod::KBDM_GUI, "gui"}
})

// NOLINTEND

#endif // JSON_DEFINITIONS_HXX
2 changes: 1 addition & 1 deletion src/common/repository/KeyValueRepositoryFile.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class KeyValueRepositoryFile : public KeyValueRepository {

protected:

const FSNode& myNode;
const FSNode& myNode; // NOLINT: we want a reference here
};

///////////////////////////////////////////////////////////////////////////////
Expand Down
13 changes: 7 additions & 6 deletions src/debugger/DebuggerParser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1248,12 +1248,12 @@ void DebuggerParser::executeDump()
{
const auto dump = [&](ostream& os, int start, int end)
{
for(int i = start; i <= end; i += 16)
for(int i = start; i <= end; i += 16) // NOLINT (i is not a const)
{
// Print label every 16 bytes
os << Base::toString(i) << ": ";

for(int j = i; j < i+16 && j <= end; ++j)
for(int j = i; j < i+16 && j <= end; ++j) // NOLINT (j is not a const)
{
os << Base::toString(debugger.peek(j)) << " ";
if(j == i+7 && j != end) os << "- ";
Expand Down Expand Up @@ -1291,7 +1291,7 @@ void DebuggerParser::executeDump()
return;
}

ostringstream path;
ostringstream path; // NOLINT (path is not a const)
path << debugger.myOSystem.userDir() << cartName() << "_dbg_";
if(execDepth > 0)
path << execPrefix;
Expand All @@ -1302,7 +1302,7 @@ void DebuggerParser::executeDump()

commandResult << "dumped ";

stringstream out;
stringstream out; // NOLINT (out is not a const)
if((args[2] & 0x01) != 0)
{
// dump memory
Expand Down Expand Up @@ -1381,6 +1381,7 @@ void DebuggerParser::executeDump()
if(OK)
{
const stringstream localOut(outStr);
// NOLINTNEXTLINE (localOut is not a const)
ostringstream localResult(resultStr, std::ios_base::app);

saveDump(node, localOut, localResult);
Expand Down Expand Up @@ -2171,7 +2172,7 @@ void DebuggerParser::executeSaveRom()
// "saveSes"
void DebuggerParser::executeSaveSes()
{
ostringstream filename;
ostringstream filename; // NOLINT (filename is not a const)
auto timeinfo = BSPF::localTime();
filename << std::put_time(&timeinfo, "session_%F_%H-%M-%S.txt");

Expand All @@ -2193,7 +2194,7 @@ void DebuggerParser::executeSaveSes()
}
else
{
ostringstream path;
ostringstream path; // NOLINT (path is not a const)

if(argCount)
path << argStrings[0];
Expand Down
2 changes: 1 addition & 1 deletion src/debugger/gui/AmigaMouseWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ AmigaMouseWidget::AmigaMouseWidget(GuiObject* boss, const GUI::Font& font,
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 AmigaMouseWidget::getGrayCodeTable(const int index, const int) const
uInt8 AmigaMouseWidget::getGrayCodeTable(int index, int) const
{
return myGrayCodeTable[index];
}
6 changes: 4 additions & 2 deletions src/debugger/gui/AmigaMouseWidget.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ class AmigaMouseWidget : public PointingDeviceWidget
~AmigaMouseWidget() override = default;

private:
const std::array<uInt8, 4> myGrayCodeTable = { 0b00, 0b10, 0b11, 0b01 };
static constexpr std::array<uInt8, 4> myGrayCodeTable = {
0b00, 0b10, 0b11, 0b01
};

uInt8 getGrayCodeTable(const int index, const int direction) const override;
uInt8 getGrayCodeTable(int index, int direction) const override;

// Following constructors and assignment operators not supported
AmigaMouseWidget() = delete;
Expand Down
Loading

0 comments on commit 67974a9

Please sign in to comment.