mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
Fix types referenced via typedef not being accounted for when building rendering context
This commit is contained in:
parent
1164ec1777
commit
7b29d61bb5
@ -45,7 +45,7 @@ RenderingUsedType* RenderingContext::AddUsedType(std::unique_ptr<RenderingUsedTy
|
||||
return result;
|
||||
}
|
||||
|
||||
RenderingUsedType* RenderingContext::GetBaseType(RenderingUsedType* usedType)
|
||||
RenderingUsedType* RenderingContext::GetBaseType(const IDataRepository* repository, MemberComputations* computations, RenderingUsedType* usedType)
|
||||
{
|
||||
if(usedType->m_type->GetType() == DataDefinitionType::TYPEDEF)
|
||||
{
|
||||
@ -54,9 +54,18 @@ RenderingUsedType* RenderingContext::GetBaseType(RenderingUsedType* usedType)
|
||||
while(typedefDefinition->m_type_declaration->m_type->GetType() == DataDefinitionType::TYPEDEF)
|
||||
typedefDefinition = dynamic_cast<const TypedefDefinition*>(typedefDefinition->m_type_declaration->m_type);
|
||||
|
||||
const auto foundUsedType = m_used_types_lookup.find(typedefDefinition);
|
||||
const auto foundUsedType = m_used_types_lookup.find(typedefDefinition->m_type_declaration->m_type);
|
||||
if(foundUsedType == m_used_types_lookup.end())
|
||||
return AddUsedType(std::make_unique<RenderingUsedType>(typedefDefinition->m_type_declaration->m_type, nullptr));
|
||||
{
|
||||
const auto* memberDef = dynamic_cast<const DefinitionWithMembers*>(typedefDefinition->m_type_declaration->m_type);
|
||||
StructureInformation* info = nullptr;
|
||||
if (memberDef)
|
||||
info = repository->GetInformationFor(memberDef);
|
||||
|
||||
auto* addedUsedType = AddUsedType(std::make_unique<RenderingUsedType>(typedefDefinition->m_type_declaration->m_type, info));
|
||||
ScanUsedTypeIfNeeded(repository, computations, usedType);
|
||||
return addedUsedType;
|
||||
}
|
||||
|
||||
return foundUsedType->second.get();
|
||||
}
|
||||
@ -64,7 +73,7 @@ RenderingUsedType* RenderingContext::GetBaseType(RenderingUsedType* usedType)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void RenderingContext::AddMembersToContext(StructureInformation* info)
|
||||
void RenderingContext::AddMembersToContext(const IDataRepository* repository, StructureInformation* info)
|
||||
{
|
||||
for(const auto& member : info->m_ordered_members)
|
||||
{
|
||||
@ -80,7 +89,7 @@ void RenderingContext::AddMembersToContext(StructureInformation* info)
|
||||
else
|
||||
usedType = existingUsedType->second.get();
|
||||
|
||||
auto* baseUsedType = GetBaseType(usedType);
|
||||
auto* baseUsedType = GetBaseType(repository, &computations, usedType);
|
||||
|
||||
if(!computations.IsInRuntimeBlock())
|
||||
{
|
||||
@ -104,20 +113,25 @@ void RenderingContext::AddMembersToContext(StructureInformation* info)
|
||||
usedType->m_pointer_array_reference_is_reusable = true;
|
||||
}
|
||||
|
||||
if(usedType->m_info != nullptr && !StructureComputations(usedType->m_info).IsAsset() && !computations.IsInRuntimeBlock() && !usedType->m_members_loaded)
|
||||
{
|
||||
usedType->m_members_loaded = true;
|
||||
AddMembersToContext(usedType->m_info);
|
||||
}
|
||||
ScanUsedTypeIfNeeded(repository, &computations, usedType);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderingContext::MakeAsset(StructureInformation* asset)
|
||||
void RenderingContext::ScanUsedTypeIfNeeded(const IDataRepository* repository, MemberComputations* computations, RenderingUsedType* usedType)
|
||||
{
|
||||
if (usedType->m_info != nullptr && !StructureComputations(usedType->m_info).IsAsset() && !computations->IsInRuntimeBlock() && !usedType->m_members_loaded)
|
||||
{
|
||||
usedType->m_members_loaded = true;
|
||||
AddMembersToContext(repository, usedType->m_info);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderingContext::MakeAsset(const IDataRepository* repository, StructureInformation* asset)
|
||||
{
|
||||
m_asset = asset;
|
||||
AddUsedType(std::make_unique<RenderingUsedType>(asset->m_definition, asset));
|
||||
|
||||
AddMembersToContext(asset);
|
||||
AddMembersToContext(repository, asset);
|
||||
}
|
||||
|
||||
void RenderingContext::CreateUsedTypeCollections()
|
||||
@ -152,7 +166,7 @@ std::unique_ptr<RenderingContext> RenderingContext::BuildContext(const IDataRepo
|
||||
{
|
||||
auto context = std::make_unique<RenderingContext>(RenderingContext(repository->GetGameName(), repository->GetAllFastFileBlocks()));
|
||||
|
||||
context->MakeAsset(asset);
|
||||
context->MakeAsset(repository, asset);
|
||||
context->CreateUsedTypeCollections();
|
||||
|
||||
return std::move(context);
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "Domain/Computations/MemberComputations.h"
|
||||
#include "Domain/Information/StructureInformation.h"
|
||||
#include "Persistence/IDataRepository.h"
|
||||
|
||||
@ -30,9 +31,10 @@ class RenderingContext
|
||||
RenderingContext(std::string game, std::vector<const FastFileBlock*> fastFileBlocks);
|
||||
|
||||
RenderingUsedType* AddUsedType(std::unique_ptr<RenderingUsedType> usedType);
|
||||
RenderingUsedType* GetBaseType(RenderingUsedType* usedType);
|
||||
void AddMembersToContext(StructureInformation* info);
|
||||
void MakeAsset(StructureInformation* asset);
|
||||
RenderingUsedType* GetBaseType(const IDataRepository* repository, MemberComputations* computations, RenderingUsedType* usedType);
|
||||
void AddMembersToContext(const IDataRepository* repository, StructureInformation* info);
|
||||
void ScanUsedTypeIfNeeded(const IDataRepository* repository, MemberComputations* computations, RenderingUsedType* usedType);
|
||||
void MakeAsset(const IDataRepository* repository, StructureInformation* asset);
|
||||
void CreateUsedTypeCollections();
|
||||
|
||||
public:
|
||||
|
@ -7,7 +7,14 @@ bool CreateMemberInformationPostProcessor::CreateMemberInformationForStructure(I
|
||||
for(const auto& member : structure->m_definition->m_members)
|
||||
{
|
||||
StructureInformation* typeInfo = nullptr;
|
||||
const auto* memberDefinition = dynamic_cast<const DefinitionWithMembers*>(member->m_type_declaration->m_type);
|
||||
const auto* currentDefinition = member->m_type_declaration->m_type;
|
||||
|
||||
while(currentDefinition->GetType() == DataDefinitionType::TYPEDEF)
|
||||
{
|
||||
currentDefinition = dynamic_cast<const TypedefDefinition*>(currentDefinition)->m_type_declaration->m_type;
|
||||
}
|
||||
|
||||
const auto* memberDefinition = dynamic_cast<const DefinitionWithMembers*>(currentDefinition);
|
||||
|
||||
if(memberDefinition != nullptr)
|
||||
typeInfo = repository->GetInformationFor(memberDefinition);
|
||||
|
Loading…
x
Reference in New Issue
Block a user