From 3c9496233280b02f5a1e86e47d2262562141a951 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 21 May 2017 17:18:11 -0400 Subject: [PATCH 1/5] SignatureDB: Move two functions into the cpp file These are implementation details. --- .../Core/PowerPC/SignatureDB/SignatureDB.cpp | 22 ++++++++++--------- .../Core/PowerPC/SignatureDB/SignatureDB.h | 3 --- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp index d9582d99de..667d974d29 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp +++ b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp @@ -18,15 +18,9 @@ #include "Core/PowerPC/SignatureDB/DSYSignatureDB.h" #include "Core/PowerPC/SignatureDB/MEGASignatureDB.h" -SignatureDB::SignatureDB(SignatureDB::HandlerType handler) : m_handler(CreateFormatHandler(handler)) +namespace { -} - -SignatureDB::SignatureDB(const std::string& file_path) : SignatureDB(GetHandlerType(file_path)) -{ -} - -SignatureDB::HandlerType SignatureDB::GetHandlerType(const std::string& file_path) +SignatureDB::HandlerType GetHandlerType(const std::string& file_path) { if (StringEndsWith(file_path, ".csv")) return SignatureDB::HandlerType::CSV; @@ -35,8 +29,7 @@ SignatureDB::HandlerType SignatureDB::GetHandlerType(const std::string& file_pat return SignatureDB::HandlerType::DSY; } -std::unique_ptr -SignatureDB::CreateFormatHandler(SignatureDB::HandlerType handler) const +std::unique_ptr CreateFormatHandler(SignatureDB::HandlerType handler) { switch (handler) { @@ -49,6 +42,15 @@ SignatureDB::CreateFormatHandler(SignatureDB::HandlerType handler) const return std::make_unique(); } } +} // Anonymous namespace + +SignatureDB::SignatureDB(SignatureDB::HandlerType handler) : m_handler(CreateFormatHandler(handler)) +{ +} + +SignatureDB::SignatureDB(const std::string& file_path) : SignatureDB(GetHandlerType(file_path)) +{ +} void SignatureDB::Clear() { diff --git a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.h b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.h index 01277c9bd5..d3fb9b5b3b 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.h +++ b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.h @@ -27,8 +27,6 @@ public: explicit SignatureDB(HandlerType handler); explicit SignatureDB(const std::string& file_path); - static HandlerType GetHandlerType(const std::string& file_path); - void Clear(); // Does not clear. Remember to clear first if that's what you want. bool Load(const std::string& file_path); @@ -41,7 +39,6 @@ public: bool Add(u32 start_addr, u32 size, const std::string& name); private: - std::unique_ptr CreateFormatHandler(HandlerType handler) const; std::unique_ptr m_handler; }; From 5301efddd059d7153521bfc5fdcab81fdbcabb7c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 21 May 2017 17:21:22 -0400 Subject: [PATCH 2/5] SignatureDB: Remove unnecessary qualifiers and virtual keywords --- Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp | 2 +- Source/Core/Core/PowerPC/SignatureDB/SignatureDB.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp index 667d974d29..55f3ba6100 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp +++ b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp @@ -44,7 +44,7 @@ std::unique_ptr CreateFormatHandler(SignatureDB::Handl } } // Anonymous namespace -SignatureDB::SignatureDB(SignatureDB::HandlerType handler) : m_handler(CreateFormatHandler(handler)) +SignatureDB::SignatureDB(HandlerType handler) : m_handler(CreateFormatHandler(handler)) { } diff --git a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.h b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.h index d3fb9b5b3b..5a507e966c 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.h +++ b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.h @@ -73,13 +73,13 @@ public: static u32 ComputeCodeChecksum(u32 offsetStart, u32 offsetEnd); - virtual void Clear() override; - virtual void List() const override; + void Clear() override; + void List() const override; - virtual void Populate(const PPCSymbolDB* func_db, const std::string& filter = "") override; - virtual void Apply(PPCSymbolDB* func_db) const override; + void Populate(const PPCSymbolDB* func_db, const std::string& filter = "") override; + void Apply(PPCSymbolDB* func_db) const override; - virtual bool Add(u32 startAddr, u32 size, const std::string& name) override; + bool Add(u32 startAddr, u32 size, const std::string& name) override; protected: // Map from signature to function. We store the DB in this map because it optimizes the From d0089191e102859dfc55cad219b09e8254280e15 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 21 May 2017 17:22:37 -0400 Subject: [PATCH 3/5] SignatureDB: default the format handler destructor --- Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp index 55f3ba6100..b4b5eb78ed 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp +++ b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp @@ -219,6 +219,4 @@ u32 HashSignatureDB::ComputeCodeChecksum(u32 offsetStart, u32 offsetEnd) return sum; } -SignatureDBFormatHandler::~SignatureDBFormatHandler() -{ -} +SignatureDBFormatHandler::~SignatureDBFormatHandler() = default; From bbe1e643fb9fb83d55345101e793afd75d040b00 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 21 May 2017 17:24:14 -0400 Subject: [PATCH 4/5] SignatureDB: in-class initialize DBFunc members --- Source/Core/Core/PowerPC/SignatureDB/SignatureDB.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.h b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.h index 5a507e966c..efcd22ea37 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.h +++ b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.h @@ -63,11 +63,10 @@ class HashSignatureDB : public SignatureDBFormatHandler public: struct DBFunc { - u32 size; + u32 size = 0; std::string name; std::string object_name; std::string object_location; - DBFunc() : size(0) {} }; using FuncDB = std::map; From c3bab0b0e7ff25293455f89829a188237ef048cb Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 21 May 2017 17:35:49 -0400 Subject: [PATCH 5/5] SignatureDB: Remove unnecessary header --- Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp index b4b5eb78ed..4dfd5f64a0 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp +++ b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp @@ -5,7 +5,6 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/StringUtil.h" #include "Core/PowerPC/PPCAnalyst.h"