1
0
mirror of synced 2025-02-12 00:33:00 +01:00
ImHex/tests/include/test_patterns/test_pattern_enums.hpp
WerWolv c051f5d3e7
patterns: Rewrite evaluation engine (#306)
* patterns: Rewrite most of the evaluator to mainly use polymorphism instead of just RTTI

* patterns: Fixed a couple of AST memory leaks

* patterns: Parse string operations correctly

* patterns: Various fixes and cleanup

* patterns: Implement primitive function definitions

Function parameters now need to provide their type in the definition

* patterns: Added function variable definition and assignment

* patterns: Added remaining function statements

* patterns: Added unsized and while-sized arrays

* patterns: Added multi variable declarations to functions

* patterns: Added std::format built-in function

* patterns: Allow passing custom types to functions

* patterns: Added attributes and new "format" attribute

* patterns: Use libfmt for std::print instead of custom version

* patterns: Remove unnecessary string compare function

* pattern: Fix preprocessor directives

* patterns: Fix unit tests

* patterns: Added cast expression

* patterns: Handle endianess in function parameters

* patterns: Added casting to different endian

* patterns: Added 'str' type for functions
2021-09-21 21:29:18 +02:00

38 lines
915 B
C++

#pragma once
#include "test_pattern.hpp"
namespace hex::test {
class TestPatternEnums : public TestPattern {
public:
TestPatternEnums() : TestPattern("Enums"){
auto testEnum = create<PatternDataEnum>("TestEnum", "testEnum", 0x120, sizeof(u32));
testEnum->setEnumValues({
{ u128(0x0000), "A" },
{ s128(0x1234), "B" },
{ u128(0x1235), "C" },
{ u128(0x1236), "D" },
});
addPattern(testEnum);
}
~TestPatternEnums() override = default;
[[nodiscard]]
std::string getSourceCode() const override {
return R"(
enum TestEnum : u32 {
A,
B = 0x1234,
C,
D
};
TestEnum testEnum @ 0x120;
)";
}
};
}