From 269af11eb438a0c87922f1218aa17fe03d7e6f61 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Thu, 19 Nov 2020 21:30:12 +0100 Subject: [PATCH] Added enum support back --- include/lang/pattern_data.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/lang/pattern_data.hpp b/include/lang/pattern_data.hpp index 0c6f91d42..e817612aa 100644 --- a/include/lang/pattern_data.hpp +++ b/include/lang/pattern_data.hpp @@ -364,7 +364,24 @@ namespace hex::lang { : PatternData(Type::Enum, offset, size, name, color), m_enumName(enumName), m_enumValues(enumValues) { } void createEntry(prv::Provider* &provider) override { + u64 value = 0; + provider->read(this->getOffset(), &value, this->getSize()); + std::string valueString = this->m_enumName + "::"; + + bool foundValue = false; + for (auto &[entryValue, entryName] : this->m_enumValues) { + if (value == entryValue) { + valueString += entryName; + foundValue = true; + break; + } + } + + if (!foundValue) + valueString += "???"; + + this->createDefaultEntry(hex::format("%s (0x0*lx)", valueString.c_str(), this->getSize() * 2, value)); } std::string getTypeName() override {