mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-08-25 16:37:18 +02:00
hle: services: Use std::shared_ptr instead of copy by value.
This commit is contained in:
parent
90bda66028
commit
7b07e521ca
@ -847,7 +847,7 @@ private:
|
|||||||
LOG_DEBUG(Service_AM, "called");
|
LOG_DEBUG(Service_AM, "called");
|
||||||
|
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
applet->GetBroker().PushNormalDataFromGame(*rp.PopIpcInterface<IStorage>());
|
applet->GetBroker().PushNormalDataFromGame(rp.PopIpcInterface<IStorage>());
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
@ -867,14 +867,14 @@ private:
|
|||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.PushIpcInterface<IStorage>(std::move(*storage));
|
rb.PushIpcInterface<IStorage>(std::move(storage));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PushInteractiveInData(Kernel::HLERequestContext& ctx) {
|
void PushInteractiveInData(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_AM, "called");
|
LOG_DEBUG(Service_AM, "called");
|
||||||
|
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
applet->GetBroker().PushInteractiveDataFromGame(*rp.PopIpcInterface<IStorage>());
|
applet->GetBroker().PushInteractiveDataFromGame(rp.PopIpcInterface<IStorage>());
|
||||||
|
|
||||||
ASSERT(applet->IsInitialized());
|
ASSERT(applet->IsInitialized());
|
||||||
applet->ExecuteInteractive();
|
applet->ExecuteInteractive();
|
||||||
@ -898,7 +898,7 @@ private:
|
|||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.PushIpcInterface<IStorage>(std::move(*storage));
|
rb.PushIpcInterface<IStorage>(std::move(storage));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetPopOutDataEvent(Kernel::HLERequestContext& ctx) {
|
void GetPopOutDataEvent(Kernel::HLERequestContext& ctx) {
|
||||||
|
@ -50,7 +50,7 @@ AppletDataBroker::RawChannelData AppletDataBroker::PeekDataToAppletForDebug() co
|
|||||||
return {std::move(out_normal), std::move(out_interactive)};
|
return {std::move(out_normal), std::move(out_interactive)};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<IStorage> AppletDataBroker::PopNormalDataToGame() {
|
std::shared_ptr<IStorage> AppletDataBroker::PopNormalDataToGame() {
|
||||||
if (out_channel.empty())
|
if (out_channel.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ std::unique_ptr<IStorage> AppletDataBroker::PopNormalDataToGame() {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<IStorage> AppletDataBroker::PopNormalDataToApplet() {
|
std::shared_ptr<IStorage> AppletDataBroker::PopNormalDataToApplet() {
|
||||||
if (in_channel.empty())
|
if (in_channel.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ std::unique_ptr<IStorage> AppletDataBroker::PopNormalDataToApplet() {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<IStorage> AppletDataBroker::PopInteractiveDataToGame() {
|
std::shared_ptr<IStorage> AppletDataBroker::PopInteractiveDataToGame() {
|
||||||
if (out_interactive_channel.empty())
|
if (out_interactive_channel.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ std::unique_ptr<IStorage> AppletDataBroker::PopInteractiveDataToGame() {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<IStorage> AppletDataBroker::PopInteractiveDataToApplet() {
|
std::shared_ptr<IStorage> AppletDataBroker::PopInteractiveDataToApplet() {
|
||||||
if (in_interactive_channel.empty())
|
if (in_interactive_channel.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@ -88,21 +88,21 @@ std::unique_ptr<IStorage> AppletDataBroker::PopInteractiveDataToApplet() {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppletDataBroker::PushNormalDataFromGame(IStorage storage) {
|
void AppletDataBroker::PushNormalDataFromGame(std::shared_ptr<IStorage>&& storage) {
|
||||||
in_channel.push_back(std::make_unique<IStorage>(storage));
|
in_channel.emplace_back(std::move(storage));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppletDataBroker::PushNormalDataFromApplet(IStorage storage) {
|
void AppletDataBroker::PushNormalDataFromApplet(std::shared_ptr<IStorage>&& storage) {
|
||||||
out_channel.push_back(std::make_unique<IStorage>(storage));
|
out_channel.emplace_back(std::move(storage));
|
||||||
pop_out_data_event.writable->Signal();
|
pop_out_data_event.writable->Signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppletDataBroker::PushInteractiveDataFromGame(IStorage storage) {
|
void AppletDataBroker::PushInteractiveDataFromGame(std::shared_ptr<IStorage>&& storage) {
|
||||||
in_interactive_channel.push_back(std::make_unique<IStorage>(storage));
|
in_interactive_channel.emplace_back(std::move(storage));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppletDataBroker::PushInteractiveDataFromApplet(IStorage storage) {
|
void AppletDataBroker::PushInteractiveDataFromApplet(std::shared_ptr<IStorage>&& storage) {
|
||||||
out_interactive_channel.push_back(std::make_unique<IStorage>(storage));
|
out_interactive_channel.emplace_back(std::move(storage));
|
||||||
pop_interactive_out_data_event.writable->Signal();
|
pop_interactive_out_data_event.writable->Signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,17 +72,17 @@ public:
|
|||||||
// Retrieves but does not pop the data sent to applet.
|
// Retrieves but does not pop the data sent to applet.
|
||||||
RawChannelData PeekDataToAppletForDebug() const;
|
RawChannelData PeekDataToAppletForDebug() const;
|
||||||
|
|
||||||
std::unique_ptr<IStorage> PopNormalDataToGame();
|
std::shared_ptr<IStorage> PopNormalDataToGame();
|
||||||
std::unique_ptr<IStorage> PopNormalDataToApplet();
|
std::shared_ptr<IStorage> PopNormalDataToApplet();
|
||||||
|
|
||||||
std::unique_ptr<IStorage> PopInteractiveDataToGame();
|
std::shared_ptr<IStorage> PopInteractiveDataToGame();
|
||||||
std::unique_ptr<IStorage> PopInteractiveDataToApplet();
|
std::shared_ptr<IStorage> PopInteractiveDataToApplet();
|
||||||
|
|
||||||
void PushNormalDataFromGame(IStorage storage);
|
void PushNormalDataFromGame(std::shared_ptr<IStorage>&& storage);
|
||||||
void PushNormalDataFromApplet(IStorage storage);
|
void PushNormalDataFromApplet(std::shared_ptr<IStorage>&& storage);
|
||||||
|
|
||||||
void PushInteractiveDataFromGame(IStorage storage);
|
void PushInteractiveDataFromGame(std::shared_ptr<IStorage>&& storage);
|
||||||
void PushInteractiveDataFromApplet(IStorage storage);
|
void PushInteractiveDataFromApplet(std::shared_ptr<IStorage>&& storage);
|
||||||
|
|
||||||
void SignalStateChanged() const;
|
void SignalStateChanged() const;
|
||||||
|
|
||||||
@ -94,16 +94,16 @@ private:
|
|||||||
// Queues are named from applet's perspective
|
// Queues are named from applet's perspective
|
||||||
|
|
||||||
// PopNormalDataToApplet and PushNormalDataFromGame
|
// PopNormalDataToApplet and PushNormalDataFromGame
|
||||||
std::deque<std::unique_ptr<IStorage>> in_channel;
|
std::deque<std::shared_ptr<IStorage>> in_channel;
|
||||||
|
|
||||||
// PopNormalDataToGame and PushNormalDataFromApplet
|
// PopNormalDataToGame and PushNormalDataFromApplet
|
||||||
std::deque<std::unique_ptr<IStorage>> out_channel;
|
std::deque<std::shared_ptr<IStorage>> out_channel;
|
||||||
|
|
||||||
// PopInteractiveDataToApplet and PushInteractiveDataFromGame
|
// PopInteractiveDataToApplet and PushInteractiveDataFromGame
|
||||||
std::deque<std::unique_ptr<IStorage>> in_interactive_channel;
|
std::deque<std::shared_ptr<IStorage>> in_interactive_channel;
|
||||||
|
|
||||||
// PopInteractiveDataToGame and PushInteractiveDataFromApplet
|
// PopInteractiveDataToGame and PushInteractiveDataFromApplet
|
||||||
std::deque<std::unique_ptr<IStorage>> out_interactive_channel;
|
std::deque<std::shared_ptr<IStorage>> out_interactive_channel;
|
||||||
|
|
||||||
Kernel::EventPair state_changed_event;
|
Kernel::EventPair state_changed_event;
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ void Error::Execute() {
|
|||||||
|
|
||||||
void Error::DisplayCompleted() {
|
void Error::DisplayCompleted() {
|
||||||
complete = true;
|
complete = true;
|
||||||
broker.PushNormalDataFromApplet(IStorage{std::vector<u8>{}});
|
broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::vector<u8>{}));
|
||||||
broker.SignalStateChanged();
|
broker.SignalStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ namespace Service::AM::Applets {
|
|||||||
constexpr ResultCode ERROR_INVALID_PIN{ErrorModule::PCTL, 221};
|
constexpr ResultCode ERROR_INVALID_PIN{ErrorModule::PCTL, 221};
|
||||||
|
|
||||||
static void LogCurrentStorage(AppletDataBroker& broker, std::string_view prefix) {
|
static void LogCurrentStorage(AppletDataBroker& broker, std::string_view prefix) {
|
||||||
std::unique_ptr<IStorage> storage = broker.PopNormalDataToApplet();
|
std::shared_ptr<IStorage> storage = broker.PopNormalDataToApplet();
|
||||||
for (; storage != nullptr; storage = broker.PopNormalDataToApplet()) {
|
for (; storage != nullptr; storage = broker.PopNormalDataToApplet()) {
|
||||||
const auto data = storage->GetData();
|
const auto data = storage->GetData();
|
||||||
LOG_INFO(Service_AM,
|
LOG_INFO(Service_AM,
|
||||||
@ -148,7 +148,7 @@ void Auth::AuthFinished(bool successful) {
|
|||||||
std::vector<u8> out(sizeof(Return));
|
std::vector<u8> out(sizeof(Return));
|
||||||
std::memcpy(out.data(), &return_, sizeof(Return));
|
std::memcpy(out.data(), &return_, sizeof(Return));
|
||||||
|
|
||||||
broker.PushNormalDataFromApplet(IStorage{std::move(out)});
|
broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::move(out)));
|
||||||
broker.SignalStateChanged();
|
broker.SignalStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ void PhotoViewer::Execute() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PhotoViewer::ViewFinished() {
|
void PhotoViewer::ViewFinished() {
|
||||||
broker.PushNormalDataFromApplet(IStorage{std::vector<u8>{}});
|
broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::vector<u8>{}));
|
||||||
broker.SignalStateChanged();
|
broker.SignalStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,8 +234,8 @@ void StubApplet::ExecuteInteractive() {
|
|||||||
LOG_WARNING(Service_AM, "called (STUBBED)");
|
LOG_WARNING(Service_AM, "called (STUBBED)");
|
||||||
LogCurrentStorage(broker, "ExecuteInteractive");
|
LogCurrentStorage(broker, "ExecuteInteractive");
|
||||||
|
|
||||||
broker.PushNormalDataFromApplet(IStorage{std::vector<u8>(0x1000)});
|
broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::vector<u8>(0x1000)));
|
||||||
broker.PushInteractiveDataFromApplet(IStorage{std::vector<u8>(0x1000)});
|
broker.PushInteractiveDataFromApplet(std::make_shared<IStorage>(std::vector<u8>(0x1000)));
|
||||||
broker.SignalStateChanged();
|
broker.SignalStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,8 +243,8 @@ void StubApplet::Execute() {
|
|||||||
LOG_WARNING(Service_AM, "called (STUBBED)");
|
LOG_WARNING(Service_AM, "called (STUBBED)");
|
||||||
LogCurrentStorage(broker, "Execute");
|
LogCurrentStorage(broker, "Execute");
|
||||||
|
|
||||||
broker.PushNormalDataFromApplet(IStorage{std::vector<u8>(0x1000)});
|
broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::vector<u8>(0x1000)));
|
||||||
broker.PushInteractiveDataFromApplet(IStorage{std::vector<u8>(0x1000)});
|
broker.PushInteractiveDataFromApplet(std::make_shared<IStorage>(std::vector<u8>(0x1000)));
|
||||||
broker.SignalStateChanged();
|
broker.SignalStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ void ProfileSelect::ExecuteInteractive() {
|
|||||||
|
|
||||||
void ProfileSelect::Execute() {
|
void ProfileSelect::Execute() {
|
||||||
if (complete) {
|
if (complete) {
|
||||||
broker.PushNormalDataFromApplet(IStorage{std::move(final_data)});
|
broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::move(final_data)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ void ProfileSelect::SelectionComplete(std::optional<Common::UUID> uuid) {
|
|||||||
|
|
||||||
final_data = std::vector<u8>(sizeof(UserSelectionOutput));
|
final_data = std::vector<u8>(sizeof(UserSelectionOutput));
|
||||||
std::memcpy(final_data.data(), &output, final_data.size());
|
std::memcpy(final_data.data(), &output, final_data.size());
|
||||||
broker.PushNormalDataFromApplet(IStorage{std::move(final_data)});
|
broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::move(final_data)));
|
||||||
broker.SignalStateChanged();
|
broker.SignalStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ void SoftwareKeyboard::ExecuteInteractive() {
|
|||||||
|
|
||||||
void SoftwareKeyboard::Execute() {
|
void SoftwareKeyboard::Execute() {
|
||||||
if (complete) {
|
if (complete) {
|
||||||
broker.PushNormalDataFromApplet(IStorage{std::move(final_data)});
|
broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::move(final_data)));
|
||||||
broker.SignalStateChanged();
|
broker.SignalStateChanged();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -145,15 +145,15 @@ void SoftwareKeyboard::WriteText(std::optional<std::u16string> text) {
|
|||||||
final_data = output_main;
|
final_data = output_main;
|
||||||
|
|
||||||
if (complete) {
|
if (complete) {
|
||||||
broker.PushNormalDataFromApplet(IStorage{std::move(output_main)});
|
broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::move(output_main)));
|
||||||
broker.SignalStateChanged();
|
broker.SignalStateChanged();
|
||||||
} else {
|
} else {
|
||||||
broker.PushInteractiveDataFromApplet(IStorage{std::move(output_sub)});
|
broker.PushInteractiveDataFromApplet(std::make_shared<IStorage>(std::move(output_sub)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
output_main[0] = 1;
|
output_main[0] = 1;
|
||||||
complete = true;
|
complete = true;
|
||||||
broker.PushNormalDataFromApplet(IStorage{std::move(output_main)});
|
broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::move(output_main)));
|
||||||
broker.SignalStateChanged();
|
broker.SignalStateChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,7 +284,7 @@ void WebBrowser::Finalize() {
|
|||||||
std::vector<u8> data(sizeof(WebCommonReturnValue));
|
std::vector<u8> data(sizeof(WebCommonReturnValue));
|
||||||
std::memcpy(data.data(), &out, sizeof(WebCommonReturnValue));
|
std::memcpy(data.data(), &out, sizeof(WebCommonReturnValue));
|
||||||
|
|
||||||
broker.PushNormalDataFromApplet(IStorage{std::move(data)});
|
broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::move(data)));
|
||||||
broker.SignalStateChanged();
|
broker.SignalStateChanged();
|
||||||
|
|
||||||
if (!temporary_dir.empty() && FileUtil::IsDirectory(temporary_dir)) {
|
if (!temporary_dir.empty() && FileUtil::IsDirectory(temporary_dir)) {
|
||||||
|
@ -420,7 +420,7 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IFile file(result.Unwrap());
|
auto file = std::make_shared<IFile>(result.Unwrap());
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
@ -445,7 +445,7 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IDirectory directory(result.Unwrap());
|
auto directory = std::make_shared<IDirectory>(result.Unwrap());
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
@ -794,8 +794,8 @@ void FSP_SRV::OpenFileSystemWithPatch(Kernel::HLERequestContext& ctx) {
|
|||||||
void FSP_SRV::OpenSdCardFileSystem(Kernel::HLERequestContext& ctx) {
|
void FSP_SRV::OpenSdCardFileSystem(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_FS, "called");
|
LOG_DEBUG(Service_FS, "called");
|
||||||
|
|
||||||
IFileSystem filesystem(fsc.OpenSDMC().Unwrap(),
|
auto filesystem = std::make_shared<IFileSystem>(
|
||||||
SizeGetter::FromStorageId(fsc, FileSys::StorageId::SdCard));
|
fsc.OpenSDMC().Unwrap(), SizeGetter::FromStorageId(fsc, FileSys::StorageId::SdCard));
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
@ -846,7 +846,8 @@ void FSP_SRV::OpenSaveDataFileSystem(Kernel::HLERequestContext& ctx) {
|
|||||||
id = FileSys::StorageId::NandSystem;
|
id = FileSys::StorageId::NandSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
IFileSystem filesystem(std::move(dir.Unwrap()), SizeGetter::FromStorageId(fsc, id));
|
auto filesystem =
|
||||||
|
std::make_shared<IFileSystem>(std::move(dir.Unwrap()), SizeGetter::FromStorageId(fsc, id));
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
@ -898,7 +899,7 @@ void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IStorage storage(std::move(romfs.Unwrap()));
|
auto storage = std::make_shared<IStorage>(std::move(romfs.Unwrap()));
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
@ -937,7 +938,8 @@ void FSP_SRV::OpenDataStorageByDataId(Kernel::HLERequestContext& ctx) {
|
|||||||
|
|
||||||
FileSys::PatchManager pm{title_id};
|
FileSys::PatchManager pm{title_id};
|
||||||
|
|
||||||
IStorage storage(pm.PatchRomFS(std::move(data.Unwrap()), 0, FileSys::ContentRecordType::Data));
|
auto storage = std::make_shared<IStorage>(
|
||||||
|
pm.PatchRomFS(std::move(data.Unwrap()), 0, FileSys::ContentRecordType::Data));
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
Loading…
Reference in New Issue
Block a user