Get rid of Common::String::emptyString, and also of some port specific hackery (getting rid of certain global C++ objs)

svn-id: r46781
This commit is contained in:
Max Horn 2009-12-30 23:01:36 +00:00
parent a753f606ec
commit b0e02675e7
6 changed files with 9 additions and 59 deletions

View file

@ -40,17 +40,6 @@ static bool isValidDomainName(const Common::String &domName) {
namespace Common { namespace Common {
#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__))
const String ConfigManager::kApplicationDomain("scummvm");
const String ConfigManager::kTransientDomain("__TRANSIENT");
#ifdef ENABLE_KEYMAPPER
const String ConfigManager::kKeymapperDomain("keymapper");
#endif
#else
const char *ConfigManager::kApplicationDomain = "scummvm"; const char *ConfigManager::kApplicationDomain = "scummvm";
const char *ConfigManager::kTransientDomain = "__TRANSIENT"; const char *ConfigManager::kTransientDomain = "__TRANSIENT";
@ -58,13 +47,10 @@ const char *ConfigManager::kTransientDomain = "__TRANSIENT";
const char *ConfigManager::kKeymapperDomain = "keymapper"; const char *ConfigManager::kKeymapperDomain = "keymapper";
#endif #endif
#endif
#pragma mark - #pragma mark -
ConfigManager::ConfigManager() ConfigManager::ConfigManager() : _activeDomain(0) {
: _activeDomain(0) {
} }
@ -407,11 +393,7 @@ const String & ConfigManager::get(const String &key) const {
else if (_defaultsDomain.contains(key)) else if (_defaultsDomain.contains(key))
return _defaultsDomain[key]; return _defaultsDomain[key];
#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__)) return _emptyString;
return String::emptyString;
#else
return ConfMan._emptyString;
#endif
} }
const String & ConfigManager::get(const String &key, const String &domName) const { const String & ConfigManager::get(const String &key, const String &domName) const {
@ -434,11 +416,7 @@ const String & ConfigManager::get(const String &key, const String &domName) cons
if (!domain->contains(key)) { if (!domain->contains(key)) {
#if 1 #if 1
#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__)) return _emptyString;
return String::emptyString;
#else
return ConfMan._emptyString;
#endif
#else #else
error("ConfigManager::get(%s,%s) called on non-existent key", error("ConfigManager::get(%s,%s) called on non-existent key",
key.c_str(), domName.c_str()); key.c_str(), domName.c_str());
@ -641,11 +619,7 @@ const String &ConfigManager::Domain::get(const String &key) const {
if (iter != end()) if (iter != end())
return iter->_value; return iter->_value;
#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__))
return String::emptyString;
#else
return ConfMan._emptyString; return ConfMan._emptyString;
#endif
} }
void ConfigManager::Domain::setDomainComment(const String &comment) { void ConfigManager::Domain::setDomainComment(const String &comment) {

View file

@ -68,29 +68,15 @@ public:
typedef HashMap<String, Domain, IgnoreCase_Hash, IgnoreCase_EqualTo> DomainMap; typedef HashMap<String, Domain, IgnoreCase_Hash, IgnoreCase_EqualTo> DomainMap;
#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__))
/** The name of the application domain (normally 'scummvm'). */ /** The name of the application domain (normally 'scummvm'). */
static const String kApplicationDomain; static const char *kApplicationDomain;
/** The transient (pseudo) domain. */ /** The transient (pseudo) domain. */
static const String kTransientDomain;
#ifdef ENABLE_KEYMAPPER
/** The name of keymapper domain used to store the key maps */
static const String kKeymapperDomain;
#endif
#else
static const char *kApplicationDomain;
static const char *kTransientDomain; static const char *kTransientDomain;
const String _emptyString;
#ifdef ENABLE_KEYMAPPER #ifdef ENABLE_KEYMAPPER
/** The name of keymapper domain used to store the key maps */ /** The name of keymapper domain used to store the key maps */
static const char *kKeymapperDomain; static const char *kKeymapperDomain;
#endif
#endif #endif
void loadDefaultConfigFile(); void loadDefaultConfigFile();
@ -179,6 +165,8 @@ private:
Domain * _activeDomain; Domain * _activeDomain;
String _filename; String _filename;
const String _emptyString;
}; };
} // End of namespace Common } // End of namespace Common

View file

@ -37,13 +37,6 @@
namespace Common { namespace Common {
#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__))
const String String::emptyString;
#else
const char *String::emptyString = "";
#endif
MemoryPool *g_refCountPool = 0; // FIXME: This is never freed right now MemoryPool *g_refCountPool = 0; // FIXME: This is never freed right now
static uint32 computeCapacity(uint32 len) { static uint32 computeCapacity(uint32 len) {

View file

@ -90,12 +90,6 @@ protected:
} }
public: public:
#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__))
static const String emptyString;
#else
static const char *emptyString;
#endif
/** Construct a new empty string. */ /** Construct a new empty string. */
String() : _size(0), _str(_storage) { _storage[0] = 0; } String() : _size(0), _str(_storage) { _storage[0] = 0; }

View file

@ -75,7 +75,7 @@ public:
int getSelected() const { return _selectedItem; } int getSelected() const { return _selectedItem; }
uint32 getSelectedTag() const { return (_selectedItem >= 0) ? _entries[_selectedItem].tag : (uint32)-1; } uint32 getSelectedTag() const { return (_selectedItem >= 0) ? _entries[_selectedItem].tag : (uint32)-1; }
const String& getSelectedString() const { return (_selectedItem >= 0) ? _entries[_selectedItem].name : String::emptyString; } // const String& getSelectedString() const { return (_selectedItem >= 0) ? _entries[_selectedItem].name : String::emptyString; }
void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); draw(); } void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); draw(); }
void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED); draw(); } void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED); draw(); }

View file

@ -114,7 +114,8 @@ void SaveLoadChooser::open() {
} }
const Common::String &SaveLoadChooser::getResultString() const { const Common::String &SaveLoadChooser::getResultString() const {
return (_list->getSelected() > -1) ? _list->getSelectedString() : _resultString; int selItem = _list->getSelected();
return (selItem >= 0) ? _list->getSelectedString() : _resultString;
} }
void SaveLoadChooser::setSaveMode(bool saveMode) { void SaveLoadChooser::setSaveMode(bool saveMode) {