You know what's better than adding move semantics and initializer

lists to the Array class?  Completely deleting all that code and
using a std::vector directly :)


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3054 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2014-11-07 23:28:40 +00:00
parent 9cf9b41989
commit 740eeed579
27 changed files with 62 additions and 259 deletions

View File

@ -59,7 +59,7 @@ Cheat* CheatManager::add(const string& name, const string& code,
{ {
if(myCheatList[i]->name() == name || myCheatList[i]->code() == code) if(myCheatList[i]->name() == name || myCheatList[i]->code() == code)
{ {
myCheatList.remove_at(i); myCheatList.removeAt(i);
break; break;
} }
} }
@ -68,7 +68,7 @@ Cheat* CheatManager::add(const string& name, const string& code,
if(idx == -1) if(idx == -1)
myCheatList.push_back(cheat); myCheatList.push_back(cheat);
else else
myCheatList.insert_at(idx, cheat); myCheatList.insertAt(idx, cheat);
// And enable/disable it (the cheat knows how to enable or disable itself) // And enable/disable it (the cheat knows how to enable or disable itself)
if(enable) if(enable)
@ -91,7 +91,7 @@ void CheatManager::remove(int idx)
addPerFrame(c, false); addPerFrame(c, false);
// Then remove it from the cheatlist entirely // Then remove it from the cheatlist entirely
myCheatList.remove_at(idx); myCheatList.removeAt(idx);
c->disable(); c->disable();
delete c; delete c;
} }
@ -122,7 +122,7 @@ void CheatManager::addPerFrame(Cheat* cheat, bool enable)
else else
{ {
if(found) if(found)
myPerFrameList.remove_at(i); myPerFrameList.removeAt(i);
} }
} }

View File

@ -15,9 +15,6 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id$ // $Id$
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
//============================================================================ //============================================================================
#ifndef ARRAY_HXX #ifndef ARRAY_HXX
@ -30,208 +27,30 @@
namespace Common { namespace Common {
template <class T> template <class T>
class Array class Array : public vector<T>
{ {
protected:
uInt32 _capacity;
uInt32 _size;
T* _data;
public: public:
typedef T* iterator; void append(const Array<T>& array)
typedef const T* const_iterator;
public:
// Standard c'tor
Array<T>() : _capacity(0), _size(0), _data(nullptr) { }
// Copy c'tor
Array<T>(const Array<T>& array)
: _capacity(array._size+128), _size(array._size), _data(nullptr)
{ {
_data = new T[_capacity]; this->insert(this->end(), array.begin(), array.end());
for(uInt32 i = 0; i < _size; i++)
_data[i] = array._data[i];
}
// Copy assignment
Array<T>& operator =(const Array<T>& array)
{
delete [] _data;
_size = array._size;
_capacity = _size + 128;
_data = new T[_capacity];
for(uInt32 i = 0; i < _size; i++)
_data[i] = array._data[i];
return *this;
} }
// Move c'tor void insertAt(uInt32 idx, const T& element)
Array<T>(Array<T>&& array)
: _capacity(array._capacity), _size(array._size), _data(array._data)
{ {
array._size = 0; this->insert(this->cbegin()+idx, element);
array._capacity = 0;
array._data = nullptr;
}
// Move assignment
Array<T>& operator =(Array<T>&& array)
{
if(this != &array)
{
delete[] _data;
_capacity = array._size;
_size = array._size;
_data = array._data;
array._capacity = 0;
array._size = 0;
array._data = nullptr;
}
return *this;
} }
// Initializer list c'tor void removeAt(uInt32 idx)
Array<T>(std::initializer_list<T> il) : _capacity(0), _size(0), _data(nullptr)
{ {
ensureCapacity(il.size()); this->erase(this->cbegin()+idx);
for(int e: il)
_data[_size++] = e;
}
// D'tor
~Array<T>()
{
if(_data)
{
delete[] _data;
_data = nullptr;
}
}
void reserve(uInt32 capacity)
{
if(capacity > _capacity)
ensureCapacity(capacity - 128);
}
void push_back(const T& element)
{
ensureCapacity(_size + 1);
_data[_size++] = element;
}
void push_back(const Array<T>& array)
{
ensureCapacity(_size + array._size);
for(uInt32 i = 0; i < array._size; i++)
_data[_size++] = array._data[i];
}
void insert_at(uInt32 idx, const T& element)
{
assert(idx >= 0 && idx <= _size);
ensureCapacity(_size + 1);
// The following loop is not efficient if you can just memcpy things around.
// e.g. if you have a list of ints. But for real objects (String...), memcpy
// usually isn't correct (specifically, for any class which has a non-default
// copy behaviour. E.g. the String class uses a refCounter which has to be
// updated whenever a String is copied.
for(uInt32 i = _size; i > idx; i--)
_data[i] = _data[i-1];
_data[idx] = element;
_size++;
}
T remove_at(uInt32 idx)
{
assert(idx >= 0 && idx < _size);
T tmp = _data[idx];
for(uInt32 i = idx; i < _size - 1; i++)
_data[i] = _data[i+1];
_size--;
return tmp;
}
T& operator [](uInt32 idx)
{
assert(idx >= 0 && idx < _size);
return _data[idx];
}
const T& operator [](uInt32 idx) const
{
assert(idx >= 0 && idx < _size);
return _data[idx];
}
uInt32 size() const { return _size; }
uInt32 capacity() const { return _capacity; }
void clear(bool fullerase = true)
{
if(fullerase)
{
if(_data)
{
delete [] _data;
_data = nullptr;
}
_capacity = 0;
}
_size = 0;
}
bool isEmpty() const
{
return (_size == 0);
}
iterator begin()
{
return _data;
}
iterator end()
{
return _data + _size;
}
const_iterator begin() const
{
return _data;
}
const_iterator end() const
{
return _data + _size;
}
protected:
void ensureCapacity(uInt32 new_len)
{
if (new_len <= _capacity)
return;
T* old_data = _data;
_capacity = new_len + 128;
_data = new T[_capacity];
if(old_data)
{
// Copy old data
for(uInt32 i = 0; i < _size; i++)
_data[i] = old_data[i];
delete[] old_data;
}
} }
}; };
} // Namespace Common } // Namespace Common
typedef Common::Array<Int32> IntArray; // Common array types
typedef Common::Array<bool> BoolArray; class IntArray : public Common::Array<Int32> { };
typedef Common::Array<uInt8> ByteArray; class BoolArray : public Common::Array<bool> { };
class ByteArray : public Common::Array<uInt8> { };
#endif #endif

View File

@ -159,7 +159,7 @@ void PNGLibrary::saveImage(const string& filename, const FBSurface& surface,
// Do we want the entire surface or just a section? // Do we want the entire surface or just a section?
png_uint_32 width = rect.width(), height = rect.height(); png_uint_32 width = rect.width(), height = rect.height();
if(rect.isEmpty()) if(rect.empty())
{ {
width = surface.width(); width = surface.width();
height = surface.height(); height = surface.height();

View File

@ -21,23 +21,10 @@
#define STRING_LIST_HXX #define STRING_LIST_HXX
#include "Array.hxx" #include "Array.hxx"
#include "bspf.hxx"
class StringList : public Common::Array<string> class StringList : public Common::Array<string>
{ {
public: public:
void push_back(const char* str)
{
ensureCapacity(_size + 1);
_data[_size++] = str;
}
void push_back(const string& str)
{
ensureCapacity(_size + 1);
_data[_size++] = str;
}
static string removePattern(const string& str, const string& pattern) static string removePattern(const string& str, const string& pattern)
{ {
// This can probably be made more efficient ... // This can probably be made more efficient ...

View File

@ -76,22 +76,19 @@ class Variant
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static const Variant EmptyVariant(""); static const Variant EmptyVariant = Variant();
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
class VariantList : public Common::Array<pair<string,Variant>> class VariantList : public Common::Array<pair<string,Variant>>
{ {
public: public:
VariantList() { }
void push_back(const Variant& name, const Variant& tag = EmptyVariant) void push_back(const Variant& name, const Variant& tag = EmptyVariant)
{ {
ensureCapacity(_size + 1); emplace_back(name.toString(), tag);
_data[_size++] = make_pair(name.toString(), tag);
} }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static const VariantList EmptyVarList; static const VariantList EmptyVarList = VariantList();
#endif #endif

View File

@ -302,7 +302,7 @@ bool CartDebug::disassemble(bool force)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartDebug::fillDisassemblyList(BankInfo& info, uInt16 search) bool CartDebug::fillDisassemblyList(BankInfo& info, uInt16 search)
{ {
myDisassembly.list.clear(false); myDisassembly.list.clear();
myDisassembly.fieldwidth = 14 + myLabelLength; myDisassembly.fieldwidth = 14 + myLabelLength;
DiStella distella(*this, myDisassembly.list, info, DiStella::settings, DiStella distella(*this, myDisassembly.list, info, DiStella::settings,
myDisLabels, myDisDirectives, myReserved); myDisLabels, myDisDirectives, myReserved);
@ -1010,7 +1010,7 @@ string CartDebug::saveDisassembly()
{ {
BankInfo& info = myBankInfo[bank]; BankInfo& info = myBankInfo[bank];
// Disassemble bank // Disassemble bank
disasm.list.clear(false); // don't fully de-allocate space disasm.list.clear();
DiStella distella(*this, disasm.list, info, settings, DiStella distella(*this, disasm.list, info, settings,
myDisLabels, myDisDirectives, myReserved); myDisLabels, myDisDirectives, myReserved);

View File

@ -684,7 +684,7 @@ bool Debugger::RewindManager::addState()
myStateList[myTop] = new Serializer(); myStateList[myTop] = new Serializer();
Serializer& s = *(myStateList[myTop]); Serializer& s = *(myStateList[myTop]);
if(s.isValid()) if(s.valid())
{ {
s.reset(); s.reset();
if(myOSystem.state().saveState(s) && myOSystem.console().tia().saveDisplay(s)) if(myOSystem.state().saveState(s) && myOSystem.console().tia().saveDisplay(s))
@ -723,7 +723,7 @@ bool Debugger::RewindManager::rewindState()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::RewindManager::isEmpty() bool Debugger::RewindManager::empty()
{ {
return mySize == 0; return mySize == 0;
} }

View File

@ -328,7 +328,7 @@ class Debugger : public DialogContainer
public: public:
bool addState(); bool addState();
bool rewindState(); bool rewindState();
bool isEmpty(); bool empty();
void clear(); void clear();
private: private:

View File

@ -886,7 +886,7 @@ void DebuggerParser::executeDelwatch()
int which = args[0] - 1; int which = args[0] - 1;
if(which >= 0 && which < (int)watches.size()) if(which >= 0 && which < (int)watches.size())
{ {
watches.remove_at(which); watches.removeAt(which);
commandResult << "removed watch"; commandResult << "removed watch";
} }
else else

View File

@ -28,6 +28,7 @@ struct Command;
#include "bspf.hxx" #include "bspf.hxx"
#include "Array.hxx" #include "Array.hxx"
#include "StringList.hxx"
#include "FrameBuffer.hxx" #include "FrameBuffer.hxx"
#include "Settings.hxx" #include "Settings.hxx"

View File

@ -450,7 +450,7 @@ void CartridgeCTY::loadTune(uInt8 index)
void CartridgeCTY::loadScore(uInt8 index) void CartridgeCTY::loadScore(uInt8 index)
{ {
Serializer serializer(myEEPROMFile, true); Serializer serializer(myEEPROMFile, true);
if(serializer.isValid()) if(serializer.valid())
{ {
uInt8 scoreRAM[256]; uInt8 scoreRAM[256];
try try
@ -470,7 +470,7 @@ void CartridgeCTY::loadScore(uInt8 index)
void CartridgeCTY::saveScore(uInt8 index) void CartridgeCTY::saveScore(uInt8 index)
{ {
Serializer serializer(myEEPROMFile); Serializer serializer(myEEPROMFile);
if(serializer.isValid()) if(serializer.valid())
{ {
// Load score RAM // Load score RAM
uInt8 scoreRAM[256]; uInt8 scoreRAM[256];
@ -504,7 +504,7 @@ void CartridgeCTY::saveScore(uInt8 index)
void CartridgeCTY::wipeAllScores() void CartridgeCTY::wipeAllScores()
{ {
Serializer serializer(myEEPROMFile); Serializer serializer(myEEPROMFile);
if(serializer.isValid()) if(serializer.valid())
{ {
// Erase score RAM // Erase score RAM
uInt8 scoreRAM[256]; uInt8 scoreRAM[256];

View File

@ -371,7 +371,7 @@ uInt8 CartridgeFA2::ramReadWrite()
// We go ahead and do the access now, and only return when a sufficient // We go ahead and do the access now, and only return when a sufficient
// amount of time has passed // amount of time has passed
Serializer serializer(myFlashFile); Serializer serializer(myFlashFile);
if(serializer.isValid()) if(serializer.valid())
{ {
if(myRAM[255] == 1) // read if(myRAM[255] == 1) // read
{ {
@ -423,7 +423,7 @@ uInt8 CartridgeFA2::ramReadWrite()
void CartridgeFA2::flash(uInt8 operation) void CartridgeFA2::flash(uInt8 operation)
{ {
Serializer serializer(myFlashFile); Serializer serializer(myFlashFile);
if(serializer.isValid()) if(serializer.valid())
{ {
if(operation == 0) // erase if(operation == 0) // erase
{ {

View File

@ -27,12 +27,12 @@ class OSystem;
class DialogContainer; class DialogContainer;
class EventMappingWidget; class EventMappingWidget;
class MouseControl; class MouseControl;
class StringList;
class VariantList; class VariantList;
#include "Array.hxx" #include "Array.hxx"
#include "Event.hxx" #include "Event.hxx"
#include "StellaKeys.hxx" #include "StellaKeys.hxx"
#include "StringList.hxx"
#include "bspf.hxx" #include "bspf.hxx"
enum MouseButton { enum MouseButton {

View File

@ -325,7 +325,7 @@ int EventHandler::JoystickHandler::add(StellaJoystick* stick)
} }
stick->type = StellaJoystick::JT_REGULAR; stick->type = StellaJoystick::JT_REGULAR;
} }
mySticks.insert_at(stick->ID, stick); mySticks.insertAt(stick->ID, stick);
// Map the stelladaptors we've found according to the specified ports // Map the stelladaptors we've found according to the specified ports
if(specialAdaptor) if(specialAdaptor)

View File

@ -39,7 +39,7 @@ void FBSurface::readPixels(uInt8* buffer, uInt32 pitch, const GUI::Rect& rect) c
{ {
uInt8* src = (uInt8*) myPixels + rect.y() * myPitch + rect.x(); uInt8* src = (uInt8*) myPixels + rect.y() * myPitch + rect.x();
if(rect.isEmpty()) if(rect.empty())
memcpy(buffer, src, width() * height() * 4); memcpy(buffer, src, width() * height() * 4);
else else
{ {

View File

@ -76,7 +76,7 @@ bool FrameBuffer::initialize()
// Check the 'maxres' setting, which is an undocumented developer feature // Check the 'maxres' setting, which is an undocumented developer feature
// that specifies the desktop size (not normally set) // that specifies the desktop size (not normally set)
const GUI::Size& s = myOSystem.settings().getSize("maxres"); const GUI::Size& s = myOSystem.settings().getSize("maxres");
if(s.isValid()) if(s.valid())
{ {
query_w = s.w; query_w = s.w;
query_h = s.h; query_h = s.h;
@ -943,9 +943,9 @@ void FrameBuffer::VideoModeList::clear()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FrameBuffer::VideoModeList::isEmpty() const bool FrameBuffer::VideoModeList::empty() const
{ {
return myModeList.isEmpty(); return myModeList.empty();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -32,7 +32,6 @@ namespace GUI {
#include "EventHandler.hxx" #include "EventHandler.hxx"
#include "Rect.hxx" #include "Rect.hxx"
#include "StringList.hxx"
#include "Variant.hxx" #include "Variant.hxx"
#include "FBSurface.hxx" #include "FBSurface.hxx"
#include "TIASurface.hxx" #include "TIASurface.hxx"
@ -484,7 +483,7 @@ class FrameBuffer
void add(const VideoMode& mode); void add(const VideoMode& mode);
void clear(); void clear();
bool isEmpty() const; bool empty() const;
uInt32 size() const; uInt32 size() const;
void previous(); void previous();

View File

@ -444,8 +444,8 @@ void M6502::delCondBreak(uInt32 brk)
if(brk < myBreakConds.size()) if(brk < myBreakConds.size())
{ {
delete myBreakConds[brk]; delete myBreakConds[brk];
myBreakConds.remove_at(brk); myBreakConds.removeAt(brk);
myBreakCondNames.remove_at(brk); myBreakCondNames.removeAt(brk);
} }
} }

View File

@ -99,7 +99,7 @@ Serializer::~Serializer()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Serializer::isValid() const bool Serializer::valid() const
{ {
return myStream != NULL; return myStream != NULL;
} }

View File

@ -50,7 +50,7 @@ class Serializer
If a file is opened readonly, we can never write to it. If a file is opened readonly, we can never write to it.
The isValid() method must immediately be called to verify the stream The valid() method must immediately be called to verify the stream
was correctly initialized. was correctly initialized.
*/ */
Serializer(const string& filename, bool readonly = false); Serializer(const string& filename, bool readonly = false);
@ -66,7 +66,7 @@ class Serializer
Answers whether the serializer is currently initialized for reading Answers whether the serializer is currently initialized for reading
and writing. and writing.
*/ */
bool isValid() const; bool valid() const;
/** /**
Resets the read/write location to the beginning of the stream. Resets the read/write location to the beginning of the stream.

View File

@ -173,7 +173,7 @@ void StateManager::loadState(int slot)
// Make sure the file can be opened in read-only mode // Make sure the file can be opened in read-only mode
Serializer in(buf.str(), true); Serializer in(buf.str(), true);
if(!in.isValid()) if(!in.valid())
{ {
buf.str(""); buf.str("");
buf << "Can't open/load from state file " << slot; buf << "Can't open/load from state file " << slot;
@ -217,7 +217,7 @@ void StateManager::saveState(int slot)
// Make sure the file can be opened for writing // Make sure the file can be opened for writing
Serializer out(buf.str()); Serializer out(buf.str());
if(!out.isValid()) if(!out.valid())
{ {
buf.str(""); buf.str("");
buf << "Can't open/save to state file " << slot; buf << "Can't open/save to state file " << slot;
@ -267,7 +267,7 @@ bool StateManager::loadState(Serializer& in)
if(myOSystem.hasConsole()) if(myOSystem.hasConsole())
{ {
// Make sure the file can be opened for reading // Make sure the file can be opened for reading
if(in.isValid()) if(in.valid())
{ {
// First test if we have a valid header and cart type // First test if we have a valid header and cart type
// If so, do a complete state load using the Console // If so, do a complete state load using the Console
@ -287,7 +287,7 @@ bool StateManager::saveState(Serializer& out)
if(myOSystem.hasConsole()) if(myOSystem.hasConsole())
{ {
// Make sure the file can be opened for writing // Make sure the file can be opened for writing
if(out.isValid()) if(out.valid())
{ {
// Add header so that if the state format changes in the future, // Add header so that if the state format changes in the future,
// we'll know right away, without having to parse the rest of the file // we'll know right away, without having to parse the rest of the file

View File

@ -114,7 +114,7 @@ void ComboDialog::loadConfig()
StringList events; StringList events;
instance().eventHandler().getComboListForEvent(myComboEvent, events); instance().eventHandler().getComboListForEvent(myComboEvent, events);
int size = BSPF_min(events.size(), 8u); int size = BSPF_min((int)events.size(), 8);
for(int i = 0; i < size; ++i) for(int i = 0; i < size; ++i)
myEvents[i]->setSelected("", events[i]); myEvents[i]->setSelected("", events[i]);

View File

@ -150,7 +150,7 @@ void Dialog::addToFocusList(WidgetArray& list)
for(uInt32 i = 0; i < list.size(); ++i) for(uInt32 i = 0; i < list.size(); ++i)
list[i]->setFlags(WIDGET_RETAIN_FOCUS); list[i]->setFlags(WIDGET_RETAIN_FOCUS);
_myFocus.list.push_back(list); _myFocus.list.append(list);
_focusList = _myFocus.list; _focusList = _myFocus.list;
if(list.size() > 0) if(list.size() > 0)
@ -176,14 +176,14 @@ void Dialog::addToFocusList(WidgetArray& list, TabWidget* w, int tabId)
// Now insert in the correct place in that focus list // Now insert in the correct place in that focus list
uInt32 id = tabId; uInt32 id = tabId;
if(id < focus.size()) if(id < focus.size())
focus[id].list.push_back(list); focus[id].list.append(list);
else else
{ {
// Make sure the array is large enough // Make sure the array is large enough
while(focus.size() <= id) while(focus.size() <= id)
focus.push_back(Focus()); focus.push_back(Focus());
focus[id].list.push_back(list); focus[id].list.append(list);
} }
if(list.size() > 0) if(list.size() > 0)
@ -245,13 +245,13 @@ void Dialog::buildCurrentFocusList(int tabID)
_myTabList[id].appendFocusList(_focusList); _myTabList[id].appendFocusList(_focusList);
// Add remaining items from main focus list // Add remaining items from main focus list
_focusList.push_back(_myFocus.list); _focusList.append(_myFocus.list);
// Add button group at end of current focus list // Add button group at end of current focus list
// We do it this way for TabWidget, so that buttons are scanned // We do it this way for TabWidget, so that buttons are scanned
// *after* the widgets in the current tab // *after* the widgets in the current tab
if(_buttonGroup.size() > 0) if(_buttonGroup.size() > 0)
_focusList.push_back(_buttonGroup); _focusList.append(_buttonGroup);
// Finally, the moment we've all been waiting for :) // Finally, the moment we've all been waiting for :)
// Set the actual focus widget // Set the actual focus widget
@ -727,7 +727,7 @@ void Dialog::TabFocus::appendFocusList(WidgetArray& list)
int active = widget->getActiveTab(); int active = widget->getActiveTab();
if(active >= 0 && active < (int)focus.size()) if(active >= 0 && active < (int)focus.size())
list.push_back(focus[active].list); list.append(focus[active].list);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -254,7 +254,7 @@ void LauncherDialog::loadConfig()
// Assume that if the list is empty, this is the first time that loadConfig() // Assume that if the list is empty, this is the first time that loadConfig()
// has been called (and we should reload the list) // has been called (and we should reload the list)
if(myList->getList().isEmpty()) if(myList->getList().empty())
{ {
myPrevDirButton->setEnabled(false); myPrevDirButton->setEnabled(false);
myCurrentNode = FilesystemNode(romdir == "" ? "~" : romdir); myCurrentNode = FilesystemNode(romdir == "" ? "~" : romdir);

View File

@ -88,7 +88,7 @@ void ListWidget::setSelected(int item)
void ListWidget::setSelected(const string& item) void ListWidget::setSelected(const string& item)
{ {
int selected = -1; int selected = -1;
if(!_list.isEmpty()) if(!_list.empty())
{ {
if(item == "") if(item == "")
selected = 0; selected = 0;

View File

@ -76,7 +76,7 @@ void MessageBox::addText(const GUI::Font& font, const StringList& text)
for(uInt32 i = 0; i < text.size(); ++i) for(uInt32 i = 0; i < text.size(); ++i)
str_w = BSPF_max((int)text[i].length(), str_w); str_w = BSPF_max((int)text[i].length(), str_w);
_w = BSPF_min(str_w * fontWidth + 20, _w); _w = BSPF_min(str_w * fontWidth + 20, _w);
_h = BSPF_min(((text.size() + 2) * lineHeight + 20), (uInt32)_h); _h = BSPF_min((uInt32)((text.size() + 2) * lineHeight + 20), (uInt32)_h);
xpos = 10; ypos = 10; xpos = 10; ypos = 10;
for(uInt32 i = 0; i < text.size(); ++i) for(uInt32 i = 0; i < text.size(); ++i)

View File

@ -74,7 +74,7 @@ struct Size
if(c != 'x') if(c != 'x')
w = h = 0; w = h = 0;
} }
bool isValid() const { return w > 0 && h > 0; } bool valid() const { return w > 0 && h > 0; }
Size& operator=(const Size& s) { w = s.w; h = s.h; return *this; }; 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; };
@ -118,7 +118,7 @@ struct Rect
Rect(const Point& p, uInt32 w, uInt32 h) : top(p.y), left(p.x), bottom(h), right(w) {} Rect(const Point& p, uInt32 w, uInt32 h) : top(p.y), left(p.x), bottom(h), right(w) {}
Rect(uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2) : top(y1), left(x1), bottom(y2), right(x2) Rect(uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2) : top(y1), left(x1), bottom(y2), right(x2)
{ {
assert(isValid()); assert(valid());
} }
uInt32 x() const { return left; } uInt32 x() const { return left; }
@ -138,14 +138,14 @@ struct Rect
left = x1; left = x1;
bottom = y2; bottom = y2;
right = x2; right = x2;
assert(isValid()); assert(valid());
} }
bool isValid() const { bool valid() const {
return (left <= right && top <= bottom); return (left <= right && top <= bottom);
} }
bool isEmpty() const { bool empty() const {
return top == 0 && left == 0 && bottom == 0 && right == 0; return top == 0 && left == 0 && bottom == 0 && right == 0;
} }