From 2848ff342f7d811b4994fc77f746695bb72577b6 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 4 Aug 2014 02:13:59 -0400 Subject: [PATCH 1/2] DolphinWX: More readable variable names in BreakpointView Also doesn't make everything rely on a single temp variable. --- .../DolphinWX/Debugger/BreakpointView.cpp | 49 +++++++++---------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/Source/Core/DolphinWX/Debugger/BreakpointView.cpp b/Source/Core/DolphinWX/Debugger/BreakpointView.cpp index 1d23b7ec63..b6800dee40 100644 --- a/Source/Core/DolphinWX/Debugger/BreakpointView.cpp +++ b/Source/Core/DolphinWX/Debugger/BreakpointView.cpp @@ -15,6 +15,7 @@ #include "Common/BreakPoints.h" #include "Common/CommonTypes.h" +#include "Common/StringUtil.h" #include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/PPCSymbolDB.h" #include "DolphinWX/WxUtils.h" @@ -42,28 +43,24 @@ void CBreakPointView::Update() InsertColumn(3, _("Address")); InsertColumn(4, _("Flags")); - char szBuffer[64]; const BreakPoints::TBreakPoints& rBreakPoints = PowerPC::breakpoints.GetBreakPoints(); for (const auto& rBP : rBreakPoints) { if (!rBP.bTemporary) { - wxString temp; - temp = StrToWxStr(rBP.bOn ? "on" : " "); - int Item = InsertItem(0, temp); - temp = StrToWxStr("BP"); - SetItem(Item, 1, temp); + wxString breakpoint_enabled_str = StrToWxStr(rBP.bOn ? "on" : " "); + int Item = InsertItem(0, breakpoint_enabled_str); + SetItem(Item, 1, StrToWxStr("BP")); Symbol *symbol = g_symbolDB.GetSymbolFromAddr(rBP.iAddress); if (symbol) { - temp = StrToWxStr(g_symbolDB.GetDescription(rBP.iAddress)); - SetItem(Item, 2, temp); + wxString symbol_description = StrToWxStr(g_symbolDB.GetDescription(rBP.iAddress)); + SetItem(Item, 2, symbol_description); } - sprintf(szBuffer, "%08x", rBP.iAddress); - temp = StrToWxStr(szBuffer); - SetItem(Item, 3, temp); + std::string address = StringFromFormat("%08x", rBP.iAddress); + SetItem(Item, 3, StrToWxStr(address)); SetItemData(Item, rBP.iAddress); } @@ -72,29 +69,27 @@ void CBreakPointView::Update() const MemChecks::TMemChecks& rMemChecks = PowerPC::memchecks.GetMemChecks(); for (const auto& rMemCheck : rMemChecks) { - wxString temp; - temp = StrToWxStr((rMemCheck.Break || rMemCheck.Log) ? "on" : " "); - int Item = InsertItem(0, temp); - temp = StrToWxStr("MC"); - SetItem(Item, 1, temp); + wxString memcheck_on_str = StrToWxStr((rMemCheck.Break || rMemCheck.Log) ? "on" : " "); + int Item = InsertItem(0, memcheck_on_str); + SetItem(Item, 1, StrToWxStr("MC")); Symbol *symbol = g_symbolDB.GetSymbolFromAddr(rMemCheck.StartAddress); if (symbol) { - temp = StrToWxStr(g_symbolDB.GetDescription(rMemCheck.StartAddress)); - SetItem(Item, 2, temp); + wxString memcheck_start_addr = StrToWxStr(g_symbolDB.GetDescription(rMemCheck.StartAddress)); + SetItem(Item, 2, memcheck_start_addr); } - sprintf(szBuffer, "%08x to %08x", rMemCheck.StartAddress, rMemCheck.EndAddress); - temp = StrToWxStr(szBuffer); - SetItem(Item, 3, temp); + std::string address_range_str = StringFromFormat("%08x to %08x", rMemCheck.StartAddress, rMemCheck.EndAddress); + SetItem(Item, 3, StrToWxStr(address_range_str)); - size_t c = 0; - if (rMemCheck.OnRead) szBuffer[c++] = 'r'; - if (rMemCheck.OnWrite) szBuffer[c++] = 'w'; - szBuffer[c] = 0x00; - temp = StrToWxStr(szBuffer); - SetItem(Item, 4, temp); + std::string mode; + if (rMemCheck.OnRead) + mode += 'r'; + if (rMemCheck.OnWrite) + mode += 'w'; + + SetItem(Item, 4, StrToWxStr(mode)); SetItemData(Item, rMemCheck.StartAddress); } From 77ccfa1967217e9d8d3d5bc448f2c33240d00bd8 Mon Sep 17 00:00:00 2001 From: lioncash Date: Fri, 15 Aug 2014 09:51:29 -0400 Subject: [PATCH 2/2] DolphinWX: Fix variable styling in BreakpointView --- .../DolphinWX/Debugger/BreakpointView.cpp | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Source/Core/DolphinWX/Debugger/BreakpointView.cpp b/Source/Core/DolphinWX/Debugger/BreakpointView.cpp index b6800dee40..7e36aacf30 100644 --- a/Source/Core/DolphinWX/Debugger/BreakpointView.cpp +++ b/Source/Core/DolphinWX/Debugger/BreakpointView.cpp @@ -49,20 +49,20 @@ void CBreakPointView::Update() if (!rBP.bTemporary) { wxString breakpoint_enabled_str = StrToWxStr(rBP.bOn ? "on" : " "); - int Item = InsertItem(0, breakpoint_enabled_str); - SetItem(Item, 1, StrToWxStr("BP")); + int item = InsertItem(0, breakpoint_enabled_str); + SetItem(item, 1, StrToWxStr("BP")); Symbol *symbol = g_symbolDB.GetSymbolFromAddr(rBP.iAddress); if (symbol) { wxString symbol_description = StrToWxStr(g_symbolDB.GetDescription(rBP.iAddress)); - SetItem(Item, 2, symbol_description); + SetItem(item, 2, symbol_description); } std::string address = StringFromFormat("%08x", rBP.iAddress); - SetItem(Item, 3, StrToWxStr(address)); + SetItem(item, 3, StrToWxStr(address)); - SetItemData(Item, rBP.iAddress); + SetItemData(item, rBP.iAddress); } } @@ -70,18 +70,18 @@ void CBreakPointView::Update() for (const auto& rMemCheck : rMemChecks) { wxString memcheck_on_str = StrToWxStr((rMemCheck.Break || rMemCheck.Log) ? "on" : " "); - int Item = InsertItem(0, memcheck_on_str); - SetItem(Item, 1, StrToWxStr("MC")); + int item = InsertItem(0, memcheck_on_str); + SetItem(item, 1, StrToWxStr("MC")); Symbol *symbol = g_symbolDB.GetSymbolFromAddr(rMemCheck.StartAddress); if (symbol) { wxString memcheck_start_addr = StrToWxStr(g_symbolDB.GetDescription(rMemCheck.StartAddress)); - SetItem(Item, 2, memcheck_start_addr); + SetItem(item, 2, memcheck_start_addr); } std::string address_range_str = StringFromFormat("%08x to %08x", rMemCheck.StartAddress, rMemCheck.EndAddress); - SetItem(Item, 3, StrToWxStr(address_range_str)); + SetItem(item, 3, StrToWxStr(address_range_str)); std::string mode; if (rMemCheck.OnRead) @@ -89,9 +89,9 @@ void CBreakPointView::Update() if (rMemCheck.OnWrite) mode += 'w'; - SetItem(Item, 4, StrToWxStr(mode)); + SetItem(item, 4, StrToWxStr(mode)); - SetItemData(Item, rMemCheck.StartAddress); + SetItemData(item, rMemCheck.StartAddress); } Refresh(); @@ -99,10 +99,10 @@ void CBreakPointView::Update() void CBreakPointView::DeleteCurrentSelection() { - int Item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); - if (Item >= 0) + int item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + if (item >= 0) { - u32 Address = (u32)GetItemData(Item); + u32 Address = (u32)GetItemData(item); PowerPC::breakpoints.Remove(Address); PowerPC::memchecks.Remove(Address); Update();