mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-11-18 04:47:32 +01:00
applet: Use std::queue instead of std::vector for storage stack
This commit is contained in:
parent
19b2571aec
commit
4ee087fb3c
@ -567,12 +567,12 @@ public:
|
||||
|
||||
private:
|
||||
void AppletStorageProxyOutData(IStorage storage) {
|
||||
storage_stack.push_back(std::make_shared<IStorage>(storage));
|
||||
storage_stack.push(std::make_shared<IStorage>(storage));
|
||||
pop_out_data_event->Signal();
|
||||
}
|
||||
|
||||
void AppletStorageProxyOutInteractiveData(IStorage storage) {
|
||||
interactive_storage_stack.push_back(std::make_shared<IStorage>(storage));
|
||||
interactive_storage_stack.push(std::make_shared<IStorage>(storage));
|
||||
pop_interactive_out_data_event->Signal();
|
||||
}
|
||||
|
||||
@ -621,7 +621,7 @@ private:
|
||||
|
||||
void PushInData(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
storage_stack.push_back(rp.PopIpcInterface<IStorage>());
|
||||
storage_stack.push(rp.PopIpcInterface<IStorage>());
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
@ -631,17 +631,23 @@ private:
|
||||
|
||||
void PopOutData(Kernel::HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<IStorage>(std::move(storage_stack.back()));
|
||||
|
||||
storage_stack.pop_back();
|
||||
if (storage_stack.empty()) {
|
||||
rb.Push(ResultCode(-1));
|
||||
return;
|
||||
}
|
||||
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<IStorage>(std::move(storage_stack.front()));
|
||||
|
||||
storage_stack.pop();
|
||||
|
||||
LOG_DEBUG(Service_AM, "called");
|
||||
}
|
||||
|
||||
void PushInteractiveInData(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
interactive_storage_stack.push_back(rp.PopIpcInterface<IStorage>());
|
||||
interactive_storage_stack.push(rp.PopIpcInterface<IStorage>());
|
||||
|
||||
ASSERT(applet->IsInitialized());
|
||||
applet->ReceiveInteractiveData(interactive_storage_stack.back());
|
||||
@ -657,10 +663,16 @@ private:
|
||||
|
||||
void PopInteractiveOutData(Kernel::HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<IStorage>(std::move(interactive_storage_stack.back()));
|
||||
|
||||
interactive_storage_stack.pop_back();
|
||||
if (interactive_storage_stack.empty()) {
|
||||
rb.Push(ResultCode(-1));
|
||||
return;
|
||||
}
|
||||
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<IStorage>(std::move(interactive_storage_stack.front()));
|
||||
|
||||
interactive_storage_stack.pop();
|
||||
|
||||
LOG_DEBUG(Service_AM, "called");
|
||||
}
|
||||
@ -682,8 +694,8 @@ private:
|
||||
}
|
||||
|
||||
std::shared_ptr<Applets::Applet> applet;
|
||||
std::vector<std::shared_ptr<IStorage>> storage_stack;
|
||||
std::vector<std::shared_ptr<IStorage>> interactive_storage_stack;
|
||||
std::queue<std::shared_ptr<IStorage>> storage_stack;
|
||||
std::queue<std::shared_ptr<IStorage>> interactive_storage_stack;
|
||||
Kernel::SharedPtr<Kernel::Event> state_changed_event;
|
||||
Kernel::SharedPtr<Kernel::Event> pop_out_data_event;
|
||||
Kernel::SharedPtr<Kernel::Event> pop_interactive_out_data_event;
|
||||
|
@ -2,7 +2,10 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <cstring>
|
||||
#include "common/assert.h"
|
||||
#include "core/frontend/applets/software_keyboard.h"
|
||||
#include "core/hle/service/am/am.h"
|
||||
#include "core/hle/service/am/applets/applets.h"
|
||||
|
||||
namespace Service::AM::Applets {
|
||||
@ -11,8 +14,15 @@ Applet::Applet() = default;
|
||||
|
||||
Applet::~Applet() = default;
|
||||
|
||||
void Applet::Initialize(std::vector<std::shared_ptr<IStorage>> storage) {
|
||||
void Applet::Initialize(std::queue<std::shared_ptr<IStorage>> storage) {
|
||||
storage_stack = std::move(storage);
|
||||
|
||||
const auto common_data = storage_stack.front()->GetData();
|
||||
storage_stack.pop();
|
||||
|
||||
ASSERT(common_data.size() >= sizeof(CommonArguments));
|
||||
std::memcpy(&common_args, common_data.data(), sizeof(CommonArguments));
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include "common/swap.h"
|
||||
|
||||
union ResultCode;
|
||||
@ -29,7 +29,7 @@ public:
|
||||
Applet();
|
||||
virtual ~Applet();
|
||||
|
||||
virtual void Initialize(std::vector<std::shared_ptr<IStorage>> storage);
|
||||
virtual void Initialize(std::queue<std::shared_ptr<IStorage>> storage);
|
||||
|
||||
virtual bool TransactionComplete() const = 0;
|
||||
virtual ResultCode GetStatus() const = 0;
|
||||
@ -53,7 +53,8 @@ protected:
|
||||
};
|
||||
static_assert(sizeof(CommonArguments) == 0x20, "CommonArguments has incorrect size.");
|
||||
|
||||
std::vector<std::shared_ptr<IStorage>> storage_stack;
|
||||
CommonArguments common_args;
|
||||
std::queue<std::shared_ptr<IStorage>> storage_stack;
|
||||
bool initialized = false;
|
||||
};
|
||||
|
||||
|
@ -42,7 +42,7 @@ SoftwareKeyboard::SoftwareKeyboard() = default;
|
||||
|
||||
SoftwareKeyboard::~SoftwareKeyboard() = default;
|
||||
|
||||
void SoftwareKeyboard::Initialize(std::vector<std::shared_ptr<IStorage>> storage_) {
|
||||
void SoftwareKeyboard::Initialize(std::queue<std::shared_ptr<IStorage>> storage_) {
|
||||
complete = false;
|
||||
initial_text.clear();
|
||||
final_data.clear();
|
||||
@ -50,11 +50,14 @@ void SoftwareKeyboard::Initialize(std::vector<std::shared_ptr<IStorage>> storage
|
||||
Applet::Initialize(std::move(storage_));
|
||||
|
||||
ASSERT(storage_stack.size() >= 2);
|
||||
const auto& keyboard_config = storage_stack[1]->GetData();
|
||||
const auto& keyboard_config = storage_stack.front()->GetData();
|
||||
storage_stack.pop();
|
||||
|
||||
ASSERT(keyboard_config.size() >= sizeof(KeyboardConfig));
|
||||
std::memcpy(&config, keyboard_config.data(), sizeof(KeyboardConfig));
|
||||
|
||||
const auto& work_buffer = storage_stack[2]->GetData();
|
||||
const auto& work_buffer = storage_stack.front()->GetData();
|
||||
storage_stack.pop();
|
||||
|
||||
if (config.initial_string_size == 0)
|
||||
return;
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
SoftwareKeyboard();
|
||||
~SoftwareKeyboard() override;
|
||||
|
||||
void Initialize(std::vector<std::shared_ptr<IStorage>> storage) override;
|
||||
void Initialize(std::queue<std::shared_ptr<IStorage>> storage) override;
|
||||
|
||||
bool TransactionComplete() const override;
|
||||
ResultCode GetStatus() const override;
|
||||
|
Loading…
Reference in New Issue
Block a user