2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-07-01 16:51:56 +00:00

ZoneCodeGenerator: Add computations for single references to be able to correctly handle arrays

This commit is contained in:
Jan
2019-11-24 01:58:01 +01:00
parent 6d1359c3d9
commit 5d3c13e833
15 changed files with 418 additions and 223 deletions

View File

@ -5,8 +5,24 @@ Lower(name) ::= "$name; format=\"lower\"$"
TypeDeclaration(typeDecl) ::= "$if(typeDecl.IsConst)$const $endif$$typeDecl.Type.FullName$"
TypeVarName(structure) ::= "var$structure.Type.Name$"
TypePtrVarName(structure) ::= "var$structure.Type.Name$Ptr"
TypeVarName(structure) ::= "var$SafeTypeName(structure.Type)$"
TypePtrVarName(structure) ::= "var$SafeTypeName(structure.Type)$Ptr"
SafeTypeName(type) ::= "$type; format=\"safe_name\"$"
PrintFollowingReferences(references) ::= <%
$references:{ reference |
$if(reference.ArraySize)$
[$reference.ArraySize$]
$else$
*
$endif$
}$
%>
PrintArrayIndices(reference) ::= "$reference.ArrayIndices:{ index | [$index$] }$"
PrintOperandStatic(op) ::= <%
$if(op.EnumMemberValue)$

View File

@ -1,68 +1,59 @@
delimiters "$", "$"
// Everything related to loading a pointer with a count that can be larger than 1
LoadArrayPointer_Loading(context, structure, member) ::= <%
$TypeVarName(structure)$->$member.Member.Name$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$>(alignof($TypeDeclaration(member.Member.VariableType)$));$\n$
LoadArrayPointer_Loading(context, structure, member, reference) ::= <%
$TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>(alignof($TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$));$\n$
$if(member.StructureType && !member.StructureType.IsLeaf)$
$TypeVarName(member.StructureType)$ = $TypeVarName(structure)$->$member.Member.Name$;$\n$
LoadArray_$member.Member.VariableType.Type.Name$(true, $PrintEvaluation(member.Computations.ArrayPointerCountEvaluation)$);
$TypeVarName(member.StructureType)$ = $TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
LoadArray_$member.Member.VariableType.Type.Name$(true, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$);
$else$
m_stream->Load<$TypeDeclaration(member.Member.VariableType)$>($TypeVarName(structure)$->$member.Member.Name$, $PrintEvaluation(member.Computations.ArrayPointerCountEvaluation)$);
m_stream->Load<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>($TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$);
$endif$
%>
LoadArrayPointer_PointerCheck(context, structure, member) ::= <<
if ($TypeVarName(structure)$->$member.Member.Name$)
LoadArrayPointer_PointerCheck(context, structure, member, reference) ::= <<
if ($TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$)
{
$if(member.IsReusable)$
if($TypeVarName(structure)$->$member.Member.Name$ == PTR_FOLLOWING)
if($TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$ == PTR_FOLLOWING)
{
$LoadArrayPointer_Loading(context, structure, member)$
$LoadArrayPointer_Loading(context, structure, member, reference)$
}
else
{
$TypeVarName(structure)$->$member.Member.Name$ = m_stream->ConvertOffsetToPointer($TypeVarName(structure)$->$member.Member.Name$);
$TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->ConvertOffsetToPointer($TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$);
}
$else$
$LoadArrayPointer_Loading(context, structure, member)$
$LoadArrayPointer_Loading(context, structure, member, reference)$
$endif$
}
>>
LoadArrayPointer_Condition(context, structure, member) ::= <%
$if(member.Condition)$
$if(structure.IsUnion)$
if($PrintEvaluation(member.Condition)$)$\n$
{$\n$
$LoadArrayPointer_PointerCheck(context, structure, member)$$\n$
}$\n$
$\n$
LoadArrayPointer_TypeCheck(context, structure, member, reference) ::= <%
$if(member.IsScriptString)$
// ScriptString $member.Member.Name$
$else$
if($PrintEvaluation(member.Condition)$)$\n$
{$\n$
$LoadArrayPointer_PointerCheck(context, structure, member)$$\n$
}$\n$
$\n$
$endif$
$else$
$LoadArrayPointer_PointerCheck(context, structure, member)$$\n$
$\n$
$LoadArrayPointer_PointerCheck(context, structure, member, reference)$
$endif$
%>
LoadArrayPointer(context, structure, member) ::= <%
$if(!member.Computations.ShouldIgnore)$
$LoadArrayPointer_Condition(context, structure, member)$
LoadArrayPointer_Condition(context, structure, member, reference) ::= <<
$if(member.Condition)$$\\$
if($PrintEvaluation(member.Condition)$)
{
$LoadArrayPointer_TypeCheck(context, structure, member, reference)$
}
$else$$\\$
$LoadArrayPointer_TypeCheck(context, structure, member, reference)$$\\$
$endif$
>>
LoadArrayPointer(context, structure, member, reference) ::= <%
$LoadArrayPointer_Condition(context, structure, member, reference)$
%>

View File

@ -1,2 +1,4 @@
delimiters "$", "$"
// Loading common
LoaderClassName(asset) ::= "Loader_$asset.Type.Name$"

View File

@ -1,21 +1,25 @@
delimiters "$", "$"
// Everything related to loading an embedded reference
LoadEmbedded_Load(context, structure, member) ::= <<
$TypeVarName(member.StructureType)$ = &$TypeVarName(structure)$->$member.Member.Name$;
LoadEmbedded_Load(context, structure, member, reference) ::= <<
$TypeVarName(member.StructureType)$ = &$TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$;
Load_$member.Member.VariableType.Type.Name$(false);
>>
LoadEmbedded_Array(context, structure, member) ::= <<
>>
LoadEmbedded(context, structure, member) ::= <%
$if(!member.Computations.ShouldIgnore)$
$if(member.Computations.IsArray)$
$LoadEmbedded_Array(context, structure, member)$
LoadEmbedded_TypeCheck(context, structure, member, reference) ::= <%
$if(member.IsScriptString)$
$TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$ = UseScriptString($TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$);
$else$
$LoadEmbedded_Load(context, structure, member)$
$LoadEmbedded_Load(context, structure, member, reference)$
$endif$
$endif$
%>
%>
LoadEmbedded(context, structure, member, reference) ::= <%
$LoadEmbedded_TypeCheck(context, structure, member, reference)$
%>
LoadEmbeddedArray(context, structure, member, reference) ::= <<
$TypeVarName(member.StructureType)$ = $TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$;
LoadArray_$member.Member.VariableType.Type.Name$(false, $reference.ArraySize$); // ASDF
>>

View File

@ -0,0 +1,45 @@
delimiters "$", "$"
LoadPointerArray_Loading(context, structure, member, reference) ::= <%
$if(member.Computations.IsArray)$
$TypePtrVarName(member.Member.VariableType)$ = $TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
LoadPtrArray_$SafeTypeName(member.Member.VariableType.Type)$(false, $reference.ArraySize$);
$else$
$TypePtrVarName(member.Member.VariableType)$ = $TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
LoadPtrArray_$SafeTypeName(member.Member.VariableType.Type)$(true, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$);
$endif$
%>
LoadPointerArray_String(context, structure, member, reference) ::= <%
$if(reference.IsArray)$
varXString = $TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
LoadXStringArray(false, $reference.ArraySize$);
$else$
$TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>(alignof($TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$));$\n$
varXString = $TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
LoadXStringArray(true, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$);
$endif$
%>
LoadPointerArray_TypeCheck(context, structure, member, reference) ::= <%
$if(member.IsString)$
$LoadPointerArray_String(context, structure, member, reference)$
$else$
$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)$$\\$
$endif$
>>
LoadPointerArray(context, structure, member, reference) ::= <%
$LoadPointerArray_Condition(context, structure, member, reference)$
%>

View File

@ -1,62 +1,78 @@
delimiters "$", "$"
// Everything related to loading a pointer with a count that is statically 1
LoadSinglePointerInner(context, structure, member) ::= <<
$TypeVarName(structure)$->$member.Member.Name$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$>(alignof($TypeDeclaration(member.Member.VariableType)$));
LoadSinglePointerInner(context, structure, member, reference) ::= <%
$TypeVarName(structure)$->$member.Member.Name$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>(alignof($TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$));$\n$
$if(member.StructureType && !member.StructureType.IsLeaf)$
$TypeVarName(member.StructureType)$ = $TypeVarName(structure)$->$member.Member.Name$;
$TypeVarName(member.StructureType)$ = $TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
Load_$member.Member.VariableType.Type.Name$(true);
$else$
m_stream->Load<$TypeDeclaration(member.Member.VariableType)$>($TypeVarName(structure)$->$member.Member.Name$);$endif$
>>
LoadSinglePointerAsset(context, structure, member) ::= <<
m_stream->Load<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>($TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$);
$endif$
%>
LoadSinglePointerAsset(context, structure, member, reference) ::= <<
$LoaderClassName(member.StructureType)$ loader(m_script_string_provider, m_zone, m_stream);
loader.Load(&$TypeVarName(structure)$->$member.Member.Name$);
loader.Load(&$TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$);
>>
LoadSinglePointer_PointerCheck(context, structure, member) ::= <<
if ($TypeVarName(structure)$->$member.Member.Name$)
LoadSinglePointer_PointerCheck(context, structure, member, reference) ::= <<
if ($TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$)
{
$if(member.StructureType && member.StructureType.IsAsset)$
$LoadSinglePointerAsset(context, structure, member)$
$LoadSinglePointerAsset(context, structure, member, reference)$
$else$
$if(member.IsReusable)$
if($TypeVarName(structure)$->$member.Member.Name$ == PTR_FOLLOWING)
if($TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$ == PTR_FOLLOWING)
{
$LoadSinglePointerInner(context, structure, member)$
$LoadSinglePointerInner(context, structure, member, reference)$
}
else
{
$TypeVarName(structure)$->$member.Member.Name$ = m_stream->ConvertOffsetToPointer($TypeVarName(structure)$->$member.Member.Name$);
$TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->ConvertOffsetToPointer($TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$);
}
$else$
$LoadSinglePointerInner(context, structure, member)$
$LoadSinglePointerInner(context, structure, member, reference)$
$endif$
$endif$
}
>>
LoadSinglePointer_Condition(context, structure, member) ::= <%
$if(member.Condition)$
if($PrintEvaluation(member.Condition)$)$\n$
{$\n$
$LoadSinglePointer_PointerCheck(context, structure, member)$$\n$
}$\n$
$\n$
LoadSinglePointer_String(context, structure, member, reference) ::= <%
varXString = &$TypeVarName(structure)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
LoadXString(false);
%>
LoadSinglePointer_TypeCheck(context, structure, member, reference) ::= <%
$if(member.IsString)$
$LoadSinglePointer_String(context, structure, member, reference)$
$elseif(member.IsScriptString)$
// ScriptString $member.Member.Name$
$else$
$LoadSinglePointer_PointerCheck(context, structure, member)$$\n$
$\n$
$LoadSinglePointer_PointerCheck(context, structure, member, reference)$
$endif$
%>
LoadSinglePointer(context, structure, member) ::= <%
$if(!member.Computations.ShouldIgnore)$
$if(!member.Computations.IsArray && member.Computations.PointerDepthIsOne)$$! TODO: FIX ARRAYS !$
$LoadSinglePointer_Condition(context, structure, member)$
LoadSinglePointer_Condition(context, structure, member, reference) ::= <<
$if(member.Condition)$
if($PrintEvaluation(member.Condition)$)
{
$LoadSinglePointer_TypeCheck(context, structure, member, reference)$
}
$if(structure.IsUnion)$
return;
$endif$
$else$$\\$
$LoadSinglePointer_TypeCheck(context, structure, member, reference)$$\\$
$endif$
>>
LoadSinglePointer(context, structure, member, reference) ::= <%
$LoadSinglePointer_Condition(context, structure, member, reference)$
%>

View File

@ -1,30 +0,0 @@
// String
LoadStringSingleDepth(context, structure, member) ::= <%
$if(!member.Computations.IsArray)$
varXString = &$TypeVarName(structure)$->$member.Member.Name$;$\n$
LoadXString(false);$\n$
$else$
varXString = $TypeVarName(structure)$->$member.Member.Name$;$\n$
LoadXStringArray(false, $first(member.Computations.ArraySizes)$);$\n$
$endif$
%>
LoadString_PointerCheck(context, structure, member) ::= <<
if ($TypeVarName(structure)$->$member.Member.Name$)
{
$TypeVarName(structure)$->$member.Member.Name$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$*>(alignof($TypeDeclaration(member.Member.VariableType)$*));
varXString = $TypeVarName(structure)$->$member.Member.Name$;
LoadXStringArray(true, $PrintEvaluation(member.Computations.ArrayPointerCountEvaluation)$);
}
>>
LoadString(context, structure, member) ::= <%
$if(member.Computations.PointerDepthIsOne)$
$LoadStringSingleDepth(context, structure, member)$
$elseif(member.Computations.PointerDepthIsTwo && member.Computations.ArrayPointerCountEvaluation)$
$LoadString_PointerCheck(context, structure, member)$
$else$
#error Cannot load string $member.Member.Name$
$endif$
%>

View File

@ -3,10 +3,10 @@ delimiters "$", "$"
import "Common.stg"
import "Loading/Common.stg"
import "Loading/String.stg"
import "Loading/ArrayPointer.stg"
import "Loading/Embedded.stg"
import "Loading/SinglePointer.stg"
import "Loading/PointerArray.stg"
// Loading common
LoaderClassName(asset) ::= "Loader_$asset.Type.Name$"
@ -14,7 +14,8 @@ 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);"
HeaderArrayPtrLoadMethodDeclaration(structure) ::= "void LoadArray_$structure.Type.Name$(bool atStreamStart, size_t count);"
HeaderArrayLoadMethodDeclaration(structure) ::= "void LoadArray_$structure.Type.Name$(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);"
HeaderGetNameMethodDeclaration(asset) ::= "static std::string GetAssetName($asset.Type.FullName$* pAsset);"
@ -22,26 +23,24 @@ HeaderAssetLoadMethodDeclaration(asset) ::= "void LoadAsset_$asset.Type.Name$($a
HeaderMainLoadMethodDeclaration(asset) ::= "void Load($asset.Type.FullName$** pAsset);"
VariableDeclaration(type) ::= <<
$type.FullName$* var$type.Name$;
$type.FullName$* var$SafeTypeName(type)$;
>>
PointerVariableDeclaration(type) ::= <<
$type.FullName$** var$type.Name$Ptr;
$type.FullName$** var$SafeTypeName(type)$Ptr;
>>
HeaderDeclaration(structure) ::= <%
$if(structure.SinglePointerReferenceExists)$
$HeaderSinglePtrLoadMethodDeclaration(structure)$
HeaderMethodDeclarations(usedType) ::= <%
$if(usedType.PointerArrayReferenceExists)$
$HeaderPtrArrayLoadMethodDeclaration(usedType.Type)$
$\n$
$endif$
$if(structure.ArrayPointerReferenceExists && !structure.IsLeaf)$
$HeaderArrayPtrLoadMethodDeclaration(structure)$
$if(usedType.ArrayReferenceExists && usedType.Information && !usedType.Information.IsLeaf)$
$HeaderArrayLoadMethodDeclaration(usedType.Information)$
$\n$
$endif$
$if(!structure.IsLeaf && structure.Computations.IsUsed)$
$HeaderLoadMethodDeclaration(structure)$
$if(usedType.Information && !usedType.Information.IsLeaf && !usedType.Information.IsAsset)$
$HeaderLoadMethodDeclaration(usedType.Information)$
$\n$
$endif$
%>
@ -68,11 +67,13 @@ namespace $context.Game$
{
$VariableDeclaration(context.Asset.Type)$
$PointerVariableDeclaration(context.Asset.Type)$
$context.MemberTypes:{type | $if(!type.IsAnonymous)$$VariableDeclaration(type)$
$context.UsedTypes:{type | $if(type.Information && !type.Information.Type.IsAnonymous && !type.Information.IsLeaf && !type.Information.IsAsset)$$VariableDeclaration(type.Type)$
$endif$}$
$context.Structures:{structure | $if(!structure.IsAsset && structure.SinglePointerReferenceExists)$$PointerVariableDeclaration(structure.Type)$
$endif$}$
$context.Structures:{structure | $if(!structure.IsAsset)$$HeaderDeclaration(structure)$$endif$}$
$context.UsedTypes:{type | $if(type.PointerArrayReferenceExists && !type.IsContextAsset)$$PointerVariableDeclaration(type.Type)$
$endif$}$$\\$
$context.UsedTypes:{usedType | $HeaderMethodDeclarations(usedType)$}$
$HeaderLoadMethodDeclaration(context.Asset)$
$HeaderSinglePtrLoadMethodDeclaration(context.Asset)$
$HeaderAssetLoadMethodDeclaration(context.Asset)$
@ -89,41 +90,43 @@ LoadMember(context, member) ::= <<
Loading member $member.Member.Name$
>>
LoadMemberIfNeedsTreatment(context, structure, member) ::= <%
$if(member.IsString)$
$LoadString(context, structure, member)$
$elseif(member.IsScriptString)$
// Load scriptstring for $member.Member.Name$
$elseif(member.Computations.IsArrayPointerReference && member.Computations.PointerDepthIsOne)$
$LoadArrayPointer(context, structure, member)$
$elseif(member.Computations.IsSinglePointerReference)$
$LoadSinglePointer(context, structure, member)$
$elseif(member.Computations.IsEmbeddedReference && member.StructureType && !member.StructureType.IsLeaf)$
$LoadEmbedded(context, structure, member)$
LoadMemberReference(context, structure, member, reference) ::= <%
$if(reference.IsSinglePointer)$
$\n$$\n$
$LoadSinglePointer(context, structure, member, reference)$
$elseif(reference.IsArrayPointer)$
$\n$$\n$
$LoadArrayPointer(context, structure, member, reference)$
$elseif(reference.IsPointerArray)$
$\n$$\n$
$LoadPointerArray(context, structure, member, reference)$
$elseif(reference.IsArray && !reference.NextReference)$
$\n$$\n$
$LoadEmbeddedArray(context, structure, member, reference)$
$elseif(!reference.Reference)$
$\n$$\n$
$LoadEmbedded(context, structure, member, reference)$
$else$
$\n$$\n$
// $member.Member.Name$
$endif$
%>
LoadMethod(structure, context) ::= <<
void $LoaderClassName(context.Asset)$::Load_$structure.Type.Name$(const bool atStreamStart)
{
assert($TypeVarName(structure)$ != nullptr);
LoadMemberIfNeedsTreatment(context, structure, member) ::= <%
$if(!member.Computations.ShouldIgnore)$
if(atStreamStart)
m_stream->Load<$structure.Type.FullName$>($TypeVarName(structure)$);
$if(structure.Block.IsTemp)$
$if(member.IsString || member.IsScriptString)$
$LoadMemberReference(context, structure, member, member.Computations.References)$
$elseif(member.Computations.ContainsNonEmbeddedReference)$
$LoadMemberReference(context, structure, member, member.Computations.References)$
$elseif(member.StructureType && !member.StructureType.IsLeaf)$
$LoadMemberReference(context, structure, member, member.Computations.References)$
$endif$
m_stream->PushBlock($context.DefaultNormalBlock.Name$);
$endif$
$structure.OrderedMembers:{member | $LoadMemberIfNeedsTreatment(context, structure, member)$}$
$if(structure.Block.IsTemp)$
m_stream->PopBlock();
$endif$
}
>>
$endif$
%>
LoadSinglePtrMethod(structure, context) ::= <<
LoadSinglePtrMethod(context, structure) ::= <<
void $LoaderClassName(context.Asset)$::LoadPtr_$structure.Type.Name$(const bool atStreamStart)
{
assert($TypePtrVarName(structure)$ != nullptr);
@ -177,7 +180,14 @@ void $LoaderClassName(context.Asset)$::LoadPtr_$structure.Type.Name$(const bool
}
>>
LoadArrayPtrMethod(structure, context) ::= <<
LoadPointerArrayMethod(context, type, structure) ::= <<
void $LoaderClassName(context.Asset)$::LoadPtrArray_$SafeTypeName(type)$(const bool atStreamStart, const size_t count)
{
}
>>
LoadArrayMethod(context, structure) ::= <<
void $LoaderClassName(context.Asset)$::LoadArray_$structure.Type.Name$(const bool atStreamStart, const size_t count)
{
assert($TypeVarName(structure)$ != nullptr);
@ -193,21 +203,40 @@ void $LoaderClassName(context.Asset)$::LoadArray_$structure.Type.Name$(const boo
}
>>
SourceDefinition(structure, context) ::= <<
$if(structure.SinglePointerReferenceExists)$
$LoadSinglePtrMethod(structure, context)$
LoadMethod(context, structure) ::= <<
void $LoaderClassName(context.Asset)$::Load_$structure.Type.Name$(const bool atStreamStart)
{
assert($TypeVarName(structure)$ != nullptr);
$endif$
$if(structure.ArrayPointerReferenceExists && !structure.IsLeaf)$
$LoadArrayPtrMethod(structure, context)$
if(atStreamStart)
m_stream->Load<$structure.Type.FullName$>($TypeVarName(structure)$);$\\$
$if(structure.Block.IsTemp)$
$endif$
$if(!structure.IsLeaf && structure.Computations.IsUsed)$
$LoadMethod(structure, context)$
m_stream->PushBlock($context.DefaultNormalBlock.Name$);$\\$
$endif$
$structure.OrderedMembers:{member | $LoadMemberIfNeedsTreatment(context, structure, member)$}$
$if(structure.Block.IsTemp)$
$endif$
m_stream->PopBlock();
$endif$
}
>>
SourceDefinition(context, usedType) ::= <%
$if(usedType.PointerArrayReferenceExists)$
$LoadPointerArrayMethod(context, usedType.Type, usedType.Information)$
$\n$$\n$
$endif$
$if(usedType.ArrayReferenceExists && usedType.Information && !usedType.Information.IsLeaf)$
$LoadArrayMethod(context, usedType.Information)$
$\n$$\n$
$endif$
$if(usedType.Information && !usedType.Information.IsLeaf && !usedType.Information.IsAsset)$
$LoadMethod(context, usedType.Information)$
$\n$$\n$
$endif$
%>
VariableInitialization(type) ::= <<
var$type.Name$ = nullptr;
>>
@ -222,14 +251,15 @@ $LoaderClassName(context.Asset)$::$LoaderClassName(context.Asset)$(IZoneScriptSt
{
$VariableInitialization(context.Asset.Type)$
$PointerVariableInitialization(context.Asset.Type)$
$context.MemberTypes:{type | $if(!type.IsAnonymous)$$VariableInitialization(type)$
$endif$}$
$context.Structures:{structure | $if(!structure.IsAsset && structure.SinglePointerReferenceExists)$$PointerVariableInitialization(structure.Type)$
$endif$}$
$context.UsedTypes:{type | $if(type.Information && !type.Information.Type.IsAnonymous && !type.Information.IsLeaf && !type.Information.IsAsset)$$VariableInitialization(type.Type)$
$endif$}$
$context.UsedTypes:{type | $if(type.Information && type.PointerArrayReferenceExists && !type.IsContextAsset)$$PointerVariableInitialization(type.Type)$
$endif$}$$\\$
}
>>
LoadAssetMethod(structure, context) ::= <<
LoadAssetMethod(context, structure) ::= <<
void $LoaderClassName(context.Asset)$::LoadAsset_$structure.Type.Name$($structure.Type.FullName$** pAsset)
{
assert(pAsset != nullptr);
@ -283,12 +313,12 @@ using namespace $context.Game$;
$ConstructorMethod(context)$
$context.Structures:{structure | $if(!structure.IsAsset)$$SourceDefinition(structure, context)$$endif$}$
$LoadMethod(context.Asset, context)$
$context.UsedTypes:{usedType | $SourceDefinition(context, usedType)$}$
$LoadMethod(context, context.Asset)$
$LoadAssetMethod(context.Asset, context)$
$LoadSinglePtrMethod(context, context.Asset)$
$LoadSinglePtrMethod(context.Asset, context)$
$LoadAssetMethod(context, context.Asset)$
$MainLoadMethod(context)$