1
0
mirror of synced 2024-09-24 19:48:25 +02:00

tests: Fixed compile errors

This commit is contained in:
WerWolv 2021-10-03 12:32:58 +02:00
parent 12a8cadcfe
commit 51a98736e8
10 changed files with 34 additions and 25 deletions

View File

@ -1425,7 +1425,7 @@ namespace hex::pl {
literal = pattern->clone();
}
if (auto transformFunc = pattern->getTransformFunction(); transformFunc.has_value()) {
if (auto transformFunc = pattern->getTransformFunction(); transformFunc.has_value() && pattern->getEvaluator() != nullptr) {
auto result = transformFunc->func(evaluator, { literal });
if (!result.has_value())

View File

@ -56,15 +56,21 @@ namespace hex::pl {
class PatternCreationLimiter {
public:
explicit PatternCreationLimiter(Evaluator *evaluator) : m_evaluator(evaluator) {
if (this->m_evaluator == nullptr) return;
this->m_evaluator->patternCreated();
}
PatternCreationLimiter(const PatternCreationLimiter &other) {
if (this->m_evaluator == nullptr) return;
this->m_evaluator = other.m_evaluator;
this->m_evaluator->patternCreated();
}
~PatternCreationLimiter() {
if (this->m_evaluator == nullptr) return;
this->m_evaluator->patternDestroyed();
}

View File

@ -32,6 +32,7 @@ namespace hex {
if (ImGui::Button("hex.common.okay"_lang) || ImGui::IsKeyDown(ImGuiKey_Escape))
ImGui::CloseCurrentPopup();
ImGui::SetWindowPos((SharedData::windowSize - ImGui::GetWindowSize()) / 2, ImGuiCond_Appearing);
ImGui::EndPopup();
}
@ -43,6 +44,7 @@ namespace hex {
if (ImGui::Button("hex.common.okay"_lang) || ImGui::IsKeyDown(ImGuiKey_Escape))
ImGui::CloseCurrentPopup();
ImGui::SetWindowPos((SharedData::windowSize - ImGui::GetWindowSize()) / 2, ImGuiCond_Appearing);
ImGui::EndPopup();
}
@ -56,6 +58,7 @@ namespace hex {
ImGui::CloseCurrentPopup();
}
ImGui::SetWindowPos((SharedData::windowSize - ImGui::GetWindowSize()) / 2, ImGuiCond_Appearing);
ImGui::EndPopup();
}
}

View File

@ -7,13 +7,13 @@ namespace hex::test {
class TestPatternBitfields : public TestPattern {
public:
TestPatternBitfields() : TestPattern("Bitfields") {
auto testBitfield = create<PatternDataBitfield>("TestBitfield", "testBitfield", 0x12, (4 * 4) / 8);
auto testBitfield = create<PatternDataBitfield>("TestBitfield", "testBitfield", 0x12, (4 * 4) / 8, nullptr);
testBitfield->setEndian(std::endian::big);
testBitfield->setFields({
create<PatternDataBitfieldField>("", "a", 0x12, 0, 4),
create<PatternDataBitfieldField>("", "b", 0x12, 4, 4),
create<PatternDataBitfieldField>("", "c", 0x12, 8, 4),
create<PatternDataBitfieldField>("", "d", 0x12, 12, 4)
create<PatternDataBitfieldField>("", "a", 0x12, 0, 4, nullptr),
create<PatternDataBitfieldField>("", "b", 0x12, 4, 4, nullptr),
create<PatternDataBitfieldField>("", "c", 0x12, 8, 4, nullptr),
create<PatternDataBitfieldField>("", "d", 0x12, 12, 4, nullptr)
});
addPattern(testBitfield);

View File

@ -7,7 +7,7 @@ namespace hex::test {
class TestPatternEnums : public TestPattern {
public:
TestPatternEnums() : TestPattern("Enums"){
auto testEnum = create<PatternDataEnum>("TestEnum", "testEnum", 0x08, sizeof(u32));
auto testEnum = create<PatternDataEnum>("TestEnum", "testEnum", 0x08, sizeof(u32), nullptr);
testEnum->setEnumValues({
{ u128(0x0000), "A" },
{ s128(0x0C), "B" },

View File

@ -7,12 +7,12 @@ namespace hex::test {
class TestPatternPadding : public TestPattern {
public:
TestPatternPadding() : TestPattern("Padding") {
auto testStruct = create<PatternDataStruct>("TestStruct", "testStruct", 0x100, sizeof(s32) + 20 + sizeof(u8[0x10]));
auto testStruct = create<PatternDataStruct>("TestStruct", "testStruct", 0x100, sizeof(s32) + 20 + sizeof(u8[0x10]), nullptr);
auto variable = create<PatternDataSigned>("s32", "variable", 0x100, sizeof(s32));
auto padding = create<PatternDataPadding>("padding", "", 0x100 + sizeof(s32), 20);
auto array = create<PatternDataStaticArray>("u8", "array", 0x100 + sizeof(s32) + 20, sizeof(u8[0x10]));
array->setEntries(create<PatternDataUnsigned>("u8", "", 0x100 + sizeof(s32) + 20, sizeof(u8)), 0x10);
auto variable = create<PatternDataSigned>("s32", "variable", 0x100, sizeof(s32), nullptr);
auto padding = create<PatternDataPadding>("padding", "", 0x100 + sizeof(s32), 20, nullptr);
auto array = create<PatternDataStaticArray>("u8", "array", 0x100 + sizeof(s32) + 20, sizeof(u8[0x10]), nullptr);
array->setEntries(create<PatternDataUnsigned>("u8", "", 0x100 + sizeof(s32) + 20, sizeof(u8), nullptr), 0x10);
testStruct->setMembers({ variable, padding, array });

View File

@ -9,13 +9,13 @@ namespace hex::test {
TestPatternPlacement() : TestPattern("Placement") {
// placementVar
{
addPattern(create<PatternDataUnsigned>("u32", "placementVar", 0x00, sizeof(u32)));
addPattern(create<PatternDataUnsigned>("u32", "placementVar", 0x00, sizeof(u32), nullptr));
}
// placementArray
{
auto placementArray = create<PatternDataStaticArray>("u8", "placementArray", 0x10, sizeof(u8) * 10);
placementArray->setEntries(create<PatternDataUnsigned>("u8", "", 0x10, sizeof(u8)), 10);
auto placementArray = create<PatternDataStaticArray>("u8", "placementArray", 0x10, sizeof(u8) * 10, nullptr);
placementArray->setEntries(create<PatternDataUnsigned>("u8", "", 0x10, sizeof(u8), nullptr), 10);
addPattern(placementArray);
}

View File

@ -9,8 +9,8 @@ namespace hex::test {
TestPatternPointers() : TestPattern("Pointers") {
// placementPointer
{
auto placementPointer = create<PatternDataPointer>("", "placementPointer", 0x0C, sizeof(u8));
auto pointedTo = create<PatternDataUnsigned>("u32", "", 0x49, sizeof(u32));
auto placementPointer = create<PatternDataPointer>("", "placementPointer", 0x0C, sizeof(u8), nullptr);
auto pointedTo = create<PatternDataUnsigned>("u32", "", 0x49, sizeof(u32), nullptr);
placementPointer->setPointedAtPattern(pointedTo);
addPattern(placementPointer);
}

View File

@ -7,11 +7,11 @@ namespace hex::test {
class TestPatternStructs : public TestPattern {
public:
TestPatternStructs() : TestPattern("Structs") {
auto testStruct = create<PatternDataStruct>("TestStruct", "testStruct", 0x100, sizeof(s32) + sizeof(u8[0x10]));
auto testStruct = create<PatternDataStruct>("TestStruct", "testStruct", 0x100, sizeof(s32) + sizeof(u8[0x10]), nullptr);
auto variable = create<PatternDataSigned>("s32", "variable", 0x100, sizeof(s32));
auto array = create<PatternDataStaticArray>("u8", "array", 0x100 + sizeof(s32), sizeof(u8[0x10]));
array->setEntries(create<PatternDataUnsigned>("u8", "", 0x100 + sizeof(s32), sizeof(u8)), 0x10);
auto variable = create<PatternDataSigned>("s32", "variable", 0x100, sizeof(s32), nullptr);
auto array = create<PatternDataStaticArray>("u8", "array", 0x100 + sizeof(s32), sizeof(u8[0x10]), nullptr);
array->setEntries(create<PatternDataUnsigned>("u8", "", 0x100 + sizeof(s32), sizeof(u8), nullptr), 0x10);
testStruct->setMembers({ variable, array });

View File

@ -7,11 +7,11 @@ namespace hex::test {
class TestPatternUnions : public TestPattern {
public:
TestPatternUnions() : TestPattern("Unions") {
auto testUnion = create<PatternDataUnion>("TestUnion", "testUnion", 0x200, sizeof(u128));
auto testUnion = create<PatternDataUnion>("TestUnion", "testUnion", 0x200, sizeof(u128), nullptr);
auto array = create<PatternDataStaticArray>("s32", "array", 0x200, sizeof(s32[2]));
array->setEntries(create<PatternDataSigned>("s32", "", 0x200, sizeof(s32)), 2);
auto variable = create<PatternDataUnsigned>("u128", "variable", 0x200, sizeof(u128));
auto array = create<PatternDataStaticArray>("s32", "array", 0x200, sizeof(s32[2]), nullptr);
array->setEntries(create<PatternDataSigned>("s32", "", 0x200, sizeof(s32), nullptr), 2);
auto variable = create<PatternDataUnsigned>("u128", "variable", 0x200, sizeof(u128), nullptr);
testUnion->setMembers({ array, variable });