strat: use m_ for member variables

This commit is contained in:
Michael Scire
2021-10-10 00:14:06 -07:00
parent ce28591ab2
commit a595c232b9
425 changed files with 8531 additions and 8484 deletions

View File

@@ -21,20 +21,20 @@ namespace ams::ncm {
class AutoBuffer {
NON_COPYABLE(AutoBuffer);
private:
u8 *buffer;
size_t size;
u8 *m_buffer;
size_t m_size;
public:
AutoBuffer() : buffer(nullptr), size(0) { /* ... */ }
AutoBuffer() : m_buffer(nullptr), m_size(0) { /* ... */ }
~AutoBuffer() {
this->Reset();
}
AutoBuffer(AutoBuffer &&rhs) {
this->buffer = rhs.buffer;
this->size = rhs.size;
rhs.buffer = nullptr;
rhs.size = 0;
m_buffer = rhs.m_buffer;
m_size = rhs.m_size;
rhs.m_buffer = nullptr;
rhs.m_size = 0;
}
AutoBuffer &operator=(AutoBuffer &&rhs) {
@@ -43,35 +43,35 @@ namespace ams::ncm {
}
void Swap(AutoBuffer &rhs) {
std::swap(this->buffer, rhs.buffer);
std::swap(this->size, rhs.size);
std::swap(m_buffer, rhs.m_buffer);
std::swap(m_size, rhs.m_size);
}
void Reset() {
if (this->buffer != nullptr) {
delete[] this->buffer;
this->buffer = nullptr;
this->size = 0;
if (m_buffer != nullptr) {
delete[] m_buffer;
m_buffer = nullptr;
m_size = 0;
}
}
u8 *Get() const {
return this->buffer;
return m_buffer;
}
size_t GetSize() const {
return this->size;
return m_size;
}
Result Initialize(size_t size) {
/* Check that we're not already initialized. */
AMS_ABORT_UNLESS(this->buffer == nullptr);
AMS_ABORT_UNLESS(m_buffer == nullptr);
/* Allocate a buffer. */
this->buffer = new (std::nothrow) u8[size];
R_UNLESS(this->buffer != nullptr, ncm::ResultAllocationFailed());
m_buffer = new (std::nothrow) u8[size];
R_UNLESS(m_buffer != nullptr, ncm::ResultAllocationFailed());
this->size = size;
m_size = size;
return ResultSuccess();
}
@@ -80,7 +80,7 @@ namespace ams::ncm {
R_TRY(this->Initialize(size));
/* Copy the input data in. */
std::memcpy(this->buffer, buf, size);
std::memcpy(m_buffer, buf, size);
return ResultSuccess();
}

View File

@@ -22,11 +22,11 @@ namespace ams::ncm {
class ContentMetaDatabaseBuilder {
private:
ContentMetaDatabase *db;
ContentMetaDatabase *m_db;
private:
Result BuildFromPackageContentMeta(void *buf, size_t size, const ContentInfo &meta_info);
public:
explicit ContentMetaDatabaseBuilder(ContentMetaDatabase *d) : db(d) { /* ... */ }
explicit ContentMetaDatabaseBuilder(ContentMetaDatabase *d) : m_db(d) { /* ... */ }
Result BuildFromStorage(ContentStorage *storage);
Result BuildFromPackage(const char *package_root_path);

View File

@@ -33,26 +33,26 @@ namespace ams::ncm {
class ContentMetaMemoryResource : public MemoryResource {
private:
mem::StandardAllocator allocator;
size_t peak_total_alloc_size;
size_t peak_alloc_size;
mem::StandardAllocator m_allocator;
size_t m_peak_total_alloc_size;
size_t m_peak_alloc_size;
public:
explicit ContentMetaMemoryResource(void *heap, size_t heap_size) : allocator(heap, heap_size) { /* ... */ }
explicit ContentMetaMemoryResource(void *heap, size_t heap_size) : m_allocator(heap, heap_size), m_peak_alloc_size(0), m_peak_total_alloc_size(0) { /* ... */ }
mem::StandardAllocator *GetAllocator() { return std::addressof(this->allocator); }
size_t GetPeakTotalAllocationSize() const { return this->peak_total_alloc_size; }
size_t GetPeakAllocationSize() const { return this->peak_alloc_size; }
mem::StandardAllocator *GetAllocator() { return std::addressof(m_allocator); }
size_t GetPeakTotalAllocationSize() const { return m_peak_total_alloc_size; }
size_t GetPeakAllocationSize() const { return m_peak_alloc_size; }
private:
virtual void *AllocateImpl(size_t size, size_t alignment) override {
void *mem = this->allocator.Allocate(size, alignment);
this->peak_total_alloc_size = std::max(this->allocator.Hash().allocated_size, this->peak_total_alloc_size);
this->peak_alloc_size = std::max(size, this->peak_alloc_size);
void *mem = m_allocator.Allocate(size, alignment);
m_peak_total_alloc_size = std::max(m_allocator.Hash().allocated_size, m_peak_total_alloc_size);
m_peak_alloc_size = std::max(size, m_peak_alloc_size);
return mem;
}
virtual void DeallocateImpl(void *buffer, size_t size, size_t alignment) override {
AMS_UNUSED(size, alignment);
return this->allocator.Free(buffer);
return m_allocator.Free(buffer);
}
virtual bool IsEqualImpl(const MemoryResource &resource) const override {
@@ -103,16 +103,16 @@ namespace ams::ncm {
ContentMetaDatabaseRoot() { /* ... */ }
};
private:
os::SdkRecursiveMutex mutex;
bool initialized;
ContentStorageRoot content_storage_roots[MaxContentStorageRoots];
ContentMetaDatabaseRoot content_meta_database_roots[MaxContentMetaDatabaseRoots];
u32 num_content_storage_entries;
u32 num_content_meta_entries;
RightsIdCache rights_id_cache;
RegisteredHostContent registered_host_content;
os::SdkRecursiveMutex m_mutex;
bool m_initialized;
ContentStorageRoot m_content_storage_roots[MaxContentStorageRoots];
ContentMetaDatabaseRoot m_content_meta_database_roots[MaxContentMetaDatabaseRoots];
u32 m_num_content_storage_entries;
u32 m_num_content_meta_entries;
RightsIdCache m_rights_id_cache;
RegisteredHostContent m_registered_host_content;
public:
ContentManagerImpl() : mutex(), initialized(false), num_content_storage_entries(0), num_content_meta_entries(0), rights_id_cache(), registered_host_content() {
ContentManagerImpl() : m_mutex(), m_initialized(false), m_content_storage_roots(), m_content_meta_database_roots(), m_num_content_storage_entries(0), m_num_content_meta_entries(0), m_rights_id_cache(), m_registered_host_content() {
/* ... */
};
~ContentManagerImpl();

View File

@@ -118,9 +118,9 @@ namespace ams::ncm {
using HeaderType = ContentMetaHeaderType;
using InfoType = ContentInfoType;
private:
void *data;
const size_t size;
bool is_header_valid;
void *m_data;
const size_t m_size;
bool m_is_header_valid;
private:
static size_t GetExtendedHeaderSize(ContentMetaType type) {
switch (type) {
@@ -132,8 +132,8 @@ namespace ams::ncm {
}
}
protected:
constexpr ContentMetaAccessor(const void *d, size_t sz) : data(const_cast<void *>(d)), size(sz), is_header_valid(true) { /* ... */ }
constexpr ContentMetaAccessor(void *d, size_t sz) : data(d), size(sz), is_header_valid(false) { /* ... */ }
constexpr ContentMetaAccessor(const void *d, size_t sz) : m_data(const_cast<void *>(d)), m_size(sz), m_is_header_valid(true) { /* ... */ }
constexpr ContentMetaAccessor(void *d, size_t sz) : m_data(d), m_size(sz), m_is_header_valid(false) { /* ... */ }
template<class NewHeaderType, class NewInfoType>
static constexpr size_t CalculateSizeImpl(size_t ext_header_size, size_t content_count, size_t content_meta_count, size_t extended_data_size, bool has_digest) {
@@ -145,7 +145,7 @@ namespace ams::ncm {
}
uintptr_t GetExtendedHeaderAddress() const {
return reinterpret_cast<uintptr_t>(this->data) + sizeof(HeaderType);
return reinterpret_cast<uintptr_t>(m_data) + sizeof(HeaderType);
}
uintptr_t GetContentInfoStartAddress() const {
@@ -214,21 +214,21 @@ namespace ams::ncm {
public:
const void *GetData() const {
return this->data;
return m_data;
}
size_t GetSize() const {
return this->size;
return m_size;
}
HeaderType *GetWritableHeader() const {
AMS_ABORT_UNLESS(this->is_header_valid);
return reinterpret_cast<HeaderType *>(this->data);
AMS_ABORT_UNLESS(m_is_header_valid);
return reinterpret_cast<HeaderType *>(m_data);
}
const HeaderType *GetHeader() const {
AMS_ABORT_UNLESS(this->is_header_valid);
return static_cast<const HeaderType *>(this->data);
AMS_ABORT_UNLESS(m_is_header_valid);
return static_cast<const HeaderType *>(m_data);
}
ContentMetaKey GetKey() const {

View File

@@ -26,13 +26,13 @@ namespace ams::ncm {
s32 total;
};
private:
sf::SharedPointer<IContentMetaDatabase> interface;
sf::SharedPointer<IContentMetaDatabase> m_interface;
public:
ContentMetaDatabase() { /* ... */ }
explicit ContentMetaDatabase(sf::SharedPointer<IContentMetaDatabase> intf) : interface(intf) { /* ... */ }
explicit ContentMetaDatabase(sf::SharedPointer<IContentMetaDatabase> intf) : m_interface(intf) { /* ... */ }
ContentMetaDatabase(ContentMetaDatabase &&rhs) {
this->interface = std::move(rhs.interface);
m_interface = std::move(rhs.m_interface);
}
ContentMetaDatabase &operator=(ContentMetaDatabase &&rhs) {
@@ -41,18 +41,18 @@ namespace ams::ncm {
}
void swap(ContentMetaDatabase &rhs) {
std::swap(this->interface, rhs.interface);
std::swap(m_interface, rhs.m_interface);
}
public:
Result Set(const ContentMetaKey &key, const void *buf, size_t size) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->Set(key, sf::InBuffer(buf, size));
AMS_ASSERT(m_interface != nullptr);
return m_interface->Set(key, sf::InBuffer(buf, size));
}
Result Get(size_t *out_size, void *dst, size_t dst_size, const ContentMetaKey &key) {
AMS_ASSERT(this->interface != nullptr);
AMS_ASSERT(m_interface != nullptr);
u64 size;
R_TRY(this->interface->Get(std::addressof(size), key, sf::OutBuffer(dst, dst_size)));
R_TRY(m_interface->Get(std::addressof(size), key, sf::OutBuffer(dst, dst_size)));
*out_size = size;
return ResultSuccess();
@@ -60,13 +60,13 @@ namespace ams::ncm {
#define AMS_NCM_DEFINE_GETTERS(Kind, IdType) \
Result Get##Kind(ContentId *out, IdType##Id id, u32 version) { \
return this->interface->GetContentIdByType(out, ContentMetaKey::MakeUnknownType(id.value, version), ContentType::Kind); \
return m_interface->GetContentIdByType(out, ContentMetaKey::MakeUnknownType(id.value, version), ContentType::Kind); \
} \
\
Result GetLatest##Kind(ContentId *out, IdType##Id id) { \
ContentMetaKey latest_key; \
R_TRY(this->interface->GetLatestContentMetaKey(std::addressof(latest_key), id.value)); \
return this->interface->GetContentIdByType(out, latest_key, ContentType::Kind); \
R_TRY(m_interface->GetLatestContentMetaKey(std::addressof(latest_key), id.value)); \
return m_interface->GetContentIdByType(out, latest_key, ContentType::Kind); \
}
AMS_NCM_DEFINE_GETTERS(Program, Program)
@@ -78,8 +78,8 @@ namespace ams::ncm {
#undef AMS_NCM_DEFINE_GETTERS
Result Remove(const ContentMetaKey &key) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->Remove(key);
AMS_ASSERT(m_interface != nullptr);
return m_interface->Remove(key);
}
Result Remove(SystemProgramId id, u32 version) {
@@ -95,99 +95,99 @@ namespace ams::ncm {
}
Result GetContentIdByType(ContentId *out_content_id, const ContentMetaKey &key, ContentType type) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetContentIdByType(out_content_id, key, type);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetContentIdByType(out_content_id, key, type);
}
Result GetContentIdByTypeAndIdOffset(ContentId *out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetContentIdByTypeAndIdOffset(out_content_id, key, type, id_offset);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetContentIdByTypeAndIdOffset(out_content_id, key, type, id_offset);
}
ListCount ListApplication(ApplicationContentMetaKey *dst, size_t dst_size) {
ListCount lc = {};
R_ABORT_UNLESS(this->interface->ListApplication(std::addressof(lc.total), std::addressof(lc.written), sf::OutArray<ApplicationContentMetaKey>(dst, dst_size), ContentMetaType::Unknown));
R_ABORT_UNLESS(m_interface->ListApplication(std::addressof(lc.total), std::addressof(lc.written), sf::OutArray<ApplicationContentMetaKey>(dst, dst_size), ContentMetaType::Unknown));
return lc;
}
ListCount ListContentMeta(ContentMetaKey *dst, size_t dst_size, ContentMetaType type = ContentMetaType::Unknown, ApplicationId app_id = InvalidApplicationId, u64 min = std::numeric_limits<u64>::min(), u64 max = std::numeric_limits<u64>::max(), ContentInstallType install_type = ContentInstallType::Full) {
ListCount lc = {};
R_ABORT_UNLESS(this->interface->List(std::addressof(lc.total), std::addressof(lc.written), sf::OutArray<ContentMetaKey>(dst, dst_size), type, app_id, min, max, install_type));
R_ABORT_UNLESS(m_interface->List(std::addressof(lc.total), std::addressof(lc.written), sf::OutArray<ContentMetaKey>(dst, dst_size), type, app_id, min, max, install_type));
return lc;
}
Result GetLatest(ContentMetaKey *out_key, u64 id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetLatestContentMetaKey(out_key, id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetLatestContentMetaKey(out_key, id);
}
Result ListContentInfo(s32 *out_count, ContentInfo *dst, size_t dst_size, const ContentMetaKey &key, s32 offset) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->ListContentInfo(out_count, sf::OutArray<ContentInfo>(dst, dst_size), key, offset);
AMS_ASSERT(m_interface != nullptr);
return m_interface->ListContentInfo(out_count, sf::OutArray<ContentInfo>(dst, dst_size), key, offset);
}
Result ListContentMetaInfo(s32 *out_count, ContentMetaInfo *dst, size_t dst_size, const ContentMetaKey &key, s32 offset) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->ListContentMetaInfo(out_count, sf::OutArray<ContentMetaInfo>(dst, dst_size), key, offset);
AMS_ASSERT(m_interface != nullptr);
return m_interface->ListContentMetaInfo(out_count, sf::OutArray<ContentMetaInfo>(dst, dst_size), key, offset);
}
Result Has(bool *out, const ContentMetaKey &key) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->Has(out, key);
AMS_ASSERT(m_interface != nullptr);
return m_interface->Has(out, key);
}
Result HasAll(bool *out, const ContentMetaKey *keys, size_t num_keys) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->HasAll(out, sf::InArray<ContentMetaKey>(keys, num_keys));
AMS_ASSERT(m_interface != nullptr);
return m_interface->HasAll(out, sf::InArray<ContentMetaKey>(keys, num_keys));
}
Result HasContent(bool *out, const ContentMetaKey &key, const ContentId &content_id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->HasContent(out, key, content_id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->HasContent(out, key, content_id);
}
Result GetSize(size_t *out_size, const ContentMetaKey &key) {
AMS_ASSERT(this->interface != nullptr);
AMS_ASSERT(m_interface != nullptr);
u64 size;
R_TRY(this->interface->GetSize(std::addressof(size), key));
R_TRY(m_interface->GetSize(std::addressof(size), key));
*out_size = size;
return ResultSuccess();
}
Result GetRequiredSystemVersion(u32 *out_version, const ContentMetaKey &key) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetRequiredSystemVersion(out_version, key);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetRequiredSystemVersion(out_version, key);
}
Result GetPatchId(PatchId *out_patch_id, const ContentMetaKey &key) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetPatchId(out_patch_id, key);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetPatchId(out_patch_id, key);
}
Result DisableForcibly() {
AMS_ASSERT(this->interface != nullptr);
return this->interface->DisableForcibly();
AMS_ASSERT(m_interface != nullptr);
return m_interface->DisableForcibly();
}
Result LookupOrphanContent(bool *out_orphaned, ContentId *content_list, size_t count) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->LookupOrphanContent(sf::OutArray<bool>(out_orphaned, count), sf::InArray<ContentId>(content_list, count));
AMS_ASSERT(m_interface != nullptr);
return m_interface->LookupOrphanContent(sf::OutArray<bool>(out_orphaned, count), sf::InArray<ContentId>(content_list, count));
}
Result Commit() {
AMS_ASSERT(this->interface != nullptr);
return this->interface->Commit();
AMS_ASSERT(m_interface != nullptr);
return m_interface->Commit();
}
Result GetAttributes(u8 *out_attributes, const ContentMetaKey &key) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetAttributes(out_attributes, key);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetAttributes(out_attributes, key);
}
Result GetRequiredApplicationVersion(u32 *out_version, const ContentMetaKey &key) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetRequiredApplicationVersion(out_version, key);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetRequiredApplicationVersion(out_version, key);
}
};

View File

@@ -112,10 +112,10 @@ namespace ams::ncm {
template<typename MemberTypePointer, typename DataTypePointer>
class PatchMetaExtendedDataReaderWriterBase {
private:
MemberTypePointer data;
const size_t size;
MemberTypePointer m_data;
const size_t m_size;
public:
PatchMetaExtendedDataReaderWriterBase(MemberTypePointer d, size_t sz) : data(d), size(sz) { /* ... */ }
PatchMetaExtendedDataReaderWriterBase(MemberTypePointer d, size_t sz) : m_data(d), m_size(sz) { /* ... */ }
protected:
s32 CountFragmentSet(s32 delta_index) const {
auto delta_header = this->GetPatchDeltaHeader(0);
@@ -154,7 +154,7 @@ namespace ams::ncm {
}
DataTypePointer GetHeaderAddress() const {
return reinterpret_cast<DataTypePointer>(this->data);
return reinterpret_cast<DataTypePointer>(m_data);
}
DataTypePointer GetPatchHistoryHeaderAddress(s32 index) const {
@@ -307,15 +307,15 @@ namespace ams::ncm {
class SystemUpdateMetaExtendedDataReaderWriterBase {
private:
void *data;
const size_t size;
bool is_header_valid;
void *m_data;
const size_t m_size;
bool m_is_header_valid;
protected:
constexpr SystemUpdateMetaExtendedDataReaderWriterBase(const void *d, size_t sz) : data(const_cast<void *>(d)), size(sz), is_header_valid(true) { /* ... */ }
constexpr SystemUpdateMetaExtendedDataReaderWriterBase(void *d, size_t sz) : data(d), size(sz), is_header_valid(false) { /* ... */ }
constexpr SystemUpdateMetaExtendedDataReaderWriterBase(const void *d, size_t sz) : m_data(const_cast<void *>(d)), m_size(sz), m_is_header_valid(true) { /* ... */ }
constexpr SystemUpdateMetaExtendedDataReaderWriterBase(void *d, size_t sz) : m_data(d), m_size(sz), m_is_header_valid(false) { /* ... */ }
uintptr_t GetHeaderAddress() const {
return reinterpret_cast<uintptr_t>(this->data);
return reinterpret_cast<uintptr_t>(m_data);
}
uintptr_t GetFirmwareVariationIdStartAddress() const {
@@ -343,7 +343,7 @@ namespace ams::ncm {
}
public:
const SystemUpdateMetaExtendedDataHeader *GetHeader() const {
AMS_ABORT_UNLESS(this->is_header_valid);
AMS_ABORT_UNLESS(m_is_header_valid);
return reinterpret_cast<const SystemUpdateMetaExtendedDataHeader *>(this->GetHeaderAddress());
}

View File

@@ -21,13 +21,13 @@ namespace ams::ncm {
class ContentStorage {
NON_COPYABLE(ContentStorage);
private:
sf::SharedPointer<IContentStorage> interface;
sf::SharedPointer<IContentStorage> m_interface;
public:
ContentStorage() { /* ... */ }
explicit ContentStorage(sf::SharedPointer<IContentStorage> intf) : interface(intf) { /* ... */ }
explicit ContentStorage(sf::SharedPointer<IContentStorage> intf) : m_interface(intf) { /* ... */ }
ContentStorage(ContentStorage &&rhs) {
this->interface = std::move(rhs.interface);
m_interface = std::move(rhs.m_interface);
}
ContentStorage &operator=(ContentStorage &&rhs) {
@@ -36,166 +36,166 @@ namespace ams::ncm {
}
void swap(ContentStorage &rhs) {
std::swap(this->interface, rhs.interface);
std::swap(m_interface, rhs.m_interface);
}
public:
PlaceHolderId GeneratePlaceHolderId() {
AMS_ASSERT(this->interface != nullptr);
AMS_ASSERT(m_interface != nullptr);
PlaceHolderId id;
R_ABORT_UNLESS(this->interface->GeneratePlaceHolderId(std::addressof(id)));
R_ABORT_UNLESS(m_interface->GeneratePlaceHolderId(std::addressof(id)));
return id;
}
Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->CreatePlaceHolder(placeholder_id, content_id, size);
AMS_ASSERT(m_interface != nullptr);
return m_interface->CreatePlaceHolder(placeholder_id, content_id, size);
}
Result DeletePlaceHolder(PlaceHolderId placeholder_id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->DeletePlaceHolder(placeholder_id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->DeletePlaceHolder(placeholder_id);
}
Result HasPlaceHolder(bool *out, PlaceHolderId placeholder_id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->HasPlaceHolder(out, placeholder_id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->HasPlaceHolder(out, placeholder_id);
}
Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, const void *buf, size_t size) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->WritePlaceHolder(placeholder_id, offset, sf::InBuffer(buf, size));
AMS_ASSERT(m_interface != nullptr);
return m_interface->WritePlaceHolder(placeholder_id, offset, sf::InBuffer(buf, size));
}
Result Register(PlaceHolderId placeholder_id, ContentId content_id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->Register(placeholder_id, content_id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->Register(placeholder_id, content_id);
}
Result Delete(ContentId content_id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->Delete(content_id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->Delete(content_id);
}
Result Has(bool *out, ContentId content_id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->Has(out, content_id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->Has(out, content_id);
}
void GetPath(Path *out, ContentId content_id) {
AMS_ASSERT(this->interface != nullptr);
R_ABORT_UNLESS(this->interface->GetPath(out, content_id));
AMS_ASSERT(m_interface != nullptr);
R_ABORT_UNLESS(m_interface->GetPath(out, content_id));
}
void GetPlaceHolderPath(Path *out, PlaceHolderId placeholder_id) {
AMS_ASSERT(this->interface != nullptr);
R_ABORT_UNLESS(this->interface->GetPlaceHolderPath(out, placeholder_id));
AMS_ASSERT(m_interface != nullptr);
R_ABORT_UNLESS(m_interface->GetPlaceHolderPath(out, placeholder_id));
}
Result CleanupAllPlaceHolder() {
AMS_ASSERT(this->interface != nullptr);
return this->interface->CleanupAllPlaceHolder();
AMS_ASSERT(m_interface != nullptr);
return m_interface->CleanupAllPlaceHolder();
}
Result ListPlaceHolder(s32 *out_count, PlaceHolderId *out_list, size_t out_list_size) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->ListPlaceHolder(out_count, sf::OutArray<PlaceHolderId>(out_list, out_list_size));
AMS_ASSERT(m_interface != nullptr);
return m_interface->ListPlaceHolder(out_count, sf::OutArray<PlaceHolderId>(out_list, out_list_size));
}
Result GetContentCount(s32 *out_count) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetContentCount(out_count);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetContentCount(out_count);
}
Result ListContentId(s32 *out_count, ContentId *out_list, size_t out_list_size, s32 offset) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->ListContentId(out_count, sf::OutArray<ContentId>(out_list, out_list_size), offset);
AMS_ASSERT(m_interface != nullptr);
return m_interface->ListContentId(out_count, sf::OutArray<ContentId>(out_list, out_list_size), offset);
}
Result GetSize(s64 *out_size, ContentId content_id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetSizeFromContentId(out_size, content_id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetSizeFromContentId(out_size, content_id);
}
Result GetSize(s64 *out_size, PlaceHolderId placeholder_id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetSizeFromPlaceHolderId(out_size, placeholder_id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetSizeFromPlaceHolderId(out_size, placeholder_id);
}
Result DisableForcibly() {
AMS_ASSERT(this->interface != nullptr);
return this->interface->DisableForcibly();
AMS_ASSERT(m_interface != nullptr);
return m_interface->DisableForcibly();
}
Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->RevertToPlaceHolder(placeholder_id, old_content_id, new_content_id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->RevertToPlaceHolder(placeholder_id, old_content_id, new_content_id);
}
Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->SetPlaceHolderSize(placeholder_id, size);
AMS_ASSERT(m_interface != nullptr);
return m_interface->SetPlaceHolderSize(placeholder_id, size);
}
Result ReadContentIdFile(void *dst, size_t size, ContentId content_id, s64 offset) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->ReadContentIdFile(sf::OutBuffer(dst, size), content_id, offset);
AMS_ASSERT(m_interface != nullptr);
return m_interface->ReadContentIdFile(sf::OutBuffer(dst, size), content_id, offset);
}
Result GetRightsId(ncm::RightsId *out_rights_id, PlaceHolderId placeholder_id) {
AMS_ASSERT(this->interface != nullptr);
AMS_ASSERT(m_interface != nullptr);
const auto vers = hos::GetVersion();
if (vers >= hos::Version_3_0_0) {
return this->interface->GetRightsIdFromPlaceHolderId(out_rights_id, placeholder_id);
return m_interface->GetRightsIdFromPlaceHolderId(out_rights_id, placeholder_id);
} else {
AMS_ABORT_UNLESS(vers >= hos::Version_2_0_0);
*out_rights_id = {};
return this->interface->GetRightsIdFromPlaceHolderIdDeprecated(std::addressof(out_rights_id->id), placeholder_id);
return m_interface->GetRightsIdFromPlaceHolderIdDeprecated(std::addressof(out_rights_id->id), placeholder_id);
}
}
Result GetRightsId(ncm::RightsId *out_rights_id, ContentId content_id) {
AMS_ASSERT(this->interface != nullptr);
AMS_ASSERT(m_interface != nullptr);
const auto vers = hos::GetVersion();
if (vers >= hos::Version_3_0_0) {
return this->interface->GetRightsIdFromContentId(out_rights_id, content_id);
return m_interface->GetRightsIdFromContentId(out_rights_id, content_id);
} else {
AMS_ABORT_UNLESS(vers >= hos::Version_2_0_0);
*out_rights_id = {};
return this->interface->GetRightsIdFromContentIdDeprecated(std::addressof(out_rights_id->id), content_id);
return m_interface->GetRightsIdFromContentIdDeprecated(std::addressof(out_rights_id->id), content_id);
}
}
Result WriteContentForDebug(ContentId content_id, s64 offset, const void *buf, size_t size) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->WriteContentForDebug(content_id, offset, sf::InBuffer(buf, size));
AMS_ASSERT(m_interface != nullptr);
return m_interface->WriteContentForDebug(content_id, offset, sf::InBuffer(buf, size));
}
Result GetFreeSpaceSize(s64 *out_size) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetFreeSpaceSize(out_size);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetFreeSpaceSize(out_size);
}
Result GetTotalSpaceSize(s64 *out_size) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetTotalSpaceSize(out_size);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetTotalSpaceSize(out_size);
}
Result FlushPlaceHolder() {
AMS_ASSERT(this->interface != nullptr);
return this->interface->FlushPlaceHolder();
AMS_ASSERT(m_interface != nullptr);
return m_interface->FlushPlaceHolder();
}
Result RepairInvalidFileAttribute() {
AMS_ASSERT(this->interface != nullptr);
return this->interface->RepairInvalidFileAttribute();
AMS_ASSERT(m_interface != nullptr);
return m_interface->RepairInvalidFileAttribute();
}
Result GetRightsIdFromPlaceHolderIdWithCache(ncm::RightsId *out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetRightsIdFromPlaceHolderIdWithCache(out_rights_id, placeholder_id, cache_content_id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetRightsIdFromPlaceHolderIdWithCache(out_rights_id, placeholder_id, cache_content_id);
}
};

View File

@@ -82,18 +82,18 @@ namespace ams::ncm {
NON_COPYABLE(InstallTaskBase);
NON_MOVEABLE(InstallTaskBase);
private:
crypto::Sha256Generator sha256_generator;
StorageId install_storage;
InstallTaskDataBase *data;
InstallProgress progress;
os::SdkMutex progress_mutex;
u32 config;
os::SdkMutex cancel_mutex;
bool cancel_requested;
InstallThroughput throughput;
TimeSpan throughput_start_time;
os::SdkMutex throughput_mutex;
FirmwareVariationId firmware_variation_id;
crypto::Sha256Generator m_sha256_generator;
StorageId m_install_storage;
InstallTaskDataBase *m_data;
InstallProgress m_progress;
os::SdkMutex m_progress_mutex;
u32 m_config;
os::SdkMutex m_cancel_mutex;
bool m_cancel_requested;
InstallThroughput m_throughput;
TimeSpan m_throughput_start_time;
os::SdkMutex m_throughput_mutex;
FirmwareVariationId m_firmware_variation_id;
private:
ALWAYS_INLINE Result SetLastResultOnFailure(Result result) {
if (R_FAILED(result)) {
@@ -102,7 +102,7 @@ namespace ams::ncm {
return result;
}
public:
InstallTaskBase() : data(), progress(), progress_mutex(), cancel_mutex(), cancel_requested(), throughput_mutex() { /* ... */ }
InstallTaskBase() : m_data(), m_progress(), m_progress_mutex(), m_cancel_mutex(), m_cancel_requested(), m_throughput_mutex() { /* ... */ }
virtual ~InstallTaskBase() { /* ... */ };
public:
virtual void Cancel();
@@ -144,10 +144,10 @@ namespace ams::ncm {
virtual Result PrepareDependency();
Result PrepareSystemUpdateDependency();
virtual Result PrepareContentMetaIfLatest(const ContentMetaKey &key); /* NOTE: This is not virtual in Nintendo's code. We do so to facilitate downgrades. */
u32 GetConfig() const { return this->config; }
u32 GetConfig() const { return m_config; }
Result WriteContentMetaToPlaceHolder(InstallContentInfo *out_install_content_info, ContentStorage *storage, const InstallContentMetaInfo &meta_info, util::optional<bool> is_temporary);
StorageId GetInstallStorage() const { return this->install_storage; }
StorageId GetInstallStorage() const { return m_install_storage; }
virtual Result OnPrepareComplete() { return ResultSuccess(); }
@@ -196,7 +196,7 @@ namespace ams::ncm {
public:
virtual Result CheckInstallable() { return ResultSuccess(); }
void SetFirmwareVariationId(FirmwareVariationId id) { this->firmware_variation_id = id; }
void SetFirmwareVariationId(FirmwareVariationId id) { m_firmware_variation_id = id; }
Result ListRightsIds(s32 *out_count, Span<RightsId> out_span, const ContentMetaKey &key, s32 offset);
};

View File

@@ -59,12 +59,12 @@ namespace ams::ncm {
struct DataHolder : public InstallContentMeta, public util::IntrusiveListBaseNode<DataHolder>{};
using DataList = util::IntrusiveListBaseTraits<DataHolder>::ListType;
private:
DataList data_list;
InstallProgressState state;
Result last_result;
SystemUpdateTaskApplyInfo system_update_task_apply_info;
DataList m_data_list;
InstallProgressState m_state;
Result m_last_result;
SystemUpdateTaskApplyInfo m_system_update_task_apply_info;
public:
MemoryInstallTaskData() : state(InstallProgressState::NotPrepared), last_result(ResultSuccess()) { /* ... */ };
MemoryInstallTaskData() : m_state(InstallProgressState::NotPrepared), m_last_result(ResultSuccess()) { /* ... */ };
~MemoryInstallTaskData() {
this->Cleanup();
}
@@ -104,8 +104,8 @@ namespace ams::ncm {
static_assert(sizeof(EntryInfo) == 0x10);
private:
Header header;
char path[64];
Header m_header;
char m_path[64];
private:
static constexpr Header MakeInitialHeader(s32 max_entries) {
return {

View File

@@ -40,13 +40,13 @@ namespace ams::ncm {
class HeapState {
private:
os::SdkMutex mutex;
lmem::HeapHandle heap_handle;
size_t total_alloc_size;
size_t peak_total_alloc_size;
size_t peak_alloc_size;
os::SdkMutex m_mutex;
lmem::HeapHandle m_heap_handle;
size_t m_total_alloc_size;
size_t m_peak_total_alloc_size;
size_t m_peak_alloc_size;
public:
constexpr HeapState() : mutex(), heap_handle(nullptr), total_alloc_size(0), peak_total_alloc_size(0), peak_alloc_size(0) { /* ... */ }
constexpr HeapState() : m_mutex(), m_heap_handle(nullptr), m_total_alloc_size(0), m_peak_total_alloc_size(0), m_peak_alloc_size(0) { /* ... */ }
void Initialize(lmem::HeapHandle heap_handle);
void Allocate(size_t size);

View File

@@ -20,7 +20,7 @@ namespace ams::ncm {
class PackageInstallTask : public PackageInstallTaskBase {
private:
MemoryInstallTaskData data;
MemoryInstallTaskData m_data;
public:
Result Initialize(const char *package_root, StorageId storage_id, void *buffer, size_t buffer_size, bool ignore_ticket);
protected:

View File

@@ -23,16 +23,16 @@ namespace ams::ncm {
private:
using PackagePath = kvdb::BoundedString<256>;
private:
PackagePath package_root;
void *buffer;
size_t buffer_size;
PackagePath m_package_root;
void *m_buffer;
size_t m_buffer_size;
public:
PackageInstallTaskBase() : package_root() { /* ... */ }
PackageInstallTaskBase() : m_package_root() { /* ... */ }
Result Initialize(const char *package_root_path, void *buffer, size_t buffer_size, StorageId storage_id, InstallTaskDataBase *data, u32 config);
protected:
const char *GetPackageRootPath() {
return this->package_root.Get();
return m_package_root.Get();
}
private:
virtual Result OnWritePlaceHolder(const ContentMetaKey &key, InstallContentInfo *content_info) override;

View File

@@ -22,10 +22,10 @@ namespace ams::ncm {
private:
using PackagePath = kvdb::BoundedString<0x100>;
private:
PackagePath context_path;
FileInstallTaskData data;
ContentMetaDatabase package_db;
bool gamecard_content_meta_database_active;
PackagePath m_context_path;
FileInstallTaskData m_data;
ContentMetaDatabase m_package_db;
bool m_gamecard_content_meta_database_active;
public:
~PackageSystemUpdateTask();
@@ -35,7 +35,7 @@ namespace ams::ncm {
protected:
virtual Result PrepareInstallContentMetaData() override;
virtual Result GetInstallContentMetaInfo(InstallContentMetaInfo *out, const ContentMetaKey &key) override;
InstallTaskDataBase &GetInstallData() { return this->data; } /* Atmosphere extension. */
InstallTaskDataBase &GetInstallData() { return m_data; } /* Atmosphere extension. */
private:
virtual Result PrepareDependency() override;

View File

@@ -28,10 +28,10 @@ namespace ams::ncm {
private:
using RegisteredPathList = ams::util::IntrusiveListBaseTraits<RegisteredPath>::ListType;
private:
os::SdkMutex mutex;
RegisteredPathList path_list;
os::SdkMutex m_mutex;
RegisteredPathList m_path_list;
public:
RegisteredHostContent() : mutex(), path_list() { /* ... */ }
RegisteredHostContent() : m_mutex(), m_path_list() { /* ... */ }
~RegisteredHostContent();
Result RegisterPath(const ncm::ContentId &content_id, const ncm::Path &path);

View File

@@ -33,28 +33,28 @@ namespace ams::ncm {
u64 last_accessed;
};
private:
Entry entries[MaxEntries];
u64 counter;
os::SdkMutex mutex;
Entry m_entries[MaxEntries];
u64 m_counter;
os::SdkMutex m_mutex;
public:
RightsIdCache() : mutex() {
RightsIdCache() : m_mutex() {
this->Invalidate();
}
void Invalidate() {
this->counter = 2;
m_counter = 2;
for (size_t i = 0; i < MaxEntries; i++) {
this->entries[i].last_accessed = 1;
m_entries[i].last_accessed = 1;
}
}
void Store(ContentId content_id, ncm::RightsId rights_id) {
std::scoped_lock lk(this->mutex);
Entry *eviction_candidate = std::addressof(this->entries[0]);
std::scoped_lock lk(m_mutex);
Entry *eviction_candidate = std::addressof(m_entries[0]);
/* Find a suitable existing entry to store our new one at. */
for (size_t i = 1; i < MaxEntries; i++) {
Entry *entry = std::addressof(this->entries[i]);
Entry *entry = std::addressof(m_entries[i]);
/* Change eviction candidates if the uuid already matches ours, or if the uuid doesn't already match and the last_accessed count is lower */
if (content_id == entry->uuid || (content_id != eviction_candidate->uuid && entry->last_accessed < eviction_candidate->last_accessed)) {
@@ -65,19 +65,19 @@ namespace ams::ncm {
/* Update the cache. */
eviction_candidate->uuid = content_id.uuid;
eviction_candidate->rights_id = rights_id;
eviction_candidate->last_accessed = this->counter++;
eviction_candidate->last_accessed = m_counter++;
}
bool Find(ncm::RightsId *out_rights_id, ContentId content_id) {
std::scoped_lock lk(this->mutex);
std::scoped_lock lk(m_mutex);
/* Attempt to locate the content id in the cache. */
for (size_t i = 0; i < MaxEntries; i++) {
Entry *entry = std::addressof(this->entries[i]);
Entry *entry = std::addressof(m_entries[i]);
if (entry->last_accessed != 1 && content_id == entry->uuid) {
entry->last_accessed = this->counter;
this->counter++;
entry->last_accessed = m_counter;
m_counter++;
*out_rights_id = entry->rights_id;
return true;
}

View File

@@ -23,30 +23,30 @@ namespace ams::ncm {
public:
static constexpr s32 MaxCount = 10;
private:
StorageId ids[MaxCount];
s32 count;
StorageId m_ids[MaxCount];
s32 m_count;
public:
constexpr StorageList() : ids(), count() { /* ... */ }
constexpr StorageList() : m_ids(), m_count() { /* ... */ }
void Push(StorageId storage_id) {
AMS_ABORT_UNLESS(this->count < MaxCount);
AMS_ABORT_UNLESS(m_count < MaxCount);
for (s32 i = 0; i < MaxCount; i++) {
if (this->ids[i] == storage_id) {
if (m_ids[i] == storage_id) {
return;
}
}
this->ids[this->count++] = storage_id;
m_ids[m_count++] = storage_id;
}
s32 Count() const {
return this->count;
return m_count;
}
StorageId operator[](s32 i) const {
AMS_ABORT_UNLESS(i < this->count);
return this->ids[i];
AMS_ABORT_UNLESS(i < m_count);
return m_ids[i];
}
};

View File

@@ -23,7 +23,7 @@ namespace ams::ncm {
private:
class Impl;
private:
std::unique_ptr<Impl> impl;
std::unique_ptr<Impl> m_impl;
public:
SubmissionPackageInstallTask();
virtual ~SubmissionPackageInstallTask() override;