Skip to content

Commit

Permalink
strat: use m_ for member variables
Browse files Browse the repository at this point in the history
  • Loading branch information
SciresM committed Oct 10, 2021
1 parent ce28591 commit a595c23
Show file tree
Hide file tree
Showing 425 changed files with 8,536 additions and 8,489 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,39 @@ namespace ams::ddsf {
NON_COPYABLE(DeviceCodeEntry);
NON_MOVEABLE(DeviceCodeEntry);
private:
ams::DeviceCode device_code = ams::InvalidDeviceCode;
IDevice *device = nullptr;
ams::DeviceCode m_device_code = ams::InvalidDeviceCode;
IDevice *m_device = nullptr;
public:
constexpr DeviceCodeEntry(ams::DeviceCode dc, IDevice *dev) : device_code(dc), device(dev) {
constexpr DeviceCodeEntry(ams::DeviceCode dc, IDevice *dev) : m_device_code(dc), m_device(dev) {
AMS_ASSERT(dev != nullptr);
}

constexpr ams::DeviceCode GetDeviceCode() const {
return this->device_code;
return m_device_code;
}

constexpr IDevice &GetDevice() {
return *this->device;
return *m_device;
}

constexpr const IDevice &GetDevice() const {
return *this->device;
return *m_device;
}
};

class DeviceCodeEntryHolder {
NON_COPYABLE(DeviceCodeEntryHolder);
NON_MOVEABLE(DeviceCodeEntryHolder);
private:
util::IntrusiveListNode list_node;
util::TypedStorage<DeviceCodeEntry> entry_storage;
bool is_constructed;
util::IntrusiveListNode m_list_node;
util::TypedStorage<DeviceCodeEntry> m_entry_storage;
bool m_is_constructed;
public:
using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&DeviceCodeEntryHolder::list_node>;
using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&DeviceCodeEntryHolder::m_list_node>;
using List = typename ListTraits::ListType;
friend class util::IntrusiveList<DeviceCodeEntryHolder, util::IntrusiveListMemberTraitsDeferredAssert<&DeviceCodeEntryHolder::list_node>>;
friend class util::IntrusiveList<DeviceCodeEntryHolder, util::IntrusiveListMemberTraitsDeferredAssert<&DeviceCodeEntryHolder::m_list_node>>;
public:
DeviceCodeEntryHolder() : list_node(), entry_storage(), is_constructed(false) {
DeviceCodeEntryHolder() : m_list_node(), m_entry_storage(), m_is_constructed(false) {
/* ... */
}

Expand All @@ -75,34 +75,34 @@ namespace ams::ddsf {
}

bool IsLinkedToList() const {
return this->list_node.IsLinked();
return m_list_node.IsLinked();
}

DeviceCodeEntry &Construct(DeviceCode dc, IDevice *dev) {
AMS_ASSERT(!this->IsConstructed());
DeviceCodeEntry *entry = util::ConstructAt(this->entry_storage, dc, dev);
this->is_constructed = true;
DeviceCodeEntry *entry = util::ConstructAt(m_entry_storage, dc, dev);
m_is_constructed = true;
return *entry;
}

bool IsConstructed() const {
return this->is_constructed;
return m_is_constructed;
}

void Destroy() {
AMS_ASSERT(this->IsConstructed());
util::DestroyAt(this->entry_storage);
this->is_constructed = false;
util::DestroyAt(m_entry_storage);
m_is_constructed = false;
}

DeviceCodeEntry &Get() {
AMS_ASSERT(this->IsConstructed());
return GetReference(this->entry_storage);
return GetReference(m_entry_storage);
}

const DeviceCodeEntry &Get() const {
AMS_ASSERT(this->IsConstructed());
return GetReference(this->entry_storage);
return GetReference(m_entry_storage);
}
};
static_assert(DeviceCodeEntryHolder::ListTraits::IsValid());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,33 @@ namespace ams::ddsf {

class DeviceCodeEntryManager {
private:
ams::MemoryResource *memory_resource;
ddsf::DeviceCodeEntryHolder::List entry_list;
mutable os::SdkMutex entry_list_lock;
ams::MemoryResource *m_memory_resource;
ddsf::DeviceCodeEntryHolder::List m_entry_list;
mutable os::SdkMutex m_entry_list_lock;
private:
void DestroyAllEntries() {
auto it = this->entry_list.begin();
while (it != this->entry_list.end()) {
auto it = m_entry_list.begin();
while (it != m_entry_list.end()) {
ddsf::DeviceCodeEntryHolder *entry = std::addressof(*it);
it = this->entry_list.erase(it);
it = m_entry_list.erase(it);

AMS_ASSERT(entry->IsConstructed());
if (entry->IsConstructed()) {
entry->Destroy();
}

this->memory_resource->Deallocate(entry, sizeof(*entry));
m_memory_resource->Deallocate(entry, sizeof(*entry));
}
}
public:
DeviceCodeEntryManager(ams::MemoryResource *mr) : memory_resource(mr), entry_list(), entry_list_lock() { /* ... */ }
DeviceCodeEntryManager(ams::MemoryResource *mr) : m_memory_resource(mr), m_entry_list(), m_entry_list_lock() { /* ... */ }

~DeviceCodeEntryManager() {
this->DestroyAllEntries();
}

void Reset() {
std::scoped_lock lk(this->entry_list_lock);
std::scoped_lock lk(m_entry_list_lock);
this->DestroyAllEntries();
}

Expand All @@ -66,15 +66,15 @@ namespace ams::ddsf {

template<typename F>
int ForEachEntry(F f) {
return impl::ForEach(this->entry_list_lock, this->entry_list, [&](DeviceCodeEntryHolder &holder) -> bool {
return impl::ForEach(m_entry_list_lock, m_entry_list, [&](DeviceCodeEntryHolder &holder) -> bool {
AMS_ASSERT(holder.IsConstructed());
return f(holder.Get());
});
}

template<typename F>
int ForEachEntry(F f) const {
return impl::ForEach(this->entry_list_lock, this->entry_list, [&](const DeviceCodeEntryHolder &holder) -> bool {
return impl::ForEach(m_entry_list_lock, m_entry_list, [&](const DeviceCodeEntryHolder &holder) -> bool {
AMS_ASSERT(holder.IsConstructed());
return f(holder.Get());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,41 @@ namespace ams::ddsf {
private:
struct LoopControlCommandParameters;
private:
bool is_initialized;
bool is_looping;
os::SdkConditionVariable is_looping_cv;
os::MultiWaitType multi_wait;
os::ThreadType *loop_thread;
os::Event loop_control_event;
os::MultiWaitHolderType loop_control_event_holder;
LoopControlCommandParameters *loop_control_command_params;
os::LightEvent loop_control_command_done_event;
os::SdkMutex loop_control_lock;
bool m_is_initialized;
bool m_is_looping;
os::SdkConditionVariable m_is_looping_cv;
os::MultiWaitType m_multi_wait;
os::ThreadType *m_loop_thread;
os::Event m_loop_control_event;
os::MultiWaitHolderType m_loop_control_event_holder;
LoopControlCommandParameters *m_loop_control_command_params;
os::LightEvent m_loop_control_command_done_event;
os::SdkMutex m_loop_control_lock;
private:
void ProcessControlCommand(LoopControlCommandParameters *params);
void ProcessControlCommandImpl(LoopControlCommandParameters *params);
public:
EventHandlerManager()
: is_initialized(false), is_looping(false), is_looping_cv(), multi_wait(),
loop_thread(), loop_control_event(os::EventClearMode_AutoClear), loop_control_event_holder(),
loop_control_command_params(), loop_control_command_done_event(os::EventClearMode_AutoClear),
loop_control_lock()
: m_is_initialized(false), m_is_looping(false), m_is_looping_cv(), m_multi_wait(),
m_loop_thread(), m_loop_control_event(os::EventClearMode_AutoClear), m_loop_control_event_holder(),
m_loop_control_command_params(), m_loop_control_command_done_event(os::EventClearMode_AutoClear),
m_loop_control_lock()
{
this->Initialize();
}

~EventHandlerManager() {
if (this->is_looping) {
if (m_is_looping) {
AMS_ASSERT(!this->IsRunningOnLoopThread());
this->RequestStop();
}
if (this->is_initialized) {
if (m_is_initialized) {
this->Finalize();
}
}

bool IsRunningOnLoopThread() const { return this->loop_thread == os::GetCurrentThread(); }
bool IsLooping() const { return this->is_looping; }
bool IsRunningOnLoopThread() const { return m_loop_thread == os::GetCurrentThread(); }
bool IsLooping() const { return m_is_looping; }

void Initialize();
void Finalize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,57 +32,57 @@ namespace ams::ddsf {
public:
AMS_DDSF_CASTABLE_ROOT_TRAITS(ams::ddsf::IDevice);
private:
util::IntrusiveListNode list_node;
IDriver *driver;
ISession::List session_list;
mutable os::SdkMutex session_list_lock;
bool is_exclusive_write;
util::IntrusiveListNode m_list_node;
IDriver *m_driver;
ISession::List m_session_list;
mutable os::SdkMutex m_session_list_lock;
bool m_is_exclusive_write;
public:
using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&IDevice::list_node>;
using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&IDevice::m_list_node>;
using List = typename ListTraits::ListType;
friend class util::IntrusiveList<IDevice, util::IntrusiveListMemberTraitsDeferredAssert<&IDevice::list_node>>;
friend class util::IntrusiveList<IDevice, util::IntrusiveListMemberTraitsDeferredAssert<&IDevice::m_list_node>>;
private:
Result AttachSession(ISession *session) {
AMS_ASSERT(session != nullptr);
std::scoped_lock lk(this->session_list_lock);
std::scoped_lock lk(m_session_list_lock);

/* Check if we're allowed to attach the session. */
if (this->is_exclusive_write && session->CheckExclusiveWrite()) {
for (const auto &attached : this->session_list) {
if (m_is_exclusive_write && session->CheckExclusiveWrite()) {
for (const auto &attached : m_session_list) {
R_UNLESS(!attached.CheckAccess(AccessMode_Write), ddsf::ResultAccessModeDenied());
}
}

/* Attach the session. */
this->session_list.push_back(*session);
m_session_list.push_back(*session);
return ResultSuccess();
}

void DetachSession(ISession *session) {
AMS_ASSERT(session != nullptr);
std::scoped_lock lk(this->session_list_lock);
this->session_list.erase(this->session_list.iterator_to(*session));
std::scoped_lock lk(m_session_list_lock);
m_session_list.erase(m_session_list.iterator_to(*session));
}

void AttachDriver(IDriver *drv) {
AMS_ASSERT(drv != nullptr);
AMS_ASSERT(!this->IsDriverAttached());
this->driver = drv;
m_driver = drv;
AMS_ASSERT(this->IsDriverAttached());
}

void DetachDriver() {
AMS_ASSERT(this->IsDriverAttached());
this->driver = nullptr;
m_driver = nullptr;
AMS_ASSERT(!this->IsDriverAttached());
}
public:
IDevice(bool exclusive_write) : list_node(), driver(nullptr), session_list(), session_list_lock(), is_exclusive_write(exclusive_write) {
this->session_list.clear();
IDevice(bool exclusive_write) : m_list_node(), m_driver(nullptr), m_session_list(), m_session_list_lock(), m_is_exclusive_write(exclusive_write) {
m_session_list.clear();
}
protected:
~IDevice() {
this->session_list.clear();
m_session_list.clear();
}
public:
void AddTo(List &list) {
Expand All @@ -94,45 +94,45 @@ namespace ams::ddsf {
}

bool IsLinkedToList() const {
return this->list_node.IsLinked();
return m_list_node.IsLinked();
}

IDriver &GetDriver() {
AMS_ASSERT(this->IsDriverAttached());
return *this->driver;
return *m_driver;
}

const IDriver &GetDriver() const {
AMS_ASSERT(this->IsDriverAttached());
return *this->driver;
return *m_driver;
}

bool IsDriverAttached() const {
return this->driver != nullptr;
return m_driver != nullptr;
}

template<typename F>
Result ForEachSession(F f, bool return_on_fail) {
return impl::ForEach(this->session_list_lock, this->session_list, f, return_on_fail);
return impl::ForEach(m_session_list_lock, m_session_list, f, return_on_fail);
}

template<typename F>
Result ForEachSession(F f, bool return_on_fail) const {
return impl::ForEach(this->session_list_lock, this->session_list, f, return_on_fail);
return impl::ForEach(m_session_list_lock, m_session_list, f, return_on_fail);
}

template<typename F>
int ForEachSession(F f) {
return impl::ForEach(this->session_list_lock, this->session_list, f);
return impl::ForEach(m_session_list_lock, m_session_list, f);
}

template<typename F>
int ForEachSession(F f) const {
return impl::ForEach(this->session_list_lock, this->session_list, f);
return impl::ForEach(m_session_list_lock, m_session_list, f);
}

bool HasAnyOpenSession() const {
return !this->session_list.empty();
return !m_session_list.empty();
}
};
static_assert(IDevice::ListTraits::IsValid());
Expand Down
Loading

0 comments on commit a595c23

Please sign in to comment.