mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-09-18 22:47:25 +00:00
chore: detect structs that differ on different architectures
* and exclude them from assetstructtests
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "Parsing/Impl/ParserFilesystemStream.h"
|
||||
#include "Parsing/PostProcessing/CreateMemberInformationPostProcessor.h"
|
||||
#include "Parsing/PostProcessing/CreateStructureInformationPostProcessor.h"
|
||||
#include "Parsing/PostProcessing/CrossPlatformStructurePostProcessor.h"
|
||||
#include "Parsing/PostProcessing/IPostProcessor.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -67,6 +68,7 @@ void HeaderFileReader::SetupPostProcessors()
|
||||
// Order is important
|
||||
m_post_processors.emplace_back(std::make_unique<CreateStructureInformationPostProcessor>());
|
||||
m_post_processors.emplace_back(std::make_unique<CreateMemberInformationPostProcessor>());
|
||||
m_post_processors.emplace_back(std::make_unique<CrossPlatformStructurePostProcessor>());
|
||||
}
|
||||
|
||||
bool HeaderFileReader::ReadHeaderFile(IDataRepository* repository)
|
||||
|
@@ -0,0 +1,58 @@
|
||||
#include "CrossPlatformStructurePostProcessor.h"
|
||||
|
||||
#include "Domain/Definition/PointerDeclarationModifier.h"
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
namespace
|
||||
{
|
||||
bool CalculateHasMatchingCrossPlatformStructure(std::unordered_set<const void*>& visitedStructures, StructureInformation* info)
|
||||
{
|
||||
if (visitedStructures.find(info) != visitedStructures.end())
|
||||
return info->m_has_matching_cross_platform_structure;
|
||||
|
||||
visitedStructures.emplace(info);
|
||||
|
||||
for (const auto& member : info->m_ordered_members)
|
||||
{
|
||||
for (const auto& modifier : member->m_member->m_type_declaration->m_declaration_modifiers)
|
||||
{
|
||||
if (modifier->GetType() == DeclarationModifierType::POINTER)
|
||||
{
|
||||
info->m_has_matching_cross_platform_structure = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (member->m_type != nullptr && member->m_type != info && !CalculateHasMatchingCrossPlatformStructure(visitedStructures, member->m_type))
|
||||
{
|
||||
info->m_has_matching_cross_platform_structure = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
info->m_has_matching_cross_platform_structure = true;
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool CrossPlatformStructurePostProcessor::PostProcess(IDataRepository* repository)
|
||||
{
|
||||
const auto& allInfos = repository->GetAllStructureInformation();
|
||||
|
||||
if (repository->GetArchitecture() == OWN_ARCHITECTURE)
|
||||
{
|
||||
for (const auto& info : allInfos)
|
||||
info->m_has_matching_cross_platform_structure = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::unordered_set<const void*> visitedStructures;
|
||||
for (const auto& info : allInfos)
|
||||
{
|
||||
CalculateHasMatchingCrossPlatformStructure(visitedStructures, info);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "IPostProcessor.h"
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
class CrossPlatformStructurePostProcessor final : public IPostProcessor
|
||||
{
|
||||
public:
|
||||
bool PostProcess(IDataRepository* repository) override;
|
||||
};
|
Reference in New Issue
Block a user