mirror of https://github.com/PCSX2/pcsx2.git
pcsx2: Convert ScopedPtr to unique_ptr
This commit is contained in:
parent
8889f4fdcc
commit
499fed40f2
|
@ -16,6 +16,7 @@
|
||||||
#include "PrecompiledHeader.h"
|
#include "PrecompiledHeader.h"
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "GS.h"
|
#include "GS.h"
|
||||||
|
|
||||||
|
@ -24,7 +25,7 @@
|
||||||
// GS Playback
|
// GS Playback
|
||||||
int g_SaveGSStream = 0; // save GS stream; 1 - prepare, 2 - save
|
int g_SaveGSStream = 0; // save GS stream; 1 - prepare, 2 - save
|
||||||
int g_nLeftGSFrames = 0; // when saving, number of frames left
|
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.
|
// fixme - need to take this concept and make it MTGS friendly.
|
||||||
#ifdef _STGS_GSSTATE_CODE
|
#ifdef _STGS_GSSTATE_CODE
|
||||||
|
@ -77,7 +78,7 @@ __fi void GSVSYNC(void) {
|
||||||
Console.WriteLn( L"\t%s", file.c_str() );
|
Console.WriteLn( L"\t%s", file.c_str() );
|
||||||
|
|
||||||
SafeArray<u8> buf;
|
SafeArray<u8> buf;
|
||||||
g_fGSSave = new memSavingState( buf );
|
g_fGSSave = std::unique_ptr<memSavingState>(new memSavingState( buf ));
|
||||||
|
|
||||||
g_SaveGSStream = 1;
|
g_SaveGSStream = 1;
|
||||||
g_nLeftGSFrames = 2;
|
g_nLeftGSFrames = 2;
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
#include <wx/dir.h>
|
#include <wx/dir.h>
|
||||||
#include <wx/file.h>
|
#include <wx/file.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "GS.h"
|
#include "GS.h"
|
||||||
#include "Gif.h"
|
#include "Gif.h"
|
||||||
#include "CDVD/CDVDisoReader.h"
|
#include "CDVD/CDVDisoReader.h"
|
||||||
|
|
||||||
#include "Utilities/ScopedPtr.h"
|
|
||||||
#include "Utilities/pxStreams.h"
|
#include "Utilities/pxStreams.h"
|
||||||
|
|
||||||
#include "svnrev.h"
|
#include "svnrev.h"
|
||||||
|
@ -991,7 +991,7 @@ void SysCorePlugins::Load( PluginsEnum_t pid, const wxString& srcfile )
|
||||||
ScopedLock lock( m_mtx_PluginStatus );
|
ScopedLock lock( m_mtx_PluginStatus );
|
||||||
pxAssert( (uint)pid < PluginId_Count );
|
pxAssert( (uint)pid < PluginId_Count );
|
||||||
Console.Indent().WriteLn( L"Binding %4s: %s ", WX_STR(tbl_PluginInfo[pid].GetShortname()), WX_STR(srcfile) );
|
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] )
|
void SysCorePlugins::Load( const wxString (&folders)[PluginId_Count] )
|
||||||
|
@ -1056,7 +1056,7 @@ void SysCorePlugins::Unload(PluginsEnum_t pid)
|
||||||
{
|
{
|
||||||
ScopedLock lock( m_mtx_PluginStatus );
|
ScopedLock lock( m_mtx_PluginStatus );
|
||||||
pxAssert( (uint)pid < PluginId_Count );
|
pxAssert( (uint)pid < PluginId_Count );
|
||||||
m_info[pid].Delete();
|
m_info[pid] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SysCorePlugins::Unload()
|
void SysCorePlugins::Unload()
|
||||||
|
|
|
@ -298,7 +298,7 @@ protected:
|
||||||
volatile u32 m_mcdOpen;
|
volatile u32 m_mcdOpen;
|
||||||
|
|
||||||
public: // hack until we unsuck plugins...
|
public: // hack until we unsuck plugins...
|
||||||
ScopedPtr<PluginStatus_t> m_info[PluginId_AllocCount];
|
std::unique_ptr<PluginStatus_t> m_info[PluginId_AllocCount];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SysCorePlugins();
|
SysCorePlugins();
|
||||||
|
|
|
@ -74,7 +74,6 @@ typedef int BOOL;
|
||||||
|
|
||||||
#include "Utilities/FixedPointTypes.h"
|
#include "Utilities/FixedPointTypes.h"
|
||||||
#include "Utilities/wxBaseTools.h"
|
#include "Utilities/wxBaseTools.h"
|
||||||
#include "Utilities/ScopedPtr.h"
|
|
||||||
#include "Utilities/Path.h"
|
#include "Utilities/Path.h"
|
||||||
#include "Utilities/Console.h"
|
#include "Utilities/Console.h"
|
||||||
#include "Utilities/MemcpyFast.h"
|
#include "Utilities/MemcpyFast.h"
|
||||||
|
|
|
@ -291,8 +291,8 @@ template< typename CpuType >
|
||||||
class CpuInitializer
|
class CpuInitializer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScopedPtr<CpuType> MyCpu;
|
std::unique_ptr<CpuType> MyCpu;
|
||||||
ScopedExcept ExThrown;
|
ScopedExcept ExThrown;
|
||||||
|
|
||||||
CpuInitializer();
|
CpuInitializer();
|
||||||
virtual ~CpuInitializer() throw();
|
virtual ~CpuInitializer() throw();
|
||||||
|
@ -302,8 +302,8 @@ public:
|
||||||
return !!MyCpu;
|
return !!MyCpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
CpuType* GetPtr() { return MyCpu.GetPtr(); }
|
CpuType* GetPtr() { return MyCpu.get(); }
|
||||||
const CpuType* GetPtr() const { return MyCpu.GetPtr(); }
|
const CpuType* GetPtr() const { return MyCpu.get(); }
|
||||||
|
|
||||||
operator CpuType*() { return GetPtr(); }
|
operator CpuType*() { return GetPtr(); }
|
||||||
operator const CpuType*() const { return GetPtr(); }
|
operator const CpuType*() const { return GetPtr(); }
|
||||||
|
@ -318,19 +318,19 @@ template< typename CpuType >
|
||||||
CpuInitializer< CpuType >::CpuInitializer()
|
CpuInitializer< CpuType >::CpuInitializer()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
MyCpu = new CpuType();
|
MyCpu = std::unique_ptr<CpuType>(new CpuType());
|
||||||
MyCpu->Reserve();
|
MyCpu->Reserve();
|
||||||
}
|
}
|
||||||
catch( Exception::RuntimeError& ex )
|
catch( Exception::RuntimeError& ex )
|
||||||
{
|
{
|
||||||
Console.Error( L"CPU provider error:\n\t" + ex.FormatDiagnosticMessage() );
|
Console.Error( L"CPU provider error:\n\t" + ex.FormatDiagnosticMessage() );
|
||||||
MyCpu = NULL;
|
MyCpu = nullptr;
|
||||||
ExThrown = ScopedExcept(ex.Clone());
|
ExThrown = ScopedExcept(ex.Clone());
|
||||||
}
|
}
|
||||||
catch( std::runtime_error& ex )
|
catch( std::runtime_error& ex )
|
||||||
{
|
{
|
||||||
Console.Error( L"CPU provider error (STL Exception)\n\tDetails:" + fromUTF8( ex.what() ) );
|
Console.Error( L"CPU provider error (STL Exception)\n\tDetails:" + fromUTF8( ex.what() ) );
|
||||||
MyCpu = NULL;
|
MyCpu = nullptr;
|
||||||
ExThrown = ScopedExcept(new Exception::RuntimeError(ex));
|
ExThrown = ScopedExcept(new Exception::RuntimeError(ex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -485,7 +485,7 @@ SysCpuProviderPack::SysCpuProviderPack()
|
||||||
Console.WriteLn( Color_StrongBlue, "Reserving memory for recompilers..." );
|
Console.WriteLn( Color_StrongBlue, "Reserving memory for recompilers..." );
|
||||||
ConsoleIndentScope indent(1);
|
ConsoleIndentScope indent(1);
|
||||||
|
|
||||||
CpuProviders = new CpuInitializerSet();
|
CpuProviders = std::unique_ptr<CpuInitializerSet>(new CpuInitializerSet());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
recCpu.Reserve();
|
recCpu.Reserve();
|
||||||
|
|
|
@ -135,7 +135,7 @@ protected:
|
||||||
ScopedExcept m_RecExceptionIOP;
|
ScopedExcept m_RecExceptionIOP;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScopedPtr<CpuInitializerSet> CpuProviders;
|
std::unique_ptr<CpuInitializerSet> CpuProviders;
|
||||||
|
|
||||||
SysCpuProviderPack();
|
SysCpuProviderPack();
|
||||||
virtual ~SysCpuProviderPack() throw();
|
virtual ~SysCpuProviderPack() throw();
|
||||||
|
|
|
@ -79,8 +79,8 @@ class ArchiveEntryList
|
||||||
DeclareNoncopyableObject( ArchiveEntryList );
|
DeclareNoncopyableObject( ArchiveEntryList );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<ArchiveEntry> m_list;
|
std::vector<ArchiveEntry> m_list;
|
||||||
ScopedPtr<ArchiveDataBuffer> m_data;
|
std::unique_ptr<ArchiveDataBuffer> m_data;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~ArchiveEntryList() throw() {}
|
virtual ~ArchiveEntryList() throw() {}
|
||||||
|
@ -89,22 +89,21 @@ public:
|
||||||
|
|
||||||
ArchiveEntryList( ArchiveDataBuffer* data )
|
ArchiveEntryList( ArchiveDataBuffer* data )
|
||||||
{
|
{
|
||||||
m_data = data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchiveEntryList( ArchiveDataBuffer& data )
|
ArchiveEntryList( ArchiveDataBuffer& data )
|
||||||
|
: m_data(&data)
|
||||||
{
|
{
|
||||||
m_data = &data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const VmStateBuffer* GetBuffer() const
|
const VmStateBuffer* GetBuffer() const
|
||||||
{
|
{
|
||||||
return m_data;
|
return m_data.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
VmStateBuffer* GetBuffer()
|
VmStateBuffer* GetBuffer()
|
||||||
{
|
{
|
||||||
return m_data;
|
return m_data.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
u8* GetPtr( uint idx )
|
u8* GetPtr( uint idx )
|
||||||
|
|
|
@ -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");
|
if (!mVU.dispCache) throw Exception::OutOfMemory (mVU.index ? L"Micro VU1 Dispatcher" : L"Micro VU0 Dispatcher");
|
||||||
memset(mVU.dispCache, 0xcc, mVUdispCacheSize);
|
memset(mVU.dispCache, 0xcc, mVUdispCacheSize);
|
||||||
|
|
||||||
mVU.regAlloc = new microRegAlloc(mVU.index);
|
mVU.regAlloc.reset(new microRegAlloc(mVU.index));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resets Rec Data
|
// Resets Rec Data
|
||||||
|
|
|
@ -22,6 +22,7 @@ using namespace x86Emitter;
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <memory>
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "VU.h"
|
#include "VU.h"
|
||||||
#include "MTVU.h"
|
#include "MTVU.h"
|
||||||
|
@ -192,10 +193,10 @@ struct microVU {
|
||||||
u32 progMemMask; // VU Micro Memory Size (in u32's)
|
u32 progMemMask; // VU Micro Memory Size (in u32's)
|
||||||
u32 cacheSize; // VU Cache Size
|
u32 cacheSize; // VU Cache Size
|
||||||
|
|
||||||
microProgManager prog; // Micro Program Data
|
microProgManager prog; // Micro Program Data
|
||||||
microProfiler profiler; // Opcode Profiler
|
microProfiler profiler; // Opcode Profiler
|
||||||
ScopedPtr<microRegAlloc> regAlloc; // Reg Alloc Class
|
std::unique_ptr<microRegAlloc> regAlloc; // Reg Alloc Class
|
||||||
ScopedPtr<AsciiFile> logFile; // Log File Pointer
|
std::unique_ptr<AsciiFile> logFile; // Log File Pointer
|
||||||
|
|
||||||
RecompiledCodeReserve* cache_reserve;
|
RecompiledCodeReserve* cache_reserve;
|
||||||
u8* cache; // Dynarec Cache Start (where we will start writing the recompiled code to)
|
u8* cache; // Dynarec Cache Start (where we will start writing the recompiled code to)
|
||||||
|
|
|
@ -48,7 +48,7 @@ void __mVUdumpProgram(microVU& mVU, microProgram& prog) {
|
||||||
mVUbranch = 0;
|
mVUbranch = 0;
|
||||||
|
|
||||||
const wxString logname(wxsFormat(L"microVU%d prog - %02d.html", mVU.index, prog.idx));
|
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("<html>\n");
|
||||||
mVUlog("<title>microVU%d MicroProgram Log</title>\n", mVU.index);
|
mVUlog("<title>microVU%d MicroProgram Log</title>\n", mVU.index);
|
||||||
|
@ -126,6 +126,6 @@ void __mVUdumpProgram(microVU& mVU, microProgram& prog) {
|
||||||
iPC = bPC;
|
iPC = bPC;
|
||||||
setCode();
|
setCode();
|
||||||
|
|
||||||
mVU.logFile.Delete();
|
mVU.logFile.reset(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue