fix: fill structs in runtime block that are not matching structure

This commit is contained in:
Jan
2025-06-03 22:01:43 +01:00
parent 469ea01767
commit 4bb8120d77

View File

@ -1129,7 +1129,7 @@ namespace
} }
} }
void LoadMember_ArrayPointer(const StructureInformation* info, const MemberInformation* member, const DeclarationModifierComputations& modifier) const void LoadMember_ArrayPointer(const StructureInformation* info, const MemberInformation* member, const DeclarationModifierComputations& modifier)
{ {
const MemberComputations computations(member); const MemberComputations computations(member);
if (member->m_type && !member->m_type->m_is_leaf && !computations.IsInRuntimeBlock()) if (member->m_type && !member->m_type->m_is_leaf && !computations.IsInRuntimeBlock())
@ -1151,6 +1151,20 @@ namespace
LINE(MakeCustomActionCall(member->m_post_load_action.get())) LINE(MakeCustomActionCall(member->m_post_load_action.get()))
} }
} }
else if (member->m_type && !member->m_type->m_has_matching_cross_platform_structure && computations.IsInRuntimeBlock())
{
LINEF("const auto runtimeArraySize = static_cast<size_t>({0});", MakeEvaluation(modifier.GetArrayPointerCountEvaluation()))
LINEF("const auto runtimeFill = m_stream.LoadWithFill({0} * runtimeArraySize);", member->m_member->m_type_declaration->m_type->GetSize())
LINE("for (auto i = 0uz; i < runtimeArraySize; i++)")
LINE("{")
m_intendation++;
LINEF("{0} = &{1}[i];", MakeTypeVarName(member->m_member->m_type_declaration->m_type), MakeMemberAccess(info, member, modifier))
LINEF("FillStruct_{0}(runtimeFill.AtOffset(i * {1}));",
MakeSafeTypeName(member->m_member->m_type_declaration->m_type),
member->m_member->m_type_declaration->m_type->GetSize())
m_intendation--;
LINE("}")
}
else else
{ {
LINEF("m_stream.Load<{0}{1}>({2}, {3});", LINEF("m_stream.Load<{0}{1}>({2}, {3});",
@ -1310,6 +1324,13 @@ namespace
LINE(MakeCustomActionCall(member->m_post_load_action.get())) LINE(MakeCustomActionCall(member->m_post_load_action.get()))
} }
} }
else if (member->m_type && !member->m_type->m_has_matching_cross_platform_structure && computations.IsInRuntimeBlock())
{
LINEF("{0} = {1};", MakeTypeVarName(member->m_member->m_type_declaration->m_type), MakeMemberAccess(info, member, modifier))
LINEF("FillStruct_{0}(m_stream.LoadWithFill({1}));",
MakeSafeTypeName(member->m_member->m_type_declaration->m_type),
member->m_member->m_type_declaration->m_type->GetSize())
}
else else
{ {
LINEF("m_stream.Load<{0}{1}>({2});", LINEF("m_stream.Load<{0}{1}>({2});",