mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-07-01 16:51:56 +00:00
ZoneCodeGenerator: Make members have a block they are being loaded into instead of structures
This commit is contained in:
@ -55,9 +55,43 @@ if ($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(refere
|
||||
}
|
||||
>>
|
||||
|
||||
LoadArrayPointer_Condition(context, structure, member, reference) ::= <<
|
||||
$if(member.Condition)$$\\$
|
||||
if($PrintEvaluation(member.Condition)$)
|
||||
LoadArrayPointer_Block(context, structure, member, reference) ::= <%
|
||||
$if(member.Computations.IsNotDefaultNormalBlock)$
|
||||
m_stream->PushBlock($member.Block.Name$);$\n$
|
||||
$endif$
|
||||
|
||||
$LoadArrayPointer_PointerCheck(context, structure, member, reference)$
|
||||
|
||||
$if(member.Computations.IsNotDefaultNormalBlock)$
|
||||
$\n$m_stream->PopBlock();
|
||||
$endif$
|
||||
%>
|
||||
|
||||
LoadArrayPointer(context, structure, member, reference) ::= <%
|
||||
$LoadArrayPointer_Block(context, structure, member, reference)$
|
||||
%>
|
||||
|
||||
LoadPointerArrayMethod_Loading(context, type, structure) ::= <%
|
||||
*$TypePtrVarName(type)$ = m_stream->Alloc<$type.FullName$>(alignof($type.FullName$));
|
||||
// $type.Alignment$
|
||||
$\n$
|
||||
|
||||
$if(structure && !structure.IsLeaf)$
|
||||
|
||||
$TypeVarName(structure.Type)$ = *$TypePtrVarName(type)$;$\n$
|
||||
Load_$type.Name$(true);
|
||||
|
||||
$else$
|
||||
|
||||
m_stream->Load<$type.FullName$>(*$TypePtrVarName(type)$);
|
||||
|
||||
$endif$
|
||||
%>
|
||||
|
||||
LoadPointerArrayMethod_Asset(context, type, structure) ::= <<
|
||||
$LoaderClassName(structure)$ loader(m_script_string_provider, m_zone, m_stream);
|
||||
loader.Load($TypePtrVarName(type)$);
|
||||
>>
|
||||
|
||||
LoadPointerArrayMethod_PointerCheck(context, type, structure, reusable) ::= <<
|
||||
if (*$TypePtrVarName(type)$)
|
||||
|
@ -15,22 +15,20 @@ $LoadEmbedded_Load(context, structure, member, reference)$
|
||||
$endif$
|
||||
%>
|
||||
|
||||
LoadEmbedded_Condition(context, structure, member, reference) ::= <<
|
||||
$if(member.Condition)$
|
||||
if($PrintEvaluation(member.Condition)$)
|
||||
{
|
||||
$LoadEmbedded_TypeCheck(context, structure, member, reference)$
|
||||
$if(structure.IsUnion)$
|
||||
return;
|
||||
$endif$
|
||||
}
|
||||
$else$$\\$
|
||||
$LoadEmbedded_TypeCheck(context, structure, member, reference)$$\\$
|
||||
LoadEmbedded_Block(context, structure, member, reference) ::= <%
|
||||
$if(member.Computations.IsNotDefaultNormalBlock)$
|
||||
m_stream->PushBlock($member.Block.Name$);$\n$
|
||||
$endif$
|
||||
>>
|
||||
|
||||
$LoadEmbedded_TypeCheck(context, structure, member, reference)$
|
||||
|
||||
$if(member.Computations.IsNotDefaultNormalBlock)$
|
||||
$\n$m_stream->PopBlock();
|
||||
$endif$
|
||||
%>
|
||||
|
||||
LoadEmbedded(context, structure, member, reference) ::= <%
|
||||
$LoadEmbedded_Condition(context, structure, member, reference)$
|
||||
$LoadEmbedded_Block(context, structure, member, reference)$
|
||||
%>
|
||||
|
||||
LoadEmbeddedArray_TypeCheck(context, structure, member, reference) ::= <%
|
||||
|
@ -31,17 +31,18 @@ $LoadPointerArray_Loading(context, structure, member, reference)$
|
||||
$endif$
|
||||
%>
|
||||
|
||||
LoadPointerArray_Condition(context, structure, member, reference) ::= <<
|
||||
$if(member.Condition)$$\\$
|
||||
if($PrintEvaluation(member.Condition)$)
|
||||
{
|
||||
$LoadPointerArray_TypeCheck(context, structure, member, reference)$
|
||||
}
|
||||
$else$$\\$
|
||||
$LoadPointerArray_TypeCheck(context, structure, member, reference)$$\\$
|
||||
LoadPointerArray_Block(context, structure, member, reference) ::= <%
|
||||
$if(member.Computations.IsNotDefaultNormalBlock)$
|
||||
m_stream->PushBlock($member.Block.Name$);$\n$
|
||||
$endif$
|
||||
>>
|
||||
|
||||
$LoadPointerArray_TypeCheck(context, structure, member, reference)$
|
||||
|
||||
$if(member.Computations.IsNotDefaultNormalBlock)$
|
||||
$\n$m_stream->PopBlock();
|
||||
$endif$
|
||||
%>
|
||||
|
||||
LoadPointerArray(context, structure, member, reference) ::= <%
|
||||
$LoadPointerArray_Condition(context, structure, member, reference)$
|
||||
$LoadPointerArray_Block(context, structure, member, reference)$
|
||||
%>
|
@ -65,20 +65,18 @@ $LoadSinglePointer_PointerCheck(context, structure, member, reference)$
|
||||
$endif$
|
||||
%>
|
||||
|
||||
LoadSinglePointer_Condition(context, structure, member, reference) ::= <<
|
||||
$if(member.Condition)$
|
||||
if($PrintEvaluation(member.Condition)$)
|
||||
{
|
||||
$LoadSinglePointer_TypeCheck(context, structure, member, reference)$
|
||||
}
|
||||
$if(structure.IsUnion)$
|
||||
return;
|
||||
LoadSinglePointer_Block(context, structure, member, reference) ::= <%
|
||||
$if(member.Computations.IsNotDefaultNormalBlock)$
|
||||
m_stream->PushBlock($member.Block.Name$);$\n$
|
||||
$endif$
|
||||
$else$$\\$
|
||||
$LoadSinglePointer_TypeCheck(context, structure, member, reference)$$\\$
|
||||
|
||||
$LoadSinglePointer_TypeCheck(context, structure, member, reference)$
|
||||
|
||||
$if(member.Computations.IsNotDefaultNormalBlock)$
|
||||
$\n$m_stream->PopBlock();
|
||||
$endif$
|
||||
>>
|
||||
%>
|
||||
|
||||
LoadSinglePointer(context, structure, member, reference) ::= <%
|
||||
$LoadSinglePointer_Condition(context, structure, member, reference)$
|
||||
$LoadSinglePointer_Block(context, structure, member, reference)$
|
||||
%>
|
@ -13,7 +13,7 @@ LoaderClassName(asset) ::= "Loader_$asset.Type.Name$"
|
||||
|
||||
HeaderConstructor(context) ::= "$LoaderClassName(context.Asset)$(IZoneScriptStringProvider* scriptStringProvider, Zone* zone, IZoneInputStream* stream);"
|
||||
|
||||
HeaderSinglePtrLoadMethodDeclaration(structure) ::= "void LoadPtr_$structure.Type.Name$(bool atStreamStart);"
|
||||
HeaderTempPtrLoadMethodDeclaration(structure) ::= "void LoadPtr_$structure.Type.Name$(bool atStreamStart);"
|
||||
HeaderArrayLoadMethodDeclaration(type) ::= "void LoadArray_$SafeTypeName(type)$(bool atStreamStart, size_t count);"
|
||||
HeaderPtrArrayLoadMethodDeclaration(type) ::= "void LoadPtrArray_$SafeTypeName(type)$(bool atStreamStart, size_t count);"
|
||||
HeaderLoadMethodDeclaration(structure) ::= "void Load_$structure.Type.Name$(bool atStreamStart);"
|
||||
@ -62,7 +62,7 @@ namespace $context.Game$
|
||||
$context.UsedTypes:{usedType | $if(usedType.ArrayReferenceExists && usedType.Information && !usedType.Information.IsLeaf)$$HeaderArrayLoadMethodDeclaration(usedType.Type)$$\n$$endif$}$
|
||||
$context.UsedStructures:{usedStructure | $if(!usedStructure.IsLeaf && !usedStructure.IsAsset)$$HeaderLoadMethodDeclaration(usedStructure)$$\n$$endif$}$
|
||||
$HeaderLoadMethodDeclaration(context.Asset)$
|
||||
$HeaderSinglePtrLoadMethodDeclaration(context.Asset)$
|
||||
$HeaderTempPtrLoadMethodDeclaration(context.Asset)$
|
||||
$HeaderAssetLoadMethodDeclaration(context.Asset)$
|
||||
|
||||
public:
|
||||
@ -113,7 +113,7 @@ $endif$
|
||||
$endif$
|
||||
%>
|
||||
|
||||
LoadSinglePtrMethod(context, structure) ::= <<
|
||||
LoadTempPtrMethod(context, structure) ::= <<
|
||||
void $LoaderClassName(context.Asset)$::LoadPtr_$structure.Type.Name$(const bool atStreamStart)
|
||||
{
|
||||
assert($TypePtrVarName(structure.Type)$ != nullptr);
|
||||
@ -121,7 +121,7 @@ void $LoaderClassName(context.Asset)$::LoadPtr_$structure.Type.Name$(const bool
|
||||
if(atStreamStart)
|
||||
m_stream->Load<$structure.Type.FullName$*>($TypePtrVarName(structure.Type)$);
|
||||
|
||||
m_stream->PushBlock($structure.Block.Name$);
|
||||
m_stream->PushBlock($context.DefaultTempBlock.Name$);
|
||||
|
||||
if(*$TypePtrVarName(structure.Type)$ != nullptr)
|
||||
{
|
||||
@ -131,12 +131,10 @@ void $LoaderClassName(context.Asset)$::LoadPtr_$structure.Type.Name$(const bool
|
||||
if(*$TypePtrVarName(structure.Type)$ == PTR_FOLLOWING)
|
||||
$endif$
|
||||
{
|
||||
$if(structure.Block.IsTemp)$
|
||||
$structure.Type.FullName$** toInsert = nullptr;
|
||||
if(*$TypePtrVarName(structure.Type)$ == PTR_INSERT)
|
||||
toInsert = m_stream->InsertPointer<$structure.Type.FullName$>();
|
||||
|
||||
$endif$
|
||||
*$TypePtrVarName(structure.Type)$ = m_stream->Alloc<$structure.Type.FullName$>(alignof($structure.Type.FullName$));
|
||||
|
||||
$if(!structure.IsLeaf)$
|
||||
@ -147,11 +145,9 @@ void $LoaderClassName(context.Asset)$::LoadPtr_$structure.Type.Name$(const bool
|
||||
$if(structure.IsAsset)$
|
||||
LoadAsset_$structure.Type.Name$($TypePtrVarName(structure.Type)$);
|
||||
$endif$
|
||||
$if(structure.Block.IsTemp)$
|
||||
|
||||
if(toInsert != nullptr)
|
||||
*toInsert = *$TypePtrVarName(structure.Type)$;
|
||||
$endif$
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -286,7 +282,7 @@ $context.UsedTypes:{usedType | $if(usedType.ArrayReferenceExists && usedType.Inf
|
||||
$context.UsedStructures:{usedStructure | $if(!usedStructure.IsLeaf && !usedStructure.IsAsset)$$LoadMethod(context, usedStructure)$$\n$$\n$$endif$}$
|
||||
$LoadMethod(context, context.Asset)$
|
||||
|
||||
$LoadSinglePtrMethod(context, context.Asset)$
|
||||
$LoadTempPtrMethod(context, context.Asset)$
|
||||
|
||||
$LoadAssetMethod(context, context.Asset)$
|
||||
|
||||
|
Reference in New Issue
Block a user