pcsx2: Convert ScopedPtr to unique_ptr

This commit is contained in:
Jonathan Li 2016-01-27 17:49:03 +00:00
parent 8889f4fdcc
commit 499fed40f2
10 changed files with 29 additions and 29 deletions

View File

@ -16,6 +16,7 @@
#include "PrecompiledHeader.h"
#include <list>
#include <memory>
#include "GS.h"
@ -24,7 +25,7 @@
// GS Playback
int g_SaveGSStream = 0; // save GS stream; 1 - prepare, 2 - save
int g_nLeftGSFrames = 0; // when saving, number of frames left
static ScopedPtr<memSavingState> g_fGSSave;
static std::unique_ptr<memSavingState> g_fGSSave;
// fixme - need to take this concept and make it MTGS friendly.
#ifdef _STGS_GSSTATE_CODE
@ -77,7 +78,7 @@ __fi void GSVSYNC(void) {
Console.WriteLn( L"\t%s", file.c_str() );
SafeArray<u8> buf;
g_fGSSave = new memSavingState( buf );
g_fGSSave = std::unique_ptr<memSavingState>(new memSavingState( buf ));
g_SaveGSStream = 1;
g_nLeftGSFrames = 2;

View File

@ -18,12 +18,12 @@
#include <wx/dir.h>
#include <wx/file.h>
#include <memory>
#include "GS.h"
#include "Gif.h"
#include "CDVD/CDVDisoReader.h"
#include "Utilities/ScopedPtr.h"
#include "Utilities/pxStreams.h"
#include "svnrev.h"
@ -991,7 +991,7 @@ void SysCorePlugins::Load( PluginsEnum_t pid, const wxString& srcfile )
ScopedLock lock( m_mtx_PluginStatus );
pxAssert( (uint)pid < PluginId_Count );
Console.Indent().WriteLn( L"Binding %4s: %s ", WX_STR(tbl_PluginInfo[pid].GetShortname()), WX_STR(srcfile) );
m_info[pid] = new PluginStatus_t( pid, srcfile );
m_info[pid] = std::unique_ptr<PluginStatus_t>(new PluginStatus_t(pid, srcfile));
}
void SysCorePlugins::Load( const wxString (&folders)[PluginId_Count] )
@ -1056,7 +1056,7 @@ void SysCorePlugins::Unload(PluginsEnum_t pid)
{
ScopedLock lock( m_mtx_PluginStatus );
pxAssert( (uint)pid < PluginId_Count );
m_info[pid].Delete();
m_info[pid] = nullptr;
}
void SysCorePlugins::Unload()

View File

@ -298,7 +298,7 @@ protected:
volatile u32 m_mcdOpen;
public: // hack until we unsuck plugins...
ScopedPtr<PluginStatus_t> m_info[PluginId_AllocCount];
std::unique_ptr<PluginStatus_t> m_info[PluginId_AllocCount];
public:
SysCorePlugins();

View File

@ -74,7 +74,6 @@ typedef int BOOL;
#include "Utilities/FixedPointTypes.h"
#include "Utilities/wxBaseTools.h"
#include "Utilities/ScopedPtr.h"
#include "Utilities/Path.h"
#include "Utilities/Console.h"
#include "Utilities/MemcpyFast.h"

View File

@ -291,8 +291,8 @@ template< typename CpuType >
class CpuInitializer
{
public:
ScopedPtr<CpuType> MyCpu;
ScopedExcept ExThrown;
std::unique_ptr<CpuType> MyCpu;
ScopedExcept ExThrown;
CpuInitializer();
virtual ~CpuInitializer() throw();
@ -302,8 +302,8 @@ public:
return !!MyCpu;
}
CpuType* GetPtr() { return MyCpu.GetPtr(); }
const CpuType* GetPtr() const { return MyCpu.GetPtr(); }
CpuType* GetPtr() { return MyCpu.get(); }
const CpuType* GetPtr() const { return MyCpu.get(); }
operator CpuType*() { return GetPtr(); }
operator const CpuType*() const { return GetPtr(); }
@ -318,19 +318,19 @@ template< typename CpuType >
CpuInitializer< CpuType >::CpuInitializer()
{
try {
MyCpu = new CpuType();
MyCpu = std::unique_ptr<CpuType>(new CpuType());
MyCpu->Reserve();
}
catch( Exception::RuntimeError& ex )
{
Console.Error( L"CPU provider error:\n\t" + ex.FormatDiagnosticMessage() );
MyCpu = NULL;
MyCpu = nullptr;
ExThrown = ScopedExcept(ex.Clone());
}
catch( std::runtime_error& ex )
{
Console.Error( L"CPU provider error (STL Exception)\n\tDetails:" + fromUTF8( ex.what() ) );
MyCpu = NULL;
MyCpu = nullptr;
ExThrown = ScopedExcept(new Exception::RuntimeError(ex));
}
}
@ -485,7 +485,7 @@ SysCpuProviderPack::SysCpuProviderPack()
Console.WriteLn( Color_StrongBlue, "Reserving memory for recompilers..." );
ConsoleIndentScope indent(1);
CpuProviders = new CpuInitializerSet();
CpuProviders = std::unique_ptr<CpuInitializerSet>(new CpuInitializerSet());
try {
recCpu.Reserve();

View File

@ -135,7 +135,7 @@ protected:
ScopedExcept m_RecExceptionIOP;
public:
ScopedPtr<CpuInitializerSet> CpuProviders;
std::unique_ptr<CpuInitializerSet> CpuProviders;
SysCpuProviderPack();
virtual ~SysCpuProviderPack() throw();

View File

@ -79,8 +79,8 @@ class ArchiveEntryList
DeclareNoncopyableObject( ArchiveEntryList );
protected:
std::vector<ArchiveEntry> m_list;
ScopedPtr<ArchiveDataBuffer> m_data;
std::vector<ArchiveEntry> m_list;
std::unique_ptr<ArchiveDataBuffer> m_data;
public:
virtual ~ArchiveEntryList() throw() {}
@ -89,22 +89,21 @@ public:
ArchiveEntryList( ArchiveDataBuffer* data )
{
m_data = data;
}
ArchiveEntryList( ArchiveDataBuffer& data )
: m_data(&data)
{
m_data = &data;
}
const VmStateBuffer* GetBuffer() const
{
return m_data;
return m_data.get();
}
VmStateBuffer* GetBuffer()
{
return m_data;
return m_data.get();
}
u8* GetPtr( uint idx )

View File

@ -67,7 +67,7 @@ void mVUinit(microVU& mVU, uint vuIndex) {
if (!mVU.dispCache) throw Exception::OutOfMemory (mVU.index ? L"Micro VU1 Dispatcher" : L"Micro VU0 Dispatcher");
memset(mVU.dispCache, 0xcc, mVUdispCacheSize);
mVU.regAlloc = new microRegAlloc(mVU.index);
mVU.regAlloc.reset(new microRegAlloc(mVU.index));
}
// Resets Rec Data

View File

@ -22,6 +22,7 @@ using namespace x86Emitter;
#include <deque>
#include <algorithm>
#include <memory>
#include "Common.h"
#include "VU.h"
#include "MTVU.h"
@ -192,10 +193,10 @@ struct microVU {
u32 progMemMask; // VU Micro Memory Size (in u32's)
u32 cacheSize; // VU Cache Size
microProgManager prog; // Micro Program Data
microProfiler profiler; // Opcode Profiler
ScopedPtr<microRegAlloc> regAlloc; // Reg Alloc Class
ScopedPtr<AsciiFile> logFile; // Log File Pointer
microProgManager prog; // Micro Program Data
microProfiler profiler; // Opcode Profiler
std::unique_ptr<microRegAlloc> regAlloc; // Reg Alloc Class
std::unique_ptr<AsciiFile> logFile; // Log File Pointer
RecompiledCodeReserve* cache_reserve;
u8* cache; // Dynarec Cache Start (where we will start writing the recompiled code to)

View File

@ -48,7 +48,7 @@ void __mVUdumpProgram(microVU& mVU, microProgram& prog) {
mVUbranch = 0;
const wxString logname(wxsFormat(L"microVU%d prog - %02d.html", mVU.index, prog.idx));
mVU.logFile = new AsciiFile(Path::Combine(g_Conf->Folders.Logs, logname), L"w");
mVU.logFile = std::unique_ptr<AsciiFile>(new AsciiFile(Path::Combine(g_Conf->Folders.Logs, logname), L"w"));
mVUlog("<html>\n");
mVUlog("<title>microVU%d MicroProgram Log</title>\n", mVU.index);
@ -126,6 +126,6 @@ void __mVUdumpProgram(microVU& mVU, microProgram& prog) {
iPC = bPC;
setCode();
mVU.logFile.Delete();
mVU.logFile.reset(nullptr);
}