mirror of https://github.com/stella-emu/stella.git
Some fixes for suggestions from clang-tidy.
This commit is contained in:
parent
162b13f3d1
commit
00d241c67b
|
@ -22,7 +22,7 @@ namespace Common {
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
string Base::toString(int value, Common::Base::Fmt outputBase)
|
string Base::toString(int value, Common::Base::Fmt outputBase)
|
||||||
{
|
{
|
||||||
static char vToS_buf[32]; // NOLINT - One place where C-style is acceptable
|
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;
|
outputBase = myDefaultBase;
|
||||||
|
|
|
@ -69,7 +69,7 @@ Int16 HighScoresManager::peek(uInt16 addr) const
|
||||||
{
|
{
|
||||||
if (myOSystem.hasConsole())
|
if (myOSystem.hasConsole())
|
||||||
{
|
{
|
||||||
if(addr < 0x100u || myOSystem.console().cartridge().internalRamSize() == 0)
|
if(addr < 0x100U || myOSystem.console().cartridge().internalRamSize() == 0)
|
||||||
return myOSystem.console().system().peek(addr);
|
return myOSystem.console().system().peek(addr);
|
||||||
else
|
else
|
||||||
return myOSystem.console().cartridge().internalRamGetValue(addr);
|
return myOSystem.console().cartridge().internalRamGetValue(addr);
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace {
|
||||||
return serializedMask.size() == 1 ? serializedMask.at(0) : serializedMask;
|
return serializedMask.size() == 1 ? serializedMask.at(0) : serializedMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
int deserializeModkeyMask(json serializedMask)
|
int deserializeModkeyMask(const json& serializedMask)
|
||||||
{
|
{
|
||||||
if(serializedMask.is_null()) return StellaMod::KBDM_NONE;
|
if(serializedMask.is_null()) return StellaMod::KBDM_NONE;
|
||||||
if(!serializedMask.is_array()) return serializedMask.get<StellaMod>();
|
if(!serializedMask.is_array()) return serializedMask.get<StellaMod>();
|
||||||
|
|
|
@ -43,7 +43,7 @@ std::map<string, Variant> KeyValueRepositorySqlite::load()
|
||||||
myStmtSelect->reset();
|
myStmtSelect->reset();
|
||||||
}
|
}
|
||||||
catch (const SqliteError& err) {
|
catch (const SqliteError& err) {
|
||||||
Logger::info(err.message);
|
Logger::info(err.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
|
@ -69,7 +69,7 @@ void KeyValueRepositorySqlite::save(const std::map<string, Variant>& values)
|
||||||
tx.commit();
|
tx.commit();
|
||||||
}
|
}
|
||||||
catch (const SqliteError& err) {
|
catch (const SqliteError& err) {
|
||||||
Logger::info(err.message);
|
Logger::info(err.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ void KeyValueRepositorySqlite::save(const string& key, const Variant& value)
|
||||||
myStmtInsert->reset();
|
myStmtInsert->reset();
|
||||||
}
|
}
|
||||||
catch (const SqliteError& err) {
|
catch (const SqliteError& err) {
|
||||||
Logger::info(err.message);
|
Logger::info(err.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ bool SettingsDb::initialize()
|
||||||
mySettingsRepository->initialize();
|
mySettingsRepository->initialize();
|
||||||
}
|
}
|
||||||
catch (const SqliteError& err) {
|
catch (const SqliteError& err) {
|
||||||
Logger::info("sqlite DB " + databaseFileName() + " failed to initialize: " + err.message);
|
Logger::info("sqlite DB " + databaseFileName() + " failed to initialize: " + err.what());
|
||||||
|
|
||||||
myDb.reset();
|
myDb.reset();
|
||||||
mySettingsRepository.reset();
|
mySettingsRepository.reset();
|
||||||
|
|
|
@ -66,7 +66,7 @@ void SqliteDatabase::initialize()
|
||||||
}
|
}
|
||||||
|
|
||||||
throw SqliteError("unable to initialize sqlite DB for unknown reason");
|
throw SqliteError("unable to initialize sqlite DB for unknown reason");
|
||||||
};
|
}
|
||||||
|
|
||||||
exec("PRAGMA journal_mode=WAL");
|
exec("PRAGMA journal_mode=WAL");
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,16 @@
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
|
||||||
struct SqliteError {
|
class SqliteError : public std::exception
|
||||||
explicit SqliteError(const string& _message) : message(_message) {}
|
{
|
||||||
|
public:
|
||||||
|
explicit SqliteError(const string& message) : myMessage(message) { }
|
||||||
|
explicit SqliteError(sqlite3* handle) : myMessage(sqlite3_errmsg(handle)) { }
|
||||||
|
|
||||||
explicit SqliteError(sqlite3* handle) : message(sqlite3_errmsg(handle)) {}
|
const char* what() const noexcept override { return myMessage.c_str(); }
|
||||||
|
|
||||||
const string message;
|
private:
|
||||||
|
const string myMessage;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SQLITE_ERROR_HXX
|
#endif // SQLITE_ERROR_HXX
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "SqliteError.hxx"
|
#include "SqliteError.hxx"
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
SqliteStatement::SqliteStatement(sqlite3* handle, string sql)
|
SqliteStatement::SqliteStatement(sqlite3* handle, const string& sql)
|
||||||
: myHandle(handle)
|
: myHandle(handle)
|
||||||
{
|
{
|
||||||
if (sqlite3_prepare_v2(handle, sql.c_str(), -1, &myStmt, nullptr) != SQLITE_OK)
|
if (sqlite3_prepare_v2(handle, sql.c_str(), -1, &myStmt, nullptr) != SQLITE_OK)
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
class SqliteStatement {
|
class SqliteStatement {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SqliteStatement(sqlite3* handle, string sql);
|
SqliteStatement(sqlite3* handle, const string& sql);
|
||||||
|
|
||||||
~SqliteStatement();
|
~SqliteStatement();
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ void Cartridge3EWidget::loadConfig()
|
||||||
myBankWidgets[1]->setSelectedIndex(bank - myCart.romBankCount(), oldBank != bank);
|
myBankWidgets[1]->setSelectedIndex(bank - myCart.romBankCount(), oldBank != bank);
|
||||||
}
|
}
|
||||||
|
|
||||||
CartDebugWidget::loadConfig(); // Intentionally calling grand-parent method
|
CartDebugWidget::loadConfig(); // NOLINT : Intentionally calling grand-parent method
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -41,7 +41,7 @@ string DataGridRamWidget::getToolTip(const Common::Point& pos) const
|
||||||
|
|
||||||
const Int32 addr = _addrList[idx];
|
const Int32 addr = _addrList[idx];
|
||||||
const string label = _ram.getLabel(addr);
|
const string label = _ram.getLabel(addr);
|
||||||
const string tip = DataGridWidget::getToolTip(pos);
|
string tip = DataGridWidget::getToolTip(pos);
|
||||||
|
|
||||||
if(label.empty())
|
if(label.empty())
|
||||||
return tip;
|
return tip;
|
||||||
|
|
|
@ -89,7 +89,7 @@ string ToggleBitWidget::getToolTip(const Common::Point& pos) const
|
||||||
if(idx.y < 0)
|
if(idx.y < 0)
|
||||||
return EmptyString;
|
return EmptyString;
|
||||||
|
|
||||||
const string tip = ToggleWidget::getToolTip(pos);
|
string tip = ToggleWidget::getToolTip(pos);
|
||||||
|
|
||||||
if(idx.x < static_cast<int>(_labelList.size()))
|
if(idx.x < static_cast<int>(_labelList.size()))
|
||||||
{
|
{
|
||||||
|
|
|
@ -185,11 +185,6 @@ class Console : public Serializable, public ConsoleIO
|
||||||
*/
|
*/
|
||||||
EmulationTiming& emulationTiming() { return myEmulationTiming; }
|
EmulationTiming& emulationTiming() { return myEmulationTiming; }
|
||||||
|
|
||||||
/**
|
|
||||||
Retrieve the current game's refresh rate, or 0 if no game.
|
|
||||||
*/
|
|
||||||
int refreshRate() const;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
Toggle between NTSC/PAL/SECAM (and variants) display format.
|
Toggle between NTSC/PAL/SECAM (and variants) display format.
|
||||||
|
|
|
@ -184,10 +184,10 @@ void FBSurface::drawChar(const GUI::Font& font, uInt8 chr,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bbw = desc.bbx[chr].w;
|
bbw = desc.bbx[chr].w; // NOLINT
|
||||||
bbh = desc.bbx[chr].h;
|
bbh = desc.bbx[chr].h; // NOLINT
|
||||||
bbx = desc.bbx[chr].x;
|
bbx = desc.bbx[chr].x; // NOLINT
|
||||||
bby = desc.bbx[chr].y;
|
bby = desc.bbx[chr].y; // NOLINT
|
||||||
}
|
}
|
||||||
|
|
||||||
uInt32 cx = tx + bbx;
|
uInt32 cx = tx + bbx;
|
||||||
|
|
|
@ -1288,6 +1288,8 @@ void FrameBuffer::setCursorState()
|
||||||
showCursor(true); // +UI, +Emulation
|
showCursor(true); // +UI, +Emulation
|
||||||
myGrabMouse = false; // disable grab while cursor is shown in emulation
|
myGrabMouse = false; // disable grab while cursor is shown in emulation
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
myBackend->grabMouse(emulation && (analog || alwaysUseMouse) && myGrabMouse);
|
myBackend->grabMouse(emulation && (analog || alwaysUseMouse) && myGrabMouse);
|
||||||
|
|
|
@ -172,7 +172,7 @@ void AboutDialog::updateStrings(int page, int lines, string& title)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(i < lines)
|
while(i < lines) // NOLINT : i changes in lambda above
|
||||||
ADD_ALINE();
|
ADD_ALINE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ void HelpDialog::updateStrings(uInt8 page, uInt8 lines, string& title)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(i < lines)
|
while(i < lines) // NOLINT : i changes in lambda above
|
||||||
ADD_LINE();
|
ADD_LINE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,11 +45,11 @@ using json = nlohmann::json;
|
||||||
class HighScoresDialog : public Dialog
|
class HighScoresDialog : public Dialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const uInt32 NUM_RANKS = 10;
|
static constexpr uInt32 NUM_RANKS = 10;
|
||||||
|
|
||||||
HighScoresDialog(OSystem& osystem, DialogContainer& parent,
|
HighScoresDialog(OSystem& osystem, DialogContainer& parent,
|
||||||
int max_w, int max_h, Menu::AppMode mode);
|
int max_w, int max_h, Menu::AppMode mode);
|
||||||
virtual ~HighScoresDialog();
|
~HighScoresDialog() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void loadConfig() override;
|
void loadConfig() override;
|
||||||
|
|
|
@ -35,7 +35,7 @@ class HighScoresMenu : public DialogContainer
|
||||||
Create a new menu stack
|
Create a new menu stack
|
||||||
*/
|
*/
|
||||||
explicit HighScoresMenu(OSystem& osystem);
|
explicit HighScoresMenu(OSystem& osystem);
|
||||||
virtual ~HighScoresMenu();
|
~HighScoresMenu() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Dialog* baseDialog() override;
|
Dialog* baseDialog() override;
|
||||||
|
|
|
@ -138,15 +138,8 @@ void ProgressDialog::incProgress()
|
||||||
void ProgressDialog::handleCommand(CommandSender* sender, int cmd,
|
void ProgressDialog::handleCommand(CommandSender* sender, int cmd,
|
||||||
int data, int id)
|
int data, int id)
|
||||||
{
|
{
|
||||||
switch(cmd)
|
if(cmd == Event::UICancel)
|
||||||
{
|
|
||||||
case Event::UICancel:
|
|
||||||
myIsCancelled = true;
|
myIsCancelled = true;
|
||||||
break;
|
else
|
||||||
|
|
||||||
default:
|
|
||||||
Dialog::handleCommand(sender, cmd, data, 0);
|
Dialog::handleCommand(sender, cmd, data, 0);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,7 @@ void R77HelpDialog::updateStrings(uInt8 page, uInt8 lines, string& title)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (i < lines)
|
while (i < lines) // NOLINT : i changes in lambda above
|
||||||
ADD_BIND();
|
ADD_BIND();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -393,19 +393,11 @@ void TimeMachineDialog::handleKeyUp(StellaKey key, StellaMod mod)
|
||||||
|
|
||||||
Event::Type event = instance().eventHandler().eventForKey(EventMode::kEmulationMode, key, mod);
|
Event::Type event = instance().eventHandler().eventForKey(EventMode::kEmulationMode, key, mod);
|
||||||
|
|
||||||
switch (event)
|
if(event == Event::TogglePlayBackMode || key == KBDK_SPACE)
|
||||||
{
|
|
||||||
case Event::TogglePlayBackMode:
|
|
||||||
handleCommand(nullptr, kPlayBack, 0, 0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if (key == KBDK_SPACE)
|
|
||||||
handleCommand(nullptr, kPlayBack, 0, 0);
|
handleCommand(nullptr, kPlayBack, 0, 0);
|
||||||
else
|
else
|
||||||
Dialog::handleKeyUp(key, mod);
|
Dialog::handleKeyUp(key, mod);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void TimeMachineDialog::handleCommand(CommandSender* sender, int cmd,
|
void TimeMachineDialog::handleCommand(CommandSender* sender, int cmd,
|
||||||
|
|
Loading…
Reference in New Issue