Replace boost::optional with std::optional where possible
This commit is contained in:
parent
87e16c80ac
commit
d37a2270d6
30 changed files with 104 additions and 106 deletions
|
@ -99,7 +99,7 @@ System::ResultStatus System::Load(EmuWindow& emu_window, const std::string& file
|
|||
LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath);
|
||||
return ResultStatus::ErrorGetLoader;
|
||||
}
|
||||
std::pair<boost::optional<u32>, Loader::ResultStatus> system_mode =
|
||||
std::pair<std::optional<u32>, Loader::ResultStatus> system_mode =
|
||||
app_loader->LoadKernelSystemMode();
|
||||
|
||||
if (system_mode.second != Loader::ResultStatus::Success) {
|
||||
|
@ -116,7 +116,7 @@ System::ResultStatus System::Load(EmuWindow& emu_window, const std::string& file
|
|||
}
|
||||
}
|
||||
|
||||
ResultStatus init_result{Init(emu_window, system_mode.first.get())};
|
||||
ResultStatus init_result{Init(emu_window, *system_mode.first)};
|
||||
if (init_result != ResultStatus::Success) {
|
||||
LOG_CRITICAL(Core, "Failed to initialize system (Error {})!",
|
||||
static_cast<u32>(init_result));
|
||||
|
|
|
@ -38,13 +38,13 @@ Loader::ResultStatus Ticket::Load(const std::vector<u8> file_data, std::size_t o
|
|||
return Loader::ResultStatus::Success;
|
||||
}
|
||||
|
||||
boost::optional<std::array<u8, 16>> Ticket::GetTitleKey() const {
|
||||
std::optional<std::array<u8, 16>> Ticket::GetTitleKey() const {
|
||||
HW::AES::InitKeys();
|
||||
std::array<u8, 16> ctr{};
|
||||
std::memcpy(ctr.data(), &ticket_body.title_id, sizeof(u64));
|
||||
HW::AES::SelectCommonKeyIndex(ticket_body.common_key_index);
|
||||
if (!HW::AES::IsNormalKeyAvailable(HW::AES::KeySlotID::TicketCommonKey)) {
|
||||
return boost::none;
|
||||
return {};
|
||||
}
|
||||
auto key = HW::AES::GetNormalKey(HW::AES::KeySlotID::TicketCommonKey);
|
||||
auto title_key = ticket_body.title_key;
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <boost/optional.hpp>
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/swap.h"
|
||||
|
@ -48,7 +48,7 @@ public:
|
|||
#pragma pack(pop)
|
||||
|
||||
Loader::ResultStatus Load(const std::vector<u8> file_data, std::size_t offset = 0);
|
||||
boost::optional<std::array<u8, 16>> GetTitleKey() const;
|
||||
std::optional<std::array<u8, 16>> GetTitleKey() const;
|
||||
|
||||
private:
|
||||
Body ticket_body;
|
||||
|
|
|
@ -147,7 +147,7 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi
|
|||
|
||||
if (base_address == 0 && target_address == 0) {
|
||||
// Calculate the address at which to map the memory block.
|
||||
target_address = Memory::PhysicalToVirtualAddress(linear_heap_phys_address).value();
|
||||
target_address = *Memory::PhysicalToVirtualAddress(linear_heap_phys_address);
|
||||
}
|
||||
|
||||
// Map the memory block into the target process
|
||||
|
|
|
@ -131,8 +131,7 @@ ResultCode CIAFile::WriteTitleMetadata() {
|
|||
auto content_count = container.GetTitleMetadata().GetContentCount();
|
||||
content_written.resize(content_count);
|
||||
|
||||
auto title_key = container.GetTicket().GetTitleKey();
|
||||
if (title_key) {
|
||||
if (auto title_key = container.GetTicket().GetTitleKey()) {
|
||||
decryption_state->content.resize(content_count);
|
||||
for (std::size_t i = 0; i < content_count; ++i) {
|
||||
auto ctr = tmd.GetContentCTRByIndex(i);
|
||||
|
@ -339,7 +338,7 @@ InstallStatus InstallCIA(const std::string& path,
|
|||
Service::AM::CIAFile installFile(
|
||||
Service::AM::GetTitleMediaType(container.GetTitleMetadata().GetTitleID()));
|
||||
|
||||
bool title_key_available = container.GetTicket().GetTitleKey().is_initialized();
|
||||
bool title_key_available = container.GetTicket().GetTitleKey().has_value();
|
||||
|
||||
for (std::size_t i = 0; i < container.GetTitleMetadata().GetContentCount(); i++) {
|
||||
if ((container.GetTitleMetadata().GetContentTypeByIndex(static_cast<u16>(i)) &
|
||||
|
|
|
@ -207,7 +207,7 @@ ResultVal<MessageParameter> AppletManager::GlanceParameter(AppletId app_id) {
|
|||
// Note: The NS module always clears the DSPSleep and DSPWakeup signals even in GlanceParameter.
|
||||
if (next_parameter->signal == SignalType::DspSleep ||
|
||||
next_parameter->signal == SignalType::DspWakeup)
|
||||
next_parameter = boost::none;
|
||||
next_parameter = {};
|
||||
|
||||
return MakeResult<MessageParameter>(parameter);
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ ResultVal<MessageParameter> AppletManager::ReceiveParameter(AppletId app_id) {
|
|||
auto result = GlanceParameter(app_id);
|
||||
if (result.Succeeded()) {
|
||||
// Clear the parameter
|
||||
next_parameter = boost::none;
|
||||
next_parameter = {};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ bool AppletManager::CancelParameter(bool check_sender, AppletId sender_appid, bo
|
|||
}
|
||||
|
||||
if (cancellation_success)
|
||||
next_parameter = boost::none;
|
||||
next_parameter = {};
|
||||
|
||||
return cancellation_success;
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
#include <boost/optional.hpp>
|
||||
#include "core/hle/kernel/event.h"
|
||||
#include "core/hle/result.h"
|
||||
#include "core/hle/service/fs/archive.h"
|
||||
|
@ -143,7 +143,7 @@ public:
|
|||
private:
|
||||
/// Parameter data to be returned in the next call to Glance/ReceiveParameter.
|
||||
/// TODO(Subv): Use std::optional once we migrate to C++17.
|
||||
boost::optional<MessageParameter> next_parameter;
|
||||
std::optional<MessageParameter> next_parameter;
|
||||
|
||||
static constexpr std::size_t NumAppletSlot = 4;
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ void Module::Interface::GetSharedFont(Kernel::HLERequestContext& ctx) {
|
|||
// The shared font has to be relocated to the new address before being passed to the
|
||||
// application.
|
||||
VAddr target_address =
|
||||
Memory::PhysicalToVirtualAddress(apt->shared_font_mem->linear_heap_phys_address).value();
|
||||
*Memory::PhysicalToVirtualAddress(apt->shared_font_mem->linear_heap_phys_address);
|
||||
if (!apt->shared_font_relocated) {
|
||||
BCFNT::RelocateSharedFont(apt->shared_font_mem, target_address);
|
||||
apt->shared_font_relocated = true;
|
||||
|
|
|
@ -132,7 +132,7 @@ void HTTP_C::CreateContext(Kernel::HLERequestContext& ctx) {
|
|||
}
|
||||
|
||||
// This command can only be called without a bound session.
|
||||
if (session_data->current_http_context != boost::none) {
|
||||
if (session_data->current_http_context) {
|
||||
LOG_ERROR(Service_HTTP, "Command called with a bound context");
|
||||
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||
|
@ -198,7 +198,7 @@ void HTTP_C::CloseContext(Kernel::HLERequestContext& ctx) {
|
|||
return;
|
||||
}
|
||||
|
||||
ASSERT_MSG(session_data->current_http_context == boost::none,
|
||||
ASSERT_MSG(!session_data->current_http_context,
|
||||
"Unimplemented CloseContext on context-bound session");
|
||||
|
||||
auto itr = contexts.find(context_handle);
|
||||
|
@ -249,7 +249,7 @@ void HTTP_C::AddRequestHeader(Kernel::HLERequestContext& ctx) {
|
|||
}
|
||||
|
||||
// This command can only be called with a bound context
|
||||
if (session_data->current_http_context == boost::none) {
|
||||
if (!session_data->current_http_context) {
|
||||
LOG_ERROR(Service_HTTP, "Command called without a bound context");
|
||||
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||
|
@ -263,7 +263,7 @@ void HTTP_C::AddRequestHeader(Kernel::HLERequestContext& ctx) {
|
|||
LOG_ERROR(Service_HTTP,
|
||||
"Tried to add a request header on a mismatched session input context={} session "
|
||||
"context={}",
|
||||
context_handle, session_data->current_http_context.get());
|
||||
context_handle, *session_data->current_http_context);
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||
rb.Push(ERROR_STATE_ERROR);
|
||||
rb.PushMappedBuffer(value_buffer);
|
||||
|
@ -313,7 +313,7 @@ void HTTP_C::OpenClientCertContext(Kernel::HLERequestContext& ctx) {
|
|||
if (!session_data->initialized) {
|
||||
LOG_ERROR(Service_HTTP, "Command called without Initialize");
|
||||
result = ERROR_STATE_ERROR;
|
||||
} else if (session_data->current_http_context != boost::none) {
|
||||
} else if (session_data->current_http_context) {
|
||||
LOG_ERROR(Service_HTTP, "Command called with a bound context");
|
||||
result = ERROR_NOT_IMPLEMENTED;
|
||||
} else if (session_data->num_client_certs >= 2) {
|
||||
|
@ -352,7 +352,7 @@ void HTTP_C::OpenDefaultClientCertContext(Kernel::HLERequestContext& ctx) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (session_data->current_http_context != boost::none) {
|
||||
if (session_data->current_http_context) {
|
||||
LOG_ERROR(Service_HTTP, "Command called with a bound context");
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
||||
rb.Push(ERROR_NOT_IMPLEMENTED);
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <boost/optional.hpp>
|
||||
#include "core/hle/kernel/shared_memory.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
|
@ -112,8 +112,8 @@ public:
|
|||
std::string url;
|
||||
RequestMethod method;
|
||||
RequestState state = RequestState::NotStarted;
|
||||
boost::optional<Proxy> proxy;
|
||||
boost::optional<BasicAuth> basic_auth;
|
||||
std::optional<Proxy> proxy;
|
||||
std::optional<BasicAuth> basic_auth;
|
||||
SSLConfig ssl_config{};
|
||||
u32 socket_buffer_size;
|
||||
std::vector<RequestHeader> headers;
|
||||
|
@ -123,7 +123,7 @@ public:
|
|||
struct SessionData : public Kernel::SessionRequestHandler::SessionDataBase {
|
||||
/// The HTTP context that is currently bound to this session, this can be empty if no context
|
||||
/// has been bound. Certain commands can only be called on a session with a bound context.
|
||||
boost::optional<Context::Handle> current_http_context;
|
||||
std::optional<Context::Handle> current_http_context;
|
||||
|
||||
u32 session_id;
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <exception>
|
||||
#include <optional>
|
||||
#include <sstream>
|
||||
#include <boost/optional.hpp>
|
||||
#include "common/common_paths.h"
|
||||
#include "common/file_util.h"
|
||||
#include "common/logging/log.h"
|
||||
|
@ -18,24 +18,24 @@ namespace AES {
|
|||
|
||||
namespace {
|
||||
|
||||
boost::optional<AESKey> generator_constant;
|
||||
std::optional<AESKey> generator_constant;
|
||||
|
||||
struct KeySlot {
|
||||
boost::optional<AESKey> x;
|
||||
boost::optional<AESKey> y;
|
||||
boost::optional<AESKey> normal;
|
||||
std::optional<AESKey> x;
|
||||
std::optional<AESKey> y;
|
||||
std::optional<AESKey> normal;
|
||||
|
||||
void SetKeyX(boost::optional<AESKey> key) {
|
||||
void SetKeyX(std::optional<AESKey> key) {
|
||||
x = key;
|
||||
GenerateNormalKey();
|
||||
}
|
||||
|
||||
void SetKeyY(boost::optional<AESKey> key) {
|
||||
void SetKeyY(std::optional<AESKey> key) {
|
||||
y = key;
|
||||
GenerateNormalKey();
|
||||
}
|
||||
|
||||
void SetNormalKey(boost::optional<AESKey> key) {
|
||||
void SetNormalKey(std::optional<AESKey> key) {
|
||||
normal = key;
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ struct KeySlot {
|
|||
if (x && y && generator_constant) {
|
||||
normal = Lrot128(Add128(Xor128(Lrot128(*x, 2), *y), *generator_constant), 87);
|
||||
} else {
|
||||
normal = boost::none;
|
||||
normal = {};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ struct KeySlot {
|
|||
};
|
||||
|
||||
std::array<KeySlot, KeySlotID::MaxKeySlotID> key_slots;
|
||||
std::array<boost::optional<AESKey>, 6> common_key_y_slots;
|
||||
std::array<std::optional<AESKey>, 6> common_key_y_slots;
|
||||
|
||||
AESKey HexToKey(const std::string& hex) {
|
||||
if (hex.size() < 32) {
|
||||
|
@ -169,7 +169,7 @@ void SetNormalKey(std::size_t slot_id, const AESKey& key) {
|
|||
}
|
||||
|
||||
bool IsNormalKeyAvailable(std::size_t slot_id) {
|
||||
return key_slots.at(slot_id).normal.is_initialized();
|
||||
return key_slots.at(slot_id).normal.has_value();
|
||||
}
|
||||
|
||||
AESKey GetNormalKey(std::size_t slot_id) {
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
#include <algorithm>
|
||||
#include <initializer_list>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <boost/optional.hpp>
|
||||
#include "common/common_types.h"
|
||||
#include "common/file_util.h"
|
||||
#include "core/file_sys/romfs_reader.h"
|
||||
|
@ -107,7 +107,7 @@ public:
|
|||
* information.
|
||||
* @returns A pair with the optional system mode, and and the status.
|
||||
*/
|
||||
virtual std::pair<boost::optional<u32>, ResultStatus> LoadKernelSystemMode() {
|
||||
virtual std::pair<std::optional<u32>, ResultStatus> LoadKernelSystemMode() {
|
||||
// 96MB allocated to the application.
|
||||
return std::make_pair(2, ResultStatus::Success);
|
||||
}
|
||||
|
|
|
@ -49,11 +49,11 @@ FileType AppLoader_NCCH::IdentifyType(FileUtil::IOFile& file) {
|
|||
return FileType::Error;
|
||||
}
|
||||
|
||||
std::pair<boost::optional<u32>, ResultStatus> AppLoader_NCCH::LoadKernelSystemMode() {
|
||||
std::pair<std::optional<u32>, ResultStatus> AppLoader_NCCH::LoadKernelSystemMode() {
|
||||
if (!is_loaded) {
|
||||
ResultStatus res = base_ncch.Load();
|
||||
if (res != ResultStatus::Success) {
|
||||
return std::make_pair(boost::none, res);
|
||||
return std::make_pair(std::optional<u32>{}, res);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
* Loads the Exheader and returns the system mode for this application.
|
||||
* @returns A pair with the optional system mode, and and the status.
|
||||
*/
|
||||
std::pair<boost::optional<u32>, ResultStatus> LoadKernelSystemMode() override;
|
||||
std::pair<std::optional<u32>, ResultStatus> LoadKernelSystemMode() override;
|
||||
|
||||
ResultStatus ReadCode(std::vector<u8>& buffer) override;
|
||||
|
||||
|
|
|
@ -333,7 +333,7 @@ void RasterizerMarkRegionCached(PAddr start, u32 size, bool cached) {
|
|||
PAddr paddr = start;
|
||||
|
||||
for (unsigned i = 0; i < num_pages; ++i, paddr += PAGE_SIZE) {
|
||||
boost::optional<VAddr> maybe_vaddr = PhysicalToVirtualAddress(paddr);
|
||||
std::optional<VAddr> maybe_vaddr = PhysicalToVirtualAddress(paddr);
|
||||
// While the physical <-> virtual mapping is 1:1 for the regions supported by the cache,
|
||||
// some games (like Pokemon Super Mystery Dungeon) will try to use textures that go beyond
|
||||
// the end address of VRAM, causing the Virtual->Physical translation to fail when flushing
|
||||
|
@ -433,7 +433,7 @@ void RasterizerFlushVirtualRegion(VAddr start, u32 size, FlushMode mode) {
|
|||
VAddr overlap_start = std::max(start, region_start);
|
||||
VAddr overlap_end = std::min(end, region_end);
|
||||
|
||||
PAddr physical_start = TryVirtualToPhysicalAddress(overlap_start).value();
|
||||
PAddr physical_start = *TryVirtualToPhysicalAddress(overlap_start);
|
||||
u32 overlap_size = overlap_end - overlap_start;
|
||||
|
||||
auto* rasterizer = VideoCore::g_renderer->Rasterizer();
|
||||
|
@ -740,7 +740,7 @@ void WriteMMIO<u64>(MMIORegionPointer mmio_handler, VAddr addr, const u64 data)
|
|||
mmio_handler->Write64(addr, data);
|
||||
}
|
||||
|
||||
boost::optional<PAddr> TryVirtualToPhysicalAddress(const VAddr addr) {
|
||||
std::optional<PAddr> TryVirtualToPhysicalAddress(const VAddr addr) {
|
||||
if (addr == 0) {
|
||||
return 0;
|
||||
} else if (addr >= VRAM_VADDR && addr < VRAM_VADDR_END) {
|
||||
|
@ -757,7 +757,7 @@ boost::optional<PAddr> TryVirtualToPhysicalAddress(const VAddr addr) {
|
|||
return addr - N3DS_EXTRA_RAM_VADDR + N3DS_EXTRA_RAM_PADDR;
|
||||
}
|
||||
|
||||
return boost::none;
|
||||
return {};
|
||||
}
|
||||
|
||||
PAddr VirtualToPhysicalAddress(const VAddr addr) {
|
||||
|
@ -770,7 +770,7 @@ PAddr VirtualToPhysicalAddress(const VAddr addr) {
|
|||
return *paddr;
|
||||
}
|
||||
|
||||
boost::optional<VAddr> PhysicalToVirtualAddress(const PAddr addr) {
|
||||
std::optional<VAddr> PhysicalToVirtualAddress(const PAddr addr) {
|
||||
if (addr == 0) {
|
||||
return 0;
|
||||
} else if (addr >= VRAM_PADDR && addr < VRAM_PADDR_END) {
|
||||
|
@ -785,7 +785,7 @@ boost::optional<VAddr> PhysicalToVirtualAddress(const PAddr addr) {
|
|||
return addr - N3DS_EXTRA_RAM_PADDR + N3DS_EXTRA_RAM_VADDR;
|
||||
}
|
||||
|
||||
return boost::none;
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace Memory
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <boost/optional.hpp>
|
||||
#include "common/common_types.h"
|
||||
#include "core/mmio.h"
|
||||
|
||||
|
@ -214,7 +214,7 @@ std::string ReadCString(VAddr vaddr, std::size_t max_length);
|
|||
* Converts a virtual address inside a region with 1:1 mapping to physical memory to a physical
|
||||
* address. This should be used by services to translate addresses for use by the hardware.
|
||||
*/
|
||||
boost::optional<PAddr> TryVirtualToPhysicalAddress(VAddr addr);
|
||||
std::optional<PAddr> TryVirtualToPhysicalAddress(VAddr addr);
|
||||
|
||||
/**
|
||||
* Converts a virtual address inside a region with 1:1 mapping to physical memory to a physical
|
||||
|
@ -227,7 +227,7 @@ PAddr VirtualToPhysicalAddress(VAddr addr);
|
|||
/**
|
||||
* Undoes a mapping performed by VirtualToPhysicalAddress().
|
||||
*/
|
||||
boost::optional<VAddr> PhysicalToVirtualAddress(PAddr paddr);
|
||||
std::optional<VAddr> PhysicalToVirtualAddress(PAddr paddr);
|
||||
|
||||
/**
|
||||
* Gets a pointer to the memory region beginning at the specified physical address.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue