diff --git a/src/common/AudioSettings.hxx b/src/common/AudioSettings.hxx index 26f517b65..4f2e8a67f 100644 --- a/src/common/AudioSettings.hxx +++ b/src/common/AudioSettings.hxx @@ -127,7 +127,7 @@ class AudioSettings private: - Settings& mySettings; + Settings& mySettings; // NOLINT: we want a reference here Preset myPreset{Preset::custom}; diff --git a/src/common/PJoystickHandler.cxx b/src/common/PJoystickHandler.cxx index c7dd7e4bd..c3a70a271 100644 --- a/src/common/PJoystickHandler.cxx +++ b/src/common/PJoystickHandler.cxx @@ -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); @@ -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 @@ -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 @@ -531,7 +530,7 @@ void PhysicalJoystickHandler::defineControllerMappings( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EventMode PhysicalJoystickHandler::getMode(const Properties& properties, - const PropType propType) + PropType propType) { const string& propName = properties.get(propType); @@ -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) { @@ -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) @@ -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) { @@ -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) @@ -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) @@ -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)); @@ -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); @@ -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); diff --git a/src/common/PJoystickHandler.hxx b/src/common/PJoystickHandler.hxx index a151d8c8e..82bed73fd 100644 --- a/src/common/PJoystickHandler.hxx +++ b/src/common/PJoystickHandler.hxx @@ -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; @@ -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; @@ -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); @@ -145,9 +145,9 @@ class PhysicalJoystickHandler using StickDatabase = std::map>; using StickList = std::map; - 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; @@ -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; } @@ -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(JoyDir::NONE) + ? JoyDir::NONE + : value > 0 ? JoyDir::POS : JoyDir::NEG; } // Handle regular axis events (besides special Stelladaptor handling) @@ -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}; diff --git a/src/common/StellaKeys.hxx b/src/common/StellaKeys.hxx index 5287bce2b..3b6693be5 100644 --- a/src/common/StellaKeys.hxx +++ b/src/common/StellaKeys.hxx @@ -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, @@ -393,7 +393,7 @@ enum StellaKey }; // This comes directly from SDL_keycode.h -enum StellaMod +enum StellaMod: uInt16 { KBDM_NONE = 0x0000, KBDM_LSHIFT = 0x0001, diff --git a/src/common/Variant.hxx b/src/common/Variant.hxx index 32a5c9e65..999762984 100644 --- a/src/common/Variant.hxx +++ b/src/common/Variant.hxx @@ -29,6 +29,7 @@ @author Stephen Anthony */ +// NOLINTBEGIN: c'tors cannot be explicit here class Variant { private: @@ -91,4 +92,5 @@ namespace VarList { } } // namespace VarList +// NOLINTEND #endif diff --git a/src/common/ZipHandler.hxx b/src/common/ZipHandler.hxx index 3ecf88938..2b2debf99 100644 --- a/src/common/ZipHandler.hxx +++ b/src/common/ZipHandler.hxx @@ -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 diff --git a/src/common/bspf.hxx b/src/common/bspf.hxx index bda8c559d..f8243fc5d 100644 --- a/src/common/bspf.hxx +++ b/src/common/bspf.hxx @@ -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(ch1)) == toupper(static_cast(ch2)); }); diff --git a/src/common/jsonDefinitions.hxx b/src/common/jsonDefinitions.hxx index e4c98991b..4c9a104f8 100644 --- a/src/common/jsonDefinitions.hxx +++ b/src/common/jsonDefinitions.hxx @@ -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" @@ -769,4 +772,6 @@ NLOHMANN_JSON_SERIALIZE_ENUM(StellaMod, { {StellaMod::KBDM_GUI, "gui"} }) +// NOLINTEND + #endif // JSON_DEFINITIONS_HXX diff --git a/src/common/repository/KeyValueRepositoryFile.hxx b/src/common/repository/KeyValueRepositoryFile.hxx index 87e4b85c0..ad1e917a8 100644 --- a/src/common/repository/KeyValueRepositoryFile.hxx +++ b/src/common/repository/KeyValueRepositoryFile.hxx @@ -36,7 +36,7 @@ class KeyValueRepositoryFile : public KeyValueRepository { protected: - const FSNode& myNode; + const FSNode& myNode; // NOLINT: we want a reference here }; /////////////////////////////////////////////////////////////////////////////// diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 5bb8d1380..ef23ef06b 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -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 << "- "; @@ -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; @@ -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 @@ -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); @@ -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"); @@ -2193,7 +2194,7 @@ void DebuggerParser::executeSaveSes() } else { - ostringstream path; + ostringstream path; // NOLINT (path is not a const) if(argCount) path << argStrings[0]; diff --git a/src/debugger/gui/AmigaMouseWidget.cxx b/src/debugger/gui/AmigaMouseWidget.cxx index bf4861587..7a0f7226f 100644 --- a/src/debugger/gui/AmigaMouseWidget.cxx +++ b/src/debugger/gui/AmigaMouseWidget.cxx @@ -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]; } diff --git a/src/debugger/gui/AmigaMouseWidget.hxx b/src/debugger/gui/AmigaMouseWidget.hxx index 4e0154ff7..03422f046 100644 --- a/src/debugger/gui/AmigaMouseWidget.hxx +++ b/src/debugger/gui/AmigaMouseWidget.hxx @@ -31,9 +31,11 @@ class AmigaMouseWidget : public PointingDeviceWidget ~AmigaMouseWidget() override = default; private: - const std::array myGrayCodeTable = { 0b00, 0b10, 0b11, 0b01 }; + static constexpr std::array 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; diff --git a/src/debugger/gui/AtariMouseWidget.cxx b/src/debugger/gui/AtariMouseWidget.cxx index 63d137502..e7f3a0d26 100644 --- a/src/debugger/gui/AtariMouseWidget.cxx +++ b/src/debugger/gui/AtariMouseWidget.cxx @@ -24,7 +24,7 @@ AtariMouseWidget::AtariMouseWidget(GuiObject* boss, const GUI::Font& font, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt8 AtariMouseWidget::getGrayCodeTable(const int index, const int direction) const +uInt8 AtariMouseWidget::getGrayCodeTable(int index, int) const { return myGrayCodeTable[index]; } diff --git a/src/debugger/gui/AtariMouseWidget.hxx b/src/debugger/gui/AtariMouseWidget.hxx index 6ed4a2d9c..d5fa6ac7e 100644 --- a/src/debugger/gui/AtariMouseWidget.hxx +++ b/src/debugger/gui/AtariMouseWidget.hxx @@ -30,9 +30,11 @@ class AtariMouseWidget : public PointingDeviceWidget ~AtariMouseWidget() override = default; private: - const std::array myGrayCodeTable = { 0b00, 0b01, 0b11, 0b10 }; + static constexpr std::array myGrayCodeTable = { + 0b00, 0b01, 0b11, 0b10 + }; - 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 AtariMouseWidget() = delete; diff --git a/src/debugger/gui/AudioWidget.hxx b/src/debugger/gui/AudioWidget.hxx index 506c64743..51d28a15b 100644 --- a/src/debugger/gui/AudioWidget.hxx +++ b/src/debugger/gui/AudioWidget.hxx @@ -34,7 +34,7 @@ class AudioWidget : public Widget, public CommandSender private: // ID's for the various widgets // We need ID's, since there are more than one of several types of widgets - enum { + enum: uInt8 { kAUDFID, kAUDCID, kAUDVID @@ -48,7 +48,7 @@ class AudioWidget : public Widget, public CommandSender StaticTextWidget* myAudEffV{nullptr}; // Audio channels - enum + enum: uInt8 { kAud0Addr, kAud1Addr diff --git a/src/debugger/gui/BoosterWidget.hxx b/src/debugger/gui/BoosterWidget.hxx index f69ba71a4..86dbde30f 100644 --- a/src/debugger/gui/BoosterWidget.hxx +++ b/src/debugger/gui/BoosterWidget.hxx @@ -29,7 +29,9 @@ class BoosterWidget : public ControllerWidget ~BoosterWidget() override = default; private: - enum { kJUp = 0, kJDown, kJLeft, kJRight, kJFire, kJBooster, kJTrigger }; + enum: uInt8 { + kJUp = 0, kJDown, kJLeft, kJRight, kJFire, kJBooster, kJTrigger + }; std::array myPins{nullptr}; static constexpr std::array ourPinNo = {{ diff --git a/src/debugger/gui/CartDebugWidget.cxx b/src/debugger/gui/CartDebugWidget.cxx index 5ba81db7f..85a1b477b 100644 --- a/src/debugger/gui/CartDebugWidget.cxx +++ b/src/debugger/gui/CartDebugWidget.cxx @@ -39,7 +39,7 @@ CartDebugWidget::CartDebugWidget(GuiObject* boss, const GUI::Font& lfont, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int CartDebugWidget::addBaseInformation(size_t bytes, string_view manufacturer, - string_view desc, const uInt16 maxlines) + string_view desc, uInt16 maxlines) { const int lwidth = _font.getStringWidth("Manufacturer "), fwidth = _w - lwidth - 12; diff --git a/src/debugger/gui/CartDebugWidget.hxx b/src/debugger/gui/CartDebugWidget.hxx index 00b131bd5..8fcb6b4a8 100644 --- a/src/debugger/gui/CartDebugWidget.hxx +++ b/src/debugger/gui/CartDebugWidget.hxx @@ -23,7 +23,7 @@ class StringListWidget; namespace GUI { class Font; -} +} // namespace GUI #include "Base.hxx" // not needed here, but all child classes need it #include "Command.hxx" @@ -39,7 +39,7 @@ class CartDebugWidget : public Widget, public CommandSender public: int addBaseInformation(size_t bytes, string_view manufacturer, - string_view desc, const uInt16 maxlines = 10); + string_view desc, uInt16 maxlines = 10); // Inform the ROM Widget that the underlying cart has somehow changed void invalidate(); diff --git a/src/debugger/gui/CartEnhancedWidget.hxx b/src/debugger/gui/CartEnhancedWidget.hxx index 60d161912..dac804c3a 100644 --- a/src/debugger/gui/CartEnhancedWidget.hxx +++ b/src/debugger/gui/CartEnhancedWidget.hxx @@ -25,7 +25,7 @@ class PopUpWidget; namespace GUI { class Font; -} +} // namespace GUI #include "Variant.hxx" #include "CartDebugWidget.hxx" diff --git a/src/debugger/gui/CpuWidget.hxx b/src/debugger/gui/CpuWidget.hxx index dacd3fd6e..302c8effe 100644 --- a/src/debugger/gui/CpuWidget.hxx +++ b/src/debugger/gui/CpuWidget.hxx @@ -44,14 +44,14 @@ class CpuWidget : public Widget, public CommandSender private: // ID's for the various widgets // We need ID's, since there are more than one of several types of widgets - enum { + enum: uInt8 { kPCRegID, kCpuRegID, kCpuRegDecID, kCpuRegBinID }; - enum { + enum: uInt8 { kPCRegAddr, kSPRegAddr, kARegAddr, @@ -59,7 +59,7 @@ class CpuWidget : public Widget, public CommandSender kYRegAddr }; - enum { + enum: uInt8 { kPSRegN = 0, kPSRegV = 1, kPSRegB = 3, diff --git a/src/debugger/gui/DataGridWidget.hxx b/src/debugger/gui/DataGridWidget.hxx index 554933463..5ba03c3a7 100644 --- a/src/debugger/gui/DataGridWidget.hxx +++ b/src/debugger/gui/DataGridWidget.hxx @@ -78,7 +78,7 @@ class DataGridWidget : public EditableWidget // Account for the extra width of embedded scrollbar int getWidth() const override; - int colWidth() { return _colWidth; } + int colWidth() const { return _colWidth; } void setOpsWidget(DataGridOpsWidget* w) { _opsWidget = w; } diff --git a/src/debugger/gui/DebuggerDialog.hxx b/src/debugger/gui/DebuggerDialog.hxx index 0291c62e4..c536162a8 100644 --- a/src/debugger/gui/DebuggerDialog.hxx +++ b/src/debugger/gui/DebuggerDialog.hxx @@ -38,10 +38,10 @@ class OptionsDialog; namespace GUI { class MessageBox; -} +} // namespace GUI namespace Common { struct Rect; -} +} // namespace Common #include "Dialog.hxx" @@ -50,7 +50,7 @@ class DebuggerDialog : public Dialog public: // Note: these sizes make sure that all major tabs are fully visible // cart dependend information (e.g. DPC+) may require more space - enum { + enum: uInt16 { kSmallFontMinW = 1090, kSmallFontMinH = 720, kMediumFontMinW = 1160, kMediumFontMinH = 770, kLargeFontMinW = 1160, kLargeFontMinH = 870 diff --git a/src/debugger/gui/GenesisWidget.hxx b/src/debugger/gui/GenesisWidget.hxx index 790182d58..dc7ba4187 100644 --- a/src/debugger/gui/GenesisWidget.hxx +++ b/src/debugger/gui/GenesisWidget.hxx @@ -29,7 +29,7 @@ class GenesisWidget : public ControllerWidget ~GenesisWidget() override = default; private: - enum { kJUp = 0, kJDown, kJLeft, kJRight, kJBbtn, kJCbtn }; + enum: uInt8 { kJUp = 0, kJDown, kJLeft, kJRight, kJBbtn, kJCbtn }; std::array myPins{nullptr}; static constexpr std::array ourPinNo = {{ diff --git a/src/debugger/gui/Joy2BPlusWidget.hxx b/src/debugger/gui/Joy2BPlusWidget.hxx index 3a3570a00..ad1e090ee 100644 --- a/src/debugger/gui/Joy2BPlusWidget.hxx +++ b/src/debugger/gui/Joy2BPlusWidget.hxx @@ -29,7 +29,7 @@ class Joy2BPlusWidget : public ControllerWidget ~Joy2BPlusWidget() override = default; private: - enum { kJUp = 0, kJDown, kJLeft, kJRight, kJButtonB, kJButtonC, kJButton3 }; + enum: uInt8 { kJUp = 0, kJDown, kJLeft, kJRight, kJButtonB, kJButtonC, kJButton3 }; std::array myPins{nullptr}; static constexpr std::array ourPinNo = {{ diff --git a/src/debugger/gui/JoystickWidget.hxx b/src/debugger/gui/JoystickWidget.hxx index 1abc26e79..e16e73001 100644 --- a/src/debugger/gui/JoystickWidget.hxx +++ b/src/debugger/gui/JoystickWidget.hxx @@ -29,7 +29,7 @@ class JoystickWidget : public ControllerWidget ~JoystickWidget() override = default; private: - enum { kJUp = 0, kJDown, kJLeft, kJRight, kJFire }; + enum: uInt8 { kJUp = 0, kJDown, kJLeft, kJRight, kJFire }; std::array myPins{nullptr}; static constexpr std::array ourPinNo = {{ diff --git a/src/debugger/gui/PointingDeviceWidget.cxx b/src/debugger/gui/PointingDeviceWidget.cxx index 58bfc2446..a55bbc57e 100644 --- a/src/debugger/gui/PointingDeviceWidget.cxx +++ b/src/debugger/gui/PointingDeviceWidget.cxx @@ -141,7 +141,7 @@ void PointingDeviceWidget::setGrayCodeV() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PointingDeviceWidget::setValue(DataGridWidget* grayValue, - const int index, const int direction) + int index, int direction) { const uInt8 grayCode = getGrayCodeTable(index, direction); diff --git a/src/debugger/gui/PointingDeviceWidget.hxx b/src/debugger/gui/PointingDeviceWidget.hxx index 9abd35953..c47ce9b62 100644 --- a/src/debugger/gui/PointingDeviceWidget.hxx +++ b/src/debugger/gui/PointingDeviceWidget.hxx @@ -45,14 +45,14 @@ class PointingDeviceWidget : public ControllerWidget CheckboxWidget* myFire{nullptr}; private: - virtual uInt8 getGrayCodeTable(const int index, const int direction) const = 0; + virtual uInt8 getGrayCodeTable(int index, int direction) const = 0; void loadConfig() override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override; void setGrayCodeH(); void setGrayCodeV(); - void setValue(DataGridWidget* grayValue, const int index, const int direction); + void setValue(DataGridWidget* grayValue, int index, int direction); // Following constructors and assignment operators not supported PointingDeviceWidget() = delete; diff --git a/src/debugger/gui/PromptWidget.hxx b/src/debugger/gui/PromptWidget.hxx index 8513270af..fdb4eaaad 100644 --- a/src/debugger/gui/PromptWidget.hxx +++ b/src/debugger/gui/PromptWidget.hxx @@ -100,7 +100,7 @@ class PromptWidget : public Widget, public CommandSender void resetFunctions(); private: - enum { + enum: uInt16 { kBufferSize = 32768, kLineBufferSize = 256, kHistorySize = 1000 diff --git a/src/debugger/gui/RiotWidget.hxx b/src/debugger/gui/RiotWidget.hxx index 0a75accb3..6bc230b1e 100644 --- a/src/debugger/gui/RiotWidget.hxx +++ b/src/debugger/gui/RiotWidget.hxx @@ -75,7 +75,7 @@ class RiotWidget : public Widget, public CommandSender // ID's for the various widgets // We need ID's, since there are more than one of several types of widgets - enum { + enum: uInt8 { kTim1TID, kTim8TID, kTim64TID, kTim1024TID, kTimWriteID, kSWCHABitsID, kSWACNTBitsID, kSWCHBBitsID, kSWBCNTBitsID, kP0DiffChanged, kP1DiffChanged, kTVTypeChanged, kSelectID, kResetID, diff --git a/src/debugger/gui/TiaWidget.hxx b/src/debugger/gui/TiaWidget.hxx index acf050b28..efc3ea38e 100644 --- a/src/debugger/gui/TiaWidget.hxx +++ b/src/debugger/gui/TiaWidget.hxx @@ -102,7 +102,7 @@ class TiaWidget : public Widget, public CommandSender // ID's for the various widgets // We need ID's, since there are more than one of several types of widgets - enum { + enum: uInt8 { kP0_PFID, kP0_BLID, kP0_M1ID, kP0_M0ID, kP0_P1ID, kP1_PFID, kP1_BLID, kP1_M1ID, kP1_M0ID, kM0_PFID, kM0_BLID, kM0_M1ID, @@ -146,7 +146,7 @@ class TiaWidget : public Widget, public CommandSender }; // Color registers - enum { + enum: uInt8 { kCOLUP0Addr, kCOLUP1Addr, kCOLUPFAddr, diff --git a/src/debugger/gui/TrakBallWidget.cxx b/src/debugger/gui/TrakBallWidget.cxx index 4c32fd2a4..2c262b795 100644 --- a/src/debugger/gui/TrakBallWidget.cxx +++ b/src/debugger/gui/TrakBallWidget.cxx @@ -25,7 +25,7 @@ TrakBallWidget::TrakBallWidget(GuiObject* boss, const GUI::Font& font, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt8 TrakBallWidget::getGrayCodeTable(const int index, const int direction) const +uInt8 TrakBallWidget::getGrayCodeTable(int index, int direction) const { return myGrayCodeTable[(index & 0b1) + direction * 2]; } diff --git a/src/debugger/gui/TrakBallWidget.hxx b/src/debugger/gui/TrakBallWidget.hxx index 4d21c7aa9..5e3f9aaf7 100644 --- a/src/debugger/gui/TrakBallWidget.hxx +++ b/src/debugger/gui/TrakBallWidget.hxx @@ -31,9 +31,11 @@ class TrakBallWidget : public PointingDeviceWidget ~TrakBallWidget() override = default; private: - const std::array myGrayCodeTable = { 0b00, 0b10, 0b01, 0b11 }; + static constexpr std::array myGrayCodeTable = { + 0b00, 0b10, 0b01, 0b11 + }; - 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 TrakBallWidget() = delete; diff --git a/src/debugger/yacc/YaccParser.hxx b/src/debugger/yacc/YaccParser.hxx index a95c37331..0f573f2aa 100644 --- a/src/debugger/yacc/YaccParser.hxx +++ b/src/debugger/yacc/YaccParser.hxx @@ -40,6 +40,6 @@ namespace YaccParser CpuMethod getCpuSpecial(const char* ch); RiotMethod getRiotSpecial(const char* ch); TiaMethod getTiaSpecial(const char* ch); -} +} // namespace YaccParser #endif diff --git a/src/emucore/Bankswitch.hxx b/src/emucore/Bankswitch.hxx index 6cd43face..d5593c93a 100644 --- a/src/emucore/Bankswitch.hxx +++ b/src/emucore/Bankswitch.hxx @@ -37,7 +37,7 @@ class Bankswitch { public: // Currently supported bankswitch schemes - enum class Type { + enum class Type: uInt8 { _AUTO, _03E0, _0840, _0FA0, _2IN1, _4IN1, _8IN1, _16IN1, _32IN1, _64IN1, _128IN1, _2K, _3E, _3EX, _3EP, _3F, _4A50, _4K, _4KSC, _AR, _BF, _BFSC, _BUS, _CDF, @@ -60,7 +60,7 @@ class Bankswitch static constexpr size_t any_KB = 0; static const std::array(Type::NumSchemes)> Sizes; + static_cast(Type::NumSchemes)> Sizes; // Info about the various bankswitch schemes, useful for displaying // in GUI dropdown boxes, etc @@ -69,7 +69,7 @@ class Bankswitch string_view desc; }; static const std::array(Type::NumSchemes)> BSList; + static_cast(Type::NumSchemes)> BSList; public: // Convert BSType enum to string @@ -96,14 +96,14 @@ class Bankswitch /** Convenience functions for different parameter types. */ - static inline bool isValidRomName(const FSNode& name, string& ext) { + static bool isValidRomName(const FSNode& name, string& ext) { return isValidRomName(name.getPath(), ext); } - static inline bool isValidRomName(const FSNode& name) { + static bool isValidRomName(const FSNode& name) { string ext; // extension not used return isValidRomName(name.getPath(), ext); } - static inline bool isValidRomName(string_view name) { + static bool isValidRomName(string_view name) { string ext; // extension not used return isValidRomName(name, ext); } @@ -130,6 +130,7 @@ class Bankswitch private: // Following constructors and assignment operators not supported Bankswitch() = delete; + ~Bankswitch() = delete; Bankswitch(const Bankswitch&) = delete; Bankswitch(Bankswitch&&) = delete; Bankswitch& operator=(const Bankswitch&) = delete; diff --git a/src/emucore/Cart.hxx b/src/emucore/Cart.hxx index 93f842c21..ea09b34ef 100644 --- a/src/emucore/Cart.hxx +++ b/src/emucore/Cart.hxx @@ -32,7 +32,7 @@ class Settings; #ifdef DEBUGGER_SUPPORT namespace GUI { class Font; - } + } // namespace GUI #endif /** @@ -167,8 +167,8 @@ class Cartridge : public Device @return Address of illegal access if one occurred, else 0 */ - inline uInt16 getIllegalRAMReadAccess() const { - return myRamReadAccesses.size() > 0 ? myRamReadAccesses[0] : 0; + uInt16 getIllegalRAMReadAccess() const { + return !myRamReadAccesses.empty() ? myRamReadAccesses[0] : 0; } /** @@ -178,7 +178,9 @@ class Cartridge : public Device @return Address of illegal access if one occurred, else 0 */ - inline uInt16 getIllegalRAMWriteAccess() const { return myRamWriteAccess; } + uInt16 getIllegalRAMWriteAccess() const { + return myRamWriteAccess; + } /** Query the access counters diff --git a/src/emucore/Cart4A50.hxx b/src/emucore/Cart4A50.hxx index d94202d67..209308024 100644 --- a/src/emucore/Cart4A50.hxx +++ b/src/emucore/Cart4A50.hxx @@ -176,43 +176,37 @@ class Cartridge4A50 : public Cartridge /** Methods to perform all the ways that banks can be switched */ - inline void bankROMLower(uInt16 value) - { + void bankROMLower(uInt16 value) { myIsRomLow = true; mySliceLow = value << 11; myBankChanged = true; } - inline void bankRAMLower(uInt16 value) - { + void bankRAMLower(uInt16 value) { myIsRomLow = false; mySliceLow = value << 11; myBankChanged = true; } - inline void bankROMMiddle(uInt16 value) - { + void bankROMMiddle(uInt16 value) { myIsRomMiddle = true; mySliceMiddle = value << 11; myBankChanged = true; } - inline void bankRAMMiddle(uInt16 value) - { + void bankRAMMiddle(uInt16 value) { myIsRomMiddle = false; mySliceMiddle = value << 11; myBankChanged = true; } - inline void bankROMHigh(uInt16 value) - { + void bankROMHigh(uInt16 value) { myIsRomHigh = true; mySliceHigh = value << 8; myBankChanged = true; } - inline void bankRAMHigh(uInt16 value) - { + void bankRAMHigh(uInt16 value) { myIsRomHigh = false; mySliceHigh = value << 8; myBankChanged = true; diff --git a/src/emucore/CartBUS.hxx b/src/emucore/CartBUS.hxx index 8f7c5581a..27a51010a 100644 --- a/src/emucore/CartBUS.hxx +++ b/src/emucore/CartBUS.hxx @@ -42,7 +42,7 @@ class CartridgeBUS : public CartridgeARM friend class CartridgeBUSInfoWidget; friend class CartridgeRamBUSWidget; - enum class BUSSubtype { + enum class BUSSubtype: uInt8 { BUS0, // very old demos when BUS was in flux, not supported in Stella BUS1, // draconian_20161102.bin BUS2, // 128bus_20170120.bin, 128chronocolour_20170101.bin, parrot_20161231_NTSC.bin diff --git a/src/emucore/CartCDF.hxx b/src/emucore/CartCDF.hxx index f40403521..db4d272fb 100644 --- a/src/emucore/CartCDF.hxx +++ b/src/emucore/CartCDF.hxx @@ -66,7 +66,7 @@ class CartridgeCDF : public CartridgeARM public: - enum class CDFSubtype { + enum class CDFSubtype: uInt8 { CDF0, CDF1, CDFJ, diff --git a/src/emucore/CartCreator.hxx b/src/emucore/CartCreator.hxx index 610edeabd..ec985da45 100644 --- a/src/emucore/CartCreator.hxx +++ b/src/emucore/CartCreator.hxx @@ -86,6 +86,7 @@ class CartCreator private: // Following constructors and assignment operators not supported CartCreator() = delete; + ~CartCreator() = delete; CartCreator(const CartCreator&) = delete; CartCreator(CartCreator&&) = delete; CartCreator& operator=(const CartCreator&) = delete; diff --git a/src/emucore/CartDetector.hxx b/src/emucore/CartDetector.hxx index 995e7c046..93030af71 100644 --- a/src/emucore/CartDetector.hxx +++ b/src/emucore/CartDetector.hxx @@ -259,6 +259,7 @@ class CartDetector private: // Following constructors and assignment operators not supported CartDetector() = delete; + ~CartDetector() = delete; CartDetector(const CartDetector&) = delete; CartDetector(CartDetector&&) = delete; CartDetector& operator=(const CartDetector&) = delete; diff --git a/src/emucore/CartELF.cxx b/src/emucore/CartELF.cxx index c3bcb093e..23577308c 100644 --- a/src/emucore/CartELF.cxx +++ b/src/emucore/CartELF.cxx @@ -542,7 +542,7 @@ void CartridgeELF::runArm() ) return; - const uInt32 cyclesGoal = static_cast( + const auto cyclesGoal = static_cast( (mySystem->cycles() + ARM_RUNAHED_MAX) * myArmCyclesPer6502Cycle - getArmCycles()); uInt32 cycles = 0; diff --git a/src/emucore/CompuMate.hxx b/src/emucore/CompuMate.hxx index d7dac730f..85226570c 100644 --- a/src/emucore/CompuMate.hxx +++ b/src/emucore/CompuMate.hxx @@ -52,6 +52,7 @@ class CompuMate @param system The system using this controller */ CompuMate(const Console& console, const Event& event, const System& system); + ~CompuMate() = default; /** Return the left and right CompuMate controllers diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index 35c3c4c19..33182f445 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -968,11 +968,12 @@ void Console::setControllers(string_view romMd5) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Console::changeLeftController(int direction) { - int type = static_cast(Controller::getType(myProperties.get(PropType::Controller_Left))); + auto type = + static_cast(Controller::getType(myProperties.get(PropType::Controller_Left))); if(!type) - type = static_cast(Controller::getType(leftController().name())); + type = static_cast(Controller::getType(leftController().name())); type = BSPF::clampw(type + direction, - 1, static_cast(Controller::Type::LastType) - 1); + 1, static_cast(Controller::Type::LastType) - 1); myProperties.set(PropType::Controller_Left, Controller::getPropName(Controller::Type{type})); setControllers(myProperties.get(PropType::Cart_MD5)); @@ -985,11 +986,12 @@ void Console::changeLeftController(int direction) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Console::changeRightController(int direction) { - int type = static_cast(Controller::getType(myProperties.get(PropType::Controller_Right))); + auto type = + static_cast(Controller::getType(myProperties.get(PropType::Controller_Right))); if(!type) - type = static_cast(Controller::getType(rightController().name())); + type = static_cast(Controller::getType(rightController().name())); type = BSPF::clampw(type + direction, - 1, static_cast(Controller::Type::LastType) - 1); + 1, static_cast(Controller::Type::LastType) - 1); myProperties.set(PropType::Controller_Right, Controller::getPropName(Controller::Type{type})); setControllers(myProperties.get(PropType::Cart_MD5)); @@ -1001,7 +1003,7 @@ void Console::changeRightController(int direction) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - unique_ptr Console::getControllerPort( - const Controller::Type type, const Controller::Jack port, string_view romMd5) + Controller::Type type, Controller::Jack port, string_view romMd5) { unique_ptr controller; diff --git a/src/emucore/Console.hxx b/src/emucore/Console.hxx index e96e13302..49b38d33a 100644 --- a/src/emucore/Console.hxx +++ b/src/emucore/Console.hxx @@ -428,8 +428,8 @@ class Console : public Serializable, public ConsoleIO /** Selects the left or right controller depending on ROM properties */ - unique_ptr getControllerPort(const Controller::Type type, - const Controller::Jack port, + unique_ptr getControllerPort(Controller::Type type, + Controller::Jack port, string_view romMd5); void toggleTIABit(TIABit bit, string_view bitname, diff --git a/src/emucore/ConsoleTiming.hxx b/src/emucore/ConsoleTiming.hxx index d408e0a19..7de5a96c0 100644 --- a/src/emucore/ConsoleTiming.hxx +++ b/src/emucore/ConsoleTiming.hxx @@ -21,7 +21,7 @@ /** Contains timing information about the specified console. */ -enum class ConsoleTiming +enum class ConsoleTiming: uInt8 { ntsc, // console with CPU running at 1.193182 MHz, NTSC colours pal, // console with CPU running at 1.182298 MHz, PAL colours diff --git a/src/emucore/Control.cxx b/src/emucore/Control.cxx index 7b577cecc..75c789a1b 100644 --- a/src/emucore/Control.cxx +++ b/src/emucore/Control.cxx @@ -136,7 +136,7 @@ string Controller::getPropName(const Type type) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Controller::Type Controller::getType(string_view propName) { - for(int i = 0; i < static_cast(Type::LastType); ++i) + for(uInt8 i = 0; i < static_cast(Type::LastType); ++i) if (BSPF::equalsIgnoreCase(propName, getPropName(Type{i}))) return Type{i}; diff --git a/src/emucore/Control.hxx b/src/emucore/Control.hxx index 682845ed9..77f4ee8f1 100644 --- a/src/emucore/Control.hxx +++ b/src/emucore/Control.hxx @@ -81,22 +81,22 @@ class Controller : public Serializable /** Enumeration of the controller jacks */ - enum class Jack { Left = 0, Right = 1, Left2 = 2, Right2 = 3 }; + enum class Jack: uInt8 { Left = 0, Right = 1, Left2 = 2, Right2 = 3 }; /** Enumeration of the digital pins of a controller port */ - enum class DigitalPin { One, Two, Three, Four, Six }; + enum class DigitalPin: uInt8 { One, Two, Three, Four, Six }; /** Enumeration of the analog pins of a controller port */ - enum class AnalogPin { Five, Nine }; + enum class AnalogPin: uInt8 { Five, Nine }; /** Enumeration of the controller types */ - enum class Type + enum class Type: uInt8 { Unknown, AmigaMouse, AtariMouse, AtariVox, BoosterGrip, CompuMate, @@ -269,12 +269,12 @@ class Controller : public Serializable /** Returns the display name of the given controller type */ - static string getName(const Type type); + static string getName(Type type); /** Returns the property name of the given controller type */ - static string getPropName(const Type type); + static string getPropName(Type type); /** Returns the controller type of the given property name @@ -305,9 +305,8 @@ class Controller : public Serializable */ static int analogDeadZoneValue(int deadZone); - inline static int digitalDeadZone() { return DIGITAL_DEAD_ZONE; } - - inline static int analogDeadZone() { return ANALOG_DEAD_ZONE; } + static int digitalDeadZone() { return DIGITAL_DEAD_ZONE; } + static int analogDeadZone() { return ANALOG_DEAD_ZONE; } /** Sets the sensitivity for analog emulation movement @@ -338,28 +337,28 @@ class Controller : public Serializable Derived classes *must* use these accessor/mutator methods. The read/write methods above are meant to be used at a higher level. */ - inline bool setPin(DigitalPin pin, bool value) { + bool setPin(DigitalPin pin, bool value) { return myDigitalPinState[static_cast(pin)] = value; } - inline bool getPin(DigitalPin pin) const { + bool getPin(DigitalPin pin) const { return myDigitalPinState[static_cast(pin)]; } - inline void setPin(AnalogPin pin, AnalogReadout::Connection value) { + void setPin(AnalogPin pin, AnalogReadout::Connection value) { myAnalogPinValue[static_cast(pin)] = value; if(myOnAnalogPinUpdateCallback) myOnAnalogPinUpdateCallback(pin); } - inline AnalogReadout::Connection getPin(AnalogPin pin) const { + AnalogReadout::Connection getPin(AnalogPin pin) const { return myAnalogPinValue[static_cast(pin)]; } - inline void resetDigitalPins() { + void resetDigitalPins() { setPin(DigitalPin::One, true); setPin(DigitalPin::Two, true); setPin(DigitalPin::Three, true); setPin(DigitalPin::Four, true); setPin(DigitalPin::Six, true); } - inline void resetAnalogPins() { + void resetAnalogPins() { setPin(AnalogPin::Five, AnalogReadout::disconnect()); setPin(AnalogPin::Nine, AnalogReadout::disconnect()); } @@ -370,7 +369,7 @@ class Controller : public Serializable @param pressed True if the fire button is currently pressed @return The result of the auto fire event check */ - inline bool getAutoFireState(bool pressed) + bool getAutoFireState(bool pressed) { if(AUTO_FIRE && AUTO_FIRE_RATE && pressed) { @@ -389,7 +388,7 @@ class Controller : public Serializable @param pressed True if the fire button is current pressed @return The result of the auto fire event check */ - inline bool getAutoFireStateP1(bool pressed) + bool getAutoFireStateP1(bool pressed) { if(AUTO_FIRE && AUTO_FIRE_RATE && pressed) { diff --git a/src/emucore/ControlLowLevel.hxx b/src/emucore/ControlLowLevel.hxx index 0258ccf9b..d705d5934 100644 --- a/src/emucore/ControlLowLevel.hxx +++ b/src/emucore/ControlLowLevel.hxx @@ -38,26 +38,26 @@ class ControllerLowLevel : myController(controller) { } virtual ~ControllerLowLevel() = default; - inline bool setPin(Controller::DigitalPin pin, bool value) { + bool setPin(Controller::DigitalPin pin, bool value) { return myController.setPin(pin, value); } - inline bool togglePin(Controller::DigitalPin pin) { return false; } - inline bool getPin(Controller::DigitalPin pin) const { + bool togglePin(Controller::DigitalPin pin) { return false; } // NOLINT (is this required?) + bool getPin(Controller::DigitalPin pin) const { return myController.getPin(pin); } - inline void setPin(Controller::AnalogPin pin, AnalogReadout::Connection value) { + void setPin(Controller::AnalogPin pin, AnalogReadout::Connection value) { myController.setPin(pin, value); } - inline AnalogReadout::Connection getPin(Controller::AnalogPin pin) const { + AnalogReadout::Connection getPin(Controller::AnalogPin pin) const { return myController.getPin(pin); } - inline void resetDigitalPins() { + void resetDigitalPins() { myController.resetDigitalPins(); } - inline void resetAnalogPins() { + void resetAnalogPins() { myController.resetAnalogPins(); } - inline Controller& controller() const { return myController; } + Controller& controller() const { return myController; } protected: Controller& myController; diff --git a/src/emucore/ControllerDetector.cxx b/src/emucore/ControllerDetector.cxx index eef68ed97..dac9141a5 100644 --- a/src/emucore/ControllerDetector.cxx +++ b/src/emucore/ControllerDetector.cxx @@ -23,7 +23,7 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Controller::Type ControllerDetector::detectType( const ByteBuffer& image, size_t size, - const Controller::Type type, const Controller::Jack port, + Controller::Type type, Controller::Jack port, const Settings& settings, bool isQuadTari) { if(type == Controller::Type::Unknown || settings.getBool("rominfo")) @@ -46,7 +46,7 @@ Controller::Type ControllerDetector::detectType( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string ControllerDetector::detectName(const ByteBuffer& image, size_t size, - const Controller::Type type, const Controller::Jack port, + Controller::Type type, Controller::Jack port, const Settings& settings, bool isQuadTari) { return Controller::getName(detectType(image, size, type, port, settings, isQuadTari)); diff --git a/src/emucore/ControllerDetector.hxx b/src/emucore/ControllerDetector.hxx index 38b098113..836678374 100644 --- a/src/emucore/ControllerDetector.hxx +++ b/src/emucore/ControllerDetector.hxx @@ -43,7 +43,7 @@ class ControllerDetector @return The detected controller type */ static Controller::Type detectType(const ByteBuffer& image, size_t size, - const Controller::Type type, const Controller::Jack port, + Controller::Type type, Controller::Jack port, const Settings& settings, bool isQuadTari = false); /** @@ -60,7 +60,7 @@ class ControllerDetector @return The (detected) controller name */ static string detectName(const ByteBuffer& image, size_t size, - const Controller::Type type, const Controller::Jack port, + Controller::Type type, Controller::Jack port, const Settings& settings, bool isQuadTari = false); private: @@ -137,6 +137,7 @@ class ControllerDetector private: // Following constructors and assignment operators not supported ControllerDetector() = delete; + ~ControllerDetector() = delete; ControllerDetector(const ControllerDetector&) = delete; ControllerDetector(ControllerDetector&&) = delete; ControllerDetector& operator=(const ControllerDetector&) = delete; diff --git a/src/emucore/DefProps.hxx b/src/emucore/DefProps.hxx index 9c5b53278..f5d7de9f7 100644 --- a/src/emucore/DefProps.hxx +++ b/src/emucore/DefProps.hxx @@ -25,6 +25,8 @@ regenerated and the application recompiled. */ +// NOLINTBEGIN: static analyzer can't tell the following is data + static constexpr uInt32 DEF_PROPS_SIZE = 3661; /** @@ -3698,4 +3700,6 @@ static constexpr BSPF::array2D DefProps = {{ { "ffebb0070689b9d322687edd9c0a2bae", "", "", "Spitfire Attack (1983) (Milton Bradley) [h1]", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" } }}; +// NOLINTEND + #endif diff --git a/src/emucore/Device.hxx b/src/emucore/Device.hxx index 09461698c..b9f77335a 100644 --- a/src/emucore/Device.hxx +++ b/src/emucore/Device.hxx @@ -33,7 +33,7 @@ class System; class Device : public Serializable { public: - enum AccessType { + enum AccessType: uInt16 { NONE = 0, REFERENCED = 1 << 0, /* 0x01, code somewhere in the program references it, i.e. LDA $F372 referenced $F372 */ @@ -102,7 +102,7 @@ class Device : public Serializable @param out The Serializer object to use @return False on any errors, else true */ - virtual bool save(Serializer& out) const override = 0; + bool save(Serializer& out) const override = 0; /** Load the current state of this device from the given Serializer. @@ -110,7 +110,7 @@ class Device : public Serializable @param in The Serializer object to use @return False on any errors, else true */ - virtual bool load(Serializer& in) override = 0; + bool load(Serializer& in) override = 0; public: /** diff --git a/src/emucore/DispatchResult.hxx b/src/emucore/DispatchResult.hxx index 4eb1edb33..d2c494acc 100644 --- a/src/emucore/DispatchResult.hxx +++ b/src/emucore/DispatchResult.hxx @@ -23,7 +23,7 @@ class DispatchResult { public: - enum class Status { invalid, ok, debugger, fatal }; + enum class Status: uInt8 { invalid, ok, debugger, fatal }; public: diff --git a/src/emucore/EmulationTiming.hxx b/src/emucore/EmulationTiming.hxx index 5ffa4bd8c..97fd579de 100644 --- a/src/emucore/EmulationTiming.hxx +++ b/src/emucore/EmulationTiming.hxx @@ -25,8 +25,9 @@ class EmulationTiming { public: - EmulationTiming(FrameLayout frameLayout = FrameLayout::ntsc, - ConsoleTiming consoleTiming = ConsoleTiming::ntsc); + explicit EmulationTiming(FrameLayout frameLayout = FrameLayout::ntsc, + ConsoleTiming consoleTiming = ConsoleTiming::ntsc); + ~EmulationTiming() = default; EmulationTiming& updateFrameLayout(FrameLayout frameLayout); diff --git a/src/emucore/EmulationWorker.hxx b/src/emucore/EmulationWorker.hxx index 57cc2f026..18f869a0f 100644 --- a/src/emucore/EmulationWorker.hxx +++ b/src/emucore/EmulationWorker.hxx @@ -134,7 +134,7 @@ class EmulationWorker /** Thread state. */ - enum class State { + enum class State: uInt8 { // Initial state initializing, // Thread has initialized. From the point, myThreadIsRunningMutex is locked if and only if @@ -153,7 +153,7 @@ class EmulationWorker /** Thread behavior is controlled by signals that are raised prior to waking up the thread. */ - enum class Signal { + enum class Signal: uInt8 { // Resume emulation resume, // Stop emulation diff --git a/src/emucore/Event.hxx b/src/emucore/Event.hxx index 18d8ef939..8a7d6d9d0 100644 --- a/src/emucore/Event.hxx +++ b/src/emucore/Event.hxx @@ -34,7 +34,7 @@ class Event console and controller event types as well as events that aren't technically part of the emulation core. */ - enum Type + enum Type: uInt16 { NoType = 0, ConsoleColor, ConsoleBlackWhite, ConsoleColorToggle, Console7800Pause, @@ -182,7 +182,7 @@ class Event }; // Event categorizing groups - enum Group + enum Group: uInt8 { Menu, Emulation, Misc, AudioVideo, States, Console, Joystick, Paddles, Driving, Keyboard, @@ -201,13 +201,14 @@ class Event Create a new event object. */ Event() { clear(); } + ~Event() = default; public: /** Get the value associated with the event of the specified type. */ Int32 get(Type type) const { - std::lock_guard lock(myMutex); + const std::lock_guard lock(myMutex); return myValues[type]; } @@ -216,7 +217,7 @@ class Event Set the value associated with the event of the specified type. */ void set(Type type, Int32 value) { - std::lock_guard lock(myMutex); + const std::lock_guard lock(myMutex); myValues[type] = value; } @@ -226,7 +227,7 @@ class Event */ void clear() { - std::lock_guard lock(myMutex); + const std::lock_guard lock(myMutex); myValues.fill(Event::NoType); } diff --git a/src/emucore/EventHandler.hxx b/src/emucore/EventHandler.hxx index 97991e1b7..68ed189c1 100644 --- a/src/emucore/EventHandler.hxx +++ b/src/emucore/EventHandler.hxx @@ -30,7 +30,7 @@ class GlobalKeyHandler; namespace GUI { class Font; -} +} // namespace GUI #include "Event.hxx" #include "EventHandlerConstants.hxx" @@ -59,7 +59,7 @@ class EventHandler /** Create a new event handler object */ - EventHandler(OSystem& osystem); + explicit EventHandler(OSystem& osystem); virtual ~EventHandler(); /** @@ -428,7 +428,7 @@ class EventHandler virtual void pollEvent() = 0; // Other events that can be received from the underlying event handler - enum class SystemEvent { + enum class SystemEvent: uInt8 { WINDOW_SHOWN, WINDOW_HIDDEN, WINDOW_EXPOSED, diff --git a/src/emucore/EventHandlerConstants.hxx b/src/emucore/EventHandlerConstants.hxx index 0283b5ec5..43f630f02 100644 --- a/src/emucore/EventHandlerConstants.hxx +++ b/src/emucore/EventHandlerConstants.hxx @@ -21,7 +21,7 @@ #include // Enumeration representing the different states of operation -enum class EventHandlerState { +enum class EventHandlerState: uInt8 { EMULATION, TIMEMACHINE, PLAYBACK, @@ -36,7 +36,7 @@ enum class EventHandlerState { NONE }; -enum class MouseButton { +enum class MouseButton: uInt8 { LEFT, RIGHT, MIDDLE, @@ -47,7 +47,7 @@ enum class MouseButton { static constexpr int JOY_CTRL_NONE = -1; -enum class JoyAxis { +enum class JoyAxis: Int8 { X = 0, // make sure these are set correctly, Y = 1, // since they'll be used as array indices Z = 2, @@ -55,14 +55,14 @@ enum class JoyAxis { NONE = JOY_CTRL_NONE }; -enum class JoyDir { +enum class JoyDir: Int8 { NEG = -1, POS = 1, NONE = 0, ANALOG = 2 }; -enum class JoyHatDir { +enum class JoyHatDir: uInt8 { UP = 0, // make sure these are set correctly, DOWN = 1, // since they'll be used as array indices LEFT = 2, @@ -70,7 +70,7 @@ enum class JoyHatDir { CENTER = 4 }; -enum JoyHatMask { +enum JoyHatMask: uInt8 { EVENT_HATUP_M = 1<<0, EVENT_HATDOWN_M = 1<<1, EVENT_HATLEFT_M = 1<<2, @@ -78,7 +78,7 @@ enum JoyHatMask { EVENT_HATCENTER_M = 1<<4 }; -enum class EventMode { +enum class EventMode: uInt8 { kEmulationMode, // active mapping used for emulation kMenuMode, // mapping used for dialogs kJoystickMode, // 5 extra modes for mapping controller keys separately for emulation mode @@ -92,8 +92,7 @@ enum class EventMode { kNumModes }; -namespace GUI -{ +namespace GUI { #ifdef RETRON77 static const std::string SELECT = "Mode"; static const std::string LEFT_DIFFICULTY = "P1 skill"; @@ -107,6 +106,6 @@ namespace GUI static const std::string LEFT_DIFF = "Left Diff"; static const std::string RIGHT_DIFF = "Right Diff"; #endif -} +} // namespace GUI #endif // EVENTHANDLER_CONSTANTS_HXX diff --git a/src/emucore/FBSurface.cxx b/src/emucore/FBSurface.cxx index c167ad502..6dffb9a76 100644 --- a/src/emucore/FBSurface.cxx +++ b/src/emucore/FBSurface.cxx @@ -450,7 +450,7 @@ int FBSurface::drawString(const GUI::Font& font, string_view s, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool FBSurface::checkBounds(const uInt32 x, const uInt32 y) const +bool FBSurface::checkBounds(uInt32 x, uInt32 y) const { if (x <= width() && y <= height()) return true; diff --git a/src/emucore/FBSurface.hxx b/src/emucore/FBSurface.hxx index 094c73588..eb89e055f 100644 --- a/src/emucore/FBSurface.hxx +++ b/src/emucore/FBSurface.hxx @@ -23,10 +23,10 @@ class TIASurface; namespace GUI { class Font; -} +} // namespace GUI namespace Common { struct Rect; -} +} // namespace Common #include "FrameBufferConstants.hxx" #include "FrameBuffer.hxx" @@ -55,8 +55,7 @@ class FBSurface This method returns the surface pixel pointer and pitch, which are used when one wishes to modify the surface pixels directly. */ - inline void basePtr(uInt32*& pixels, uInt32& pitch) const - { + void basePtr(uInt32*& pixels, uInt32& pitch) const { pixels = myPixels; pitch = myPitch; } @@ -403,14 +402,14 @@ class FBSurface @param y The y coordinate to check @return True if coordinates are in bounds */ - bool checkBounds(const uInt32 x, const uInt32 y) const; + bool checkBounds(uInt32 x, uInt32 y) const; /** Check if the given character is a whitespace. @param c Character to check @return True if whitespace character */ - static bool isWhiteSpace(const char c) { + static bool isWhiteSpace(char c) { static constexpr string_view spaces{" ,.;:+-*/\\'([\n"}; return spaces.find(c) != string_view::npos; } diff --git a/src/emucore/FSNode.hxx b/src/emucore/FSNode.hxx index b3f6ab99c..9e9b2536e 100644 --- a/src/emucore/FSNode.hxx +++ b/src/emucore/FSNode.hxx @@ -59,7 +59,7 @@ class FSNode /** * Flag to tell listDir() which kind of files to list. */ - enum class ListMode { FilesOnly, DirectoriesOnly, All }; + enum class ListMode: uInt8 { FilesOnly, DirectoriesOnly, All }; /** Function used to filter the file listing. Returns true if the filename should be included, else false.*/ @@ -97,8 +97,7 @@ class FSNode * Compare the name of this node to the name of another, testing for * equality. */ - inline bool operator==(const FSNode& node) const - { + bool operator==(const FSNode& node) const { return BSPF::compareIgnoreCase(getName(), node.getName()) == 0; } diff --git a/src/emucore/FrameBuffer.hxx b/src/emucore/FrameBuffer.hxx index 09875eb61..55e5d1ca8 100644 --- a/src/emucore/FrameBuffer.hxx +++ b/src/emucore/FrameBuffer.hxx @@ -56,7 +56,7 @@ class FrameBuffer // Zoom level step interval static constexpr double ZOOM_STEPS = 0.25; - enum UpdateMode { + enum UpdateMode: uInt8 { NONE = 0, REDRAW = 1, RERENDER = 2 diff --git a/src/emucore/FrameBufferConstants.hxx b/src/emucore/FrameBufferConstants.hxx index 6b5d3c4a8..955c32ee7 100644 --- a/src/emucore/FrameBufferConstants.hxx +++ b/src/emucore/FrameBufferConstants.hxx @@ -25,31 +25,31 @@ namespace FBMinimum { static constexpr uInt32 Width = TIAConstants::viewableWidth * 2; static constexpr uInt32 Height = TIAConstants::viewableHeight * 2; -} +} // namespace FBMinimum // Return values for initialization of framebuffer window -enum class FBInitStatus { +enum class FBInitStatus: uInt8 { Success, FailComplete, FailTooLarge, FailNotSupported }; -enum class BufferType { +enum class BufferType: uInt8 { None, Launcher, Emulator, Debugger }; -enum class ScalingInterpolation { +enum class ScalingInterpolation: uInt8 { none, sharp, blur }; // Positions for onscreen/overlaid messages -enum class MessagePosition { +enum class MessagePosition: uInt8 { TopLeft, TopCenter, TopRight, @@ -120,14 +120,14 @@ using UIPaletteArray = std::array; using FullPaletteArray = std::array; // Text alignment modes for drawString() -enum class TextAlign { +enum class TextAlign: uInt8 { Left, Center, Right }; // Line types for drawing rectangular frames -enum class FrameStyle { +enum class FrameStyle: uInt8 { Solid, Dashed }; diff --git a/src/emucore/GlobalKeyHandler.cxx b/src/emucore/GlobalKeyHandler.cxx index 67355c43f..1e0b393ce 100644 --- a/src/emucore/GlobalKeyHandler.cxx +++ b/src/emucore/GlobalKeyHandler.cxx @@ -34,7 +34,7 @@ GlobalKeyHandler::GlobalKeyHandler(OSystem& osystem) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool GlobalKeyHandler::handleEvent(const Event::Type event, bool pressed, bool repeated) +bool GlobalKeyHandler::handleEvent(Event::Type event, bool pressed, bool repeated) { // The global settings keys change settings or values as long as the setting // message from the previous settings event is still displayed. @@ -136,7 +136,7 @@ bool GlobalKeyHandler::handleEvent(const Event::Type event, bool pressed, bool r } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void GlobalKeyHandler::setSetting(const Setting setting) +void GlobalKeyHandler::setSetting(Setting setting) { if(setting == Setting::ZOOM && myOSystem.frameBuffer().fullScreen()) mySetting = Setting::FS_ASPECT; @@ -146,7 +146,7 @@ void GlobalKeyHandler::setSetting(const Setting setting) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void GlobalKeyHandler::setDirectSetting(const Setting setting) +void GlobalKeyHandler::setDirectSetting(Setting setting) { myDirectSetting = setting; } @@ -331,7 +331,7 @@ GlobalKeyHandler::Function GlobalKeyHandler::cycleSetting(int direction) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -GlobalKeyHandler::SettingData GlobalKeyHandler::getSettingData(const Setting setting) const +GlobalKeyHandler::SettingData GlobalKeyHandler::getSettingData(Setting setting) const { // Notes: // - all setting methods MUST always display a message diff --git a/src/emucore/GlobalKeyHandler.hxx b/src/emucore/GlobalKeyHandler.hxx index 61ba7f91c..b59b130d8 100644 --- a/src/emucore/GlobalKeyHandler.hxx +++ b/src/emucore/GlobalKeyHandler.hxx @@ -29,9 +29,10 @@ class GlobalKeyHandler { public: explicit GlobalKeyHandler(OSystem& osystem); + ~GlobalKeyHandler() = default; public: - enum class Setting + enum class Setting: Int8 { NONE = -1, // *** Audio & Video group *** @@ -138,14 +139,14 @@ class GlobalKeyHandler }; public: - bool handleEvent(const Event::Type event, bool pressed, bool repeated); - void setSetting(const Setting setting); - void setDirectSetting(const Setting setting); + bool handleEvent(Event::Type event, bool pressed, bool repeated); + void setSetting(Setting setting); + void setDirectSetting(Setting setting); private: using Function = std::function; - enum class Group + enum class Group: uInt8 { AV, INPUT, @@ -171,7 +172,7 @@ class GlobalKeyHandler // Cycle settings using given direction (can be 0) Function cycleSetting(int direction); // Get adjustment function and if it is repeated - SettingData getSettingData(const Setting setting) const; + SettingData getSettingData(Setting setting) const; PhysicalJoystickHandler& joyHandler() const { return myOSystem.eventHandler().joyHandler(); diff --git a/src/emucore/Keyboard.hxx b/src/emucore/Keyboard.hxx index 4da722489..f7e68688b 100644 --- a/src/emucore/Keyboard.hxx +++ b/src/emucore/Keyboard.hxx @@ -63,7 +63,7 @@ class Keyboard : public Controller string name() const override { return "Keyboard"; } private: - enum class ColumnState { + enum class ColumnState: uInt8 { vcc, gnd, notConnected }; diff --git a/src/emucore/KidVid.hxx b/src/emucore/KidVid.hxx index 5141f5200..1dee5f224 100644 --- a/src/emucore/KidVid.hxx +++ b/src/emucore/KidVid.hxx @@ -102,7 +102,7 @@ class KidVid : public Controller void setNextSong(); private: - enum class Game { + enum class Game: uInt8 { Smurfs, BBears }; diff --git a/src/emucore/M6532.hxx b/src/emucore/M6532.hxx index 4a018fb63..4b3e9fe7b 100644 --- a/src/emucore/M6532.hxx +++ b/src/emucore/M6532.hxx @@ -250,11 +250,14 @@ class M6532 : public Device std::array myIOAccessBase; // The arrays containing information about every byte of RIOT // indicating how often it is accessed. - std::array myRAMAccessCounter; - std::array myStackAccessCounter; - std::array myIOAccessCounter; + std::array(RAM_SIZE * 2)> myRAMAccessCounter; + std::array(STACK_SIZE * 2)> myStackAccessCounter; + std::array(IO_SIZE * 2)> myIOAccessCounter; // The array used to skip the first ZP access tracking - std::array myZPAccessDelay; + std::array myZPAccessDelay; // Detect timer being accessed on wraparound bool myTimWrappedOnRead{false}; diff --git a/src/emucore/MD5.cxx b/src/emucore/MD5.cxx index 6d8292a98..afdd5f04f 100644 --- a/src/emucore/MD5.cxx +++ b/src/emucore/MD5.cxx @@ -60,7 +60,7 @@ void MD5::init() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Decodes input (uInt8) into output (uInt32). // Assumes len is a multiple of 4. -void MD5::decode(uInt32* output, const uInt8* const input, uInt32 len) +void MD5::decode(uInt32* output, const uInt8* input, uInt32 len) { for (uInt32 i = 0, j = 0; j < len; ++i, j += 4) output[i] = (static_cast(input[j])) @@ -72,7 +72,7 @@ void MD5::decode(uInt32* output, const uInt8* const input, uInt32 len) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Encodes input (uInt32) into output (uInt8). // Assumes len is a multiple of 4. -void MD5::encode(uInt8* output, const uInt32* const input, uInt32 len) +void MD5::encode(uInt8* output, const uInt32* input, uInt32 len) { for (uInt32 i = 0, j = 0; j < len; ++i, j += 4) { output[j] = static_cast(input[i] & 0xff); @@ -84,7 +84,7 @@ void MD5::encode(uInt8* output, const uInt32* const input, uInt32 len) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Apply MD5 algo on a block. -void MD5::transform(const uInt8* const block) +void MD5::transform(const uInt8* block) { std::array x; decode(x.data(), block, BLOCKSIZE); @@ -175,7 +175,7 @@ void MD5::transform(const uInt8* const block) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // MD5 block update operation. // Continues an MD5 message-digest operation, processing another message block. -void MD5::update(const uInt8* const input, uInt32 length) +void MD5::update(const uInt8* input, uInt32 length) { // Compute number of bytes mod 64 auto index = count[0] / 8 % BLOCKSIZE; diff --git a/src/emucore/MD5.hxx b/src/emucore/MD5.hxx index b3f404fbc..2b12ae380 100644 --- a/src/emucore/MD5.hxx +++ b/src/emucore/MD5.hxx @@ -72,54 +72,55 @@ class MD5 public: MD5() = default; + ~MD5() = default; private: void init(); - void update(const uInt8* const input, uInt32 length); + void update(const uInt8* input, uInt32 length); void finalize(); string hexdigest() const; void transform(const uInt8* block); - static void decode(uInt32* output, const uInt8* const input, uInt32 len); - static void encode(uInt8* output, const uInt32* const input, uInt32 len); + static void decode(uInt32* output, const uInt8* input, uInt32 len); + static void encode(uInt8* output, const uInt32* input, uInt32 len); // F, G, H and I are basic MD5 functions. - FORCE_INLINE constexpr uInt32 F(uInt32 x, uInt32 y, uInt32 z) { + static constexpr uInt32 F(uInt32 x, uInt32 y, uInt32 z) { return (x&y) | (~x&z); } - FORCE_INLINE constexpr uInt32 G(uInt32 x, uInt32 y, uInt32 z) { + static constexpr uInt32 G(uInt32 x, uInt32 y, uInt32 z) { return (x&z) | (y&~z); } - FORCE_INLINE constexpr uInt32 H(uInt32 x, uInt32 y, uInt32 z) { + static constexpr uInt32 H(uInt32 x, uInt32 y, uInt32 z) { return x^y^z; } - FORCE_INLINE constexpr uInt32 I(uInt32 x, uInt32 y, uInt32 z) { + static constexpr uInt32 I(uInt32 x, uInt32 y, uInt32 z) { return y ^ (x | ~z); } // rotate_left rotates x left n bits. - FORCE_INLINE constexpr uInt32 rotate_left(uInt32 x, int n) { + static constexpr uInt32 rotate_left(uInt32 x, int n) { return (x << n) | (x >> (32-n)); } // FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. // Rotation is separate from addition to prevent recomputation. - FORCE_INLINE constexpr void FF(uInt32 &a, uInt32 b, uInt32 c, - uInt32 d, uInt32 x, uInt32 s, uInt32 ac) { + static constexpr void FF(uInt32 &a, uInt32 b, uInt32 c, + uInt32 d, uInt32 x, uInt32 s, uInt32 ac) { a = rotate_left(a+ F(b,c,d) + x + ac, s) + b; } - FORCE_INLINE constexpr void GG(uInt32 &a, uInt32 b, uInt32 c, uInt32 d, - uInt32 x, uInt32 s, uInt32 ac) { + static constexpr void GG(uInt32 &a, uInt32 b, uInt32 c, uInt32 d, + uInt32 x, uInt32 s, uInt32 ac) { a = rotate_left(a + G(b,c,d) + x + ac, s) + b; } - FORCE_INLINE constexpr void HH(uInt32 &a, uInt32 b, uInt32 c, uInt32 d, - uInt32 x, uInt32 s, uInt32 ac) { + static constexpr void HH(uInt32 &a, uInt32 b, uInt32 c, uInt32 d, + uInt32 x, uInt32 s, uInt32 ac) { a = rotate_left(a + H(b,c,d) + x + ac, s) + b; } - FORCE_INLINE constexpr void II(uInt32 &a, uInt32 b, uInt32 c, uInt32 d, - uInt32 x, uInt32 s, uInt32 ac) { + static constexpr void II(uInt32 &a, uInt32 b, uInt32 c, uInt32 d, + uInt32 x, uInt32 s, uInt32 ac) { a = rotate_left(a + I(b,c,d) + x + ac, s) + b; } private: - static inline constexpr uInt32 BLOCKSIZE = 64; + static constexpr uInt32 BLOCKSIZE = 64; bool finalized{false}; std::array buffer; // bytes that didn't fit in last chunk std::array count; // 64bit counter for number of bits (lo, hi) diff --git a/src/emucore/MT24LC256.hxx b/src/emucore/MT24LC256.hxx index eeebc5cc3..4a292dc7b 100644 --- a/src/emucore/MT24LC256.hxx +++ b/src/emucore/MT24LC256.hxx @@ -80,7 +80,7 @@ class MT24LC256 void jpee_data_stop(); void jpee_clock_fall(); bool jpee_timercheck(int mode); - void jpee_logproc(string_view st) { cerr << " " << st << '\n'; } + static void jpee_logproc(string_view st) { cerr << " " << st << '\n'; } void update(); diff --git a/src/emucore/OSystem.hxx b/src/emucore/OSystem.hxx index 50c352ef8..93437cfb7 100644 --- a/src/emucore/OSystem.hxx +++ b/src/emucore/OSystem.hxx @@ -105,7 +105,7 @@ class OSystem @return The frame buffer */ FrameBuffer& frameBuffer() const { return *myFrameBuffer; } - bool hasFrameBuffer() const { return myFrameBuffer.get() != nullptr; } + bool hasFrameBuffer() const { return myFrameBuffer != nullptr; } /** Get the sound object of the system. diff --git a/src/emucore/Props.hxx b/src/emucore/Props.hxx index f0f005326..d2d8bef58 100644 --- a/src/emucore/Props.hxx +++ b/src/emucore/Props.hxx @@ -97,7 +97,7 @@ class Properties @return The value of the property */ const string& get(PropType key) const { - const uInt8 pos = static_cast(key); + const auto pos = static_cast(key); return pos < static_cast(PropType::NumTypes) ? myProperties[pos] : EmptyString; } diff --git a/src/emucore/PropsSet.hxx b/src/emucore/PropsSet.hxx index 5b4b6ee39..e5080fb8a 100644 --- a/src/emucore/PropsSet.hxx +++ b/src/emucore/PropsSet.hxx @@ -40,8 +40,8 @@ class OSystem; class PropertiesSet { public: - PropertiesSet(); + ~PropertiesSet() = default; void setRepository(shared_ptr repository); diff --git a/src/emucore/QuadTari.cxx b/src/emucore/QuadTari.cxx index c9585a32f..ce304942d 100644 --- a/src/emucore/QuadTari.cxx +++ b/src/emucore/QuadTari.cxx @@ -82,7 +82,7 @@ QuadTari::QuadTari(Jack jack, const OSystem& osystem, const System& system, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -unique_ptr QuadTari::addController(const Controller::Type type, bool second) +unique_ptr QuadTari::addController(Controller::Type type, bool second) { FSNode nvramfile = myOSystem.nvramDir(); const Controller::onMessageCallback callback = [&os = myOSystem] diff --git a/src/emucore/QuadTari.hxx b/src/emucore/QuadTari.hxx index 238ecc8df..07d5ae7e6 100644 --- a/src/emucore/QuadTari.hxx +++ b/src/emucore/QuadTari.hxx @@ -121,7 +121,7 @@ class QuadTari : public Controller // determine which controller is active bool isFirst() const; - unique_ptr addController(const Controller::Type type, bool second); + unique_ptr addController(Controller::Type type, bool second); const OSystem& myOSystem; const Properties& myProperties; diff --git a/src/emucore/Random.hxx b/src/emucore/Random.hxx index 6e4c916a2..0026c792d 100644 --- a/src/emucore/Random.hxx +++ b/src/emucore/Random.hxx @@ -39,6 +39,7 @@ class Random : public Serializable explicit Random() { initSeed(static_cast(std::chrono::system_clock::now().time_since_epoch().count())); } + ~Random() override = default; /** Create a new random number generator with given seed. diff --git a/src/emucore/SaveKey.cxx b/src/emucore/SaveKey.cxx index 5608001c2..84a6d9b5e 100644 --- a/src/emucore/SaveKey.cxx +++ b/src/emucore/SaveKey.cxx @@ -110,7 +110,7 @@ void SaveKey::eraseCurrent() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool SaveKey::isPageUsed(const uInt32 page) const +bool SaveKey::isPageUsed(uInt32 page) const { return myEEPROM->isPageUsed(page); } diff --git a/src/emucore/SaveKey.hxx b/src/emucore/SaveKey.hxx index 8a60a02d1..df77e62dd 100644 --- a/src/emucore/SaveKey.hxx +++ b/src/emucore/SaveKey.hxx @@ -109,7 +109,7 @@ class SaveKey : public Controller void eraseCurrent(); /** Returns true if the page is used by the current ROM */ - bool isPageUsed(const uInt32 page) const; + bool isPageUsed(uInt32 page) const; private: // The EEPROM used in the SaveKey diff --git a/src/emucore/Serializer.hxx b/src/emucore/Serializer.hxx index ad5b62401..4e72e0f76 100644 --- a/src/emucore/Serializer.hxx +++ b/src/emucore/Serializer.hxx @@ -35,7 +35,7 @@ class Serializer { public: - enum class Mode { ReadOnly, ReadWrite, ReadWriteTrunc }; + enum class Mode: uInt8 { ReadOnly, ReadWrite, ReadWriteTrunc }; public: /** diff --git a/src/emucore/Settings.hxx b/src/emucore/Settings.hxx index 64e045707..be3eccab8 100644 --- a/src/emucore/Settings.hxx +++ b/src/emucore/Settings.hxx @@ -105,10 +105,10 @@ class Settings const string& getString(string_view key) const { return value(key).toString(); } - const Common::Size getSize(string_view key) const { + Common::Size getSize(string_view key) const { return value(key).toSize(); } - const Common::Point getPoint(string_view key) const { + Common::Point getPoint(string_view key) const { return value(key).toPoint(); } diff --git a/src/emucore/Sound.hxx b/src/emucore/Sound.hxx index 8c75b4130..e7aa8ed23 100644 --- a/src/emucore/Sound.hxx +++ b/src/emucore/Sound.hxx @@ -38,7 +38,7 @@ class Sound Create a new sound object. The open method must be invoked before using the object. */ - Sound(OSystem& osystem) : myOSystem{osystem} { } + explicit Sound(OSystem& osystem) : myOSystem{osystem} { } virtual ~Sound() = default; public: diff --git a/src/emucore/System.hxx b/src/emucore/System.hxx index 81afa1a75..d994ed8ef 100644 --- a/src/emucore/System.hxx +++ b/src/emucore/System.hxx @@ -101,14 +101,14 @@ class System : public Serializable @return The attached 6532 microprocessor */ - inline M6532& m6532() const { return myM6532; } + M6532& m6532() const { return myM6532; } /** Answer the TIA device attached to the system. @return The attached TIA device */ - inline TIA& tia() const { return myTIA; } + TIA& tia() const { return myTIA; } /** Answer the Cart attached to the system. @@ -140,14 +140,14 @@ class System : public Serializable @return The number of system cycles which have passed */ - inline uInt64 cycles() const { return myCycles; } + uInt64 cycles() const { return myCycles; } /** Increment the system cycles by the specified number of cycles. @param amount The amount to add to the system cycles counter */ - inline void incrementCycles(uInt32 amount) { myCycles += amount; } + void incrementCycles(uInt32 amount) { myCycles += amount; } /** Informs all attached devices that the console type has changed. @@ -171,7 +171,7 @@ class System : public Serializable /** * See peekImpl below. */ - inline uInt8 peek(uInt16 address, Device::AccessFlags flags = Device::NONE) + uInt8 peek(uInt16 address, Device::AccessFlags flags = Device::NONE) { return peekImpl(address, flags); } @@ -179,7 +179,7 @@ class System : public Serializable /** * See peekImpl below. */ - inline uInt8 peekOob(uInt16 address, Device::AccessFlags flags = Device::NONE) + uInt8 peekOob(uInt16 address, Device::AccessFlags flags = Device::NONE) { return peekImpl(address, flags); } @@ -187,7 +187,7 @@ class System : public Serializable /** * See pokeImpl below. */ - inline void poke(uInt16 address, uInt8 value, Device::AccessFlags flags = Device::NONE) + void poke(uInt16 address, uInt8 value, Device::AccessFlags flags = Device::NONE) { pokeImpl(address, value, flags); } @@ -195,7 +195,7 @@ class System : public Serializable /** * See pokeImpl below. */ - inline void pokeOob(uInt16 address, uInt8 value, Device::AccessFlags flags = Device::NONE) + void pokeOob(uInt16 address, uInt8 value, Device::AccessFlags flags = Device::NONE) { pokeImpl(address, value, flags); } diff --git a/src/emucore/TIASurface.hxx b/src/emucore/TIASurface.hxx index e161f5d0a..944d4ed45 100644 --- a/src/emucore/TIASurface.hxx +++ b/src/emucore/TIASurface.hxx @@ -169,7 +169,7 @@ class TIASurface Enable/disable/query NTSC filtering effects. */ void enableNTSC(bool enable); - bool ntscEnabled() const { return uInt8(myFilter) & 0x10; } + bool ntscEnabled() const { return static_cast(myFilter) & 0x10; } string effectsInfo() const; /** @@ -195,7 +195,7 @@ class TIASurface void updateSurfaceSettings(); private: - enum class ScanlineMask { + enum class ScanlineMask: uInt8 { Standard, Thin, Pixels, @@ -246,10 +246,12 @@ class TIASurface // Phosphor blend int myPBlend{0}; - std::array myRGBFramebuffer; - std::array myPrevRGBFramebuffer; + std::array + (AtariNTSC::outWidth(TIAConstants::frameBufferWidth) * + TIAConstants::frameBufferHeight)> myRGBFramebuffer; + std::array + (AtariNTSC::outWidth(TIAConstants::frameBufferWidth) * + TIAConstants::frameBufferHeight)> myPrevRGBFramebuffer; ///////////////////////////////////////////////////////////// // Use scanlines in TIA rendering mode diff --git a/src/emucore/Thumbulator.cxx b/src/emucore/Thumbulator.cxx index 37eaee80b..705f5488f 100644 --- a/src/emucore/Thumbulator.cxx +++ b/src/emucore/Thumbulator.cxx @@ -135,7 +135,7 @@ using Common::Base; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Thumbulator::Thumbulator(const uInt16* rom_ptr, uInt16* ram_ptr, uInt32 rom_size, - const uInt32 c_base, const uInt32 c_start, const uInt32 c_stack, + uInt32 c_base, uInt32 c_start, uInt32 c_stack, bool traponfatal, double cyclefactor, Thumbulator::ConfigureFor configurefor, Cartridge* cartridge) @@ -760,9 +760,9 @@ uInt32 Thumbulator::read32(uInt32 addr) data = systick_count; return data; #ifdef THUMB_CYCLE_COUNT - case 0xE01FC100: // APBDIV + case 0xE01FC100: // APBDIV _countCycles = true; // enabe cycle counting - return 1; // random value + return 1; // random value #endif #ifndef UNSAFE_OPTIMIZATIONS diff --git a/src/emucore/Thumbulator.hxx b/src/emucore/Thumbulator.hxx index bb3c614f4..adfaf8638 100644 --- a/src/emucore/Thumbulator.hxx +++ b/src/emucore/Thumbulator.hxx @@ -50,7 +50,7 @@ class Thumbulator public: // control cartridge specific features of the Thumbulator class, // such as the start location for calling custom code - enum class ConfigureFor { + enum class ConfigureFor: uInt8 { BUS, // cartridges of type BUS CDF, // cartridges of type CDF CDF1, // cartridges of type CDF version 1 @@ -58,7 +58,7 @@ class Thumbulator CDFJplus, // cartridges of type CDFJ+ DPCplus // cartridges of type DPC+ }; - enum class ChipType { + enum class ChipType: Int8 { AUTO = -1, LPC2101, // Harmony (includes LPC2103) LPC2104_OC, // Dev cart overclocked (includes LPC2105) @@ -66,7 +66,7 @@ class Thumbulator LPC213x, // future use (includes LPC2132) numTypes }; - enum class MamModeType { + enum class MamModeType: uInt8 { mode0, mode1, mode2, modeX }; struct ChipPropsType { @@ -88,10 +88,11 @@ class Thumbulator }; Thumbulator(const uInt16* rom_ptr, uInt16* ram_ptr, uInt32 rom_size, - const uInt32 c_base, const uInt32 c_start, const uInt32 c_stack, + uInt32 c_base, uInt32 c_start, uInt32 c_stack, bool traponfatal, double cyclefactor, Thumbulator::ConfigureFor configurefor, Cartridge* cartridge); + ~Thumbulator() = default; /** Run the ARM code, and return when finished. A runtime_error exception is @@ -198,14 +199,15 @@ class Thumbulator numOps }; #ifdef THUMB_CYCLE_COUNT - enum class CycleType { + enum class CycleType: uInt8 { S, N, I // Sequential, Non-sequential, Internal }; - enum class AccessType { + enum class AccessType: uInt8 { prefetch, branch, data }; #endif - const std::array ChipProps = + const std::array(ChipType::numTypes)> ChipProps = {{ { "LPC2101..3", 70.0, 4, 1 }, // LPC2101_02_03 { "LPC2104..6 OC", 70.0, 4, 2 }, // LPC2104_05_06 Overclocked @@ -335,10 +337,10 @@ class Thumbulator ROMSIZE = ROMADDMASK + 1, // 512KB RAMSIZE = RAMADDMASK + 1, // 32KB - CPSR_N = 1u << 31, - CPSR_Z = 1u << 30, - CPSR_C = 1u << 29, - CPSR_V = 1u << 28; + CPSR_N = 1U << 31, + CPSR_Z = 1U << 30, + CPSR_C = 1U << 29, + CPSR_V = 1U << 28; private: // Following constructors and assignment operators not supported diff --git a/src/emucore/exception/EmulationWarning.hxx b/src/emucore/exception/EmulationWarning.hxx index 60d08ac08..10d6dcc6c 100644 --- a/src/emucore/exception/EmulationWarning.hxx +++ b/src/emucore/exception/EmulationWarning.hxx @@ -32,7 +32,7 @@ class EmulationWarning : public std::exception } private: - const string myMessage; + string myMessage; }; #endif // EMULATION_WARNING_HXX diff --git a/src/emucore/exception/FatalEmulationError.hxx b/src/emucore/exception/FatalEmulationError.hxx index ea70df0c5..9fe7dc4a1 100644 --- a/src/emucore/exception/FatalEmulationError.hxx +++ b/src/emucore/exception/FatalEmulationError.hxx @@ -32,7 +32,7 @@ class FatalEmulationError : public std::exception } private: - const string myMessage; + string myMessage; }; #endif // FATAL_EMULATION_ERROR_HXX diff --git a/src/emucore/tia/AnalogReadout.hxx b/src/emucore/tia/AnalogReadout.hxx index d636d2b90..9a1cadf13 100644 --- a/src/emucore/tia/AnalogReadout.hxx +++ b/src/emucore/tia/AnalogReadout.hxx @@ -43,6 +43,7 @@ class AnalogReadout : public Serializable public: AnalogReadout(); + ~AnalogReadout() override = default; void reset(uInt64 timestamp); diff --git a/src/emucore/tia/Audio.hxx b/src/emucore/tia/Audio.hxx index 9a054c5b0..d5809625a 100644 --- a/src/emucore/tia/Audio.hxx +++ b/src/emucore/tia/Audio.hxx @@ -28,6 +28,7 @@ class Audio : public Serializable { public: Audio(); + ~Audio() override = default; void reset(); @@ -46,9 +47,9 @@ class Audio : public Serializable FORCE_INLINE void tick(); - inline AudioChannel& channel0() { return myChannel0; } + AudioChannel& channel0() { return myChannel0; } - inline AudioChannel& channel1() { return myChannel1; } + AudioChannel& channel1() { return myChannel1; } /** Serializable methods (see that class for more information). diff --git a/src/emucore/tia/AudioChannel.hxx b/src/emucore/tia/AudioChannel.hxx index 6302dcba3..ee37f5931 100644 --- a/src/emucore/tia/AudioChannel.hxx +++ b/src/emucore/tia/AudioChannel.hxx @@ -25,6 +25,7 @@ class AudioChannel : public Serializable { public: AudioChannel() = default; + ~AudioChannel() override = default; void reset(); diff --git a/src/emucore/tia/Background.hxx b/src/emucore/tia/Background.hxx index c24231b2c..9d5f0a946 100644 --- a/src/emucore/tia/Background.hxx +++ b/src/emucore/tia/Background.hxx @@ -27,6 +27,7 @@ class Background : public Serializable { public: Background() = default; + ~Background() override = default; public: void setTIA(TIA* tia) { myTIA = tia; } @@ -39,7 +40,7 @@ class Background : public Serializable void applyColorLoss(); - inline uInt8 getColor() const { return myColor; } + uInt8 getColor() const { return myColor; } /** Serializable methods (see that class for more information). diff --git a/src/emucore/tia/Ball.hxx b/src/emucore/tia/Ball.hxx index dc81b4289..74c44b7f1 100644 --- a/src/emucore/tia/Ball.hxx +++ b/src/emucore/tia/Ball.hxx @@ -27,11 +27,11 @@ class TIA; class Ball : public Serializable { public: - /** The collision mask is injected at construction */ explicit Ball(uInt32 collisionMask); + ~Ball() override = default; public: @@ -123,12 +123,12 @@ class Ball : public Serializable Is the ball visible? This is determined by looking at bit 15 of the collision mask. */ - inline bool isOn() const { return (collision & 0x8000); } + bool isOn() const { return (collision & 0x8000); } /** Get the current color. */ - inline uInt8 getColor() const { return myColor; } + uInt8 getColor() const { return myColor; } /** Shuffle the enabled flag. This is called in VDELBL mode when GRP1 is diff --git a/src/emucore/tia/DelayQueue.hxx b/src/emucore/tia/DelayQueue.hxx index 254f4f1cb..f66069929 100644 --- a/src/emucore/tia/DelayQueue.hxx +++ b/src/emucore/tia/DelayQueue.hxx @@ -34,6 +34,7 @@ class DelayQueue : public Serializable public: DelayQueue(); + ~DelayQueue() override = default; public: diff --git a/src/emucore/tia/DelayQueueIteratorImpl.hxx b/src/emucore/tia/DelayQueueIteratorImpl.hxx index 3f5bd6519..b5fcdd820 100644 --- a/src/emucore/tia/DelayQueueIteratorImpl.hxx +++ b/src/emucore/tia/DelayQueueIteratorImpl.hxx @@ -44,7 +44,7 @@ class DelayQueueIteratorImpl : public DelayQueueIterator uInt8 currentIndex() const; private: - const DelayQueue& myDelayQueue; + const DelayQueue& myDelayQueue; // NOLINT: we want a reference here uInt8 myDelayCycle{0}; uInt8 myIndex{0}; }; diff --git a/src/emucore/tia/DelayQueueMember.hxx b/src/emucore/tia/DelayQueueMember.hxx index 8a8bf6440..2dca006ad 100644 --- a/src/emucore/tia/DelayQueueMember.hxx +++ b/src/emucore/tia/DelayQueueMember.hxx @@ -32,6 +32,7 @@ class DelayQueueMember : public Serializable { public: DelayQueueMember(); + ~DelayQueueMember() override = default; public: void push(uInt8 address, uInt8 value); @@ -64,9 +65,7 @@ class DelayQueueMember : public Serializable { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - template -DelayQueueMember::DelayQueueMember() -{ -} +DelayQueueMember::DelayQueueMember() = default; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - template @@ -82,7 +81,7 @@ void DelayQueueMember::push(uInt8 address, uInt8 value) template void DelayQueueMember::remove(uInt8 address) { - uInt8 index; + uInt8 index = 0; for (index = 0; index < mySize; ++index) { if (myEntries[index].address == address) break; diff --git a/src/emucore/tia/DrawCounterDecodes.hxx b/src/emucore/tia/DrawCounterDecodes.hxx index 598828aa0..35e92359f 100644 --- a/src/emucore/tia/DrawCounterDecodes.hxx +++ b/src/emucore/tia/DrawCounterDecodes.hxx @@ -33,6 +33,7 @@ class DrawCounterDecodes protected: DrawCounterDecodes(); + ~DrawCounterDecodes() = default; private: diff --git a/src/emucore/tia/FrameLayout.hxx b/src/emucore/tia/FrameLayout.hxx index 08c78474a..e1305b73d 100644 --- a/src/emucore/tia/FrameLayout.hxx +++ b/src/emucore/tia/FrameLayout.hxx @@ -18,7 +18,7 @@ #ifndef FRAME_LAYOUT #define FRAME_LAYOUT -enum class FrameLayout { +enum class FrameLayout: uInt8 { ntsc, // ROM display has NTSC timings (~60Hz, ~262 scanlines, etc) pal, // ROM display has PAL timings (~50Hz, ~312 scanlines, etc) pal60, // ROM display has NTSC timings (~60Hz, ~262 scanlines, etc), but uses PAL colors diff --git a/src/emucore/tia/LatchedInput.hxx b/src/emucore/tia/LatchedInput.hxx index 27cb44246..76ee53c9a 100644 --- a/src/emucore/tia/LatchedInput.hxx +++ b/src/emucore/tia/LatchedInput.hxx @@ -25,6 +25,7 @@ class LatchedInput : public Serializable { public: LatchedInput() = default; + ~LatchedInput() override = default; public: diff --git a/src/emucore/tia/Missile.hxx b/src/emucore/tia/Missile.hxx index ae9a65593..995a18650 100644 --- a/src/emucore/tia/Missile.hxx +++ b/src/emucore/tia/Missile.hxx @@ -30,6 +30,7 @@ class Missile : public Serializable public: explicit Missile(uInt32 collisionMask); + ~Missile() override = default; public: @@ -64,7 +65,7 @@ class Missile : public Serializable void toggleEnabled(bool enabled); - inline bool isOn() const { return (collision & 0x8000); } + bool isOn() const { return (collision & 0x8000); } uInt8 getColor() const; uInt8 getPosition() const; diff --git a/src/emucore/tia/Player.hxx b/src/emucore/tia/Player.hxx index a6247005a..222e2a7d5 100644 --- a/src/emucore/tia/Player.hxx +++ b/src/emucore/tia/Player.hxx @@ -28,6 +28,7 @@ class Player : public Serializable { public: explicit Player(uInt32 collisionMask); + ~Player() override = default; public: @@ -66,7 +67,7 @@ class Player : public Serializable uInt8 getClock() const { return myCounter; } - inline bool isOn() const { return (collision & 0x8000); } + bool isOn() const { return (collision & 0x8000); } uInt8 getColor() const; void shufflePatterns(); @@ -115,7 +116,7 @@ class Player : public Serializable uInt8 myColor{0}; uInt8 myObjectColor{0}, myDebugColor{0}; - bool myDebugEnabled{0}; + bool myDebugEnabled{false}; bool myIsSuppressed{false}; @@ -205,7 +206,7 @@ void Player::tick() if (myRenderCounter > 0) ++mySampleCounter; - if (myRenderCounter >= 0 && myDividerChangeCounter >= 0 && myDividerChangeCounter-- == 0) + if (myRenderCounter >= 0 && myDividerChangeCounter >= 0 && myDividerChangeCounter-- == 0) // NOLINT (bugprone-inc-dec-in-conditions) setDivider(myDividerPending); break; @@ -214,7 +215,7 @@ void Player::tick() if (myRenderCounter > 1 && (((myRenderCounter - 1) % myDivider) == 0)) ++mySampleCounter; - if (myRenderCounter > 0 && myDividerChangeCounter >= 0 && myDividerChangeCounter-- == 0) + if (myRenderCounter > 0 && myDividerChangeCounter >= 0 && myDividerChangeCounter-- == 0) // NOLINT (bugprone-inc-dec-in-conditions) setDivider(myDividerPending); break; diff --git a/src/emucore/tia/Playfield.hxx b/src/emucore/tia/Playfield.hxx index 24e2ac47a..166374238 100644 --- a/src/emucore/tia/Playfield.hxx +++ b/src/emucore/tia/Playfield.hxx @@ -31,6 +31,7 @@ class Playfield : public Serializable The collision mask is injected at construction */ explicit Playfield(uInt32 collisionMask); + ~Playfield() override = default; public: @@ -118,7 +119,7 @@ class Playfield : public Serializable Is the playfield visible? This is determined by looking at bit 15 of the collision mask. */ - inline bool isOn() const { return (collision & 0x8000); } + bool isOn() const { return (collision & 0x8000); } /** Get the current color. @@ -275,7 +276,7 @@ void Playfield::tick(uInt32 x) if (x & 0x03) return; - uInt32 currentPixel; + uInt32 currentPixel; // NOLINT (cppcoreguidelines-init-variables) if (myEffectivePattern == 0) { currentPixel = 0; diff --git a/src/emucore/tia/TIA.cxx b/src/emucore/tia/TIA.cxx index b206a6510..a7bb57f5d 100644 --- a/src/emucore/tia/TIA.cxx +++ b/src/emucore/tia/TIA.cxx @@ -64,7 +64,7 @@ static constexpr uInt8 resxLateHblankThreshold = TIAConstants::H_CYCLES - 3; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TIA::TIA(ConsoleIO& console, const ConsoleTimingProvider& timingProvider, - Settings& settings, const onPhosphorCallback callback) + Settings& settings, const onPhosphorCallback& callback) : myConsole{console}, myTimingProvider{timingProvider}, mySettings{settings}, diff --git a/src/emucore/tia/TIA.hxx b/src/emucore/tia/TIA.hxx index 1db52d95c..bd7873b46 100644 --- a/src/emucore/tia/TIA.hxx +++ b/src/emucore/tia/TIA.hxx @@ -39,7 +39,6 @@ #include "Ball.hxx" #include "LatchedInput.hxx" #include "AnalogReadout.hxx" -#include "DelayQueueIterator.hxx" #include "Control.hxx" #include "System.hxx" @@ -75,7 +74,7 @@ class TIA : public Device /** * Possible palette entries for objects in "fixed debug color mode". */ - enum FixedColor { + enum FixedColor: uInt8 { NTSC_RED = 0x42, NTSC_ORANGE = 0x38, NTSC_YELLOW = 0x1c, @@ -118,7 +117,7 @@ class TIA : public Device @param settings The settings object for this TIA device */ TIA(ConsoleIO& console, const ConsoleTimingProvider& timingProvider, - Settings& settings, const onPhosphorCallback callback); + Settings& settings, const onPhosphorCallback& callback); ~TIA() override = default; public: @@ -224,7 +223,7 @@ class TIA : public Device /** Did we generate a new frame? */ - bool newFramePending() { return myFramesSinceLastRender > 0; } + bool newFramePending() const { return myFramesSinceLastRender > 0; } /** * Clear any pending frames. @@ -234,7 +233,7 @@ class TIA : public Device /** The number of frames since we did last render to the front buffer. */ - uInt32 framesSinceLastRender() { return myFramesSinceLastRender; } + uInt32 framesSinceLastRender() const { return myFramesSinceLastRender; } /** Render the pending frame to the framebuffer and clear the flag. @@ -257,7 +256,7 @@ class TIA : public Device /** Answers dimensional info about the framebuffer. */ - uInt32 width() const { return TIAConstants::H_PIXEL; } + uInt32 width() const { return TIAConstants::H_PIXEL; } // NOLINT uInt32 height() const { return myFrameManager->height(); } Int32 vcenter() const { return myFrameManager->vcenter(); } Int32 minVcenter() const { return myFrameManager->minVcenter(); } @@ -362,7 +361,7 @@ class TIA : public Device Answers the system cycles used by WSYNC from the start of the current frame. */ uInt32 frameWSyncCycles() const { - return uInt32(myFrameWsyncCycles); + return static_cast(myFrameWsyncCycles); } #endif // DEBUGGER_SUPPORT @@ -599,18 +598,18 @@ class TIA : public Device /** * During each line, the TIA cycles through these two states. */ - enum class HState {blank, frame}; + enum class HState: uInt8 {blank, frame}; /** * The three different modes of the priority encoder. Check TIA::renderPixel * for a precise definition. */ - enum class Priority {pfp, score, normal}; + enum class Priority: uInt8 {pfp, score, normal}; /** * Palette and indices for fixed debug colors. */ - enum FixedObject { P0, M0, P1, M1, PF, BL, BK }; + enum FixedObject: uInt8 { P0, M0, P1, M1, PF, BL, BK }; BSPF::array2D myFixedColorPalette; std::array myFixedColorNames; @@ -841,12 +840,12 @@ class TIA : public Device LatchedInput myInput1; // Pointer to the internal color-index-based frame buffer - std::array myFramebuffer; + std::array(TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight)> myFramebuffer; // The frame is rendered to the backbuffer and only copied to the framebuffer // upon completion - std::array myBackBuffer; - std::array myFrontBuffer; + std::array(TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight)> myBackBuffer; + std::array(TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight)> myFrontBuffer; // We snapshot frame statistics when the back buffer is copied to the front buffer // and when the front buffer is copied to the frame buffer diff --git a/src/emucore/tia/TIAConstants.hxx b/src/emucore/tia/TIAConstants.hxx index cf8f0e674..19c2fafac 100644 --- a/src/emucore/tia/TIAConstants.hxx +++ b/src/emucore/tia/TIAConstants.hxx @@ -34,7 +34,7 @@ namespace TIAConstants { H_PIXEL = 160, H_CYCLES = 76, CYCLE_CLOCKS = 3, H_CLOCKS = H_CYCLES * CYCLE_CLOCKS, // = 228 H_BLANK_CLOCKS = H_CLOCKS - H_PIXEL; // = 68 -} +} // namespace TIAConstants enum TIABit: uInt8 { P0Bit = 0x01, // Bit for Player 0 @@ -48,7 +48,7 @@ enum TIABit: uInt8 { AllBits = 0xff }; -enum TIAColor { +enum TIAColor: uInt8 { BKColor = 0, // Color index for Background PFColor = 1, // Color index for Playfield P0Color = 2, // Color index for Player 0 @@ -59,7 +59,7 @@ enum TIAColor { HBLANKColor = 7 // Color index for HMove blank area }; -enum class CollisionBit +enum class CollisionBit: uInt16 { M0P1 = 1 << 0, // Missle0 - Player1 collision M0P0 = 1 << 1, // Missle0 - Player0 collision @@ -79,7 +79,7 @@ enum class CollisionBit }; // TIA Write/Read register names -enum TIARegister { +enum TIARegister: uInt8 { VSYNC = 0x00, // Write: vertical sync set-clear (D1) VBLANK = 0x01, // Write: vertical blank set-clear (D7-6,D1) WSYNC = 0x02, // Write: wait for leading edge of hrz. blank (strobe) diff --git a/src/emucore/tia/frame-manager/AbstractFrameManager.hxx b/src/emucore/tia/frame-manager/AbstractFrameManager.hxx index 887c47d96..87a636146 100644 --- a/src/emucore/tia/frame-manager/AbstractFrameManager.hxx +++ b/src/emucore/tia/frame-manager/AbstractFrameManager.hxx @@ -33,6 +33,7 @@ class AbstractFrameManager : public Serializable public: AbstractFrameManager(); + ~AbstractFrameManager() override = default; public: @@ -78,7 +79,7 @@ class AbstractFrameManager : public Serializable * Should the TIA render its frame? This is buffered in a flag for * performance reasons; descendants must update the flag. */ - inline bool isRendering() const { return myIsRendering; } + bool isRendering() const { return myIsRendering; } /** * Is vsync on? @@ -88,7 +89,7 @@ class AbstractFrameManager : public Serializable /** * Is vblank on? */ - inline bool vblank() const { return myVblank; } + bool vblank() const { return myVblank; } /** * The number of scanlines in the last finished frame. diff --git a/src/emucore/tia/frame-manager/FrameLayoutDetector.hxx b/src/emucore/tia/frame-manager/FrameLayoutDetector.hxx index 89bfc7290..012203c20 100644 --- a/src/emucore/tia/frame-manager/FrameLayoutDetector.hxx +++ b/src/emucore/tia/frame-manager/FrameLayoutDetector.hxx @@ -34,6 +34,7 @@ class FrameLayoutDetector: public AbstractFrameManager public: FrameLayoutDetector(); + ~FrameLayoutDetector() override = default; public: @@ -75,7 +76,7 @@ class FrameLayoutDetector: public AbstractFrameManager /** * This frame manager only tracks frame boundaries, so we have only two states. */ - enum class State { + enum class State: uInt8 { // Wait for VSYNC to be enabled. waitForVsyncStart, @@ -86,7 +87,7 @@ class FrameLayoutDetector: public AbstractFrameManager /** * Misc. numeric constants used in the algorithm. */ - enum Metrics: uInt32 { + enum Metrics: uInt32 { // NOLINT: use 32-bit, even though 16-bit is sufficient // ideal frame heights frameLinesNTSC = 262, frameLinesPAL = 312, @@ -132,7 +133,7 @@ class FrameLayoutDetector: public AbstractFrameManager */ static constexpr int NUM_HUES = 16; static constexpr int NUM_LUMS = 8; - std::array myColorCount{0}; + std::array(NUM_HUES * NUM_LUMS)> myColorCount{0}; private: FrameLayoutDetector(const FrameLayoutDetector&) = delete; diff --git a/src/emucore/tia/frame-manager/FrameManager.hxx b/src/emucore/tia/frame-manager/FrameManager.hxx index a29f70e62..092c68ca8 100644 --- a/src/emucore/tia/frame-manager/FrameManager.hxx +++ b/src/emucore/tia/frame-manager/FrameManager.hxx @@ -26,7 +26,7 @@ class FrameManager: public AbstractFrameManager { public: - enum Metrics : uInt32 { + enum Metrics : uInt32 { // NOLINT: use 32-bit, even though 16-bit is sufficient vblankNTSC = 37, vblankPAL = 45, vsync = 3, @@ -34,7 +34,7 @@ class FrameManager: public AbstractFrameManager { frameSizePAL = 312, baseHeightNTSC = 228, // 217..239 baseHeightPAL = 274, // 260..288 - maxHeight = static_cast(baseHeightPAL * 1.05 + 0.5), // 288 + maxHeight = static_cast(baseHeightPAL * 1.05 + 0.5), // 288 FIXME maxLinesVsync = 50, initialGarbageFrames = TIAConstants::initialGarbageFrames, ystartNTSC = 23, @@ -45,6 +45,7 @@ class FrameManager: public AbstractFrameManager { public: FrameManager(); + ~FrameManager() override = default; public: void setJitterSensitivity(uInt8 sensitivity) override { myJitterEmulation.setSensitivity(sensitivity); } @@ -95,7 +96,7 @@ class FrameManager: public AbstractFrameManager { private: - enum class State { + enum class State: uInt8 { waitForVsyncStart, waitForVsyncEnd, waitForFrameStart, diff --git a/src/emucore/tia/frame-manager/JitterEmulation.hxx b/src/emucore/tia/frame-manager/JitterEmulation.hxx index a85e9b478..89d13131c 100644 --- a/src/emucore/tia/frame-manager/JitterEmulation.hxx +++ b/src/emucore/tia/frame-manager/JitterEmulation.hxx @@ -28,6 +28,7 @@ class JitterEmulation : public Serializable { public: JitterEmulation(); + ~JitterEmulation() override = default; public: // sensitivity: diff --git a/src/gui/BrowserDialog.hxx b/src/gui/BrowserDialog.hxx index 881020f3e..e9e4c025d 100644 --- a/src/gui/BrowserDialog.hxx +++ b/src/gui/BrowserDialog.hxx @@ -33,7 +33,7 @@ class StaticTextWidget; class BrowserDialog : public Dialog { public: - enum class Mode { + enum class Mode: uInt8 { FileLoad, // File selector, no input from user FileLoadNoDirs, // File selector, no input from user, fixed directory FileSave, // File selector, filename changable by user diff --git a/src/gui/DeveloperDialog.cxx b/src/gui/DeveloperDialog.cxx index 3e5a57873..3b5503709 100644 --- a/src/gui/DeveloperDialog.cxx +++ b/src/gui/DeveloperDialog.cxx @@ -1231,8 +1231,8 @@ void DeveloperDialog::handleSize() { for(i = horizon; i < NUM_HORIZONS; ++i) { - if(static_cast(size) * instance().state().rewindManager().INTERVAL_CYCLES[interval] - <= instance().state().rewindManager().HORIZON_CYCLES[i]) + if(static_cast(size) * RewindManager::INTERVAL_CYCLES[interval] + <= RewindManager::HORIZON_CYCLES[i]) { found = true; break; @@ -1281,8 +1281,8 @@ void DeveloperDialog::handleInterval() { for(i = horizon; i < NUM_HORIZONS; ++i) { - if(static_cast(size) * instance().state().rewindManager().INTERVAL_CYCLES[interval] - <= instance().state().rewindManager().HORIZON_CYCLES[i]) + if(static_cast(size) * RewindManager::INTERVAL_CYCLES[interval] + <= RewindManager::HORIZON_CYCLES[i]) { found = true; break; @@ -1319,8 +1319,8 @@ void DeveloperDialog::handleHorizon() { for(i = interval; i >= 0; --i) { - if(static_cast(size) * instance().state().rewindManager().INTERVAL_CYCLES[i] - <= instance().state().rewindManager().HORIZON_CYCLES[horizon]) + if(static_cast(size) * RewindManager::INTERVAL_CYCLES[i] + <= RewindManager::HORIZON_CYCLES[horizon]) { found = true; break; diff --git a/src/gui/DeveloperDialog.hxx b/src/gui/DeveloperDialog.hxx index 8b57c6873..0d817143d 100644 --- a/src/gui/DeveloperDialog.hxx +++ b/src/gui/DeveloperDialog.hxx @@ -31,7 +31,7 @@ class ColorWidget; namespace GUI { class Font; -} +} // namespace GUI #include "bspf.hxx" #include "Dialog.hxx" diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index dffa313f8..0d8ef33e8 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -45,7 +45,7 @@ class Dialog : public GuiObject public: // Current Stella mode - enum class AppMode { launcher, emulator, debugger }; + enum class AppMode: uInt8 { launcher, emulator, debugger }; using RenderCallback = std::function; diff --git a/src/gui/EventMappingWidget.hxx b/src/gui/EventMappingWidget.hxx index 4a1c960d6..104bb0e20 100644 --- a/src/gui/EventMappingWidget.hxx +++ b/src/gui/EventMappingWidget.hxx @@ -42,7 +42,7 @@ class EventMappingWidget : public Widget, public CommandSender int x, int y, int w, int h); ~EventMappingWidget() override = default; - bool remapMode() { return myRemapStatus; } + bool remapMode() const { return myRemapStatus; } void setDefaults(); @@ -74,7 +74,7 @@ class EventMappingWidget : public Widget, public CommandSender void resetRemapping(); void stopRemapping(); - bool isRemapping() { return myRemapStatus; } + bool isRemapping() const { return myRemapStatus; } void drawKeyMapping(); void enableButtons(bool state); diff --git a/src/gui/FavoritesManager.hxx b/src/gui/FavoritesManager.hxx index 3f1ddbe61..747840d38 100644 --- a/src/gui/FavoritesManager.hxx +++ b/src/gui/FavoritesManager.hxx @@ -40,6 +40,7 @@ class FavoritesManager using PopularList = std::vector; explicit FavoritesManager(Settings& settings); + ~FavoritesManager() = default; void load(); void save(); diff --git a/src/gui/FileListWidget.hxx b/src/gui/FileListWidget.hxx index 210199122..2bc173afc 100644 --- a/src/gui/FileListWidget.hxx +++ b/src/gui/FileListWidget.hxx @@ -102,7 +102,7 @@ class FileListWidget : public StringListWidget const FSNode& currentDir() const { return _node; } static void setQuickSelectDelay(uInt64 time) { _QUICK_SELECT_DELAY = time; } - uInt64 getQuickSelectDelay() const { return _QUICK_SELECT_DELAY; } + static uInt64 getQuickSelectDelay() { return _QUICK_SELECT_DELAY; } ProgressDialog& progress(); void incProgress(); @@ -116,7 +116,7 @@ class FileListWidget : public StringListWidget explicit HistoryType(const FSNode& _hnode, string_view _hselected) : node{_hnode}, selected{_hselected} {} }; - enum class IconType { + enum class IconType: uInt8 { unknown, rom, directory, diff --git a/src/gui/Font.hxx b/src/gui/Font.hxx index ee19731d1..51a3f24ff 100644 --- a/src/gui/Font.hxx +++ b/src/gui/Font.hxx @@ -47,7 +47,7 @@ struct FontDesc const uInt8* width; /* character widths or nullptr if fixed */ const BBX* bbx; /* character bounding box or nullptr if fixed */ int defaultchar; /* default char (not glyph index) */ - long bits_size; /* # words of bitmap_t bits */ + Int64 bits_size; /* # words of bitmap_t bits */ }; namespace GUI { @@ -56,6 +56,7 @@ class Font { public: explicit Font(const FontDesc& desc); + ~Font() = default; const FontDesc& desc() const { return myFontDesc; } diff --git a/src/gui/GameInfoDialog.hxx b/src/gui/GameInfoDialog.hxx index 5a9b8d718..6247df9f1 100644 --- a/src/gui/GameInfoDialog.hxx +++ b/src/gui/GameInfoDialog.hxx @@ -199,7 +199,7 @@ class GameInfoDialog : public Dialog, public CommandSender kBezelFilePressed = 'BFpr' }; - enum { kLinkId }; + enum: uInt8 { kLinkId }; // Game properties for currently loaded ROM Properties myGameProperties; diff --git a/src/gui/GlobalPropsDialog.hxx b/src/gui/GlobalPropsDialog.hxx index 68a113f80..db350d33f 100644 --- a/src/gui/GlobalPropsDialog.hxx +++ b/src/gui/GlobalPropsDialog.hxx @@ -43,7 +43,7 @@ class GlobalPropsDialog : public Dialog, public CommandSender void handleCommand(CommandSender* sender, int cmd, int data, int id) override; private: - enum { + enum: uInt8 { kJ0Up, kJ0Down, kJ0Left, kJ0Right, kJ0Fire, kJ1Up, kJ1Down, kJ1Left, kJ1Right, kJ1Fire }; diff --git a/src/gui/GuiObject.hxx b/src/gui/GuiObject.hxx index 2066e6b59..03a14f299 100644 --- a/src/gui/GuiObject.hxx +++ b/src/gui/GuiObject.hxx @@ -42,7 +42,7 @@ class GuiObject : public CommandReceiver friend class DialogContainer; public: - enum : uInt32 { + enum : uInt32 { // NOLINT: use 32-bit, even though 16-bit is sufficient FLAG_ENABLED = 1 << 0, FLAG_INVISIBLE = 1 << 1, FLAG_HILITED = 1 << 2, @@ -58,7 +58,7 @@ class GuiObject : public CommandReceiver public: // The commands generated by various widgets - enum { + enum: uInt32 { // NOLINT: use 32-bit, even though 16-bit is sufficient kOKCmd = 'OK ', kCloseCmd = 'CLOS', kNextCmd = 'NEXT', diff --git a/src/gui/HighScoresDialog.hxx b/src/gui/HighScoresDialog.hxx index af10f8588..d3c72f8ca 100644 --- a/src/gui/HighScoresDialog.hxx +++ b/src/gui/HighScoresDialog.hxx @@ -25,7 +25,7 @@ class EditTextWidget; class PopUpWidget; namespace GUI { class MessageBox; -} +} // namespace GUI class Serializer; #include "OptionsMenu.hxx" diff --git a/src/gui/Icon.hxx b/src/gui/Icon.hxx index 9756c5f54..21c0c7857 100644 --- a/src/gui/Icon.hxx +++ b/src/gui/Icon.hxx @@ -38,6 +38,7 @@ class Icon : myIconDesc{desc}, myBitmap{bitmap} { } Icon(int width, int height, const uIntArray& bitmap) : Icon(IconDesc(width, height), bitmap) { } + ~Icon() = default; const IconDesc& desc() const { return myIconDesc; } int height() const { return myIconDesc.height; } diff --git a/src/gui/InputDialog.hxx b/src/gui/InputDialog.hxx index fecc6b478..32916cf92 100644 --- a/src/gui/InputDialog.hxx +++ b/src/gui/InputDialog.hxx @@ -29,7 +29,7 @@ class SliderWidget; class StaticTextWidget; namespace GUI { class MessageBox; -} +} // namespace GUI #include "Dialog.hxx" #include "bspf.hxx" diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index ce49533b2..72f619982 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -1045,7 +1045,8 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd, if(subDirs && cmd == EditableWidget::kChangedCmd) { // delay (potentially slow) subdirectories reloads until user stops typing - myReloadTime = TimerManager::getTicks() / 1000 + myList->getQuickSelectDelay(); + myReloadTime = TimerManager::getTicks() / 1000 + + LauncherFileListWidget::getQuickSelectDelay(); myPendingReload = true; } else @@ -1173,11 +1174,11 @@ void LauncherDialog::openContextMenu(int x, int y) { if(!currentNode().isDirectory()) { - if(myList->isUserDir(currentNode().getName())) + if(LauncherFileListWidget::isUserDir(currentNode().getName())) items.emplace_back("Remove all from favorites", "removefavorites"); - if(myList->isPopularDir(currentNode().getName())) + if(LauncherFileListWidget::isPopularDir(currentNode().getName())) items.emplace_back("Remove all from most popular", "removepopular"); - if(myList->isRecentDir(currentNode().getName())) + if(LauncherFileListWidget::isRecentDir(currentNode().getName())) items.emplace_back("Remove all from recently played", "removerecent"); if(myList->inRecentDir()) items.emplace_back("Remove from recently played", "Ctrl+X", "remove"); diff --git a/src/gui/LauncherDialog.hxx b/src/gui/LauncherDialog.hxx index 608ef2d91..1e7b3bd03 100644 --- a/src/gui/LauncherDialog.hxx +++ b/src/gui/LauncherDialog.hxx @@ -33,10 +33,10 @@ class StaticTextWidget; namespace Common { struct Size; -} +} // namespace Common namespace GUI { class MessageBox; -} +} // namespace GUI #include #include diff --git a/src/gui/LauncherFileListWidget.hxx b/src/gui/LauncherFileListWidget.hxx index ab23525e1..0b71165eb 100644 --- a/src/gui/LauncherFileListWidget.hxx +++ b/src/gui/LauncherFileListWidget.hxx @@ -55,9 +55,9 @@ class LauncherFileListWidget : public FileListWidget bool inUserDir() const { return myVirtualDir == user_name; } bool inRecentDir() const { return myVirtualDir == recent_name; } bool inPopularDir() const { return myVirtualDir == popular_name; } - bool isUserDir(string_view name) const { return name == user_name; } - bool isRecentDir(string_view name) const { return name == recent_name; } - bool isPopularDir(string_view name) const { return name == popular_name; } + static bool isUserDir(string_view name) { return name == user_name; } + static bool isRecentDir(string_view name) { return name == recent_name; } + static bool isPopularDir(string_view name) { return name == popular_name; } private: static const string user_name; diff --git a/src/gui/ListWidget.hxx b/src/gui/ListWidget.hxx index c974b4bff..643322198 100644 --- a/src/gui/ListWidget.hxx +++ b/src/gui/ListWidget.hxx @@ -76,8 +76,8 @@ class ListWidget : public EditableWidget bool handleEvent(Event::Type e) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override; - virtual void drawWidget(bool hilite) override = 0; - virtual Common::Rect getEditRect() const override = 0; + void drawWidget(bool hilite) override = 0; + Common::Rect getEditRect() const override = 0; int findItem(int x, int y) const; void recalc(); diff --git a/src/gui/MessageDialog.hxx b/src/gui/MessageDialog.hxx index e064bb4e0..3cbb3d5fd 100644 --- a/src/gui/MessageDialog.hxx +++ b/src/gui/MessageDialog.hxx @@ -36,7 +36,7 @@ class MessageDialog : public Dialog bool yesNo = false); static void setMessage(string_view title, const StringList& text, bool yesNo = false); - bool confirmed() { return myConfirmed; } + static bool confirmed() { return myConfirmed; } protected: void loadConfig() override; diff --git a/src/gui/MessageMenu.cxx b/src/gui/MessageMenu.cxx index 93f410200..8df470e8c 100644 --- a/src/gui/MessageMenu.cxx +++ b/src/gui/MessageMenu.cxx @@ -60,7 +60,7 @@ void MessageMenu::setMessage(string_view title, string_view text, bool yesNo) bool MessageMenu::confirmed() { if (myMessageDialog != nullptr) - return myMessageDialog->confirmed(); + return MessageDialog::confirmed(); return false; } diff --git a/src/gui/NavigationWidget.hxx b/src/gui/NavigationWidget.hxx index 650281c98..c78b70d2b 100644 --- a/src/gui/NavigationWidget.hxx +++ b/src/gui/NavigationWidget.hxx @@ -22,7 +22,7 @@ class EditTextWidget; class FileListWidget; namespace GUI { class Font; -} +} // namespace GUI #include "Widget.hxx" diff --git a/src/gui/RadioButtonWidget.hxx b/src/gui/RadioButtonWidget.hxx index d19365a99..b1387f589 100644 --- a/src/gui/RadioButtonWidget.hxx +++ b/src/gui/RadioButtonWidget.hxx @@ -33,6 +33,7 @@ class RadioButtonWidget : public CheckboxWidget RadioButtonWidget(GuiObject* boss, const GUI::Font& font, int x, int y, const string& label, RadioButtonGroup* group, int cmd = 0); + ~RadioButtonWidget() override = default; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override; void setState(bool state, bool send = true) override; @@ -62,13 +63,14 @@ class RadioButtonGroup { public: RadioButtonGroup() = default; + ~RadioButtonGroup() = default; // add widget to group void addWidget(RadioButtonWidget* widget); // tell the group which widget was selected void select(const RadioButtonWidget* widget); void setSelected(uInt32 selected); - uInt32 getSelected() { return mySelected; } + uInt32 getSelected() const { return mySelected; } private: WidgetArray myWidgets; diff --git a/src/gui/RomAuditDialog.cxx b/src/gui/RomAuditDialog.cxx index f6048a404..6862a83bc 100644 --- a/src/gui/RomAuditDialog.cxx +++ b/src/gui/RomAuditDialog.cxx @@ -111,20 +111,24 @@ void RomAuditDialog::auditRoms() myResults2->setText(""); const FSNode node(auditPath); - FSList files; + FSList files; // NOLINT (files is not a const) files.reserve(2048); node.getChildren(files, FSNode::ListMode::FilesOnly); // Create a progress dialog box to show the progress of processing // the ROMs, since this is usually a time-consuming operation + // NOLINTBEGIN (the following are not a const) ostringstream buf; ProgressDialog progress(this, instance().frameBuffer().font()); + // NOLINTEND buf << "Auditing ROM files" << ELLIPSIS; progress.setMessage(buf.view()); progress.setRange(0, static_cast(files.size()) - 1, 5); progress.open(); + // NOLINTBEGIN: several variables are tagged as const by clang-tidy, + // but they obviously cannot be; suspect a bug in the tool Properties props; uInt32 renamed = 0, notfound = 0; for(uInt32 idx = 0; idx < files.size() && !progress.isCancelled(); ++idx) @@ -160,6 +164,8 @@ void RomAuditDialog::auditRoms() // Update the progress bar, indicating one more ROM has been processed progress.incProgress(); } + // NOLINTEND + progress.close(); myResults1->setText(std::to_string(renamed)); @@ -175,7 +181,7 @@ void RomAuditDialog::handleCommand(CommandSender* sender, int cmd, case GuiObject::kOKCmd: if(!myConfirmMsg) { - StringList msg; + StringList msg; // NOLINT (msg is not a const) msg.emplace_back("This operation cannot be undone. Your ROMs"); msg.emplace_back("will be modified, and as such there is a chance"); msg.emplace_back("that files may be lost. You are recommended"); diff --git a/src/gui/RomAuditDialog.hxx b/src/gui/RomAuditDialog.hxx index d0dd4dee7..07e63d3e7 100644 --- a/src/gui/RomAuditDialog.hxx +++ b/src/gui/RomAuditDialog.hxx @@ -25,7 +25,7 @@ class EditTextWidget; class StaticTextWidget; namespace GUI { class MessageBox; -} +} // namespace GUI #include "Dialog.hxx" #include "Command.hxx" diff --git a/src/gui/RomImageWidget.hxx b/src/gui/RomImageWidget.hxx index e97b889f1..baf478fae 100644 --- a/src/gui/RomImageWidget.hxx +++ b/src/gui/RomImageWidget.hxx @@ -44,7 +44,7 @@ class RomImageWidget : public Widget void toggleImageZoom(); void disableImageZoom() { myZoomMode = false; } - uInt64 pendingLoadTime() { return myMaxLoadTime * timeFactor; } + uInt64 pendingLoadTime() const { return myMaxLoadTime * timeFactor; } protected: #ifdef IMAGE_SUPPORT @@ -75,7 +75,7 @@ class RomImageWidget : public Widget private: // Navigation areas - enum class Area { + enum class Area: uInt8 { NONE, LEFT, RIGHT, diff --git a/src/gui/ScrollBarWidget.hxx b/src/gui/ScrollBarWidget.hxx index 715be125b..6d8becff3 100644 --- a/src/gui/ScrollBarWidget.hxx +++ b/src/gui/ScrollBarWidget.hxx @@ -59,7 +59,7 @@ class ScrollBarWidget : public Widget, public CommandSender int _wheel_lines{0}; private: - enum class Part { None, UpArrow, DownArrow, Slider, PageUp, PageDown }; + enum class Part: uInt8 { None, UpArrow, DownArrow, Slider, PageUp, PageDown }; Part _part{Part::None}; Part _draggingPart{Part::None}; diff --git a/src/gui/StellaSettingsDialog.hxx b/src/gui/StellaSettingsDialog.hxx index e6581f96f..93d731c9c 100644 --- a/src/gui/StellaSettingsDialog.hxx +++ b/src/gui/StellaSettingsDialog.hxx @@ -33,7 +33,7 @@ class PopUpWidget; namespace GUI { class Font; class MessageBox; -} +} // namespace GUI class StellaSettingsDialog : public Dialog { diff --git a/src/gui/TabWidget.hxx b/src/gui/TabWidget.hxx index d6c0b9546..e57560e9b 100644 --- a/src/gui/TabWidget.hxx +++ b/src/gui/TabWidget.hxx @@ -56,9 +56,9 @@ class TabWidget : public Widget, public CommandSender void setParentWidget(int tabID, Widget* parent); Widget* parentWidget(int tabID); - int getTabWidth() { return _tabWidth; } - int getTabHeight() { return _tabHeight; } - int getActiveTab() { return _activeTab; } + int getTabWidth() const { return _tabWidth; } + int getTabHeight() const { return _tabHeight; } + int getActiveTab() const { return _activeTab; } void loadConfig() override; @@ -95,7 +95,7 @@ class TabWidget : public Widget, public CommandSender int _activeTab{-1}; bool _firstTime{true}; - enum { + enum: uInt8 { kTabLeftOffset = 0, kTabSpacing = 1, kTabPadding = 4 diff --git a/src/gui/TimeLineWidget.hxx b/src/gui/TimeLineWidget.hxx index 0d821422b..fa3db5faa 100644 --- a/src/gui/TimeLineWidget.hxx +++ b/src/gui/TimeLineWidget.hxx @@ -26,6 +26,7 @@ class TimeLineWidget : public ButtonWidget TimeLineWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int w, int h, string_view label = "", uInt32 labelWidth = 0, int cmd = 0); + ~TimeLineWidget() override = default; void setValue(int value) override; uInt32 getValue() const { return _value; } diff --git a/src/gui/UndoHandler.hxx b/src/gui/UndoHandler.hxx index bd8a74176..3cfb9931b 100644 --- a/src/gui/UndoHandler.hxx +++ b/src/gui/UndoHandler.hxx @@ -29,7 +29,7 @@ class UndoHandler { public: - UndoHandler(size_t size = 100); + explicit UndoHandler(size_t size = 100); ~UndoHandler() = default; // Reset undo buffer diff --git a/src/gui/VideoAudioDialog.cxx b/src/gui/VideoAudioDialog.cxx index 000c307b2..32dc0dede 100644 --- a/src/gui/VideoAudioDialog.cxx +++ b/src/gui/VideoAudioDialog.cxx @@ -1382,14 +1382,14 @@ void VideoAudioDialog::handleCommand(CommandSender* sender, int cmd, case kHeadroomChanged: { - std::ostringstream ss; + std::ostringstream ss; // NOLINT (ss is not a const) ss << std::fixed << std::setprecision(1) << (0.5 * myHeadroomSlider->getValue()) << " frames"; myHeadroomSlider->setValueLabel(ss.view()); break; } case kBufferSizeChanged: { - std::ostringstream ss; + std::ostringstream ss; // NOLINT (ss is not a const) ss << std::fixed << std::setprecision(1) << (0.5 * myBufferSizeSlider->getValue()) << " frames"; myBufferSizeSlider->setValueLabel(ss.view()); break; diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 2c885b8f3..74657f69d 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -324,7 +324,7 @@ class CheckboxWidget : public ButtonWidget { public: enum { kCheckActionCmd = 'CBAC' }; - enum class FillType { Normal, Inactive, Circle }; + enum class FillType: uInt8 { Normal, Inactive, Circle }; public: CheckboxWidget(GuiObject* boss, const GUI::Font& font, int x, int y, diff --git a/src/lib/nanojpeg/nanojpeg_lib.hxx b/src/lib/nanojpeg/nanojpeg_lib.hxx index f13523f57..093436737 100644 --- a/src/lib/nanojpeg/nanojpeg_lib.hxx +++ b/src/lib/nanojpeg/nanojpeg_lib.hxx @@ -25,7 +25,7 @@ #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Weverything" - #include "nanojpeg.c" + #include "nanojpeg.c" // NOLINT (bugprone-suspicious-include) #pragma clang diagnostic pop #elif defined(__GNUC__) || defined(__GNUG__) #pragma GCC diagnostic push diff --git a/src/os/macos/SerialPortMACOS.cxx b/src/os/macos/SerialPortMACOS.cxx index 2988df189..d9f609255 100644 --- a/src/os/macos/SerialPortMACOS.cxx +++ b/src/os/macos/SerialPortMACOS.cxx @@ -15,7 +15,7 @@ // this file, and for a DISCLAIMER OF ALL WARRANTIES. //============================================================================ -#include +#include #include #include #include @@ -28,12 +28,6 @@ #include "FSNode.hxx" #include "SerialPortMACOS.hxx" -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -SerialPortMACOS::SerialPortMACOS() - : SerialPort() -{ -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SerialPortMACOS::~SerialPortMACOS() { diff --git a/src/os/macos/SerialPortMACOS.hxx b/src/os/macos/SerialPortMACOS.hxx index a55f6d9c6..1c6b4c9df 100644 --- a/src/os/macos/SerialPortMACOS.hxx +++ b/src/os/macos/SerialPortMACOS.hxx @@ -28,7 +28,7 @@ class SerialPortMACOS : public SerialPort { public: - SerialPortMACOS(); + SerialPortMACOS() = default; ~SerialPortMACOS() override; /** diff --git a/src/os/unix/SerialPortUNIX.cxx b/src/os/unix/SerialPortUNIX.cxx index 2295b5d93..dabf454f3 100644 --- a/src/os/unix/SerialPortUNIX.cxx +++ b/src/os/unix/SerialPortUNIX.cxx @@ -91,7 +91,7 @@ bool SerialPortUNIX::isCTS() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - StringList SerialPortUNIX::portNames() { - StringList ports; + StringList ports; // NOLINT: cannot be const, but clang-tidy suggests it // Check if port is valid; for now that means if it can be opened // Eventually we may extend this to do more intensive checks @@ -106,7 +106,7 @@ StringList SerialPortUNIX::portNames() return BSPF::startsWithIgnoreCase(node.getPath(), "/dev/ttyACM") || BSPF::startsWithIgnoreCase(node.getPath(), "/dev/ttyUSB"); }; - FSList portList; + FSList portList; // NOLINT: cannot be const, but clang-tidy suggests it portList.reserve(5); const FSNode dev("/dev/"); diff --git a/src/os/windows/OSystemWINDOWS.cxx b/src/os/windows/OSystemWINDOWS.cxx index 558c150da..abc34c832 100644 --- a/src/os/windows/OSystemWINDOWS.cxx +++ b/src/os/windows/OSystemWINDOWS.cxx @@ -25,8 +25,7 @@ void OSystemWINDOWS::getBaseDirectories(string& basedir, string& homedir, bool useappdir, string_view usedir) { - const HomeFinder homefinder; - const FSNode appdata(homefinder.getAppDataPath()); + const FSNode appdata(HomeFinder::getAppDataPath()); if(appdata.isDirectory()) { @@ -36,7 +35,7 @@ void OSystemWINDOWS::getBaseDirectories(string& basedir, string& homedir, basedir += "Stella\\"; } - const FSNode defaultHomeDir(homefinder.getDesktopPath()); + const FSNode defaultHomeDir(HomeFinder::getDesktopPath()); homedir = defaultHomeDir.getShortPath(); // Check to see if basedir overrides are active diff --git a/src/os/windows/SerialPortWINDOWS.cxx b/src/os/windows/SerialPortWINDOWS.cxx index c84fbe3c6..fdbbd4854 100644 --- a/src/os/windows/SerialPortWINDOWS.cxx +++ b/src/os/windows/SerialPortWINDOWS.cxx @@ -18,12 +18,6 @@ #include "Windows.hxx" #include "SerialPortWINDOWS.hxx" -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -SerialPortWINDOWS::SerialPortWINDOWS() - : SerialPort() -{ -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SerialPortWINDOWS::~SerialPortWINDOWS() { diff --git a/src/os/windows/SerialPortWINDOWS.hxx b/src/os/windows/SerialPortWINDOWS.hxx index d90a66ad5..0e961a5bb 100644 --- a/src/os/windows/SerialPortWINDOWS.hxx +++ b/src/os/windows/SerialPortWINDOWS.hxx @@ -27,7 +27,7 @@ class SerialPortWINDOWS : public SerialPort { public: - SerialPortWINDOWS(); + SerialPortWINDOWS() = default; ~SerialPortWINDOWS() override; /** diff --git a/src/tools/create_props.pl b/src/tools/create_props.pl index d43743c0d..4350dfbf0 100755 --- a/src/tools/create_props.pl +++ b/src/tools/create_props.pl @@ -66,6 +66,7 @@ print OUTFILE " located in the src/tools directory. All properties changes\n"; print OUTFILE " should be made in stella.pro, and then this file should be\n"; print OUTFILE " regenerated and the application recompiled.\n"; print OUTFILE "*/\n"; +print OUTFILE "\n// NOLINTBEGIN: static analyzer can't tell the following is data\n"; print OUTFILE "\nstatic constexpr uInt32 DEF_PROPS_SIZE = " . $setsize . ";"; print OUTFILE "\n\n"; print OUTFILE "/**\n"; @@ -93,7 +94,7 @@ for my $key ( sort keys %propset ) } print OUTFILE "}};\n"; -print OUTFILE "\n"; +print OUTFILE "\n// NOLINTEND\n\n"; print OUTFILE "#endif\n"; close(OUTFILE);