Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/Core/Common/Assembler/GekkoLexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ void Lexer::EatAndReset()
SetIdentifierMatchRule(IdentifierMatchRule::Typical);
}

std::optional<std::string_view> Lexer::RunDfa(const std::vector<DfaNode>& dfa) const
std::optional<std::string_view> Lexer::RunDfa(std::span<const DfaNode> dfa) const
{
size_t dfa_index = 0;
bool transition_found;
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Common/Assembler/GekkoLexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <array>
#include <deque>
#include <optional>
#include <span>
#include <string_view>
#include <vector>

Expand Down Expand Up @@ -166,7 +167,7 @@ class Lexer
}

private:
std::optional<std::string_view> RunDfa(const std::vector<DfaNode>& dfa) const;
std::optional<std::string_view> RunDfa(std::span<const DfaNode> dfa) const;
void SkipWs() const;
void FeedbackTokens() const;
bool IdentifierHeadExtra(char h) const;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Common/Debug/Watches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void Watches::RemoveWatch(std::size_t index)
m_watches.erase(m_watches.begin() + index);
}

void Watches::LoadFromStrings(const std::vector<std::string>& watches)
void Watches::LoadFromStrings(std::span<const std::string> watches)
{
for (const std::string& watch : watches)
{
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Common/Debug/Watches.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <cstddef>
#include <span>
#include <string>
#include <vector>

Expand Down Expand Up @@ -42,7 +43,7 @@ class Watches
void DisableWatch(std::size_t index);
bool HasEnabledWatch(u32 address) const;
void RemoveWatch(std::size_t index);
void LoadFromStrings(const std::vector<std::string>& watches);
void LoadFromStrings(std::span<const std::string> watches);
std::vector<std::string> SaveToStrings() const;
void Clear();

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Common/HttpRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ HttpRequest::Response HttpRequest::Get(const std::string& url, const Headers& he
return m_impl->Fetch(url, Impl::Method::GET, headers, nullptr, 0, codes);
}

HttpRequest::Response HttpRequest::Post(const std::string& url, const std::vector<u8>& payload,
HttpRequest::Response HttpRequest::Post(const std::string& url, std::span<const u8> payload,
const Headers& headers, AllowedReturnCodes codes)
{
return m_impl->Fetch(url, Impl::Method::POST, headers, payload.data(), payload.size(), codes);
}

HttpRequest::Response HttpRequest::Post(const std::string& url, const std::string& payload,
HttpRequest::Response HttpRequest::Post(const std::string& url, std::string_view payload,
const Headers& headers, AllowedReturnCodes codes)
{
return m_impl->Fetch(url, Impl::Method::POST, headers,
Expand Down
5 changes: 3 additions & 2 deletions Source/Core/Common/HttpRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <optional>
#include <span>
#include <string>
#include <string_view>
#include <vector>

#include "Common/CommonTypes.h"
Expand Down Expand Up @@ -50,9 +51,9 @@ class HttpRequest final
std::string GetHeaderValue(std::string_view name) const;
Response Get(const std::string& url, const Headers& headers = {},
AllowedReturnCodes codes = AllowedReturnCodes::Ok_Only);
Response Post(const std::string& url, const std::vector<u8>& payload, const Headers& headers = {},
Response Post(const std::string& url, std::span<const u8> payload, const Headers& headers = {},
AllowedReturnCodes codes = AllowedReturnCodes::Ok_Only);
Response Post(const std::string& url, const std::string& payload, const Headers& headers = {},
Response Post(const std::string& url, std::string_view payload, const Headers& headers = {},
AllowedReturnCodes codes = AllowedReturnCodes::Ok_Only);

Response PostMultiform(const std::string& url, std::span<Multiform> multiform,
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Common/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ DHCPBody::DHCPBody(u32 transaction, const MACAddress& client_address, u32 new_ip

DHCPPacket::DHCPPacket() = default;

DHCPPacket::DHCPPacket(const std::vector<u8>& data)
DHCPPacket::DHCPPacket(std::span<const u8> data)
{
if (data.size() < DHCPBody::SIZE)
return;
Expand All @@ -489,7 +489,7 @@ DHCPPacket::DHCPPacket(const std::vector<u8>& data)
}
}

void DHCPPacket::AddOption(u8 fnc, const std::vector<u8>& params)
void DHCPPacket::AddOption(u8 fnc, std::span<const u8> params)
{
if (params.size() > 255)
return;
Expand All @@ -507,7 +507,7 @@ std::vector<u8> DHCPPacket::Build() const
{
result.insert(result.end(), opt.begin(), opt.end());
}
const std::vector<u8> no_option = {255, 0, 0, 0};
constexpr auto no_option = std::to_array<u8>({255, 0, 0, 0});
result.insert(result.end(), no_option.begin(), no_option.end());

return result;
Expand Down
10 changes: 8 additions & 2 deletions Source/Core/Common/Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#pragma once

#include <array>
#include <initializer_list>
#include <optional>
#include <span>
#include <string>
#include <string_view>
#include <type_traits>
Expand Down Expand Up @@ -183,8 +185,12 @@ static_assert(sizeof(DHCPBody) == DHCPBody::SIZE);
struct DHCPPacket
{
DHCPPacket();
DHCPPacket(const std::vector<u8>& data);
void AddOption(u8 fnc, const std::vector<u8>& params);
DHCPPacket(std::span<const u8> data);
void AddOption(u8 fnc, std::span<const u8> params);
void AddOption(u8 fnc, std::initializer_list<u8> params)
{
AddOption(fnc, {params.begin(), params.end()});
}
std::vector<u8> Build() const;

DHCPBody body;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/Boot/DolReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/Boot/DolReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class DolReader final : public BootExecutableReader
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;
};
4 changes: 2 additions & 2 deletions Source/Core/Core/CheatSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/CheatSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ 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);

// Refresh the values for the given results in the given address space, only keeping values for
// 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);

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/Config/MainSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/Config/MainSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 6 additions & 5 deletions Source/Core/Core/DSP/DSPCodeUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Core/DSP/DSPCodeUtil.h"

#include <algorithm>
#include <span>
#include <string>
#include <vector>

Expand Down Expand Up @@ -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;
Expand All @@ -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());
Expand Down Expand Up @@ -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;
Expand All @@ -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');

Expand Down Expand Up @@ -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);

Expand Down
9 changes: 5 additions & 4 deletions Source/Core/Core/DSP/DSPCodeUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <optional>
#include <span>
#include <string>
#include <vector>

Expand All @@ -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
5 changes: 2 additions & 3 deletions Source/Core/Core/DSP/DSPDisassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <limits>
#include <string>
#include <utility>
#include <vector>

#include <fmt/format.h>

Expand All @@ -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())
{
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Core/DSP/DSPDisassembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#pragma once

#include <span>
#include <string>
#include <vector>

#include "Common/CommonTypes.h"

Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/Debugger/DebugInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <cstddef>
#include <optional>
#include <span>
#include <string>
#include <vector>

Expand Down Expand Up @@ -40,7 +41,7 @@ class DebugInterface
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;

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/Debugger/PPCDebugInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/Debugger/PPCDebugInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class PPCDebugInterface final : public Core::DebugInterface
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;

Expand Down
3 changes: 1 addition & 2 deletions Source/Core/Core/FifoPlayer/FifoDataFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading