mirror of
https://github.com/libretro/stella2023.git
synced 2024-12-02 14:46:32 +00:00
Implemented suggestions from various linting tools.
This commit is contained in:
parent
13c2eaeff1
commit
72c88d27a9
@ -67,7 +67,7 @@ class PNGLibrary
|
||||
more detailed error message.
|
||||
*/
|
||||
void saveImage(const string& filename,
|
||||
const VariantList& comments = EmptyVarList);
|
||||
const VariantList& comments = VariantList{});
|
||||
|
||||
/**
|
||||
Save the given surface to a PNG file.
|
||||
@ -82,8 +82,8 @@ class PNGLibrary
|
||||
more detailed error message.
|
||||
*/
|
||||
void saveImage(const string& filename, const FBSurface& surface,
|
||||
const Common::Rect& rect = Common::EmptyRect,
|
||||
const VariantList& comments = EmptyVarList);
|
||||
const Common::Rect& rect = Common::Rect{},
|
||||
const VariantList& comments = VariantList{});
|
||||
|
||||
/**
|
||||
Called at regular intervals, and used to determine whether a
|
||||
|
@ -35,7 +35,7 @@ struct Point
|
||||
Int32 x{0}; //!< The horizontal part of the point
|
||||
Int32 y{0}; //!< The vertical part of the point
|
||||
|
||||
Point() = default;
|
||||
constexpr Point() = default;
|
||||
explicit constexpr Point(Int32 x1, Int32 y1) : x{x1}, y{y1} { }
|
||||
explicit Point(const string& p) {
|
||||
char c = '\0';
|
||||
@ -58,7 +58,7 @@ struct Size
|
||||
uInt32 w{0}; //!< The width part of the size
|
||||
uInt32 h{0}; //!< The height part of the size
|
||||
|
||||
Size() = default;
|
||||
constexpr Size() = default;
|
||||
explicit constexpr Size(uInt32 w1, uInt32 h1) : w{w1}, h{h1} { }
|
||||
explicit Size(const string& s) {
|
||||
char c = '\0';
|
||||
@ -69,7 +69,7 @@ struct Size
|
||||
}
|
||||
constexpr bool valid() const { return w > 0 && h > 0; }
|
||||
|
||||
void clamp(uInt32 lower_w, uInt32 upper_w, uInt32 lower_h, uInt32 upper_h) {
|
||||
constexpr void clamp(uInt32 lower_w, uInt32 upper_w, uInt32 lower_h, uInt32 upper_h) {
|
||||
w = BSPF::clamp(w, lower_w, upper_w);
|
||||
h = BSPF::clamp(h, lower_h, upper_h);
|
||||
}
|
||||
@ -113,7 +113,7 @@ private:
|
||||
uInt32 bottom{0}, right{0};
|
||||
|
||||
public:
|
||||
Rect() {}
|
||||
constexpr Rect() = default;
|
||||
constexpr explicit Rect(const Size& s) : bottom{ s.h }, right{ s.w } { assert(valid()); }
|
||||
constexpr Rect(uInt32 w, uInt32 h) : bottom{ h }, right{ w } { assert(valid()); }
|
||||
constexpr Rect(const Point& p, uInt32 w, uInt32 h)
|
||||
@ -186,9 +186,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
static const Rect EmptyRect;
|
||||
|
||||
} // End of namespace Common
|
||||
|
||||
#endif
|
||||
|
@ -27,32 +27,32 @@
|
||||
*/
|
||||
namespace Common {
|
||||
|
||||
template <typename T, uInt32 CAPACITY = 50>
|
||||
template <typename T, size_t CAPACITY = 50>
|
||||
class FixedStack
|
||||
{
|
||||
private:
|
||||
std::array<T, CAPACITY> _stack;
|
||||
uInt32 _size{0};
|
||||
size_t _size{0};
|
||||
|
||||
public:
|
||||
using StackFunction = std::function<void(T&)>;
|
||||
|
||||
FixedStack<T, CAPACITY>() { }
|
||||
FixedStack<T, CAPACITY>() = default;
|
||||
|
||||
bool empty() const { return _size <= 0; }
|
||||
bool empty() const { return _size == 0; }
|
||||
bool full() const { return _size >= CAPACITY; }
|
||||
|
||||
T top() const { return _stack[_size - 1]; }
|
||||
T get(uInt32 pos) const { return _stack[pos]; }
|
||||
void push(const T& x) { _stack[_size++] = x; }
|
||||
T pop() { return std::move(_stack[--_size]); }
|
||||
uInt32 size() const { return _size; }
|
||||
T top() const { return _stack[_size - 1]; }
|
||||
T get(size_t pos) const { return _stack[pos]; }
|
||||
void push(const T& x) { _stack[_size++] = x; }
|
||||
T pop() { return std::move(_stack[--_size]); }
|
||||
size_t size() const { return _size; }
|
||||
|
||||
// Reverse the contents of the stack
|
||||
// This operation isn't needed very often, but it's handy to have
|
||||
void reverse() {
|
||||
if(_size > 1)
|
||||
for(uInt32 i = 0, j = _size - 1; i < j; ++i, --j)
|
||||
for(size_t i = 0, j = _size - 1; i < j; ++i, --j)
|
||||
std::swap(_stack[i], _stack[j]);
|
||||
}
|
||||
|
||||
@ -61,12 +61,12 @@ class FixedStack
|
||||
// and no access to individual elements is allowed outside
|
||||
// the class.
|
||||
void applyAll(const StackFunction& func) {
|
||||
for(uInt32 i = 0; i < _size; ++i)
|
||||
for(size_t i = 0; i < _size; ++i)
|
||||
func(_stack[i]);
|
||||
}
|
||||
|
||||
friend ostream& operator<<(ostream& os, const FixedStack<T>& s) {
|
||||
for(uInt32 pos = 0; pos < s._size; ++pos)
|
||||
for(size_t pos = 0; pos < s._size; ++pos)
|
||||
os << s._stack[pos] << " ";
|
||||
return os;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class Variant
|
||||
}
|
||||
|
||||
public:
|
||||
Variant() { } // NOLINT
|
||||
Variant() = default; // NOLINT
|
||||
|
||||
Variant(const string& s) : data{s} { }
|
||||
Variant(const char* s) : data{s} { }
|
||||
@ -93,13 +93,10 @@ using VariantList = vector<std::pair<string,Variant>>;
|
||||
|
||||
namespace VarList {
|
||||
inline void push_back(VariantList& list, const Variant& name,
|
||||
const Variant& tag = EmptyVariant)
|
||||
const Variant& tag = Variant{})
|
||||
{
|
||||
list.emplace_back(name.toString(), tag);
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
static const VariantList EmptyVarList;
|
||||
|
||||
#endif
|
||||
|
@ -155,15 +155,15 @@ namespace BSPF
|
||||
|
||||
// Combines 'max' and 'min', and clamps value to the upper/lower value
|
||||
// if it is outside the specified range
|
||||
template<typename T> inline T clamp(T val, T lower, T upper)
|
||||
template<typename T> inline constexpr T clamp(T val, T lower, T upper)
|
||||
{
|
||||
return (val < lower) ? lower : (val > upper) ? upper : val;
|
||||
}
|
||||
template<typename T> inline void clamp(T& val, T lower, T upper, T setVal)
|
||||
template<typename T> inline constexpr void clamp(T& val, T lower, T upper, T setVal)
|
||||
{
|
||||
if(val < lower || val > upper) val = setVal;
|
||||
}
|
||||
template<typename T> inline T clampw(T val, T lower, T upper)
|
||||
template<typename T> inline constexpr T clampw(T val, T lower, T upper)
|
||||
{
|
||||
return (val < lower) ? upper : (val > upper) ? lower : val;
|
||||
}
|
||||
|
@ -1021,7 +1021,7 @@ string TIADebug::audFreq1()
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string TIADebug::audFreq(uInt8 dist, uInt8 div)
|
||||
{
|
||||
constexpr uInt16 dist_div[16] = {
|
||||
static constexpr uInt16 dist_div[16] = {
|
||||
1, 15, 465, 465, 2, 2, 31, 31,
|
||||
511, 31, 31, 1, 6, 6, 93, 93
|
||||
};
|
||||
|
@ -92,7 +92,7 @@ bool Bankswitch::isValidRomName(const string& name)
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const std::array<Bankswitch::Description, static_cast<int>(Bankswitch::Type::NumSchemes)>
|
||||
constexpr std::array<Bankswitch::Description, static_cast<int>(Bankswitch::Type::NumSchemes)>
|
||||
Bankswitch::BSList = {{
|
||||
{ "AUTO" , "Auto-detect" },
|
||||
{ "0840" , "0840 (8K EconoBanking)" },
|
||||
@ -153,10 +153,10 @@ Bankswitch::BSList = {{
|
||||
#endif
|
||||
}};
|
||||
|
||||
#ifdef GUI_SUPPORT
|
||||
const std::array<Bankswitch::SizesType, static_cast<int>(Bankswitch::Type::NumSchemes)>
|
||||
#if defined(GUI_SUPPORT)
|
||||
constexpr std::array<Bankswitch::SizesType, static_cast<int>(Bankswitch::Type::NumSchemes)>
|
||||
Bankswitch::Sizes = {{
|
||||
{ Bankswitch::any_KB, Bankswitch::any_KB }, // _AUTO
|
||||
{ Bankswitch::any_KB, Bankswitch::any_KB }, // _AUTO
|
||||
{ 8_KB, 8_KB }, // _0840
|
||||
{ 8_KB, 8_KB }, // _0FA0
|
||||
{ 4_KB, 64_KB }, // _2IN1
|
||||
@ -195,7 +195,7 @@ Bankswitch::Sizes = {{
|
||||
{ 32_KB, 32_KB }, // _F4SC
|
||||
{ 16_KB, 16_KB }, // _F6
|
||||
{ 16_KB, 16_KB }, // _F6SC
|
||||
{ 8_KB, 8_KB }, // _F8
|
||||
{ 8_KB, 8_KB }, // _F8
|
||||
{ 8_KB, 8_KB }, // _F8SC
|
||||
{ 12_KB, 12_KB }, // _FA
|
||||
{ 24_KB, 32_KB }, // _FA2
|
||||
@ -214,7 +214,7 @@ Bankswitch::Sizes = {{
|
||||
{ Bankswitch::any_KB, Bankswitch::any_KB } }
|
||||
#endif
|
||||
}};
|
||||
#endif
|
||||
#endif // GUI_SUPPORT
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Bankswitch::ExtensionMap Bankswitch::ourExtensions = {
|
||||
|
@ -54,8 +54,8 @@ class Bankswitch
|
||||
|
||||
#ifdef GUI_SUPPORT
|
||||
struct SizesType {
|
||||
size_t minSize;
|
||||
size_t maxSize;
|
||||
size_t minSize{0};
|
||||
size_t maxSize{0};
|
||||
};
|
||||
static constexpr size_t any_KB = 0;
|
||||
|
||||
|
@ -174,7 +174,7 @@ void TIASurface::setNTSC(NTSCFilter::Preset preset, bool show)
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void TIASurface::changeNTSC(int direction)
|
||||
{
|
||||
constexpr NTSCFilter::Preset PRESETS[] = {
|
||||
static constexpr std::array<NTSCFilter::Preset, 6> PRESETS = {
|
||||
NTSCFilter::Preset::OFF, NTSCFilter::Preset::RGB, NTSCFilter::Preset::SVIDEO,
|
||||
NTSCFilter::Preset::COMPOSITE, NTSCFilter::Preset::BAD, NTSCFilter::Preset::CUSTOM
|
||||
};
|
||||
@ -334,7 +334,7 @@ void TIASurface::createScanlineSurface()
|
||||
: vRepeats(c_vRepeats), data(c_data)
|
||||
{}
|
||||
};
|
||||
std::array<Pattern, int(ScanlineMask::NumMasks)> Patterns = {{
|
||||
static std::array<Pattern, int(ScanlineMask::NumMasks)> Patterns = {{
|
||||
Pattern(1, // standard
|
||||
{
|
||||
{ 0x00000000 },
|
||||
|
@ -79,11 +79,11 @@ FrameLayout FrameLayoutDetector::detectedLayout(bool detectPal60, bool detectNts
|
||||
{
|
||||
// Multiply each hue's count with its NTSC and PAL stats and aggregate results
|
||||
// If NTSC/PAL results differ significantly, overrule frame result
|
||||
constexpr std::array<double, NUM_HUES> ntscColorFactor{
|
||||
static constexpr std::array<double, NUM_HUES> ntscColorFactor{
|
||||
0.00000, 0.05683, 0.06220, 0.05505, 0.06162, 0.02874, 0.03532, 0.03716,
|
||||
0.15568, 0.06471, 0.02886, 0.03224, 0.06903, 0.11478, 0.02632, 0.01675
|
||||
}; // ignore black = 0x00!
|
||||
constexpr std::array<double, NUM_HUES> palColorFactor{
|
||||
static constexpr std::array<double, NUM_HUES> palColorFactor{
|
||||
0.00000, 0.00450, 0.09962, 0.07603, 0.06978, 0.13023, 0.09638, 0.02268,
|
||||
0.02871, 0.04700, 0.02950, 0.11974, 0.03474, 0.08025, 0.00642, 0.00167
|
||||
}; // ignore black = 0x00!
|
||||
|
@ -42,7 +42,8 @@ class ContextMenu : public Dialog, public CommandSender
|
||||
|
||||
public:
|
||||
ContextMenu(GuiObject* boss, const GUI::Font& font,
|
||||
const VariantList& items, int cmd = 0, int width = 0);
|
||||
const VariantList& items = VariantList{},
|
||||
int cmd = 0, int width = 0);
|
||||
~ContextMenu() override = default;
|
||||
|
||||
bool isShading() const override { return false; }
|
||||
|
@ -166,7 +166,7 @@ int DialogContainer::addDialog(Dialog* d)
|
||||
d->setDirty();
|
||||
myDialogStack.push(d);
|
||||
}
|
||||
return myDialogStack.size();
|
||||
return static_cast<int>(myDialogStack.size());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -182,7 +182,7 @@ ContextMenu& EditableWidget::mouseMenu()
|
||||
{
|
||||
// add mouse context menu
|
||||
if(myMouseMenu == nullptr)
|
||||
myMouseMenu = make_unique<ContextMenu>(this, _font, EmptyVarList);
|
||||
myMouseMenu = make_unique<ContextMenu>(this, _font);
|
||||
|
||||
return *myMouseMenu;
|
||||
}
|
||||
|
@ -256,8 +256,9 @@ void InputDialog::addDevicePortTab()
|
||||
ypos += lineHeight + VGAP * 3;
|
||||
lwidth = _font.getStringWidth("AtariVox serial port ");
|
||||
fwidth = _w - HBORDER * 2 - 2 - lwidth - PopUpWidget::dropDownWidth(_font);
|
||||
myAVoxPort = new PopUpWidget(myTab, _font, HBORDER, ypos, fwidth, lineHeight, EmptyVarList,
|
||||
"AtariVox serial port ", lwidth, kCursorStateChanged);
|
||||
myAVoxPort = new PopUpWidget(myTab, _font, HBORDER, ypos, fwidth, lineHeight,
|
||||
VariantList{}, "AtariVox serial port ", lwidth,
|
||||
kCursorStateChanged);
|
||||
myAVoxPort->setEditable(true);
|
||||
wid.push_back(myAVoxPort);
|
||||
|
||||
|
@ -788,7 +788,7 @@ ContextMenu& LauncherDialog::contextMenu()
|
||||
{
|
||||
if(myContextMenu == nullptr)
|
||||
// Create (empty) context menu for ROM list options
|
||||
myContextMenu = make_unique<ContextMenu>(this, _font, EmptyVarList);
|
||||
myContextMenu = make_unique<ContextMenu>(this, _font);
|
||||
|
||||
return *myContextMenu;
|
||||
}
|
||||
|
@ -481,7 +481,7 @@ void StellaSettingsDialog::loadControllerProperties(const Properties& props)
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
int StellaSettingsDialog::levelToValue(int level)
|
||||
{
|
||||
constexpr int NUM_LEVELS = 11;
|
||||
static constexpr int NUM_LEVELS = 11;
|
||||
static constexpr std::array<uInt8, NUM_LEVELS> values = {
|
||||
0, 5, 11, 18, 26, 35, 45, 56, 68, 81, 95
|
||||
};
|
||||
@ -492,7 +492,7 @@ int StellaSettingsDialog::levelToValue(int level)
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
int StellaSettingsDialog::valueToLevel(int value)
|
||||
{
|
||||
constexpr int NUM_LEVELS = 11;
|
||||
static constexpr int NUM_LEVELS = 11;
|
||||
static constexpr std::array<uInt8, NUM_LEVELS> values = {
|
||||
0, 5, 11, 18, 26, 35, 45, 56, 68, 81, 95
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user