From 8e103d0675c5d854d56183a90cce430fcefeba23 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 26 Jul 2018 09:45:18 -0400 Subject: [PATCH] kernel/timer: Make data members private where applicable Instead, we can just expose functions that return the queryable state instead of letting anything modify it. --- src/citra_qt/debugger/wait_tree.cpp | 6 +++--- src/core/hle/kernel/svc.cpp | 5 +++-- src/core/hle/kernel/timer.h | 22 +++++++++++++++++----- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/citra_qt/debugger/wait_tree.cpp b/src/citra_qt/debugger/wait_tree.cpp index 52493c58fd..d746a1564a 100644 --- a/src/citra_qt/debugger/wait_tree.cpp +++ b/src/citra_qt/debugger/wait_tree.cpp @@ -298,11 +298,11 @@ std::vector> WaitTreeTimer::GetChildren() const { const auto& timer = static_cast(object); list.push_back(std::make_unique( - tr("reset type = %1").arg(GetResetTypeQString(timer.reset_type)))); + tr("reset type = %1").arg(GetResetTypeQString(timer.GetResetType())))); list.push_back( - std::make_unique(tr("initial delay = %1").arg(timer.initial_delay))); + std::make_unique(tr("initial delay = %1").arg(timer.GetInitialDelay()))); list.push_back( - std::make_unique(tr("interval delay = %1").arg(timer.interval_delay))); + std::make_unique(tr("interval delay = %1").arg(timer.GetIntervalDelay()))); return list; } diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 6e30bb0a63..4c0b2864f3 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -981,8 +981,9 @@ static ResultCode ClearEvent(Handle handle) { /// Creates a timer static ResultCode CreateTimer(Handle* out_handle, u32 reset_type) { - SharedPtr timer = Timer::Create(static_cast(reset_type)); - timer->name = Common::StringFromFormat("timer-%08x", Core::CPU().GetReg(14)); + SharedPtr timer = + Timer::Create(static_cast(reset_type), + Common::StringFromFormat("timer-%08x", Core::CPU().GetReg(14))); CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(timer))); LOG_TRACE(Kernel_SVC, "called reset_type=0x{:08X} : created handle=0x{:08X}", reset_type, diff --git a/src/core/hle/kernel/timer.h b/src/core/hle/kernel/timer.h index 82d19cefcd..c63f0ed905 100644 --- a/src/core/hle/kernel/timer.h +++ b/src/core/hle/kernel/timer.h @@ -32,13 +32,17 @@ public: return HANDLE_TYPE; } - ResetType reset_type; ///< The ResetType of this timer + ResetType GetResetType() const { + return reset_type; + } - bool signaled; ///< Whether the timer has been signaled or not - std::string name; ///< Name of timer (optional) + u64 GetInitialDelay() const { + return initial_delay; + } - u64 initial_delay; ///< The delay until the timer fires for the first time - u64 interval_delay; ///< The delay until the timer fires after the first time + u64 GetIntervalDelay() const { + return interval_delay; + } bool ShouldWait(Thread* thread) const override; void Acquire(Thread* thread) override; @@ -67,6 +71,14 @@ private: Timer(); ~Timer() override; + ResetType reset_type; ///< The ResetType of this timer + + u64 initial_delay; ///< The delay until the timer fires for the first time + u64 interval_delay; ///< The delay until the timer fires after the first time + + bool signaled; ///< Whether the timer has been signaled or not + std::string name; ///< Name of timer (optional) + /// Handle used as userdata to reference this object when inserting into the CoreTiming queue. Handle callback_handle; };