mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 00:02:55 +00:00
Create default StructuredDataDef struct when none was specified so there is always a root struct
This commit is contained in:
parent
5327ce8ec9
commit
f061ff91f5
@ -101,18 +101,34 @@ namespace sdd::def_scope_sequences
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
void ProcessMatch(StructuredDataDefParserState* state, SequenceResult<SimpleParserValue>& result) const override
|
static void CreateDefaultStructWhenNoStructsSpecified(const StructuredDataDefParserState* state)
|
||||||
{
|
{
|
||||||
assert(state->m_current_enum == nullptr);
|
if (state->m_current_def->m_structs.empty())
|
||||||
assert(state->m_current_struct == nullptr);
|
{
|
||||||
|
state->m_current_def->m_structs.emplace_back(std::make_unique<CommonStructuredDataDefStruct>());
|
||||||
|
state->m_current_def->m_root_type = CommonStructuredDataDefType(CommonStructuredDataDefTypeCategory::STRUCT, 0u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SetDefSizeFromRootStruct(const StructuredDataDefParserState* state)
|
||||||
|
{
|
||||||
if (state->m_current_def->m_root_type.m_category == CommonStructuredDataDefTypeCategory::STRUCT
|
if (state->m_current_def->m_root_type.m_category == CommonStructuredDataDefTypeCategory::STRUCT
|
||||||
&& state->m_current_def->m_root_type.m_info.type_index < state->m_current_def->m_structs.size())
|
&& state->m_current_def->m_root_type.m_info.type_index < state->m_current_def->m_structs.size())
|
||||||
{
|
{
|
||||||
const auto* _struct = state->m_current_def->m_structs[state->m_current_def->m_root_type.m_info.type_index].get();
|
const auto* _struct = state->m_current_def->m_structs[state->m_current_def->m_root_type.m_info.type_index].get();
|
||||||
state->m_current_def->m_size_in_byte = _struct->m_size_in_byte;
|
state->m_current_def->m_size_in_byte = _struct->m_size_in_byte;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void ProcessMatch(StructuredDataDefParserState* state, SequenceResult<SimpleParserValue>& result) const override
|
||||||
|
{
|
||||||
|
assert(state->m_current_enum == nullptr);
|
||||||
|
assert(state->m_current_struct == nullptr);
|
||||||
|
|
||||||
|
CreateDefaultStructWhenNoStructsSpecified(state);
|
||||||
|
SetDefSizeFromRootStruct(state);
|
||||||
|
|
||||||
state->m_current_def = nullptr;
|
state->m_current_def = nullptr;
|
||||||
state->m_def_types_by_name.clear();
|
state->m_def_types_by_name.clear();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user