Run code through clang-modernize -loop-convert to create range-based for loops, and manually fix some stuff up.

This commit is contained in:
comex
2013-11-03 20:54:01 -05:00
parent 00fe5057f1
commit 965b32be9c
90 changed files with 688 additions and 739 deletions
+2 -2
View File
@@ -158,8 +158,8 @@ void CARCodeAddEdit::UpdateTextCtrl(ActionReplay::ARCode arCode)
if (arCode.name != "")
{
for (u32 i = 0; i < arCode.ops.size(); i++)
EditCheatCode->AppendText(wxString::Format(wxT("%08X %08X\n"), arCode.ops.at(i).cmd_addr, arCode.ops.at(i).value));
for (auto& op : arCode.ops)
EditCheatCode->AppendText(wxString::Format(wxT("%08X %08X\n"), op.cmd_addr, op.value));
}
else
{
+4 -4
View File
@@ -185,9 +185,9 @@ CConfigMain::CConfigMain(wxWindow* parent, wxWindowID id, const wxString& title,
CreateGUIControls();
// Update selected ISO paths
for(u32 i = 0; i < SConfig::GetInstance().m_ISOFolder.size(); i++)
for(auto& folder : SConfig::GetInstance().m_ISOFolder)
{
ISOPaths->Append(StrToWxStr(SConfig::GetInstance().m_ISOFolder[i]));
ISOPaths->Append(StrToWxStr(folder));
}
}
@@ -251,8 +251,8 @@ void CConfigMain::InitializeGUILists()
arrayStringFor_Framelimit.Add(wxString::Format(wxT("%i"), i));
// Emulator Engine
for (unsigned int a = 0; a < (sizeof(CPUCores) / sizeof(CPUCore)); ++a)
arrayStringFor_CPUEngine.Add(wxGetTranslation(CPUCores[a].name));
for (auto& CPUCores_a : CPUCores)
arrayStringFor_CPUEngine.Add(wxGetTranslation(CPUCores_a.name));
// DSP Engine
arrayStringFor_DSPEngine.Add(_("DSP HLE emulation (fast)"));
@@ -32,9 +32,8 @@ void CBreakPointView::Update()
char szBuffer[64];
const BreakPoints::TBreakPoints& rBreakPoints = PowerPC::breakpoints.GetBreakPoints();
for (size_t i = 0; i < rBreakPoints.size(); i++)
for (const auto& rBP : rBreakPoints)
{
const TBreakPoint& rBP = rBreakPoints[i];
if (!rBP.bTemporary)
{
wxString temp;
@@ -59,10 +58,8 @@ void CBreakPointView::Update()
}
const MemChecks::TMemChecks& rMemChecks = PowerPC::memchecks.GetMemChecks();
for (size_t i = 0; i < rMemChecks.size(); i++)
for (const auto& rMemCheck : rMemChecks)
{
const TMemCheck& rMemCheck = rMemChecks[i];
wxString temp;
temp = StrToWxStr((rMemCheck.Break || rMemCheck.Log) ? "on" : " ");
int Item = InsertItem(0, temp);
@@ -296,9 +296,9 @@ void CCodeWindow::UpdateLists()
if (!symbol)
return;
for (int i = 0; i < (int)symbol->callers.size(); i++)
for (auto& call : symbol->callers)
{
u32 caller_addr = symbol->callers[i].callAddress;
u32 caller_addr = call.callAddress;
Symbol *caller_symbol = g_symbolDB.GetSymbolFromAddr(caller_addr);
if (caller_symbol)
{
@@ -309,9 +309,9 @@ void CCodeWindow::UpdateLists()
}
calls->Clear();
for (int i = 0; i < (int)symbol->calls.size(); i++)
for (auto& call : symbol->calls)
{
u32 call_addr = symbol->calls[i].function;
u32 call_addr = call.function;
Symbol *call_symbol = g_symbolDB.GetSymbolFromAddr(call_addr);
if (call_symbol)
{
@@ -332,10 +332,10 @@ void CCodeWindow::UpdateCallstack()
bool ret = Dolphin_Debugger::GetCallstack(stack);
for (size_t i = 0; i < stack.size(); i++)
for (auto& frame : stack)
{
int idx = callstack->Append(StrToWxStr(stack[i].Name));
callstack->SetClientData(idx, (void*)(u64)stack[i].vAddress);
int idx = callstack->Append(StrToWxStr(frame.Name));
callstack->SetClientData(idx, (void*)(u64)frame.vAddress);
}
if (!ret)
@@ -552,8 +552,8 @@ void CCodeWindow::InitBitmaps()
m_Bitmaps[Toolbar_SetPC] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
// scale to 24x24 for toolbar
for (size_t n = 0; n < ToolbarDebugBitmapMax; n++)
m_Bitmaps[n] = wxBitmap(m_Bitmaps[n].ConvertToImage().Scale(24, 24));
for (auto& bitmap : m_Bitmaps)
bitmap = wxBitmap(bitmap.ConvertToImage().Scale(24, 24));
}
void CCodeWindow::PopulateToolbar(wxAuiToolBar* toolBar)
@@ -294,9 +294,9 @@ void CMemoryView::OnPaint(wxPaintEvent& event)
(mem_data&0xff0000)>>16,
(mem_data&0xff00)>>8,
mem_data&0xff};
for (size_t i = 0; i < 4; i++)
if (a[i] == '\0')
a[i] = ' ';
for (auto& word : a)
if (word == '\0')
word = ' ';
sprintf(dis, "%c%c%c%c", a[0], a[1], a[2], a[3]);
}
else if (viewAsType == VIEWAS_HEX)
@@ -314,31 +314,31 @@ void CMemoryView::OnPaint(wxPaintEvent& event)
debugger->readExtraMemory(memory, address+28)
};
for (int i = 0; i < 8; i++)
for (auto& word : mema)
{
char buf[32] = "";
switch (dataType)
{
case 0:
sprintf(buf, " %02X %02X %02X %02X",
((mema[i]&0xff000000)>>24)&0xFF,
((mema[i]&0xff0000)>>16)&0xFF,
((mema[i]&0xff00)>>8)&0xFF,
mema[i]&0xff);
((word&0xff000000)>>24)&0xFF,
((word&0xff0000)>>16)&0xFF,
((word&0xff00)>>8)&0xFF,
word&0xff);
break;
case 1:
sprintf(buf, " %02X%02X %02X%02X",
((mema[i]&0xff000000)>>24)&0xFF,
((mema[i]&0xff0000)>>16)&0xFF,
((mema[i]&0xff00)>>8)&0xFF,
mema[i]&0xff);
((word&0xff000000)>>24)&0xFF,
((word&0xff0000)>>16)&0xFF,
((word&0xff00)>>8)&0xFF,
word&0xff);
break;
case 2:
sprintf(buf, " %02X%02X%02X%02X",
((mema[i]&0xff000000)>>24)&0xFF,
((mema[i]&0xff0000)>>16)&0xFF,
((mema[i]&0xff00)>>8)&0xFF,
mema[i]&0xff);
((word&0xff000000)>>24)&0xFF,
((word&0xff0000)>>16)&0xFF,
((word&0xff00)>>8)&0xFF,
word&0xff);
break;
}
strcat(dis, buf);
+2 -2
View File
@@ -917,8 +917,8 @@ wxString FifoPlayerDlg::CreateRecordingMemSizeLabel() const
for (int frameNum = 0; frameNum < file->GetFrameCount(); ++frameNum)
{
const vector<MemoryUpdate>& memUpdates = file->GetFrame(frameNum).memoryUpdates;
for (unsigned int i = 0; i < memUpdates.size(); ++i)
memBytes += memUpdates[i].size;
for (auto& memUpdate : memUpdates)
memBytes += memUpdate.size;
}
return CreateIntegerLabel(memBytes, _("Memory Byte"));
+19 -19
View File
@@ -905,12 +905,12 @@ void CFrame::LoadIniPerspectives()
ini.Get("Perspectives", "Active", &ActivePerspective, 0);
SplitString(_Perspectives, ',', VPerspectives);
for (u32 i = 0; i < VPerspectives.size(); i++)
for (auto& VPerspective : VPerspectives)
{
SPerspectives Tmp;
std::string _Section, _Perspective, _Width, _Height;
std::string _Section, _Perspective, _Widths, _Heights;
std::vector<std::string> _SWidth, _SHeight;
Tmp.Name = VPerspectives[i];
Tmp.Name = VPerspective;
// Don't save a blank perspective
if (Tmp.Name.empty())
@@ -922,22 +922,22 @@ void CFrame::LoadIniPerspectives()
"name=Pane 0;caption=Pane 0;state=768;dir=5;prop=100000;|"
"name=Pane 1;caption=Pane 1;state=31458108;dir=4;prop=100000;|"
"dock_size(5,0,0)=22|dock_size(4,0,0)=333|");
ini.Get(_Section.c_str(), "Width", &_Width, "70,25");
ini.Get(_Section.c_str(), "Height", &_Height, "80,80");
ini.Get(_Section.c_str(), "Width", &_Widths, "70,25");
ini.Get(_Section.c_str(), "Height", &_Heights, "80,80");
Tmp.Perspective = StrToWxStr(_Perspective);
SplitString(_Width, ',', _SWidth);
SplitString(_Height, ',', _SHeight);
for (u32 j = 0; j < _SWidth.size(); j++)
SplitString(_Widths, ',', _SWidth);
SplitString(_Heights, ',', _SHeight);
for (auto& Width : _SWidth)
{
int _Tmp;
if (TryParse(_SWidth[j].c_str(), &_Tmp)) Tmp.Width.push_back(_Tmp);
if (TryParse(Width.c_str(), &_Tmp)) Tmp.Width.push_back(_Tmp);
}
for (u32 j = 0; j < _SHeight.size(); j++)
for (auto& Height : _SHeight)
{
int _Tmp;
if (TryParse(_SHeight[j].c_str(), &_Tmp)) Tmp.Height.push_back(_Tmp);
if (TryParse(Height.c_str(), &_Tmp)) Tmp.Height.push_back(_Tmp);
}
Perspectives.push_back(Tmp);
}
@@ -983,25 +983,25 @@ void CFrame::SaveIniPerspectives()
// Save perspective names
std::string STmp = "";
for (u32 i = 0; i < Perspectives.size(); i++)
for (auto& Perspective : Perspectives)
{
STmp += Perspectives[i].Name + ",";
STmp += Perspective.Name + ",";
}
STmp = STmp.substr(0, STmp.length()-1);
ini.Set("Perspectives", "Perspectives", STmp.c_str());
ini.Set("Perspectives", "Active", ActivePerspective);
// Save the perspectives
for (u32 i = 0; i < Perspectives.size(); i++)
for (auto& Perspective : Perspectives)
{
std::string _Section = "P - " + Perspectives[i].Name;
ini.Set(_Section.c_str(), "Perspective", WxStrToStr(Perspectives[i].Perspective));
std::string _Section = "P - " + Perspective.Name;
ini.Set(_Section.c_str(), "Perspective", WxStrToStr(Perspective.Perspective));
std::string SWidth = "", SHeight = "";
for (u32 j = 0; j < Perspectives[i].Width.size(); j++)
for (u32 j = 0; j < Perspective.Width.size(); j++)
{
SWidth += StringFromFormat("%i,", Perspectives[i].Width[j]);
SHeight += StringFromFormat("%i,", Perspectives[i].Height[j]);
SWidth += StringFromFormat("%i,", Perspective.Width[j]);
SHeight += StringFromFormat("%i,", Perspective.Height[j]);
}
// Remove the ending ","
SWidth = SWidth.substr(0, SWidth.length()-1);
+2 -2
View File
@@ -1795,9 +1795,9 @@ void CFrame::GameListChanged(wxCommandEvent& event)
CFileSearch FileSearch(Extensions, Directories);
const CFileSearch::XStringVector& rFilenames = FileSearch.GetFileNames();
for (u32 i = 0; i < rFilenames.size(); i++)
for (auto& rFilename : rFilenames)
{
File::Delete(rFilenames[i]);
File::Delete(rFilename);
}
break;
}
+9 -13
View File
@@ -475,15 +475,15 @@ void CGameListCtrl::ScanForISOs()
{
File::FSTEntry FST_Temp;
File::ScanDirectoryTree(Directories[i], FST_Temp);
for (u32 j = 0; j < FST_Temp.children.size(); j++)
for (auto& Entry : FST_Temp.children)
{
if (FST_Temp.children[j].isDirectory)
if (Entry.isDirectory)
{
bool duplicate = false;
for (u32 k = 0; k < Directories.size(); k++)
for (auto& Directory : Directories)
{
if (strcmp(Directories[k].c_str(),
FST_Temp.children[j].physicalName.c_str()) == 0)
if (strcmp(Directory.c_str(),
Entry.physicalName.c_str()) == 0)
{
duplicate = true;
break;
@@ -491,7 +491,7 @@ void CGameListCtrl::ScanForISOs()
}
if (!duplicate)
Directories.push_back(
FST_Temp.children[j].physicalName.c_str());
Entry.physicalName.c_str());
}
}
}
@@ -539,7 +539,7 @@ void CGameListCtrl::ScanForISOs()
if (dialog.WasCancelled())
break;
std::auto_ptr<GameListItem> iso_file(new GameListItem(rFilenames[i]));
std::unique_ptr<GameListItem> iso_file(new GameListItem(rFilenames[i]));
const GameListItem& ISOFile = *iso_file;
if (ISOFile.IsValid())
@@ -603,13 +603,9 @@ void CGameListCtrl::ScanForISOs()
{
const std::vector<std::string> drives = cdio_get_devices();
for (std::vector<std::string>::const_iterator iter = drives.begin(); iter != drives.end(); ++iter)
for (const auto& drive : drives)
{
#ifdef __APPLE__
std::auto_ptr<GameListItem> gli(new GameListItem(*iter));
#else
std::unique_ptr<GameListItem> gli(new GameListItem(*iter));
#endif
std::unique_ptr<GameListItem> gli(new GameListItem(drive));
if (gli->IsValid())
m_ISOFiles.push_back(gli.release());
+9 -12
View File
@@ -1223,9 +1223,8 @@ void CISOProperties::PatchList_Load()
PatchEngine::LoadPatchSection("OnFrame", onFrame, GameIniDefault, GameIniLocal);
u32 index = 0;
for (auto it = onFrame.begin(); it != onFrame.end(); ++it)
for (PatchEngine::Patch& p : onFrame)
{
PatchEngine::Patch p = *it;
Patches->Append(StrToWxStr(p.name));
Patches->Check(index, p.active);
if (!p.user_defined)
@@ -1239,16 +1238,16 @@ void CISOProperties::PatchList_Save()
std::vector<std::string> lines;
std::vector<std::string> enabledLines;
u32 index = 0;
for (auto onFrame_it = onFrame.begin(); onFrame_it != onFrame.end(); ++onFrame_it)
for (PatchEngine::Patch& p : onFrame)
{
if (Patches->IsChecked(index))
enabledLines.push_back("$" + onFrame_it->name);
enabledLines.push_back("$" + p.name);
// Do not save default patches.
if (DefaultPatches.find(onFrame_it->name) == DefaultPatches.end())
if (DefaultPatches.find(p.name) == DefaultPatches.end())
{
lines.push_back("$" + onFrame_it->name);
for (auto iter2 = onFrame_it->entries.begin(); iter2 != onFrame_it->entries.end(); ++iter2)
lines.push_back("$" + p.name);
for (auto iter2 = p.entries.begin(); iter2 != p.entries.end(); ++iter2)
{
std::string temp = StringFromFormat("0x%08X:%s:0x%08X", iter2->address, PatchEngine::PatchTypeStrings[iter2->type], iter2->value);
lines.push_back(temp);
@@ -1330,10 +1329,8 @@ void CISOProperties::ActionReplayList_Save()
std::vector<std::string> lines;
std::vector<std::string> enabledLines;
u32 index = 0;
for (auto iter = arCodes.begin(); iter != arCodes.end(); ++iter)
for (auto code : arCodes)
{
ActionReplay::ARCode code = *iter;
if (Cheats->IsChecked(index))
enabledLines.push_back("$" + code.name);
@@ -1341,9 +1338,9 @@ void CISOProperties::ActionReplayList_Save()
if (DefaultCheats.find(code.name) == DefaultCheats.end())
{
lines.push_back("$" + code.name);
for (auto iter2 = code.ops.begin(); iter2 != code.ops.end(); ++iter2)
for (auto& op : code.ops)
{
lines.push_back(WxStrToStr(wxString::Format(wxT("%08X %08X"), iter2->cmd_addr, iter2->value)));
lines.push_back(WxStrToStr(wxString::Format(wxT("%08X %08X"), op.cmd_addr, op.value)));
}
}
++index;
@@ -905,14 +905,14 @@ ControlGroupsSizer::ControlGroupsSizer(ControllerEmu* const controller, wxWindow
size_t col_size = 0;
wxBoxSizer* stacked_groups = NULL;
for (unsigned int i = 0; i < controller->groups.size(); ++i)
for (ControllerEmu::ControlGroup* group : controller->groups)
{
ControlGroupBox* control_group_box = new ControlGroupBox(controller->groups[i], parent, eventsink);
ControlGroupBox* control_group_box = new ControlGroupBox(group, parent, eventsink);
wxStaticBoxSizer *control_group =
new wxStaticBoxSizer(wxVERTICAL, parent, wxGetTranslation(StrToWxStr(controller->groups[i]->name)));
new wxStaticBoxSizer(wxVERTICAL, parent, wxGetTranslation(StrToWxStr(group->name)));
control_group->Add(control_group_box);
const size_t grp_size = controller->groups[i]->controls.size() + controller->groups[i]->settings.size();
const size_t grp_size = group->controls.size() + group->settings.size();
col_size += grp_size;
if (col_size > 8 || NULL == stacked_groups)
{
@@ -45,12 +45,12 @@ void CWiiSaveCrypted::ExportAllSaves()
std::string folder = StringFromFormat("%s/%08x/", titleFolder.c_str(), pathMask | i);
File::ScanDirectoryTree(folder, FST_Temp);
for (u32 j = 0; j < FST_Temp.children.size(); j++)
for (auto& entry : FST_Temp.children)
{
if (FST_Temp.children[j].isDirectory)
if (entry.isDirectory)
{
u32 gameid;
if (AsciiToHex(FST_Temp.children[j].virtualName.c_str(), gameid))
if (AsciiToHex(entry.virtualName.c_str(), gameid))
{
std::string bannerPath = StringFromFormat("%s%08x/data/banner.bin", folder.c_str(), gameid);
if (File::Exists(bannerPath))
@@ -63,9 +63,9 @@ void CWiiSaveCrypted::ExportAllSaves()
}
}
SuccessAlertT("Found %x save files", (unsigned int) titles.size());
for (u32 i = 0; i < titles.size(); ++i)
for (auto& title : titles)
{
CWiiSaveCrypted* exportSave = new CWiiSaveCrypted("", titles[i]);
CWiiSaveCrypted* exportSave = new CWiiSaveCrypted("", title);
delete exportSave;
}
}
@@ -581,25 +581,25 @@ void CWiiSaveCrypted::ScanForFiles(std::string savDir, std::vector<std::string>&
File::FSTEntry FST_Temp;
File::ScanDirectoryTree(Directories[i], FST_Temp);
for (u32 j = 0; j < FST_Temp.children.size(); j++)
for (auto& elem : FST_Temp.children)
{
if (strncmp(FST_Temp.children.at(j).virtualName.c_str(), "banner.bin", 10) != 0)
if (strncmp(elem.virtualName.c_str(), "banner.bin", 10) != 0)
{
(*_numFiles)++;
*_sizeFiles += FILE_HDR_SZ;
if (FST_Temp.children.at(j).isDirectory)
if (elem.isDirectory)
{
if ((FST_Temp.children.at(j).virtualName == "nocopy") || FST_Temp.children.at(j).virtualName == "nomove")
if ((elem.virtualName == "nocopy") || elem.virtualName == "nomove")
{
PanicAlert("This save will likely require homebrew tools to copy to a real wii");
}
Directories.push_back(FST_Temp.children.at(j).physicalName);
Directories.push_back(elem.physicalName);
}
else
{
FileList.push_back(FST_Temp.children.at(j).physicalName);
*_sizeFiles += ROUND_UP(FST_Temp.children.at(j).size, BLOCK_SZ);
FileList.push_back(elem.physicalName);
*_sizeFiles += ROUND_UP(elem.size, BLOCK_SZ);
}
}
}
+2 -2
View File
@@ -622,8 +622,8 @@ PadMapDiag::PadMapDiag(wxWindow* const parent, PadMapping map[], PadMapping wiim
wxArrayString player_names;
player_names.Add(_("None"));
for (unsigned int i = 0; i < m_player_list.size(); i++)
player_names.Add(m_player_list[i]->name);
for (auto& player : m_player_list)
player_names.Add(player->name);
wxString wiimote_names[5];
wiimote_names[0] = _("None");