citra-emu
/
citra
Archived
1
0
Fork 0

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>(
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;
}

View File

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

View File

@ -938,8 +938,9 @@ static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, u32
/// Create an event
static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) {
SharedPtr<Event> evt = Event::Create(static_cast<ResetType>(reset_type));
evt->name = Common::StringFromFormat("event-%08x", Core::CPU().GetReg(14));
SharedPtr<Event> evt =
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)));
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>();
if (ac->connect_event) {
ac->connect_event->name = "AC:connect_event";
ac->connect_event->SetName("AC:connect_event");
ac->connect_event->Signal();
ac->ac_connected = true;
}
@ -67,7 +67,7 @@ void Module::Interface::CloseAsync(Kernel::HLERequestContext& ctx) {
}
if (ac->close_event) {
ac->close_event->name = "AC:close_event";
ac->close_event->SetName("AC:close_event");
ac->close_event->Signal();
}
@ -134,7 +134,7 @@ void Module::Interface::RegisterDisconnectEvent(Kernel::HLERequestContext& ctx)
ac->disconnect_event = rp.PopObject<Kernel::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);

View File

@ -354,7 +354,7 @@ void GSP_GPU::RegisterInterruptRelayQueue(Kernel::HLERequestContext& ctx) {
// TODO(mailwl): return right error code instead assert
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());
session_data->interrupt_event = std::move(interrupt_event);