diff options
| author | 2018-11-20 12:02:16 -0500 | |
|---|---|---|
| committer | 2018-11-20 12:36:33 -0500 | |
| commit | 73b77489846989c8bccf9615ae75658d1ebc6f1d (patch) | |
| tree | 83a7ed08070dbbc8be1b8bec9570e5c200bd498c | |
| parent | am/applets: Replace includes with forward declarations where applicable (diff) | |
| download | yuzu-73b77489846989c8bccf9615ae75658d1ebc6f1d.tar.gz yuzu-73b77489846989c8bccf9615ae75658d1ebc6f1d.tar.xz yuzu-73b77489846989c8bccf9615ae75658d1ebc6f1d.zip | |
am/applets: Make the applet data broker part of the applet itself.
The accessor should be doing just that, accessing, rather than retaining
the lifetime of the data broker as well.
| -rw-r--r-- | src/core/hle/service/am/am.cpp | 20 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/applets.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/applets.h | 15 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/software_keyboard.cpp | 24 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/software_keyboard.h | 2 |
5 files changed, 36 insertions, 31 deletions
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index fd14af1e7..9696db42b 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -532,8 +532,7 @@ void ICommonStateGetter::GetPerformanceMode(Kernel::HLERequestContext& ctx) { | |||
| 532 | class ILibraryAppletAccessor final : public ServiceFramework<ILibraryAppletAccessor> { | 532 | class ILibraryAppletAccessor final : public ServiceFramework<ILibraryAppletAccessor> { |
| 533 | public: | 533 | public: |
| 534 | explicit ILibraryAppletAccessor(std::shared_ptr<Applets::Applet> applet) | 534 | explicit ILibraryAppletAccessor(std::shared_ptr<Applets::Applet> applet) |
| 535 | : ServiceFramework("ILibraryAppletAccessor"), applet(std::move(applet)), | 535 | : ServiceFramework("ILibraryAppletAccessor"), applet(std::move(applet)) { |
| 536 | broker(std::make_shared<Applets::AppletDataBroker>()) { | ||
| 537 | // clang-format off | 536 | // clang-format off |
| 538 | static const FunctionInfo functions[] = { | 537 | static const FunctionInfo functions[] = { |
| 539 | {0, &ILibraryAppletAccessor::GetAppletStateChangedEvent, "GetAppletStateChangedEvent"}, | 538 | {0, &ILibraryAppletAccessor::GetAppletStateChangedEvent, "GetAppletStateChangedEvent"}, |
| @@ -562,7 +561,7 @@ public: | |||
| 562 | 561 | ||
| 563 | private: | 562 | private: |
| 564 | void GetAppletStateChangedEvent(Kernel::HLERequestContext& ctx) { | 563 | void GetAppletStateChangedEvent(Kernel::HLERequestContext& ctx) { |
| 565 | const auto event = broker->GetStateChangedEvent(); | 564 | const auto event = applet->GetBroker().GetStateChangedEvent(); |
| 566 | event->Signal(); | 565 | event->Signal(); |
| 567 | 566 | ||
| 568 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 567 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| @@ -590,7 +589,7 @@ private: | |||
| 590 | void Start(Kernel::HLERequestContext& ctx) { | 589 | void Start(Kernel::HLERequestContext& ctx) { |
| 591 | ASSERT(applet != nullptr); | 590 | ASSERT(applet != nullptr); |
| 592 | 591 | ||
| 593 | applet->Initialize(broker); | 592 | applet->Initialize(); |
| 594 | applet->Execute(); | 593 | applet->Execute(); |
| 595 | 594 | ||
| 596 | IPC::ResponseBuilder rb{ctx, 2}; | 595 | IPC::ResponseBuilder rb{ctx, 2}; |
| @@ -601,7 +600,7 @@ private: | |||
| 601 | 600 | ||
| 602 | void PushInData(Kernel::HLERequestContext& ctx) { | 601 | void PushInData(Kernel::HLERequestContext& ctx) { |
| 603 | IPC::RequestParser rp{ctx}; | 602 | IPC::RequestParser rp{ctx}; |
| 604 | broker->PushNormalDataFromGame(*rp.PopIpcInterface<IStorage>()); | 603 | applet->GetBroker().PushNormalDataFromGame(*rp.PopIpcInterface<IStorage>()); |
| 605 | 604 | ||
| 606 | IPC::ResponseBuilder rb{ctx, 2}; | 605 | IPC::ResponseBuilder rb{ctx, 2}; |
| 607 | rb.Push(RESULT_SUCCESS); | 606 | rb.Push(RESULT_SUCCESS); |
| @@ -612,7 +611,7 @@ private: | |||
| 612 | void PopOutData(Kernel::HLERequestContext& ctx) { | 611 | void PopOutData(Kernel::HLERequestContext& ctx) { |
| 613 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 612 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 614 | 613 | ||
| 615 | const auto storage = broker->PopNormalDataToGame(); | 614 | const auto storage = applet->GetBroker().PopNormalDataToGame(); |
| 616 | if (storage == nullptr) { | 615 | if (storage == nullptr) { |
| 617 | rb.Push(ERR_NO_DATA_IN_CHANNEL); | 616 | rb.Push(ERR_NO_DATA_IN_CHANNEL); |
| 618 | return; | 617 | return; |
| @@ -626,7 +625,7 @@ private: | |||
| 626 | 625 | ||
| 627 | void PushInteractiveInData(Kernel::HLERequestContext& ctx) { | 626 | void PushInteractiveInData(Kernel::HLERequestContext& ctx) { |
| 628 | IPC::RequestParser rp{ctx}; | 627 | IPC::RequestParser rp{ctx}; |
| 629 | broker->PushInteractiveDataFromGame(*rp.PopIpcInterface<IStorage>()); | 628 | applet->GetBroker().PushInteractiveDataFromGame(*rp.PopIpcInterface<IStorage>()); |
| 630 | 629 | ||
| 631 | ASSERT(applet->IsInitialized()); | 630 | ASSERT(applet->IsInitialized()); |
| 632 | applet->ExecuteInteractive(); | 631 | applet->ExecuteInteractive(); |
| @@ -641,7 +640,7 @@ private: | |||
| 641 | void PopInteractiveOutData(Kernel::HLERequestContext& ctx) { | 640 | void PopInteractiveOutData(Kernel::HLERequestContext& ctx) { |
| 642 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 641 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 643 | 642 | ||
| 644 | const auto storage = broker->PopInteractiveDataToGame(); | 643 | const auto storage = applet->GetBroker().PopInteractiveDataToGame(); |
| 645 | if (storage == nullptr) { | 644 | if (storage == nullptr) { |
| 646 | rb.Push(ERR_NO_DATA_IN_CHANNEL); | 645 | rb.Push(ERR_NO_DATA_IN_CHANNEL); |
| 647 | return; | 646 | return; |
| @@ -656,7 +655,7 @@ private: | |||
| 656 | void GetPopOutDataEvent(Kernel::HLERequestContext& ctx) { | 655 | void GetPopOutDataEvent(Kernel::HLERequestContext& ctx) { |
| 657 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 656 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 658 | rb.Push(RESULT_SUCCESS); | 657 | rb.Push(RESULT_SUCCESS); |
| 659 | rb.PushCopyObjects(broker->GetNormalDataEvent()); | 658 | rb.PushCopyObjects(applet->GetBroker().GetNormalDataEvent()); |
| 660 | 659 | ||
| 661 | LOG_DEBUG(Service_AM, "called"); | 660 | LOG_DEBUG(Service_AM, "called"); |
| 662 | } | 661 | } |
| @@ -664,13 +663,12 @@ private: | |||
| 664 | void GetPopInteractiveOutDataEvent(Kernel::HLERequestContext& ctx) { | 663 | void GetPopInteractiveOutDataEvent(Kernel::HLERequestContext& ctx) { |
| 665 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 664 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 666 | rb.Push(RESULT_SUCCESS); | 665 | rb.Push(RESULT_SUCCESS); |
| 667 | rb.PushCopyObjects(broker->GetInteractiveDataEvent()); | 666 | rb.PushCopyObjects(applet->GetBroker().GetInteractiveDataEvent()); |
| 668 | 667 | ||
| 669 | LOG_DEBUG(Service_AM, "called"); | 668 | LOG_DEBUG(Service_AM, "called"); |
| 670 | } | 669 | } |
| 671 | 670 | ||
| 672 | std::shared_ptr<Applets::Applet> applet; | 671 | std::shared_ptr<Applets::Applet> applet; |
| 673 | std::shared_ptr<Applets::AppletDataBroker> broker; | ||
| 674 | }; | 672 | }; |
| 675 | 673 | ||
| 676 | void IStorage::Open(Kernel::HLERequestContext& ctx) { | 674 | void IStorage::Open(Kernel::HLERequestContext& ctx) { |
diff --git a/src/core/hle/service/am/applets/applets.cpp b/src/core/hle/service/am/applets/applets.cpp index 8adb81823..becbadd06 100644 --- a/src/core/hle/service/am/applets/applets.cpp +++ b/src/core/hle/service/am/applets/applets.cpp | |||
| @@ -98,10 +98,8 @@ Applet::Applet() = default; | |||
| 98 | 98 | ||
| 99 | Applet::~Applet() = default; | 99 | Applet::~Applet() = default; |
| 100 | 100 | ||
| 101 | void Applet::Initialize(std::shared_ptr<AppletDataBroker> broker_) { | 101 | void Applet::Initialize() { |
| 102 | broker = std::move(broker_); | 102 | const auto common = broker.PopNormalDataToApplet(); |
| 103 | |||
| 104 | const auto common = broker->PopNormalDataToApplet(); | ||
| 105 | ASSERT(common != nullptr); | 103 | ASSERT(common != nullptr); |
| 106 | 104 | ||
| 107 | const auto common_data = common->GetData(); | 105 | const auto common_data = common->GetData(); |
diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h index 9c1f068d4..f65ea119c 100644 --- a/src/core/hle/service/am/applets/applets.h +++ b/src/core/hle/service/am/applets/applets.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <queue> | 8 | #include <queue> |
| 9 | #include "common/swap.h" | 9 | #include "common/swap.h" |
| 10 | #include "core/hle/kernel/kernel.h" | ||
| 10 | 11 | ||
| 11 | union ResultCode; | 12 | union ResultCode; |
| 12 | 13 | ||
| @@ -72,7 +73,7 @@ public: | |||
| 72 | Applet(); | 73 | Applet(); |
| 73 | virtual ~Applet(); | 74 | virtual ~Applet(); |
| 74 | 75 | ||
| 75 | virtual void Initialize(std::shared_ptr<AppletDataBroker> broker); | 76 | virtual void Initialize(); |
| 76 | 77 | ||
| 77 | virtual bool TransactionComplete() const = 0; | 78 | virtual bool TransactionComplete() const = 0; |
| 78 | virtual ResultCode GetStatus() const = 0; | 79 | virtual ResultCode GetStatus() const = 0; |
| @@ -83,6 +84,14 @@ public: | |||
| 83 | return initialized; | 84 | return initialized; |
| 84 | } | 85 | } |
| 85 | 86 | ||
| 87 | AppletDataBroker& GetBroker() { | ||
| 88 | return broker; | ||
| 89 | } | ||
| 90 | |||
| 91 | const AppletDataBroker& GetBroker() const { | ||
| 92 | return broker; | ||
| 93 | } | ||
| 94 | |||
| 86 | protected: | 95 | protected: |
| 87 | struct CommonArguments { | 96 | struct CommonArguments { |
| 88 | u32_le arguments_version; | 97 | u32_le arguments_version; |
| @@ -94,8 +103,8 @@ protected: | |||
| 94 | }; | 103 | }; |
| 95 | static_assert(sizeof(CommonArguments) == 0x20, "CommonArguments has incorrect size."); | 104 | static_assert(sizeof(CommonArguments) == 0x20, "CommonArguments has incorrect size."); |
| 96 | 105 | ||
| 97 | CommonArguments common_args; | 106 | CommonArguments common_args{}; |
| 98 | std::shared_ptr<AppletDataBroker> broker; | 107 | AppletDataBroker broker; |
| 99 | bool initialized = false; | 108 | bool initialized = false; |
| 100 | }; | 109 | }; |
| 101 | 110 | ||
diff --git a/src/core/hle/service/am/applets/software_keyboard.cpp b/src/core/hle/service/am/applets/software_keyboard.cpp index c4b76a515..981bdec51 100644 --- a/src/core/hle/service/am/applets/software_keyboard.cpp +++ b/src/core/hle/service/am/applets/software_keyboard.cpp | |||
| @@ -42,21 +42,21 @@ SoftwareKeyboard::SoftwareKeyboard() = default; | |||
| 42 | 42 | ||
| 43 | SoftwareKeyboard::~SoftwareKeyboard() = default; | 43 | SoftwareKeyboard::~SoftwareKeyboard() = default; |
| 44 | 44 | ||
| 45 | void SoftwareKeyboard::Initialize(std::shared_ptr<AppletDataBroker> broker_) { | 45 | void SoftwareKeyboard::Initialize() { |
| 46 | complete = false; | 46 | complete = false; |
| 47 | initial_text.clear(); | 47 | initial_text.clear(); |
| 48 | final_data.clear(); | 48 | final_data.clear(); |
| 49 | 49 | ||
| 50 | Applet::Initialize(std::move(broker_)); | 50 | Applet::Initialize(); |
| 51 | 51 | ||
| 52 | const auto keyboard_config_storage = broker->PopNormalDataToApplet(); | 52 | const auto keyboard_config_storage = broker.PopNormalDataToApplet(); |
| 53 | ASSERT(keyboard_config_storage != nullptr); | 53 | ASSERT(keyboard_config_storage != nullptr); |
| 54 | const auto& keyboard_config = keyboard_config_storage->GetData(); | 54 | const auto& keyboard_config = keyboard_config_storage->GetData(); |
| 55 | 55 | ||
| 56 | ASSERT(keyboard_config.size() >= sizeof(KeyboardConfig)); | 56 | ASSERT(keyboard_config.size() >= sizeof(KeyboardConfig)); |
| 57 | std::memcpy(&config, keyboard_config.data(), sizeof(KeyboardConfig)); | 57 | std::memcpy(&config, keyboard_config.data(), sizeof(KeyboardConfig)); |
| 58 | 58 | ||
| 59 | const auto work_buffer_storage = broker->PopNormalDataToApplet(); | 59 | const auto work_buffer_storage = broker.PopNormalDataToApplet(); |
| 60 | ASSERT(work_buffer_storage != nullptr); | 60 | ASSERT(work_buffer_storage != nullptr); |
| 61 | const auto& work_buffer = work_buffer_storage->GetData(); | 61 | const auto& work_buffer = work_buffer_storage->GetData(); |
| 62 | 62 | ||
| @@ -81,7 +81,7 @@ void SoftwareKeyboard::ExecuteInteractive() { | |||
| 81 | if (complete) | 81 | if (complete) |
| 82 | return; | 82 | return; |
| 83 | 83 | ||
| 84 | const auto storage = broker->PopInteractiveDataToApplet(); | 84 | const auto storage = broker.PopInteractiveDataToApplet(); |
| 85 | ASSERT(storage != nullptr); | 85 | ASSERT(storage != nullptr); |
| 86 | const auto data = storage->GetData(); | 86 | const auto data = storage->GetData(); |
| 87 | const auto status = static_cast<bool>(data[0]); | 87 | const auto status = static_cast<bool>(data[0]); |
| @@ -95,13 +95,13 @@ void SoftwareKeyboard::ExecuteInteractive() { | |||
| 95 | std::memcpy(string.data(), data.data() + 4, string.size() * 2); | 95 | std::memcpy(string.data(), data.data() + 4, string.size() * 2); |
| 96 | frontend.SendTextCheckDialog( | 96 | frontend.SendTextCheckDialog( |
| 97 | Common::UTF16StringFromFixedZeroTerminatedBuffer(string.data(), string.size()), | 97 | Common::UTF16StringFromFixedZeroTerminatedBuffer(string.data(), string.size()), |
| 98 | [this] { broker->SignalStateChanged(); }); | 98 | [this] { broker.SignalStateChanged(); }); |
| 99 | } | 99 | } |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | void SoftwareKeyboard::Execute() { | 102 | void SoftwareKeyboard::Execute() { |
| 103 | if (complete) { | 103 | if (complete) { |
| 104 | broker->PushNormalDataFromApplet(IStorage{final_data}); | 104 | broker.PushNormalDataFromApplet(IStorage{final_data}); |
| 105 | return; | 105 | return; |
| 106 | } | 106 | } |
| 107 | 107 | ||
| @@ -145,17 +145,17 @@ void SoftwareKeyboard::WriteText(std::optional<std::u16string> text) { | |||
| 145 | final_data = output_main; | 145 | final_data = output_main; |
| 146 | 146 | ||
| 147 | if (complete) { | 147 | if (complete) { |
| 148 | broker->PushNormalDataFromApplet(IStorage{output_main}); | 148 | broker.PushNormalDataFromApplet(IStorage{output_main}); |
| 149 | } else { | 149 | } else { |
| 150 | broker->PushInteractiveDataFromApplet(IStorage{output_sub}); | 150 | broker.PushInteractiveDataFromApplet(IStorage{output_sub}); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | broker->SignalStateChanged(); | 153 | broker.SignalStateChanged(); |
| 154 | } else { | 154 | } else { |
| 155 | output_main[0] = 1; | 155 | output_main[0] = 1; |
| 156 | complete = true; | 156 | complete = true; |
| 157 | broker->PushNormalDataFromApplet(IStorage{output_main}); | 157 | broker.PushNormalDataFromApplet(IStorage{output_main}); |
| 158 | broker->SignalStateChanged(); | 158 | broker.SignalStateChanged(); |
| 159 | } | 159 | } |
| 160 | } | 160 | } |
| 161 | } // namespace Service::AM::Applets | 161 | } // namespace Service::AM::Applets |
diff --git a/src/core/hle/service/am/applets/software_keyboard.h b/src/core/hle/service/am/applets/software_keyboard.h index 38cabcaec..efd5753a1 100644 --- a/src/core/hle/service/am/applets/software_keyboard.h +++ b/src/core/hle/service/am/applets/software_keyboard.h | |||
| @@ -55,7 +55,7 @@ public: | |||
| 55 | SoftwareKeyboard(); | 55 | SoftwareKeyboard(); |
| 56 | ~SoftwareKeyboard() override; | 56 | ~SoftwareKeyboard() override; |
| 57 | 57 | ||
| 58 | void Initialize(std::shared_ptr<AppletDataBroker> broker) override; | 58 | void Initialize() override; |
| 59 | 59 | ||
| 60 | bool TransactionComplete() const override; | 60 | bool TransactionComplete() const override; |
| 61 | ResultCode GetStatus() const override; | 61 | ResultCode GetStatus() const override; |