And a few more string_view conversions.

This commit is contained in:
Stephen Anthony 2022-12-21 20:36:35 -03:30
parent ff0bbf525f
commit 313f7dd914
5 changed files with 16 additions and 16 deletions

View File

@ -202,16 +202,16 @@ uInt8 CartridgeE7Widget::internalRamGetValue(int addr)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeE7Widget::getSpotLower(int idx)
string_view CartridgeE7Widget::getSpotLower(int idx) const
{
static constexpr std::array<const char*, 4> spot_lower_8K = {
static constexpr std::array<string_view, 4> spot_lower_8K = {
"#0 - ROM ($FFE4)", "#1 - ROM ($FFE5)", "#2 - ROM ($FFE6)", "#3 - RAM ($FFE7)"
};
static constexpr std::array<const char*, 6> spot_lower_12K = {
static constexpr std::array<string_view, 6> spot_lower_12K = {
"#0 - ROM ($FFE0)", "#1 - ROM ($FFE1)",
"#2 - ROM ($FFE4)", "#3 - ROM ($FFE5)", "#4 - ROM ($FFE6)", "#5 - RAM ($FFE7)"
};
static constexpr std::array<const char*, 8> spot_lower_16K = {
static constexpr std::array<string_view, 8> spot_lower_16K = {
"#0 - ROM ($FFE0)", "#1 - ROM ($FFE1)", "#2 - ROM ($FFE2)", "#3 - ROM ($FFE3)",
"#4 - ROM ($FFE4)", "#5 - ROM ($FFE5)", "#6 - ROM ($FFE6)", "#7 - RAM ($FFE7)"
};
@ -225,12 +225,11 @@ const char* CartridgeE7Widget::getSpotLower(int idx)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeE7Widget::getSpotUpper(int idx)
string_view CartridgeE7Widget::getSpotUpper(int idx) const
{
static constexpr std::array<const char*, 4> spot_upper = {
static constexpr std::array<string_view, 4> spot_upper = {
"#0 - RAM ($FFE8)", "#1 - RAM ($FFE9)", "#2 - RAM ($FFEA)", "#3 - RAM ($FFEB)"
};
return spot_upper[idx];
}

View File

@ -54,8 +54,8 @@ class CartridgeE7Widget : public CartDebugWidget
protected:
void initialize(GuiObject* boss, const CartridgeE7& cart,
const ostringstream& info);
const char* getSpotLower(int idx);
static const char* getSpotUpper(int idx);
string_view getSpotLower(int idx) const;
string_view getSpotUpper(int idx) const;
private:
void saveOldState() override;

View File

@ -243,7 +243,7 @@ string Thumbulator::run(uInt32& cycles, bool irqDrivenAudio)
#ifndef UNSAFE_OPTIMIZATIONS
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Thumbulator::fatalError(const char* opcode, uInt32 v1, const char* msg)
int Thumbulator::fatalError(string_view opcode, uInt32 v1, string_view msg)
{
statusMsg << "Thumb ARM emulation fatal error: " << endl
<< opcode << "(" << Base::HEX8 << v1 << "), " << msg << endl;
@ -254,11 +254,12 @@ int Thumbulator::fatalError(const char* opcode, uInt32 v1, const char* msg)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Thumbulator::fatalError(const char* opcode, uInt32 v1, uInt32 v2,
const char* msg)
int Thumbulator::fatalError(string_view opcode, uInt32 v1, uInt32 v2,
string_view msg)
{
statusMsg << "Thumb ARM emulation fatal error: " << endl
<< opcode << "(" << Base::HEX8 << v1 << "," << v2 << "), " << msg << endl;
<< opcode << "(" << Base::HEX8 << v1 << "," << v2 << "), " << msg
<< endl;
dump_regs();
if(trapOnFatal)
throw runtime_error(statusMsg.str());

View File

@ -239,8 +239,8 @@ class Thumbulator
// Throw a runtime_error exception containing an error referencing the
// given message and variables
// Note that the return value is never used in these methods
int fatalError(const char* opcode, uInt32 v1, const char* msg);
int fatalError(const char* opcode, uInt32 v1, uInt32 v2, const char* msg);
int fatalError(string_view opcode, uInt32 v1, string_view msg);
int fatalError(string_view opcode, uInt32 v1, uInt32 v2, string_view msg);
void dump_counters() const;
void dump_regs();

View File

@ -77,7 +77,7 @@ string FSNodeWINDOWS::getShortPath() const
if (home != "" && BSPF::startsWithIgnoreCase(_path, home))
{
string path = "~";
const char* const offset = _path.c_str() + home.length();
const char* const offset = _path.c_str() + home.size();
if (*offset != FSNode::PATH_SEPARATOR)
path += FSNode::PATH_SEPARATOR;
path += offset;