mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-01-13 12:11:50 +00:00
fix: do not fill in runtime block members
This commit is contained in:
@@ -486,16 +486,23 @@ namespace
|
||||
else if (member->m_type && !member->m_type->m_has_matching_cross_platform_structure)
|
||||
{
|
||||
LINEF("const auto fillArraySize = static_cast<size_t>({0});", MakeEvaluation(modifier.GetArrayPointerCountEvaluation()))
|
||||
LINEF("const auto fill = m_stream->WriteWithFill({0} * fillArraySize);", member->m_member->m_type_declaration->m_type->GetSize())
|
||||
LINE("for (auto i = 0uz; i < fillArraySize; i++)")
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
LINEF("{0} = &{1}[i];", MakeTypeVarName(member->m_type->m_definition), MakeMemberAccess(info, member, modifier))
|
||||
LINEF("FillStruct_{0}(fill.AtOffset(i * {1}));",
|
||||
MakeSafeTypeName(member->m_type->m_definition),
|
||||
member->m_member->m_type_declaration->m_type->GetSize())
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
if (!computations.IsInRuntimeBlock())
|
||||
{
|
||||
LINEF("const auto fill = m_stream->WriteWithFill({0} * fillArraySize);", member->m_member->m_type_declaration->m_type->GetSize())
|
||||
LINE("for (auto i = 0uz; i < fillArraySize; i++)")
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
LINEF("{0} = &{1}[i];", MakeTypeVarName(member->m_type->m_definition), MakeMemberAccess(info, member, modifier))
|
||||
LINEF("FillStruct_{0}(fill.AtOffset(i * {1}));",
|
||||
MakeSafeTypeName(member->m_type->m_definition),
|
||||
member->m_member->m_type_declaration->m_type->GetSize())
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
}
|
||||
else
|
||||
{
|
||||
LINEF("m_stream->IncBlockPos({0} * fillArraySize);", member->m_member->m_type_declaration->m_type->GetSize())
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -360,10 +360,12 @@ ZoneStreamFillWriteAccessor::ZoneStreamFillWriteAccessor(void* blockBuffer, cons
|
||||
|
||||
ZoneStreamFillWriteAccessor ZoneStreamFillWriteAccessor::AtOffset(const size_t offset) const
|
||||
{
|
||||
assert(m_block_buffer);
|
||||
return ZoneStreamFillWriteAccessor(static_cast<char*>(m_block_buffer) + offset, m_buffer_size - offset);
|
||||
}
|
||||
|
||||
ZoneOutputOffset ZoneStreamFillWriteAccessor::Offset() const
|
||||
{
|
||||
assert(m_block_buffer);
|
||||
return ZoneOutputOffset(m_block_buffer);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
|
||||
template<typename T> void Fill(const T& value, const size_t offset) const
|
||||
{
|
||||
assert(m_block_buffer);
|
||||
assert(offset + sizeof(T) <= m_buffer_size);
|
||||
|
||||
*reinterpret_cast<T*>(static_cast<char*>(m_block_buffer) + offset) = value;
|
||||
@@ -43,6 +44,7 @@ public:
|
||||
|
||||
template<typename T, size_t S> void FillArray(T (&value)[S], const size_t offset) const
|
||||
{
|
||||
assert(m_block_buffer);
|
||||
assert(offset + sizeof(T) * S <= m_buffer_size);
|
||||
|
||||
std::memcpy(static_cast<char*>(m_block_buffer) + offset, value, sizeof(T) * S);
|
||||
|
||||
Reference in New Issue
Block a user