From aa0f307e06e5aae3b12f9f15b350dc81b30d61de Mon Sep 17 00:00:00 2001 From: Ori Avtalion Date: Tue, 28 Jun 2011 02:06:23 +0300 Subject: [PATCH] ALL: Require DECLARE_SINGLETON to be used in the Common namepsace Silences the clang warning: static data member specialization of '_singleton' must originally be declared in namespace 'Common'; accepted as a C++0x extension [-Wc++0x-extensions] Wrapping "namespace Common {}" around the macro assignment causes clang to complain about a spurious semicolon, and removing the semicolon at the end of the macro causes some editors to misbehave. Changing the requirement of using the macro in one namespace (the global) to another (Common) seems a small price to pay to silence a warning. --- backends/fs/ds/ds-fs-factory.cpp | 2 ++ backends/fs/ps2/ps2-fs-factory.cpp | 2 ++ backends/fs/psp/psp-fs-factory.cpp | 2 ++ backends/fs/wii/wii-fs-factory.cpp | 2 ++ backends/platform/psp/display_manager.cpp | 2 ++ backends/platform/psp/powerman.cpp | 2 ++ backends/platform/psp/rtc.cpp | 2 ++ backends/plugins/elf/memory-manager.cpp | 2 ++ backends/plugins/elf/shorts-segment-manager.cpp | 2 ++ base/plugins.cpp | 4 ++++ common/EventRecorder.cpp | 4 ++-- common/archive.cpp | 4 ++-- common/config-manager.cpp | 4 ++-- common/debug.cpp | 4 ++-- common/singleton.h | 6 ++---- common/translation.cpp | 4 ++-- engines/lure/sound.cpp | 2 ++ engines/sword25/gfx/animationtemplateregistry.cpp | 2 ++ engines/sword25/math/regionregistry.cpp | 2 ++ engines/sword25/sword25.cpp | 2 ++ engines/testbed/config-params.cpp | 2 ++ graphics/cursorman.cpp | 2 ++ graphics/fontman.cpp | 2 ++ graphics/yuv_to_rgb.cpp | 2 ++ gui/gui-manager.cpp | 2 ++ 25 files changed, 52 insertions(+), 14 deletions(-) diff --git a/backends/fs/ds/ds-fs-factory.cpp b/backends/fs/ds/ds-fs-factory.cpp index 3fd97d07eb2..4e09c3446b9 100644 --- a/backends/fs/ds/ds-fs-factory.cpp +++ b/backends/fs/ds/ds-fs-factory.cpp @@ -27,7 +27,9 @@ #include "backends/fs/ds/ds-fs.h" #include "dsmain.h" //for the isGBAMPAvailable() function +namespace Common { DECLARE_SINGLETON(DSFilesystemFactory); +} AbstractFSNode *DSFilesystemFactory::makeRootFileNode() const { if (DS::isGBAMPAvailable()) { diff --git a/backends/fs/ps2/ps2-fs-factory.cpp b/backends/fs/ps2/ps2-fs-factory.cpp index cad92b5dec2..ef7b2013a38 100644 --- a/backends/fs/ps2/ps2-fs-factory.cpp +++ b/backends/fs/ps2/ps2-fs-factory.cpp @@ -27,7 +27,9 @@ #include "backends/fs/ps2/ps2-fs-factory.h" #include "backends/fs/ps2/ps2-fs.h" +namespace Common { 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 ef1df246ba0..bb3aca8ee65 100644 --- a/backends/fs/psp/psp-fs-factory.cpp +++ b/backends/fs/psp/psp-fs-factory.cpp @@ -43,7 +43,9 @@ #include +namespace Common { 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 34cde8ef46c..fbc9ef1da86 100644 --- a/backends/fs/wii/wii-fs-factory.cpp +++ b/backends/fs/wii/wii-fs-factory.cpp @@ -40,7 +40,9 @@ #include #endif +namespace Common { DECLARE_SINGLETON(WiiFilesystemFactory); +} WiiFilesystemFactory::WiiFilesystemFactory() : _dvdMounted(false), diff --git a/backends/platform/psp/display_manager.cpp b/backends/platform/psp/display_manager.cpp index e945dca4a8e..422805714f0 100644 --- a/backends/platform/psp/display_manager.cpp +++ b/backends/platform/psp/display_manager.cpp @@ -62,7 +62,9 @@ const OSystem::GraphicsMode DisplayManager::_supportedModes[] = { // Class VramAllocator ----------------------------------- +namespace Common { DECLARE_SINGLETON(VramAllocator); +} //#define __PSP_DEBUG_FUNCS__ /* For debugging the stack */ //#define __PSP_DEBUG_PRINT__ diff --git a/backends/platform/psp/powerman.cpp b/backends/platform/psp/powerman.cpp index fe9dcfa6738..b72d05809de 100644 --- a/backends/platform/psp/powerman.cpp +++ b/backends/platform/psp/powerman.cpp @@ -30,7 +30,9 @@ //#define __PSP_DEBUG_PRINT__ #include "backends/platform/psp/trace.h" +namespace Common { DECLARE_SINGLETON(PowerManager); +} // Function to debug the Power Manager (we have no output to screen) inline void PowerManager::debugPM() { diff --git a/backends/platform/psp/rtc.cpp b/backends/platform/psp/rtc.cpp index 3d6d4295a61..6c8e9199864 100644 --- a/backends/platform/psp/rtc.cpp +++ b/backends/platform/psp/rtc.cpp @@ -34,7 +34,9 @@ // Class PspRtc --------------------------------------------------------------- +namespace Common { DECLARE_SINGLETON(PspRtc); +} void PspRtc::init() { // init our starting ticks uint32 ticks[2]; diff --git a/backends/plugins/elf/memory-manager.cpp b/backends/plugins/elf/memory-manager.cpp index 02669b36478..058d818dc46 100644 --- a/backends/plugins/elf/memory-manager.cpp +++ b/backends/plugins/elf/memory-manager.cpp @@ -29,7 +29,9 @@ #include "common/util.h" #include +namespace Common { DECLARE_SINGLETON(ELFMemoryManager); +} ELFMemoryManager::ELFMemoryManager() : _heap(0), _heapSize(0), _heapAlign(0), diff --git a/backends/plugins/elf/shorts-segment-manager.cpp b/backends/plugins/elf/shorts-segment-manager.cpp index b3a9531c2dd..caa328a4f23 100644 --- a/backends/plugins/elf/shorts-segment-manager.cpp +++ b/backends/plugins/elf/shorts-segment-manager.cpp @@ -33,7 +33,9 @@ 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 +namespace Common { DECLARE_SINGLETON(ShortSegmentManager); // For singleton +} ShortSegmentManager::ShortSegmentManager() { _shortsStart = &__plugin_hole_start ; //shorts segment begins at the plugin hole we made when linking diff --git a/base/plugins.cpp b/base/plugins.cpp index 4c2fd2cffc7..4413995b886 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -540,7 +540,9 @@ void PluginManager::addToPluginsInMemList(Plugin *plugin) { #include "engines/metaengine.h" +namespace Common { DECLARE_SINGLETON(EngineManager); +} /** * This function works for both cached and uncached PluginManagers. @@ -631,7 +633,9 @@ const EnginePlugin::List &EngineManager::getPlugins() const { #include "audio/musicplugin.h" +namespace Common { 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 eb22e1ea885..4441070050d 100644 --- a/common/EventRecorder.cpp +++ b/common/EventRecorder.cpp @@ -27,10 +27,10 @@ #include "common/savefile.h" #include "common/textconsole.h" -DECLARE_SINGLETON(Common::EventRecorder); - namespace Common { +DECLARE_SINGLETON(EventRecorder); + #define RECORD_SIGNATURE 0x54455354 #define RECORD_VERSION 1 diff --git a/common/archive.cpp b/common/archive.cpp index 0ef3893a8c9..102d7aaa3f3 100644 --- a/common/archive.cpp +++ b/common/archive.cpp @@ -285,7 +285,7 @@ void SearchManager::clear() { addDirectory(".", ".", -2); } +DECLARE_SINGLETON(SearchManager); + } // namespace Common -DECLARE_SINGLETON(Common::SearchManager); - diff --git a/common/config-manager.cpp b/common/config-manager.cpp index a9d8c890356..fbdb611f3cb 100644 --- a/common/config-manager.cpp +++ b/common/config-manager.cpp @@ -27,8 +27,6 @@ #include "common/system.h" #include "common/textconsole.h" -DECLARE_SINGLETON(Common::ConfigManager); - static bool isValidDomainName(const Common::String &domName) { const char *p = domName.c_str(); while (*p && (isalnum(static_cast(*p)) || *p == '-' || *p == '_')) @@ -38,6 +36,8 @@ static bool isValidDomainName(const Common::String &domName) { namespace Common { +DECLARE_SINGLETON(ConfigManager); + const char *ConfigManager::kApplicationDomain = "scummvm"; const char *ConfigManager::kTransientDomain = "__TRANSIENT"; diff --git a/common/debug.cpp b/common/debug.cpp index 0dae344bb28..50f99753db3 100644 --- a/common/debug.cpp +++ b/common/debug.cpp @@ -29,10 +29,10 @@ // TODO: Move gDebugLevel into namespace Common. int gDebugLevel = -1; -DECLARE_SINGLETON(Common::DebugManager); - namespace Common { +DECLARE_SINGLETON(DebugManager); + namespace { struct DebugLevelComperator { diff --git a/common/singleton.h b/common/singleton.h index 2f5fa41877d..43f1c0c4d03 100644 --- a/common/singleton.h +++ b/common/singleton.h @@ -89,15 +89,13 @@ protected: }; /** - * Note that you need to use this macro from the global namespace. + * Note that you need to use this macro from the Common 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) \ - template<> T *Common::Singleton::_singleton = 0 + template<> T *Singleton::_singleton = 0 } // End of namespace Common diff --git a/common/translation.cpp b/common/translation.cpp index e456f733fd8..5c8a04352da 100644 --- a/common/translation.cpp +++ b/common/translation.cpp @@ -37,10 +37,10 @@ #ifdef USE_TRANSLATION -DECLARE_SINGLETON(Common::TranslationManager); - namespace Common { +DECLARE_SINGLETON(TranslationManager); + bool operator<(const TLanguage &l, const TLanguage &r) { return strcmp(l.name, r.name) < 0; } diff --git a/engines/lure/sound.cpp b/engines/lure/sound.cpp index cf28e0bb747..85b86a84001 100644 --- a/engines/lure/sound.cpp +++ b/engines/lure/sound.cpp @@ -31,7 +31,9 @@ #include "common/endian.h" #include "audio/midiparser.h" +namespace Common { DECLARE_SINGLETON(Lure::SoundManager); +} namespace Lure { diff --git a/engines/sword25/gfx/animationtemplateregistry.cpp b/engines/sword25/gfx/animationtemplateregistry.cpp index 43c099c89d2..8184b49eba8 100644 --- a/engines/sword25/gfx/animationtemplateregistry.cpp +++ b/engines/sword25/gfx/animationtemplateregistry.cpp @@ -34,7 +34,9 @@ #include "sword25/gfx/animationtemplateregistry.h" #include "sword25/gfx/animationtemplate.h" +namespace Common { DECLARE_SINGLETON(Sword25::AnimationTemplateRegistry); +} namespace Sword25 { diff --git a/engines/sword25/math/regionregistry.cpp b/engines/sword25/math/regionregistry.cpp index dff85602050..68c360a5ee7 100644 --- a/engines/sword25/math/regionregistry.cpp +++ b/engines/sword25/math/regionregistry.cpp @@ -34,7 +34,9 @@ #include "sword25/math/regionregistry.h" #include "sword25/math/region.h" +namespace Common { DECLARE_SINGLETON(Sword25::RegionRegistry); +} namespace Sword25 { diff --git a/engines/sword25/sword25.cpp b/engines/sword25/sword25.cpp index b111746c32a..22011880524 100644 --- a/engines/sword25/sword25.cpp +++ b/engines/sword25/sword25.cpp @@ -50,7 +50,9 @@ #include "sword25/gfx/animationtemplateregistry.h" // Needed so we can destroy the singleton #include "sword25/gfx/renderobjectregistry.h" // Needed so we can destroy the singleton +namespace Common { DECLARE_SINGLETON(Sword25::RenderObjectRegistry); +} #include "sword25/math/regionregistry.h" // Needed so we can destroy the singleton namespace Sword25 { diff --git a/engines/testbed/config-params.cpp b/engines/testbed/config-params.cpp index 9a5062185b2..d7ead48f630 100644 --- a/engines/testbed/config-params.cpp +++ b/engines/testbed/config-params.cpp @@ -24,7 +24,9 @@ #include "testbed/config-params.h" +namespace Common { DECLARE_SINGLETON(Testbed::ConfigParams); +} namespace Testbed { diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index a5498903e2b..1d4e482bf49 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -24,7 +24,9 @@ #include "common/system.h" #include "common/stack.h" +namespace Common { DECLARE_SINGLETON(Graphics::CursorManager); +} namespace Graphics { diff --git a/graphics/fontman.cpp b/graphics/fontman.cpp index f40cf976029..d1da5507473 100644 --- a/graphics/fontman.cpp +++ b/graphics/fontman.cpp @@ -23,7 +23,9 @@ #include "graphics/fontman.h" #include "common/translation.h" +namespace Common { DECLARE_SINGLETON(Graphics::FontManager); +} namespace Graphics { diff --git a/graphics/yuv_to_rgb.cpp b/graphics/yuv_to_rgb.cpp index 037ea9a007c..bdc481016ea 100644 --- a/graphics/yuv_to_rgb.cpp +++ b/graphics/yuv_to_rgb.cpp @@ -189,7 +189,9 @@ const YUVToRGBLookup *YUVToRGBManager::getLookup(Graphics::PixelFormat format) { } // End of namespace Graphics +namespace Common { DECLARE_SINGLETON(Graphics::YUVToRGBManager); +} #define YUVToRGBMan (Graphics::YUVToRGBManager::instance()) diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp index af1852d56d6..212d68430c9 100644 --- a/gui/gui-manager.cpp +++ b/gui/gui-manager.cpp @@ -39,7 +39,9 @@ #include "graphics/cursorman.h" +namespace Common { DECLARE_SINGLETON(GUI::GuiManager); +} namespace GUI {