More range-based loops and overrides

This commit is contained in:
Tillmann Karras 2014-03-11 06:55:00 +01:00
parent 3fc9ca0789
commit 2fcaca0603
18 changed files with 110 additions and 127 deletions

View File

@ -283,13 +283,10 @@ bool RunCode(const ARCode &arcode)
LogInfo("Code Name: %s", arcode.name.c_str());
LogInfo("Number of codes: %i", arcode.ops.size());
std::vector<AREntry>::const_iterator
iter = arcode.ops.begin(),
ops_end = arcode.ops.end();
for (; iter != ops_end; ++iter)
for (const AREntry& entry : arcode.ops)
{
const ARAddr& addr = *(ARAddr*)&iter->cmd_addr;
const u32 data = iter->value;
const ARAddr& addr = *(ARAddr*)&entry.cmd_addr;
const u32 data = entry.value;
// after a conditional code, skip lines if needed
if (skip_count)

View File

@ -24,11 +24,10 @@ InputPlugin *GetPlugin()
void Shutdown()
{
std::vector<ControllerEmu*>::const_iterator
i = g_plugin.controllers.begin(),
e = g_plugin.controllers.end();
for ( ; i!=e; ++i )
delete *i;
for (const ControllerEmu* i : g_plugin.controllers)
{
delete i;
}
g_plugin.controllers.clear();
WiimoteReal::Stop();

View File

@ -299,13 +299,14 @@ public:
static void RunTable59(UGeckoInstruction _instCode);
static void RunTable63(UGeckoInstruction _instCode);
static u32 Helper_Carry(u32 _uValue1, u32 _uValue2);
private:
// flag helper
static void Helper_UpdateCR0(u32 _uValue);
static void Helper_UpdateCR1(double _fValue);
static void Helper_UpdateCR1(float _fValue);
static void Helper_UpdateCRx(int _x, u32 _uValue);
static u32 Helper_Carry(u32 _uValue1, u32 _uValue2);
// address helper
static u32 Helper_Get_EA (const UGeckoInstruction _inst);

View File

@ -547,12 +547,9 @@ void CheatSearchTab::UpdateCheatSearchResultsList()
}
else
{
std::vector<CheatSearchResult>::const_iterator
i = search_results.begin(),
e = search_results.end();
for (; i!=e; ++i)
for (const CheatSearchResult& result : search_results)
{
u32 display_value = i->old_value;
u32 display_value = result.old_value;
// #ifdef LIL_ENDIAN :p
switch (search_type_size)
@ -574,7 +571,7 @@ void CheatSearchTab::UpdateCheatSearchResultsList()
rowfmt[14] = (wxChar)(wxT('0') + search_type_size*2);
lbox_search_results->Append(
wxString::Format(rowfmt, i->address, display_value, display_value, display_value));
wxString::Format(rowfmt, result.address, display_value, display_value, display_value));
}
}

View File

@ -88,14 +88,13 @@ void CodeConfigPanel::UpdateCodeList(bool checkRunning)
m_listbox_gcodes->Clear();
// add the codes to the listbox
std::vector<GeckoCode>::const_iterator
gcodes_iter = m_gcodes.begin(),
gcodes_end = m_gcodes.end();
for (; gcodes_iter!=gcodes_end; ++gcodes_iter)
for (const GeckoCode& code : m_gcodes)
{
m_listbox_gcodes->Append(StrToWxStr(gcodes_iter->name));
if (gcodes_iter->enabled)
m_listbox_gcodes->Append(StrToWxStr(code.name));
if (code.enabled)
{
m_listbox_gcodes->Check(m_listbox_gcodes->GetCount()-1, true);
}
}
wxCommandEvent evt;
@ -131,21 +130,19 @@ void CodeConfigPanel::UpdateInfoBox(wxCommandEvent&)
// notes textctrl
m_infobox.textctrl_notes->Clear();
std::vector<std::string>::const_iterator
notes_iter = m_gcodes[sel].notes.begin(),
notes_end = m_gcodes[sel].notes.end();
for (; notes_iter!=notes_end; ++notes_iter)
m_infobox.textctrl_notes->AppendText(StrToWxStr(*notes_iter));
for (const std::string& note : m_gcodes[sel].notes)
{
m_infobox.textctrl_notes->AppendText(StrToWxStr(note));
}
m_infobox.textctrl_notes->ScrollLines(-99); // silly
m_infobox.label_creator->SetLabel(wxGetTranslation(wxstr_creator) + StrToWxStr(m_gcodes[sel].creator));
// add codes to info listbox
std::vector<GeckoCode::Code>::const_iterator
codes_iter = m_gcodes[sel].codes.begin(),
codes_end = m_gcodes[sel].codes.end();
for (; codes_iter!=codes_end; ++codes_iter)
m_infobox.listbox_codes->Append(wxString::Format(wxT("%08X %08X"), codes_iter->address, codes_iter->data));
for (const GeckoCode::Code& code : m_gcodes[sel].codes)
{
m_infobox.listbox_codes->Append(wxString::Format(wxT("%08X %08X"), code.address, code.data));
}
}
else
{
@ -281,10 +278,7 @@ void CodeConfigPanel::DownloadCodes(wxCommandEvent&)
unsigned long added_count = 0;
// append the codes to the code list
std::vector<GeckoCode>::const_iterator
gcodes_iter = gcodes.begin(),
gcodes_end = gcodes.end();
for (; gcodes_iter!= gcodes_end; ++gcodes_iter)
for (const GeckoCode& code : gcodes)
{
// only add codes which do not already exist
std::vector<GeckoCode>::const_iterator
@ -294,13 +288,13 @@ void CodeConfigPanel::DownloadCodes(wxCommandEvent&)
{
if (existing_gcodes_end == existing_gcodes_iter)
{
m_gcodes.push_back(*gcodes_iter);
m_gcodes.push_back(code);
++added_count;
break;
}
// code exists
if (existing_gcodes_iter->Compare(*gcodes_iter))
if (existing_gcodes_iter->Compare(code))
break;
}
}

View File

@ -235,11 +235,10 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
choice_backend = new wxChoice(page_general, wxID_ANY);
RegisterControl(choice_backend, wxGetTranslation(backend_desc));
std::vector<VideoBackend*>::const_iterator
it = g_available_video_backends.begin(),
itend = g_available_video_backends.end();
for (; it != itend; ++it)
choice_backend->AppendString(wxGetTranslation(StrToWxStr((*it)->GetDisplayName())));
for (const VideoBackend* backend : g_available_video_backends)
{
choice_backend->AppendString(wxGetTranslation(StrToWxStr(backend->GetDisplayName())));
}
choice_backend->SetStringSelection(wxGetTranslation(StrToWxStr(g_video_backend->GetDisplayName())));
choice_backend->Bind(wxEVT_COMMAND_CHOICE_SELECTED, &VideoConfigDiag::Event_Backend, this);
@ -259,11 +258,10 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
{
wxChoice* const choice_adapter = CreateChoice(page_general, vconfig.iAdapter, wxGetTranslation(adapter_desc));
std::vector<std::string>::const_iterator
it = vconfig.backend_info.Adapters.begin(),
itend = vconfig.backend_info.Adapters.end();
for (; it != itend; ++it)
choice_adapter->AppendString(StrToWxStr(*it));
for (const std::string& adapter : vconfig.backend_info.Adapters)
{
choice_adapter->AppendString(StrToWxStr(adapter));
}
choice_adapter->Select(vconfig.iAdapter);
@ -381,11 +379,10 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
text_aamode = new wxStaticText(page_enh, -1, _("Anti-Aliasing:"));
choice_aamode = CreateChoice(page_enh, vconfig.iMultisampleMode, wxGetTranslation(aa_desc));
std::vector<std::string>::const_iterator
it = vconfig.backend_info.AAModes.begin(),
itend = vconfig.backend_info.AAModes.end();
for (; it != itend; ++it)
choice_aamode->AppendString(wxGetTranslation(StrToWxStr(*it)));
for (const std::string& mode : vconfig.backend_info.AAModes)
{
choice_aamode->AppendString(wxGetTranslation(StrToWxStr(mode)));
}
choice_aamode->Select(vconfig.iMultisampleMode);
szr_enh->Add(text_aamode, 1, wxALIGN_CENTER_VERTICAL, 0);
@ -406,11 +403,10 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
RegisterControl(choice_ppshader, wxGetTranslation(ppshader_desc));
choice_ppshader->AppendString(_("(off)"));
std::vector<std::string>::const_iterator
it = vconfig.backend_info.PPShaders.begin(),
itend = vconfig.backend_info.PPShaders.end();
for (; it != itend; ++it)
choice_ppshader->AppendString(StrToWxStr(*it));
for (const std::string& shader : vconfig.backend_info.PPShaders)
{
choice_ppshader->AppendString(StrToWxStr(shader));
}
if (vconfig.sPostProcessingShader.empty())
choice_ppshader->Select(0);

View File

@ -49,9 +49,9 @@ struct XFBSource : public XFBSourceBase
~XFBSource() { tex->Release(); }
void Draw(const MathUtil::Rectangle<int> &sourcerc,
const MathUtil::Rectangle<float> &drawrc) const;
void DecodeToTexture(u32 xfbAddr, u32 fbWidth, u32 fbHeight);
void CopyEFB(float Gamma);
const MathUtil::Rectangle<float> &drawrc) const override;
void DecodeToTexture(u32 xfbAddr, u32 fbWidth, u32 fbHeight) override;
void CopyEFB(float Gamma) override;
D3DTexture2D* const tex;
};
@ -81,10 +81,10 @@ public:
}
private:
XFBSourceBase* CreateXFBSource(unsigned int target_width, unsigned int target_height);
void GetTargetSize(unsigned int *width, unsigned int *height, const EFBRectangle& sourceRc);
XFBSourceBase* CreateXFBSource(unsigned int target_width, unsigned int target_height) override;
void GetTargetSize(unsigned int *width, unsigned int *height, const EFBRectangle& sourceRc) override;
void CopyToRealXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc,float Gamma);
void CopyToRealXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc,float Gamma) override;
static struct Efb
{

View File

@ -12,12 +12,12 @@ public:
PerfQuery();
~PerfQuery();
void EnableQuery(PerfQueryGroup type);
void DisableQuery(PerfQueryGroup type);
void ResetQuery();
u32 GetQueryResult(PerfQueryType type);
void FlushResults();
bool IsFlushed() const;
void EnableQuery(PerfQueryGroup type) override;
void DisableQuery(PerfQueryGroup type) override;
void ResetQuery() override;
u32 GetQueryResult(PerfQueryType type) override;
void FlushResults() override;
bool IsFlushed() const override;
private:
struct ActiveQuery

View File

@ -12,41 +12,41 @@ public:
Renderer();
~Renderer();
void SetColorMask();
void SetBlendMode(bool forceUpdate);
void SetScissorRect(const EFBRectangle& rc);
void SetGenerationMode();
void SetDepthMode();
void SetLogicOpMode();
void SetDitherMode();
void SetLineWidth();
void SetSamplerState(int stage,int texindex);
void SetInterlacingMode();
void SetViewport();
void SetColorMask() override;
void SetBlendMode(bool forceUpdate) override;
void SetScissorRect(const EFBRectangle& rc) override;
void SetGenerationMode() override;
void SetDepthMode() override;
void SetLogicOpMode() override;
void SetDitherMode() override;
void SetLineWidth() override;
void SetSamplerState(int stage,int texindex) override;
void SetInterlacingMode() override;
void SetViewport() override;
// TODO: Fix confusing names (see ResetAPIState and RestoreAPIState)
void ApplyState(bool bUseDstAlpha);
void RestoreState();
void ApplyState(bool bUseDstAlpha) override;
void RestoreState() override;
void ApplyCullDisable();
void RestoreCull();
void RenderText(const std::string& text, int left, int top, u32 color);
void RenderText(const std::string& text, int left, int top, u32 color) override;
u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data);
u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) override;
void ResetAPIState();
void RestoreAPIState();
void ResetAPIState() override;
void RestoreAPIState() override;
TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc);
TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) override;
void SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& rc,float Gamma);
void SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& rc,float Gamma) override;
void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z);
void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z) override;
void ReinterpretPixelData(unsigned int convtype);
void ReinterpretPixelData(unsigned int convtype) override;
bool SaveScreenshot(const std::string &filename, const TargetRectangle &rc);
bool SaveScreenshot(const std::string &filename, const TargetRectangle &rc) override;
static bool CheckForResize();
};

View File

@ -27,21 +27,21 @@ private:
~TCacheEntry();
void Load(unsigned int width, unsigned int height,
unsigned int expanded_width, unsigned int levels);
unsigned int expanded_width, unsigned int levels) override;
void FromRenderTarget(u32 dstAddr, unsigned int dstFormat,
unsigned int srcFormat, const EFBRectangle& srcRect,
bool isIntensity, bool scaleByHalf, unsigned int cbufid,
const float *colmat);
const float *colmat) override;
void Bind(unsigned int stage);
bool Save(const std::string& filename, unsigned int level);
void Bind(unsigned int stage) override;
bool Save(const std::string& filename, unsigned int level) override;
};
TCacheEntryBase* CreateTexture(unsigned int width, unsigned int height,
unsigned int expanded_width, unsigned int tex_levels, PC_TexFormat pcfmt);
unsigned int expanded_width, unsigned int tex_levels, PC_TexFormat pcfmt) override;
TCacheEntryBase* CreateRenderTargetTexture(unsigned int scaled_tex_w, unsigned int scaled_tex_h);
TCacheEntryBase* CreateRenderTargetTexture(unsigned int scaled_tex_w, unsigned int scaled_tex_h) override;
u64 EncodeToRamFromTexture(u32 address, void* source_texture, u32 SourceW, u32 SourceH, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle& source) {return 0;};
};

View File

@ -17,12 +17,12 @@ public:
VertexManager();
~VertexManager();
NativeVertexFormat* CreateNativeVertexFormat();
void CreateDeviceObjects();
void DestroyDeviceObjects();
NativeVertexFormat* CreateNativeVertexFormat() override;
void CreateDeviceObjects() override;
void DestroyDeviceObjects() override;
protected:
virtual void ResetBuffer(u32 stride);
virtual void ResetBuffer(u32 stride) override;
u16* GetIndexBuffer() { return &LocalIBuffer[0]; }
private:
@ -30,7 +30,7 @@ private:
void PrepareDrawBuffers();
void Draw(u32 stride);
// temp
void vFlush(bool useDstAlpha);
void vFlush(bool useDstAlpha) override;
u32 m_vertex_buffer_cursor;
u32 m_vertex_draw_offset;

View File

@ -8,19 +8,19 @@ namespace DX11
class VideoBackend : public VideoBackendHardware
{
bool Initialize(void *&);
void Shutdown();
bool Initialize(void *&) override;
void Shutdown() override;
std::string GetName();
std::string GetDisplayName();
std::string GetName() const override;
std::string GetDisplayName() const override;
void Video_Prepare();
void Video_Cleanup();
void Video_Prepare() override;
void Video_Cleanup() override;
void ShowConfig(void* parent);
void ShowConfig(void* parent) override;
void UpdateFPSDisplay(const std::string&);
unsigned int PeekMessages();
void UpdateFPSDisplay(const std::string&) override;
unsigned int PeekMessages() override;
};
}

View File

@ -11,8 +11,8 @@ class VideoBackend : public VideoBackendHardware
bool Initialize(void *&) override;
void Shutdown() override;
std::string GetName() override;
std::string GetDisplayName() override;
std::string GetName() const override;
std::string GetDisplayName() const override;
void Video_Prepare() override;
void Video_Cleanup() override;

View File

@ -92,12 +92,12 @@ Make AA apply instantly during gameplay if possible
namespace OGL
{
std::string VideoBackend::GetName()
std::string VideoBackend::GetName() const
{
return "OGL";
}
std::string VideoBackend::GetDisplayName()
std::string VideoBackend::GetDisplayName() const
{
if (GLInterface != nullptr && GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3)
return "OpenGLES";

View File

@ -56,7 +56,7 @@ static volatile bool fifoStateRun = false;
static volatile bool emuRunningState = false;
static std::mutex m_csSWVidOccupied;
std::string VideoSoftware::GetName()
std::string VideoSoftware::GetName() const
{
return _trans("Software Renderer");
}

View File

@ -13,7 +13,7 @@ class VideoSoftware : public VideoBackend
bool Initialize(void *&) override;
void Shutdown() override;
std::string GetName() override;
std::string GetName() const override;
void EmuStateChange(EMUSTATE_CHANGE newState) override;

View File

@ -47,11 +47,10 @@ VideoConfigDialog::VideoConfigDialog(wxWindow* parent, const std::string& title,
wxStaticText* const label_backend = new wxStaticText(page_general, wxID_ANY, _("Backend:"));
wxChoice* const choice_backend = new wxChoice(page_general, wxID_ANY, wxDefaultPosition);
std::vector<VideoBackend*>::const_iterator
it = g_available_video_backends.begin(),
itend = g_available_video_backends.end();
for (; it != itend; ++it)
choice_backend->AppendString(StrToWxStr((*it)->GetDisplayName()));
for (const VideoBackend* backend : g_available_video_backends)
{
choice_backend->AppendString(StrToWxStr(backend->GetDisplayName()));
}
// TODO: How to get the translated plugin name?
choice_backend->SetStringSelection(StrToWxStr(g_video_backend->GetName()));

View File

@ -80,8 +80,8 @@ public:
virtual void Shutdown() = 0;
virtual void RunLoop(bool enable) = 0;
virtual std::string GetName() = 0;
virtual std::string GetDisplayName() { return GetName(); }
virtual std::string GetName() const = 0;
virtual std::string GetDisplayName() const { return GetName(); }
virtual void ShowConfig(void*) {}