From 28cbd0a6ba531576227580ef7e263d23d704afb4 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Sat, 21 Feb 2009 12:07:03 +0000 Subject: [PATCH] CPlugin had a non-virtual destructor. This fixes that, plus reindents a bunch of code. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2332 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Common.vcproj | 16 +++--- Source/Core/Common/Src/DynamicLibrary.cpp | 2 +- Source/Core/Common/Src/Plugin.cpp | 10 ++-- Source/Core/Common/Src/Plugin.h | 59 +++++++++++------------ Source/Core/Common/Src/PluginDSP.cpp | 5 +- Source/Core/Common/Src/PluginDSP.h | 2 +- Source/Core/Common/Src/PluginPAD.h | 24 ++++----- Source/Core/Common/Src/PluginVideo.h | 50 ++++++++++--------- Source/Core/Common/Src/PluginWiimote.cpp | 31 ++++++------ Source/Core/Common/Src/PluginWiimote.h | 28 +++++------ Source/Core/Core/Src/PluginManager.cpp | 14 +++--- Source/Core/VideoCommon/Src/VideoCommon.h | 16 +++--- 12 files changed, 130 insertions(+), 127 deletions(-) diff --git a/Source/Core/Common/Common.vcproj b/Source/Core/Common/Common.vcproj index 2cac5e54ac..35dffb7942 100644 --- a/Source/Core/Common/Common.vcproj +++ b/Source/Core/Common/Common.vcproj @@ -461,14 +461,6 @@ - - - - @@ -590,6 +582,14 @@ RelativePath=".\Src\DriveUtil.h" > + + + + diff --git a/Source/Core/Common/Src/DynamicLibrary.cpp b/Source/Core/Common/Src/DynamicLibrary.cpp index f547d84ea1..30c85aabd3 100644 --- a/Source/Core/Common/Src/DynamicLibrary.cpp +++ b/Source/Core/Common/Src/DynamicLibrary.cpp @@ -121,7 +121,7 @@ int DynamicLibrary::Unload() #ifdef _WIN32 retval = FreeLibrary(library); #else - retval = dlclose(library)?0:1; + retval = dlclose(library) ? 0 : 1; #endif if (!retval) diff --git a/Source/Core/Common/Src/Plugin.cpp b/Source/Core/Common/Src/Plugin.cpp index 89ba44247e..d39d1683d3 100644 --- a/Source/Core/Common/Src/Plugin.cpp +++ b/Source/Core/Common/Src/Plugin.cpp @@ -67,7 +67,7 @@ CPlugin::CPlugin(const char* _szName) : valid(false) m_Initialize != 0 && m_Shutdown != 0 && m_DoState != 0) - valid = true; + valid = true; // Save the filename for this plugin Filename = _szName; @@ -83,9 +83,9 @@ bool CPlugin::GetInfo(PLUGIN_INFO& _pluginInfo) { if (m_GetDllInfo != NULL) { m_GetDllInfo(&_pluginInfo); - return(true); + return true; } - return(false); + return false; } // Config: Open the Config window @@ -112,12 +112,8 @@ void CPlugin::DoState(unsigned char **ptr, int mode) { m_DoState(ptr, mode); } -// Run Initialize() in the plugin void CPlugin::Initialize(void *init) { - /* We first check that we have found the Initialize() function, but there - is no restriction on running this several times */ - // Uh, the above comment sounds extremely dubious. if (m_Initialize != NULL) m_Initialize(init); } diff --git a/Source/Core/Common/Src/Plugin.h b/Source/Core/Common/Src/Plugin.h index 90cd82a888..7018ee54ec 100644 --- a/Source/Core/Common/Src/Plugin.h +++ b/Source/Core/Common/Src/Plugin.h @@ -34,41 +34,38 @@ namespace Common class CPlugin { - public: +public: + CPlugin(const char* _szName); + virtual ~CPlugin(); - CPlugin(const char* _szName); - ~CPlugin(); + // This functions is only used when CPlugin is called directly, when a parent class like PluginVideo + // is called its own IsValid() will be called. + virtual bool IsValid() { return valid; }; + std::string GetFilename() const { return Filename; } + bool GetInfo(PLUGIN_INFO& _pluginInfo); + void SetGlobals(PLUGIN_GLOBALS* _PluginGlobals); + void *LoadSymbol(const char *sym); - // This functions is only used when CPlugin is called directly, when a parent class like PluginVideo - // is called its own IsValid() will be called. - virtual bool IsValid() {return valid;}; - std::string GetFilename() {return Filename;}; + void Config(HWND _hwnd); + void About(HWND _hwnd); + void Debug(HWND _hwnd, bool Show); + void DoState(unsigned char **ptr, int mode); + void Initialize(void *init); + void Shutdown(); - bool GetInfo(PLUGIN_INFO& _pluginInfo); - void SetGlobals(PLUGIN_GLOBALS* _PluginGlobals); - void *LoadSymbol(const char *sym); +private: + DynamicLibrary m_hInstLib; + std::string Filename; + bool valid; - void Config(HWND _hwnd); - void About(HWND _hwnd); - void Debug(HWND _hwnd, bool Show); - void DoState(unsigned char **ptr, int mode); - void Initialize(void *init); - void Shutdown(); - - private: - - DynamicLibrary m_hInstLib; - bool valid; - std::string Filename; - - // Functions - TGetDllInfo m_GetDllInfo; - TDllConfig m_DllConfig; - TDllDebugger m_DllDebugger; - TSetDllGlobals m_SetDllGlobals; - TInitialize m_Initialize; - TShutdown m_Shutdown; - TDoState m_DoState; + // Functions + TGetDllInfo m_GetDllInfo; + TDllConfig m_DllConfig; + TDllDebugger m_DllDebugger; + TSetDllGlobals m_SetDllGlobals; + TInitialize m_Initialize; + TShutdown m_Shutdown; + TDoState m_DoState; }; } // end of namespace Common diff --git a/Source/Core/Common/Src/PluginDSP.cpp b/Source/Core/Common/Src/PluginDSP.cpp index 5e4d4d29d9..5c5f8507be 100644 --- a/Source/Core/Common/Src/PluginDSP.cpp +++ b/Source/Core/Common/Src/PluginDSP.cpp @@ -2,8 +2,9 @@ namespace Common { -PluginDSP::PluginDSP(const char *_Filename) : CPlugin(_Filename), validDSP(false) { - +PluginDSP::PluginDSP(const char *_Filename) +: CPlugin(_Filename), validDSP(false) +{ DSP_ReadMailboxHigh = reinterpret_cast (LoadSymbol("DSP_ReadMailboxHigh")); DSP_ReadMailboxLow = reinterpret_cast diff --git a/Source/Core/Common/Src/PluginDSP.h b/Source/Core/Common/Src/PluginDSP.h index c326c64b80..3b9a600bed 100644 --- a/Source/Core/Common/Src/PluginDSP.h +++ b/Source/Core/Common/Src/PluginDSP.h @@ -18,7 +18,7 @@ class PluginDSP : public CPlugin { public: PluginDSP(const char *_Filename); - ~PluginDSP(); + virtual ~PluginDSP(); virtual bool IsValid() {return validDSP;}; TDSP_ReadMailBox DSP_ReadMailboxHigh; diff --git a/Source/Core/Common/Src/PluginPAD.h b/Source/Core/Common/Src/PluginPAD.h index 755c581011..13122503d9 100644 --- a/Source/Core/Common/Src/PluginPAD.h +++ b/Source/Core/Common/Src/PluginPAD.h @@ -5,15 +5,16 @@ #include "Plugin.h" namespace Common { - typedef void (__cdecl* TPAD_GetStatus)(u8, SPADStatus*); - typedef void (__cdecl* TPAD_Input)(u16, u8); - typedef void (__cdecl* TPAD_Rumble)(u8, unsigned int, unsigned int); - typedef unsigned int (__cdecl* TPAD_GetAttachedPads)(); - - class PluginPAD : public CPlugin { - public: + +typedef void (__cdecl* TPAD_GetStatus)(u8, SPADStatus*); +typedef void (__cdecl* TPAD_Input)(u16, u8); +typedef void (__cdecl* TPAD_Rumble)(u8, unsigned int, unsigned int); +typedef unsigned int (__cdecl* TPAD_GetAttachedPads)(); + +class PluginPAD : public CPlugin { +public: PluginPAD(const char *_Filename); - ~PluginPAD(); + virtual ~PluginPAD(); virtual bool IsValid() {return validPAD;}; TPAD_GetStatus PAD_GetStatus; @@ -21,10 +22,11 @@ namespace Common { TPAD_Rumble PAD_Rumble; TPAD_GetAttachedPads PAD_GetAttachedPads; - private: +private: bool validPAD; - }; -} +}; + +} // namespace #endif diff --git a/Source/Core/Common/Src/PluginVideo.h b/Source/Core/Common/Src/PluginVideo.h index 3e76a44e29..a0b72b01c7 100644 --- a/Source/Core/Common/Src/PluginVideo.h +++ b/Source/Core/Common/Src/PluginVideo.h @@ -5,33 +5,35 @@ #include "Plugin.h" namespace Common { - typedef void (__cdecl* TVideo_Prepare)(); - typedef void (__cdecl* TVideo_SendFifoData)(u8*,u32); - typedef void (__cdecl* TVideo_UpdateXFB)(u8*, u32, u32, s32, bool); - typedef bool (__cdecl* TVideo_Screenshot)(const char* filename); - typedef void (__cdecl* TVideo_EnterLoop)(); - typedef void (__cdecl* TVideo_ExitLoop)(); - typedef void (__cdecl* TVideo_AddMessage)(const char* pstr, unsigned int milliseconds); - class PluginVideo : public CPlugin - { - public: - PluginVideo(const char *_Filename); - ~PluginVideo(); - virtual bool IsValid() {return validVideo;}; +typedef void (__cdecl* TVideo_Prepare)(); +typedef void (__cdecl* TVideo_SendFifoData)(u8*,u32); +typedef void (__cdecl* TVideo_UpdateXFB)(u8*, u32, u32, s32, bool); +typedef bool (__cdecl* TVideo_Screenshot)(const char* filename); +typedef void (__cdecl* TVideo_EnterLoop)(); +typedef void (__cdecl* TVideo_ExitLoop)(); +typedef void (__cdecl* TVideo_AddMessage)(const char* pstr, unsigned int milliseconds); - TVideo_Prepare Video_Prepare; - TVideo_SendFifoData Video_SendFifoData; - TVideo_EnterLoop Video_EnterLoop; - TVideo_ExitLoop Video_ExitLoop; - TVideo_UpdateXFB Video_UpdateXFB; +class PluginVideo : public CPlugin +{ +public: + PluginVideo(const char *_Filename); + virtual ~PluginVideo(); + virtual bool IsValid() {return validVideo;}; - TVideo_AddMessage Video_AddMessage; - TVideo_Screenshot Video_Screenshot; + TVideo_Prepare Video_Prepare; + TVideo_SendFifoData Video_SendFifoData; + TVideo_EnterLoop Video_EnterLoop; + TVideo_ExitLoop Video_ExitLoop; + TVideo_UpdateXFB Video_UpdateXFB; - private: - bool validVideo; - }; -} + TVideo_AddMessage Video_AddMessage; + TVideo_Screenshot Video_Screenshot; + +private: + bool validVideo; +}; + +} // namespace #endif diff --git a/Source/Core/Common/Src/PluginWiimote.cpp b/Source/Core/Common/Src/PluginWiimote.cpp index 9587e3b6ae..17a04b8cd6 100644 --- a/Source/Core/Common/Src/PluginWiimote.cpp +++ b/Source/Core/Common/Src/PluginWiimote.cpp @@ -1,24 +1,27 @@ #include "PluginWiimote.h" namespace Common { - PluginWiimote::PluginWiimote(const char *_Filename) : CPlugin(_Filename), validWiimote(false) { - + +PluginWiimote::PluginWiimote(const char *_Filename) + : CPlugin(_Filename), validWiimote(false) +{ Wiimote_ControlChannel = reinterpret_cast - (LoadSymbol("Wiimote_ControlChannel")); + (LoadSymbol("Wiimote_ControlChannel")); Wiimote_InterruptChannel = reinterpret_cast - (LoadSymbol("Wiimote_InterruptChannel")); + (LoadSymbol("Wiimote_InterruptChannel")); Wiimote_Update = reinterpret_cast - (LoadSymbol("Wiimote_Update")); + (LoadSymbol("Wiimote_Update")); Wiimote_GetAttachedControllers = reinterpret_cast - (LoadSymbol("Wiimote_GetAttachedControllers")); + (LoadSymbol("Wiimote_GetAttachedControllers")); if ((Wiimote_ControlChannel != 0) && - (Wiimote_InterruptChannel != 0) && - (Wiimote_Update != 0) && - (Wiimote_GetAttachedControllers != 0)) - validWiimote = true; - } - - PluginWiimote::~PluginWiimote() { - } + (Wiimote_InterruptChannel != 0) && + (Wiimote_Update != 0) && + (Wiimote_GetAttachedControllers != 0)) + validWiimote = true; +} + +PluginWiimote::~PluginWiimote() { +} + } diff --git a/Source/Core/Common/Src/PluginWiimote.h b/Source/Core/Common/Src/PluginWiimote.h index 2a3a902b47..3572dddc7c 100644 --- a/Source/Core/Common/Src/PluginWiimote.h +++ b/Source/Core/Common/Src/PluginWiimote.h @@ -6,27 +6,27 @@ namespace Common { - typedef unsigned int (__cdecl* TPAD_GetAttachedPads)(); - typedef void (__cdecl* TWiimote_Update)(); - typedef void (__cdecl* TWiimote_Output)(u16 _channelID, const void* _pData, u32 _Size); - typedef void (__cdecl* TWiimote_Input)(u16 _channelID, const void* _pData, u32 _Size); - typedef unsigned int (__cdecl* TWiimote_GetAttachedControllers)(); +typedef unsigned int (__cdecl* TPAD_GetAttachedPads)(); +typedef void (__cdecl* TWiimote_Update)(); +typedef void (__cdecl* TWiimote_Output)(u16 _channelID, const void* _pData, u32 _Size); +typedef void (__cdecl* TWiimote_Input)(u16 _channelID, const void* _pData, u32 _Size); +typedef unsigned int (__cdecl* TWiimote_GetAttachedControllers)(); - class PluginWiimote : public CPlugin { - public: +class PluginWiimote : public CPlugin { +public: PluginWiimote(const char *_Filename); - ~PluginWiimote(); + virtual ~PluginWiimote(); virtual bool IsValid() {return validWiimote;}; - TWiimote_Output Wiimote_ControlChannel; - TWiimote_Input Wiimote_InterruptChannel; - TWiimote_Update Wiimote_Update; + TWiimote_Output Wiimote_ControlChannel; + TWiimote_Input Wiimote_InterruptChannel; + TWiimote_Update Wiimote_Update; TWiimote_GetAttachedControllers Wiimote_GetAttachedControllers; - private: +private: bool validWiimote; +}; - }; -} +} // namespace #endif diff --git a/Source/Core/Core/Src/PluginManager.cpp b/Source/Core/Core/Src/PluginManager.cpp index aef91f512d..9b1bbd71fe 100644 --- a/Source/Core/Core/Src/PluginManager.cpp +++ b/Source/Core/Core/Src/PluginManager.cpp @@ -79,6 +79,8 @@ CPluginManager CPluginManager::m_Instance; ////////////////////////////////////////////////////////////////////////////////////////// // The Plugin Manager Class // ŻŻŻŻŻŻŻŻŻŻŻŻ + +// The plugin manager is some sort of singleton that runs during Dolphin's entire lifespan. CPluginManager::CPluginManager() : m_params(SConfig::GetInstance().m_LocalCoreStartupParameter) { @@ -87,7 +89,7 @@ CPluginManager::CPluginManager() : m_PluginGlobals->config = (void *)&SConfig::GetInstance(); m_PluginGlobals->messageLogger = NULL; - // Set initial values to NULL, this is only done when Dolphin is started + // Set initial values to NULL. m_video = NULL; m_dsp = NULL; for (int i = 0; i < MAXPADS; i++) @@ -104,8 +106,10 @@ CPluginManager::~CPluginManager() delete m_PluginGlobals; delete m_dsp; - for (int i = 0; i < MAXPADS; i++) { - if (m_pad[i] && OkayToInitPlugin(i)) { + for (int i = 0; i < MAXPADS; i++) + { + if (m_pad[i] && OkayToInitPlugin(i)) + { Console::Print("Delete: %i\n", i); delete m_pad[i]; } @@ -183,7 +187,7 @@ bool CPluginManager::InitPlugins() void CPluginManager::ShutdownPlugins() { for (int i = 0; i < MAXPADS; i++) { - if (m_pad[i] && OkayToInitPlugin(i)) { + if (m_pad[i]) { m_pad[i]->Shutdown(); //delete m_pad[i]; } @@ -201,7 +205,6 @@ void CPluginManager::ShutdownPlugins() if (m_video) { m_video->Shutdown(); - // This is needed for Stop and Start to work delete m_video; m_video = NULL; } @@ -209,7 +212,6 @@ void CPluginManager::ShutdownPlugins() if (m_dsp) { m_dsp->Shutdown(); - // This is needed for Stop and Start to work delete m_dsp; m_dsp = NULL; } diff --git a/Source/Core/VideoCommon/Src/VideoCommon.h b/Source/Core/VideoCommon/Src/VideoCommon.h index 0a99340c02..5bd47db4f4 100644 --- a/Source/Core/VideoCommon/Src/VideoCommon.h +++ b/Source/Core/VideoCommon/Src/VideoCommon.h @@ -111,16 +111,16 @@ void HandleGLError(); #ifdef _WIN32 -#define ERROR_LOG(...) LOG(VIDEO, __VA_ARGS__) -#define INFO_LOG(...) LOG(VIDEO, __VA_ARGS__) -#define PRIM_LOG(...) LOG(VIDEO, __VA_ARGS__) -#define DEBUG_LOG(...) LOG(VIDEO, __VA_ARGS__) +#define ERROR_LOG(...) {LOG(VIDEO, __VA_ARGS__)} +#define INFO_LOG(...) {LOG(VIDEO, __VA_ARGS__)} +#define PRIM_LOG(...) {LOG(VIDEO, __VA_ARGS__)} +#define DEBUG_LOG(...) {LOG(VIDEO, __VA_ARGS__)} #else -#define ERROR_LOG(...) LOG(VIDEO, ##__VA_ARGS__) -#define INFO_LOG(...) LOG(VIDEO, ##__VA_ARGS__) -#define PRIM_LOG(...) LOG(VIDEO, ##__VA_ARGS__) -#define DEBUG_LOG(...) LOG(VIDEO, ##__VA_ARGS__) +#define ERROR_LOG(...) {LOG(VIDEO, ##__VA_ARGS__)} +#define INFO_LOG(...) {LOG(VIDEO, ##__VA_ARGS__)} +#define PRIM_LOG(...) {LOG(VIDEO, ##__VA_ARGS__)} +#define DEBUG_LOG(...) {LOG(VIDEO, ##__VA_ARGS__)} #endif #ifdef LOGGING