diff options
author | Johannes Schickel | 2010-03-13 21:55:49 +0000 |
---|---|---|
committer | Johannes Schickel | 2010-03-13 21:55:49 +0000 |
commit | 40562798d6670775768224f77514ed000ff78c38 (patch) | |
tree | 4798a9207e4467c273339e8058f749304115f4db | |
parent | 958fa8d5cbe1ccffdaf6812f39238fccb67307a4 (diff) | |
download | scummvm-rg350-40562798d6670775768224f77514ed000ff78c38.tar.gz scummvm-rg350-40562798d6670775768224f77514ed000ff78c38.tar.bz2 scummvm-rg350-40562798d6670775768224f77514ed000ff78c38.zip |
Fix our DECLARE_SINGLETON macro to conform to the C++ specs.
We need to use a namespace Common { } there to make strict C++ compilers
like clang++ and comeau happy. I also added a slight comment about why
that is needed to the macro definition and a note that you need to use
it from the global namespace.
svn-id: r48254
-rw-r--r-- | backends/fs/palmos/palmos-fs-factory.cpp | 2 | ||||
-rw-r--r-- | backends/fs/ps2/ps2-fs-factory.cpp | 2 | ||||
-rw-r--r-- | backends/fs/psp/psp-fs-factory.cpp | 2 | ||||
-rw-r--r-- | backends/fs/wii/wii-fs-factory.cpp | 2 | ||||
-rw-r--r-- | backends/platform/psp/powerman.cpp | 2 | ||||
-rw-r--r-- | backends/platform/psp/psploader.cpp | 2 | ||||
-rw-r--r-- | base/plugins.cpp | 6 | ||||
-rw-r--r-- | common/EventRecorder.cpp | 2 | ||||
-rw-r--r-- | common/archive.cpp | 5 | ||||
-rw-r--r-- | common/config-manager.cpp | 2 | ||||
-rw-r--r-- | common/singleton.h | 13 | ||||
-rw-r--r-- | engines/lure/sound.cpp | 2 | ||||
-rw-r--r-- | graphics/cursorman.cpp | 2 | ||||
-rw-r--r-- | graphics/fontman.cpp | 2 | ||||
-rw-r--r-- | gui/GuiManager.cpp | 2 | ||||
-rw-r--r-- | sound/audiocd.cpp | 2 |
16 files changed, 31 insertions, 19 deletions
diff --git a/backends/fs/palmos/palmos-fs-factory.cpp b/backends/fs/palmos/palmos-fs-factory.cpp index 889d541571..97b3644205 100644 --- a/backends/fs/palmos/palmos-fs-factory.cpp +++ b/backends/fs/palmos/palmos-fs-factory.cpp @@ -26,7 +26,7 @@ #include "backends/fs/palmos/palmos-fs-factory.h" #include "backends/fs/palmos/palmos-fs.cpp" -DECLARE_SINGLETON(PalmOSFilesystemFactory); +DECLARE_SINGLETON(PalmOSFilesystemFactory) AbstractFSNode *PalmOSFilesystemFactory::makeRootFileNode() const { return new PalmOSFilesystemNode(); diff --git a/backends/fs/ps2/ps2-fs-factory.cpp b/backends/fs/ps2/ps2-fs-factory.cpp index 18478b4f3d..8d3c22d2d0 100644 --- a/backends/fs/ps2/ps2-fs-factory.cpp +++ b/backends/fs/ps2/ps2-fs-factory.cpp @@ -26,7 +26,7 @@ #include "backends/fs/ps2/ps2-fs-factory.h" #include "backends/fs/ps2/ps2-fs.cpp" -DECLARE_SINGLETON(Ps2FilesystemFactory); +DECLARE_SINGLETON(Ps2FilesystemFactory) AbstractFSNode *Ps2FilesystemFactory::makeRootFileNode() const { return new Ps2FilesystemNode(); diff --git a/backends/fs/psp/psp-fs-factory.cpp b/backends/fs/psp/psp-fs-factory.cpp index 7ed84de034..7a22954919 100644 --- a/backends/fs/psp/psp-fs-factory.cpp +++ b/backends/fs/psp/psp-fs-factory.cpp @@ -26,7 +26,7 @@ #include "backends/fs/psp/psp-fs-factory.h" #include "backends/fs/psp/psp-fs.cpp" -DECLARE_SINGLETON(PSPFilesystemFactory); +DECLARE_SINGLETON(PSPFilesystemFactory) AbstractFSNode *PSPFilesystemFactory::makeRootFileNode() const { return new PSPFilesystemNode(); diff --git a/backends/fs/wii/wii-fs-factory.cpp b/backends/fs/wii/wii-fs-factory.cpp index c06b6e5d5f..5bc8ba56f5 100644 --- a/backends/fs/wii/wii-fs-factory.cpp +++ b/backends/fs/wii/wii-fs-factory.cpp @@ -36,7 +36,7 @@ #include <smb.h> #endif -DECLARE_SINGLETON(WiiFilesystemFactory); +DECLARE_SINGLETON(WiiFilesystemFactory) WiiFilesystemFactory::WiiFilesystemFactory() : _dvdMounted(false), diff --git a/backends/platform/psp/powerman.cpp b/backends/platform/psp/powerman.cpp index f00272384d..2f0086089c 100644 --- a/backends/platform/psp/powerman.cpp +++ b/backends/platform/psp/powerman.cpp @@ -30,7 +30,7 @@ #include "./trace.h" #include "engine.h" -DECLARE_SINGLETON(PowerManager); +DECLARE_SINGLETON(PowerManager) #ifdef __PSP_DEBUG_SUSPEND__ void PowerManager::debugPM() { diff --git a/backends/platform/psp/psploader.cpp b/backends/platform/psp/psploader.cpp index e720fbe4a1..94310936f6 100644 --- a/backends/platform/psp/psploader.cpp +++ b/backends/platform/psp/psploader.cpp @@ -51,7 +51,7 @@ extern char __plugin_hole_start; // Indicates start of hole in program file for extern char __plugin_hole_end; // Indicates end of hole in program file extern char _gp[]; // Value of gp register -DECLARE_SINGLETON(ShortSegmentManager); // For singleton +DECLARE_SINGLETON(ShortSegmentManager) // For singleton // Get rid of symbol table in memory void DLObject::discard_symtab() { diff --git a/base/plugins.cpp b/base/plugins.cpp index c68fd7c461..6c80da65d4 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -283,7 +283,7 @@ void FilePluginProvider::addCustomDirectories(Common::FSList &dirs) const { #pragma mark - -DECLARE_SINGLETON(PluginManager); +DECLARE_SINGLETON(PluginManager) PluginManager::PluginManager() { // Always add the static plugin provider. @@ -375,7 +375,7 @@ bool PluginManager::tryLoadPlugin(Plugin *plugin) { #include "engines/metaengine.h" -DECLARE_SINGLETON(EngineManager); +DECLARE_SINGLETON(EngineManager) GameDescriptor EngineManager::findGame(const Common::String &gameName, const EnginePlugin **plugin) const { // Find the GameDescriptor for this target @@ -421,7 +421,7 @@ const EnginePlugin::List &EngineManager::getPlugins() const { #include "sound/musicplugin.h" -DECLARE_SINGLETON(MusicManager); +DECLARE_SINGLETON(MusicManager) const MusicPlugin::List &MusicManager::getPlugins() const { return (const MusicPlugin::List &)PluginManager::instance().getPlugins(PLUGIN_TYPE_MUSIC); diff --git a/common/EventRecorder.cpp b/common/EventRecorder.cpp index 47ab3da3d6..92cef51cf4 100644 --- a/common/EventRecorder.cpp +++ b/common/EventRecorder.cpp @@ -27,7 +27,7 @@ #include "common/config-manager.h" -DECLARE_SINGLETON(Common::EventRecorder); +DECLARE_SINGLETON(Common::EventRecorder) namespace Common { diff --git a/common/archive.cpp b/common/archive.cpp index f0790f1a27..fe62355b8a 100644 --- a/common/archive.cpp +++ b/common/archive.cpp @@ -270,8 +270,6 @@ SeekableReadStream *SearchSet::createReadStreamForMember(const String &name) con } -DECLARE_SINGLETON(SearchManager); - SearchManager::SearchManager() { clear(); // Force a reset } @@ -291,3 +289,6 @@ void SearchManager::clear() { } } // namespace Common + +DECLARE_SINGLETON(Common::SearchManager) + diff --git a/common/config-manager.cpp b/common/config-manager.cpp index 5934f32012..9d8281a748 100644 --- a/common/config-manager.cpp +++ b/common/config-manager.cpp @@ -29,7 +29,7 @@ #include "common/util.h" #include "common/system.h" -DECLARE_SINGLETON(Common::ConfigManager); +DECLARE_SINGLETON(Common::ConfigManager) static bool isValidDomainName(const Common::String &domName) { const char *p = domName.c_str(); diff --git a/common/singleton.h b/common/singleton.h index 1a7b339bf6..d66fb84cc2 100644 --- a/common/singleton.h +++ b/common/singleton.h @@ -91,7 +91,18 @@ protected: typedef T SingletonBaseType; }; -#define DECLARE_SINGLETON(T) template<> T *Common::Singleton<T>::_singleton = 0 +/** + * Note that you need to use this macro from the global namespace. + * + * This is because C++ requires initial explicit specialization + * to be placed in the same namespace as the template. + * It has to be put in the global namespace to assure the correct + * namespace Common is referenced. + */ +#define DECLARE_SINGLETON(T) \ + namespace Common { \ + template<> T *Singleton<T>::_singleton = 0; \ + } // End of namespace Common } // End of namespace Common diff --git a/engines/lure/sound.cpp b/engines/lure/sound.cpp index bdece99dcd..e725b7c31a 100644 --- a/engines/lure/sound.cpp +++ b/engines/lure/sound.cpp @@ -34,7 +34,7 @@ #include "common/endian.h" #include "sound/midiparser.h" -DECLARE_SINGLETON(Lure::SoundManager); +DECLARE_SINGLETON(Lure::SoundManager) namespace Lure { diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index fe90545280..35e771b2f4 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -27,7 +27,7 @@ #include "common/system.h" #include "common/stack.h" -DECLARE_SINGLETON(Graphics::CursorManager); +DECLARE_SINGLETON(Graphics::CursorManager) namespace Graphics { diff --git a/graphics/fontman.cpp b/graphics/fontman.cpp index 0fc493c402..1827cb69aa 100644 --- a/graphics/fontman.cpp +++ b/graphics/fontman.cpp @@ -25,7 +25,7 @@ #include "graphics/fontman.h" //#include "gui/consolefont.h" -DECLARE_SINGLETON(Graphics::FontManager); +DECLARE_SINGLETON(Graphics::FontManager) namespace Graphics { diff --git a/gui/GuiManager.cpp b/gui/GuiManager.cpp index 3d02816196..99fb3be4dc 100644 --- a/gui/GuiManager.cpp +++ b/gui/GuiManager.cpp @@ -37,7 +37,7 @@ #include "graphics/cursorman.h" -DECLARE_SINGLETON(GUI::GuiManager); +DECLARE_SINGLETON(GUI::GuiManager) namespace GUI { diff --git a/sound/audiocd.cpp b/sound/audiocd.cpp index bd2d4d46f0..b579048973 100644 --- a/sound/audiocd.cpp +++ b/sound/audiocd.cpp @@ -32,7 +32,7 @@ #include "common/util.h" #include "common/system.h" -DECLARE_SINGLETON(Audio::AudioCDManager); +DECLARE_SINGLETON(Audio::AudioCDManager) namespace Audio { |