From 5c84ad30a199b59950bebf16c3985d169c932ac5 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Mon, 21 Jul 2014 19:58:03 +0400 Subject: [PATCH] LogBase class for both SysCallBase and Module --- rpcs3/Emu/SysCalls/LogBase.h | 75 +++++++++++++++++++++++++ rpcs3/Emu/SysCalls/Modules.cpp | 2 +- rpcs3/Emu/SysCalls/Modules.h | 66 +--------------------- rpcs3/Emu/SysCalls/Modules/libmixer.cpp | 6 +- rpcs3/Emu/SysCalls/SysCalls.h | 69 ++--------------------- rpcs3/emucore.vcxproj | 1 + rpcs3/emucore.vcxproj.filters | 3 + 7 files changed, 90 insertions(+), 132 deletions(-) create mode 100644 rpcs3/Emu/SysCalls/LogBase.h diff --git a/rpcs3/Emu/SysCalls/LogBase.h b/rpcs3/Emu/SysCalls/LogBase.h new file mode 100644 index 0000000000..9be179baec --- /dev/null +++ b/rpcs3/Emu/SysCalls/LogBase.h @@ -0,0 +1,75 @@ +#pragma once + +class LogBase +{ + bool m_logging; + +public: + LogBase() + : m_logging(false) + { + } + + void SetLogging(bool value) + { + m_logging = value; + } + + virtual const std::string& GetName() const = 0; + + template void Notice(const u32 id, const char* fmt, Targs... args) + { + LOG_NOTICE(HLE, GetName() + fmt::Format("[%d]: ", id) + fmt::Format(fmt, args...)); + } + + template void Notice(const char* fmt, Targs... args) + { + LOG_NOTICE(HLE, GetName() + ": " + fmt::Format(fmt, args...)); + } + + template __forceinline void Log(const char* fmt, Targs... args) + { + if (m_logging) + { + Notice(fmt, args...); + } + } + + template __forceinline void Log(const u32 id, const char* fmt, Targs... args) + { + if (m_logging) + { + Notice(id, fmt, args...); + } + } + + template void Warning(const u32 id, const char* fmt, Targs... args) + { + LOG_WARNING(HLE, GetName() + fmt::Format("[%d] warning: ", id) + fmt::Format(fmt, args...)); + } + + template void Warning(const char* fmt, Targs... args) + { + LOG_WARNING(HLE, GetName() + " warning: " + fmt::Format(fmt, args...)); + } + + template void Error(const u32 id, const char* fmt, Targs... args) + { + LOG_ERROR(HLE, GetName() + fmt::Format("[%d] error: ", id) + fmt::Format(fmt, args...)); + } + + template void Error(const char* fmt, Targs... args) + { + LOG_ERROR(HLE, GetName() + " error: " + fmt::Format(fmt, args...)); + } + + template void Todo(const u32 id, const char* fmt, Targs... args) + { + LOG_ERROR(HLE, GetName() + fmt::Format("[%d] TODO: ", id) + fmt::Format(fmt, args...)); + } + + template void Todo(const char* fmt, Targs... args) + { + LOG_ERROR(HLE, GetName() + " TODO: " + fmt::Format(fmt, args...)); + } +}; \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/Modules.cpp b/rpcs3/Emu/SysCalls/Modules.cpp index 4aa50a02fa..78b5d4ba8d 100644 --- a/rpcs3/Emu/SysCalls/Modules.cpp +++ b/rpcs3/Emu/SysCalls/Modules.cpp @@ -148,7 +148,7 @@ u16 Module::GetID() const return m_id; } -std::string Module::GetName() const +const std::string& Module::GetName() const { return m_name; } diff --git a/rpcs3/Emu/SysCalls/Modules.h b/rpcs3/Emu/SysCalls/Modules.h index b65eba3f4c..a7835db354 100644 --- a/rpcs3/Emu/SysCalls/Modules.h +++ b/rpcs3/Emu/SysCalls/Modules.h @@ -1,6 +1,7 @@ #pragma once #include "Emu/SysCalls/SC_FUNC.h" +#include "LogBase.h" //TODO struct ModuleFunc @@ -41,7 +42,7 @@ struct SFunc } }; -class Module +class Module : public LogBase { std::string m_name; u16 m_id; @@ -73,71 +74,10 @@ public: bool IsLoaded() const; u16 GetID() const; - std::string GetName() const; + virtual const std::string& GetName() const override; void SetName(const std::string& name); public: - bool IsLogging() - { - return Ini.HLELogging.GetValue(); - } - - template void Notice(const u32 id, const char* fmt, Targs... args) - { - LOG_NOTICE(HLE, GetName() + fmt::Format("[%d]: ", id) + fmt::Format(fmt, args...)); - } - - template void Notice(const char* fmt, Targs... args) - { - LOG_NOTICE(HLE, GetName() + ": " + fmt::Format(fmt, args...)); - } - - template __forceinline void Log(const char* fmt, Targs... args) - { - if (IsLogging()) - { - Notice(fmt, args...); - } - } - - template __forceinline void Log(const u32 id, const char* fmt, Targs... args) - { - if (IsLogging()) - { - Notice(id, fmt, args...); - } - } - - template void Warning(const u32 id, const char* fmt, Targs... args) - { - LOG_WARNING(HLE, GetName() + fmt::Format("[%d] warning: ", id) + fmt::Format(fmt, args...)); - } - - template void Warning(const char* fmt, Targs... args) - { - LOG_WARNING(HLE, GetName() + " warning: " + fmt::Format(fmt, args...)); - } - - template void Error(const u32 id, const char* fmt, Targs... args) - { - LOG_ERROR(HLE, GetName() + fmt::Format("[%d] error: ", id) + fmt::Format(fmt, args...)); - } - - template void Error(const char* fmt, Targs... args) - { - LOG_ERROR(HLE, GetName() + " error: " + fmt::Format(fmt, args...)); - } - - template void Todo(const u32 id, const char* fmt, Targs... args) - { - LOG_ERROR(HLE, GetName() + fmt::Format("[%d] TODO: ", id) + fmt::Format(fmt, args...)); - } - - template void Todo(const char* fmt, Targs... args) - { - LOG_ERROR(HLE, GetName() + " TODO: " + fmt::Format(fmt, args...)); - } - bool CheckID(u32 id) const; template bool CheckId(u32 id, T*& data) { diff --git a/rpcs3/Emu/SysCalls/Modules/libmixer.cpp b/rpcs3/Emu/SysCalls/Modules/libmixer.cpp index 3303469eb4..81fe2a7ab7 100644 --- a/rpcs3/Emu/SysCalls/Modules/libmixer.cpp +++ b/rpcs3/Emu/SysCalls/Modules/libmixer.cpp @@ -1206,7 +1206,7 @@ void libmixer_init() 0xf000000048000000 // b ); - REG_SUB_EMPTY(libmixer, "surmxUti", cellSurMixerUtilGetLevelFromDB); - REG_SUB_EMPTY(libmixer, "surmxUti", cellSurMixerUtilGetLevelFromDBIndex); - REG_SUB_EMPTY(libmixer, "surmxUti", cellSurMixerUtilNoteToRatio); + REG_SUB(libmixer, "surmxUti", cellSurMixerUtilGetLevelFromDB, 0); + REG_SUB(libmixer, "surmxUti", cellSurMixerUtilGetLevelFromDBIndex, 0); + REG_SUB(libmixer, "surmxUti", cellSurMixerUtilNoteToRatio, 0); } diff --git a/rpcs3/Emu/SysCalls/SysCalls.h b/rpcs3/Emu/SysCalls/SysCalls.h index 66d07cfd45..61629ba897 100644 --- a/rpcs3/Emu/SysCalls/SysCalls.h +++ b/rpcs3/Emu/SysCalls/SysCalls.h @@ -30,6 +30,7 @@ #include "Emu/Event.h" #include "rpcs3/Ini.h" +#include "LogBase.h" //#define SYSCALLS_DEBUG @@ -49,7 +50,7 @@ namespace detail{ template<> bool CheckId(u32 id, ID*& _id,const std::string &name); } -class SysCallBase //Module +class SysCallBase : public LogBase { private: std::string m_module_name; @@ -62,67 +63,9 @@ public: { } - const std::string& GetName() const { return m_module_name; } - - bool IsLogging() + virtual const std::string& GetName() const override { - return Ini.HLELogging.GetValue(); - } - - template void Notice(const u32 id, const char* fmt, Targs... args) - { - LOG_NOTICE(HLE, GetName() + fmt::Format("[%d]: ", id) + fmt::Format(fmt, args...)); - } - - template void Notice(const char* fmt, Targs... args) - { - LOG_NOTICE(HLE, GetName() + ": " + fmt::Format(fmt, args...)); - } - - template __forceinline void Log(const char* fmt, Targs... args) - { - if (IsLogging()) - { - Notice(fmt, args...); - } - } - - template __forceinline void Log(const u32 id, const char* fmt, Targs... args) - { - if (IsLogging()) - { - Notice(id, fmt, args...); - } - } - - template void Warning(const u32 id, const char* fmt, Targs... args) - { - LOG_WARNING(HLE, GetName() + fmt::Format("[%d] warning: ", id) + fmt::Format(fmt, args...)); - } - - template void Warning(const char* fmt, Targs... args) - { - LOG_WARNING(HLE, GetName() + " warning: " + fmt::Format(fmt, args...)); - } - - template void Error(const u32 id, const char* fmt, Targs... args) - { - LOG_ERROR(HLE, GetName() + fmt::Format("[%d] error: ", id) + fmt::Format(fmt, args...)); - } - - template void Error(const char* fmt, Targs... args) - { - LOG_ERROR(HLE, GetName() + " error: " + fmt::Format(fmt, args...)); - } - - template void Todo(const u32 id, const char* fmt, Targs... args) - { - LOG_ERROR(HLE, GetName() + fmt::Format("[%d] TODO: ", id) + fmt::Format(fmt, args...)); - } - - template void Todo(const char* fmt, Targs... args) - { - LOG_ERROR(HLE, GetName() + " TODO: " + fmt::Format(fmt, args...)); + return m_module_name; } bool CheckId(u32 id) const @@ -190,7 +133,3 @@ public: #define REG_SUB(module, group, name, ...) \ static const u64 name ## _table[] = {__VA_ARGS__ , 0}; \ module->AddFuncSub(group, name ## _table, #name, name) - -#define REG_SUB_EMPTY(module, group, name,...) \ - static const u64 name ## _table[] = {0}; \ - module->AddFuncSub(group, name ## _table, #name, name) diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index 2ee34fa688..0465079533 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -315,6 +315,7 @@ + diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index 446d1a2613..11ce9c141d 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -1093,5 +1093,8 @@ Emu\SysCalls\Modules + + Emu\SysCalls + \ No newline at end of file