2021-09-11 21:13:49 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "test_pattern.hpp"
|
|
|
|
|
|
|
|
namespace hex::test {
|
|
|
|
|
|
|
|
class TestPatternStructs : public TestPattern {
|
|
|
|
public:
|
2022-01-24 19:53:17 +00:00
|
|
|
TestPatternStructs() : TestPattern("Structs") {
|
2022-01-29 11:40:49 +00:00
|
|
|
auto testStruct = create<PatternDataStruct>("TestStruct", "testStruct", 0x100, sizeof(i32) + sizeof(u8[0x10]));
|
2021-09-11 21:13:49 +00:00
|
|
|
|
2022-01-29 11:40:49 +00:00
|
|
|
auto variable = create<PatternDataSigned>("s32", "variable", 0x100, sizeof(i32));
|
|
|
|
auto array = create<PatternDataStaticArray>("u8", "array", 0x100 + sizeof(i32), sizeof(u8[0x10]));
|
|
|
|
array->setEntries(create<PatternDataUnsigned>("u8", "", 0x100 + sizeof(i32), sizeof(u8)), 0x10);
|
2021-09-11 21:13:49 +00:00
|
|
|
|
|
|
|
testStruct->setMembers({ variable, array });
|
|
|
|
|
|
|
|
addPattern(testStruct);
|
|
|
|
}
|
|
|
|
~TestPatternStructs() override = default;
|
|
|
|
|
2022-01-24 19:53:17 +00:00
|
|
|
[[nodiscard]] std::string getSourceCode() const override {
|
2021-09-11 21:13:49 +00:00
|
|
|
return R"(
|
|
|
|
struct TestStruct {
|
|
|
|
s32 variable;
|
|
|
|
u8 array[0x10];
|
|
|
|
};
|
|
|
|
|
|
|
|
TestStruct testStruct @ 0x100;
|
|
|
|
)";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|