More const cleanups.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3011 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2014-10-21 23:02:20 +00:00
parent f8be548312
commit 920dcdb8a5
21 changed files with 43 additions and 67 deletions

View File

@ -41,7 +41,7 @@ void EventHandlerSDL2::enableTextEvents(bool enable)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* EventHandlerSDL2::nameForKey(StellaKey key)
const char* EventHandlerSDL2::nameForKey(StellaKey key) const
{
return SDL_GetScancodeName(SDL_Scancode(key));
}

View File

@ -53,7 +53,7 @@ class EventHandlerSDL2 : public EventHandler
/**
Returns the human-readable name for a StellaKey.
*/
const char* nameForKey(StellaKey key);
const char* nameForKey(StellaKey key) const;
/**
Collects and dispatches any pending SDL2 events.

View File

@ -96,7 +96,7 @@ class Cartridge : public Device
*/
void lockBank() { myBankLocked = true; }
void unlockBank() { myBankLocked = false; }
bool bankLocked() { return myBankLocked; }
bool bankLocked() const { return myBankLocked; }
/**
Get the default startup bank for a cart. This is the bank where

View File

@ -346,7 +346,7 @@ class Console : public Serializable
Cartridge& myCart;
// Reference to the event object to use
Event& myEvent;
const Event& myEvent;
// Properties for the game
Properties myProperties;

View File

@ -174,18 +174,6 @@ bool Controller::load(Serializer& in)
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Controller::name() const
{
return myName;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Controller::about() const
{
return name() + " in " + (myJack == Left ? "left port" : "right port");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Int32 Controller::maximumResistance = 0x7FFFFFFF;

View File

@ -101,8 +101,8 @@ class Controller : public Serializable
@param jack The jack the controller is plugged into
@param event The event object to use for events
@param type The type for this controller
@param system The system using this controller
@param type The type for this controller
*/
Controller(Jack jack, const Event& event, const System& system,
Type type);
@ -201,12 +201,13 @@ class Controller : public Serializable
/**
Returns the name of this controller.
*/
virtual string name() const;
virtual string name() const { return myName; }
/**
Returns more detailed information about this controller.
*/
virtual string about() const;
virtual string about() const
{ return name() + " in " + (myJack == Left ? "left port" : "right port"); }
/**
The following two functions are used by the debugger to set

View File

@ -109,7 +109,7 @@ class EventHandler
@return The event object
*/
Event& event() { return myEvent; }
const Event& event() const { return myEvent; }
/**
Initialize state of this eventhandler.
@ -347,7 +347,7 @@ class EventHandler
/**
Returns the human-readable name for a StellaKey.
*/
virtual const char* nameForKey(StellaKey key) { return EmptyString.c_str(); }
virtual const char* nameForKey(StellaKey key) const { return EmptyString.c_str(); }
/**
Collects and dispatches any pending events.
@ -371,7 +371,7 @@ class EventHandler
};
void handleSystemEvent(SystemEvent e, int data1 = 0, int data2 = 0);
// An abstraction of joystick in Stella.
// An abstraction of a joystick in Stella.
// A StellaJoystick holds its own event mapping information, space for
// which is dynamically allocated based on the actual number of buttons,
// axes, etc that the device contains.
@ -415,7 +415,7 @@ class EventHandler
int* axisLastValue;
private:
void getValues(const string& list, IntArray& map);
void getValues(const string& list, IntArray& map) const;
friend ostream& operator<<(ostream& os, const StellaJoystick& s) {
os << " ID: " << s.ID << ", name: " << s.name << ", numaxis: " << s.numAxes
@ -465,7 +465,7 @@ class EventHandler
Common::Array<StellaJoystick*> mySticks;
void setStickDefaultMapping(int stick, Event::Type type, EventMode mode);
void printDatabase();
void printDatabase() const;
};
/**

View File

@ -208,7 +208,7 @@ void EventHandler::StellaJoystick::eraseEvent(Event::Type event, EventMode mode)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::StellaJoystick::getValues(const string& list, IntArray& map)
void EventHandler::StellaJoystick::getValues(const string& list, IntArray& map) const
{
map.clear();
istringstream buf(list);
@ -266,7 +266,7 @@ EventHandler::JoystickHandler::~JoystickHandler()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::JoystickHandler::printDatabase()
void EventHandler::JoystickHandler::printDatabase() const
{
cerr << "---------------------------------------------------------" << endl
<< "joy database:" << endl;

View File

@ -721,7 +721,7 @@ void FrameBuffer::toggleGrabMouse()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 FrameBuffer::maxWindowSizeForScreen(uInt32 baseWidth, uInt32 baseHeight,
uInt32 screenWidth, uInt32 screenHeight)
uInt32 screenWidth, uInt32 screenHeight) const
{
uInt32 multiplier = 1;
for(;;)

View File

@ -454,13 +454,7 @@ class FrameBuffer
still fit in the given screen dimensions.
*/
uInt32 maxWindowSizeForScreen(uInt32 baseWidth, uInt32 baseHeight,
uInt32 screenWidth, uInt32 screenHeight);
/**
Determine all supported (windowed) TIA zoom levels for the current
framebuffer. This will take into account any aspect ratio correction.
*/
void setTIAZoomLevels(uInt32 basewidth, uInt32 baseheight);
uInt32 screenWidth, uInt32 screenHeight) const;
/**
Set all possible video modes (both windowed and fullscreen) available for

View File

@ -99,7 +99,7 @@ MT24LC256::~MT24LC256()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool MT24LC256::readSDA()
bool MT24LC256::readSDA() const
{
return jpee_mdat && jpee_sdat;
}

View File

@ -51,7 +51,7 @@ class MT24LC256
public:
/** Read boolean data from the SDA line */
bool readSDA();
bool readSDA() const;
/** Write boolean data to the SDA and SCL lines */
void writeSDA(bool state);

View File

@ -341,7 +341,7 @@ class OSystem
Answers whether the ROM launcher was actually successfully used
at some point since the app started.
@return True on success, otherwise false
@return True if launcher was ever used, otherwise false
*/
bool launcherUsed() const { return myLauncherUsed; }

View File

@ -99,7 +99,7 @@ Serializer::~Serializer()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Serializer::isValid()
bool Serializer::isValid() const
{
return myStream != NULL;
}
@ -113,7 +113,7 @@ void Serializer::reset()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 Serializer::getByte()
uInt8 Serializer::getByte() const
{
char buf;
myStream->read(&buf, 1);
@ -122,13 +122,13 @@ uInt8 Serializer::getByte()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Serializer::getByteArray(uInt8* array, uInt32 size)
void Serializer::getByteArray(uInt8* array, uInt32 size) const
{
myStream->read((char*)array, size);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 Serializer::getShort()
uInt16 Serializer::getShort() const
{
uInt16 val = 0;
myStream->read((char*)&val, sizeof(uInt16));
@ -137,13 +137,13 @@ uInt16 Serializer::getShort()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Serializer::getShortArray(uInt16* array, uInt32 size)
void Serializer::getShortArray(uInt16* array, uInt32 size) const
{
myStream->read((char*)array, sizeof(uInt16)*size);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 Serializer::getInt()
uInt32 Serializer::getInt() const
{
uInt32 val = 0;
myStream->read((char*)&val, sizeof(uInt32));
@ -152,13 +152,13 @@ uInt32 Serializer::getInt()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Serializer::getIntArray(uInt32* array, uInt32 size)
void Serializer::getIntArray(uInt32* array, uInt32 size) const
{
myStream->read((char*)array, sizeof(uInt32)*size);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Serializer::getString()
string Serializer::getString() const
{
int len = getInt();
string str;
@ -169,7 +169,7 @@ string Serializer::getString()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Serializer::getBool()
bool Serializer::getBool() const
{
return getByte() == TruePattern;
}

View File

@ -66,7 +66,7 @@ class Serializer
Answers whether the serializer is currently initialized for reading
and writing.
*/
bool isValid();
bool isValid() const;
/**
Resets the read/write location to the beginning of the stream.
@ -78,7 +78,7 @@ class Serializer
@result The byte value which has been read from the stream.
*/
uInt8 getByte();
uInt8 getByte() const;
/**
Reads a byte array (unsigned 8-bit) from the current input stream.
@ -86,15 +86,14 @@ class Serializer
@param array The location to store the bytes read
@param size The size of the array (number of bytes to read)
*/
void getByteArray(uInt8* array, uInt32 size);
void getByteArray(uInt8* array, uInt32 size) const;
/**
Reads a short value (unsigned 16-bit) from the current input stream.
@result The short value which has been read from the stream.
*/
uInt16 getShort();
uInt16 getShort() const;
/**
Reads a short array (unsigned 16-bit) from the current input stream.
@ -102,14 +101,14 @@ class Serializer
@param array The location to store the shorts read
@param size The size of the array (number of shorts to read)
*/
void getShortArray(uInt16* array, uInt32 size);
void getShortArray(uInt16* array, uInt32 size) const;
/**
Reads an int value (unsigned 32-bit) from the current input stream.
@result The int value which has been read from the stream.
*/
uInt32 getInt();
uInt32 getInt() const;
/**
Reads an integer array (unsigned 32-bit) from the current input stream.
@ -117,21 +116,21 @@ class Serializer
@param array The location to store the integers read
@param size The size of the array (number of integers to read)
*/
void getIntArray(uInt32* array, uInt32 size);
void getIntArray(uInt32* array, uInt32 size) const;
/**
Reads a string from the current input stream.
@result The string which has been read from the stream.
*/
string getString();
string getString() const;
/**
Reads a boolean value from the current input stream.
@result The boolean value which has been read from the stream.
*/
bool getBool();
bool getBool() const;
/**
Writes an byte value (unsigned 8-bit) to the current output stream.

View File

@ -330,7 +330,7 @@ void Settings::validate()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Settings::usage()
void Settings::usage() const
{
cout << endl
<< "Stella version " << STELLA_VERSION << endl

View File

@ -64,7 +64,7 @@ class Settings
/**
This method should be called to display usage information.
*/
void usage();
void usage() const;
/**
Get the value assigned to the specified key.

View File

@ -42,12 +42,6 @@ StateManager::StateManager(OSystem* osystem)
reset();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool StateManager::isActive()
{
return myActiveMode != kOffMode;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool StateManager::toggleRecordMode()
{

View File

@ -44,7 +44,7 @@ class StateManager
/**
Answers whether the manager is in record or playback mode
*/
bool isActive();
bool isActive() const { return myActiveMode != kOffMode; }
bool toggleRecordMode();
bool toggleRewindMode();

View File

@ -146,7 +146,7 @@ class System : public Serializable
@return The null device associated with the system
*/
NullDevice& nullDevice() { return myNullDevice; }
const NullDevice& nullDevice() const { return myNullDevice; }
/**
Get the total number of pages available in the system.

View File

@ -220,7 +220,7 @@ class TIA : public Device
Answers whether this TIA runs at NTSC or PAL scanrates,
based on how many frames of out the total count are PAL frames.
*/
bool isPAL()
bool isPAL() const
{ return float(myPALFrameCounter) / myFrameCounter >= (25.0/60.0); }
/**