mirror of
https://github.com/cemu-project/Cemu.git
synced 2026-06-23 13:03:05 -05:00
debugger: use ConvertString instead
This commit is contained in:
parent
4d5be7c16e
commit
369d786f0e
|
|
@ -1,6 +1,5 @@
|
|||
#include "wxgui/wxgui.h"
|
||||
#include "wxgui/debugger/DumpCtrl.h"
|
||||
#include "wxgui/helpers/wxHelpers.h"
|
||||
#include "Cafe/OS/RPL/rpl.h"
|
||||
#include "Cafe/OS/RPL/rpl_structs.h"
|
||||
#include "Cafe/HW/Espresso/Debugger/Debugger.h"
|
||||
|
|
@ -403,22 +402,17 @@ bool DumpCtrl::WriteNumericDialog(uint32 address)
|
|||
if (dialog.ShowModal() != wxID_OK)
|
||||
return false;
|
||||
|
||||
const std::optional<T> opt = parse_numeric<T>(dialog.GetValue());
|
||||
|
||||
if (!opt.has_value())
|
||||
{
|
||||
wxMessageBox(_("Invalid value."), _("Error"), wxOK | wxICON_ERROR, this);
|
||||
return false;
|
||||
}
|
||||
|
||||
const T newValue = ConvertString<T>(dialog.GetValue().ToStdString());
|
||||
|
||||
if constexpr (std::is_same<T, uint8>::value)
|
||||
memory_writeU8(address, opt.value());
|
||||
memory_writeU8(address, newValue);
|
||||
else if constexpr (std::is_same<T, uint16>::value)
|
||||
memory_writeU16(address, opt.value());
|
||||
memory_writeU16(address, newValue);
|
||||
else if constexpr (std::is_same<T, uint32>::value)
|
||||
memory_writeU32(address, opt.value());
|
||||
memory_writeU32(address, newValue);
|
||||
else if constexpr (std::is_same<T, float>::value)
|
||||
memory_writeFloat(address, opt.value());
|
||||
memory_writeFloat(address, newValue);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#include "wxgui/wxgui.h"
|
||||
#include "wxgui/debugger/RegisterWindow.h"
|
||||
#include "wxgui/helpers/wxHelpers.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
|
@ -9,6 +8,7 @@
|
|||
#include "Cafe/OS/RPL/rpl.h"
|
||||
#include "Cafe/OS/RPL/rpl_structs.h"
|
||||
#include "Cafe/HW/Espresso/EspressoISA.h"
|
||||
#include "util/helpers/helpers.h"
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
@ -359,15 +359,14 @@ void RegisterWindow::OnMouseDClickEvent(wxMouseEvent& event)
|
|||
wxTextEntryDialog set_value_dialog(this, _("Enter a new value."), wxString::Format(_("Set R%d value"), register_index), wxString::Format("0x%08x", register_value));
|
||||
if (set_value_dialog.ShowModal() == wxID_OK)
|
||||
{
|
||||
const std::optional<uint32> opt = parse_numeric<uint32>(set_value_dialog.GetValue());
|
||||
if (opt.has_value())
|
||||
const uint32 value = ConvertString<uint32>(set_value_dialog.GetValue().ToStdString());
|
||||
|
||||
if (debugSession = debugger_lockDebugSession(); debugSession)
|
||||
{
|
||||
if (debugSession = debugger_lockDebugSession(); debugSession)
|
||||
{
|
||||
debugSession->gpr[register_index] = opt.value();
|
||||
debugger_unlockDebugSession(debugSession);
|
||||
}
|
||||
debugSession->gpr[register_index] = value;
|
||||
debugger_unlockDebugSession(debugSession);
|
||||
}
|
||||
|
||||
OnUpdateView();
|
||||
}
|
||||
return;
|
||||
|
|
@ -380,15 +379,14 @@ void RegisterWindow::OnMouseDClickEvent(wxMouseEvent& event)
|
|||
wxTextEntryDialog set_value_dialog(this, _("Enter a new value."), wxString::Format(_("Set FP0_%d value"), register_index), wxString::Format("%lf", register_value));
|
||||
if (set_value_dialog.ShowModal() == wxID_OK)
|
||||
{
|
||||
const std::optional<double> opt = parse_numeric<double>(set_value_dialog.GetValue());
|
||||
if (opt.has_value())
|
||||
const double value = ConvertString<double>(set_value_dialog.GetValue().ToStdString());
|
||||
|
||||
if (debugSession = debugger_lockDebugSession(); debugSession)
|
||||
{
|
||||
if (debugSession = debugger_lockDebugSession(); debugSession)
|
||||
{
|
||||
debugSession->fpr[register_index].fp0 = opt.value();
|
||||
debugger_unlockDebugSession(debugSession);
|
||||
}
|
||||
debugSession->fpr[register_index].fp0 = value;
|
||||
debugger_unlockDebugSession(debugSession);
|
||||
}
|
||||
|
||||
OnUpdateView();
|
||||
}
|
||||
|
||||
|
|
@ -402,15 +400,14 @@ void RegisterWindow::OnMouseDClickEvent(wxMouseEvent& event)
|
|||
wxTextEntryDialog set_value_dialog(this, _("Enter a new value."), wxString::Format(_("Set FP1_%d value"), register_index), wxString::Format("%lf", register_value));
|
||||
if (set_value_dialog.ShowModal() == wxID_OK)
|
||||
{
|
||||
const std::optional<double> opt = parse_numeric<double>(set_value_dialog.GetValue());
|
||||
if (opt.has_value())
|
||||
const double value = ConvertString<double>(set_value_dialog.GetValue().ToStdString());
|
||||
|
||||
if (debugSession = debugger_lockDebugSession(); debugSession)
|
||||
{
|
||||
if (debugSession = debugger_lockDebugSession(); debugSession)
|
||||
{
|
||||
debugSession->fpr[register_index].fp1 = opt.value();
|
||||
debugger_unlockDebugSession(debugSession);
|
||||
}
|
||||
debugSession->fpr[register_index].fp1 = value;
|
||||
debugger_unlockDebugSession(debugSession);
|
||||
}
|
||||
|
||||
OnUpdateView();
|
||||
}
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@
|
|||
#include <wx/listbase.h>
|
||||
#include <wx/string.h>
|
||||
|
||||
#include <concepts>
|
||||
|
||||
template <>
|
||||
struct fmt::formatter<wxString> : formatter<string_view>
|
||||
{
|
||||
|
|
@ -108,23 +106,3 @@ void update_slider_text(wxCommandEvent& event, const wxFormatString& format = "%
|
|||
uint32 fix_raw_keycode(uint32 keycode, uint32 raw_flags);
|
||||
|
||||
WindowSystem::WindowHandleInfo initHandleContextFromWxWidgetsWindow(wxWindow* wxw);
|
||||
|
||||
template <typename T>
|
||||
std::optional<T> parse_numeric(const wxString& text)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (std::is_same<T, float>::value)
|
||||
return std::stof(text.ToStdString());
|
||||
|
||||
else if (std::is_same<T, double>::value)
|
||||
return std::stod(text.ToStdString());
|
||||
|
||||
// it's integral
|
||||
return static_cast<T>(std::stol(text.ToStdString(), nullptr, 0));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user