From c48f03b2a1ff656c011f08f76cdeef11ceb786bf Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Thu, 1 Aug 2024 12:20:40 -0230 Subject: [PATCH] More fixes for warnings from clang-tidy, in `src/cheat` and `src/common`. --- src/cheat/Cheat.hxx | 2 +- src/cheat/CheatManager.hxx | 1 + src/common/AudioQueue.hxx | 2 +- src/common/AudioSettings.hxx | 4 +- src/common/Base.cxx | 2 +- src/common/Base.hxx | 17 +++--- src/common/DevSettingsHandler.hxx | 4 +- src/common/FBBackendSDL2.hxx | 4 +- src/common/FBSurfaceSDL2.hxx | 8 +-- src/common/FSNodeFactory.hxx | 3 +- src/common/FSNodeZIP.hxx | 2 +- src/common/FpsMeter.hxx | 1 + src/common/JPGLibrary.hxx | 4 ++ src/common/JoyMap.cxx | 46 +++++++-------- src/common/JoyMap.hxx | 58 +++++++++---------- src/common/KeyMap.cxx | 27 ++++----- src/common/KeyMap.hxx | 38 ++++++------ src/common/LinkedObjectPool.hxx | 1 + src/common/Logger.hxx | 3 +- src/common/MediaFactory.hxx | 1 + src/common/MouseControl.hxx | 5 +- src/common/PKeyboardHandler.cxx | 22 ++++--- src/common/PKeyboardHandler.hxx | 21 +++---- src/common/PNGLibrary.cxx | 24 +++----- src/common/PNGLibrary.hxx | 22 +++---- src/common/PaletteHandler.hxx | 5 +- src/common/PhosphorHandler.hxx | 15 ++--- src/common/PhysicalJoystick.cxx | 2 +- src/common/PhysicalJoystick.hxx | 13 +++-- src/common/RewindManager.hxx | 8 ++- src/common/SDL_lib.hxx | 2 +- src/common/SoundSDL2.cxx | 7 +-- src/common/SoundSDL2.hxx | 10 +--- src/common/Stack.hxx | 1 + src/common/StateManager.hxx | 2 +- src/common/StellaKeys.hxx | 10 ++-- src/common/StringParser.hxx | 5 +- src/common/ThreadDebugging.hxx | 1 + src/common/TimerManager.hxx | 2 +- src/common/Variant.hxx | 4 +- src/common/VideoModeHandler.hxx | 3 +- src/common/ZipHandler.hxx | 5 +- src/common/audio/ConvolutionBuffer.hxx | 5 +- src/common/audio/SimpleResampler.hxx | 1 + src/common/bspf.hxx | 26 ++++----- .../repository/KeyValueRepositoryFile.hxx | 19 +++--- .../CompositeKeyValueRepositorySqlite.hxx | 2 + .../sqlite/KeyValueRepositorySqlite.hxx | 1 + .../repository/sqlite/SqliteDatabase.hxx | 2 +- src/common/repository/sqlite/SqliteError.hxx | 2 +- .../repository/sqlite/SqliteStatement.hxx | 2 +- src/common/sdl_blitter/BlitterFactory.hxx | 2 +- src/common/smartmod.hxx | 16 ++--- src/common/tv_filters/AtariNTSC.cxx | 17 +++--- src/common/tv_filters/AtariNTSC.hxx | 28 ++++----- src/common/tv_filters/NTSCFilter.hxx | 15 ++--- src/debugger/CartDebug.cxx | 2 +- src/debugger/gui/DataGridRamWidget.hxx | 2 +- src/debugger/gui/DataGridWidget.cxx | 2 +- src/debugger/gui/DataGridWidget.hxx | 2 +- src/debugger/gui/RomListWidget.cxx | 2 +- src/debugger/gui/RomListWidget.hxx | 2 +- src/debugger/gui/RomWidget.cxx | 2 +- src/emucore/EventHandlerConstants.hxx | 22 +++---- src/emucore/Sound.hxx | 4 +- 65 files changed, 306 insertions(+), 289 deletions(-) diff --git a/src/cheat/Cheat.hxx b/src/cheat/Cheat.hxx index 449699e31..197e9bb12 100644 --- a/src/cheat/Cheat.hxx +++ b/src/cheat/Cheat.hxx @@ -27,7 +27,7 @@ class Cheat public: Cheat(OSystem& osystem, string_view name, string_view code) : myOSystem{osystem}, - myName{name == "" ? code : name}, + myName{name.empty() ? code : name}, myCode{code} { } virtual ~Cheat() = default; diff --git a/src/cheat/CheatManager.hxx b/src/cheat/CheatManager.hxx index 5b2c8376e..bc8c1a2af 100644 --- a/src/cheat/CheatManager.hxx +++ b/src/cheat/CheatManager.hxx @@ -38,6 +38,7 @@ class CheatManager { public: explicit CheatManager(OSystem& osystem); + ~CheatManager() = default; /** Adds the specified cheat to an internal list. diff --git a/src/common/AudioQueue.hxx b/src/common/AudioQueue.hxx index cc7ba32a6..d8bd4bb8c 100644 --- a/src/common/AudioQueue.hxx +++ b/src/common/AudioQueue.hxx @@ -46,6 +46,7 @@ class AudioQueue @param isStereo Whether samples are stereo or mono. */ AudioQueue(uInt32 fragmentSize, uInt32 capacity, bool isStereo); + ~AudioQueue() = default; /** Capacity getter. @@ -133,7 +134,6 @@ class AudioQueue StaggeredLogger myOverflowLogger{"audio buffer overflow", Logger::Level::INFO}; private: - AudioQueue() = delete; AudioQueue(const AudioQueue&) = delete; AudioQueue(AudioQueue&&) = delete; diff --git a/src/common/AudioSettings.hxx b/src/common/AudioSettings.hxx index aa43c5938..26f517b65 100644 --- a/src/common/AudioSettings.hxx +++ b/src/common/AudioSettings.hxx @@ -26,7 +26,7 @@ class AudioSettings { public: - enum class Preset { + enum class Preset: uInt8 { custom = 1, lowQualityMediumLag = 2, highQualityMediumLag = 3, @@ -34,7 +34,7 @@ class AudioSettings ultraQualityMinimalLag = 5 }; - enum class ResamplingQuality { + enum class ResamplingQuality: uInt8 { nearestNeighbour = 1, lanczos_2 = 2, lanczos_3 = 3 diff --git a/src/common/Base.cxx b/src/common/Base.cxx index af7ce1918..eba918378 100644 --- a/src/common/Base.cxx +++ b/src/common/Base.cxx @@ -24,7 +24,7 @@ string Base::toString(int value, Common::Base::Fmt outputBase) { static char vToS_buf[32]; // NOLINT : One place where C-style is acceptable - if(outputBase == Base::Fmt::_DEFAULT) + if(outputBase == Base::Fmt::DEFAULT) outputBase = myDefaultBase; switch(outputBase) diff --git a/src/common/Base.hxx b/src/common/Base.hxx index e68b92118..9d3a7c10f 100644 --- a/src/common/Base.hxx +++ b/src/common/Base.hxx @@ -38,7 +38,7 @@ class Base // The base to use for conversion from integers to strings // Note that the actual number of places will be determined by // the magnitude of the value itself in the general case - enum class Fmt { + enum class Fmt: uInt8 { _16, // base 16: 2, 4, 8 bytes (depending on value) _16_1, // base 16: 1 byte wide _16_2, // base 16: 2 bytes wide @@ -56,7 +56,7 @@ class Base _2, // base 2: 8 or 16 bits (depending on value) _2_8, // base 2: 1 byte (8 bits) wide _2_16, // base 2: 2 bytes (16 bits) wide - _DEFAULT + DEFAULT }; public: @@ -72,31 +72,31 @@ class Base static bool hexUppercase() { return myHexflags & std::ios_base::uppercase; } /** Output HEX digits in 0.5/1/2/4 byte format */ - static inline std::ostream& HEX1(std::ostream& os) { + static std::ostream& HEX1(std::ostream& os) { os.flags(myHexflags); return os << std::setw(1); } - static inline std::ostream& HEX2(std::ostream& os) { + static std::ostream& HEX2(std::ostream& os) { os.flags(myHexflags); return os << std::setw(2) << std::setfill('0'); } - static inline std::ostream& HEX3(std::ostream& os) + static std::ostream& HEX3(std::ostream& os) { os.flags(myHexflags); return os << std::setw(3) << std::setfill('0'); } - static inline std::ostream& HEX4(std::ostream& os) { + static std::ostream& HEX4(std::ostream& os) { os.flags(myHexflags); return os << std::setw(4) << std::setfill('0'); } - static inline std::ostream& HEX8(std::ostream& os) { + static std::ostream& HEX8(std::ostream& os) { os.flags(myHexflags); return os << std::setw(8) << std::setfill('0'); } /** Convert integer to a string in the given base format */ static string toString(int value, - Common::Base::Fmt outputBase = Common::Base::Fmt::_DEFAULT); + Common::Base::Fmt outputBase = Common::Base::Fmt::DEFAULT); private: // Default format to use when none is specified @@ -108,6 +108,7 @@ class Base private: // Following constructors and assignment operators not supported Base() = delete; + ~Base() = delete; Base(const Base&) = delete; Base(Base&&) = delete; Base& operator=(const Base&) = delete; diff --git a/src/common/DevSettingsHandler.hxx b/src/common/DevSettingsHandler.hxx index 365d8c28d..73dbf930c 100644 --- a/src/common/DevSettingsHandler.hxx +++ b/src/common/DevSettingsHandler.hxx @@ -21,6 +21,7 @@ class OSystem; #include +#include "bspf.hxx" /** This class takes care of developer settings sets. @@ -30,13 +31,14 @@ class OSystem; class DevSettingsHandler { public: - enum SettingsSet { + enum SettingsSet: uInt8 { player, developer, numSets }; explicit DevSettingsHandler(OSystem& osystem); + ~DevSettingsHandler() = default; void loadSettings(SettingsSet set); void saveSettings(SettingsSet set); diff --git a/src/common/FBBackendSDL2.hxx b/src/common/FBBackendSDL2.hxx index 310f5a9a3..1bc737cdc 100644 --- a/src/common/FBBackendSDL2.hxx +++ b/src/common/FBBackendSDL2.hxx @@ -120,7 +120,7 @@ class FBBackendSDL2 : public FBBackend @param g The green component of the color. @param b The blue component of the color. */ - inline uInt32 mapRGB(uInt8 r, uInt8 g, uInt8 b) const override + uInt32 mapRGB(uInt8 r, uInt8 g, uInt8 b) const override { return SDL_MapRGB(myPixelFormat, r, g, b); } /** @@ -131,7 +131,7 @@ class FBBackendSDL2 : public FBBackend @param b The blue component of the color. @param a The alpha component of the color. */ - inline uInt32 mapRGBA(uInt8 r, uInt8 g, uInt8 b, uInt8 a) const override + uInt32 mapRGBA(uInt8 r, uInt8 g, uInt8 b, uInt8 a) const override { return SDL_MapRGBA(myPixelFormat, r, g, b, a); } /** diff --git a/src/common/FBSurfaceSDL2.hxx b/src/common/FBSurfaceSDL2.hxx index 3f0174267..159f92a90 100644 --- a/src/common/FBSurfaceSDL2.hxx +++ b/src/common/FBSurfaceSDL2.hxx @@ -69,7 +69,7 @@ class FBSurfaceSDL2 : public FBSurface void applyAttributes() override; private: - inline bool setSrcPosInternal(uInt32 x, uInt32 y) { + bool setSrcPosInternal(uInt32 x, uInt32 y) { if(x != static_cast(mySrcR.x) || y != static_cast(mySrcR.y)) { mySrcR.x = x; mySrcR.y = y; @@ -78,7 +78,7 @@ class FBSurfaceSDL2 : public FBSurface } return false; } - inline bool setSrcSizeInternal(uInt32 w, uInt32 h) { + bool setSrcSizeInternal(uInt32 w, uInt32 h) { if(w != static_cast(mySrcR.w) || h != static_cast(mySrcR.h)) { mySrcR.w = w; mySrcR.h = h; @@ -87,7 +87,7 @@ class FBSurfaceSDL2 : public FBSurface } return false; } - inline bool setDstPosInternal(uInt32 x, uInt32 y) { + bool setDstPosInternal(uInt32 x, uInt32 y) { if(x != static_cast(myDstR.x) || y != static_cast(myDstR.y)) { myDstR.x = x; myDstR.y = y; @@ -96,7 +96,7 @@ class FBSurfaceSDL2 : public FBSurface } return false; } - inline bool setDstSizeInternal(uInt32 w, uInt32 h) { + bool setDstSizeInternal(uInt32 w, uInt32 h) { if(w != static_cast(myDstR.w) || h != static_cast(myDstR.h)) { myDstR.w = w; myDstR.h = h; diff --git a/src/common/FSNodeFactory.hxx b/src/common/FSNodeFactory.hxx index 00705f8cb..bc9361cb9 100644 --- a/src/common/FSNodeFactory.hxx +++ b/src/common/FSNodeFactory.hxx @@ -41,7 +41,7 @@ class AbstractFSNode; class FSNodeFactory { public: - enum class Type { SYSTEM, ZIP }; + enum class Type: uInt8 { SYSTEM, ZIP }; public: static unique_ptr create(string_view path, Type type) @@ -71,6 +71,7 @@ class FSNodeFactory private: // Following constructors and assignment operators not supported FSNodeFactory() = delete; + ~FSNodeFactory() = delete; FSNodeFactory(const FSNodeFactory&) = delete; FSNodeFactory(FSNodeFactory&&) = delete; FSNodeFactory& operator=(const FSNodeFactory&) = delete; diff --git a/src/common/FSNodeZIP.hxx b/src/common/FSNodeZIP.hxx index 397f6ed3a..580eeedcf 100644 --- a/src/common/FSNodeZIP.hxx +++ b/src/common/FSNodeZIP.hxx @@ -88,7 +88,7 @@ class FSNodeZIP : public AbstractFSNode private: /* Error types */ - enum class zip_error + enum class zip_error: uInt8 { NONE, NOT_A_FILE, diff --git a/src/common/FpsMeter.hxx b/src/common/FpsMeter.hxx index ba6a73526..9cb9d0b76 100644 --- a/src/common/FpsMeter.hxx +++ b/src/common/FpsMeter.hxx @@ -27,6 +27,7 @@ class FpsMeter public: explicit FpsMeter(uInt32 queueSize); + ~FpsMeter() = default; void reset(uInt32 garbageFrameLimit = 0); diff --git a/src/common/JPGLibrary.hxx b/src/common/JPGLibrary.hxx index 5a62b3dce..4697bc72c 100644 --- a/src/common/JPGLibrary.hxx +++ b/src/common/JPGLibrary.hxx @@ -23,6 +23,9 @@ class OSystem; class FBSurface; +#include "Variant.hxx" +#include "bspf.hxx" + /** This class implements a thin wrapper around the nanojpeg library, and abstracts all the irrelevant details other loading an actual image. @@ -33,6 +36,7 @@ class JPGLibrary { public: explicit JPGLibrary(OSystem& osystem); + ~JPGLibrary() = default; /** Read a JPG image from the specified file into a FBSurface structure, diff --git a/src/common/JoyMap.cxx b/src/common/JoyMap.cxx index e1577b50b..cab67348d 100644 --- a/src/common/JoyMap.cxx +++ b/src/common/JoyMap.cxx @@ -22,22 +22,21 @@ using json = nlohmann::json; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void JoyMap::add(const Event::Type event, const JoyMapping& mapping) +void JoyMap::add(Event::Type event, const JoyMapping& mapping) { myMap[mapping] = event; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void JoyMap::add(const Event::Type event, const EventMode mode, const int button, - const JoyAxis axis, const JoyDir adir, - const int hat, const JoyHatDir hdir) +void JoyMap::add(Event::Type event, EventMode mode, int button, + JoyAxis axis, JoyDir adir, int hat, JoyHatDir hdir) { add(event, JoyMapping(mode, button, axis, adir, hat, hdir)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void JoyMap::add(const Event::Type event, const EventMode mode, const int button, - const int hat, const JoyHatDir hdir) +void JoyMap::add(Event::Type event, EventMode mode, int button, + int hat, JoyHatDir hdir) { add(event, JoyMapping(mode, button, hat, hdir)); } @@ -49,15 +48,13 @@ void JoyMap::erase(const JoyMapping& mapping) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void JoyMap::erase(const EventMode mode, const int button, - const JoyAxis axis, const JoyDir adir) +void JoyMap::erase(EventMode mode, int button, JoyAxis axis, JoyDir adir) { erase(JoyMapping(mode, button, axis, adir)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void JoyMap::erase(const EventMode mode, const int button, - const int hat, const JoyHatDir hdir) +void JoyMap::erase(EventMode mode, int button, int hat, JoyHatDir hdir) { erase(JoyMapping(mode, button, hat, hdir)); } @@ -82,15 +79,15 @@ Event::Type JoyMap::get(const JoyMapping& mapping) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Event::Type JoyMap::get(const EventMode mode, const int button, - const JoyAxis axis, const JoyDir adir) const +Event::Type JoyMap::get(EventMode mode, int button, + JoyAxis axis, JoyDir adir) const { return get(JoyMapping(mode, button, axis, adir)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Event::Type JoyMap::get(const EventMode mode, const int button, - const int hat, const JoyHatDir hdir) const +Event::Type JoyMap::get(EventMode mode, int button, + int hat, JoyHatDir hdir) const { return get(JoyMapping(mode, button, hat, hdir)); } @@ -102,15 +99,14 @@ bool JoyMap::check(const JoyMapping& mapping) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool JoyMap::check(const EventMode mode, const int button, - const JoyAxis axis, const JoyDir adir, - const int hat, const JoyHatDir hdir) const +bool JoyMap::check(EventMode mode, int button, JoyAxis axis, JoyDir adir, + int hat, JoyHatDir hdir) const { return check(JoyMapping(mode, button, axis, adir, hat, hdir)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string JoyMap::getDesc(const Event::Type event, const JoyMapping& mapping) +string JoyMap::getDesc(Event::Type event, const JoyMapping& mapping) { ostringstream buf; @@ -156,7 +152,8 @@ string JoyMap::getDesc(const Event::Type event, const JoyMapping& mapping) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string JoyMap::getEventMappingDesc(int stick, const Event::Type event, const EventMode mode) const +string JoyMap::getEventMappingDesc(int stick, Event::Type event, + EventMode mode) const { ostringstream buf; @@ -173,7 +170,8 @@ string JoyMap::getEventMappingDesc(int stick, const Event::Type event, const Eve } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -JoyMap::JoyMappingArray JoyMap::getEventMapping(const Event::Type event, const EventMode mode) const +JoyMap::JoyMappingArray JoyMap::getEventMapping(Event::Type event, + EventMode mode) const { JoyMappingArray map; @@ -185,7 +183,7 @@ JoyMap::JoyMappingArray JoyMap::getEventMapping(const Event::Type event, const E } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -json JoyMap::saveMapping(const EventMode mode) const +json JoyMap::saveMapping(EventMode mode) const { using MapType = std::pair; std::vector sortedMap(myMap.begin(), myMap.end()); @@ -241,7 +239,7 @@ json JoyMap::saveMapping(const EventMode mode) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int JoyMap::loadMapping(const json& eventMappings, const EventMode mode) +int JoyMap::loadMapping(const json& eventMappings, EventMode mode) { int i = 0; @@ -327,7 +325,7 @@ json JoyMap::convertLegacyMapping(string list) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void JoyMap::eraseMode(const EventMode mode) +void JoyMap::eraseMode(EventMode mode) { for(auto item = myMap.begin(); item != myMap.end();) if(item->first.mode == mode) { @@ -338,7 +336,7 @@ void JoyMap::eraseMode(const EventMode mode) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void JoyMap::eraseEvent(const Event::Type event, const EventMode mode) +void JoyMap::eraseEvent(Event::Type event, EventMode mode) { for(auto item = myMap.begin(); item != myMap.end();) if(item->second == event && item->first.mode == mode) { diff --git a/src/common/JoyMap.hxx b/src/common/JoyMap.hxx index 093f3b406..cdb9bc0f0 100644 --- a/src/common/JoyMap.hxx +++ b/src/common/JoyMap.hxx @@ -58,6 +58,7 @@ class JoyMap axis{JoyAxis::NONE}, adir{JoyDir::NONE}, hat{c_hat}, hdir{c_hdir} { } + ~JoyMapping() = default; JoyMapping(const JoyMapping&) = default; JoyMapping& operator=(const JoyMapping&) = default; JoyMapping(JoyMapping&&) = default; @@ -77,64 +78,61 @@ class JoyMap using JoyMappingArray = std::vector; JoyMap() = default; + ~JoyMap() = default; /** Add new mapping for given event */ - void add(const Event::Type event, const JoyMapping& mapping); - void add(const Event::Type event, const EventMode mode, const int button, - const JoyAxis axis, const JoyDir adir, - const int hat = JOY_CTRL_NONE, const JoyHatDir hdir = JoyHatDir::CENTER); - void add(const Event::Type event, const EventMode mode, const int button, - const int hat, const JoyHatDir hdir); + void add(Event::Type event, const JoyMapping& mapping); + void add(Event::Type event, EventMode mode, int button, + JoyAxis axis, JoyDir adir, + int hat = JOY_CTRL_NONE, JoyHatDir hdir = JoyHatDir::CENTER); + void add(Event::Type event, EventMode mode, int button, + int hat, JoyHatDir hdir); /** Erase mapping */ void erase(const JoyMapping& mapping); - void erase(const EventMode mode, const int button, - const JoyAxis axis, const JoyDir adir); - void erase(const EventMode mode, const int button, - const int hat, const JoyHatDir hdir); + void erase(EventMode mode, int button, JoyAxis axis, JoyDir adir); + void erase(EventMode mode, int button, int hat, JoyHatDir hdir); /** Get event for mapping */ Event::Type get(const JoyMapping& mapping) const; - Event::Type get(const EventMode mode, const int button, - const JoyAxis axis = JoyAxis::NONE, const JoyDir adir = JoyDir::NONE) const; - Event::Type get(const EventMode mode, const int button, - const int hat, const JoyHatDir hdir) const; + Event::Type get(EventMode mode, int button, JoyAxis axis = JoyAxis::NONE, + JoyDir adir = JoyDir::NONE) const; + Event::Type get(EventMode mode, int button, int hat, JoyHatDir hdir) const; /** Check if a mapping exists */ bool check(const JoyMapping& mapping) const; - bool check(const EventMode mode, const int button, - const JoyAxis axis, const JoyDir adir, - const int hat = JOY_CTRL_NONE, const JoyHatDir hdir = JoyHatDir::CENTER) const; + bool check(EventMode mode, int button, JoyAxis axis, JoyDir adir, + int hat = JOY_CTRL_NONE, JoyHatDir hdir = JoyHatDir::CENTER) const; /** Get mapping description */ - string getEventMappingDesc(int stick, const Event::Type event, const EventMode mode) const; + string getEventMappingDesc(int stick, Event::Type event, EventMode mode) const; - JoyMappingArray getEventMapping(const Event::Type event, const EventMode mode) const; + JoyMappingArray getEventMapping(Event::Type event, EventMode mode) const; - nlohmann::json saveMapping(const EventMode mode) const; - int loadMapping(const nlohmann::json& eventMappings, const EventMode mode); + nlohmann::json saveMapping(EventMode mode) const; + int loadMapping(const nlohmann::json& eventMappings, EventMode mode); static nlohmann::json convertLegacyMapping(string list); /** Erase all mappings for given mode */ - void eraseMode(const EventMode mode); + void eraseMode(EventMode mode); /** Erase given event's mapping for given mode */ - void eraseEvent(const Event::Type event, const EventMode mode); + void eraseEvent(Event::Type event, EventMode mode); /** clear all mappings for a modes */ // void clear() { myMap.clear(); } size_t size() const { return myMap.size(); } private: - static string getDesc(const Event::Type event, const JoyMapping& mapping); + static string getDesc(Event::Type event, const JoyMapping& mapping); struct JoyHash { size_t operator()(const JoyMapping& m)const { - return std::hash()((uInt64(m.mode)) // 3 bits - + ((uInt64(m.button)) * 7) // 3 bits - + (((uInt64(m.axis)) << 0) // 2 bits - | ((uInt64(m.adir)) << 2) // 2 bits - | ((uInt64(m.hat )) << 4) // 1 bit - | ((uInt64(m.hdir)) << 5) // 2 bits + return std::hash()((static_cast(m.mode)) // 3 bits + + ((static_cast(m.button)) * 7) // 3 bits + + (((static_cast(m.axis)) << 0) // 2 bits + | ((static_cast(m.adir)) << 2) // 2 bits + | ((static_cast(m.hat )) << 4) // 1 bit + | ((static_cast(m.hdir)) << 5) // 2 bits ) * 61 ); } diff --git a/src/common/KeyMap.cxx b/src/common/KeyMap.cxx index fab0d064f..460087e79 100644 --- a/src/common/KeyMap.cxx +++ b/src/common/KeyMap.cxx @@ -68,13 +68,13 @@ namespace { } // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void KeyMap::add(const Event::Type event, const Mapping& mapping) +void KeyMap::add(Event::Type event, const Mapping& mapping) { myMap[convertMod(mapping)] = event; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void KeyMap::add(const Event::Type event, const EventMode mode, const int key, const int mod) +void KeyMap::add(Event::Type event, EventMode mode, int key, int mod) { add(event, Mapping(mode, key, mod)); } @@ -86,7 +86,7 @@ void KeyMap::erase(const Mapping& mapping) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void KeyMap::erase(const EventMode mode, const int key, const int mod) +void KeyMap::erase(EventMode mode, int key, int mod) { erase(Mapping(mode, key, mod)); } @@ -114,7 +114,7 @@ Event::Type KeyMap::get(const Mapping& mapping) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Event::Type KeyMap::get(const EventMode mode, const int key, const int mod) const +Event::Type KeyMap::get(EventMode mode, int key, int mod) const { return get(Mapping(mode, key, mod)); } @@ -126,7 +126,7 @@ bool KeyMap::check(const Mapping& mapping) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool KeyMap::check(const EventMode mode, const int key, const int mod) const +bool KeyMap::check(EventMode mode, int key, int mod) const { return check(Mapping(mode, key, mod)); } @@ -181,13 +181,13 @@ string KeyMap::getDesc(const Mapping& mapping) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string KeyMap::getDesc(const EventMode mode, const int key, const int mod) +string KeyMap::getDesc(EventMode mode, int key, int mod) { return getDesc(Mapping(mode, key, mod)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string KeyMap::getEventMappingDesc(const Event::Type event, const EventMode mode) const +string KeyMap::getEventMappingDesc(Event::Type event, EventMode mode) const { ostringstream buf; @@ -204,8 +204,8 @@ string KeyMap::getEventMappingDesc(const Event::Type event, const EventMode mode } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -KeyMap::MappingArray KeyMap::getEventMapping(const Event::Type event, - const EventMode mode) const +KeyMap::MappingArray KeyMap::getEventMapping(Event::Type event, + EventMode mode) const { MappingArray ma; @@ -217,7 +217,7 @@ KeyMap::MappingArray KeyMap::getEventMapping(const Event::Type event, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -json KeyMap::saveMapping(const EventMode mode) const +json KeyMap::saveMapping(EventMode mode) const { using MapType = std::pair; std::vector sortedMap(myMap.begin(), myMap.end()); @@ -256,7 +256,8 @@ json KeyMap::saveMapping(const EventMode mode) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int KeyMap::loadMapping(const json& mappings, const EventMode mode) { +int KeyMap::loadMapping(const json& mappings, EventMode mode) +{ int i = 0; for(const json& mapping : mappings) @@ -313,7 +314,7 @@ json KeyMap::convertLegacyMapping(string_view lm) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void KeyMap::eraseMode(const EventMode mode) +void KeyMap::eraseMode(EventMode mode) { for(auto item = myMap.begin(); item != myMap.end();) if(item->first.mode == mode) { @@ -324,7 +325,7 @@ void KeyMap::eraseMode(const EventMode mode) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void KeyMap::eraseEvent(const Event::Type event, const EventMode mode) +void KeyMap::eraseEvent(Event::Type event, EventMode mode) { for(auto item = myMap.begin(); item != myMap.end();) if(item->second == event && item->first.mode == mode) { diff --git a/src/common/KeyMap.hxx b/src/common/KeyMap.hxx index 0d88d75b6..e374ba0c6 100644 --- a/src/common/KeyMap.hxx +++ b/src/common/KeyMap.hxx @@ -42,6 +42,7 @@ class KeyMap : mode{c_mode}, key{c_key}, mod{c_mod} { } explicit Mapping(EventMode c_mode, int c_key, int c_mod) : mode{c_mode}, key{static_cast(c_key)}, mod{static_cast(c_mod)} { } + ~Mapping() = default; Mapping(const Mapping&) = default; Mapping& operator=(const Mapping&) = default; Mapping(Mapping&&) = default; @@ -61,41 +62,42 @@ class KeyMap using MappingArray = std::vector; KeyMap() = default; + ~KeyMap() = default; /** Add new mapping for given event */ - void add(const Event::Type event, const Mapping& mapping); - void add(const Event::Type event, const EventMode mode, const int key, const int mod); + void add(Event::Type event, const Mapping& mapping); + void add(Event::Type event, EventMode mode, int key, int mod); /** Erase mapping */ void erase(const Mapping& mapping); - void erase(const EventMode mode, const int key, const int mod); + void erase(EventMode mode, int key, int mod); /** Get event for mapping */ Event::Type get(const Mapping& mapping) const; - Event::Type get(const EventMode mode, const int key, const int mod) const; + Event::Type get(EventMode mode, int key, int mod) const; /** Check if a mapping exists */ bool check(const Mapping& mapping) const; - bool check(const EventMode mode, const int key, const int mod) const; + bool check(EventMode mode, int key, int mod) const; /** Get mapping description */ static string getDesc(const Mapping& mapping); - static string getDesc(const EventMode mode, const int key, const int mod); + static string getDesc(EventMode mode, int key, int mod); /** Get the mapping description(s) for given event and mode */ - string getEventMappingDesc(const Event::Type event, const EventMode mode) const; + string getEventMappingDesc(Event::Type event, EventMode mode) const; - MappingArray getEventMapping(const Event::Type event, const EventMode mode) const; + MappingArray getEventMapping(Event::Type event, EventMode mode) const; - nlohmann::json saveMapping(const EventMode mode) const; - int loadMapping(const nlohmann::json& mapping, const EventMode mode); + nlohmann::json saveMapping(EventMode mode) const; + int loadMapping(const nlohmann::json& mapping, EventMode mode); static nlohmann::json convertLegacyMapping(string_view lm); /** Erase all mappings for given mode */ - void eraseMode(const EventMode mode); + void eraseMode(EventMode mode); /** Erase given event's mapping for given mode */ - void eraseEvent(const Event::Type event, const EventMode mode); + void eraseEvent(Event::Type event, EventMode mode); /** clear all mappings for a modes */ // void clear() { myMap.clear(); } size_t size() { return myMap.size(); } @@ -108,12 +110,12 @@ class KeyMap struct KeyHash { size_t operator()(const Mapping& m) const { - return std::hash()((uInt64(m.mode)) // 3 bits - + ((uInt64(m.key)) * 7) // 8 bits - + (((uInt64((m.mod & KBDM_SHIFT) != 0) << 0)) // 1 bit - | ((uInt64((m.mod & KBDM_ALT ) != 0) << 1)) // 1 bit - | ((uInt64((m.mod & KBDM_GUI ) != 0) << 2)) // 1 bit - | ((uInt64((m.mod & KBDM_CTRL ) != 0) << 3)) // 1 bit + return std::hash()((static_cast(m.mode)) // 3 bits + + ((static_cast(m.key)) * 7) // 8 bits + + (((static_cast((m.mod & KBDM_SHIFT) != 0) << 0)) // 1 bit + | ((static_cast((m.mod & KBDM_ALT ) != 0) << 1)) // 1 bit + | ((static_cast((m.mod & KBDM_GUI ) != 0) << 2)) // 1 bit + | ((static_cast((m.mod & KBDM_CTRL ) != 0) << 3)) // 1 bit ) * 2047 ); } diff --git a/src/common/LinkedObjectPool.hxx b/src/common/LinkedObjectPool.hxx index 6bd81b3ed..2c0c28423 100644 --- a/src/common/LinkedObjectPool.hxx +++ b/src/common/LinkedObjectPool.hxx @@ -60,6 +60,7 @@ class LinkedObjectPool Create a pool of size CAPACITY; the active list starts out empty. */ LinkedObjectPool() { resize(CAPACITY); } + ~LinkedObjectPool() = default; /** Return node data that the 'current' iterator points to. diff --git a/src/common/Logger.hxx b/src/common/Logger.hxx index 022dbf974..480074c35 100644 --- a/src/common/Logger.hxx +++ b/src/common/Logger.hxx @@ -27,7 +27,7 @@ class Logger { public: - enum class Level { + enum class Level: uInt8 { ERR = 0, // cannot use ERROR??? INFO = 1, DEBUG = 2, @@ -55,6 +55,7 @@ class Logger { protected: Logger() = default; + ~Logger() = default; private: int myLogLevel{static_cast(Level::MAX)}; diff --git a/src/common/MediaFactory.hxx b/src/common/MediaFactory.hxx index 6e9ec061c..f70c0a99a 100644 --- a/src/common/MediaFactory.hxx +++ b/src/common/MediaFactory.hxx @@ -202,6 +202,7 @@ class MediaFactory private: // Following constructors and assignment operators not supported MediaFactory() = delete; + ~MediaFactory() = delete; MediaFactory(const MediaFactory&) = delete; MediaFactory(MediaFactory&&) = delete; MediaFactory& operator=(const MediaFactory&) = delete; diff --git a/src/common/MouseControl.hxx b/src/common/MouseControl.hxx index 1506e271a..3deeef492 100644 --- a/src/common/MouseControl.hxx +++ b/src/common/MouseControl.hxx @@ -19,9 +19,9 @@ #define MOUSE_CONTROL_HXX class Console; -class Controller; class Properties; +#include "Control.hxx" #include "bspf.hxx" /** @@ -41,7 +41,7 @@ class MouseControl /** Enumeration of mouse axis control types */ - enum class Type + enum class Type: uInt8 { LeftPaddleA = 0, LeftPaddleB, RightPaddleA, RightPaddleB, LeftDriving, RightDriving, LeftMindLink, RightMindLink, @@ -56,6 +56,7 @@ class MouseControl @param mode Contains information about how to use the mouse axes/buttons */ MouseControl(Console& console, string_view mode); + ~MouseControl() = default; /** Cycle through each available mouse control mode diff --git a/src/common/PKeyboardHandler.cxx b/src/common/PKeyboardHandler.cxx index b4ce96ab9..a5c53b006 100644 --- a/src/common/PKeyboardHandler.cxx +++ b/src/common/PKeyboardHandler.cxx @@ -235,7 +235,7 @@ void PhysicalKeyboardHandler::setDefaultMapping(Event::Type event, EventMode mod // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PhysicalKeyboardHandler::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 @@ -265,7 +265,7 @@ void PhysicalKeyboardHandler::defineControllerMappings( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EventMode PhysicalKeyboardHandler::getMode(const Properties& properties, - const PropType propType) + PropType propType) { const string& propName = properties.get(propType); @@ -276,7 +276,7 @@ EventMode PhysicalKeyboardHandler::getMode(const Properties& properties, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -EventMode PhysicalKeyboardHandler::getMode(const Controller::Type type) +EventMode PhysicalKeyboardHandler::getMode(Controller::Type type) { switch(type) { @@ -408,8 +408,7 @@ void PhysicalKeyboardHandler::enableMappings(const Event::EventSet& events, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PhysicalKeyboardHandler::enableMapping(const Event::Type event, - EventMode mode) +void PhysicalKeyboardHandler::enableMapping(Event::Type event, EventMode mode) { // copy from controller mode into emulation mode const KeyMap::MappingArray mappings = myKeyMap.getEventMapping(event, mode); @@ -419,8 +418,7 @@ void PhysicalKeyboardHandler::enableMapping(const Event::Type event, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -EventMode PhysicalKeyboardHandler::getEventMode(const Event::Type event, - const EventMode mode) +EventMode PhysicalKeyboardHandler::getEventMode(Event::Type event, EventMode mode) { if (mode == EventMode::kEmulationMode) { @@ -444,7 +442,7 @@ EventMode PhysicalKeyboardHandler::getEventMode(const Event::Type event, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool PhysicalKeyboardHandler::isJoystickEvent(const Event::Type event) +bool PhysicalKeyboardHandler::isJoystickEvent(Event::Type event) { return LeftJoystickEvents.contains(event) || QTJoystick3Events.contains(event) @@ -453,7 +451,7 @@ bool PhysicalKeyboardHandler::isJoystickEvent(const Event::Type event) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool PhysicalKeyboardHandler::isPaddleEvent(const Event::Type event) +bool PhysicalKeyboardHandler::isPaddleEvent(Event::Type event) { return LeftPaddlesEvents.contains(event) || QTPaddles3Events.contains(event) @@ -462,21 +460,21 @@ bool PhysicalKeyboardHandler::isPaddleEvent(const Event::Type event) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool PhysicalKeyboardHandler::isKeyboardEvent(const Event::Type event) +bool PhysicalKeyboardHandler::isKeyboardEvent(Event::Type event) { return LeftKeyboardEvents.contains(event) || RightKeyboardEvents.contains(event); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool PhysicalKeyboardHandler::isDrivingEvent(const Event::Type event) +bool PhysicalKeyboardHandler::isDrivingEvent(Event::Type event) { return LeftDrivingEvents.contains(event) || RightDrivingEvents.contains(event); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool PhysicalKeyboardHandler::isCommonEvent(const Event::Type event) +bool PhysicalKeyboardHandler::isCommonEvent(Event::Type event) { return !(isJoystickEvent(event) || isPaddleEvent(event) || isKeyboardEvent(event) || isDrivingEvent(event)); diff --git a/src/common/PKeyboardHandler.hxx b/src/common/PKeyboardHandler.hxx index b50e3fcce..0e7dcc059 100644 --- a/src/common/PKeyboardHandler.hxx +++ b/src/common/PKeyboardHandler.hxx @@ -24,6 +24,7 @@ class OSystem; class EventHandler; #include "bspf.hxx" +#include "Control.hxx" #include "Event.hxx" #include "EventHandlerConstants.hxx" #include "Props.hxx" @@ -52,7 +53,7 @@ class PhysicalKeyboardHandler bool updateDefaults = false); /** define mappings for current controllers */ - void defineControllerMappings(const Controller::Type type, + void defineControllerMappings(Controller::Type type, Controller::Jack port, const Properties& properties, Controller::Type qtType1 = Controller::Type::Unknown, @@ -108,23 +109,23 @@ class PhysicalKeyboardHandler EventMode mode = EventMode::kEmulationMode, bool updateDefaults = false); /** 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); /** 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); #ifdef DEBUG_BUILD void verifyDefaultMapping(PhysicalKeyboardHandler::EventMappingArray mapping, diff --git a/src/common/PNGLibrary.cxx b/src/common/PNGLibrary.cxx index e3bc9c7aa..e3b4b731c 100644 --- a/src/common/PNGLibrary.cxx +++ b/src/common/PNGLibrary.cxx @@ -442,9 +442,8 @@ void PNGLibrary::loadImagetoSurface(FBSurface& surface, bool hasAlpha) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PNGLibrary::writeMetaData( - const png_structp png_ptr, png_infop info_ptr, // NOLINT - const VariantList& metaData) +void PNGLibrary::writeMetaData(png_structp png_ptr, png_infop info_ptr, + const VariantList& metaData) { const size_t numMetaData = metaData.size(); if(numMetaData == 0) @@ -462,9 +461,8 @@ void PNGLibrary::writeMetaData( } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PNGLibrary::readMetaData( - const png_structp png_ptr, png_infop info_ptr, // NOLINT - VariantList& metaData) +void PNGLibrary::readMetaData(png_structp png_ptr, png_infop info_ptr, + VariantList& metaData) { png_textp text_ptr{nullptr}; int numMetaData{0}; @@ -479,37 +477,33 @@ void PNGLibrary::readMetaData( } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PNGLibrary::png_read_data(const png_structp ctx, // NOLINT - png_bytep area, png_size_t size) +void PNGLibrary::png_read_data(png_structp ctx, png_bytep area, png_size_t size) { (static_cast(png_get_io_ptr(ctx)))->read( reinterpret_cast(area), size); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PNGLibrary::png_write_data(const png_structp ctx, // NOLINT - png_bytep area, png_size_t size) +void PNGLibrary::png_write_data(png_structp ctx, png_bytep area, png_size_t size) { (static_cast(png_get_io_ptr(ctx)))->write( reinterpret_cast(area), size); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PNGLibrary::png_io_flush(const png_structp ctx) // NOLINT +void PNGLibrary::png_io_flush(png_structp ctx) { (static_cast(png_get_io_ptr(ctx)))->flush(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PNGLibrary::png_user_warn(const png_structp ctx, // NOLINT - png_const_charp str) +void PNGLibrary::png_user_warn(png_structp ctx, png_const_charp str) { throw runtime_error(string("PNGLibrary warning: ") + str); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PNGLibrary::png_user_error(const png_structp ctx, // NOLINT - png_const_charp str) +void PNGLibrary::png_user_error(png_structp ctx, png_const_charp str) { throw runtime_error(string("PNGLibrary error: ") + str); } diff --git a/src/common/PNGLibrary.hxx b/src/common/PNGLibrary.hxx index 18535de45..c2cfb689c 100644 --- a/src/common/PNGLibrary.hxx +++ b/src/common/PNGLibrary.hxx @@ -22,6 +22,9 @@ #include +#include "bspf.hxx" +#include "Variant.hxx" + class OSystem; class FBSurface; @@ -36,6 +39,7 @@ class PNGLibrary { public: explicit PNGLibrary(OSystem& osystem); + ~PNGLibrary() = default; /** Read a PNG image from the specified file into a FBSurface structure, @@ -178,25 +182,21 @@ class PNGLibrary /** Write PNG tEXt chunks to the image. */ - static void writeMetaData(const png_structp png_ptr, png_infop info_ptr, + static void writeMetaData(png_structp png_ptr, png_infop info_ptr, const VariantList& metaData); /** Read PNG tEXt chunks from the image. */ - static void readMetaData(const png_structp png_ptr, png_infop info_ptr, + static void readMetaData(png_structp png_ptr, png_infop info_ptr, VariantList& metaData); /** PNG library callback functions */ - static void png_read_data(const png_structp ctx, png_bytep area, - png_size_t size); - static void png_write_data(const png_structp ctx, png_bytep area, - png_size_t size); - static void png_io_flush(const png_structp ctx); - [[noreturn]] static void png_user_warn(const png_structp ctx, - png_const_charp str); - [[noreturn]] static void png_user_error(const png_structp ctx, - png_const_charp str); + static void png_read_data(png_structp ctx, png_bytep area, png_size_t size); + static void png_write_data(png_structp ctx, png_bytep area, png_size_t size); + static void png_io_flush(png_structp ctx); + [[noreturn]] static void png_user_warn(png_structp ctx, png_const_charp str); + [[noreturn]] static void png_user_error(png_structp ctx, png_const_charp str); private: // Following constructors and assignment operators not supported diff --git a/src/common/PaletteHandler.hxx b/src/common/PaletteHandler.hxx index 7d2cf3d0e..980958a0a 100644 --- a/src/common/PaletteHandler.hxx +++ b/src/common/PaletteHandler.hxx @@ -39,7 +39,7 @@ class PaletteHandler static constexpr float DEF_RGB_SHIFT = 0.0F; static constexpr float MAX_RGB_SHIFT = 22.5F; - enum Adjustables : uInt32 { + enum Adjustables : uInt8 { PHASE_SHIFT, RED_SCALE, GREEN_SCALE, @@ -66,6 +66,7 @@ class PaletteHandler public: explicit PaletteHandler(OSystem& system); + ~PaletteHandler() = default; /** Cycle through available palettes. @@ -124,7 +125,7 @@ class PaletteHandler private: static constexpr char DEGREE = 0x1c; - enum PaletteType { + enum PaletteType: uInt8 { Standard, Z26, User, diff --git a/src/common/PhosphorHandler.hxx b/src/common/PhosphorHandler.hxx index a1f3ea289..3695e2cf7 100644 --- a/src/common/PhosphorHandler.hxx +++ b/src/common/PhosphorHandler.hxx @@ -33,7 +33,7 @@ class PhosphorHandler static constexpr string_view VALUE_AUTO_ON = "autoon"; static constexpr string_view VALUE_AUTO = "auto"; - enum PhosphorMode { + enum PhosphorMode: uInt8 { ByRom, Always, Auto_on, @@ -44,6 +44,7 @@ class PhosphorHandler static constexpr string_view DEFAULT_BLEND = "50"; // align with myPhosphorPercent! PhosphorHandler() = default; + ~PhosphorHandler() = default; bool initialize(bool enable, int blend); @@ -63,12 +64,12 @@ class PhosphorHandler static constexpr uInt32 getPixel(const uInt32 c, const uInt32 p) { // Mix current calculated frame with previous displayed frame - const uInt8 rc = static_cast(c >> 16), - gc = static_cast(c >> 8), - bc = static_cast(c), - rp = static_cast(p >> 16), - gp = static_cast(p >> 8), - bp = static_cast(p); + const auto rc = static_cast(c >> 16), + gc = static_cast(c >> 8), + bc = static_cast(c), + rp = static_cast(p >> 16), + gp = static_cast(p >> 8), + bp = static_cast(p); return (ourPhosphorLUT[rc][rp] << 16) | (ourPhosphorLUT[gc][gp] << 8) | ourPhosphorLUT[bc][bp]; diff --git a/src/common/PhysicalJoystick.cxx b/src/common/PhysicalJoystick.cxx index e75b28582..e1d8a2825 100644 --- a/src/common/PhysicalJoystick.cxx +++ b/src/common/PhysicalJoystick.cxx @@ -111,7 +111,7 @@ bool PhysicalJoystick::setMap(const json& map) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - json PhysicalJoystick::convertLegacyMapping(string_view mapping, string_view name) { - istringstream buf(string{mapping}); // TODO: fixed in C++20 + istringstream buf(string{mapping}); // TODO: fixed in C++23 json convertedMapping = json::object(); string map; diff --git a/src/common/PhysicalJoystick.hxx b/src/common/PhysicalJoystick.hxx index 6bb1dd6ce..c312d2d52 100644 --- a/src/common/PhysicalJoystick.hxx +++ b/src/common/PhysicalJoystick.hxx @@ -43,7 +43,7 @@ class PhysicalJoystick static constexpr char MODE_DELIM = '>'; // must not be '^', '|' or '#' public: - enum class Port { + enum class Port: uInt8 { AUTO, LEFT, RIGHT, @@ -51,10 +51,11 @@ class PhysicalJoystick }; PhysicalJoystick() = default; + ~PhysicalJoystick() = default; nlohmann::json getMap() const; bool setMap(const nlohmann::json& map); - void setPort(const Port _port) { port = _port; } + void setPort(Port _port) { port = _port; } static nlohmann::json convertLegacyMapping(string_view mapping, string_view name); @@ -68,7 +69,7 @@ class PhysicalJoystick int axes, int buttons, int hats, int balls); private: - enum class Type { + enum class Type: uInt8 { REGULAR, LEFT_STELLADAPTOR, RIGHT_STELLADAPTOR, LEFT_2600DAPTOR, RIGHT_2600DAPTOR @@ -89,7 +90,7 @@ class PhysicalJoystick // Convert from string to Port type and vice versa static string getName(const Port _port) { static constexpr std::array(PhysicalJoystick::Port::NUM_PORTS)> NAMES = { + static_cast(PhysicalJoystick::Port::NUM_PORTS)> NAMES = { "Auto", "Left", "Right" }; @@ -98,11 +99,11 @@ class PhysicalJoystick static Port getPort(string_view portName) { static constexpr std::array(PhysicalJoystick::Port::NUM_PORTS)> NAMES = { + static_cast(PhysicalJoystick::Port::NUM_PORTS)> NAMES = { "Auto", "Left", "Right" }; - for(int i = 0; i < static_cast(PhysicalJoystick::Port::NUM_PORTS); ++i) + for(uInt8 i = 0; i < static_cast(PhysicalJoystick::Port::NUM_PORTS); ++i) if (BSPF::equalsIgnoreCase(portName, NAMES[i])) return PhysicalJoystick::Port{i}; diff --git a/src/common/RewindManager.hxx b/src/common/RewindManager.hxx index 50529be31..1dcf2cdf4 100644 --- a/src/common/RewindManager.hxx +++ b/src/common/RewindManager.hxx @@ -22,6 +22,7 @@ class OSystem; class StateManager; #include "LinkedObjectPool.hxx" +#include "Serializer.hxx" #include "bspf.hxx" /** @@ -47,12 +48,13 @@ class RewindManager { public: RewindManager(OSystem& system, StateManager& statemgr); + ~RewindManager() = default; public: static constexpr uInt32 MAX_BUF_SIZE = 1000; static constexpr int NUM_INTERVALS = 7; // cycle values for the intervals - const std::array INTERVAL_CYCLES = { + static constexpr std::array INTERVAL_CYCLES = { 76 * 262, 76 * 262 * 3, 76 * 262 * 10, @@ -74,7 +76,7 @@ class RewindManager static constexpr int NUM_HORIZONS = 8; // cycle values for the horzions - const std::array HORIZON_CYCLES = { + static constexpr std::array HORIZON_CYCLES = { uInt64{76} * 262 * 60 * 3, uInt64{76} * 262 * 60 * 10, uInt64{76} * 262 * 60 * 30, @@ -187,7 +189,7 @@ class RewindManager RewindState() = default; ~RewindState() = default; RewindState(const RewindState& rs) : cycles(rs.cycles) { } - RewindState& operator= (const RewindState& rs) { cycles = rs.cycles; return *this; } + RewindState& operator= (const RewindState& rs) { cycles = rs.cycles; return *this; } // NOLINT: we don't worry about self-assignment here RewindState(RewindState&&) = default; RewindState& operator=(RewindState&&) = default; diff --git a/src/common/SDL_lib.hxx b/src/common/SDL_lib.hxx index c0675988b..d344deab0 100644 --- a/src/common/SDL_lib.hxx +++ b/src/common/SDL_lib.hxx @@ -63,7 +63,7 @@ static inline string SDLVersion() static inline bool SDLSupportsURL() { - return static_cast(SDL_VERSION_ATLEAST(2,0,14)); + return SDL_VERSION_ATLEAST(2,0,14); } static inline bool SDLOpenURL(const string& url) diff --git a/src/common/SoundSDL2.cxx b/src/common/SoundSDL2.cxx index 313b84750..91b215a6c 100644 --- a/src/common/SoundSDL2.cxx +++ b/src/common/SoundSDL2.cxx @@ -385,8 +385,7 @@ void SoundSDL2::callback(void* object, uInt8* stream, int len) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool SoundSDL2::playWav(const string& fileName, const uInt32 position, - const uInt32 length) +bool SoundSDL2::playWav(const string& fileName, uInt32 position, uInt32 length) { const char* const device = myDeviceId ? myDevices.at(myDeviceId).first.c_str() @@ -409,9 +408,7 @@ uInt32 SoundSDL2::wavSize() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool SoundSDL2::WavHandlerSDL2::play( - const string& fileName, const char* device, - const uInt32 position, const uInt32 length -) + const string& fileName, const char* device, uInt32 position, uInt32 length) { // Load WAV file if(fileName != myFilename || myBuffer == nullptr) diff --git a/src/common/SoundSDL2.hxx b/src/common/SoundSDL2.hxx index 3130f5de4..2a118503c 100644 --- a/src/common/SoundSDL2.hxx +++ b/src/common/SoundSDL2.hxx @@ -44,10 +44,6 @@ class SoundSDL2 : public Sound using the object. */ SoundSDL2(OSystem& osystem, AudioSettings& audioSettings); - - /** - Destructor - */ ~SoundSDL2() override; public: @@ -121,8 +117,8 @@ class SoundSDL2 : public Sound @return True if the WAV file can be played, else false */ - bool playWav(const string& fileName, const uInt32 position = 0, - const uInt32 length = 0) override; + bool playWav(const string& fileName, uInt32 position = 0, + uInt32 length = 0) override; /** Stop any currently playing WAV file. @@ -185,7 +181,7 @@ class SoundSDL2 : public Sound ~WavHandlerSDL2(); bool play(const string& fileName, const char* device, - const uInt32 position, const uInt32 length); + uInt32 position, uInt32 length); void stop(); uInt32 size() const { return myBuffer ? myRemaining : 0; } diff --git a/src/common/Stack.hxx b/src/common/Stack.hxx index 88e59acf6..dd34ec97c 100644 --- a/src/common/Stack.hxx +++ b/src/common/Stack.hxx @@ -38,6 +38,7 @@ class FixedStack using StackFunction = std::function; FixedStack() = default; + ~FixedStack() = default; bool empty() const { return _size == 0; } bool full() const { return _size >= CAPACITY; } diff --git a/src/common/StateManager.hxx b/src/common/StateManager.hxx index 1576a969d..fa540acfb 100644 --- a/src/common/StateManager.hxx +++ b/src/common/StateManager.hxx @@ -35,7 +35,7 @@ class RewindManager; class StateManager { public: - enum class Mode { + enum class Mode: uInt8 { Off, TimeMachine, MovieRecord, diff --git a/src/common/StellaKeys.hxx b/src/common/StellaKeys.hxx index 937e4da1d..5287bce2b 100644 --- a/src/common/StellaKeys.hxx +++ b/src/common/StellaKeys.hxx @@ -417,7 +417,7 @@ enum StellaMod // Test if specified modifier is pressed namespace StellaModTest { - inline constexpr bool isAlt(int mod) + constexpr bool isAlt(int mod) { #if defined(BSPF_MACOS) || defined(MACOS_KEYS) return (mod & KBDM_GUI); @@ -426,16 +426,16 @@ namespace StellaModTest #endif } - inline constexpr bool isControl(int mod) + constexpr bool isControl(int mod) { return (mod & KBDM_CTRL); } - inline constexpr bool isShift(int mod) + constexpr bool isShift(int mod) { return (mod & KBDM_SHIFT); } -} +} // namespace StellaModTest namespace StellaKeyName { @@ -447,6 +447,6 @@ namespace StellaKeyName return string_view{}; #endif } -} +} // namespace StellaKeyName #endif /* StellaKeys */ diff --git a/src/common/StringParser.hxx b/src/common/StringParser.hxx index 8110b3fea..88f6036b8 100644 --- a/src/common/StringParser.hxx +++ b/src/common/StringParser.hxx @@ -36,12 +36,13 @@ class StringParser */ explicit StringParser(string_view str) { - istringstream buf(string{str}); // TODO: fixed in C++20 + istringstream buf(string{str}); // TODO: fixed in C++23 string line; while(std::getline(buf, line, '\n')) myStringList.push_back(line); } + ~StringParser() = default; /** Split the given string based on the newline character, making sure that @@ -52,7 +53,7 @@ class StringParser */ StringParser(string_view str, uInt32 maxlen) { - istringstream buf(string{str}); // TODO: fixed in C++20 + istringstream buf(string{str}); // TODO: fixed in C++23 string line; while(std::getline(buf, line, '\n')) diff --git a/src/common/ThreadDebugging.hxx b/src/common/ThreadDebugging.hxx index a7e371751..60206b360 100644 --- a/src/common/ThreadDebugging.hxx +++ b/src/common/ThreadDebugging.hxx @@ -49,6 +49,7 @@ class ThreadDebuggingHelper { [[noreturn]] static void fail(const string& message); ThreadDebuggingHelper() = default; + ~ThreadDebuggingHelper() = default; std::thread::id myMainThreadId; diff --git a/src/common/TimerManager.hxx b/src/common/TimerManager.hxx index e4cfe07d0..2ad70c1cf 100644 --- a/src/common/TimerManager.hxx +++ b/src/common/TimerManager.hxx @@ -205,7 +205,7 @@ class TimerManager bool done{false}; // Valid IDs are guaranteed not to be this value - static TimerId constexpr no_timer = TimerId(0); + static TimerId constexpr no_timer = static_cast(0); private: // Following constructors and assignment operators not supported diff --git a/src/common/Variant.hxx b/src/common/Variant.hxx index 86abfde98..32a5c9e65 100644 --- a/src/common/Variant.hxx +++ b/src/common/Variant.hxx @@ -42,7 +42,7 @@ class Variant } public: - Variant() = default; // NOLINT + Variant() = default; Variant(const string& s) : data{s} { } Variant(string_view s) : data{s} { } @@ -89,6 +89,6 @@ namespace VarList { { list.emplace_back(name.toString(), tag); } -} +} // namespace VarList #endif diff --git a/src/common/VideoModeHandler.hxx b/src/common/VideoModeHandler.hxx index 6c74e56f1..db530f321 100644 --- a/src/common/VideoModeHandler.hxx +++ b/src/common/VideoModeHandler.hxx @@ -34,7 +34,7 @@ class VideoModeHandler // 'screen' are the dimensions of the screen itself struct Mode { - enum class Stretch { + enum class Stretch: uInt8 { Preserve, // Stretch to fill all available space; preserve aspect ratio Fill, // Stretch to fill all available space None // No stretching (1x zoom) @@ -70,6 +70,7 @@ class VideoModeHandler public: VideoModeHandler() = default; + ~VideoModeHandler() = default; /** Set the base size of the image. Scaling can be applied to this, diff --git a/src/common/ZipHandler.hxx b/src/common/ZipHandler.hxx index cd153678a..3ecf88938 100644 --- a/src/common/ZipHandler.hxx +++ b/src/common/ZipHandler.hxx @@ -35,6 +35,7 @@ class ZipHandler { public: ZipHandler() = default; + ~ZipHandler() = default; // Open ZIP file for processing // An exception will be thrown on any errors @@ -54,7 +55,7 @@ class ZipHandler private: // Error types - enum class ZipError + enum class ZipError: uInt8 { NONE = 0, OUT_OF_MEMORY, @@ -182,7 +183,7 @@ class ZipHandler } string read_string(size_t offs, size_t len = string::npos) const { - return string(reinterpret_cast(myBuf + offs), len); + return {reinterpret_cast(myBuf + offs), len}; } private: diff --git a/src/common/audio/ConvolutionBuffer.hxx b/src/common/audio/ConvolutionBuffer.hxx index 6d3975ecc..b539b586a 100644 --- a/src/common/audio/ConvolutionBuffer.hxx +++ b/src/common/audio/ConvolutionBuffer.hxx @@ -23,12 +23,12 @@ class ConvolutionBuffer { public: - explicit ConvolutionBuffer(uInt32 size); + ~ConvolutionBuffer() = default; void shift(float nextValue); - float convoluteWith(const float* const kernel) const; + float convoluteWith(const float* kernel) const; private: @@ -39,7 +39,6 @@ class ConvolutionBuffer uInt32 mySize{0}; private: - ConvolutionBuffer() = delete; ConvolutionBuffer(const ConvolutionBuffer&) = delete; ConvolutionBuffer(ConvolutionBuffer&&) = delete; diff --git a/src/common/audio/SimpleResampler.hxx b/src/common/audio/SimpleResampler.hxx index 0278ad62f..88ff5aae5 100644 --- a/src/common/audio/SimpleResampler.hxx +++ b/src/common/audio/SimpleResampler.hxx @@ -29,6 +29,7 @@ class SimpleResampler : public Resampler Resampler::Format formatTo, const Resampler::NextFragmentCallback& NextFragmentCallback ); + ~SimpleResampler() override = default; void fillFragment(float* fragment, uInt32 length) override; diff --git a/src/common/bspf.hxx b/src/common/bspf.hxx index e203b5ace..8a4217fdd 100644 --- a/src/common/bspf.hxx +++ b/src/common/bspf.hxx @@ -88,8 +88,8 @@ using BoolArray = std::vector; using ByteArray = std::vector; using ShortArray = std::vector; using StringList = std::vector; -using ByteBuffer = std::unique_ptr; // NOLINT -using DWordBuffer = std::unique_ptr; // NOLINT +using ByteBuffer = std::unique_ptr; +using DWordBuffer = std::unique_ptr; // We use KB a lot; let's make a literal for it constexpr size_t operator "" _KB(unsigned long long size) @@ -105,7 +105,7 @@ std::ostream& operator<< (std::ostream& out, const std::vector& v) { return out; } -static const string EmptyString(""); +static const string EmptyString; // This is defined by some systems, but Stella has other uses for it #undef PAGE_SIZE @@ -147,7 +147,7 @@ namespace BSPF #endif // Get next power of two greater than or equal to the given value - inline constexpr size_t nextPowerOfTwo(size_t size) { + constexpr size_t nextPowerOfTwo(size_t size) { if(size < 2) return 1; size_t power2 = 1; while(power2 < size) @@ -157,7 +157,7 @@ namespace BSPF // Get next multiple of the given value // Note that this only works when multiple is a power of two - inline constexpr size_t nextMultipleOf(size_t size, size_t multiple) { + constexpr size_t nextMultipleOf(size_t size, size_t multiple) { return (size + multiple - 1) & ~(multiple - 1); } @@ -167,15 +167,15 @@ namespace BSPF // Combines 'max' and 'min', and clamps value to the upper/lower value // if it is outside the specified range - template inline constexpr T clamp(T val, T lower, T upper) + template constexpr T clamp(T val, T lower, T upper) { return std::clamp(val, lower, upper); } - template inline constexpr void clamp(T& val, T lower, T upper, T setVal) + template constexpr void clamp(T& val, T lower, T upper, T setVal) { if(val < lower || val > upper) val = setVal; } - template inline constexpr T clampw(T val, T lower, T upper) + template constexpr T clampw(T val, T lower, T upper) { return (val < lower) ? upper : (val > upper) ? lower : val; } @@ -204,7 +204,7 @@ namespace BSPF { try { int i{}; - s = s.substr(s.find_first_not_of(" ")); + s = s.substr(s.find_first_not_of(' ')); auto result = std::from_chars(s.data(), s.data() + s.size(), i, BASE); return result.ec == std::errc() ? i : defaultValue; } @@ -226,13 +226,13 @@ namespace BSPF } // Test whether two strings are equal (case insensitive) - inline constexpr bool equalsIgnoreCase(string_view s1, string_view s2) + constexpr bool equalsIgnoreCase(string_view s1, string_view s2) { return s1.size() == s2.size() ? (compareIgnoreCase(s1, s2) == 0) : false; } // Test whether the first string starts with the second one (case insensitive) - inline constexpr bool startsWithIgnoreCase(string_view s1, string_view s2) + constexpr bool startsWithIgnoreCase(string_view s1, string_view s2) { if(s1.size() >= s2.size()) return compareIgnoreCase(s1.substr(0, s2.size()), s2) == 0; @@ -241,7 +241,7 @@ namespace BSPF } // Test whether the first string ends with the second one (case insensitive) - inline constexpr bool endsWithIgnoreCase(string_view s1, string_view s2) + constexpr bool endsWithIgnoreCase(string_view s1, string_view s2) { if(s1.size() >= s2.size()) return compareIgnoreCase(s1.substr(s1.size() - s2.size()), s2) == 0; @@ -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 *const pos = std::search(s1.cbegin()+startpos, s1.cend(), s2.cbegin(), s2.cend(), [](char ch1, char ch2) { return toupper(static_cast(ch1)) == toupper(static_cast(ch2)); }); diff --git a/src/common/repository/KeyValueRepositoryFile.hxx b/src/common/repository/KeyValueRepositoryFile.hxx index 2749efd4e..87e4b85c0 100644 --- a/src/common/repository/KeyValueRepositoryFile.hxx +++ b/src/common/repository/KeyValueRepositoryFile.hxx @@ -25,7 +25,7 @@ #include "FSNode.hxx" #include "bspf.hxx" -template +template class KeyValueRepositoryFile : public KeyValueRepository { public: explicit KeyValueRepositoryFile(const FSNode& node); @@ -44,16 +44,17 @@ class KeyValueRepositoryFile : public KeyValueRepository { /////////////////////////////////////////////////////////////////////////////// // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -template +template KeyValueRepositoryFile::KeyValueRepositoryFile(const FSNode& node) : myNode{node} -{} +{ +} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -template +template KVRMap KeyValueRepositoryFile::load() { - if (!myNode.exists()) return KVRMap(); + if (!myNode.exists()) return {}; stringstream in; @@ -64,18 +65,18 @@ KVRMap KeyValueRepositoryFile::load() catch (const runtime_error& err) { Logger::error(err.what()); - return KVRMap(); + return {}; } catch (...) { - return KVRMap(); + return {}; } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -template +template bool KeyValueRepositoryFile::save(const KVRMap& values) { - if (values.size() == 0) return true; + if (values.empty()) return true; stringstream out; diff --git a/src/common/repository/sqlite/CompositeKeyValueRepositorySqlite.hxx b/src/common/repository/sqlite/CompositeKeyValueRepositorySqlite.hxx index 27ed7eb63..a70a4e3d0 100644 --- a/src/common/repository/sqlite/CompositeKeyValueRepositorySqlite.hxx +++ b/src/common/repository/sqlite/CompositeKeyValueRepositorySqlite.hxx @@ -37,6 +37,7 @@ class CompositeKeyValueRepositorySqlite : public CompositeKeyValueRepositoryAtom string_view colKey2, string_view colValue ); + ~CompositeKeyValueRepositorySqlite() override = default; shared_ptr get(string_view key) override; @@ -53,6 +54,7 @@ class CompositeKeyValueRepositorySqlite : public CompositeKeyValueRepositoryAtom ProxyRepository(const CompositeKeyValueRepositorySqlite& repo, string_view key); + ~ProxyRepository() override = default; protected: diff --git a/src/common/repository/sqlite/KeyValueRepositorySqlite.hxx b/src/common/repository/sqlite/KeyValueRepositorySqlite.hxx index 234e73185..506e0139f 100644 --- a/src/common/repository/sqlite/KeyValueRepositorySqlite.hxx +++ b/src/common/repository/sqlite/KeyValueRepositorySqlite.hxx @@ -29,6 +29,7 @@ class KeyValueRepositorySqlite : public AbstractKeyValueRepositorySqlite KeyValueRepositorySqlite(SqliteDatabase& db, string_view tableName, string_view colKey, string_view colValue); + ~KeyValueRepositorySqlite() override = default; void initialize(); diff --git a/src/common/repository/sqlite/SqliteDatabase.hxx b/src/common/repository/sqlite/SqliteDatabase.hxx index 0ad1d83b2..e2227ad90 100644 --- a/src/common/repository/sqlite/SqliteDatabase.hxx +++ b/src/common/repository/sqlite/SqliteDatabase.hxx @@ -34,7 +34,7 @@ class SqliteDatabase const string& fileName() const { return myDatabaseFile; } - operator sqlite3*() const { return myHandle; } + operator sqlite3*() const { return myHandle; } // NOLINT: explicit not required void exec(string_view sql); diff --git a/src/common/repository/sqlite/SqliteError.hxx b/src/common/repository/sqlite/SqliteError.hxx index 47d1009e2..f72b1e3de 100644 --- a/src/common/repository/sqlite/SqliteError.hxx +++ b/src/common/repository/sqlite/SqliteError.hxx @@ -30,7 +30,7 @@ class SqliteError : public std::exception const char* what() const noexcept override { return myMessage.c_str(); } private: - const string myMessage; + string myMessage; }; #endif // SQLITE_ERROR_HXX diff --git a/src/common/repository/sqlite/SqliteStatement.hxx b/src/common/repository/sqlite/SqliteStatement.hxx index d90555ed4..aebdacd2e 100644 --- a/src/common/repository/sqlite/SqliteStatement.hxx +++ b/src/common/repository/sqlite/SqliteStatement.hxx @@ -32,7 +32,7 @@ class SqliteStatement { ~SqliteStatement(); - operator sqlite3_stmt*() const { return myStmt; } + operator sqlite3_stmt*() const { return myStmt; } // NOLINT: explicit not required SqliteStatement& bind(int index, string_view value); SqliteStatement& bind(int index, Int32 value); diff --git a/src/common/sdl_blitter/BlitterFactory.hxx b/src/common/sdl_blitter/BlitterFactory.hxx index 560bb2364..135297a47 100644 --- a/src/common/sdl_blitter/BlitterFactory.hxx +++ b/src/common/sdl_blitter/BlitterFactory.hxx @@ -27,7 +27,7 @@ class BlitterFactory { public: - enum class ScalingAlgorithm { + enum class ScalingAlgorithm: uInt8 { nearestNeighbour, bilinear, quasiInteger diff --git a/src/common/smartmod.hxx b/src/common/smartmod.hxx index 524d6696f..bef736be9 100644 --- a/src/common/smartmod.hxx +++ b/src/common/smartmod.hxx @@ -29,56 +29,56 @@ constexpr uInt8 smartmod(uInt8 x) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - template<> -inline constexpr uInt8 smartmod<2>(uInt8 x) +constexpr uInt8 smartmod<2>(uInt8 x) { return x & 0x01; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - template<> -inline constexpr uInt8 smartmod<4>(uInt8 x) +constexpr uInt8 smartmod<4>(uInt8 x) { return x & 0x03; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - template<> -inline constexpr uInt8 smartmod<8>(uInt8 x) +constexpr uInt8 smartmod<8>(uInt8 x) { return x & 0x07; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - template<> -inline constexpr uInt8 smartmod<16>(uInt8 x) +constexpr uInt8 smartmod<16>(uInt8 x) { return x & 0x0F; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - template<> -inline constexpr uInt8 smartmod<32>(uInt8 x) +constexpr uInt8 smartmod<32>(uInt8 x) { return x & 0x1F; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - template<> -inline constexpr uInt8 smartmod<64>(uInt8 x) +constexpr uInt8 smartmod<64>(uInt8 x) { return x & 0x3F; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - template<> -inline constexpr uInt8 smartmod<128>(uInt8 x) +constexpr uInt8 smartmod<128>(uInt8 x) { return x & 0x7F; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - template<> -inline constexpr uInt8 smartmod<256>(uInt8 x) +constexpr uInt8 smartmod<256>(uInt8 x) { return x & 0xFF; } diff --git a/src/common/tv_filters/AtariNTSC.cxx b/src/common/tv_filters/AtariNTSC.cxx index 368fafd6c..16c48fe7b 100644 --- a/src/common/tv_filters/AtariNTSC.cxx +++ b/src/common/tv_filters/AtariNTSC.cxx @@ -100,9 +100,8 @@ void AtariNTSC::enableThreading(bool enable) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void AtariNTSC::render(const uInt8* atari_in, const uInt32 in_width, - const uInt32 in_height, void* rgb_out, - const uInt32 out_pitch, uInt32* rgb_in) +void AtariNTSC::render(const uInt8* atari_in, uInt32 in_width, uInt32 in_height, + void* rgb_out, uInt32 out_pitch, uInt32* rgb_in) { // Spawn the threads... for(uInt32 i = 0; i < myWorkerThreads; ++i) @@ -130,9 +129,9 @@ void AtariNTSC::render(const uInt8* atari_in, const uInt32 in_width, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void AtariNTSC::renderThread(const uInt8* atari_in, const uInt32 in_width, - const uInt32 in_height, const uInt32 numThreads, const uInt32 threadNum, - void* rgb_out, const uInt32 out_pitch) +void AtariNTSC::renderThread(const uInt8* atari_in, uInt32 in_width, + uInt32 in_height, uInt32 numThreads, uInt32 threadNum, + void* rgb_out, uInt32 out_pitch) { // Adapt parameters to thread number const uInt32 yStart = in_height * threadNum / numThreads; @@ -204,9 +203,9 @@ void AtariNTSC::renderThread(const uInt8* atari_in, const uInt32 in_width, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void AtariNTSC::renderWithPhosphorThread(const uInt8* atari_in, const uInt32 in_width, - const uInt32 in_height, const uInt32 numThreads, const uInt32 threadNum, - uInt32* rgb_in, void* rgb_out, const uInt32 out_pitch) +void AtariNTSC::renderWithPhosphorThread(const uInt8* atari_in, uInt32 in_width, + uInt32 in_height, uInt32 numThreads, uInt32 threadNum, uInt32* rgb_in, + void* rgb_out, uInt32 out_pitch) { // Adapt parameters to thread number const uInt32 yStart = in_height * threadNum / numThreads; diff --git a/src/common/tv_filters/AtariNTSC.hxx b/src/common/tv_filters/AtariNTSC.hxx index a659dd1d5..08a272072 100644 --- a/src/common/tv_filters/AtariNTSC.hxx +++ b/src/common/tv_filters/AtariNTSC.hxx @@ -94,8 +94,8 @@ class AtariNTSC // palette colors. // In_row_width is the number of pixels to get to the next input row. // Out_pitch is the number of *bytes* to get to the next output row. - void render(const uInt8* atari_in, const uInt32 in_width, const uInt32 in_height, - void* rgb_out, const uInt32 out_pitch, uInt32* rgb_in = nullptr); + void render(const uInt8* atari_in, uInt32 in_width, uInt32 in_height, + void* rgb_out, uInt32 out_pitch, uInt32* rgb_in = nullptr); // Number of output pixels written by blitter for given input width. // Width might be rounded down slightly; use inWidth() on result to @@ -109,10 +109,11 @@ class AtariNTSC void generateKernels(); // Threaded rendering - void renderThread(const uInt8* atari_in, const uInt32 in_width, - const uInt32 in_height, const uInt32 numThreads, const uInt32 threadNum, void* rgb_out, const uInt32 out_pitch); - void renderWithPhosphorThread(const uInt8* atari_in, const uInt32 in_width, - const uInt32 in_height, const uInt32 numThreads, const uInt32 threadNum, uInt32* rgb_in, void* rgb_out, const uInt32 out_pitch); + void renderThread(const uInt8* atari_in, uInt32 in_width, uInt32 in_height, + uInt32 numThreads, uInt32 threadNum, void* rgb_out, uInt32 out_pitch); + void renderWithPhosphorThread(const uInt8* atari_in, uInt32 in_width, + uInt32 in_height, uInt32 numThreads, uInt32 threadNum, uInt32* rgb_in, + void* rgb_out, uInt32 out_pitch); private: static constexpr Int32 @@ -153,20 +154,21 @@ class AtariNTSC luma_cutoff = 0.20F ; - std::array myRGBPalette; + std::array myRGBPalette; BSPF::array2D myColorTable; // Rendering threads - unique_ptr myThreads; // NOLINT + unique_ptr myThreads; // Number of rendering and total threads uInt32 myWorkerThreads{0}, myTotalThreads{0}; struct init_t { - std::array to_rgb{0.F}; + std::array to_rgb{0.F}; float artifacts{0.F}; float fringing{0.F}; - std::array kernel{0.F}; + std::array + (rescale_out * kernel_size * 2)> kernel{0.F}; init_t() { to_rgb.fill(0.0); @@ -213,10 +215,10 @@ class AtariNTSC // 8888: 00000000 RRRRRRRR GGGGGGGG BBBBBBBB (8-8-8-8 32-bit ARGB) #define ATARI_NTSC_RGB_OUT_8888( index, rgb_out ) {\ uInt32 raw_ =\ - kernel0 [index ] + kernel1 [(index+10)%7+14] +\ - kernelx0 [(index+7)%14] + kernelx1 [(index+ 3)%7+14+7];\ + kernel0 [(index) ] + kernel1 [((index)+10)%7+14] +\ + kernelx0 [((index)+7)%14] + kernelx1 [((index)+ 3)%7+14+7];\ ATARI_NTSC_CLAMP( raw_, 0 );\ - rgb_out = (raw_>>5 & 0x00FF0000)|(raw_>>3 & 0x0000FF00)|(raw_>>1 & 0x000000FF);\ + (rgb_out) = (raw_>>5 & 0x00FF0000)|(raw_>>3 & 0x0000FF00)|(raw_>>1 & 0x000000FF);\ } // Common ntsc macros diff --git a/src/common/tv_filters/NTSCFilter.hxx b/src/common/tv_filters/NTSCFilter.hxx index 71ef091d5..6d5b9b08e 100644 --- a/src/common/tv_filters/NTSCFilter.hxx +++ b/src/common/tv_filters/NTSCFilter.hxx @@ -36,10 +36,11 @@ class NTSCFilter { public: NTSCFilter() = default; + ~NTSCFilter() = default; public: // Set one of the available preset adjustments (Composite, S-Video, RGB, etc) - enum class Preset { + enum class Preset: uInt8 { OFF, RGB, SVIDEO, @@ -47,7 +48,7 @@ class NTSCFilter BAD, CUSTOM }; - enum class Adjustables { + enum class Adjustables: uInt8 { SHARPNESS, RESOLUTION, ARTIFACTS, @@ -106,19 +107,19 @@ class NTSCFilter // Perform Blargg filtering on input buffer, place results in // output buffer - inline void render(const uInt8* src_buf, uInt32 src_width, uInt32 src_height, - uInt32* dest_buf, uInt32 dest_pitch) + void render(const uInt8* src_buf, uInt32 src_width, uInt32 src_height, + uInt32* dest_buf, uInt32 dest_pitch) { myNTSC.render(src_buf, src_width, src_height, dest_buf, dest_pitch); } - inline void render(const uInt8* src_buf, uInt32 src_width, uInt32 src_height, - uInt32* dest_buf, uInt32 dest_pitch, uInt32* prev_buf) + void render(const uInt8* src_buf, uInt32 src_width, uInt32 src_height, + uInt32* dest_buf, uInt32 dest_pitch, uInt32* prev_buf) { myNTSC.render(src_buf, src_width, src_height, dest_buf, dest_pitch, prev_buf); } // Enable threading for the NTSC rendering - inline void enableThreading(bool enable) + void enableThreading(bool enable) { myNTSC.enableThreading(enable); } diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index 31ea780cd..4d77aa42e 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -200,7 +200,7 @@ string CartDebug::toString() bytesPerLine = 0x04; break; - case Base::Fmt::_DEFAULT: + case Base::Fmt::DEFAULT: default: return DebuggerParser::red("invalid base, this is a BUG"); } diff --git a/src/debugger/gui/DataGridRamWidget.hxx b/src/debugger/gui/DataGridRamWidget.hxx index f645e8acc..f52f10b49 100644 --- a/src/debugger/gui/DataGridRamWidget.hxx +++ b/src/debugger/gui/DataGridRamWidget.hxx @@ -30,7 +30,7 @@ class DataGridRamWidget : public DataGridWidget const GUI::Font& font, int x, int y, int cols, int rows, int colchars, int bits, - Common::Base::Fmt base = Common::Base::Fmt::_DEFAULT, + Common::Base::Fmt base = Common::Base::Fmt::DEFAULT, bool useScrollbar = false); ~DataGridRamWidget() override = default; diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index 61d5d903f..84e54155a 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -778,7 +778,7 @@ void DataGridWidget::endEditMode() case Common::Base::Fmt::_10: editString().insert(0, 1, '#'); break; - case Common::Base::Fmt::_DEFAULT: + case Common::Base::Fmt::DEFAULT: default: // TODO - properly handle all other cases break; } diff --git a/src/debugger/gui/DataGridWidget.hxx b/src/debugger/gui/DataGridWidget.hxx index cab90d395..554933463 100644 --- a/src/debugger/gui/DataGridWidget.hxx +++ b/src/debugger/gui/DataGridWidget.hxx @@ -43,7 +43,7 @@ class DataGridWidget : public EditableWidget DataGridWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int cols, int rows, int colchars, int bits, - Common::Base::Fmt base = Common::Base::Fmt::_DEFAULT, + Common::Base::Fmt base = Common::Base::Fmt::DEFAULT, bool useScrollbar = false); ~DataGridWidget() override = default; diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index fe5855905..7e881bbd4 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -109,7 +109,7 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& lfont, case Common::Base::Fmt::_10: return (c >= '0' && c <= '9') || c == ' '; - case Common::Base::Fmt::_DEFAULT: + case Common::Base::Fmt::DEFAULT: default: // TODO - properly handle all other cases return false; } diff --git a/src/debugger/gui/RomListWidget.hxx b/src/debugger/gui/RomListWidget.hxx index 54f1fc79a..376d6dc79 100644 --- a/src/debugger/gui/RomListWidget.hxx +++ b/src/debugger/gui/RomListWidget.hxx @@ -103,7 +103,7 @@ class RomListWidget : public EditableWidget int _selectedItem{-1}; int _highlightedItem{-1}; StellaKey _currentKeyDown{KBDK_UNKNOWN}; - Common::Base::Fmt _base{Common::Base::Fmt::_DEFAULT}; // base used during editing + Common::Base::Fmt _base{Common::Base::Fmt::DEFAULT}; // base used during editing const CartDebug::Disassembly* myDisasm{nullptr}; vector myCheckList; diff --git a/src/debugger/gui/RomWidget.cxx b/src/debugger/gui/RomWidget.cxx index 74f6bf3ea..ee1d0bd91 100644 --- a/src/debugger/gui/RomWidget.cxx +++ b/src/debugger/gui/RomWidget.cxx @@ -90,7 +90,7 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) case RomListWidget::kRomChangedCmd: // 'data' is the line in the disassemblylist to be accessed // 'id' is the base to use for the data to be changed - patchROM(data, myRomList->getText(), Common::Base::Fmt{id}); + patchROM(data, myRomList->getText(), Common::Base::Fmt(id)); break; case RomListWidget::kSetPCCmd: diff --git a/src/emucore/EventHandlerConstants.hxx b/src/emucore/EventHandlerConstants.hxx index 4fa1cabbf..0283b5ec5 100644 --- a/src/emucore/EventHandlerConstants.hxx +++ b/src/emucore/EventHandlerConstants.hxx @@ -18,6 +18,8 @@ #ifndef EVENTHANDLER_CONSTANTS_HXX #define EVENTHANDLER_CONSTANTS_HXX +#include + // Enumeration representing the different states of operation enum class EventHandlerState { EMULATION, @@ -93,17 +95,17 @@ enum class EventMode { namespace GUI { #ifdef RETRON77 - static const string SELECT = "Mode"; - static const string LEFT_DIFFICULTY = "P1 skill"; - static const string RIGHT_DIFFICULTY = "P2 skill"; - static const string LEFT_DIFF = "P1 Skill"; - static const string RIGHT_DIFF = "P2 Skill"; + static const std::string SELECT = "Mode"; + static const std::string LEFT_DIFFICULTY = "P1 skill"; + static const std::string RIGHT_DIFFICULTY = "P2 skill"; + static const std::string LEFT_DIFF = "P1 Skill"; + static const std::string RIGHT_DIFF = "P2 Skill"; #else - static const string SELECT = "Select"; - static const string LEFT_DIFFICULTY = "Left difficulty"; - static const string RIGHT_DIFFICULTY = "Right difficulty"; - static const string LEFT_DIFF = "Left Diff"; - static const string RIGHT_DIFF = "Right Diff"; + static const std::string SELECT = "Select"; + static const std::string LEFT_DIFFICULTY = "Left difficulty"; + static const std::string RIGHT_DIFFICULTY = "Right difficulty"; + static const std::string LEFT_DIFF = "Left Diff"; + static const std::string RIGHT_DIFF = "Right Diff"; #endif } diff --git a/src/emucore/Sound.hxx b/src/emucore/Sound.hxx index 5c20de6a9..8c75b4130 100644 --- a/src/emucore/Sound.hxx +++ b/src/emucore/Sound.hxx @@ -118,8 +118,8 @@ class Sound @return True, if the WAV file can be played */ - virtual bool playWav(const string& fileName, const uInt32 position = 0, - const uInt32 length = 0) { return false; } + virtual bool playWav(const string& fileName, uInt32 position = 0, + uInt32 length = 0) { return false; } /** Stop any currently playing WAV file.