mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-07-01 16:51:56 +00:00
ZoneCodeGenerator: Implement template code for pointer array methods
This commit is contained in:
@ -58,14 +58,42 @@ if ($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(refere
|
||||
LoadArrayPointer_Condition(context, structure, member, reference) ::= <<
|
||||
$if(member.Condition)$$\\$
|
||||
if($PrintEvaluation(member.Condition)$)
|
||||
|
||||
LoadPointerArrayMethod_PointerCheck(context, type, structure, reusable) ::= <<
|
||||
if (*$TypePtrVarName(type)$)
|
||||
{
|
||||
$LoadArrayPointer_PointerCheck(context, structure, member, reference)$
|
||||
$if(structure && structure.IsAsset)$
|
||||
$LoadPointerArrayMethod_Asset(context, type, structure)$
|
||||
$else$
|
||||
$if(reusable)$
|
||||
if(*$TypePtrVarName(type)$ == PTR_FOLLOWING)
|
||||
{
|
||||
$LoadPointerArrayMethod_Loading(context, type, structure)$
|
||||
}
|
||||
else
|
||||
{
|
||||
*$TypePtrVarName(type)$ = m_stream->ConvertOffsetToPointer(*$TypePtrVarName(type)$);
|
||||
}
|
||||
$else$
|
||||
$LoadPointerArrayMethod_Loading(context, type, structure)$
|
||||
$endif$
|
||||
$endif$
|
||||
}
|
||||
$else$$\\$
|
||||
$LoadArrayPointer_PointerCheck(context, structure, member, reference)$$\\$
|
||||
$endif$
|
||||
>>
|
||||
|
||||
LoadArrayPointer(context, structure, member, reference) ::= <%
|
||||
$LoadArrayPointer_Condition(context, structure, member, reference)$
|
||||
%>
|
||||
LoadPointerArrayMethod(context, type, structure, reusable) ::= <<
|
||||
void $LoaderClassName(context.Asset)$::LoadPtrArray_$SafeTypeName(type)$(const bool atStreamStart, const size_t count)
|
||||
{
|
||||
assert($TypePtrVarName(type)$ != nullptr);
|
||||
|
||||
if(atStreamStart)
|
||||
m_stream->Load<$type.FullName$*>($TypePtrVarName(type)$, count);
|
||||
|
||||
for(size_t index = 0; index < count; index++)
|
||||
{
|
||||
$LoadPointerArrayMethod_PointerCheck(context, type, structure, reusable)$
|
||||
|
||||
$TypePtrVarName(type)$++;
|
||||
}
|
||||
}
|
||||
>>
|
@ -167,13 +167,6 @@ void $LoaderClassName(context.Asset)$::LoadPtr_$structure.Type.Name$(const bool
|
||||
}
|
||||
>>
|
||||
|
||||
LoadPointerArrayMethod(context, type, structure) ::= <<
|
||||
void $LoaderClassName(context.Asset)$::LoadPtrArray_$SafeTypeName(type)$(const bool atStreamStart, const size_t count)
|
||||
{
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
LoadArrayMethod(context, type, structure) ::= <<
|
||||
void $LoaderClassName(context.Asset)$::LoadArray_$type.Name$(const bool atStreamStart, const size_t count)
|
||||
{
|
||||
@ -200,12 +193,12 @@ void $LoaderClassName(context.Asset)$::Load_$structure.Type.Name$(const bool atS
|
||||
|
||||
if(atStreamStart)
|
||||
m_stream->Load<$structure.Type.FullName$>($TypeVarName(structure.Type)$);$\\$
|
||||
$if(structure.Block.IsTemp)$
|
||||
$if(structure.ReferenceFromNonDefaultNormalBlockExists || structure.IsAsset)$
|
||||
|
||||
m_stream->PushBlock($context.DefaultNormalBlock.Name$);$\\$
|
||||
$endif$
|
||||
$structure.OrderedMembers:{member | $LoadMemberIfNeedsTreatment(context, structure, member)$}$
|
||||
$if(structure.Block.IsTemp)$
|
||||
$if(structure.ReferenceFromNonDefaultNormalBlockExists || structure.IsAsset)$
|
||||
|
||||
m_stream->PopBlock();
|
||||
$endif$
|
||||
@ -288,7 +281,7 @@ using namespace $context.Game$;
|
||||
|
||||
$ConstructorMethod(context)$
|
||||
|
||||
$context.UsedTypes:{usedType | $if(usedType.PointerArrayReferenceExists)$$LoadPointerArrayMethod(context, usedType.Type, usedType.Information)$$\n$$\n$$endif$}$
|
||||
$context.UsedTypes:{usedType | $if(usedType.PointerArrayReferenceExists)$$LoadPointerArrayMethod(context, usedType.Type, usedType.Information, usedType.PointerArrayReferenceIsReusable)$$\n$$\n$$endif$}$
|
||||
$context.UsedTypes:{usedType | $if(usedType.ArrayReferenceExists && usedType.Information && !usedType.Information.IsLeaf)$$LoadArrayMethod(context, usedType.Type, usedType.Information)$$\n$$\n$$endif$}$
|
||||
$context.UsedStructures:{usedStructure | $if(!usedStructure.IsLeaf && !usedStructure.IsAsset)$$LoadMethod(context, usedStructure)$$\n$$\n$$endif$}$
|
||||
$LoadMethod(context, context.Asset)$
|
||||
|
Reference in New Issue
Block a user