Merge pull request #14500 from Sintendo/span2
Replace `const std::vector&` arguments with `std::span`
This commit is contained in:
79 files changed
+164
-146
No files matched your search
@@ -31,7 +31,7 @@ DolReader::DolReader(const std::string& filename) : BootExecutableReader(filenam
|
||||
|
||||
DolReader::~DolReader() = default;
|
||||
|
||||
bool DolReader::Initialize(const std::vector<u8>& buffer)
|
||||
bool DolReader::Initialize(std::span<const u8> buffer)
|
||||
{
|
||||
if (buffer.size() < sizeof(SDolHeader) || buffer.size() > UINT32_MAX)
|
||||
return false;
|
||||
|
||||
@@ -65,7 +65,7 @@ private:
|
||||
bool m_is_ancast;
|
||||
|
||||
// Copy sections to internal buffers
|
||||
bool Initialize(const std::vector<u8>& buffer);
|
||||
bool Initialize(std::span<const u8> buffer);
|
||||
|
||||
bool LoadAncastIntoMemory(Core::System& system) const;
|
||||
};
|
||||
@@ -111,7 +111,7 @@ TryReadValueFromEmulatedMemory(const Core::CPUThreadGuard& guard, u32 addr,
|
||||
|
||||
template <typename T>
|
||||
auto Cheats::NewSearch(const Core::CPUThreadGuard& guard,
|
||||
const std::vector<Cheats::MemoryRange>& memory_ranges,
|
||||
std::span<const Cheats::MemoryRange> memory_ranges,
|
||||
PowerPC::RequestedAddressSpace address_space, bool aligned,
|
||||
const std::function<bool(const T& value)>& validator)
|
||||
-> std::expected<std::vector<SearchResult<T>>, SearchErrorCode>
|
||||
@@ -164,7 +164,7 @@ auto Cheats::NewSearch(const Core::CPUThreadGuard& guard,
|
||||
|
||||
template <typename T>
|
||||
auto Cheats::NextSearch(
|
||||
const Core::CPUThreadGuard& guard, const std::vector<Cheats::SearchResult<T>>& previous_results,
|
||||
const Core::CPUThreadGuard& guard, std::span<const Cheats::SearchResult<T>> previous_results,
|
||||
PowerPC::RequestedAddressSpace address_space,
|
||||
const std::function<bool(const T& new_value, const T& old_value)>& validator)
|
||||
-> std::expected<std::vector<SearchResult<T>>, SearchErrorCode>
|
||||
|
||||
@@ -117,7 +117,7 @@ std::vector<u8> GetValueAsByteVector(const SearchValue& value);
|
||||
// for which the given validator returns true.
|
||||
template <typename T>
|
||||
std::expected<std::vector<SearchResult<T>>, SearchErrorCode>
|
||||
NewSearch(const Core::CPUThreadGuard& guard, const std::vector<MemoryRange>& memory_ranges,
|
||||
NewSearch(const Core::CPUThreadGuard& guard, std::span<const MemoryRange> memory_ranges,
|
||||
PowerPC::RequestedAddressSpace address_space, bool aligned,
|
||||
const std::function<bool(const T& value)>& validator);
|
||||
|
||||
@@ -125,7 +125,7 @@ NewSearch(const Core::CPUThreadGuard& guard, const std::vector<MemoryRange>& mem
|
||||
// which the given validator returns true.
|
||||
template <typename T>
|
||||
std::expected<std::vector<SearchResult<T>>, SearchErrorCode>
|
||||
NextSearch(const Core::CPUThreadGuard& guard, const std::vector<SearchResult<T>>& previous_results,
|
||||
NextSearch(const Core::CPUThreadGuard& guard, std::span<const SearchResult<T>> previous_results,
|
||||
PowerPC::RequestedAddressSpace address_space,
|
||||
const std::function<bool(const T& new_value, const T& old_value)>& validator);
|
||||
|
||||
|
||||
@@ -367,7 +367,7 @@ std::vector<std::string> GetIsoPaths()
|
||||
return paths;
|
||||
}
|
||||
|
||||
void SetIsoPaths(const std::vector<std::string>& paths)
|
||||
void SetIsoPaths(std::span<const std::string> paths)
|
||||
{
|
||||
size_t old_size = MathUtil::SaturatingCast<size_t>(Config::Get(Config::MAIN_ISO_PATH_COUNT));
|
||||
size_t new_size = paths.size();
|
||||
|
||||
@@ -218,7 +218,7 @@ extern const Info<int> MAIN_GDB_PORT;
|
||||
extern const Info<int> MAIN_ISO_PATH_COUNT;
|
||||
extern const Info<std::string> MAIN_SKYLANDERS_PATH;
|
||||
std::vector<std::string> GetIsoPaths();
|
||||
void SetIsoPaths(const std::vector<std::string>& paths);
|
||||
void SetIsoPaths(std::span<const std::string> paths);
|
||||
|
||||
// Main.GBA
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "Core/DSP/DSPCodeUtil.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -35,7 +36,7 @@ bool Assemble(const std::string& text, std::vector<u16>& code, bool force)
|
||||
return assembler.Assemble(text, code);
|
||||
}
|
||||
|
||||
bool Disassemble(const std::vector<u16>& code, bool line_numbers, std::string& text)
|
||||
bool Disassemble(std::span<const u16> code, bool line_numbers, std::string& text)
|
||||
{
|
||||
if (code.empty())
|
||||
return false;
|
||||
@@ -56,7 +57,7 @@ bool Disassemble(const std::vector<u16>& code, bool line_numbers, std::string& t
|
||||
|
||||
// NOTE: This code is called from DSPTool and UnitTests, which do not use the logging system.
|
||||
// Thus, fmt::print is used instead of the log system.
|
||||
bool Compare(const std::vector<u16>& code1, const std::vector<u16>& code2)
|
||||
bool Compare(std::span<const u16> code1, std::span<const u16> code2)
|
||||
{
|
||||
if (code1.size() != code2.size())
|
||||
fmt::print("Size difference! 1={} 2={}\n", code1.size(), code2.size());
|
||||
@@ -106,7 +107,7 @@ bool Compare(const std::vector<u16>& code1, const std::vector<u16>& code2)
|
||||
if (code2.size() != code1.size())
|
||||
{
|
||||
fmt::print("Extra code words:\n");
|
||||
const std::vector<u16>& longest = code1.size() > code2.size() ? code1 : code2;
|
||||
const auto longest = code1.size() > code2.size() ? code1 : code2;
|
||||
for (u16 i = min_size; i < longest.size(); i++)
|
||||
{
|
||||
u16 pc = i;
|
||||
@@ -119,7 +120,7 @@ bool Compare(const std::vector<u16>& code1, const std::vector<u16>& code2)
|
||||
return code1.size() == code2.size() && code1.size() == count_equal;
|
||||
}
|
||||
|
||||
std::string CodeToBinaryStringBE(const std::vector<u16>& code)
|
||||
std::string CodeToBinaryStringBE(std::span<const u16> code)
|
||||
{
|
||||
std::string str(code.size() * 2, '\0');
|
||||
|
||||
@@ -153,7 +154,7 @@ std::optional<std::vector<u16>> LoadBinary(const std::string& filename)
|
||||
return std::make_optional(BinaryStringBEToCode(buffer));
|
||||
}
|
||||
|
||||
bool SaveBinary(const std::vector<u16>& code, const std::string& filename)
|
||||
bool SaveBinary(std::span<const u16> code, const std::string& filename)
|
||||
{
|
||||
const std::string buffer = CodeToBinaryStringBE(code);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -12,16 +13,16 @@
|
||||
namespace DSP
|
||||
{
|
||||
bool Assemble(const std::string& text, std::vector<u16>& code, bool force = false);
|
||||
bool Disassemble(const std::vector<u16>& code, bool line_numbers, std::string& text);
|
||||
bool Compare(const std::vector<u16>& code1, const std::vector<u16>& code2);
|
||||
bool Disassemble(std::span<const u16> code, bool line_numbers, std::string& text);
|
||||
bool Compare(std::span<const u16> code1, std::span<const u16> code2);
|
||||
|
||||
// Big-endian, for writing straight to file using File::WriteStringToFile.
|
||||
std::string CodeToBinaryStringBE(const std::vector<u16>& code);
|
||||
std::string CodeToBinaryStringBE(std::span<const u16> code);
|
||||
std::vector<u16> BinaryStringBEToCode(const std::string& str);
|
||||
|
||||
// Load code (big endian binary).
|
||||
std::optional<std::vector<u16>> LoadBinary(const std::string& filename);
|
||||
bool SaveBinary(const std::vector<u16>& code, const std::string& filename);
|
||||
bool SaveBinary(std::span<const u16> code, const std::string& filename);
|
||||
|
||||
bool DumpDSPCode(const u8* code_be, size_t size_in_bytes, u32 crc);
|
||||
} // namespace DSP
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
@@ -23,7 +22,7 @@ DSPDisassembler::DSPDisassembler(const AssemblerSettings& settings) : settings_(
|
||||
{
|
||||
}
|
||||
|
||||
bool DSPDisassembler::Disassemble(const std::vector<u16>& code, std::string& text)
|
||||
bool DSPDisassembler::Disassemble(std::span<const u16> code, std::string& text)
|
||||
{
|
||||
if (code.size() > std::numeric_limits<u16>::max())
|
||||
{
|
||||
@@ -140,7 +139,7 @@ std::string DSPDisassembler::DisassembleParameters(const DSPOPCTemplate& opc, u1
|
||||
return buf;
|
||||
}
|
||||
|
||||
bool DSPDisassembler::DisassembleOpcode(const std::vector<u16>& code, u16* pc, std::string& dest)
|
||||
bool DSPDisassembler::DisassembleOpcode(std::span<const u16> code, u16* pc, std::string& dest)
|
||||
{
|
||||
return DisassembleOpcode(code.data(), code.size(), pc, dest);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
@@ -32,11 +32,11 @@ class DSPDisassembler
|
||||
public:
|
||||
explicit DSPDisassembler(const AssemblerSettings& settings);
|
||||
|
||||
bool Disassemble(const std::vector<u16>& code, std::string& text);
|
||||
bool Disassemble(std::span<const u16> code, std::string& text);
|
||||
|
||||
// Disassembles the given opcode at pc and increases pc by the opcode's size.
|
||||
// The PC is wrapped such that 0x0000 and 0x8000 both point to the start of the buffer.
|
||||
bool DisassembleOpcode(const std::vector<u16>& code, u16* pc, std::string& dest);
|
||||
bool DisassembleOpcode(std::span<const u16> code, u16* pc, std::string& dest);
|
||||
bool DisassembleOpcode(const u16* binbuf, size_t binbuf_size, u16* pc, std::string& dest);
|
||||
|
||||
private:
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -40,7 +41,7 @@ public:
|
||||
virtual void DisableWatch(std::size_t index) = 0;
|
||||
virtual bool HasEnabledWatch(u32 address) const = 0;
|
||||
virtual void RemoveWatch(std::size_t index) = 0;
|
||||
virtual void LoadWatchesFromStrings(const std::vector<std::string>& watches) = 0;
|
||||
virtual void LoadWatchesFromStrings(std::span<const std::string> watches) = 0;
|
||||
virtual std::vector<std::string> SaveWatchesToStrings() const = 0;
|
||||
virtual void ClearWatches() = 0;
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ void PPCDebugInterface::RemoveWatch(std::size_t index)
|
||||
return m_watches.RemoveWatch(index);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::LoadWatchesFromStrings(const std::vector<std::string>& watches)
|
||||
void PPCDebugInterface::LoadWatchesFromStrings(std::span<const std::string> watches)
|
||||
{
|
||||
m_watches.LoadFromStrings(watches);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
void DisableWatch(std::size_t index) override;
|
||||
bool HasEnabledWatch(u32 address) const override;
|
||||
void RemoveWatch(std::size_t index) override;
|
||||
void LoadWatchesFromStrings(const std::vector<std::string>& watches) override;
|
||||
void LoadWatchesFromStrings(std::span<const std::string> watches) override;
|
||||
std::vector<std::string> SaveWatchesToStrings() const override;
|
||||
void ClearWatches() override;
|
||||
|
||||
|
||||
@@ -389,8 +389,7 @@ bool FifoDataFile::GetFlag(u32 flag) const
|
||||
return !!(m_Flags & flag);
|
||||
}
|
||||
|
||||
u64 FifoDataFile::WriteMemoryUpdates(const std::vector<MemoryUpdate>& memUpdates,
|
||||
File::IOFile& file)
|
||||
u64 FifoDataFile::WriteMemoryUpdates(std::span<const MemoryUpdate> memUpdates, File::IOFile& file)
|
||||
{
|
||||
// Add space for memory update list
|
||||
u64 updateListOffset = file.Tell();
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -92,7 +93,7 @@ private:
|
||||
void SetFlag(u32 flag, bool set);
|
||||
bool GetFlag(u32 flag) const;
|
||||
|
||||
u64 WriteMemoryUpdates(const std::vector<MemoryUpdate>& memUpdates, File::IOFile& file);
|
||||
u64 WriteMemoryUpdates(std::span<const MemoryUpdate> memUpdates, File::IOFile& file);
|
||||
static void ReadMemoryUpdates(u64 fileOffset, u32 numUpdates,
|
||||
std::vector<MemoryUpdate>& memUpdates, File::IOFile& file);
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@ static void SaveGeckoCode(std::vector<std::string>& lines, const GeckoCode& gcod
|
||||
lines.push_back('*' + note);
|
||||
}
|
||||
|
||||
void SaveCodes(Common::IniFile& inifile, const std::vector<GeckoCode>& gcodes)
|
||||
void SaveCodes(Common::IniFile& inifile, std::span<const GeckoCode> gcodes)
|
||||
{
|
||||
std::vector<std::string> lines;
|
||||
std::vector<std::string> enabled_lines;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <expected>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -19,7 +20,7 @@ namespace Gecko
|
||||
{
|
||||
std::vector<GeckoCode> LoadCodes(const Common::IniFile& globalIni, const Common::IniFile& localIni);
|
||||
std::expected<std::vector<GeckoCode>, int> DownloadCodes(std::string gametdb_id);
|
||||
void SaveCodes(Common::IniFile& inifile, const std::vector<GeckoCode>& gcodes);
|
||||
void SaveCodes(Common::IniFile& inifile, std::span<const GeckoCode> gcodes);
|
||||
|
||||
std::optional<GeckoCode::Code> DeserializeLine(const std::string& line);
|
||||
} // namespace Gecko
|
||||
@@ -133,7 +133,7 @@ void DVDInterface::DoState(PointerWrap& p)
|
||||
}
|
||||
|
||||
size_t DVDInterface::ProcessDTKSamples(s16* target_samples, size_t target_block_count,
|
||||
const std::vector<u8>& audio_data)
|
||||
std::span<const u8> audio_data)
|
||||
{
|
||||
const size_t block_count_to_process =
|
||||
std::min(target_block_count, audio_data.size() / StreamADPCM::ONE_BLOCK_SIZE);
|
||||
@@ -192,7 +192,7 @@ u32 DVDInterface::AdvanceDTK(u32 maximum_blocks, u32* blocks_to_process)
|
||||
}
|
||||
|
||||
void DVDInterface::DTKStreamingCallback(DIInterruptType interrupt_type,
|
||||
const std::vector<u8>& audio_data, s64 cycles_late)
|
||||
std::span<const u8> audio_data, s64 cycles_late)
|
||||
{
|
||||
auto& ai = m_system.GetAudioInterface();
|
||||
|
||||
@@ -1304,7 +1304,7 @@ void DVDInterface::SetDriveError(DriveError error)
|
||||
}
|
||||
|
||||
void DVDInterface::FinishExecutingCommand(ReplyType reply_type, DIInterruptType interrupt_type,
|
||||
s64 cycles_late, const std::vector<u8>& data)
|
||||
s64 cycles_late, std::span<const u8> data)
|
||||
{
|
||||
// The data parameter contains the requested data iff this was called from DVDThread, and is
|
||||
// empty otherwise. DVDThread is the only source of ReplyType::NoReply and ReplyType::DTK.
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -170,17 +171,17 @@ public:
|
||||
|
||||
// Used by DVDThread
|
||||
void FinishExecutingCommand(ReplyType reply_type, DIInterruptType interrupt_type, s64 cycles_late,
|
||||
const std::vector<u8>& data = std::vector<u8>());
|
||||
std::span<const u8> data = {});
|
||||
|
||||
// Used by IOS HLE
|
||||
void SetInterruptEnabled(DIInterruptType interrupt, bool enabled);
|
||||
void ClearInterrupt(DIInterruptType interrupt);
|
||||
|
||||
private:
|
||||
void DTKStreamingCallback(DIInterruptType interrupt_type, const std::vector<u8>& audio_data,
|
||||
void DTKStreamingCallback(DIInterruptType interrupt_type, std::span<const u8> audio_data,
|
||||
s64 cycles_late);
|
||||
size_t ProcessDTKSamples(s16* target_samples, size_t target_block_count,
|
||||
const std::vector<u8>& audio_data);
|
||||
const std::span<const u8> audio_data);
|
||||
u32 AdvanceDTK(u32 maximum_blocks, u32* blocks_to_process);
|
||||
|
||||
void SetLidOpen();
|
||||
|
||||
@@ -124,9 +124,9 @@ bool CEXIETHERNET::BuiltInBBAInterface::IsActivated()
|
||||
return m_active;
|
||||
}
|
||||
|
||||
void CEXIETHERNET::BuiltInBBAInterface::WriteToQueue(const std::vector<u8>& data)
|
||||
void CEXIETHERNET::BuiltInBBAInterface::WriteToQueue(std::vector<u8> data)
|
||||
{
|
||||
m_queue_data[m_queue_write] = data;
|
||||
m_queue_data[m_queue_write] = std::move(data);
|
||||
const u8 next_write_index = (m_queue_write + 1) & 15;
|
||||
if (next_write_index != m_queue_read)
|
||||
m_queue_write = next_write_index;
|
||||
@@ -178,7 +178,7 @@ void CEXIETHERNET::BuiltInBBAInterface::PollData(std::size_t* datasize)
|
||||
// Otherwise, enqueue it
|
||||
const auto socket_data = TryGetDataFromSocket(&net_ref);
|
||||
if (socket_data.has_value())
|
||||
WriteToQueue(*socket_data);
|
||||
WriteToQueue(std::move(*socket_data));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -220,7 +220,7 @@ void CEXIETHERNET::BuiltInBBAInterface::HandleDHCP(const Common::UDPPacket& pack
|
||||
const u8* router_ip_ptr = reinterpret_cast<const u8*>(&m_router_ip);
|
||||
const std::vector<u8> ip_part(router_ip_ptr, router_ip_ptr + sizeof(m_router_ip));
|
||||
|
||||
const std::vector<u8> timeout_24h = {0, 1, 0x51, 0x80};
|
||||
constexpr auto timeout_24h = std::to_array<u8>({0, 1, 0x51, 0x80});
|
||||
|
||||
Common::DHCPPacket reply;
|
||||
reply.body = Common::DHCPBody(request.transaction_id, m_current_mac, m_current_ip, m_router_ip);
|
||||
@@ -666,8 +666,7 @@ bool CEXIETHERNET::BuiltInBBAInterface::SendFrame(const u8* frame, u32 size)
|
||||
case IPPROTO_IGMP:
|
||||
{
|
||||
// Acknowledge IGMP packet
|
||||
const std::vector<u8> data(frame, frame + size);
|
||||
WriteToQueue(data);
|
||||
WriteToQueue({frame, frame + size});
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -463,7 +463,7 @@ private:
|
||||
Common::Flag m_read_thread_shutdown;
|
||||
static void ReadThreadHandler(BuiltInBBAInterface* self);
|
||||
#endif
|
||||
void WriteToQueue(const std::vector<u8>& data);
|
||||
void WriteToQueue(std::vector<u8> data);
|
||||
bool WillQueueOverrun() const;
|
||||
void PollData(std::size_t* datasize);
|
||||
std::optional<std::vector<u8>> TryGetDataFromSocket(StackRef* ref);
|
||||
|
||||
@@ -369,7 +369,7 @@ bool MemoryManager::TryAddLargePageTableMapping(u32 logical_address, u32 transla
|
||||
return CanCreateHostMappingForGuestPages(entries);
|
||||
}
|
||||
|
||||
bool MemoryManager::CanCreateHostMappingForGuestPages(const std::vector<u32>& entries) const
|
||||
bool MemoryManager::CanCreateHostMappingForGuestPages(std::span<const u32> entries) const
|
||||
{
|
||||
const u32 translated_address = entries[0];
|
||||
if ((translated_address & (m_page_size - 1)) != 0)
|
||||
|
||||
@@ -289,7 +289,7 @@ private:
|
||||
void TryAddLargePageTableMapping(u32 logical_address, u32 translated_address, bool writeable);
|
||||
bool TryAddLargePageTableMapping(u32 logical_address, u32 translated_address,
|
||||
std::map<u32, std::vector<u32>>& map);
|
||||
bool CanCreateHostMappingForGuestPages(const std::vector<u32>& entries) const;
|
||||
bool CanCreateHostMappingForGuestPages(std::span<const u32> entries) const;
|
||||
void AddHostPageTableMapping(u32 logical_address, u32 translated_address, bool writeable,
|
||||
u32 logical_size);
|
||||
void RemoveLargePageTableMapping(u32 logical_address);
|
||||
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
|
||||
bool WriteBkHeader(const BkHeader& bk_header) override { return true; }
|
||||
|
||||
bool WriteFiles(const std::vector<SaveFile>& files) override
|
||||
bool WriteFiles(std::span<const SaveFile> files) override
|
||||
{
|
||||
if (!m_uid || !m_gid)
|
||||
return false;
|
||||
@@ -390,7 +390,7 @@ public:
|
||||
return m_file.Seek(sizeof(Header), File::SeekOrigin::Begin) && m_file.WriteArray(&bk_header, 1);
|
||||
}
|
||||
|
||||
bool WriteFiles(const std::vector<SaveFile>& files) override
|
||||
bool WriteFiles(std::span<const SaveFile> files) override
|
||||
{
|
||||
if (!m_file.Seek(sizeof(Header) + sizeof(BkHeader), File::SeekOrigin::Begin))
|
||||
return false;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -108,6 +109,6 @@ public:
|
||||
virtual std::optional<std::vector<SaveFile>> ReadFiles() = 0;
|
||||
virtual bool WriteHeader(const Header& header) = 0;
|
||||
virtual bool WriteBkHeader(const BkHeader& bk_header) = 0;
|
||||
virtual bool WriteFiles(const std::vector<SaveFile>& files) = 0;
|
||||
virtual bool WriteFiles(std::span<const SaveFile> files) = 0;
|
||||
};
|
||||
} // namespace WiiSave
|
||||
@@ -4,6 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -36,7 +37,7 @@ class GBAHostInterface
|
||||
public:
|
||||
virtual ~GBAHostInterface() = default;
|
||||
virtual void GameChanged() = 0;
|
||||
virtual void FrameEnded(const std::vector<u32>& video_buffer) = 0;
|
||||
virtual void FrameEnded(std::span<const u32> video_buffer) = 0;
|
||||
};
|
||||
|
||||
enum class HostMessageID
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <map>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -376,8 +376,8 @@ private:
|
||||
IPCReply SeekContent(u32 uid, const IOCtlVRequest& request);
|
||||
|
||||
// Title information
|
||||
IPCReply GetTitleCount(const std::vector<u64>& titles, const IOCtlVRequest& request);
|
||||
IPCReply GetTitles(const std::vector<u64>& titles, const IOCtlVRequest& request);
|
||||
IPCReply GetTitleCount(std::span<const u64> titles, const IOCtlVRequest& request);
|
||||
IPCReply GetTitles(std::span<const u64> titles, const IOCtlVRequest& request);
|
||||
IPCReply GetOwnedTitleCount(const IOCtlVRequest& request);
|
||||
IPCReply GetOwnedTitles(const IOCtlVRequest& request);
|
||||
IPCReply GetTitleCount(const IOCtlVRequest& request);
|
||||
@@ -416,7 +416,7 @@ private:
|
||||
|
||||
void FinishInit();
|
||||
|
||||
s32 WriteSystemFile(const std::string& path, const std::vector<u8>& data, Ticks ticks = {});
|
||||
s32 WriteSystemFile(const std::string& path, std::span<const u8> data, Ticks ticks = {});
|
||||
s32 WriteLaunchFile(const ES::TMDReader& tmd, Ticks ticks = {});
|
||||
bool BootstrapPPC();
|
||||
|
||||
|
||||
@@ -399,7 +399,7 @@ std::string ESCore::GetContentPath(const u64 title_id, const ES::Content& conten
|
||||
return fmt::format("{}/{:08x}.app", Common::GetTitleContentPath(title_id), content.id);
|
||||
}
|
||||
|
||||
s32 ESDevice::WriteSystemFile(const std::string& path, const std::vector<u8>& data, Ticks ticks)
|
||||
s32 ESDevice::WriteSystemFile(const std::string& path, std::span<const u8> data, Ticks ticks)
|
||||
{
|
||||
auto& fs = GetEmulationKernel().GetFSCore();
|
||||
const std::string tmp_path = "/tmp/" + PathToFileName(path);
|
||||
|
||||
@@ -120,7 +120,7 @@ IPCReply ESDevice::GetTMDStoredContents(const IOCtlVRequest& request)
|
||||
return GetStoredContents(tmd, request);
|
||||
}
|
||||
|
||||
IPCReply ESDevice::GetTitleCount(const std::vector<u64>& titles, const IOCtlVRequest& request)
|
||||
IPCReply ESDevice::GetTitleCount(std::span<const u64> titles, const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(0, 1) || request.io_vectors[0].size != 4)
|
||||
return IPCReply(ES_EINVAL);
|
||||
@@ -132,7 +132,7 @@ IPCReply ESDevice::GetTitleCount(const std::vector<u64>& titles, const IOCtlVReq
|
||||
return IPCReply(IPC_SUCCESS);
|
||||
}
|
||||
|
||||
IPCReply ESDevice::GetTitles(const std::vector<u64>& titles, const IOCtlVRequest& request)
|
||||
IPCReply ESDevice::GetTitles(std::span<const u64> titles, const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 1))
|
||||
return IPCReply(ES_EINVAL);
|
||||
|
||||
@@ -372,7 +372,7 @@ IPCReply ESDevice::ImportContentData(Context& context, const IOCtlVRequest& requ
|
||||
return IPCReply(m_core.ImportContentData(context, content_fd, data_start, data_size));
|
||||
}
|
||||
|
||||
static bool CheckIfContentHashMatches(const std::vector<u8>& content, const ES::Content& info)
|
||||
static bool CheckIfContentHashMatches(std::span<const u8> content, const ES::Content& info)
|
||||
{
|
||||
return Common::SHA1::CalculateDigest(content.data(), info.size) == info.sha1;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ void ARCUnpacker::Reset()
|
||||
m_whole_file.clear();
|
||||
}
|
||||
|
||||
void ARCUnpacker::AddBytes(const std::vector<u8>& bytes)
|
||||
void ARCUnpacker::AddBytes(std::span<const u8> bytes)
|
||||
{
|
||||
m_whole_file.insert(m_whole_file.end(), bytes.begin(), bytes.end());
|
||||
}
|
||||
@@ -244,7 +244,7 @@ std::optional<IPCReply> WFSIDevice::IOCtl(const IOCtlRequest& request)
|
||||
"IOCTL_WFSI_IMPORT_CONTENT_END";
|
||||
INFO_LOG_FMT(IOS_WFS, "{}", ioctl_name);
|
||||
|
||||
const auto callback = [this](const std::string& filename, const std::vector<u8>& bytes) {
|
||||
const auto callback = [this](const std::string& filename, std::span<const u8> bytes) {
|
||||
INFO_LOG_FMT(IOS_WFS, "Extract: {} ({} bytes)", filename, bytes.size());
|
||||
|
||||
const std::string path = WFS::NativePath(m_base_extract_path + '/' + filename);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -22,9 +23,9 @@ public:
|
||||
ARCUnpacker() { Reset(); }
|
||||
void Reset();
|
||||
|
||||
void AddBytes(const std::vector<u8>& bytes);
|
||||
void AddBytes(std::span<const u8> bytes);
|
||||
|
||||
using WriteCallback = std::function<void(const std::string&, const std::vector<u8>&)>;
|
||||
using WriteCallback = std::function<void(const std::string&, std::span<const u8>)>;
|
||||
void Extract(const WriteCallback& callback);
|
||||
|
||||
private:
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
@@ -89,7 +88,7 @@ public:
|
||||
virtual void OnIndexRefreshFailed(std::string error) = 0;
|
||||
|
||||
virtual void ShowChunkedProgressDialog(const std::string& title, u64 data_size,
|
||||
const std::vector<int>& players) = 0;
|
||||
std::span<const int> players) = 0;
|
||||
virtual void HideChunkedProgressDialog() = 0;
|
||||
virtual void SetChunkedProgress(int pid, u64 progress) = 0;
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ bool CompressFolderIntoPacket(const std::string& folder_path, sf::Packet& packet
|
||||
return CompressFolderIntoPacketInternal(File::ScanDirectoryTree(folder_path, true), packet);
|
||||
}
|
||||
|
||||
bool CompressBufferIntoPacket(const std::vector<u8>& in_buffer, sf::Packet& packet)
|
||||
bool CompressBufferIntoPacket(std::span<const u8> in_buffer, sf::Packet& packet)
|
||||
{
|
||||
const u64 size = in_buffer.size();
|
||||
packet << size;
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
#include <SFML/Network/Packet.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -22,7 +22,7 @@ constexpr std::chrono::milliseconds PEER_TIMEOUT = 30s;
|
||||
|
||||
bool CompressFileIntoPacket(const std::string& file_path, sf::Packet& packet);
|
||||
bool CompressFolderIntoPacket(const std::string& folder_path, sf::Packet& packet);
|
||||
bool CompressBufferIntoPacket(const std::vector<u8>& in_buffer, sf::Packet& packet);
|
||||
bool CompressBufferIntoPacket(std::span<const u8> in_buffer, sf::Packet& packet);
|
||||
bool DecompressPacketIntoFile(sf::Packet& packet, const std::string& file_path);
|
||||
bool DecompressPacketIntoFolder(sf::Packet& packet, const std::string& folder_path);
|
||||
std::optional<std::vector<u8>> DecompressPacketIntoBuffer(sf::Packet& packet);
|
||||
|
||||
@@ -149,7 +149,7 @@ void LoadPatchSection(const std::string& section, std::vector<Patch>* patches,
|
||||
}
|
||||
}
|
||||
|
||||
void SavePatchSection(Common::IniFile* local_ini, const std::vector<Patch>& patches)
|
||||
void SavePatchSection(Common::IniFile* local_ini, std::span<const Patch> patches)
|
||||
{
|
||||
std::vector<std::string> lines;
|
||||
std::vector<std::string> lines_enabled;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -53,7 +54,7 @@ std::optional<PatchEntry> DeserializeLine(std::string line);
|
||||
std::string SerializeLine(const PatchEntry& entry);
|
||||
void LoadPatchSection(const std::string& section, std::vector<Patch>* patches,
|
||||
const Common::IniFile& globalIni, const Common::IniFile& localIni);
|
||||
void SavePatchSection(Common::IniFile* local_ini, const std::vector<Patch>& patches);
|
||||
void SavePatchSection(Common::IniFile* local_ini, std::span<const Patch> patches);
|
||||
void LoadPatches();
|
||||
|
||||
void AddMemoryPatch(std::size_t index);
|
||||
|
||||
@@ -267,7 +267,7 @@ struct SlotWithTimestamp
|
||||
} // namespace
|
||||
|
||||
// Returns first slot number (1-based indexing) not in the vector.
|
||||
static std::optional<int> GetEmptySlot(const std::vector<SlotWithTimestamp>& used_slots)
|
||||
static std::optional<int> GetEmptySlot(std::span<const SlotWithTimestamp> used_slots)
|
||||
{
|
||||
for (int i = 1; i <= int(NUM_STATES); ++i)
|
||||
{
|
||||
|
||||
@@ -346,7 +346,7 @@ private:
|
||||
};
|
||||
|
||||
Response GetSystemTitles();
|
||||
Response ParseTitlesResponse(const std::vector<u8>& response) const;
|
||||
Response ParseTitlesResponse(std::span<const u8> response) const;
|
||||
bool ShouldInstallTitle(const TitleInfo& title);
|
||||
|
||||
UpdateResult InstallTitleFromNUS(const std::string& prefix_url, const TitleInfo& title,
|
||||
@@ -371,7 +371,7 @@ OnlineSystemUpdater::OnlineSystemUpdater(UpdateCallback update_callback, const s
|
||||
}
|
||||
|
||||
OnlineSystemUpdater::Response
|
||||
OnlineSystemUpdater::ParseTitlesResponse(const std::vector<u8>& response) const
|
||||
OnlineSystemUpdater::ParseTitlesResponse(std::span<const u8> response) const
|
||||
{
|
||||
pugi::xml_document doc;
|
||||
pugi::xml_parse_result result = doc.load_buffer(response.data(), response.size());
|
||||
|
||||
Reference in new issue
Block a user