try to reign in the vector<ptr> madness

This commit is contained in:
Peter Tissen 2014-04-14 10:55:43 +02:00
parent 552b71a378
commit 8ef9414406
10 changed files with 57 additions and 50 deletions

View file

@ -46,6 +46,7 @@ CPUThread& CPUThreadManager::AddThread(CPUThreadType type)
return *new_thread; return *new_thread;
} }
//TODO: find out where the thread is actually deleted because it's sure as shit not here
void CPUThreadManager::RemoveThread(const u32 id) void CPUThreadManager::RemoveThread(const u32 id)
{ {
std::lock_guard<std::mutex> lock(m_mtx_thread); std::lock_guard<std::mutex> lock(m_mtx_thread);

View file

@ -41,6 +41,8 @@ struct VFSManagerEntry
struct VFS struct VFS
{ {
//TODO: find out where these are supposed to be deleted or just make it shared_ptr
//and also make GetDevice and GetDeviceLocal return shared_ptr then.
std::vector<vfsDevice *> m_devices; std::vector<vfsDevice *> m_devices;
void Mount(const std::string& ps3_path, const std::string& local_path, vfsDevice* device); void Mount(const std::string& ps3_path, const std::string& local_path, vfsDevice* device);
void UnMount(const std::string& ps3_path); void UnMount(const std::string& ps3_path);

View file

@ -1201,7 +1201,7 @@ void GLGSRender::Flip()
for(uint i=0; i<m_post_draw_objs.size(); ++i) for(uint i=0; i<m_post_draw_objs.size(); ++i)
{ {
m_post_draw_objs[i]->Draw(); m_post_draw_objs[i].Draw();
} }
m_frame->Flip(m_context); m_frame->Flip(m_context);

View file

@ -541,7 +541,7 @@ class GLGSRender
{ {
private: private:
std::vector<u8> m_vdata; std::vector<u8> m_vdata;
std::vector<PostDrawObj *> m_post_draw_objs; std::vector<PostDrawObj> m_post_draw_objs;
GLProgram m_program; GLProgram m_program;
int m_fp_buf_num; int m_fp_buf_num;

View file

@ -250,14 +250,14 @@ std::string GLVertexDecompilerThread::GetFunc()
for(uint i=0; i<m_funcs.size(); ++i) for(uint i=0; i<m_funcs.size(); ++i)
{ {
if(m_funcs[i]->name.compare(name) == 0) if(m_funcs[i].name.compare(name) == 0)
return name + "()"; return name + "()";
} }
m_funcs.push_back(new FuncInfo()); m_funcs.emplace_back();
uint idx = m_funcs.size()-1; FuncInfo &idx = m_funcs.back();
m_funcs[idx]->offset = offset; idx.offset = offset;
m_funcs[idx]->name = name; idx.name = name;
return name + "()"; return name + "()";
} }
@ -283,7 +283,7 @@ std::string GLVertexDecompilerThread::BuildFuncBody(const FuncInfo& func)
uint call_func = -1; uint call_func = -1;
for(uint j=0; j<m_funcs.size(); ++j) for(uint j=0; j<m_funcs.size(); ++j)
{ {
if(m_funcs[j]->offset == i) if(m_funcs[j].offset == i)
{ {
call_func = j; call_func = j;
break; break;
@ -292,7 +292,7 @@ std::string GLVertexDecompilerThread::BuildFuncBody(const FuncInfo& func)
if(call_func != -1) if(call_func != -1)
{ {
result += '\t' + m_funcs[call_func]->name + "();\n"; result += '\t' + m_funcs[call_func].name + "();\n";
break; break;
} }
} }
@ -316,17 +316,17 @@ std::string GLVertexDecompilerThread::BuildCode()
for(int i=m_funcs.size() - 1; i>0; --i) for(int i=m_funcs.size() - 1; i>0; --i)
{ {
fp += fmt::Format("void %s();\n", m_funcs[i]->name.c_str()); fp += fmt::Format("void %s();\n", m_funcs[i].name.c_str());
} }
std::string f; std::string f;
f += fmt::Format("void %s()\n{\n\tgl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f);\n\t%s();\n\tgl_Position = gl_Position * scaleOffsetMat;\n}\n", f += fmt::Format("void %s()\n{\n\tgl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f);\n\t%s();\n\tgl_Position = gl_Position * scaleOffsetMat;\n}\n",
m_funcs[0]->name.c_str(), m_funcs[1]->name.c_str()); m_funcs[0].name.c_str(), m_funcs[1].name.c_str());
for(uint i=1; i<m_funcs.size(); ++i) for(uint i=1; i<m_funcs.size(); ++i)
{ {
f += fmt::Format("\nvoid %s()\n{\n%s}\n", m_funcs[i]->name.c_str(), BuildFuncBody(*m_funcs[i]).c_str()); f += fmt::Format("\nvoid %s()\n{\n%s}\n", m_funcs[i].name.c_str(), BuildFuncBody(m_funcs[i]).c_str());
} }
static const std::string& prot = static const std::string& prot =
@ -437,9 +437,9 @@ void GLVertexDecompilerThread::Task()
m_shader = BuildCode(); m_shader = BuildCode();
m_body.clear(); m_body.clear();
if (m_funcs.size() >= 3) if (m_funcs.size() > 2)
{ {
m_funcs = std::vector<FuncInfo *>(m_funcs.begin(), m_funcs.begin() + 3); m_funcs.erase(m_funcs.begin()+2, m_funcs.end());
} }
} }

View file

@ -135,7 +135,7 @@ struct GLVertexDecompilerThread : public ThreadBase
std::vector<std::string> m_body; std::vector<std::string> m_body;
std::vector<FuncInfo *> m_funcs; std::vector<FuncInfo> m_funcs;
//wxString main; //wxString main;
std::string& m_shader; std::string& m_shader;
@ -148,12 +148,12 @@ struct GLVertexDecompilerThread : public ThreadBase
, m_shader(shader) , m_shader(shader)
, m_parr(parr) , m_parr(parr)
{ {
m_funcs.push_back(new FuncInfo()); m_funcs.emplace_back();
m_funcs[0]->offset = 0; m_funcs[0].offset = 0;
m_funcs[0]->name = "main"; m_funcs[0].name = "main";
m_funcs.push_back(new FuncInfo()); m_funcs.emplace_back();
m_funcs[1]->offset = 0; m_funcs[1].offset = 0;
m_funcs[1]->name = "func0"; m_funcs[1].name = "func0";
//m_cur_func->body = "\tgl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f);\n"; //m_cur_func->body = "\tgl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f);\n";
} }

View file

@ -123,6 +123,7 @@ __forceinline void Module::AddFuncSub(const char group[8], const u64 ops[], char
{ {
if (!ops[0]) return; if (!ops[0]) return;
//TODO: track down where this is supposed to be deleted
SFunc* sf = new SFunc; SFunc* sf = new SFunc;
sf->ptr = (void *)func; sf->ptr = (void *)func;
sf->func = bind_func(func); sf->func = bind_func(func);

View file

@ -17,7 +17,7 @@ static const u16 bpdb_version = 0x1000;
ModuleInitializer::ModuleInitializer() ModuleInitializer::ModuleInitializer()
{ {
Emu.AddModuleInit(this); Emu.AddModuleInit(std::move(std::unique_ptr<ModuleInitializer>(this)));
} }
Emulator::Emulator() Emulator::Emulator()

View file

@ -76,7 +76,7 @@ class Emulator
u32 m_ppu_thr_exit; u32 m_ppu_thr_exit;
MemoryViewerPanel* m_memory_viewer; MemoryViewerPanel* m_memory_viewer;
//ArrayF<CPUThread> m_cpu_threads; //ArrayF<CPUThread> m_cpu_threads;
std::vector<ModuleInitializer *> m_modules_init; std::vector<std::unique_ptr<ModuleInitializer>> m_modules_init;
std::vector<u64> m_break_points; std::vector<u64> m_break_points;
std::vector<u64> m_marked_points; std::vector<u64> m_marked_points;
@ -123,9 +123,9 @@ public:
CPUThread& GetCallbackThread() { return *m_ppu_callback_thr; } CPUThread& GetCallbackThread() { return *m_ppu_callback_thr; }
EventManager& GetEventManager() { return *m_event_manager; } EventManager& GetEventManager() { return *m_event_manager; }
void AddModuleInit(ModuleInitializer* m) void AddModuleInit(std::unique_ptr<ModuleInitializer> m)
{ {
m_modules_init.push_back(m); m_modules_init.push_back(std::move(m));
} }
void SetTLSData(const u64 addr, const u64 filesz, const u64 memsz) void SetTLSData(const u64 addr, const u64 filesz, const u64 memsz)

View file

@ -28,31 +28,31 @@ struct Column
struct ColumnsArr struct ColumnsArr
{ {
std::vector<Column *> m_columns; std::vector<Column> m_columns;
ColumnsArr() ColumnsArr()
{ {
Init(); Init();
} }
std::vector<Column*>* GetSortedColumnsByPos() std::vector<Column*> GetSortedColumnsByPos()
{ {
static std::vector<Column*> arr; arr.clear(); std::vector<Column*> arr;
for(u32 pos=0; pos<m_columns.size(); pos++) for(u32 pos=0; pos<m_columns.size(); pos++)
{ {
for(u32 c=0; c<m_columns.size(); ++c) for(u32 c=0; c<m_columns.size(); ++c)
{ {
if(m_columns[c]->pos != pos) continue; if(m_columns[c].pos != pos) continue;
arr.push_back(m_columns[c]); arr.push_back(&m_columns[c]);
} }
} }
return &arr; return arr;
} }
Column* GetColumnByPos(u32 pos) Column* GetColumnByPos(u32 pos)
{ {
std::vector<Column *>& columns = *GetSortedColumnsByPos(); std::vector<Column *> columns = GetSortedColumnsByPos();
for(u32 c=0; c<columns.size(); ++c) for(u32 c=0; c<columns.size(); ++c)
{ {
if(!columns[c]->shown) if(!columns[c]->shown)
@ -78,15 +78,18 @@ public:
void Init() void Init()
{ {
m_columns.clear(); m_columns.clear();
m_columns.emplace_back(m_columns.size(), 160, "Name");
#define ADD_COLUMN(x, w, n) x = new Column(m_columns.size(), w, n); m_columns.push_back(x); m_columns.emplace_back(m_columns.size(), 85, "Serial");
ADD_COLUMN(m_col_name, 160, "Name"); m_columns.emplace_back(m_columns.size(), 55, "FW");
ADD_COLUMN(m_col_serial, 85, "Serial"); m_columns.emplace_back(m_columns.size(), 55, "App version");
ADD_COLUMN(m_col_fw, 55, "FW"); m_columns.emplace_back(m_columns.size(), 55, "Category");
ADD_COLUMN(m_col_app_ver, 55, "App version"); m_columns.emplace_back(m_columns.size(), 160, "Path");
ADD_COLUMN(m_col_category, 55, "Category"); m_col_name = &m_columns[0];
ADD_COLUMN(m_col_path, 160, "Path"); m_col_serial = &m_columns[1];
#undef ADD_COLUMN m_col_fw = &m_columns[2];
m_col_app_ver = &m_columns[3];
m_col_category = &m_columns[4];
m_col_path = &m_columns[5];
} }
void Update(std::vector<GameInfo>& game_data) void Update(std::vector<GameInfo>& game_data)
@ -114,7 +117,7 @@ public:
void Show(wxListView* list) void Show(wxListView* list)
{ {
list->DeleteAllColumns(); list->DeleteAllColumns();
std::vector<Column *>& c_col = *GetSortedColumnsByPos(); std::vector<Column *> c_col = GetSortedColumnsByPos();
for(u32 i=0, c=0; i<c_col.size(); ++i) for(u32 i=0, c=0; i<c_col.size(); ++i)
{ {
if(!c_col[i]->shown) continue; if(!c_col[i]->shown) continue;
@ -158,19 +161,19 @@ public:
#define ADD_COLUMN(v, dv, t, n, isshown) \ #define ADD_COLUMN(v, dv, t, n, isshown) \
{ \ { \
IniEntry<t> ini; \ IniEntry<t> ini; \
ini.Init(m_columns[i]->name + "_" + n, path); \ ini.Init(m_columns[i].name + "_" + n, path); \
if(isLoad) m_columns[i]->v = ini.LoadValue(dv); \ if(isLoad) m_columns[i].v = ini.LoadValue(dv); \
else if(isshown ? m_columns[i]->shown : 1) \ else if(isshown ? m_columns[i].shown : 1) \
{ \ { \
ini.SetValue(m_columns[i]->v); \ ini.SetValue(m_columns[i].v); \
ini.Save(); \ ini.Save(); \
} \ } \
} }
for(u32 i=0; i<m_columns.size(); ++i) for(u32 i=0; i<m_columns.size(); ++i)
{ {
ADD_COLUMN(pos, m_columns[i]->def_pos, int, "position", 1); ADD_COLUMN(pos, m_columns[i].def_pos, int, "position", 1);
ADD_COLUMN(width, m_columns[i]->def_width, int, "width", 1); ADD_COLUMN(width, m_columns[i].def_width, int, "width", 1);
ADD_COLUMN(shown, true, bool, "shown", 0); ADD_COLUMN(shown, true, bool, "shown", 0);
} }
@ -181,7 +184,7 @@ public:
{ {
for(u32 c2=c1+1; c2<m_columns.size(); ++c2) for(u32 c2=c1+1; c2<m_columns.size(); ++c2)
{ {
if(m_columns[c1]->pos == m_columns[c2]->pos) if(m_columns[c1].pos == m_columns[c2].pos)
{ {
ConLog.Error("Columns loaded with error!"); ConLog.Error("Columns loaded with error!");
Init(); Init();
@ -195,7 +198,7 @@ public:
bool ishas = false; bool ishas = false;
for(u32 c=0; c<m_columns.size(); ++c) for(u32 c=0; c<m_columns.size(); ++c)
{ {
if(m_columns[c]->pos != p) continue; if(m_columns[c].pos != p) continue;
ishas = true; ishas = true;
break; break;
} }