diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/AddressType.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/AddressType.hpp new file mode 100644 index 00000000..f850b8ba --- /dev/null +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/AddressType.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace Bloom +{ + enum class AddressType: std::uint8_t + { + ABSOLUTE, + RELATIVE, + }; +} diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp index 9136f3f7..15187e9c 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp @@ -7,6 +7,7 @@ #include "src/Targets/TargetMemory.hpp" #include "src/Helpers/DateTime.hpp" +#include "AddressType.hpp" namespace Bloom { @@ -40,7 +41,7 @@ namespace Bloom * See RegionItem::convertRelativeToAbsoluteAddressRange() * See RegionItem::convertAbsoluteToRelativeAddressRange() */ - MemoryRegionAddressInputType addressRangeInputType = MemoryRegionAddressInputType::ABSOLUTE; + AddressType addressRangeInputType = AddressType::ABSOLUTE; /** * This address range will always be in absolute form. Regardless of the value of this->addressRangeType. diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/ExcludedRegionItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/ExcludedRegionItem.cpp index e30cc684..54780228 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/ExcludedRegionItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/ExcludedRegionItem.cpp @@ -43,7 +43,7 @@ namespace Bloom::Widgets ); this->memoryRegion.addressRangeInputType = this->getSelectedAddressInputType(); this->memoryRegion.addressRange = - this->memoryRegion.addressRangeInputType == MemoryRegionAddressInputType::RELATIVE ? + this->memoryRegion.addressRangeInputType == AddressType::RELATIVE ? this->convertRelativeToAbsoluteAddressRange(inputAddressRange) : inputAddressRange; } } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/FocusedRegionItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/FocusedRegionItem.cpp index bf08fdf1..cc3ac15a 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/FocusedRegionItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/FocusedRegionItem.cpp @@ -43,7 +43,7 @@ namespace Bloom::Widgets ); this->memoryRegion.addressRangeInputType = this->getSelectedAddressInputType(); this->memoryRegion.addressRange = - this->memoryRegion.addressRangeInputType == MemoryRegionAddressInputType::RELATIVE ? + this->memoryRegion.addressRangeInputType == AddressType::RELATIVE ? this->convertRelativeToAbsoluteAddressRange(inputAddressRange) : inputAddressRange; auto selectedDataTypeOptionName = this->dataTypeInput->currentData().toString(); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/RegionItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/RegionItem.cpp index 4893b539..9e5c181f 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/RegionItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/RegionItem.cpp @@ -106,10 +106,9 @@ namespace Bloom::Widgets + "0x" + QString::number(memoryAddressRange.endAddress, 16).toUpper() ); - const auto absoluteAddressRange = addressType == MemoryRegionAddressInputType::RELATIVE ? - this->convertRelativeToAbsoluteAddressRange( - TargetMemoryAddressRange(startAddress, endAddress) - ) : TargetMemoryAddressRange(startAddress, endAddress); + const auto absoluteAddressRange = addressType == AddressType::RELATIVE + ? this->convertRelativeToAbsoluteAddressRange(TargetMemoryAddressRange(startAddress, endAddress)) + : TargetMemoryAddressRange(startAddress, endAddress); if (absoluteAddressRange.startAddress < memoryAddressRange.startAddress || absoluteAddressRange.startAddress > memoryAddressRange.endAddress @@ -148,7 +147,7 @@ namespace Bloom::Widgets this->addressTypeInput->addItem(option.text, optionName); } - if (region.addressRangeInputType == MemoryRegionAddressInputType::RELATIVE) { + if (region.addressRangeInputType == AddressType::RELATIVE) { auto relativeAddressRange = this->convertAbsoluteToRelativeAddressRange(region.addressRange); this->addressTypeInput->setCurrentText(RegionItem::addressRangeTypeOptionsByName.at("relative").text); @@ -176,13 +175,13 @@ namespace Bloom::Widgets QObject::connect(this->nameInput, &QLineEdit::textEdited, this, &RegionItem::onNameInputChange); } - MemoryRegionAddressInputType RegionItem::getSelectedAddressInputType() const { + AddressType RegionItem::getSelectedAddressInputType() const { auto selectedAddressTypeOptionName = this->addressTypeInput->currentData().toString(); if (RegionItem::addressRangeTypeOptionsByName.contains(selectedAddressTypeOptionName)) { return RegionItem::addressRangeTypeOptionsByName.at(selectedAddressTypeOptionName).addressType; } - return MemoryRegionAddressInputType::ABSOLUTE; + return AddressType::ABSOLUTE; } TargetMemoryAddressRange RegionItem::convertAbsoluteToRelativeAddressRange( diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/RegionItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/RegionItem.hpp index e9b3cec3..58b18f2d 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/RegionItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/RegionItem.hpp @@ -19,10 +19,12 @@ namespace Bloom::Widgets struct AddressRangeTypeOption { QString text; - MemoryRegionAddressInputType addressType; + AddressType addressType; - AddressRangeTypeOption(const QString& text, MemoryRegionAddressInputType addressType) - : text(text), addressType(addressType) {}; + AddressRangeTypeOption(const QString& text, AddressType addressType) + : text(text) + , addressType(addressType) + {}; }; class RegionItem: public ClickableWidget @@ -64,7 +66,7 @@ namespace Bloom::Widgets TextInput* sizeInput = nullptr; virtual void initFormInputs(); - [[nodiscard]] MemoryRegionAddressInputType getSelectedAddressInputType() const; + [[nodiscard]] AddressType getSelectedAddressInputType() const; Targets::TargetMemoryAddressRange convertAbsoluteToRelativeAddressRange( const Targets::TargetMemoryAddressRange& absoluteAddressRange @@ -84,8 +86,8 @@ namespace Bloom::Widgets static inline const std::map addressRangeTypeOptionsByName = std::map< QString, AddressRangeTypeOption >({ - {"absolute", AddressRangeTypeOption("Absolute", MemoryRegionAddressInputType::ABSOLUTE)}, - {"relative", AddressRangeTypeOption("Relative", MemoryRegionAddressInputType::RELATIVE)}, + {"absolute", AddressRangeTypeOption("Absolute", AddressType::ABSOLUTE)}, + {"relative", AddressRangeTypeOption("Relative", AddressType::RELATIVE)}, }); void onAddressRangeInputChange(); diff --git a/src/ProjectSettings.hpp b/src/ProjectSettings.hpp index 33891151..88157069 100644 --- a/src/ProjectSettings.hpp +++ b/src/ProjectSettings.hpp @@ -54,9 +54,9 @@ namespace Bloom {Targets::TargetMemoryEndianness::BIG, "big"}, }; - static const inline BiMap addressRangeInputTypesByName = { - {MemoryRegionAddressInputType::ABSOLUTE, "absolute"}, - {MemoryRegionAddressInputType::RELATIVE, "relative"}, + static const inline BiMap addressRangeInputTypesByName = { + {AddressType::ABSOLUTE, "absolute"}, + {AddressType::RELATIVE, "relative"}, }; [[nodiscard]] Widgets::TargetMemoryInspectionPaneSettings memoryInspectionPaneSettingsFromJson(