common: Get rid of make_unique.h

This commit is contained in:
Lioncash 2015-09-30 08:38:14 -04:00
parent ecbe6099f3
commit 1311707ed8
18 changed files with 32 additions and 57 deletions

View File

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <memory>
#include <thread> #include <thread>
#include <QDesktopWidget> #include <QDesktopWidget>
@ -28,7 +29,6 @@
#include "citra_qt/debugger/ramview.h" #include "citra_qt/debugger/ramview.h"
#include "citra_qt/debugger/registers.h" #include "citra_qt/debugger/registers.h"
#include "common/make_unique.h"
#include "common/microprofile.h" #include "common/microprofile.h"
#include "common/platform.h" #include "common/platform.h"
#include "common/scm_rev.h" #include "common/scm_rev.h"
@ -247,7 +247,7 @@ void GMainWindow::BootGame(const std::string& filename) {
} }
// Create and start the emulation thread // Create and start the emulation thread
emu_thread = Common::make_unique<EmuThread>(render_window); emu_thread = std::make_unique<EmuThread>(render_window);
emit EmulationStarting(emu_thread.get()); emit EmulationStarting(emu_thread.get());
render_window->moveContext(); render_window->moveContext();
emu_thread->start(); emu_thread->start();

View File

@ -41,7 +41,6 @@ set(HEADERS
logging/filter.h logging/filter.h
logging/log.h logging/log.h
logging/backend.h logging/backend.h
make_unique.h
math_util.h math_util.h
memory_util.h memory_util.h
microprofile.h microprofile.h

View File

@ -1,17 +0,0 @@
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <algorithm>
#include <memory>
namespace Common {
template <typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
} // namespace

View File

@ -3,8 +3,7 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <cstring> #include <cstring>
#include <memory>
#include "common/make_unique.h"
#include "core/arm/skyeye_common/armstate.h" #include "core/arm/skyeye_common/armstate.h"
#include "core/arm/skyeye_common/armsupp.h" #include "core/arm/skyeye_common/armsupp.h"
@ -18,7 +17,7 @@
#include "core/core_timing.h" #include "core/core_timing.h"
ARM_DynCom::ARM_DynCom(PrivilegeMode initial_mode) { ARM_DynCom::ARM_DynCom(PrivilegeMode initial_mode) {
state = Common::make_unique<ARMul_State>(initial_mode); state = std::make_unique<ARMul_State>(initial_mode);
} }
ARM_DynCom::~ARM_DynCom() { ARM_DynCom::~ARM_DynCom() {

View File

@ -3,12 +3,12 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <algorithm> #include <algorithm>
#include <memory>
#include <vector> #include <vector>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/file_util.h" #include "common/file_util.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/make_unique.h"
#include "common/string_util.h" #include "common/string_util.h"
#include "core/file_sys/archive_extsavedata.h" #include "core/file_sys/archive_extsavedata.h"
@ -78,7 +78,7 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_ExtSaveData::Open(cons
return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS, return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS,
ErrorSummary::InvalidState, ErrorLevel::Status); ErrorSummary::InvalidState, ErrorLevel::Status);
} }
auto archive = Common::make_unique<DiskArchive>(fullpath); auto archive = std::make_unique<DiskArchive>(fullpath);
return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive)); return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
} }

View File

@ -7,7 +7,6 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/make_unique.h"
#include "core/file_sys/archive_romfs.h" #include "core/file_sys/archive_romfs.h"
#include "core/file_sys/ivfc_archive.h" #include "core/file_sys/ivfc_archive.h"
@ -25,7 +24,7 @@ ArchiveFactory_RomFS::ArchiveFactory_RomFS(Loader::AppLoader& app_loader) {
} }
ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_RomFS::Open(const Path& path) { ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_RomFS::Open(const Path& path) {
auto archive = Common::make_unique<IVFCArchive>(romfs_file, data_offset, data_size); auto archive = std::make_unique<IVFCArchive>(romfs_file, data_offset, data_size);
return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive)); return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
} }

View File

@ -3,11 +3,11 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <algorithm> #include <algorithm>
#include <memory>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/file_util.h" #include "common/file_util.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/make_unique.h"
#include "common/string_util.h" #include "common/string_util.h"
#include "core/file_sys/archive_savedata.h" #include "core/file_sys/archive_savedata.h"
@ -47,7 +47,7 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SaveData::Open(const P
ErrorSummary::InvalidState, ErrorLevel::Status); ErrorSummary::InvalidState, ErrorLevel::Status);
} }
auto archive = Common::make_unique<DiskArchive>(std::move(concrete_mount_point)); auto archive = std::make_unique<DiskArchive>(std::move(concrete_mount_point));
return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive)); return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
} }

View File

@ -3,12 +3,12 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <algorithm> #include <algorithm>
#include <memory>
#include <vector> #include <vector>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/file_util.h" #include "common/file_util.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/make_unique.h"
#include "common/string_util.h" #include "common/string_util.h"
#include "core/file_sys/archive_savedatacheck.h" #include "core/file_sys/archive_savedatacheck.h"
@ -44,7 +44,7 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SaveDataCheck::Open(co
} }
auto size = file->GetSize(); auto size = file->GetSize();
auto archive = Common::make_unique<IVFCArchive>(file, 0, size); auto archive = std::make_unique<IVFCArchive>(file, 0, size);
return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive)); return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
} }

View File

@ -3,10 +3,10 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <algorithm> #include <algorithm>
#include <memory>
#include "common/file_util.h" #include "common/file_util.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/make_unique.h"
#include "core/file_sys/archive_sdmc.h" #include "core/file_sys/archive_sdmc.h"
#include "core/file_sys/disk_archive.h" #include "core/file_sys/disk_archive.h"
@ -36,7 +36,7 @@ bool ArchiveFactory_SDMC::Initialize() {
} }
ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SDMC::Open(const Path& path) { ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SDMC::Open(const Path& path) {
auto archive = Common::make_unique<DiskArchive>(sdmc_directory); auto archive = std::make_unique<DiskArchive>(sdmc_directory);
return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive)); return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
} }

View File

@ -3,11 +3,11 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <algorithm> #include <algorithm>
#include <memory>
#include <vector> #include <vector>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/file_util.h" #include "common/file_util.h"
#include "common/make_unique.h"
#include "common/string_util.h" #include "common/string_util.h"
#include "core/file_sys/archive_systemsavedata.h" #include "core/file_sys/archive_systemsavedata.h"
@ -59,7 +59,7 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SystemSaveData::Open(c
return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS, return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS,
ErrorSummary::InvalidState, ErrorLevel::Status); ErrorSummary::InvalidState, ErrorLevel::Status);
} }
auto archive = Common::make_unique<DiskArchive>(fullpath); auto archive = std::make_unique<DiskArchive>(fullpath);
return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive)); return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
} }

View File

@ -4,11 +4,11 @@
#include <algorithm> #include <algorithm>
#include <cstdio> #include <cstdio>
#include <memory>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/file_util.h" #include "common/file_util.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/make_unique.h"
#include "core/file_sys/disk_archive.h" #include "core/file_sys/disk_archive.h"
@ -19,7 +19,7 @@ namespace FileSys {
std::unique_ptr<FileBackend> DiskArchive::OpenFile(const Path& path, const Mode mode) const { std::unique_ptr<FileBackend> DiskArchive::OpenFile(const Path& path, const Mode mode) const {
LOG_DEBUG(Service_FS, "called path=%s mode=%01X", path.DebugStr().c_str(), mode.hex); LOG_DEBUG(Service_FS, "called path=%s mode=%01X", path.DebugStr().c_str(), mode.hex);
auto file = Common::make_unique<DiskFile>(*this, path, mode); auto file = std::make_unique<DiskFile>(*this, path, mode);
if (!file->Open()) if (!file->Open())
return nullptr; return nullptr;
return std::move(file); return std::move(file);
@ -68,7 +68,7 @@ bool DiskArchive::RenameDirectory(const Path& src_path, const Path& dest_path) c
std::unique_ptr<DirectoryBackend> DiskArchive::OpenDirectory(const Path& path) const { std::unique_ptr<DirectoryBackend> DiskArchive::OpenDirectory(const Path& path) const {
LOG_DEBUG(Service_FS, "called path=%s", path.DebugStr().c_str()); LOG_DEBUG(Service_FS, "called path=%s", path.DebugStr().c_str());
auto directory = Common::make_unique<DiskDirectory>(*this, path); auto directory = std::make_unique<DiskDirectory>(*this, path);
if (!directory->Open()) if (!directory->Open())
return nullptr; return nullptr;
return std::move(directory); return std::move(directory);
@ -101,7 +101,7 @@ bool DiskFile::Open() {
// Open the file in binary mode, to avoid problems with CR/LF on Windows systems // Open the file in binary mode, to avoid problems with CR/LF on Windows systems
mode_string += "b"; mode_string += "b";
file = Common::make_unique<FileUtil::IOFile>(path, mode_string.c_str()); file = std::make_unique<FileUtil::IOFile>(path, mode_string.c_str());
return file->IsOpen(); return file->IsOpen();
} }

View File

@ -7,7 +7,6 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/make_unique.h"
#include "core/file_sys/ivfc_archive.h" #include "core/file_sys/ivfc_archive.h"
@ -21,7 +20,7 @@ std::string IVFCArchive::GetName() const {
} }
std::unique_ptr<FileBackend> IVFCArchive::OpenFile(const Path& path, const Mode mode) const { std::unique_ptr<FileBackend> IVFCArchive::OpenFile(const Path& path, const Mode mode) const {
return Common::make_unique<IVFCFile>(romfs_file, data_offset, data_size); return std::make_unique<IVFCFile>(romfs_file, data_offset, data_size);
} }
bool IVFCArchive::DeleteFile(const Path& path) const { bool IVFCArchive::DeleteFile(const Path& path) const {
@ -56,7 +55,7 @@ bool IVFCArchive::RenameDirectory(const Path& src_path, const Path& dest_path) c
} }
std::unique_ptr<DirectoryBackend> IVFCArchive::OpenDirectory(const Path& path) const { std::unique_ptr<DirectoryBackend> IVFCArchive::OpenDirectory(const Path& path) const {
return Common::make_unique<IVFCDirectory>(); return std::make_unique<IVFCDirectory>();
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -5,7 +5,6 @@
#include "common/assert.h" #include "common/assert.h"
#include "common/common_funcs.h" #include "common/common_funcs.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/make_unique.h"
#include "core/hle/kernel/memory.h" #include "core/hle/kernel/memory.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"

View File

@ -15,7 +15,6 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "common/file_util.h" #include "common/file_util.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/make_unique.h"
#include "core/file_sys/archive_backend.h" #include "core/file_sys/archive_backend.h"
#include "core/file_sys/archive_extsavedata.h" #include "core/file_sys/archive_extsavedata.h"
@ -506,23 +505,23 @@ void ArchiveInit() {
std::string sdmc_directory = FileUtil::GetUserPath(D_SDMC_IDX); std::string sdmc_directory = FileUtil::GetUserPath(D_SDMC_IDX);
std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX); std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX);
auto sdmc_factory = Common::make_unique<FileSys::ArchiveFactory_SDMC>(sdmc_directory); auto sdmc_factory = std::make_unique<FileSys::ArchiveFactory_SDMC>(sdmc_directory);
if (sdmc_factory->Initialize()) if (sdmc_factory->Initialize())
RegisterArchiveType(std::move(sdmc_factory), ArchiveIdCode::SDMC); RegisterArchiveType(std::move(sdmc_factory), ArchiveIdCode::SDMC);
else else
LOG_ERROR(Service_FS, "Can't instantiate SDMC archive with path %s", sdmc_directory.c_str()); LOG_ERROR(Service_FS, "Can't instantiate SDMC archive with path %s", sdmc_directory.c_str());
// Create the SaveData archive // Create the SaveData archive
auto savedata_factory = Common::make_unique<FileSys::ArchiveFactory_SaveData>(sdmc_directory); auto savedata_factory = std::make_unique<FileSys::ArchiveFactory_SaveData>(sdmc_directory);
RegisterArchiveType(std::move(savedata_factory), ArchiveIdCode::SaveData); RegisterArchiveType(std::move(savedata_factory), ArchiveIdCode::SaveData);
auto extsavedata_factory = Common::make_unique<FileSys::ArchiveFactory_ExtSaveData>(sdmc_directory, false); auto extsavedata_factory = std::make_unique<FileSys::ArchiveFactory_ExtSaveData>(sdmc_directory, false);
if (extsavedata_factory->Initialize()) if (extsavedata_factory->Initialize())
RegisterArchiveType(std::move(extsavedata_factory), ArchiveIdCode::ExtSaveData); RegisterArchiveType(std::move(extsavedata_factory), ArchiveIdCode::ExtSaveData);
else else
LOG_ERROR(Service_FS, "Can't instantiate ExtSaveData archive with path %s", extsavedata_factory->GetMountPoint().c_str()); LOG_ERROR(Service_FS, "Can't instantiate ExtSaveData archive with path %s", extsavedata_factory->GetMountPoint().c_str());
auto sharedextsavedata_factory = Common::make_unique<FileSys::ArchiveFactory_ExtSaveData>(nand_directory, true); auto sharedextsavedata_factory = std::make_unique<FileSys::ArchiveFactory_ExtSaveData>(nand_directory, true);
if (sharedextsavedata_factory->Initialize()) if (sharedextsavedata_factory->Initialize())
RegisterArchiveType(std::move(sharedextsavedata_factory), ArchiveIdCode::SharedExtSaveData); RegisterArchiveType(std::move(sharedextsavedata_factory), ArchiveIdCode::SharedExtSaveData);
else else
@ -530,10 +529,10 @@ void ArchiveInit() {
sharedextsavedata_factory->GetMountPoint().c_str()); sharedextsavedata_factory->GetMountPoint().c_str());
// Create the SaveDataCheck archive, basically a small variation of the RomFS archive // Create the SaveDataCheck archive, basically a small variation of the RomFS archive
auto savedatacheck_factory = Common::make_unique<FileSys::ArchiveFactory_SaveDataCheck>(nand_directory); auto savedatacheck_factory = std::make_unique<FileSys::ArchiveFactory_SaveDataCheck>(nand_directory);
RegisterArchiveType(std::move(savedatacheck_factory), ArchiveIdCode::SaveDataCheck); RegisterArchiveType(std::move(savedatacheck_factory), ArchiveIdCode::SaveDataCheck);
auto systemsavedata_factory = Common::make_unique<FileSys::ArchiveFactory_SystemSaveData>(nand_directory); auto systemsavedata_factory = std::make_unique<FileSys::ArchiveFactory_SystemSaveData>(nand_directory);
RegisterArchiveType(std::move(systemsavedata_factory), ArchiveIdCode::SystemSaveData); RegisterArchiveType(std::move(systemsavedata_factory), ArchiveIdCode::SystemSaveData);
} }

View File

@ -6,7 +6,6 @@
#include <string> #include <string>
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/make_unique.h"
#include "common/string_util.h" #include "common/string_util.h"
#include "core/file_sys/archive_romfs.h" #include "core/file_sys/archive_romfs.h"
@ -120,7 +119,7 @@ ResultStatus LoadFile(const std::string& filename) {
AppLoader_THREEDSX app_loader(std::move(file), filename_filename, filename); AppLoader_THREEDSX app_loader(std::move(file), filename_filename, filename);
// Load application and RomFS // Load application and RomFS
if (ResultStatus::Success == app_loader.Load()) { if (ResultStatus::Success == app_loader.Load()) {
Service::FS::RegisterArchiveType(Common::make_unique<FileSys::ArchiveFactory_RomFS>(app_loader), Service::FS::ArchiveIdCode::RomFS); Service::FS::RegisterArchiveType(std::make_unique<FileSys::ArchiveFactory_RomFS>(app_loader), Service::FS::ArchiveIdCode::RomFS);
return ResultStatus::Success; return ResultStatus::Success;
} }
break; break;
@ -138,7 +137,7 @@ ResultStatus LoadFile(const std::string& filename) {
// Load application and RomFS // Load application and RomFS
if (ResultStatus::Success == app_loader.Load()) { if (ResultStatus::Success == app_loader.Load()) {
Service::FS::RegisterArchiveType(Common::make_unique<FileSys::ArchiveFactory_RomFS>(app_loader), Service::FS::ArchiveIdCode::RomFS); Service::FS::RegisterArchiveType(std::make_unique<FileSys::ArchiveFactory_RomFS>(app_loader), Service::FS::ArchiveIdCode::RomFS);
return ResultStatus::Success; return ResultStatus::Success;
} }
break; break;

View File

@ -7,7 +7,6 @@
#include <memory> #include <memory>
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/make_unique.h"
#include "common/string_util.h" #include "common/string_util.h"
#include "common/swap.h" #include "common/swap.h"

View File

@ -2,8 +2,9 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <memory>
#include "common/hash.h" #include "common/hash.h"
#include "common/make_unique.h"
#include "common/math_util.h" #include "common/math_util.h"
#include "common/microprofile.h" #include "common/microprofile.h"
#include "common/vector_math.h" #include "common/vector_math.h"
@ -29,7 +30,7 @@ void RasterizerCacheOpenGL::LoadAndBindTexture(OpenGLState &state, unsigned text
} else { } else {
MICROPROFILE_SCOPE(OpenGL_TextureUpload); MICROPROFILE_SCOPE(OpenGL_TextureUpload);
std::unique_ptr<CachedTexture> new_texture = Common::make_unique<CachedTexture>(); std::unique_ptr<CachedTexture> new_texture = std::make_unique<CachedTexture>();
new_texture->texture.Create(); new_texture->texture.Create();
state.texture_units[texture_unit].texture_2d = new_texture->texture.handle; state.texture_units[texture_unit].texture_2d = new_texture->texture.handle;

View File

@ -8,7 +8,6 @@
#include <boost/range/algorithm/fill.hpp> #include <boost/range/algorithm/fill.hpp>
#include "common/hash.h" #include "common/hash.h"
#include "common/make_unique.h"
#include "common/microprofile.h" #include "common/microprofile.h"
#include "common/profiler.h" #include "common/profiler.h"