mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 00:02:55 +00:00
zoneload member skeleton
This commit is contained in:
parent
5be0b28323
commit
04491e21f2
@ -63,8 +63,10 @@ std::string BaseTemplate::SafeTypeName(const DataDefinition* def)
|
|||||||
void BaseTemplate::TypeDecl(const TypeDeclaration* decl) const
|
void BaseTemplate::TypeDecl(const TypeDeclaration* decl) const
|
||||||
{
|
{
|
||||||
if (decl->m_is_const)
|
if (decl->m_is_const)
|
||||||
m_out << "const ";
|
{
|
||||||
m_out << decl->m_type->GetFullName();
|
LINE_MIDDLE("const ")
|
||||||
|
}
|
||||||
|
LINE_MIDDLE(decl->m_type->GetFullName())
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTemplate::PrintFollowingReferences(const std::vector<std::unique_ptr<DeclarationModifier>>& modifiers) const
|
void BaseTemplate::PrintFollowingReferences(const std::vector<std::unique_ptr<DeclarationModifier>>& modifiers) const
|
||||||
@ -74,17 +76,21 @@ void BaseTemplate::PrintFollowingReferences(const std::vector<std::unique_ptr<De
|
|||||||
if (modifier->GetType() == DeclarationModifierType::ARRAY)
|
if (modifier->GetType() == DeclarationModifierType::ARRAY)
|
||||||
{
|
{
|
||||||
const auto* array = dynamic_cast<const ArrayDeclarationModifier*>(modifier.get());
|
const auto* array = dynamic_cast<const ArrayDeclarationModifier*>(modifier.get());
|
||||||
m_out << "[" << array->m_size << "]";
|
LINE_MIDDLE("["<< array->m_size <<"]")
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_out << '*';
|
{
|
||||||
|
LINE_MIDDLE("*")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTemplate::PrintArrayIndices(const DeclarationModifierComputations& modifierComputations) const
|
void BaseTemplate::PrintArrayIndices(const DeclarationModifierComputations& modifierComputations) const
|
||||||
{
|
{
|
||||||
for (auto index : modifierComputations.GetArrayIndices())
|
for (auto index : modifierComputations.GetArrayIndices())
|
||||||
m_out << "[" << index << "]";
|
{
|
||||||
|
LINE_MIDDLE("["<<index<<"]")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTemplate::PrintCustomAction(CustomAction* action) const
|
void BaseTemplate::PrintCustomAction(CustomAction* action) const
|
||||||
@ -112,14 +118,18 @@ void BaseTemplate::PrintCustomAction(CustomAction* action) const
|
|||||||
void BaseTemplate::PrintOperandStatic(const OperandStatic* op) const
|
void BaseTemplate::PrintOperandStatic(const OperandStatic* op) const
|
||||||
{
|
{
|
||||||
if (op->m_enum_member != nullptr)
|
if (op->m_enum_member != nullptr)
|
||||||
m_out << op->m_enum_member->m_name;
|
{
|
||||||
|
LINE_MIDDLE(op->m_enum_member->m_name)
|
||||||
|
}
|
||||||
else
|
else
|
||||||
m_out << op->m_value;
|
{
|
||||||
|
LINE_MIDDLE(op->m_value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTemplate::PrintOperandDynamic(const OperandDynamic* op) const
|
void BaseTemplate::PrintOperandDynamic(const OperandDynamic* op) const
|
||||||
{
|
{
|
||||||
m_out << TypeVarName(op->m_structure->m_definition);
|
LINE_MIDDLE(TypeVarName(op->m_structure->m_definition))
|
||||||
|
|
||||||
auto first = true;
|
auto first = true;
|
||||||
for (const auto* chainMember : op->m_referenced_member_chain)
|
for (const auto* chainMember : op->m_referenced_member_chain)
|
||||||
@ -127,17 +137,19 @@ void BaseTemplate::PrintOperandDynamic(const OperandDynamic* op) const
|
|||||||
if (first)
|
if (first)
|
||||||
{
|
{
|
||||||
first = false;
|
first = false;
|
||||||
m_out << "->" << chainMember->m_member->m_name;
|
LINE_MIDDLE("->"<< chainMember->m_member->m_name)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_out << '.' << chainMember->m_member->m_name;
|
{
|
||||||
|
LINE_MIDDLE("." << chainMember->m_member->m_name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& arrayIndex : op->m_array_indices)
|
for (const auto& arrayIndex : op->m_array_indices)
|
||||||
{
|
{
|
||||||
m_out << "[";
|
LINE_MIDDLE("[")
|
||||||
PrintEvaluation(arrayIndex.get());
|
PrintEvaluation(arrayIndex.get());
|
||||||
m_out << "]";
|
LINE_MIDDLE("]")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,20 +157,20 @@ void BaseTemplate::PrintOperation(const Operation* operation) const
|
|||||||
{
|
{
|
||||||
if (operation->Operand1NeedsParenthesis())
|
if (operation->Operand1NeedsParenthesis())
|
||||||
{
|
{
|
||||||
m_out << "(";
|
LINE_MIDDLE("(")
|
||||||
PrintEvaluation(operation->m_operand1.get());
|
PrintEvaluation(operation->m_operand1.get());
|
||||||
m_out << ")";
|
LINE_MIDDLE(")")
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
PrintEvaluation(operation->m_operand1.get());
|
PrintEvaluation(operation->m_operand1.get());
|
||||||
|
|
||||||
m_out << " " << operation->m_operation_type->m_syntax << " ";
|
LINE_MIDDLE(" "<<operation->m_operation_type->m_syntax<<" ")
|
||||||
|
|
||||||
if (operation->Operand2NeedsParenthesis())
|
if (operation->Operand2NeedsParenthesis())
|
||||||
{
|
{
|
||||||
m_out << "(";
|
LINE_MIDDLE("(")
|
||||||
PrintEvaluation(operation->m_operand2.get());
|
PrintEvaluation(operation->m_operand2.get());
|
||||||
m_out << ")";
|
LINE_MIDDLE(")")
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
PrintEvaluation(operation->m_operand2.get());
|
PrintEvaluation(operation->m_operand2.get());
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
|
||||||
|
#include "Domain/Computations/MemberComputations.h"
|
||||||
#include "Domain/Computations/StructureComputations.h"
|
#include "Domain/Computations/StructureComputations.h"
|
||||||
#include "Internal/BaseTemplate.h"
|
#include "Internal/BaseTemplate.h"
|
||||||
|
|
||||||
@ -120,9 +121,61 @@ class ZoneLoadTemplate::Internal final : BaseTemplate
|
|||||||
LINE("}")
|
LINE("}")
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintLoadPtrArrayMethod_PointerCheck(const DataDefinition* def, StructureInformation* info, bool reusable)
|
void PrintLoadPtrArrayMethod_Loading(const DataDefinition* def, StructureInformation* info) const
|
||||||
{
|
{
|
||||||
// TODO
|
LINE("*"<<TypePtrVarName(def)<<" = m_stream->Alloc<"<<def->GetFullName()<<">(alignof("<<def->GetFullName()<<")); // "<<def->GetAlignment())
|
||||||
|
|
||||||
|
if (info && info->m_is_leaf)
|
||||||
|
{
|
||||||
|
LINE(TypeVarName(info->m_definition)<<" = *"<<TypePtrVarName(def)<<";")
|
||||||
|
LINE("Load_"<<SafeTypeName(def)<<"(true);")
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LINE("m_stream->Load<"<<def->GetFullName()<<">(*"<<TypePtrVarName(def)<<");")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintLoadPtrArrayMethod_PointerCheck(const DataDefinition* def, StructureInformation* info, const bool reusable)
|
||||||
|
{
|
||||||
|
LINE("if (*" << TypePtrVarName(def) << ")")
|
||||||
|
LINE("{")
|
||||||
|
m_intendation++;
|
||||||
|
|
||||||
|
if (info && StructureComputations(info).IsAsset())
|
||||||
|
{
|
||||||
|
LINE(LoaderClassName(info)<<" loader(m_zone, m_stream);")
|
||||||
|
LINE("AddDependency(loader.Load("<<TypePtrVarName(def)<<"));")
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (reusable)
|
||||||
|
{
|
||||||
|
LINE("if(*" << TypePtrVarName(def) << " == PTR_FOLLOWING)")
|
||||||
|
LINE("{")
|
||||||
|
m_intendation++;
|
||||||
|
|
||||||
|
PrintLoadPtrArrayMethod_Loading(def, info);
|
||||||
|
|
||||||
|
m_intendation--;
|
||||||
|
LINE("}")
|
||||||
|
LINE("else")
|
||||||
|
LINE("{")
|
||||||
|
m_intendation++;
|
||||||
|
|
||||||
|
LINE("*"<<TypePtrVarName(def)<<" = m_stream->ConvertOffsetToPointer(*"<<TypePtrVarName(def)<<");")
|
||||||
|
|
||||||
|
m_intendation--;
|
||||||
|
LINE("}")
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PrintLoadPtrArrayMethod_Loading(def, info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_intendation--;
|
||||||
|
LINE("}")
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintLoadPtrArrayMethod(const DataDefinition* def, StructureInformation* info, const bool reusable)
|
void PrintLoadPtrArrayMethod(const DataDefinition* def, StructureInformation* info, const bool reusable)
|
||||||
@ -194,6 +247,192 @@ class ZoneLoadTemplate::Internal final : BaseTemplate
|
|||||||
LINE("}")
|
LINE("}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LoadDynamicArray(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier)
|
||||||
|
{
|
||||||
|
LINE("// LoadDynamicArray: "<<member->m_member->m_name)
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadSinglePointer(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier)
|
||||||
|
{
|
||||||
|
LINE("// LoadSinglePointer: " << member->m_member->m_name)
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadArrayPointer(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier)
|
||||||
|
{
|
||||||
|
LINE("// LoadArrayPointer: " << member->m_member->m_name)
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadPointerArray(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier)
|
||||||
|
{
|
||||||
|
LINE("// LoadPointerArray: " << member->m_member->m_name)
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadEmbeddedArray(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier)
|
||||||
|
{
|
||||||
|
LINE("// LoadEmbeddedArray: " << member->m_member->m_name)
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadEmbedded(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier)
|
||||||
|
{
|
||||||
|
LINE("// LoadEmbedded: " << member->m_member->m_name)
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadMember_ReferenceArray(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier)
|
||||||
|
{
|
||||||
|
LINE("// LoadMember_ReferenceArray: " << member->m_member->m_name)
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadMember_Reference(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier)
|
||||||
|
{
|
||||||
|
if (modifier.IsDynamicArray())
|
||||||
|
{
|
||||||
|
LoadDynamicArray(info, member, modifier);
|
||||||
|
}
|
||||||
|
else if (modifier.IsSinglePointer())
|
||||||
|
{
|
||||||
|
LoadSinglePointer(info, member, modifier);
|
||||||
|
}
|
||||||
|
else if (modifier.IsArrayPointer())
|
||||||
|
{
|
||||||
|
LoadArrayPointer(info, member, modifier);
|
||||||
|
}
|
||||||
|
else if (modifier.IsPointerArray())
|
||||||
|
{
|
||||||
|
LoadPointerArray(info, member, modifier);
|
||||||
|
}
|
||||||
|
else if (modifier.IsArray() && modifier.GetNextDeclarationModifier() == nullptr)
|
||||||
|
{
|
||||||
|
LoadEmbeddedArray(info, member, modifier);
|
||||||
|
}
|
||||||
|
else if (modifier.GetDeclarationModifier() == nullptr)
|
||||||
|
{
|
||||||
|
LoadEmbedded(info, member, modifier);
|
||||||
|
}
|
||||||
|
else if (modifier.IsArray())
|
||||||
|
{
|
||||||
|
LoadMember_ReferenceArray(info, member, modifier);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LINE("#error LoadMemberReference failed @ "<<member->m_member->m_name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadMember_Condition_Struct(StructureInformation* info, MemberInformation* member)
|
||||||
|
{
|
||||||
|
LINE("")
|
||||||
|
if (member->m_condition)
|
||||||
|
{
|
||||||
|
LINE_START("if(")
|
||||||
|
PrintEvaluation(member->m_condition.get());
|
||||||
|
LINE_END(")")
|
||||||
|
LINE("{")
|
||||||
|
m_intendation++;
|
||||||
|
|
||||||
|
LoadMember_Reference(info, member, DeclarationModifierComputations(member));
|
||||||
|
|
||||||
|
m_intendation--;
|
||||||
|
LINE("}")
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LoadMember_Reference(info, member, DeclarationModifierComputations(member));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadMember_Condition_Union(StructureInformation* info, MemberInformation* member)
|
||||||
|
{
|
||||||
|
const MemberComputations computations(member);
|
||||||
|
|
||||||
|
if (computations.IsFirstMember())
|
||||||
|
{
|
||||||
|
LINE("")
|
||||||
|
if (member->m_condition)
|
||||||
|
{
|
||||||
|
LINE_START("if(")
|
||||||
|
PrintEvaluation(member->m_condition.get());
|
||||||
|
LINE_END(")")
|
||||||
|
LINE("{")
|
||||||
|
m_intendation++;
|
||||||
|
|
||||||
|
LoadMember_Reference(info, member, DeclarationModifierComputations(member));
|
||||||
|
|
||||||
|
m_intendation--;
|
||||||
|
LINE("}")
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LoadMember_Reference(info, member, DeclarationModifierComputations(member));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (computations.IsLastMember())
|
||||||
|
{
|
||||||
|
if (member->m_condition)
|
||||||
|
{
|
||||||
|
LINE_START("else if(")
|
||||||
|
PrintEvaluation(member->m_condition.get());
|
||||||
|
LINE_END(")")
|
||||||
|
LINE("{")
|
||||||
|
m_intendation++;
|
||||||
|
|
||||||
|
LoadMember_Reference(info, member, DeclarationModifierComputations(member));
|
||||||
|
|
||||||
|
m_intendation--;
|
||||||
|
LINE("}")
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LINE("else")
|
||||||
|
LINE("{")
|
||||||
|
m_intendation++;
|
||||||
|
|
||||||
|
LoadMember_Reference(info, member, DeclarationModifierComputations(member));
|
||||||
|
|
||||||
|
m_intendation--;
|
||||||
|
LINE("}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (member->m_condition)
|
||||||
|
{
|
||||||
|
LINE_START("else if(")
|
||||||
|
PrintEvaluation(member->m_condition.get());
|
||||||
|
LINE_END(")")
|
||||||
|
LINE("{")
|
||||||
|
m_intendation++;
|
||||||
|
|
||||||
|
LoadMember_Reference(info, member, DeclarationModifierComputations(member));
|
||||||
|
|
||||||
|
m_intendation--;
|
||||||
|
LINE("}")
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LINE("#error Middle member of union must have condition ("<<member->m_member->m_name<<")")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintLoadMemberIfNeedsTreatment(StructureInformation* info, MemberInformation* member)
|
||||||
|
{
|
||||||
|
const MemberComputations computations(member);
|
||||||
|
if (computations.ShouldIgnore())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (member->m_is_string
|
||||||
|
|| member->m_is_script_string
|
||||||
|
|| computations.ContainsNonEmbeddedReference()
|
||||||
|
|| member->m_type && !member->m_type->m_is_leaf
|
||||||
|
|| computations.IsAfterPartialLoad())
|
||||||
|
{
|
||||||
|
if (info->m_definition->GetType() == DataDefinitionType::UNION)
|
||||||
|
LoadMember_Condition_Union(info, member);
|
||||||
|
else
|
||||||
|
LoadMember_Condition_Struct(info, member);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PrintLoadMethod(StructureInformation* info)
|
void PrintLoadMethod(StructureInformation* info)
|
||||||
{
|
{
|
||||||
const StructureComputations computations(info);
|
const StructureComputations computations(info);
|
||||||
@ -240,8 +479,7 @@ class ZoneLoadTemplate::Internal final : BaseTemplate
|
|||||||
|
|
||||||
for (const auto& member : info->m_ordered_members)
|
for (const auto& member : info->m_ordered_members)
|
||||||
{
|
{
|
||||||
// TODO
|
PrintLoadMemberIfNeedsTreatment(info, member.get());
|
||||||
LINE("// "<<member->m_member->m_name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->m_block || computations.IsAsset())
|
if (info->m_block || computations.IsAsset())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user