From 88c9c15bfad71f12e2832e01705d52e04edf59ce Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Wed, 25 Dec 2019 20:40:01 -0330 Subject: [PATCH] More fixes for warnings from clang-tidy. Mostly converting C-style arrays to C++. --- src/common/FpsMeter.hxx | 2 - src/common/Rect.hxx | 6 --- src/common/SoundNull.hxx | 2 +- src/common/Variant.hxx | 2 +- src/debugger/CartDebug.cxx | 8 ++-- src/debugger/CartDebug.hxx | 8 ++-- src/debugger/TIADebug.cxx | 2 +- src/debugger/gui/RomWidget.cxx | 3 ++ src/debugger/gui/TiaOutputWidget.cxx | 9 ++-- src/debugger/gui/TiaOutputWidget.hxx | 2 +- src/debugger/gui/TiaWidget.cxx | 9 ++++ src/debugger/gui/TiaWidget.hxx | 6 +-- src/debugger/gui/TiaZoomWidget.cxx | 58 ++++++++++++-------------- src/emucore/Event.hxx | 5 +-- src/emucore/FBSurface.cxx | 6 +-- src/emucore/FBSurface.hxx | 6 +-- src/emucore/Props.cxx | 22 +++++----- src/emucore/Props.hxx | 8 ++-- src/emucore/tia/Audio.hxx | 4 +- src/emucore/tia/DelayQueueIterator.hxx | 2 +- src/emucore/tia/DelayQueueMember.hxx | 2 +- src/emucore/tia/TIA.hxx | 4 +- src/gui/AboutDialog.cxx | 5 ++- src/gui/ComboDialog.cxx | 20 ++++----- src/gui/ComboDialog.hxx | 3 +- src/gui/ContextMenu.cxx | 6 +-- src/gui/Dialog.cxx | 3 ++ src/gui/Dialog.hxx | 4 +- src/gui/FileListWidget.hxx | 2 +- src/gui/PopUpWidget.cxx | 2 +- src/gui/TimeMachineDialog.cxx | 2 +- src/gui/UIDialog.cxx | 5 ++- src/gui/Widget.hxx | 4 ++ 33 files changed, 123 insertions(+), 109 deletions(-) diff --git a/src/common/FpsMeter.hxx b/src/common/FpsMeter.hxx index 5e4daf05a..3db95c38d 100644 --- a/src/common/FpsMeter.hxx +++ b/src/common/FpsMeter.hxx @@ -55,12 +55,10 @@ class FpsMeter float myFps; private: - FpsMeter(const FpsMeter&) = delete; FpsMeter(FpsMeter&&) = delete; FpsMeter& operator=(const FpsMeter&) = delete; FpsMeter& operator=(FpsMeter&&) = delete; - }; #endif // FPS_METER_HXX diff --git a/src/common/Rect.hxx b/src/common/Rect.hxx index 51834a79c..393204358 100644 --- a/src/common/Rect.hxx +++ b/src/common/Rect.hxx @@ -36,7 +36,6 @@ struct Point Int32 y; //!< The vertical part of the point Point() : x(0), y(0) { } - Point(const Point& p) : x(p.x), y(p.y) { } explicit Point(Int32 x1, Int32 y1) : x(x1), y(y1) { } explicit Point(const string& p) : x(0), y(0) { char c = '\0'; @@ -45,7 +44,6 @@ struct Point if(c != 'x') x = y = 0; } - Point& operator=(const Point & p) { x = p.x; y = p.y; return *this; } bool operator==(const Point & p) const { return x == p.x && y == p.y; } bool operator!=(const Point & p) const { return x != p.x || y != p.y; } @@ -61,7 +59,6 @@ struct Size uInt32 h; //!< The height part of the size Size() : w(0), h(0) { } - Size(const Size& s) : w(s.w), h(s.h) { } explicit Size(uInt32 w1, uInt32 h1) : w(w1), h(h1) { } explicit Size(const string& s) : w(0), h(0) { char c = '\0'; @@ -72,7 +69,6 @@ struct Size } bool valid() const { return w > 0 && h > 0; } - Size& operator=(const Size& s) { w = s.w; h = s.h; return *this; } bool operator==(const Size& s) const { return w == s.w && h == s.h; } bool operator!=(const Size& s) const { return w != s.w || h != s.h; } bool operator<(const Size& s) const { return w < s.w && h < s.h; } @@ -111,9 +107,7 @@ struct Rect public: Rect() : top(0), left(0), bottom(0), right(0) { assert(valid()); } - Rect(const Rect& s) : top(s.top), left(s.left), bottom(s.bottom), right(s.right) { assert(valid()); } explicit Rect(const Size& s) : top(0), left(0), bottom(s.h), right(s.w) { assert(valid()); } - Rect& operator=(const Rect&) = default; Rect(uInt32 w, uInt32 h) : top(0), left(0), bottom(h), right(w) { assert(valid()); } Rect(const Point& p, uInt32 w, uInt32 h) : top(p.y), left(p.x), bottom(h), right(w) { assert(valid()); } Rect(uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2) : top(y1), left(x1), bottom(y2), right(x2) { assert(valid()); } diff --git a/src/common/SoundNull.hxx b/src/common/SoundNull.hxx index a7f623a5f..e94c164bf 100644 --- a/src/common/SoundNull.hxx +++ b/src/common/SoundNull.hxx @@ -82,7 +82,7 @@ class SoundNull : public Sound @return The previous (old) mute state */ - bool toggleMute() override { } + bool toggleMute() override { return true; } /** Sets the volume of the sound device to the specified level. The diff --git a/src/common/Variant.hxx b/src/common/Variant.hxx index 08b3253ff..a62ca79eb 100644 --- a/src/common/Variant.hxx +++ b/src/common/Variant.hxx @@ -42,7 +42,7 @@ class Variant } public: - Variant() { } + Variant() = default; Variant(const string& s) : data(s) { } Variant(const char* s) : data(s) { } diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index 2d29b6488..10ac78f3a 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -1444,13 +1444,13 @@ void CartDebug::disasmTypeAsString(ostream& buf, uInt8 flags) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const char* const CartDebug::ourTIAMnemonicR[16] = { +std::array CartDebug::ourTIAMnemonicR = { "CXM0P", "CXM1P", "CXP0FB", "CXP1FB", "CXM0FB", "CXM1FB", "CXBLPF", "CXPPMM", "INPT0", "INPT1", "INPT2", "INPT3", "INPT4", "INPT5", "$1e", "$1f" }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const char* const CartDebug::ourTIAMnemonicW[64] = { +std::array CartDebug::ourTIAMnemonicW = { "VSYNC", "VBLANK", "WSYNC", "RSYNC", "NUSIZ0", "NUSIZ1", "COLUP0", "COLUP1", "COLUPF", "COLUBK", "CTRLPF", "REFP0", "REFP1", "PF0", "PF1", "PF2", "RESP0", "RESP1", "RESM0", "RESM1", "RESBL", "AUDC0", "AUDC1", "AUDF0", @@ -1462,7 +1462,7 @@ const char* const CartDebug::ourTIAMnemonicW[64] = { }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const char* const CartDebug::ourIOMnemonic[24] = { +std::array CartDebug::ourIOMnemonic = { "SWCHA", "SWACNT", "SWCHB", "SWBCNT", "INTIM", "TIMINT", "$286", "$287", "$288", "$289", "$28a", "$28b", "$28c", "$28d", "$28e", "$28f", "$290", "$291", "$292", "$293", @@ -1470,7 +1470,7 @@ const char* const CartDebug::ourIOMnemonic[24] = { }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const char* const CartDebug::ourZPMnemonic[128] = { +std::array CartDebug::ourZPMnemonic = { "ram_80", "ram_81", "ram_82", "ram_83", "ram_84", "ram_85", "ram_86", "ram_87", "ram_88", "ram_89", "ram_8A", "ram_8B", "ram_8C", "ram_8D", "ram_8E", "ram_8F", "ram_90", "ram_91", "ram_92", "ram_93", "ram_94", "ram_95", "ram_96", "ram_97", diff --git a/src/debugger/CartDebug.hxx b/src/debugger/CartDebug.hxx index 84bc29975..cd37a42d1 100644 --- a/src/debugger/CartDebug.hxx +++ b/src/debugger/CartDebug.hxx @@ -352,10 +352,10 @@ class CartDebug : public DebuggerSystem string myListFile, mySymbolFile, myCfgFile, myDisasmFile, myRomFile; /// Table of instruction mnemonics - static const char* const ourTIAMnemonicR[16]; // read mode - static const char* const ourTIAMnemonicW[64]; // write mode - static const char* const ourIOMnemonic[24]; - static const char* const ourZPMnemonic[128]; + static std::array ourTIAMnemonicR; // read mode + static std::array ourTIAMnemonicW; // write mode + static std::array ourIOMnemonic; + static std::array ourZPMnemonic; private: // Following constructors and assignment operators not supported diff --git a/src/debugger/TIADebug.cxx b/src/debugger/TIADebug.cxx index 421faabaf..b4ca55cb5 100644 --- a/src/debugger/TIADebug.cxx +++ b/src/debugger/TIADebug.cxx @@ -433,7 +433,7 @@ bool TIADebug::collision(CollisionBit id, bool toggle) const case CollisionBit::M1P1: if(toggle) myTIA.toggleCollP1M1(); - return myTIA.collCXM1P() & 0x40; + return myTIA.collCXM1P() & 0x40; case CollisionBit::P0PF: if(toggle) diff --git a/src/debugger/gui/RomWidget.cxx b/src/debugger/gui/RomWidget.cxx index 1934c8ef0..adeded043 100644 --- a/src/debugger/gui/RomWidget.cxx +++ b/src/debugger/gui/RomWidget.cxx @@ -159,6 +159,9 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) DiStella::settings.rFlag); invalidate(); break; + + default: + break; } } diff --git a/src/debugger/gui/TiaOutputWidget.cxx b/src/debugger/gui/TiaOutputWidget.cxx index 4e75a87ea..1ab2cc77f 100644 --- a/src/debugger/gui/TiaOutputWidget.cxx +++ b/src/debugger/gui/TiaOutputWidget.cxx @@ -161,6 +161,9 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in } break; } + + default: + break; } } @@ -186,7 +189,7 @@ void TiaOutputWidget::drawWidget(bool hilite) for(uInt32 y = 0, i = 0; y < height; ++y) { - uInt32* line_ptr = myLineBuffer; + uInt32* line_ptr = myLineBuffer.data(); for(uInt32 x = 0; x < width; ++x, ++i) { uInt8 shift = i >= scanoffset ? 1 : 0; @@ -194,10 +197,10 @@ void TiaOutputWidget::drawWidget(bool hilite) *line_ptr++ = pixel; *line_ptr++ = pixel; } - s.drawPixels(myLineBuffer, _x + 1, _y + 1 + y, width << 1); + s.drawPixels(myLineBuffer.data(), _x + 1, _y + 1 + y, width << 1); } // Show electron beam position - if(visible && scanx < width && scany+2u < height) + if(visible && scanx < width && scany+2U < height) s.fillRect(_x + 1 + (scanx<<1), _y + 1 + scany, 3, 3, kColorInfo); } diff --git a/src/debugger/gui/TiaOutputWidget.hxx b/src/debugger/gui/TiaOutputWidget.hxx index 2875e46e3..3b2177372 100644 --- a/src/debugger/gui/TiaOutputWidget.hxx +++ b/src/debugger/gui/TiaOutputWidget.hxx @@ -55,7 +55,7 @@ class TiaOutputWidget : public Widget, public CommandSender // Create this buffer once, instead of allocating it each time the // TIA image is redrawn - uInt32 myLineBuffer[320]; + std::array myLineBuffer; private: void handleMouseDown(int x, int y, MouseButton b, int clickCount) override; diff --git a/src/debugger/gui/TiaWidget.cxx b/src/debugger/gui/TiaWidget.cxx index 530b37947..d3d2e090d 100644 --- a/src/debugger/gui/TiaWidget.cxx +++ b/src/debugger/gui/TiaWidget.cxx @@ -819,6 +819,9 @@ void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) case kPF2ID: tia.pf2(myPF[2]->getIntState()); break; + + default: + break; } break; @@ -922,8 +925,14 @@ void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) case kPriorityPFID: tia.priorityPF(myPriorityPF->getState() ? 1 : 0); break; + + default: + break; } break; + + default: + break; } } diff --git a/src/debugger/gui/TiaWidget.hxx b/src/debugger/gui/TiaWidget.hxx index c40d5d140..ba4100e5b 100644 --- a/src/debugger/gui/TiaWidget.hxx +++ b/src/debugger/gui/TiaWidget.hxx @@ -47,7 +47,7 @@ class TiaWidget : public Widget, public CommandSender ColorWidget* myCOLUBKColor; CheckboxWidget* myFixedEnabled; - ColorWidget* myFixedColors[8]; + std::array myFixedColors; TogglePixelWidget* myGRP0; TogglePixelWidget* myGRP0Old; @@ -89,9 +89,9 @@ class TiaWidget : public Widget, public CommandSender CheckboxWidget* myResMP1; /** Collision register bits */ - CheckboxWidget* myCollision[15]; + std::array myCollision; - TogglePixelWidget* myPF[3]; + std::array myPF; CheckboxWidget* myRefPF; CheckboxWidget* myScorePF; CheckboxWidget* myPriorityPF; diff --git a/src/debugger/gui/TiaZoomWidget.cxx b/src/debugger/gui/TiaZoomWidget.cxx index ebc88ce27..bdaaa0102 100644 --- a/src/debugger/gui/TiaZoomWidget.cxx +++ b/src/debugger/gui/TiaZoomWidget.cxx @@ -15,6 +15,8 @@ // this file, and for a DISCLAIMER OF ALL WARRANTIES. //============================================================================ +#include + #include "OSystem.hxx" #include "Console.hxx" #include "Debugger.hxx" @@ -25,8 +27,6 @@ #include "Widget.hxx" #include "GuiObject.hxx" #include "ContextMenu.hxx" -#include - #include "TiaZoomWidget.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -245,42 +245,38 @@ bool TiaZoomWidget::handleEvent(Event::Type event) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TiaZoomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) { - switch(cmd) + if(cmd == ContextMenu::kItemSelectedCmd) { - case ContextMenu::kItemSelectedCmd: + uInt32 startLine = instance().console().tia().startLine(); + const string& rmb = myMenu->getSelectedTag().toString(); + + if(rmb == "scanline") { - uInt32 startLine = instance().console().tia().startLine(); - const string& rmb = myMenu->getSelectedTag().toString(); + ostringstream command; + int lines = myClickY / myZoomLevel + myOffY + startLine - instance().console().tia().scanlines(); - if(rmb == "scanline") + if (lines < 0) + lines += instance().console().tia().scanlinesLastFrame(); + if(lines > 0) { - ostringstream command; - int lines = myClickY / myZoomLevel + myOffY + startLine - instance().console().tia().scanlines(); - - if (lines < 0) - lines += instance().console().tia().scanlinesLastFrame(); - if(lines > 0) - { - command << "scanline #" << lines; - string message = instance().debugger().parser().run(command.str()); - instance().frameBuffer().showMessage(message); - } - } - else if(rmb == "bp") - { - ostringstream command; - int scanline = myClickY / myZoomLevel + myOffY + startLine; - command << "breakif _scan==#" << scanline; + command << "scanline #" << lines; string message = instance().debugger().parser().run(command.str()); instance().frameBuffer().showMessage(message); } - else - { - int level = myMenu->getSelectedTag().toInt(); - if(level > 0) - zoom(level); - } - break; + } + else if(rmb == "bp") + { + ostringstream command; + int scanline = myClickY / myZoomLevel + myOffY + startLine; + command << "breakif _scan==#" << scanline; + string message = instance().debugger().parser().run(command.str()); + instance().frameBuffer().showMessage(message); + } + else + { + int level = myMenu->getSelectedTag().toInt(); + if(level > 0) + zoom(level); } } } diff --git a/src/emucore/Event.hxx b/src/emucore/Event.hxx index 6c7d62884..2fea72dd8 100644 --- a/src/emucore/Event.hxx +++ b/src/emucore/Event.hxx @@ -171,8 +171,7 @@ class Event { std::lock_guard lock(myMutex); - for(Int32 i = 0; i < LastType; ++i) - myValues[i] = Event::NoType; + myValues.fill(Event::NoType); } /** @@ -194,7 +193,7 @@ class Event private: // Array of values associated with each event type - Int32 myValues[LastType]; + std::array myValues; mutable std::mutex myMutex; diff --git a/src/emucore/FBSurface.cxx b/src/emucore/FBSurface.cxx index a837d1c24..f9f57cb7e 100644 --- a/src/emucore/FBSurface.cxx +++ b/src/emucore/FBSurface.cxx @@ -227,14 +227,14 @@ void FBSurface::drawChar(const GUI::Font& font, uInt8 chr, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FBSurface::drawBitmap(uInt32* bitmap, uInt32 tx, uInt32 ty, +void FBSurface::drawBitmap(const uInt32* bitmap, uInt32 tx, uInt32 ty, ColorId color, uInt32 h) { drawBitmap(bitmap, tx, ty, color, h, h); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FBSurface::drawBitmap(uInt32* bitmap, uInt32 tx, uInt32 ty, +void FBSurface::drawBitmap(const uInt32* bitmap, uInt32 tx, uInt32 ty, ColorId color, uInt32 w, uInt32 h) { if(!checkBounds(tx, ty) || !checkBounds(tx + w - 1, ty + h - 1)) @@ -254,7 +254,7 @@ void FBSurface::drawBitmap(uInt32* bitmap, uInt32 tx, uInt32 ty, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FBSurface::drawPixels(uInt32* data, uInt32 tx, uInt32 ty, uInt32 numpixels) +void FBSurface::drawPixels(const uInt32* data, uInt32 tx, uInt32 ty, uInt32 numpixels) { if(!checkBounds(tx, ty) || !checkBounds(tx + numpixels - 1, ty)) return; diff --git a/src/emucore/FBSurface.hxx b/src/emucore/FBSurface.hxx index 6528a50a7..d3eb5d35d 100644 --- a/src/emucore/FBSurface.hxx +++ b/src/emucore/FBSurface.hxx @@ -148,7 +148,7 @@ class FBSurface @param color The color of the bitmap @param h The height of the data image */ - virtual void drawBitmap(uInt32* bitmap, uInt32 x, uInt32 y, ColorId color, + virtual void drawBitmap(const uInt32* bitmap, uInt32 x, uInt32 y, ColorId color, uInt32 h = 8); /** @@ -161,7 +161,7 @@ class FBSurface @param w The width of the data image @param h The height of the data image */ - virtual void drawBitmap(uInt32* bitmap, uInt32 x, uInt32 y, ColorId color, + virtual void drawBitmap(const uInt32* bitmap, uInt32 x, uInt32 y, ColorId color, uInt32 w, uInt32 h); /** @@ -174,7 +174,7 @@ class FBSurface @param y The destination y-location to start drawing pixels @param numpixels The number of pixels to draw */ - virtual void drawPixels(uInt32* data, uInt32 x, uInt32 y, uInt32 numpixels); + virtual void drawPixels(const uInt32* data, uInt32 x, uInt32 y, uInt32 numpixels); /** This method should be called to draw a rectangular box with sides diff --git a/src/emucore/Props.cxx b/src/emucore/Props.cxx index 4fabfcafd..749b088c1 100644 --- a/src/emucore/Props.cxx +++ b/src/emucore/Props.cxx @@ -35,8 +35,8 @@ Properties::Properties(const Properties& properties) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Properties::set(PropType key, const string& value) { - uInt8 pos = static_cast(key); - if(pos < static_cast(PropType::NumTypes)) + size_t pos = static_cast(key); + if(pos < myProperties.size()) { myProperties[pos] = value; if(BSPF::equalsIgnoreCase(myProperties[pos], "AUTO-DETECT")) @@ -115,7 +115,7 @@ ostream& operator<<(ostream& os, const Properties& p) { // Write out each of the key and value pairs bool changed = false; - for(uInt8 i = 0; i < static_cast(PropType::NumTypes); ++i) + for(size_t i = 0; i < static_cast(PropType::NumTypes); ++i) { // Try to save some space by only saving the items that differ from default if(p.myProperties[i] != Properties::ourDefaultProperties[i]) @@ -192,7 +192,7 @@ void Properties::writeQuotedString(ostream& out, const string& s) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Properties::operator==(const Properties& properties) const { - for(uInt8 i = 0; i < static_cast(PropType::NumTypes); ++i) + for(size_t i = 0; i < myProperties.size(); ++i) if(myProperties[i] != properties.myProperties[i]) return false; @@ -221,14 +221,14 @@ Properties& Properties::operator=(const Properties& properties) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Properties::setDefault(PropType key, const string& value) { - ourDefaultProperties[static_cast(key)] = value; + ourDefaultProperties[static_cast(key)] = value; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Properties::copy(const Properties& properties) { // Now, copy each property from properties - for(uInt8 i = 0; i < static_cast(PropType::NumTypes); ++i) + for(size_t i = 0; i < myProperties.size(); ++i) myProperties[i] = properties.myProperties[i]; } @@ -262,16 +262,16 @@ void Properties::print() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Properties::setDefaults() { - for(uInt8 i = 0; i < static_cast(PropType::NumTypes); ++i) + for(size_t i = 0; i < myProperties.size(); ++i) myProperties[i] = ourDefaultProperties[i]; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PropType Properties::getPropType(const string& name) { - for(uInt8 i = 0; i < static_cast(PropType::NumTypes); ++i) + for(size_t i = 0; i < NUM_PROPS; ++i) if(ourPropertyNames[i] == name) - return PropType(i); + return static_cast(i); // Otherwise, indicate that the item wasn't found return PropType::NumTypes; @@ -305,7 +305,7 @@ void Properties::printHeader() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string Properties::ourDefaultProperties[static_cast(PropType::NumTypes)] = +std::array Properties::ourDefaultProperties = { "", // Cart.MD5 "", // Cart.Manufacturer @@ -331,7 +331,7 @@ string Properties::ourDefaultProperties[static_cast(PropType::NumTypes)] }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const char* const Properties::ourPropertyNames[static_cast(PropType::NumTypes)] = +std::array Properties::ourPropertyNames = { "Cart.MD5", "Cart.Manufacturer", diff --git a/src/emucore/Props.hxx b/src/emucore/Props.hxx index 76ae85952..757523dd8 100644 --- a/src/emucore/Props.hxx +++ b/src/emucore/Props.hxx @@ -188,14 +188,16 @@ class Properties static void printHeader(); private: + static constexpr size_t NUM_PROPS = static_cast(PropType::NumTypes); + // The array of properties - string myProperties[static_cast(PropType::NumTypes)]; + std::array myProperties; // List of default properties to use when none have been provided - static string ourDefaultProperties[static_cast(PropType::NumTypes)]; + static std::array ourDefaultProperties; // The text strings associated with each property type - static const char* const ourPropertyNames[static_cast(PropType::NumTypes)]; + static std::array ourPropertyNames; }; #endif diff --git a/src/emucore/tia/Audio.hxx b/src/emucore/tia/Audio.hxx index 8494c7934..7901dff86 100644 --- a/src/emucore/tia/Audio.hxx +++ b/src/emucore/tia/Audio.hxx @@ -56,8 +56,8 @@ class Audio : public Serializable AudioChannel myChannel0; AudioChannel myChannel1; - Int16 myMixingTableSum[0x1e + 1]; - Int16 myMixingTableIndividual[0x0f + 1]; + std::array myMixingTableSum; + std::array myMixingTableIndividual; Int16* myCurrentFragment; uInt32 mySampleIndex; diff --git a/src/emucore/tia/DelayQueueIterator.hxx b/src/emucore/tia/DelayQueueIterator.hxx index 73ef7930f..4bbc47577 100644 --- a/src/emucore/tia/DelayQueueIterator.hxx +++ b/src/emucore/tia/DelayQueueIterator.hxx @@ -25,7 +25,7 @@ class DelayQueueIterator { public: - virtual ~DelayQueueIterator() {} + virtual ~DelayQueueIterator() = default; public: virtual bool isValid() const = 0; diff --git a/src/emucore/tia/DelayQueueMember.hxx b/src/emucore/tia/DelayQueueMember.hxx index 90a381e1a..700133182 100644 --- a/src/emucore/tia/DelayQueueMember.hxx +++ b/src/emucore/tia/DelayQueueMember.hxx @@ -49,7 +49,7 @@ class DelayQueueMember : public Serializable { bool load(Serializer& in) override; public: - Entry myEntries[capacity]; + std::array myEntries; uInt8 mySize; private: diff --git a/src/emucore/tia/TIA.hxx b/src/emucore/tia/TIA.hxx index e6d79faeb..c95f397fa 100644 --- a/src/emucore/tia/TIA.hxx +++ b/src/emucore/tia/TIA.hxx @@ -123,7 +123,7 @@ class TIA : public Device /** Configure the frame manager. */ - void setFrameManager(AbstractFrameManager *frameManager); + void setFrameManager(AbstractFrameManager* frameManager); /** Set the audio queue. This needs to be dynamic as the queue is created after @@ -540,7 +540,7 @@ class TIA : public Device */ enum FixedObject { P0, M0, P1, M1, PF, BL, BK }; FixedColor myFixedColorPalette[3][7]; - string myFixedColorNames[7]; + std::array myFixedColorNames; private: /** diff --git a/src/gui/AboutDialog.cxx b/src/gui/AboutDialog.cxx index 8ddf1038c..47154b4ee 100644 --- a/src/gui/AboutDialog.cxx +++ b/src/gui/AboutDialog.cxx @@ -73,7 +73,7 @@ AboutDialog::AboutDialog(OSystem& osystem, DialogContainer& parent, { myDesc.push_back(new StaticTextWidget(this, font, xpos, ypos, _w - xpos * 2, fontHeight, "", TextAlign::Left)); - myDescStr.push_back(""); + myDescStr.emplace_back(""); ypos += fontHeight; } @@ -152,6 +152,9 @@ void AboutDialog::updateStrings(int page, int lines, string& title) ADD_ATEXT("\\L\\c0""VCS team for giving us the magic, and to the"); ADD_ATEXT("\\L\\c0""homebrew developers for keeping the magic alive."); break; + + default: + return; } while(i < lines) diff --git a/src/gui/ComboDialog.cxx b/src/gui/ComboDialog.cxx index 083c60141..4f887bc41 100644 --- a/src/gui/ComboDialog.cxx +++ b/src/gui/ComboDialog.cxx @@ -49,6 +49,7 @@ ComboDialog::ComboDialog(GuiObject* boss, const GUI::Font& font, ypos = 10 + _th; // Add event popup for 8 events + myEvents.fill(nullptr); auto ADD_EVENT_POPUP = [&](int idx, const string& label) { myEvents[idx] = new PopUpWidget(this, font, xpos, ypos, @@ -56,15 +57,14 @@ ComboDialog::ComboDialog(GuiObject* boss, const GUI::Font& font, wid.push_back(myEvents[idx]); ypos += lineHeight + 4; }; - - myEvents[0] = nullptr; ADD_EVENT_POPUP(0, "Event 1 "); - myEvents[1] = nullptr; ADD_EVENT_POPUP(1, "Event 2 "); - myEvents[2] = nullptr; ADD_EVENT_POPUP(2, "Event 3 "); - myEvents[3] = nullptr; ADD_EVENT_POPUP(3, "Event 4 "); - myEvents[4] = nullptr; ADD_EVENT_POPUP(4, "Event 5 "); - myEvents[5] = nullptr; ADD_EVENT_POPUP(5, "Event 6 "); - myEvents[6] = nullptr; ADD_EVENT_POPUP(6, "Event 7 "); - myEvents[7] = nullptr; ADD_EVENT_POPUP(7, "Event 8 "); + ADD_EVENT_POPUP(0, "Event 1 "); + ADD_EVENT_POPUP(1, "Event 2 "); + ADD_EVENT_POPUP(2, "Event 3 "); + ADD_EVENT_POPUP(3, "Event 4 "); + ADD_EVENT_POPUP(4, "Event 5 "); + ADD_EVENT_POPUP(5, "Event 6 "); + ADD_EVENT_POPUP(6, "Event 7 "); + ADD_EVENT_POPUP(7, "Event 8 "); // Add Defaults, OK and Cancel buttons addDefaultsOKCancelBGroup(wid, font); @@ -91,7 +91,7 @@ void ComboDialog::loadConfig() { StringList events = instance().eventHandler().getComboListForEvent(myComboEvent); - uInt32 size = std::min(uInt32(events.size()), 8u); + uInt32 size = std::min(events.size(), 8); for(uInt32 i = 0; i < size; ++i) myEvents[i]->setSelected("", events[i]); diff --git a/src/gui/ComboDialog.hxx b/src/gui/ComboDialog.hxx index aa89ea437..7787a4682 100644 --- a/src/gui/ComboDialog.hxx +++ b/src/gui/ComboDialog.hxx @@ -44,8 +44,7 @@ class ComboDialog : public Dialog private: Event::Type myComboEvent; - - PopUpWidget* myEvents[8]; + std::array myEvents; private: // Following constructors and assignment operators not supported diff --git a/src/gui/ContextMenu.cxx b/src/gui/ContextMenu.cxx index d91a6ca51..81d2d226a 100644 --- a/src/gui/ContextMenu.cxx +++ b/src/gui/ContextMenu.cxx @@ -102,7 +102,7 @@ void ContextMenu::recalc(const Common::Rect& image) { // Now is the time to adjust the height // If it's higher than the screen, we need to scroll through - uInt32 maxentries = std::min(18u, (image.h() - 2) / _rowHeight); + uInt32 maxentries = std::min(18, (image.h() - 2) / _rowHeight); if(_entries.size() > maxentries) { // We show two less than the max, so we have room for two scroll buttons @@ -521,7 +521,7 @@ void ContextMenu::scrollDown(int distance) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ContextMenu::drawDialog() { - static uInt32 up_arrow[8] = { + static constexpr uInt32 up_arrow[8] = { 0b00011000, 0b00011000, 0b00111100, @@ -531,7 +531,7 @@ void ContextMenu::drawDialog() 0b11111111, 0b11111111 }; - static uInt32 down_arrow[8] = { + static constexpr uInt32 down_arrow[8] = { 0b11111111, 0b11111111, 0b01111110, diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 777d96029..745a190ab 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -759,6 +759,9 @@ void Dialog::handleCommand(CommandSender* sender, int cmd, int data, int id) case GuiObject::kCloseCmd: close(); break; + + default: + break; } } diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index 1063b32eb..8b07ab325 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -126,7 +126,7 @@ class Dialog : public GuiObject bool shouldResize(uInt32& w, uInt32& h) const; protected: - virtual void draw() override { } + void draw() override { } void releaseFocus() override; virtual void handleText(char text); @@ -141,7 +141,7 @@ class Dialog : public GuiObject virtual void handleJoyUp(int stick, int button); virtual void handleJoyAxis(int stick, JoyAxis axis, JoyDir adir, int button = JOY_CTRL_NONE); virtual bool handleJoyHat(int stick, int hat, JoyHatDir hdir, int button = JOY_CTRL_NONE); - virtual void handleCommand(CommandSender* sender, int cmd, int data, int id) override; + void handleCommand(CommandSender* sender, int cmd, int data, int id) override; virtual Event::Type getJoyAxisEvent(int stick, JoyAxis axis, JoyDir adir, int button); Widget* findWidget(int x, int y) const; // Find the widget at pos x,y if any diff --git a/src/gui/FileListWidget.hxx b/src/gui/FileListWidget.hxx index d7a0310d4..6aebefa0c 100644 --- a/src/gui/FileListWidget.hxx +++ b/src/gui/FileListWidget.hxx @@ -74,7 +74,7 @@ class FileListWidget : public StringListWidget /** Gets current node(s) */ const FilesystemNode& selected() { - _selected = BSPF::clamp(_selected, 0u, uInt32(_fileList.size()-1)); + _selected = BSPF::clamp(_selected, 0U, uInt32(_fileList.size()-1)); return _fileList[_selected]; } const FilesystemNode& currentDir() const { return _node; } diff --git a/src/gui/PopUpWidget.cxx b/src/gui/PopUpWidget.cxx index f78e0a581..7999414c0 100644 --- a/src/gui/PopUpWidget.cxx +++ b/src/gui/PopUpWidget.cxx @@ -213,7 +213,7 @@ void PopUpWidget::drawWidget(bool hilite) s.fillRect(x + w - 15, _y + 2, 13, _h - 4, onTop ? isEnabled() && hilite ? kWidColor : kBGColorHi : kBGColorLo); // Draw an arrow pointing down at the right end to signal this is a dropdown/popup s.drawBitmap(down_arrow, x + w - 13, _y + myArrowsY + 1, - !(isEnabled() && onTop) ? kColor : kTextColor, 9u, 8u); + !(isEnabled() && onTop) ? kColor : kTextColor, 9U, 8U); // Draw the selected entry, if any const string& name = myMenu->getSelectedName(); diff --git a/src/gui/TimeMachineDialog.cxx b/src/gui/TimeMachineDialog.cxx index 178ed52d1..4892c1885 100644 --- a/src/gui/TimeMachineDialog.cxx +++ b/src/gui/TimeMachineDialog.cxx @@ -420,7 +420,7 @@ void TimeMachineDialog::initBar() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string TimeMachineDialog::getTimeString(uInt64 cycles) { - const Int32 scanlines = std::max(instance().console().tia().scanlinesLastFrame(), 240u); + const Int32 scanlines = std::max(instance().console().tia().scanlinesLastFrame(), 240); const bool isNTSC = scanlines <= 287; const Int32 NTSC_FREQ = 1193182; // ~76*262*60 const Int32 PAL_FREQ = 1182298; // ~76*312*50 diff --git a/src/gui/UIDialog.cxx b/src/gui/UIDialog.cxx index 7e432969c..e8fd359dc 100644 --- a/src/gui/UIDialog.cxx +++ b/src/gui/UIDialog.cxx @@ -16,6 +16,7 @@ //============================================================================ #include "bspf.hxx" +#include "DialogContainer.hxx" #include "BrowserDialog.hxx" #include "Dialog.hxx" #include "OSystem.hxx" @@ -438,8 +439,8 @@ void UIDialog::setDefaults() { FilesystemNode node("~"); myRomPath->setText(node.getShortPath()); - uInt32 w = std::min(instance().frameBuffer().desktopSize().w, 900u); - uInt32 h = std::min(instance().frameBuffer().desktopSize().h, 600u); + uInt32 w = std::min(instance().frameBuffer().desktopSize().w, 900); + uInt32 h = std::min(instance().frameBuffer().desktopSize().h, 600); myLauncherWidthSlider->setValue(w); myLauncherHeightSlider->setValue(h); myLauncherFontPopup->setSelected("medium", ""); diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 15f575538..cd09f57c5 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -188,6 +188,7 @@ class StaticTextWidget : public Widget int x, int y, const string& text = "", TextAlign align = TextAlign::Left, ColorId shadowColor = kNone); + virtual ~StaticTextWidget() = default; void setValue(int value); void setLabel(const string& label); void setAlign(TextAlign align) { _align = align; setDirty(); } @@ -228,6 +229,7 @@ class ButtonWidget : public StaticTextWidget, public CommandSender int x, int y, int dw, int dh, uInt32* bitmap, int bmw, int bmh, int cmd = 0, bool repeat = false); + virtual ~ButtonWidget() = default; void setCmd(int cmd) { _cmd = cmd; } int getCmd() const { return _cmd; } @@ -270,6 +272,7 @@ class CheckboxWidget : public ButtonWidget public: CheckboxWidget(GuiObject* boss, const GUI::Font& font, int x, int y, const string& label, int cmd = 0); + virtual ~CheckboxWidget() = default; void setEditable(bool editable); void setFill(FillType type); @@ -319,6 +322,7 @@ class SliderWidget : public ButtonWidget int x, int y, const string& label = "", int labelWidth = 0, int cmd = 0, int valueLabelWidth = 0, const string& valueUnit = "", int valueLabelGap = 4); + virtual ~SliderWidget() = default; void setValue(int value); int getValue() const { return _value; }