summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-11-17 12:19:06 -0500
committerGravatar Zach Hilman2018-11-18 10:53:47 -0500
commit4ee087fb3ca2b1e064422b73195a8ff7698721d9 (patch)
tree5dcd31972d79e324e8eb75e19c3c00ff2a83b03c /src
parentapplet: Add operation completed callback (diff)
downloadyuzu-4ee087fb3ca2b1e064422b73195a8ff7698721d9.tar.gz
yuzu-4ee087fb3ca2b1e064422b73195a8ff7698721d9.tar.xz
yuzu-4ee087fb3ca2b1e064422b73195a8ff7698721d9.zip
applet: Use std::queue instead of std::vector for storage stack
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/am/am.cpp32
-rw-r--r--src/core/hle/service/am/applets/applets.cpp12
-rw-r--r--src/core/hle/service/am/applets/applets.h7
-rw-r--r--src/core/hle/service/am/applets/software_keyboard.cpp9
-rw-r--r--src/core/hle/service/am/applets/software_keyboard.h2
5 files changed, 44 insertions, 18 deletions
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index 5cbcb8d91..d92a46b00 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -567,12 +567,12 @@ public:
567 567
568private: 568private:
569 void AppletStorageProxyOutData(IStorage storage) { 569 void AppletStorageProxyOutData(IStorage storage) {
570 storage_stack.push_back(std::make_shared<IStorage>(storage)); 570 storage_stack.push(std::make_shared<IStorage>(storage));
571 pop_out_data_event->Signal(); 571 pop_out_data_event->Signal();
572 } 572 }
573 573
574 void AppletStorageProxyOutInteractiveData(IStorage storage) { 574 void AppletStorageProxyOutInteractiveData(IStorage storage) {
575 interactive_storage_stack.push_back(std::make_shared<IStorage>(storage)); 575 interactive_storage_stack.push(std::make_shared<IStorage>(storage));
576 pop_interactive_out_data_event->Signal(); 576 pop_interactive_out_data_event->Signal();
577 } 577 }
578 578
@@ -621,7 +621,7 @@ private:
621 621
622 void PushInData(Kernel::HLERequestContext& ctx) { 622 void PushInData(Kernel::HLERequestContext& ctx) {
623 IPC::RequestParser rp{ctx}; 623 IPC::RequestParser rp{ctx};
624 storage_stack.push_back(rp.PopIpcInterface<IStorage>()); 624 storage_stack.push(rp.PopIpcInterface<IStorage>());
625 625
626 IPC::ResponseBuilder rb{ctx, 2}; 626 IPC::ResponseBuilder rb{ctx, 2};
627 rb.Push(RESULT_SUCCESS); 627 rb.Push(RESULT_SUCCESS);
@@ -631,17 +631,23 @@ private:
631 631
632 void PopOutData(Kernel::HLERequestContext& ctx) { 632 void PopOutData(Kernel::HLERequestContext& ctx) {
633 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 633 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
634
635 if (storage_stack.empty()) {
636 rb.Push(ResultCode(-1));
637 return;
638 }
639
634 rb.Push(RESULT_SUCCESS); 640 rb.Push(RESULT_SUCCESS);
635 rb.PushIpcInterface<IStorage>(std::move(storage_stack.back())); 641 rb.PushIpcInterface<IStorage>(std::move(storage_stack.front()));
636 642
637 storage_stack.pop_back(); 643 storage_stack.pop();
638 644
639 LOG_DEBUG(Service_AM, "called"); 645 LOG_DEBUG(Service_AM, "called");
640 } 646 }
641 647
642 void PushInteractiveInData(Kernel::HLERequestContext& ctx) { 648 void PushInteractiveInData(Kernel::HLERequestContext& ctx) {
643 IPC::RequestParser rp{ctx}; 649 IPC::RequestParser rp{ctx};
644 interactive_storage_stack.push_back(rp.PopIpcInterface<IStorage>()); 650 interactive_storage_stack.push(rp.PopIpcInterface<IStorage>());
645 651
646 ASSERT(applet->IsInitialized()); 652 ASSERT(applet->IsInitialized());
647 applet->ReceiveInteractiveData(interactive_storage_stack.back()); 653 applet->ReceiveInteractiveData(interactive_storage_stack.back());
@@ -657,10 +663,16 @@ private:
657 663
658 void PopInteractiveOutData(Kernel::HLERequestContext& ctx) { 664 void PopInteractiveOutData(Kernel::HLERequestContext& ctx) {
659 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 665 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
666
667 if (interactive_storage_stack.empty()) {
668 rb.Push(ResultCode(-1));
669 return;
670 }
671
660 rb.Push(RESULT_SUCCESS); 672 rb.Push(RESULT_SUCCESS);
661 rb.PushIpcInterface<IStorage>(std::move(interactive_storage_stack.back())); 673 rb.PushIpcInterface<IStorage>(std::move(interactive_storage_stack.front()));
662 674
663 interactive_storage_stack.pop_back(); 675 interactive_storage_stack.pop();
664 676
665 LOG_DEBUG(Service_AM, "called"); 677 LOG_DEBUG(Service_AM, "called");
666 } 678 }
@@ -682,8 +694,8 @@ private:
682 } 694 }
683 695
684 std::shared_ptr<Applets::Applet> applet; 696 std::shared_ptr<Applets::Applet> applet;
685 std::vector<std::shared_ptr<IStorage>> storage_stack; 697 std::queue<std::shared_ptr<IStorage>> storage_stack;
686 std::vector<std::shared_ptr<IStorage>> interactive_storage_stack; 698 std::queue<std::shared_ptr<IStorage>> interactive_storage_stack;
687 Kernel::SharedPtr<Kernel::Event> state_changed_event; 699 Kernel::SharedPtr<Kernel::Event> state_changed_event;
688 Kernel::SharedPtr<Kernel::Event> pop_out_data_event; 700 Kernel::SharedPtr<Kernel::Event> pop_out_data_event;
689 Kernel::SharedPtr<Kernel::Event> pop_interactive_out_data_event; 701 Kernel::SharedPtr<Kernel::Event> pop_interactive_out_data_event;
diff --git a/src/core/hle/service/am/applets/applets.cpp b/src/core/hle/service/am/applets/applets.cpp
index 03b9d83e7..be950d320 100644
--- a/src/core/hle/service/am/applets/applets.cpp
+++ b/src/core/hle/service/am/applets/applets.cpp
@@ -2,7 +2,10 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <cstring>
6#include "common/assert.h"
5#include "core/frontend/applets/software_keyboard.h" 7#include "core/frontend/applets/software_keyboard.h"
8#include "core/hle/service/am/am.h"
6#include "core/hle/service/am/applets/applets.h" 9#include "core/hle/service/am/applets/applets.h"
7 10
8namespace Service::AM::Applets { 11namespace Service::AM::Applets {
@@ -11,8 +14,15 @@ Applet::Applet() = default;
11 14
12Applet::~Applet() = default; 15Applet::~Applet() = default;
13 16
14void Applet::Initialize(std::vector<std::shared_ptr<IStorage>> storage) { 17void Applet::Initialize(std::queue<std::shared_ptr<IStorage>> storage) {
15 storage_stack = std::move(storage); 18 storage_stack = std::move(storage);
19
20 const auto common_data = storage_stack.front()->GetData();
21 storage_stack.pop();
22
23 ASSERT(common_data.size() >= sizeof(CommonArguments));
24 std::memcpy(&common_args, common_data.data(), sizeof(CommonArguments));
25
16 initialized = true; 26 initialized = true;
17} 27}
18 28
diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h
index 1ffa09420..a6a9bf77b 100644
--- a/src/core/hle/service/am/applets/applets.h
+++ b/src/core/hle/service/am/applets/applets.h
@@ -6,7 +6,7 @@
6 6
7#include <functional> 7#include <functional>
8#include <memory> 8#include <memory>
9#include <vector> 9#include <queue>
10#include "common/swap.h" 10#include "common/swap.h"
11 11
12union ResultCode; 12union ResultCode;
@@ -29,7 +29,7 @@ public:
29 Applet(); 29 Applet();
30 virtual ~Applet(); 30 virtual ~Applet();
31 31
32 virtual void Initialize(std::vector<std::shared_ptr<IStorage>> storage); 32 virtual void Initialize(std::queue<std::shared_ptr<IStorage>> storage);
33 33
34 virtual bool TransactionComplete() const = 0; 34 virtual bool TransactionComplete() const = 0;
35 virtual ResultCode GetStatus() const = 0; 35 virtual ResultCode GetStatus() const = 0;
@@ -53,7 +53,8 @@ protected:
53 }; 53 };
54 static_assert(sizeof(CommonArguments) == 0x20, "CommonArguments has incorrect size."); 54 static_assert(sizeof(CommonArguments) == 0x20, "CommonArguments has incorrect size.");
55 55
56 std::vector<std::shared_ptr<IStorage>> storage_stack; 56 CommonArguments common_args;
57 std::queue<std::shared_ptr<IStorage>> storage_stack;
57 bool initialized = false; 58 bool initialized = false;
58}; 59};
59 60
diff --git a/src/core/hle/service/am/applets/software_keyboard.cpp b/src/core/hle/service/am/applets/software_keyboard.cpp
index 039bfcc0f..a5ffa1f31 100644
--- a/src/core/hle/service/am/applets/software_keyboard.cpp
+++ b/src/core/hle/service/am/applets/software_keyboard.cpp
@@ -42,7 +42,7 @@ SoftwareKeyboard::SoftwareKeyboard() = default;
42 42
43SoftwareKeyboard::~SoftwareKeyboard() = default; 43SoftwareKeyboard::~SoftwareKeyboard() = default;
44 44
45void SoftwareKeyboard::Initialize(std::vector<std::shared_ptr<IStorage>> storage_) { 45void SoftwareKeyboard::Initialize(std::queue<std::shared_ptr<IStorage>> storage_) {
46 complete = false; 46 complete = false;
47 initial_text.clear(); 47 initial_text.clear();
48 final_data.clear(); 48 final_data.clear();
@@ -50,11 +50,14 @@ void SoftwareKeyboard::Initialize(std::vector<std::shared_ptr<IStorage>> storage
50 Applet::Initialize(std::move(storage_)); 50 Applet::Initialize(std::move(storage_));
51 51
52 ASSERT(storage_stack.size() >= 2); 52 ASSERT(storage_stack.size() >= 2);
53 const auto& keyboard_config = storage_stack[1]->GetData(); 53 const auto& keyboard_config = storage_stack.front()->GetData();
54 storage_stack.pop();
55
54 ASSERT(keyboard_config.size() >= sizeof(KeyboardConfig)); 56 ASSERT(keyboard_config.size() >= sizeof(KeyboardConfig));
55 std::memcpy(&config, keyboard_config.data(), sizeof(KeyboardConfig)); 57 std::memcpy(&config, keyboard_config.data(), sizeof(KeyboardConfig));
56 58
57 const auto& work_buffer = storage_stack[2]->GetData(); 59 const auto& work_buffer = storage_stack.front()->GetData();
60 storage_stack.pop();
58 61
59 if (config.initial_string_size == 0) 62 if (config.initial_string_size == 0)
60 return; 63 return;
diff --git a/src/core/hle/service/am/applets/software_keyboard.h b/src/core/hle/service/am/applets/software_keyboard.h
index 9629f6408..9544d6b1b 100644
--- a/src/core/hle/service/am/applets/software_keyboard.h
+++ b/src/core/hle/service/am/applets/software_keyboard.h
@@ -49,7 +49,7 @@ public:
49 SoftwareKeyboard(); 49 SoftwareKeyboard();
50 ~SoftwareKeyboard() override; 50 ~SoftwareKeyboard() override;
51 51
52 void Initialize(std::vector<std::shared_ptr<IStorage>> storage) override; 52 void Initialize(std::queue<std::shared_ptr<IStorage>> storage) override;
53 53
54 bool TransactionComplete() const override; 54 bool TransactionComplete() const override;
55 ResultCode GetStatus() const override; 55 ResultCode GetStatus() const override;