Port "kernel/event: Make data members private" from yuzu (#4077)

* kernel/event: Make data members private

Instead we can simply provide accessors to the required data instead of
giving external read/write access to the variables directly.

* fix compile error
This commit is contained in:
zhaowenlan1779 2018-08-25 01:43:29 +08:00 committed by Tobias
parent 75927ee462
commit 642f0bd62b
5 changed files with 19 additions and 11 deletions

View file

@ -260,7 +260,7 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeEvent::GetChildren() const {
list.push_back(std::make_unique<WaitTreeText>( list.push_back(std::make_unique<WaitTreeText>(
tr("reset type = %1") tr("reset type = %1")
.arg(GetResetTypeQString(static_cast<const Kernel::Event&>(object).reset_type)))); .arg(GetResetTypeQString(static_cast<const Kernel::Event&>(object).GetResetType()))));
return list; return list;
} }

View file

@ -25,16 +25,18 @@ public:
std::string GetName() const override { std::string GetName() const override {
return name; return name;
} }
void SetName(const std::string& name) {
this->name = name;
}
static const HandleType HANDLE_TYPE = HandleType::Event; static const HandleType HANDLE_TYPE = HandleType::Event;
HandleType GetHandleType() const override { HandleType GetHandleType() const override {
return HANDLE_TYPE; return HANDLE_TYPE;
} }
ResetType reset_type; ///< Current ResetType ResetType GetResetType() const {
return reset_type;
bool signaled; ///< Whether the event has already been signaled }
std::string name; ///< Name of event (optional)
bool ShouldWait(Thread* thread) const override; bool ShouldWait(Thread* thread) const override;
void Acquire(Thread* thread) override; void Acquire(Thread* thread) override;
@ -47,6 +49,11 @@ public:
private: private:
Event(); Event();
~Event() override; ~Event() override;
ResetType reset_type; ///< Current ResetType
bool signaled; ///< Whether the event has already been signaled
std::string name; ///< Name of event (optional)
}; };
} // namespace Kernel } // namespace Kernel

View file

@ -938,8 +938,9 @@ static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, u32
/// Create an event /// Create an event
static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) { static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) {
SharedPtr<Event> evt = Event::Create(static_cast<ResetType>(reset_type)); SharedPtr<Event> evt =
evt->name = Common::StringFromFormat("event-%08x", Core::CPU().GetReg(14)); Event::Create(static_cast<ResetType>(reset_type),
Common::StringFromFormat("event-%08x", Core::CPU().GetReg(14)));
CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(evt))); CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(evt)));
LOG_TRACE(Kernel_SVC, "called reset_type=0x{:08X} : created handle=0x{:08X}", reset_type, LOG_TRACE(Kernel_SVC, "called reset_type=0x{:08X} : created handle=0x{:08X}", reset_type,

View file

@ -37,7 +37,7 @@ void Module::Interface::ConnectAsync(Kernel::HLERequestContext& ctx) {
ac->connect_event = rp.PopObject<Kernel::Event>(); ac->connect_event = rp.PopObject<Kernel::Event>();
if (ac->connect_event) { if (ac->connect_event) {
ac->connect_event->name = "AC:connect_event"; ac->connect_event->SetName("AC:connect_event");
ac->connect_event->Signal(); ac->connect_event->Signal();
ac->ac_connected = true; ac->ac_connected = true;
} }
@ -67,7 +67,7 @@ void Module::Interface::CloseAsync(Kernel::HLERequestContext& ctx) {
} }
if (ac->close_event) { if (ac->close_event) {
ac->close_event->name = "AC:close_event"; ac->close_event->SetName("AC:close_event");
ac->close_event->Signal(); ac->close_event->Signal();
} }
@ -134,7 +134,7 @@ void Module::Interface::RegisterDisconnectEvent(Kernel::HLERequestContext& ctx)
ac->disconnect_event = rp.PopObject<Kernel::Event>(); ac->disconnect_event = rp.PopObject<Kernel::Event>();
if (ac->disconnect_event) { if (ac->disconnect_event) {
ac->disconnect_event->name = "AC:disconnect_event"; ac->disconnect_event->SetName("AC:disconnect_event");
} }
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);

View file

@ -354,7 +354,7 @@ void GSP_GPU::RegisterInterruptRelayQueue(Kernel::HLERequestContext& ctx) {
// TODO(mailwl): return right error code instead assert // TODO(mailwl): return right error code instead assert
ASSERT_MSG((interrupt_event != nullptr), "handle is not valid!"); ASSERT_MSG((interrupt_event != nullptr), "handle is not valid!");
interrupt_event->name = "GSP_GSP_GPU::interrupt_event"; interrupt_event->SetName("GSP_GSP_GPU::interrupt_event");
SessionData* session_data = GetSessionData(ctx.Session()); SessionData* session_data = GetSessionData(ctx.Session());
session_data->interrupt_event = std::move(interrupt_event); session_data->interrupt_event = std::move(interrupt_event);