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