2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-07-05 18:51:55 +00:00

Add base for calculation sizes of structs for StructuredDataDef

This commit is contained in:
Jan
2022-03-22 14:12:48 +01:00
parent c131c58bbe
commit 77420495f6
4 changed files with 190 additions and 1 deletions

View File

@ -3,6 +3,7 @@
#include <sstream>
#include "Parsing/Simple/Matcher/SimpleMatcherFactory.h"
#include "StructuredDataDef/Parsing/StructuredDataDefSizeCalculator.h"
namespace sdd::def_scope_sequences
{
@ -223,6 +224,18 @@ namespace sdd::def_scope_sequences
}
}
static void CalculateSizesAndOffsetsForDef(const StructuredDataDefParserState* state)
{
try
{
StructuredDataDefSizeCalculator::CalculateSizesAndOffsetsForDef(*state->m_current_def);
}
catch(SizeCalculationException& e)
{
throw ParsingException(TokenPos(), e.Message());
}
}
static void SetDefSizeFromRootStruct(const StructuredDataDefParserState* state)
{
if (state->m_current_def->m_root_type.m_category == CommonStructuredDataTypeCategory::STRUCT
@ -242,7 +255,7 @@ namespace sdd::def_scope_sequences
CreateDefaultStructWhenNoStructsSpecified(state);
EnsureAllUsedTypesHaveBeenDefined(state);
ReplaceUndefinedTypeReference(state);
// TODO: Calculate struct sizes and property offsets
CalculateSizesAndOffsetsForDef(state);
SetDefSizeFromRootStruct(state);
if (!state->m_checksum_overriden)