file-sys: Default heavy-weight class destructors in the cpp file

Several classes have a lot of non-trivial members within them, or don't
but likely should have the destructor defaulted in the cpp file for
future-proofing/being more friendly to forward declarations.

Leaving the destructor unspecified allows the compiler to inline the
destruction code all over the place, which is generally undesirable from
a code bloat perspective.
This commit is contained in:
Lioncash 2018-09-19 19:19:05 -04:00
parent 0432af5ad1
commit 05ef9dfc10
25 changed files with 45 additions and 1 deletions

View file

@ -463,6 +463,8 @@ NCA::NCA(VirtualFile file_, VirtualFile bktr_base_romfs_, u64 bktr_base_ivfc_off
status = Loader::ResultStatus::Success; status = Loader::ResultStatus::Success;
} }
NCA::~NCA() = default;
Loader::ResultStatus NCA::GetStatus() const { Loader::ResultStatus NCA::GetStatus() const {
return status; return status;
} }

View file

@ -81,6 +81,8 @@ class NCA : public ReadOnlyVfsDirectory {
public: public:
explicit NCA(VirtualFile file, VirtualFile bktr_base_romfs = nullptr, explicit NCA(VirtualFile file, VirtualFile bktr_base_romfs = nullptr,
u64 bktr_base_ivfc_offset = 0); u64 bktr_base_ivfc_offset = 0);
~NCA() override;
Loader::ResultStatus GetStatus() const; Loader::ResultStatus GetStatus() const;
std::vector<std::shared_ptr<VfsFile>> GetFiles() const override; std::vector<std::shared_ptr<VfsFile>> GetFiles() const override;

View file

@ -20,6 +20,8 @@ NACP::NACP(VirtualFile file) : raw(std::make_unique<RawNACP>()) {
file->ReadObject(raw.get()); file->ReadObject(raw.get());
} }
NACP::~NACP() = default;
const LanguageEntry& NACP::GetLanguageEntry(Language language) const { const LanguageEntry& NACP::GetLanguageEntry(Language language) const {
if (language != Language::Default) { if (language != Language::Default) {
return raw->language_entries.at(static_cast<u8>(language)); return raw->language_entries.at(static_cast<u8>(language));

View file

@ -78,6 +78,8 @@ static constexpr std::array<const char*, 15> LANGUAGE_NAMES = {
class NACP { class NACP {
public: public:
explicit NACP(VirtualFile file); explicit NACP(VirtualFile file);
~NACP();
const LanguageEntry& GetLanguageEntry(Language language = Language::Default) const; const LanguageEntry& GetLanguageEntry(Language language = Language::Default) const;
std::string GetApplicationName(Language language = Language::Default) const; std::string GetApplicationName(Language language = Language::Default) const;
std::string GetDeveloperName(Language language = Language::Default) const; std::string GetDeveloperName(Language language = Language::Default) const;

View file

@ -51,6 +51,8 @@ CNMT::CNMT(CNMTHeader header, OptionalHeader opt_header, std::vector<ContentReco
: header(std::move(header)), opt_header(std::move(opt_header)), : header(std::move(header)), opt_header(std::move(opt_header)),
content_records(std::move(content_records)), meta_records(std::move(meta_records)) {} content_records(std::move(content_records)), meta_records(std::move(meta_records)) {}
CNMT::~CNMT() = default;
u64 CNMT::GetTitleID() const { u64 CNMT::GetTitleID() const {
return header.title_id; return header.title_id;
} }

View file

@ -87,6 +87,7 @@ public:
explicit CNMT(VirtualFile file); explicit CNMT(VirtualFile file);
CNMT(CNMTHeader header, OptionalHeader opt_header, std::vector<ContentRecord> content_records, CNMT(CNMTHeader header, OptionalHeader opt_header, std::vector<ContentRecord> content_records,
std::vector<MetaRecord> meta_records); std::vector<MetaRecord> meta_records);
~CNMT();
u64 GetTitleID() const; u64 GetTitleID() const;
u32 GetTitleVersion() const; u32 GetTitleVersion() const;

View file

@ -72,6 +72,8 @@ PartitionFilesystem::PartitionFilesystem(std::shared_ptr<VfsFile> file) {
status = Loader::ResultStatus::Success; status = Loader::ResultStatus::Success;
} }
PartitionFilesystem::~PartitionFilesystem() = default;
Loader::ResultStatus PartitionFilesystem::GetStatus() const { Loader::ResultStatus PartitionFilesystem::GetStatus() const {
return status; return status;
} }

View file

@ -25,6 +25,8 @@ namespace FileSys {
class PartitionFilesystem : public ReadOnlyVfsDirectory { class PartitionFilesystem : public ReadOnlyVfsDirectory {
public: public:
explicit PartitionFilesystem(std::shared_ptr<VfsFile> file); explicit PartitionFilesystem(std::shared_ptr<VfsFile> file);
~PartitionFilesystem() override;
Loader::ResultStatus GetStatus() const; Loader::ResultStatus GetStatus() const;
std::vector<std::shared_ptr<VfsFile>> GetFiles() const override; std::vector<std::shared_ptr<VfsFile>> GetFiles() const override;

View file

@ -41,6 +41,8 @@ std::string FormatPatchTypeName(PatchType type) {
PatchManager::PatchManager(u64 title_id) : title_id(title_id) {} PatchManager::PatchManager(u64 title_id) : title_id(title_id) {}
PatchManager::~PatchManager() = default;
VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const { VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const {
LOG_INFO(Loader, "Patching ExeFS for title_id={:016X}", title_id); LOG_INFO(Loader, "Patching ExeFS for title_id={:016X}", title_id);

View file

@ -34,6 +34,7 @@ std::string FormatPatchTypeName(PatchType type);
class PatchManager { class PatchManager {
public: public:
explicit PatchManager(u64 title_id); explicit PatchManager(u64 title_id);
~PatchManager();
// Currently tracked ExeFS patches: // Currently tracked ExeFS patches:
// - Game Updates // - Game Updates

View file

@ -12,6 +12,10 @@
namespace FileSys { namespace FileSys {
ProgramMetadata::ProgramMetadata() = default;
ProgramMetadata::~ProgramMetadata() = default;
Loader::ResultStatus ProgramMetadata::Load(VirtualFile file) { Loader::ResultStatus ProgramMetadata::Load(VirtualFile file) {
std::size_t total_size = static_cast<std::size_t>(file->GetSize()); std::size_t total_size = static_cast<std::size_t>(file->GetSize());
if (total_size < sizeof(Header)) if (total_size < sizeof(Header))

View file

@ -36,6 +36,9 @@ enum class ProgramFilePermission : u64 {
*/ */
class ProgramMetadata { class ProgramMetadata {
public: public:
ProgramMetadata();
~ProgramMetadata();
Loader::ResultStatus Load(VirtualFile file); Loader::ResultStatus Load(VirtualFile file);
bool Is64BitProgram() const; bool Is64BitProgram() const;

View file

@ -28,6 +28,8 @@ RomFSFactory::RomFSFactory(Loader::AppLoader& app_loader) {
ivfc_offset = app_loader.ReadRomFSIVFCOffset(); ivfc_offset = app_loader.ReadRomFSIVFCOffset();
} }
RomFSFactory::~RomFSFactory() = default;
ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess() { ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess() {
if (!updatable) if (!updatable)
return MakeResult<VirtualFile>(file); return MakeResult<VirtualFile>(file);

View file

@ -30,6 +30,7 @@ enum class StorageId : u8 {
class RomFSFactory { class RomFSFactory {
public: public:
explicit RomFSFactory(Loader::AppLoader& app_loader); explicit RomFSFactory(Loader::AppLoader& app_loader);
~RomFSFactory();
ResultVal<VirtualFile> OpenCurrentProcess(); ResultVal<VirtualFile> OpenCurrentProcess();
ResultVal<VirtualFile> Open(u64 title_id, StorageId storage, ContentRecordType type); ResultVal<VirtualFile> Open(u64 title_id, StorageId storage, ContentRecordType type);

View file

@ -20,6 +20,8 @@ std::string SaveDataDescriptor::DebugInfo() const {
SaveDataFactory::SaveDataFactory(VirtualDir save_directory) : dir(std::move(save_directory)) {} SaveDataFactory::SaveDataFactory(VirtualDir save_directory) : dir(std::move(save_directory)) {}
SaveDataFactory::~SaveDataFactory() = default;
ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space, SaveDataDescriptor meta) { ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space, SaveDataDescriptor meta) {
if (meta.type == SaveDataType::SystemSaveData || meta.type == SaveDataType::SaveData) { if (meta.type == SaveDataType::SystemSaveData || meta.type == SaveDataType::SaveData) {
if (meta.zero_1 != 0) { if (meta.zero_1 != 0) {

View file

@ -48,6 +48,7 @@ static_assert(sizeof(SaveDataDescriptor) == 0x40, "SaveDataDescriptor has incorr
class SaveDataFactory { class SaveDataFactory {
public: public:
explicit SaveDataFactory(VirtualDir dir); explicit SaveDataFactory(VirtualDir dir);
~SaveDataFactory();
ResultVal<VirtualDir> Open(SaveDataSpaceId space, SaveDataDescriptor meta); ResultVal<VirtualDir> Open(SaveDataSpaceId space, SaveDataDescriptor meta);

View file

@ -24,7 +24,7 @@ enum class ContentRecordType : u8;
class NSP : public ReadOnlyVfsDirectory { class NSP : public ReadOnlyVfsDirectory {
public: public:
explicit NSP(VirtualFile file); explicit NSP(VirtualFile file);
~NSP(); ~NSP() override;
Loader::ResultStatus GetStatus() const; Loader::ResultStatus GetStatus() const;
Loader::ResultStatus GetProgramStatus(u64 title_id) const; Loader::ResultStatus GetProgramStatus(u64 title_id) const;

View file

@ -27,6 +27,8 @@ ConcatenatedVfsFile::ConcatenatedVfsFile(std::vector<VirtualFile> files_, std::s
} }
} }
ConcatenatedVfsFile::~ConcatenatedVfsFile() = default;
std::string ConcatenatedVfsFile::GetName() const { std::string ConcatenatedVfsFile::GetName() const {
if (files.empty()) if (files.empty())
return ""; return "";

View file

@ -22,6 +22,8 @@ class ConcatenatedVfsFile : public VfsFile {
ConcatenatedVfsFile(std::vector<VirtualFile> files, std::string name); ConcatenatedVfsFile(std::vector<VirtualFile> files, std::string name);
public: public:
~ConcatenatedVfsFile() override;
std::string GetName() const override; std::string GetName() const override;
std::size_t GetSize() const override; std::size_t GetSize() const override;
bool Resize(std::size_t new_size) override; bool Resize(std::size_t new_size) override;

View file

@ -14,6 +14,8 @@ OffsetVfsFile::OffsetVfsFile(std::shared_ptr<VfsFile> file_, std::size_t size_,
: file(file_), offset(offset_), size(size_), name(std::move(name_)), : file(file_), offset(offset_), size(size_), name(std::move(name_)),
parent(parent_ == nullptr ? file->GetContainingDirectory() : std::move(parent_)) {} parent(parent_ == nullptr ? file->GetContainingDirectory() : std::move(parent_)) {}
OffsetVfsFile::~OffsetVfsFile() = default;
std::string OffsetVfsFile::GetName() const { std::string OffsetVfsFile::GetName() const {
return name.empty() ? file->GetName() : name; return name.empty() ? file->GetName() : name;
} }

View file

@ -19,6 +19,7 @@ class OffsetVfsFile : public VfsFile {
public: public:
OffsetVfsFile(std::shared_ptr<VfsFile> file, std::size_t size, std::size_t offset = 0, OffsetVfsFile(std::shared_ptr<VfsFile> file, std::size_t size, std::size_t offset = 0,
std::string new_name = "", VirtualDir new_parent = nullptr); std::string new_name = "", VirtualDir new_parent = nullptr);
~OffsetVfsFile() override;
std::string GetName() const override; std::string GetName() const override;
std::size_t GetSize() const override; std::size_t GetSize() const override;

View file

@ -13,6 +13,8 @@ VectorVfsDirectory::VectorVfsDirectory(std::vector<VirtualFile> files_,
: files(std::move(files_)), dirs(std::move(dirs_)), parent(std::move(parent_)), : files(std::move(files_)), dirs(std::move(dirs_)), parent(std::move(parent_)),
name(std::move(name_)) {} name(std::move(name_)) {}
VectorVfsDirectory::~VectorVfsDirectory() = default;
std::vector<std::shared_ptr<VfsFile>> VectorVfsDirectory::GetFiles() const { std::vector<std::shared_ptr<VfsFile>> VectorVfsDirectory::GetFiles() const {
return files; return files;
} }

View file

@ -15,6 +15,7 @@ public:
explicit VectorVfsDirectory(std::vector<VirtualFile> files = {}, explicit VectorVfsDirectory(std::vector<VirtualFile> files = {},
std::vector<VirtualDir> dirs = {}, std::string name = "", std::vector<VirtualDir> dirs = {}, std::string name = "",
VirtualDir parent = nullptr); VirtualDir parent = nullptr);
~VectorVfsDirectory() override;
std::vector<std::shared_ptr<VfsFile>> GetFiles() const override; std::vector<std::shared_ptr<VfsFile>> GetFiles() const override;
std::vector<std::shared_ptr<VfsDirectory>> GetSubdirectories() const override; std::vector<std::shared_ptr<VfsDirectory>> GetSubdirectories() const override;

View file

@ -72,6 +72,8 @@ NAX::NAX(VirtualFile file_, std::array<u8, 0x10> nca_id)
Common::HexArrayToString(nca_id, false))); Common::HexArrayToString(nca_id, false)));
} }
NAX::~NAX() = default;
Loader::ResultStatus NAX::Parse(std::string_view path) { Loader::ResultStatus NAX::Parse(std::string_view path) {
if (file->ReadObject(header.get()) != sizeof(NAXHeader)) if (file->ReadObject(header.get()) != sizeof(NAXHeader))
return Loader::ResultStatus::ErrorBadNAXHeader; return Loader::ResultStatus::ErrorBadNAXHeader;

View file

@ -33,6 +33,7 @@ class NAX : public ReadOnlyVfsDirectory {
public: public:
explicit NAX(VirtualFile file); explicit NAX(VirtualFile file);
explicit NAX(VirtualFile file, std::array<u8, 0x10> nca_id); explicit NAX(VirtualFile file, std::array<u8, 0x10> nca_id);
~NAX() override;
Loader::ResultStatus GetStatus() const; Loader::ResultStatus GetStatus() const;