mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-21 16:45:44 +00:00
chore: update ZoneCodeGenerator code style
This commit is contained in:
parent
6d594d1651
commit
9f80909de8
@ -2,32 +2,35 @@
|
||||
|
||||
#include "Domain/Information/MemberInformation.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class MemberComputations
|
||||
{
|
||||
const MemberInformation* const m_info;
|
||||
|
||||
public:
|
||||
explicit MemberComputations(const MemberInformation* member);
|
||||
|
||||
_NODISCARD bool ShouldIgnore() const;
|
||||
_NODISCARD bool ContainsNonEmbeddedReference() const;
|
||||
_NODISCARD bool ContainsSinglePointerReference() const;
|
||||
_NODISCARD bool ContainsArrayPointerReference() const;
|
||||
_NODISCARD bool ContainsPointerArrayReference() const;
|
||||
_NODISCARD bool ContainsArrayReference() const;
|
||||
_NODISCARD const IEvaluation* GetArrayPointerCountEvaluation() const;
|
||||
_NODISCARD bool IsArray() const;
|
||||
_NODISCARD std::vector<int> GetArraySizes() const;
|
||||
_NODISCARD int GetArrayDimension() const;
|
||||
_NODISCARD bool IsPointerToArray() const;
|
||||
_NODISCARD std::vector<int> GetPointerToArraySizes() const;
|
||||
_NODISCARD int GetPointerDepth() const;
|
||||
_NODISCARD bool IsNotInDefaultNormalBlock() const;
|
||||
_NODISCARD bool IsInTempBlock() const;
|
||||
_NODISCARD bool IsInRuntimeBlock() const;
|
||||
_NODISCARD bool IsFirstMember() const;
|
||||
_NODISCARD bool IsLastMember() const;
|
||||
_NODISCARD bool HasDynamicArraySize() const;
|
||||
_NODISCARD bool IsDynamicMember() const;
|
||||
_NODISCARD bool IsAfterPartialLoad() const;
|
||||
[[nodiscard]] bool ShouldIgnore() const;
|
||||
[[nodiscard]] bool ContainsNonEmbeddedReference() const;
|
||||
[[nodiscard]] bool ContainsSinglePointerReference() const;
|
||||
[[nodiscard]] bool ContainsArrayPointerReference() const;
|
||||
[[nodiscard]] bool ContainsPointerArrayReference() const;
|
||||
[[nodiscard]] bool ContainsArrayReference() const;
|
||||
[[nodiscard]] const IEvaluation* GetArrayPointerCountEvaluation() const;
|
||||
[[nodiscard]] bool IsArray() const;
|
||||
[[nodiscard]] std::vector<int> GetArraySizes() const;
|
||||
[[nodiscard]] int GetArrayDimension() const;
|
||||
[[nodiscard]] bool IsPointerToArray() const;
|
||||
[[nodiscard]] std::vector<int> GetPointerToArraySizes() const;
|
||||
[[nodiscard]] int GetPointerDepth() const;
|
||||
[[nodiscard]] bool IsNotInDefaultNormalBlock() const;
|
||||
[[nodiscard]] bool IsInTempBlock() const;
|
||||
[[nodiscard]] bool IsInRuntimeBlock() const;
|
||||
[[nodiscard]] bool IsFirstMember() const;
|
||||
[[nodiscard]] bool IsLastMember() const;
|
||||
[[nodiscard]] bool HasDynamicArraySize() const;
|
||||
[[nodiscard]] bool IsDynamicMember() const;
|
||||
[[nodiscard]] bool IsAfterPartialLoad() const;
|
||||
|
||||
private:
|
||||
const MemberInformation* const m_info;
|
||||
};
|
||||
|
@ -2,34 +2,36 @@
|
||||
|
||||
#include "Domain/Evaluation/IEvaluation.h"
|
||||
#include "Domain/Information/MemberInformation.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class DeclarationModifierComputations
|
||||
{
|
||||
const MemberInformation* const m_information;
|
||||
std::vector<int> m_modifier_indices;
|
||||
int m_combined_index;
|
||||
|
||||
DeclarationModifierComputations(const MemberInformation* member, std::vector<int> modifierIndices);
|
||||
|
||||
public:
|
||||
explicit DeclarationModifierComputations(const MemberInformation* member);
|
||||
|
||||
_NODISCARD DeclarationModifier* GetDeclarationModifier() const;
|
||||
_NODISCARD DeclarationModifier* GetNextDeclarationModifier() const;
|
||||
_NODISCARD std::vector<DeclarationModifier*> GetFollowingDeclarationModifiers() const;
|
||||
_NODISCARD std::vector<int> GetArrayIndices() const;
|
||||
_NODISCARD bool IsArray() const;
|
||||
_NODISCARD int GetArraySize() const;
|
||||
_NODISCARD bool HasDynamicArrayCount() const;
|
||||
_NODISCARD const IEvaluation* GetDynamicArrayCountEvaluation() const;
|
||||
_NODISCARD std::vector<DeclarationModifierComputations> GetArrayEntries() const;
|
||||
_NODISCARD bool IsSinglePointer() const;
|
||||
_NODISCARD bool IsArrayPointer() const;
|
||||
_NODISCARD const IEvaluation* GetArrayPointerCountEvaluation() const;
|
||||
_NODISCARD bool IsPointerArray() const;
|
||||
_NODISCARD const IEvaluation* GetPointerArrayCountEvaluation() const;
|
||||
_NODISCARD bool IsDynamicArray() const;
|
||||
_NODISCARD const IEvaluation* GetDynamicArraySizeEvaluation() const;
|
||||
_NODISCARD unsigned GetAlignment() const;
|
||||
[[nodiscard]] DeclarationModifier* GetDeclarationModifier() const;
|
||||
[[nodiscard]] DeclarationModifier* GetNextDeclarationModifier() const;
|
||||
[[nodiscard]] std::vector<DeclarationModifier*> GetFollowingDeclarationModifiers() const;
|
||||
[[nodiscard]] std::vector<int> GetArrayIndices() const;
|
||||
[[nodiscard]] bool IsArray() const;
|
||||
[[nodiscard]] int GetArraySize() const;
|
||||
[[nodiscard]] bool HasDynamicArrayCount() const;
|
||||
[[nodiscard]] const IEvaluation* GetDynamicArrayCountEvaluation() const;
|
||||
[[nodiscard]] std::vector<DeclarationModifierComputations> GetArrayEntries() const;
|
||||
[[nodiscard]] bool IsSinglePointer() const;
|
||||
[[nodiscard]] bool IsArrayPointer() const;
|
||||
[[nodiscard]] const IEvaluation* GetArrayPointerCountEvaluation() const;
|
||||
[[nodiscard]] bool IsPointerArray() const;
|
||||
[[nodiscard]] const IEvaluation* GetPointerArrayCountEvaluation() const;
|
||||
[[nodiscard]] bool IsDynamicArray() const;
|
||||
[[nodiscard]] const IEvaluation* GetDynamicArraySizeEvaluation() const;
|
||||
[[nodiscard]] unsigned GetAlignment() const;
|
||||
|
||||
private:
|
||||
DeclarationModifierComputations(const MemberInformation* member, std::vector<int> modifierIndices);
|
||||
|
||||
const MemberInformation* const m_information;
|
||||
std::vector<int> m_modifier_indices;
|
||||
int m_combined_index;
|
||||
};
|
||||
|
@ -4,12 +4,13 @@
|
||||
|
||||
class StructureComputations
|
||||
{
|
||||
const StructureInformation* const m_info;
|
||||
|
||||
public:
|
||||
explicit StructureComputations(const StructureInformation* structure);
|
||||
|
||||
_NODISCARD bool IsAsset() const;
|
||||
_NODISCARD MemberInformation* GetDynamicMember() const;
|
||||
_NODISCARD std::vector<MemberInformation*> GetUsedMembers() const;
|
||||
[[nodiscard]] bool IsAsset() const;
|
||||
[[nodiscard]] MemberInformation* GetDynamicMember() const;
|
||||
[[nodiscard]] std::vector<MemberInformation*> GetUsedMembers() const;
|
||||
|
||||
private:
|
||||
const StructureInformation* m_info;
|
||||
};
|
||||
|
@ -2,13 +2,16 @@
|
||||
|
||||
#include "DeclarationModifier.h"
|
||||
#include "Domain/Evaluation/IEvaluation.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class ArrayDeclarationModifier final : public DeclarationModifier
|
||||
{
|
||||
public:
|
||||
explicit ArrayDeclarationModifier(int size);
|
||||
|
||||
[[nodiscard]] DeclarationModifierType GetType() const override;
|
||||
|
||||
int m_size;
|
||||
|
||||
/**
|
||||
@ -20,8 +23,4 @@ public:
|
||||
* \brief The array has a size that is given by \c m_size but only a certain dynamic amount is handled by generated count.
|
||||
*/
|
||||
std::unique_ptr<IEvaluation> m_dynamic_count_evaluation;
|
||||
|
||||
explicit ArrayDeclarationModifier(int size);
|
||||
|
||||
_NODISCARD DeclarationModifierType GetType() const override;
|
||||
};
|
||||
|
@ -4,17 +4,6 @@
|
||||
class BaseTypeDefinition final : public DataDefinition
|
||||
{
|
||||
public:
|
||||
const unsigned m_size;
|
||||
|
||||
private:
|
||||
BaseTypeDefinition(std::string name, unsigned size);
|
||||
|
||||
public:
|
||||
_NODISCARD DataDefinitionType GetType() const override;
|
||||
_NODISCARD unsigned GetAlignment() const override;
|
||||
_NODISCARD bool GetForceAlignment() const override;
|
||||
_NODISCARD unsigned GetSize() const override;
|
||||
|
||||
static const BaseTypeDefinition* const FLOAT;
|
||||
static const BaseTypeDefinition* const DOUBLE;
|
||||
static const BaseTypeDefinition* const BOOL;
|
||||
@ -32,4 +21,14 @@ public:
|
||||
|
||||
static const BaseTypeDefinition* const ALL_BASE_TYPES[];
|
||||
static const size_t ALL_BASE_TYPES_COUNT;
|
||||
|
||||
[[nodiscard]] DataDefinitionType GetType() const override;
|
||||
[[nodiscard]] unsigned GetAlignment() const override;
|
||||
[[nodiscard]] bool GetForceAlignment() const override;
|
||||
[[nodiscard]] unsigned GetSize() const override;
|
||||
|
||||
const unsigned m_size;
|
||||
|
||||
private:
|
||||
BaseTypeDefinition(std::string name, unsigned size);
|
||||
};
|
||||
|
@ -25,13 +25,13 @@ public:
|
||||
DataDefinition& operator=(const DataDefinition& other) = default;
|
||||
DataDefinition& operator=(DataDefinition&& other) noexcept = default;
|
||||
|
||||
[[nodiscard]] virtual DataDefinitionType GetType() const = 0;
|
||||
[[nodiscard]] virtual unsigned GetAlignment() const = 0;
|
||||
[[nodiscard]] virtual bool GetForceAlignment() const = 0;
|
||||
[[nodiscard]] virtual unsigned GetSize() const = 0;
|
||||
|
||||
[[nodiscard]] std::string GetFullName() const;
|
||||
|
||||
std::string m_namespace;
|
||||
std::string m_name;
|
||||
|
||||
_NODISCARD virtual DataDefinitionType GetType() const = 0;
|
||||
_NODISCARD virtual unsigned GetAlignment() const = 0;
|
||||
_NODISCARD virtual bool GetForceAlignment() const = 0;
|
||||
_NODISCARD virtual unsigned GetSize() const = 0;
|
||||
|
||||
_NODISCARD std::string GetFullName() const;
|
||||
};
|
||||
|
@ -18,5 +18,5 @@ public:
|
||||
DeclarationModifier& operator=(const DeclarationModifier& other) = default;
|
||||
DeclarationModifier& operator=(DeclarationModifier&& other) noexcept = default;
|
||||
|
||||
_NODISCARD virtual DeclarationModifierType GetType() const = 0;
|
||||
[[nodiscard]] virtual DeclarationModifierType GetType() const = 0;
|
||||
};
|
||||
|
@ -14,26 +14,6 @@ DefinitionWithMembers::DefinitionWithMembers(std::string _namespace, std::string
|
||||
{
|
||||
}
|
||||
|
||||
// void DefinitionWithMembers::CalculateAlignment()
|
||||
//{
|
||||
// if (m_has_alignment_override)
|
||||
// {
|
||||
// m_flags |= FLAG_ALIGNMENT_FORCED;
|
||||
// m_alignment = m_alignment_override;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// m_alignment = 0;
|
||||
// for (const auto& member : m_members)
|
||||
// {
|
||||
// const auto memberAlignment = member->GetAlignment();
|
||||
// if (memberAlignment > m_alignment)
|
||||
// m_alignment = memberAlignment;
|
||||
// }
|
||||
// }
|
||||
// m_flags |= FLAG_ALIGNMENT_CALCULATED;
|
||||
// }
|
||||
|
||||
unsigned DefinitionWithMembers::GetAlignment() const
|
||||
{
|
||||
assert(m_flags & FLAG_FIELDS_CALCULATED);
|
||||
|
@ -13,6 +13,12 @@ public:
|
||||
static constexpr int FLAG_FIELDS_CALCULATING = 1 << 1;
|
||||
static constexpr int FLAG_ALIGNMENT_FORCED = 1 << 2;
|
||||
|
||||
DefinitionWithMembers(std::string _namespace, std::string name, unsigned pack);
|
||||
|
||||
[[nodiscard]] unsigned GetAlignment() const override;
|
||||
[[nodiscard]] bool GetForceAlignment() const override;
|
||||
[[nodiscard]] unsigned GetSize() const override;
|
||||
|
||||
unsigned m_flags;
|
||||
unsigned m_size;
|
||||
unsigned m_alignment;
|
||||
@ -24,10 +30,4 @@ public:
|
||||
unsigned m_alignment_override;
|
||||
|
||||
std::vector<std::shared_ptr<Variable>> m_members;
|
||||
|
||||
DefinitionWithMembers(std::string _namespace, std::string name, unsigned pack);
|
||||
|
||||
_NODISCARD unsigned GetAlignment() const override;
|
||||
_NODISCARD bool GetForceAlignment() const override;
|
||||
_NODISCARD unsigned GetSize() const override;
|
||||
};
|
||||
|
@ -10,15 +10,15 @@
|
||||
class EnumDefinition final : public DataDefinition
|
||||
{
|
||||
public:
|
||||
const BaseTypeDefinition* m_parent_type;
|
||||
std::vector<std::unique_ptr<EnumMember>> m_members;
|
||||
|
||||
EnumDefinition(std::string _namespace, std::string name, const BaseTypeDefinition* parentType);
|
||||
|
||||
_NODISCARD DataDefinitionType GetType() const override;
|
||||
_NODISCARD unsigned GetAlignment() const override;
|
||||
_NODISCARD bool GetForceAlignment() const override;
|
||||
_NODISCARD unsigned GetSize() const override;
|
||||
[[nodiscard]] DataDefinitionType GetType() const override;
|
||||
[[nodiscard]] unsigned GetAlignment() const override;
|
||||
[[nodiscard]] bool GetForceAlignment() const override;
|
||||
[[nodiscard]] unsigned GetSize() const override;
|
||||
|
||||
void AddEnumMember(EnumMember enumMember);
|
||||
|
||||
const BaseTypeDefinition* m_parent_type;
|
||||
std::vector<std::unique_ptr<EnumMember>> m_members;
|
||||
};
|
||||
|
@ -5,9 +5,9 @@
|
||||
class EnumMember
|
||||
{
|
||||
public:
|
||||
std::string m_name;
|
||||
int m_value;
|
||||
|
||||
EnumMember();
|
||||
EnumMember(std::string name, int value);
|
||||
|
||||
std::string m_name;
|
||||
int m_value;
|
||||
};
|
||||
|
@ -5,13 +5,13 @@
|
||||
class ForwardDeclaration final : public DataDefinition
|
||||
{
|
||||
public:
|
||||
const DataDefinitionType m_forwarded_type;
|
||||
const DataDefinition* m_definition;
|
||||
|
||||
ForwardDeclaration(std::string _namespace, std::string name, DataDefinitionType type);
|
||||
|
||||
_NODISCARD DataDefinitionType GetType() const override;
|
||||
_NODISCARD unsigned GetAlignment() const override;
|
||||
_NODISCARD bool GetForceAlignment() const override;
|
||||
_NODISCARD unsigned GetSize() const override;
|
||||
[[nodiscard]] DataDefinitionType GetType() const override;
|
||||
[[nodiscard]] unsigned GetAlignment() const override;
|
||||
[[nodiscard]] bool GetForceAlignment() const override;
|
||||
[[nodiscard]] unsigned GetSize() const override;
|
||||
|
||||
const DataDefinitionType m_forwarded_type;
|
||||
const DataDefinition* m_definition;
|
||||
};
|
||||
|
@ -8,19 +8,19 @@
|
||||
|
||||
class PointerDeclarationModifier final : public DeclarationModifier
|
||||
{
|
||||
static const IEvaluation* const DEFAULT_COUNT;
|
||||
|
||||
static bool EvaluationIsArray(const IEvaluation* evaluation);
|
||||
|
||||
public:
|
||||
[[nodiscard]] DeclarationModifierType GetType() const override;
|
||||
[[nodiscard]] const IEvaluation* GetCountEvaluation() const;
|
||||
[[nodiscard]] const IEvaluation* GetCountEvaluationForArrayIndex(int index);
|
||||
|
||||
[[nodiscard]] bool CountEvaluationIsArray() const;
|
||||
[[nodiscard]] bool CountEvaluationIsArray(int index) const;
|
||||
[[nodiscard]] bool AnyCountEvaluationIsArray() const;
|
||||
|
||||
std::unique_ptr<IEvaluation> m_count_evaluation;
|
||||
std::vector<std::unique_ptr<IEvaluation>> m_count_evaluation_by_array_index;
|
||||
|
||||
_NODISCARD DeclarationModifierType GetType() const override;
|
||||
_NODISCARD const IEvaluation* GetCountEvaluation() const;
|
||||
_NODISCARD const IEvaluation* GetCountEvaluationForArrayIndex(int index);
|
||||
|
||||
_NODISCARD bool CountEvaluationIsArray() const;
|
||||
_NODISCARD bool CountEvaluationIsArray(int index) const;
|
||||
_NODISCARD bool AnyCountEvaluationIsArray() const;
|
||||
private:
|
||||
static const IEvaluation* const DEFAULT_COUNT;
|
||||
static bool EvaluationIsArray(const IEvaluation* evaluation);
|
||||
};
|
||||
|
@ -7,5 +7,5 @@ class StructDefinition final : public DefinitionWithMembers
|
||||
public:
|
||||
StructDefinition(std::string _namespace, std::string name, int pack);
|
||||
|
||||
_NODISCARD DataDefinitionType GetType() const override;
|
||||
[[nodiscard]] DataDefinitionType GetType() const override;
|
||||
};
|
||||
|
@ -13,21 +13,21 @@ public:
|
||||
static constexpr int FLAG_FIELDS_CALCULATED = 1 << 0;
|
||||
static constexpr int FLAG_ALIGNMENT_FORCED = 1 << 1;
|
||||
|
||||
unsigned m_flags;
|
||||
unsigned m_size;
|
||||
unsigned m_alignment;
|
||||
|
||||
explicit TypeDeclaration(const DataDefinition* type);
|
||||
|
||||
[[nodiscard]] unsigned GetSize() const;
|
||||
[[nodiscard]] unsigned GetAlignment() const;
|
||||
[[nodiscard]] bool GetForceAlignment() const;
|
||||
|
||||
std::vector<std::unique_ptr<DeclarationModifier>> m_declaration_modifiers;
|
||||
|
||||
bool m_is_const;
|
||||
bool m_has_custom_bit_size;
|
||||
|
||||
const DataDefinition* m_type;
|
||||
unsigned m_custom_bit_size;
|
||||
|
||||
std::vector<std::unique_ptr<DeclarationModifier>> m_declaration_modifiers;
|
||||
|
||||
_NODISCARD unsigned GetSize() const;
|
||||
_NODISCARD unsigned GetAlignment() const;
|
||||
_NODISCARD bool GetForceAlignment() const;
|
||||
unsigned m_flags;
|
||||
unsigned m_size;
|
||||
unsigned m_alignment;
|
||||
};
|
||||
|
@ -6,14 +6,14 @@
|
||||
class TypedefDefinition final : public DataDefinition
|
||||
{
|
||||
public:
|
||||
TypedefDefinition(std::string _namespace, std::string name, std::unique_ptr<TypeDeclaration> typeDeclaration);
|
||||
|
||||
[[nodiscard]] DataDefinitionType GetType() const override;
|
||||
[[nodiscard]] unsigned GetAlignment() const override;
|
||||
[[nodiscard]] bool GetForceAlignment() const override;
|
||||
[[nodiscard]] unsigned GetSize() const override;
|
||||
|
||||
bool m_has_alignment_override;
|
||||
unsigned m_alignment_override;
|
||||
std::unique_ptr<TypeDeclaration> m_type_declaration;
|
||||
|
||||
TypedefDefinition(std::string _namespace, std::string name, std::unique_ptr<TypeDeclaration> typeDeclaration);
|
||||
|
||||
_NODISCARD DataDefinitionType GetType() const override;
|
||||
_NODISCARD unsigned GetAlignment() const override;
|
||||
_NODISCARD bool GetForceAlignment() const override;
|
||||
_NODISCARD unsigned GetSize() const override;
|
||||
};
|
||||
|
@ -4,11 +4,8 @@
|
||||
|
||||
class UnionDefinition final : public DefinitionWithMembers
|
||||
{
|
||||
// protected:
|
||||
// void CalculateSize() override;
|
||||
|
||||
public:
|
||||
UnionDefinition(std::string _namespace, std::string name, int pack);
|
||||
|
||||
_NODISCARD DataDefinitionType GetType() const override;
|
||||
[[nodiscard]] DataDefinitionType GetType() const override;
|
||||
};
|
||||
|
@ -9,14 +9,14 @@
|
||||
class Variable
|
||||
{
|
||||
public:
|
||||
Variable(std::string name, std::unique_ptr<TypeDeclaration> typeDeclaration);
|
||||
|
||||
[[nodiscard]] unsigned GetAlignment() const;
|
||||
[[nodiscard]] bool GetForceAlignment() const;
|
||||
|
||||
std::string m_name;
|
||||
bool m_has_alignment_override;
|
||||
unsigned m_alignment_override;
|
||||
unsigned m_offset;
|
||||
std::unique_ptr<TypeDeclaration> m_type_declaration;
|
||||
|
||||
Variable(std::string name, std::unique_ptr<TypeDeclaration> typeDeclaration);
|
||||
|
||||
_NODISCARD unsigned GetAlignment() const;
|
||||
_NODISCARD bool GetForceAlignment() const;
|
||||
};
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
enum class EvaluationType
|
||||
{
|
||||
OPERAND_DYNAMIC,
|
||||
@ -20,7 +18,7 @@ public:
|
||||
IEvaluation& operator=(const IEvaluation& other) = default;
|
||||
IEvaluation& operator=(IEvaluation&& other) noexcept = default;
|
||||
|
||||
_NODISCARD virtual EvaluationType GetType() const = 0;
|
||||
_NODISCARD virtual bool IsStatic() const = 0;
|
||||
_NODISCARD virtual int EvaluateNumeric() const = 0;
|
||||
[[nodiscard]] virtual EvaluationType GetType() const = 0;
|
||||
[[nodiscard]] virtual bool IsStatic() const = 0;
|
||||
[[nodiscard]] virtual int EvaluateNumeric() const = 0;
|
||||
};
|
||||
|
@ -9,16 +9,16 @@
|
||||
class OperandDynamic final : public IEvaluation
|
||||
{
|
||||
public:
|
||||
StructureInformation* const m_structure;
|
||||
std::vector<MemberInformation*> m_referenced_member_chain;
|
||||
std::vector<std::unique_ptr<IEvaluation>> m_array_indices;
|
||||
|
||||
explicit OperandDynamic(StructureInformation* structure);
|
||||
OperandDynamic(StructureInformation* structure,
|
||||
std::vector<MemberInformation*> referencedMemberChain,
|
||||
std::vector<std::unique_ptr<IEvaluation>> arrayIndices);
|
||||
|
||||
_NODISCARD EvaluationType GetType() const override;
|
||||
_NODISCARD bool IsStatic() const override;
|
||||
_NODISCARD int EvaluateNumeric() const override;
|
||||
[[nodiscard]] EvaluationType GetType() const override;
|
||||
[[nodiscard]] bool IsStatic() const override;
|
||||
[[nodiscard]] int EvaluateNumeric() const override;
|
||||
|
||||
StructureInformation* const m_structure;
|
||||
std::vector<MemberInformation*> m_referenced_member_chain;
|
||||
std::vector<std::unique_ptr<IEvaluation>> m_array_indices;
|
||||
};
|
||||
|
@ -6,13 +6,13 @@
|
||||
class OperandStatic final : public IEvaluation
|
||||
{
|
||||
public:
|
||||
const int m_value;
|
||||
EnumMember* const m_enum_member;
|
||||
|
||||
explicit OperandStatic(int value);
|
||||
explicit OperandStatic(EnumMember* enumMember);
|
||||
|
||||
_NODISCARD EvaluationType GetType() const override;
|
||||
_NODISCARD bool IsStatic() const override;
|
||||
_NODISCARD int EvaluateNumeric() const override;
|
||||
[[nodiscard]] EvaluationType GetType() const override;
|
||||
[[nodiscard]] bool IsStatic() const override;
|
||||
[[nodiscard]] int EvaluateNumeric() const override;
|
||||
|
||||
const int m_value;
|
||||
EnumMember* const m_enum_member;
|
||||
};
|
||||
|
@ -9,17 +9,17 @@
|
||||
class Operation final : public IEvaluation
|
||||
{
|
||||
public:
|
||||
const OperationType* const m_operation_type;
|
||||
std::unique_ptr<IEvaluation> m_operand1;
|
||||
std::unique_ptr<IEvaluation> m_operand2;
|
||||
|
||||
explicit Operation(const OperationType* type);
|
||||
Operation(const OperationType* type, std::unique_ptr<IEvaluation> operand1, std::unique_ptr<IEvaluation> operand2);
|
||||
|
||||
_NODISCARD EvaluationType GetType() const override;
|
||||
_NODISCARD bool IsStatic() const override;
|
||||
_NODISCARD int EvaluateNumeric() const override;
|
||||
[[nodiscard]] EvaluationType GetType() const override;
|
||||
[[nodiscard]] bool IsStatic() const override;
|
||||
[[nodiscard]] int EvaluateNumeric() const override;
|
||||
|
||||
_NODISCARD bool Operand1NeedsParenthesis() const;
|
||||
_NODISCARD bool Operand2NeedsParenthesis() const;
|
||||
[[nodiscard]] bool Operand1NeedsParenthesis() const;
|
||||
[[nodiscard]] bool Operand2NeedsParenthesis() const;
|
||||
|
||||
const OperationType* const m_operation_type;
|
||||
std::unique_ptr<IEvaluation> m_operand1;
|
||||
std::unique_ptr<IEvaluation> m_operand2;
|
||||
};
|
||||
|
@ -20,14 +20,6 @@ enum class OperationPrecedence
|
||||
|
||||
class OperationType
|
||||
{
|
||||
public:
|
||||
std::string m_syntax;
|
||||
OperationPrecedence m_precedence;
|
||||
std::function<int(int operand1, int operand2)> m_evaluation_function;
|
||||
|
||||
private:
|
||||
OperationType(std::string syntax, OperationPrecedence precedence, std::function<int(int, int)> evaluationFunction);
|
||||
|
||||
public:
|
||||
static const OperationType* const OPERATION_ADD;
|
||||
static const OperationType* const OPERATION_SUBTRACT;
|
||||
@ -49,4 +41,11 @@ public:
|
||||
static const OperationType* const OPERATION_OR;
|
||||
|
||||
static const OperationType* const ALL_OPERATION_TYPES[];
|
||||
|
||||
std::string m_syntax;
|
||||
OperationPrecedence m_precedence;
|
||||
std::function<int(int operand1, int operand2)> m_evaluation_function;
|
||||
|
||||
private:
|
||||
OperationType(std::string syntax, OperationPrecedence precedence, std::function<int(int, int)> evaluationFunction);
|
||||
};
|
||||
|
@ -8,8 +8,8 @@
|
||||
class CustomAction
|
||||
{
|
||||
public:
|
||||
CustomAction(std::string actionName, std::vector<DataDefinition*> parameterTypes);
|
||||
|
||||
std::string m_action_name;
|
||||
std::vector<DataDefinition*> m_parameter_types;
|
||||
|
||||
CustomAction(std::string actionName, std::vector<DataDefinition*> parameterTypes);
|
||||
};
|
||||
|
@ -13,10 +13,10 @@ enum class FastFileBlockType
|
||||
class FastFileBlock
|
||||
{
|
||||
public:
|
||||
FastFileBlock(std::string name, unsigned index, FastFileBlockType type, bool isDefault);
|
||||
|
||||
std::string m_name;
|
||||
unsigned m_index;
|
||||
FastFileBlockType m_type;
|
||||
bool m_is_default;
|
||||
|
||||
FastFileBlock(std::string name, unsigned index, FastFileBlockType type, bool isDefault);
|
||||
};
|
||||
|
@ -12,6 +12,8 @@ class StructureInformation;
|
||||
class MemberInformation
|
||||
{
|
||||
public:
|
||||
MemberInformation(StructureInformation* parent, StructureInformation* type, Variable* member);
|
||||
|
||||
StructureInformation* m_parent;
|
||||
StructureInformation* m_type;
|
||||
Variable* m_member;
|
||||
@ -24,6 +26,4 @@ public:
|
||||
std::unique_ptr<CustomAction> m_post_load_action;
|
||||
const FastFileBlock* m_fast_file_block;
|
||||
const EnumMember* m_asset_ref;
|
||||
|
||||
MemberInformation(StructureInformation* parent, StructureInformation* type, Variable* member);
|
||||
};
|
||||
|
@ -5,13 +5,17 @@
|
||||
#include "Domain/Extension/CustomAction.h"
|
||||
#include "Domain/FastFile/FastFileBlock.h"
|
||||
#include "MemberInformation.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class MemberInformation;
|
||||
|
||||
class StructureInformation
|
||||
{
|
||||
public:
|
||||
explicit StructureInformation(DefinitionWithMembers* definition);
|
||||
|
||||
DefinitionWithMembers* const m_definition;
|
||||
EnumMember* m_asset_enum_entry;
|
||||
|
||||
@ -31,6 +35,4 @@ public:
|
||||
std::unique_ptr<CustomAction> m_post_load_action;
|
||||
const FastFileBlock* m_block;
|
||||
std::vector<MemberInformation*> m_name_chain;
|
||||
|
||||
explicit StructureInformation(DefinitionWithMembers* definition);
|
||||
};
|
||||
|
@ -3,21 +3,24 @@
|
||||
#include "ICodeTemplate.h"
|
||||
#include "ZoneCodeGeneratorArguments.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
class CodeGenerator
|
||||
{
|
||||
const ZoneCodeGeneratorArguments* m_args;
|
||||
public:
|
||||
explicit CodeGenerator(const ZoneCodeGeneratorArguments* args);
|
||||
|
||||
std::unordered_map<std::string, std::unique_ptr<ICodeTemplate>> m_template_mapping;
|
||||
bool GenerateCode(IDataRepository* repository);
|
||||
|
||||
private:
|
||||
void SetupTemplates();
|
||||
|
||||
bool GenerateCodeForTemplate(RenderingContext* context, ICodeTemplate* codeTemplate) const;
|
||||
static bool GetAssetWithName(IDataRepository* repository, const std::string& name, StructureInformation*& asset);
|
||||
|
||||
public:
|
||||
explicit CodeGenerator(const ZoneCodeGeneratorArguments* args);
|
||||
const ZoneCodeGeneratorArguments* m_args;
|
||||
|
||||
bool GenerateCode(IDataRepository* repository);
|
||||
std::unordered_map<std::string, std::unique_ptr<ICodeTemplate>> m_template_mapping;
|
||||
};
|
||||
|
@ -10,6 +10,8 @@
|
||||
class RenderingUsedType
|
||||
{
|
||||
public:
|
||||
RenderingUsedType(const DataDefinition* type, StructureInformation* info);
|
||||
|
||||
bool m_members_loaded;
|
||||
const DataDefinition* m_type;
|
||||
StructureInformation* m_info;
|
||||
@ -20,25 +22,13 @@ public:
|
||||
bool m_array_reference_exists;
|
||||
bool m_pointer_array_reference_exists;
|
||||
bool m_pointer_array_reference_is_reusable;
|
||||
|
||||
RenderingUsedType(const DataDefinition* type, StructureInformation* info);
|
||||
};
|
||||
|
||||
class RenderingContext
|
||||
{
|
||||
std::unordered_map<const DataDefinition*, std::unique_ptr<RenderingUsedType>> m_used_types_lookup;
|
||||
|
||||
RenderingContext(std::string game, std::vector<const FastFileBlock*> fastFileBlocks);
|
||||
|
||||
RenderingUsedType* AddUsedType(std::unique_ptr<RenderingUsedType> usedType);
|
||||
RenderingUsedType* GetBaseType(const IDataRepository* repository, MemberComputations* computations, RenderingUsedType* usedType);
|
||||
void AddMembersToContext(const IDataRepository* repository, StructureInformation* info);
|
||||
void ScanUsedTypeIfNeeded(const IDataRepository* repository, MemberComputations* computations, RenderingUsedType* usedType);
|
||||
void MakeAsset(const IDataRepository* repository, StructureInformation* asset);
|
||||
void CreateUsedTypeCollections();
|
||||
bool UsedTypeHasActions(const RenderingUsedType* usedType) const;
|
||||
|
||||
public:
|
||||
static std::unique_ptr<RenderingContext> BuildContext(const IDataRepository* repository, StructureInformation* asset);
|
||||
|
||||
std::string m_game;
|
||||
std::vector<const FastFileBlock*> m_blocks;
|
||||
|
||||
@ -52,5 +42,16 @@ public:
|
||||
const FastFileBlock* m_default_normal_block;
|
||||
const FastFileBlock* m_default_temp_block;
|
||||
|
||||
static std::unique_ptr<RenderingContext> BuildContext(const IDataRepository* repository, StructureInformation* asset);
|
||||
private:
|
||||
RenderingContext(std::string game, std::vector<const FastFileBlock*> fastFileBlocks);
|
||||
|
||||
RenderingUsedType* AddUsedType(std::unique_ptr<RenderingUsedType> usedType);
|
||||
RenderingUsedType* GetBaseType(const IDataRepository* repository, MemberComputations* computations, RenderingUsedType* usedType);
|
||||
void AddMembersToContext(const IDataRepository* repository, StructureInformation* info);
|
||||
void ScanUsedTypeIfNeeded(const IDataRepository* repository, MemberComputations* computations, RenderingUsedType* usedType);
|
||||
void MakeAsset(const IDataRepository* repository, StructureInformation* asset);
|
||||
void CreateUsedTypeCollections();
|
||||
bool UsedTypeHasActions(const RenderingUsedType* usedType) const;
|
||||
|
||||
std::unordered_map<const DataDefinition*, std::unique_ptr<RenderingUsedType>> m_used_types_lookup;
|
||||
};
|
||||
|
@ -6,34 +6,14 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
class AssetStructTestsTemplate::Internal final : BaseTemplate
|
||||
namespace
|
||||
{
|
||||
void TestMethod(StructureInformation* structure)
|
||||
static constexpr int TAG_SOURCE = 1;
|
||||
|
||||
class Template final : BaseTemplate
|
||||
{
|
||||
LINE("TEST_CASE(\"" << m_env.m_game << "::" << m_env.m_asset->m_definition->GetFullName() << ": Tests for " << structure->m_definition->GetFullName()
|
||||
<< "\", \"[assetstruct]\")")
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
for (const auto& member : structure->m_ordered_members)
|
||||
{
|
||||
if (!member->m_member->m_name.empty() && !member->m_member->m_type_declaration->m_has_custom_bit_size)
|
||||
{
|
||||
LINE("REQUIRE(offsetof(" << structure->m_definition->GetFullName() << ", " << member->m_member->m_name << ") == " << member->m_member->m_offset
|
||||
<< ");")
|
||||
}
|
||||
}
|
||||
|
||||
LINE("")
|
||||
|
||||
LINE("REQUIRE(" << structure->m_definition->GetSize() << "u == sizeof(" << structure->m_definition->GetFullName() << "));")
|
||||
LINE("REQUIRE(" << structure->m_definition->GetAlignment() << "u == alignof(" << structure->m_definition->GetFullName() << "));")
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
}
|
||||
|
||||
public:
|
||||
Internal(std::ostream& stream, RenderingContext* context)
|
||||
public:
|
||||
Template(std::ostream& stream, RenderingContext* context)
|
||||
: BaseTemplate(stream, context)
|
||||
{
|
||||
}
|
||||
@ -68,7 +48,33 @@ public:
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
void TestMethod(StructureInformation* structure)
|
||||
{
|
||||
LINE("TEST_CASE(\"" << m_env.m_game << "::" << m_env.m_asset->m_definition->GetFullName() << ": Tests for "
|
||||
<< structure->m_definition->GetFullName() << "\", \"[assetstruct]\")")
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
for (const auto& member : structure->m_ordered_members)
|
||||
{
|
||||
if (!member->m_member->m_name.empty() && !member->m_member->m_type_declaration->m_has_custom_bit_size)
|
||||
{
|
||||
LINE("REQUIRE(offsetof(" << structure->m_definition->GetFullName() << ", " << member->m_member->m_name
|
||||
<< ") == " << member->m_member->m_offset << ");")
|
||||
}
|
||||
}
|
||||
|
||||
LINE("")
|
||||
|
||||
LINE("REQUIRE(" << structure->m_definition->GetSize() << "u == sizeof(" << structure->m_definition->GetFullName() << "));")
|
||||
LINE("REQUIRE(" << structure->m_definition->GetAlignment() << "u == alignof(" << structure->m_definition->GetFullName() << "));")
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
std::vector<CodeTemplateFile> AssetStructTestsTemplate::GetFilesToRender(RenderingContext* context)
|
||||
{
|
||||
@ -89,10 +95,10 @@ std::vector<CodeTemplateFile> AssetStructTestsTemplate::GetFilesToRender(Renderi
|
||||
|
||||
void AssetStructTestsTemplate::RenderFile(std::ostream& stream, const int fileTag, RenderingContext* context)
|
||||
{
|
||||
Internal internal(stream, context);
|
||||
Template t(stream, context);
|
||||
|
||||
if (fileTag == TAG_SOURCE)
|
||||
internal.Source();
|
||||
t.Source();
|
||||
else
|
||||
std::cout << "Invalid tag in AssetStructTestsTemplate\n";
|
||||
}
|
||||
|
@ -3,10 +3,6 @@
|
||||
|
||||
class AssetStructTestsTemplate final : public ICodeTemplate
|
||||
{
|
||||
static constexpr int TAG_SOURCE = 1;
|
||||
|
||||
class Internal;
|
||||
|
||||
public:
|
||||
std::vector<CodeTemplateFile> GetFilesToRender(RenderingContext* context) override;
|
||||
void RenderFile(std::ostream& stream, int fileTag, RenderingContext* context) override;
|
||||
|
@ -15,27 +15,10 @@ class BaseTemplate
|
||||
protected:
|
||||
static constexpr const char* INTENDATION = " ";
|
||||
|
||||
std::ostream& m_out;
|
||||
RenderingContext& m_env;
|
||||
unsigned m_intendation;
|
||||
|
||||
BaseTemplate(std::ostream& stream, RenderingContext* context);
|
||||
|
||||
void DoIntendation() const;
|
||||
|
||||
private:
|
||||
static void MakeSafeTypeNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||
static void MakeTypeVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||
static void MakeTypeWrittenVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||
static void MakeTypePtrVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||
static void MakeTypeWrittenPtrVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||
static void MakeArrayIndicesInternal(const DeclarationModifierComputations& modifierComputations, std::ostringstream& str);
|
||||
static void MakeOperandStatic(const OperandStatic* op, std::ostringstream& str);
|
||||
static void MakeOperandDynamic(const OperandDynamic* op, std::ostringstream& str);
|
||||
static void MakeOperation(const Operation* operation, std::ostringstream& str);
|
||||
static void MakeEvaluationInternal(const IEvaluation* evaluation, std::ostringstream& str);
|
||||
|
||||
protected:
|
||||
static std::string Upper(std::string str);
|
||||
static std::string Lower(std::string str);
|
||||
static std::string MakeTypeVarName(const DataDefinition* def);
|
||||
@ -55,6 +38,22 @@ protected:
|
||||
static std::string MakeCustomActionCall(CustomAction* action);
|
||||
static std::string MakeArrayCount(const ArrayDeclarationModifier* arrayModifier);
|
||||
static std::string MakeEvaluation(const IEvaluation* evaluation);
|
||||
|
||||
std::ostream& m_out;
|
||||
RenderingContext& m_env;
|
||||
unsigned m_intendation;
|
||||
|
||||
private:
|
||||
static void MakeSafeTypeNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||
static void MakeTypeVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||
static void MakeTypeWrittenVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||
static void MakeTypePtrVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||
static void MakeTypeWrittenPtrVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||
static void MakeArrayIndicesInternal(const DeclarationModifierComputations& modifierComputations, std::ostringstream& str);
|
||||
static void MakeOperandStatic(const OperandStatic* op, std::ostringstream& str);
|
||||
static void MakeOperandDynamic(const OperandDynamic* op, std::ostringstream& str);
|
||||
static void MakeOperation(const Operation* operation, std::ostringstream& str);
|
||||
static void MakeEvaluationInternal(const IEvaluation* evaluation, std::ostringstream& str);
|
||||
};
|
||||
|
||||
#define LINE(x) \
|
||||
|
@ -8,8 +8,175 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
class ZoneLoadTemplate::Internal final : BaseTemplate
|
||||
namespace
|
||||
{
|
||||
static constexpr int TAG_HEADER = 1;
|
||||
static constexpr int TAG_SOURCE = 2;
|
||||
|
||||
class Template final : BaseTemplate
|
||||
{
|
||||
public:
|
||||
Template(std::ostream& stream, RenderingContext* context)
|
||||
: BaseTemplate(stream, context)
|
||||
{
|
||||
}
|
||||
|
||||
void Header()
|
||||
{
|
||||
LINE("// ====================================================================")
|
||||
LINE("// This file has been generated by ZoneCodeGenerator.")
|
||||
LINE("// Do not modify. ")
|
||||
LINE("// Any changes will be discarded when regenerating.")
|
||||
LINE("// ====================================================================")
|
||||
LINE("")
|
||||
LINE("#pragma once")
|
||||
LINE("")
|
||||
LINE("#include \"Loading/AssetLoader.h\"")
|
||||
LINE("#include \"Game/" << m_env.m_game << "/" << m_env.m_game << ".h\"")
|
||||
if (m_env.m_has_actions)
|
||||
{
|
||||
LINE("#include \"Game/" << m_env.m_game << "/XAssets/" << Lower(m_env.m_asset->m_definition->m_name) << "/"
|
||||
<< Lower(m_env.m_asset->m_definition->m_name) << "_actions.h\"")
|
||||
}
|
||||
LINE("#include <string>")
|
||||
LINE("")
|
||||
LINE("namespace " << m_env.m_game)
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
LINE("class " << LoaderClassName(m_env.m_asset) << " final : public AssetLoader")
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
LINE("XAssetInfo<" << m_env.m_asset->m_definition->GetFullName() << ">* m_asset_info;")
|
||||
if (m_env.m_has_actions)
|
||||
{
|
||||
LINE("Actions_" << m_env.m_asset->m_definition->m_name << " m_actions;")
|
||||
}
|
||||
LINE(VariableDecl(m_env.m_asset->m_definition))
|
||||
LINE(PointerVariableDecl(m_env.m_asset->m_definition))
|
||||
LINE("")
|
||||
|
||||
// Variable Declarations: type varType;
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_info && !type->m_info->m_definition->m_anonymous && !type->m_info->m_is_leaf && !StructureComputations(type->m_info).IsAsset())
|
||||
{
|
||||
LINE(VariableDecl(type->m_type))
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists && !type->m_is_context_asset)
|
||||
{
|
||||
LINE(PointerVariableDecl(type->m_type))
|
||||
}
|
||||
}
|
||||
|
||||
LINE("")
|
||||
|
||||
// Method Declarations
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists)
|
||||
{
|
||||
PrintHeaderPtrArrayLoadMethodDeclaration(type->m_type);
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_array_reference_exists && type->m_info && !type->m_info->m_is_leaf && type->m_non_runtime_reference_exists)
|
||||
{
|
||||
PrintHeaderArrayLoadMethodDeclaration(type->m_type);
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_structures)
|
||||
{
|
||||
if (type->m_non_runtime_reference_exists && !type->m_info->m_is_leaf && !StructureComputations(type->m_info).IsAsset())
|
||||
{
|
||||
PrintHeaderLoadMethodDeclaration(type->m_info);
|
||||
}
|
||||
}
|
||||
PrintHeaderLoadMethodDeclaration(m_env.m_asset);
|
||||
PrintHeaderTempPtrLoadMethodDeclaration(m_env.m_asset);
|
||||
PrintHeaderAssetLoadMethodDeclaration(m_env.m_asset);
|
||||
LINE("")
|
||||
m_intendation--;
|
||||
LINE("public:")
|
||||
m_intendation++;
|
||||
PrintHeaderConstructor();
|
||||
PrintHeaderMainLoadMethodDeclaration(m_env.m_asset);
|
||||
PrintHeaderGetNameMethodDeclaration(m_env.m_asset);
|
||||
|
||||
m_intendation--;
|
||||
LINE("};")
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
}
|
||||
|
||||
void Source()
|
||||
{
|
||||
LINE("// ====================================================================")
|
||||
LINE("// This file has been generated by ZoneCodeGenerator.")
|
||||
LINE("// Do not modify. ")
|
||||
LINE("// Any changes will be discarded when regenerating.")
|
||||
LINE("// ====================================================================")
|
||||
LINE("")
|
||||
LINE("#include \"" << Lower(m_env.m_asset->m_definition->m_name) << "_load_db.h\"")
|
||||
LINE("#include \"" << Lower(m_env.m_asset->m_definition->m_name) << "_mark_db.h\"")
|
||||
LINE("#include <cassert>")
|
||||
LINE("#include <cstring>")
|
||||
LINE("")
|
||||
|
||||
if (!m_env.m_referenced_assets.empty())
|
||||
{
|
||||
LINE("// Referenced Assets:")
|
||||
for (auto* type : m_env.m_referenced_assets)
|
||||
{
|
||||
LINE("#include \"../" << Lower(type->m_type->m_name) << "/" << Lower(type->m_type->m_name) << "_load_db.h\"")
|
||||
}
|
||||
LINE("")
|
||||
}
|
||||
LINE("using namespace " << m_env.m_game << ";")
|
||||
LINE("")
|
||||
PrintConstructorMethod();
|
||||
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists)
|
||||
{
|
||||
LINE("")
|
||||
PrintLoadPtrArrayMethod(type->m_type, type->m_info, type->m_pointer_array_reference_is_reusable);
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_array_reference_exists && type->m_info && !type->m_info->m_is_leaf && type->m_non_runtime_reference_exists)
|
||||
{
|
||||
LINE("")
|
||||
PrintLoadArrayMethod(type->m_type, type->m_info);
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_structures)
|
||||
{
|
||||
if (type->m_non_runtime_reference_exists && !type->m_info->m_is_leaf && !StructureComputations(type->m_info).IsAsset())
|
||||
{
|
||||
LINE("")
|
||||
PrintLoadMethod(type->m_info);
|
||||
}
|
||||
}
|
||||
LINE("")
|
||||
PrintLoadMethod(m_env.m_asset);
|
||||
LINE("")
|
||||
PrintLoadPtrMethod(m_env.m_asset);
|
||||
LINE("")
|
||||
PrintLoadAssetMethod(m_env.m_asset);
|
||||
LINE("")
|
||||
PrintMainLoadMethod();
|
||||
LINE("")
|
||||
PrintGetNameMethod();
|
||||
}
|
||||
|
||||
private:
|
||||
enum class MemberLoadType
|
||||
{
|
||||
ARRAY_POINTER,
|
||||
@ -337,8 +504,8 @@ class ZoneLoadTemplate::Internal final : BaseTemplate
|
||||
else
|
||||
{
|
||||
LINE("m_stream->Load<" << MakeTypeDecl(member->m_member->m_type_declaration.get())
|
||||
<< MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()) << ">(" << MakeMemberAccess(info, member, modifier)
|
||||
<< ", " << MakeEvaluation(modifier.GetArrayPointerCountEvaluation()) << ");")
|
||||
<< MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()) << ">("
|
||||
<< MakeMemberAccess(info, member, modifier) << ", " << MakeEvaluation(modifier.GetArrayPointerCountEvaluation()) << ");")
|
||||
}
|
||||
}
|
||||
|
||||
@ -394,8 +561,8 @@ class ZoneLoadTemplate::Internal final : BaseTemplate
|
||||
else if (computations.IsAfterPartialLoad())
|
||||
{
|
||||
LINE("m_stream->Load<" << MakeTypeDecl(member->m_member->m_type_declaration.get())
|
||||
<< MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()) << ">(" << MakeMemberAccess(info, member, modifier)
|
||||
<< ", " << arraySizeStr << ");")
|
||||
<< MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()) << ">("
|
||||
<< MakeMemberAccess(info, member, modifier) << ", " << arraySizeStr << ");")
|
||||
}
|
||||
}
|
||||
|
||||
@ -410,8 +577,8 @@ class ZoneLoadTemplate::Internal final : BaseTemplate
|
||||
else
|
||||
{
|
||||
LINE("m_stream->Load<" << MakeTypeDecl(member->m_member->m_type_declaration.get())
|
||||
<< MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()) << ">(" << MakeMemberAccess(info, member, modifier)
|
||||
<< ", " << MakeEvaluation(modifier.GetDynamicArraySizeEvaluation()) << ");")
|
||||
<< MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()) << ">("
|
||||
<< MakeMemberAccess(info, member, modifier) << ", " << MakeEvaluation(modifier.GetDynamicArraySizeEvaluation()) << ");")
|
||||
}
|
||||
}
|
||||
|
||||
@ -446,8 +613,8 @@ class ZoneLoadTemplate::Internal final : BaseTemplate
|
||||
else if (computations.IsAfterPartialLoad())
|
||||
{
|
||||
LINE("m_stream->Load<" << MakeTypeDecl(member->m_member->m_type_declaration.get())
|
||||
<< MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()) << ">(&" << MakeMemberAccess(info, member, modifier)
|
||||
<< ");")
|
||||
<< MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()) << ">(&"
|
||||
<< MakeMemberAccess(info, member, modifier) << ");")
|
||||
}
|
||||
}
|
||||
|
||||
@ -474,8 +641,8 @@ class ZoneLoadTemplate::Internal final : BaseTemplate
|
||||
else
|
||||
{
|
||||
LINE("m_stream->Load<" << MakeTypeDecl(member->m_member->m_type_declaration.get())
|
||||
<< MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()) << ">(" << MakeMemberAccess(info, member, modifier)
|
||||
<< ");")
|
||||
<< MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()) << ">("
|
||||
<< MakeMemberAccess(info, member, modifier) << ");")
|
||||
}
|
||||
}
|
||||
|
||||
@ -555,7 +722,10 @@ class ZoneLoadTemplate::Internal final : BaseTemplate
|
||||
return true;
|
||||
}
|
||||
|
||||
void LoadMember_Alloc(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier, const MemberLoadType loadType)
|
||||
void LoadMember_Alloc(StructureInformation* info,
|
||||
MemberInformation* member,
|
||||
const DeclarationModifierComputations& modifier,
|
||||
const MemberLoadType loadType)
|
||||
{
|
||||
if (!LoadMember_ShouldMakeAlloc(info, member, modifier, loadType))
|
||||
{
|
||||
@ -574,8 +744,8 @@ class ZoneLoadTemplate::Internal final : BaseTemplate
|
||||
|
||||
// This used to use `alignof()` to calculate alignment but due to inconsistencies between compilers and bugs discovered in MSVC
|
||||
// (Alignment specified via `__declspec(align())` showing as correct via intellisense but is incorrect when compiled for types that have a larger
|
||||
// alignment than the specified value) this was changed to make ZoneCodeGenerator calculate what is supposed to be used as alignment when allocating.
|
||||
// This is more reliable when being used with different compilers and the value used can be seen in the source code directly
|
||||
// alignment than the specified value) this was changed to make ZoneCodeGenerator calculate what is supposed to be used as alignment when
|
||||
// allocating. This is more reliable when being used with different compilers and the value used can be seen in the source code directly
|
||||
if (member->m_alloc_alignment)
|
||||
{
|
||||
LINE(MakeMemberAccess(info, member, modifier)
|
||||
@ -628,7 +798,10 @@ class ZoneLoadTemplate::Internal final : BaseTemplate
|
||||
return true;
|
||||
}
|
||||
|
||||
void LoadMember_Reuse(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier, const MemberLoadType loadType)
|
||||
void LoadMember_Reuse(StructureInformation* info,
|
||||
MemberInformation* member,
|
||||
const DeclarationModifierComputations& modifier,
|
||||
const MemberLoadType loadType)
|
||||
{
|
||||
if (!LoadMember_ShouldMakeReuse(info, member, modifier, loadType) || !member->m_is_reusable)
|
||||
{
|
||||
@ -639,7 +812,8 @@ class ZoneLoadTemplate::Internal final : BaseTemplate
|
||||
const MemberComputations computations(member);
|
||||
if (computations.IsInTempBlock())
|
||||
{
|
||||
LINE("if(" << MakeMemberAccess(info, member, modifier) << " == PTR_FOLLOWING || " << MakeMemberAccess(info, member, modifier) << " == PTR_INSERT)")
|
||||
LINE("if(" << MakeMemberAccess(info, member, modifier) << " == PTR_FOLLOWING || " << MakeMemberAccess(info, member, modifier)
|
||||
<< " == PTR_INSERT)")
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
@ -987,7 +1161,8 @@ class ZoneLoadTemplate::Internal final : BaseTemplate
|
||||
|
||||
if (inTemp)
|
||||
{
|
||||
LINE("if(*" << MakeTypePtrVarName(info->m_definition) << " == PTR_FOLLOWING || *" << MakeTypePtrVarName(info->m_definition) << " == PTR_INSERT)")
|
||||
LINE("if(*" << MakeTypePtrVarName(info->m_definition) << " == PTR_FOLLOWING || *" << MakeTypePtrVarName(info->m_definition)
|
||||
<< " == PTR_INSERT)")
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1168,168 +1343,8 @@ class ZoneLoadTemplate::Internal final : BaseTemplate
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
}
|
||||
|
||||
public:
|
||||
Internal(std::ostream& stream, RenderingContext* context)
|
||||
: BaseTemplate(stream, context)
|
||||
{
|
||||
}
|
||||
|
||||
void Header()
|
||||
{
|
||||
LINE("// ====================================================================")
|
||||
LINE("// This file has been generated by ZoneCodeGenerator.")
|
||||
LINE("// Do not modify. ")
|
||||
LINE("// Any changes will be discarded when regenerating.")
|
||||
LINE("// ====================================================================")
|
||||
LINE("")
|
||||
LINE("#pragma once")
|
||||
LINE("")
|
||||
LINE("#include \"Loading/AssetLoader.h\"")
|
||||
LINE("#include \"Game/" << m_env.m_game << "/" << m_env.m_game << ".h\"")
|
||||
if (m_env.m_has_actions)
|
||||
{
|
||||
LINE("#include \"Game/" << m_env.m_game << "/XAssets/" << Lower(m_env.m_asset->m_definition->m_name) << "/"
|
||||
<< Lower(m_env.m_asset->m_definition->m_name) << "_actions.h\"")
|
||||
}
|
||||
LINE("#include <string>")
|
||||
LINE("")
|
||||
LINE("namespace " << m_env.m_game)
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
LINE("class " << LoaderClassName(m_env.m_asset) << " final : public AssetLoader")
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
LINE("XAssetInfo<" << m_env.m_asset->m_definition->GetFullName() << ">* m_asset_info;")
|
||||
if (m_env.m_has_actions)
|
||||
{
|
||||
LINE("Actions_" << m_env.m_asset->m_definition->m_name << " m_actions;")
|
||||
}
|
||||
LINE(VariableDecl(m_env.m_asset->m_definition))
|
||||
LINE(PointerVariableDecl(m_env.m_asset->m_definition))
|
||||
LINE("")
|
||||
|
||||
// Variable Declarations: type varType;
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_info && !type->m_info->m_definition->m_anonymous && !type->m_info->m_is_leaf && !StructureComputations(type->m_info).IsAsset())
|
||||
{
|
||||
LINE(VariableDecl(type->m_type))
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists && !type->m_is_context_asset)
|
||||
{
|
||||
LINE(PointerVariableDecl(type->m_type))
|
||||
}
|
||||
}
|
||||
|
||||
LINE("")
|
||||
|
||||
// Method Declarations
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists)
|
||||
{
|
||||
PrintHeaderPtrArrayLoadMethodDeclaration(type->m_type);
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_array_reference_exists && type->m_info && !type->m_info->m_is_leaf && type->m_non_runtime_reference_exists)
|
||||
{
|
||||
PrintHeaderArrayLoadMethodDeclaration(type->m_type);
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_structures)
|
||||
{
|
||||
if (type->m_non_runtime_reference_exists && !type->m_info->m_is_leaf && !StructureComputations(type->m_info).IsAsset())
|
||||
{
|
||||
PrintHeaderLoadMethodDeclaration(type->m_info);
|
||||
}
|
||||
}
|
||||
PrintHeaderLoadMethodDeclaration(m_env.m_asset);
|
||||
PrintHeaderTempPtrLoadMethodDeclaration(m_env.m_asset);
|
||||
PrintHeaderAssetLoadMethodDeclaration(m_env.m_asset);
|
||||
LINE("")
|
||||
m_intendation--;
|
||||
LINE("public:")
|
||||
m_intendation++;
|
||||
PrintHeaderConstructor();
|
||||
PrintHeaderMainLoadMethodDeclaration(m_env.m_asset);
|
||||
PrintHeaderGetNameMethodDeclaration(m_env.m_asset);
|
||||
|
||||
m_intendation--;
|
||||
LINE("};")
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
}
|
||||
|
||||
void Source()
|
||||
{
|
||||
LINE("// ====================================================================")
|
||||
LINE("// This file has been generated by ZoneCodeGenerator.")
|
||||
LINE("// Do not modify. ")
|
||||
LINE("// Any changes will be discarded when regenerating.")
|
||||
LINE("// ====================================================================")
|
||||
LINE("")
|
||||
LINE("#include \"" << Lower(m_env.m_asset->m_definition->m_name) << "_load_db.h\"")
|
||||
LINE("#include \"" << Lower(m_env.m_asset->m_definition->m_name) << "_mark_db.h\"")
|
||||
LINE("#include <cassert>")
|
||||
LINE("#include <cstring>")
|
||||
LINE("")
|
||||
|
||||
if (!m_env.m_referenced_assets.empty())
|
||||
{
|
||||
LINE("// Referenced Assets:")
|
||||
for (auto* type : m_env.m_referenced_assets)
|
||||
{
|
||||
LINE("#include \"../" << Lower(type->m_type->m_name) << "/" << Lower(type->m_type->m_name) << "_load_db.h\"")
|
||||
}
|
||||
LINE("")
|
||||
}
|
||||
LINE("using namespace " << m_env.m_game << ";")
|
||||
LINE("")
|
||||
PrintConstructorMethod();
|
||||
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists)
|
||||
{
|
||||
LINE("")
|
||||
PrintLoadPtrArrayMethod(type->m_type, type->m_info, type->m_pointer_array_reference_is_reusable);
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_array_reference_exists && type->m_info && !type->m_info->m_is_leaf && type->m_non_runtime_reference_exists)
|
||||
{
|
||||
LINE("")
|
||||
PrintLoadArrayMethod(type->m_type, type->m_info);
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_structures)
|
||||
{
|
||||
if (type->m_non_runtime_reference_exists && !type->m_info->m_is_leaf && !StructureComputations(type->m_info).IsAsset())
|
||||
{
|
||||
LINE("")
|
||||
PrintLoadMethod(type->m_info);
|
||||
}
|
||||
}
|
||||
LINE("")
|
||||
PrintLoadMethod(m_env.m_asset);
|
||||
LINE("")
|
||||
PrintLoadPtrMethod(m_env.m_asset);
|
||||
LINE("")
|
||||
PrintLoadAssetMethod(m_env.m_asset);
|
||||
LINE("")
|
||||
PrintMainLoadMethod();
|
||||
LINE("")
|
||||
PrintGetNameMethod();
|
||||
}
|
||||
};
|
||||
};
|
||||
} // namespace
|
||||
|
||||
std::vector<CodeTemplateFile> ZoneLoadTemplate::GetFilesToRender(RenderingContext* context)
|
||||
{
|
||||
@ -1356,18 +1371,15 @@ std::vector<CodeTemplateFile> ZoneLoadTemplate::GetFilesToRender(RenderingContex
|
||||
|
||||
void ZoneLoadTemplate::RenderFile(std::ostream& stream, const int fileTag, RenderingContext* context)
|
||||
{
|
||||
Internal internal(stream, context);
|
||||
Template t(stream, context);
|
||||
|
||||
if (fileTag == TAG_HEADER)
|
||||
{
|
||||
internal.Header();
|
||||
}
|
||||
else if (fileTag == TAG_SOURCE)
|
||||
{
|
||||
internal.Source();
|
||||
t.Header();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Unknown tag for ZoneLoadTemplate: " << fileTag << "\n";
|
||||
assert(fileTag == TAG_SOURCE);
|
||||
t.Source();
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,6 @@
|
||||
|
||||
class ZoneLoadTemplate final : public ICodeTemplate
|
||||
{
|
||||
static constexpr int TAG_HEADER = 1;
|
||||
static constexpr int TAG_SOURCE = 2;
|
||||
|
||||
class Internal;
|
||||
|
||||
public:
|
||||
std::vector<CodeTemplateFile> GetFilesToRender(RenderingContext* context) override;
|
||||
void RenderFile(std::ostream& stream, int fileTag, RenderingContext* context) override;
|
||||
|
@ -9,8 +9,165 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
class ZoneMarkTemplate::Internal final : BaseTemplate
|
||||
namespace
|
||||
{
|
||||
static constexpr int TAG_HEADER = 1;
|
||||
static constexpr int TAG_SOURCE = 2;
|
||||
|
||||
class Template final : BaseTemplate
|
||||
{
|
||||
public:
|
||||
Template(std::ostream& stream, RenderingContext* context)
|
||||
: BaseTemplate(stream, context)
|
||||
{
|
||||
}
|
||||
|
||||
void Header()
|
||||
{
|
||||
LINE("// ====================================================================")
|
||||
LINE("// This file has been generated by ZoneCodeGenerator.")
|
||||
LINE("// Do not modify. ")
|
||||
LINE("// Any changes will be discarded when regenerating.")
|
||||
LINE("// ====================================================================")
|
||||
LINE("")
|
||||
LINE("#pragma once")
|
||||
LINE("")
|
||||
LINE("#include \"Loading/AssetMarker.h\"")
|
||||
LINE("#include \"Game/" << m_env.m_game << "/" << m_env.m_game << ".h\"")
|
||||
LINE("#include <string>")
|
||||
LINE("")
|
||||
LINE("namespace " << m_env.m_game)
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
LINE("class " << MarkerClassName(m_env.m_asset) << " final : public AssetMarker")
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
LINE(VariableDecl(m_env.m_asset->m_definition))
|
||||
LINE(PointerVariableDecl(m_env.m_asset->m_definition))
|
||||
LINE("")
|
||||
|
||||
m_intendation--;
|
||||
LINE("public:")
|
||||
m_intendation++;
|
||||
|
||||
// Variable Declarations: type varType;
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_info && !type->m_info->m_definition->m_anonymous && !type->m_info->m_is_leaf && !StructureComputations(type->m_info).IsAsset())
|
||||
{
|
||||
LINE(VariableDecl(type->m_type))
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists && !type->m_is_context_asset)
|
||||
{
|
||||
LINE(PointerVariableDecl(type->m_type))
|
||||
}
|
||||
}
|
||||
|
||||
LINE("")
|
||||
|
||||
// Method Declarations
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists && type->m_info->m_requires_marking)
|
||||
{
|
||||
PrintHeaderPtrArrayMarkMethodDeclaration(type->m_type);
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_array_reference_exists && type->m_info && !type->m_info->m_is_leaf && type->m_info->m_requires_marking
|
||||
&& type->m_non_runtime_reference_exists)
|
||||
{
|
||||
PrintHeaderArrayMarkMethodDeclaration(type->m_type);
|
||||
}
|
||||
}
|
||||
for (const auto* type : m_env.m_used_structures)
|
||||
{
|
||||
if (type->m_non_runtime_reference_exists && !type->m_info->m_is_leaf && type->m_info->m_requires_marking
|
||||
&& !StructureComputations(type->m_info).IsAsset())
|
||||
{
|
||||
PrintHeaderMarkMethodDeclaration(type->m_info);
|
||||
}
|
||||
}
|
||||
PrintHeaderMarkMethodDeclaration(m_env.m_asset);
|
||||
LINE("")
|
||||
PrintHeaderGetNameMethodDeclaration(m_env.m_asset);
|
||||
PrintHeaderGetAssetInfoMethodDeclaration(m_env.m_asset);
|
||||
LINE("")
|
||||
PrintHeaderConstructor();
|
||||
PrintHeaderMainMarkMethodDeclaration(m_env.m_asset);
|
||||
|
||||
m_intendation--;
|
||||
LINE("};")
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
}
|
||||
|
||||
void Source()
|
||||
{
|
||||
LINE("// ====================================================================")
|
||||
LINE("// This file has been generated by ZoneCodeGenerator.")
|
||||
LINE("// Do not modify. ")
|
||||
LINE("// Any changes will be discarded when regenerating.")
|
||||
LINE("// ====================================================================")
|
||||
LINE("")
|
||||
LINE("#include \"" << Lower(m_env.m_asset->m_definition->m_name) << "_mark_db.h\"")
|
||||
LINE("#include <cassert>")
|
||||
LINE("")
|
||||
|
||||
if (!m_env.m_referenced_assets.empty())
|
||||
{
|
||||
LINE("// Referenced Assets:")
|
||||
for (const auto* type : m_env.m_referenced_assets)
|
||||
{
|
||||
LINE("#include \"../" << Lower(type->m_type->m_name) << "/" << Lower(type->m_type->m_name) << "_mark_db.h\"")
|
||||
}
|
||||
LINE("")
|
||||
}
|
||||
LINE("using namespace " << m_env.m_game << ";")
|
||||
LINE("")
|
||||
PrintConstructorMethod();
|
||||
|
||||
for (const auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists && type->m_info->m_requires_marking)
|
||||
{
|
||||
LINE("")
|
||||
PrintMarkPtrArrayMethod(type->m_type, type->m_info, type->m_pointer_array_reference_is_reusable);
|
||||
}
|
||||
}
|
||||
for (const auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_array_reference_exists && type->m_info && !type->m_info->m_is_leaf && type->m_info->m_requires_marking
|
||||
&& type->m_non_runtime_reference_exists)
|
||||
{
|
||||
LINE("")
|
||||
PrintMarkArrayMethod(type->m_type, type->m_info);
|
||||
}
|
||||
}
|
||||
for (const auto* type : m_env.m_used_structures)
|
||||
{
|
||||
if (type->m_non_runtime_reference_exists && !type->m_info->m_is_leaf && type->m_info->m_requires_marking
|
||||
&& !StructureComputations(type->m_info).IsAsset())
|
||||
{
|
||||
LINE("")
|
||||
PrintMarkMethod(type->m_info);
|
||||
}
|
||||
}
|
||||
LINE("")
|
||||
PrintMarkMethod(m_env.m_asset);
|
||||
LINE("")
|
||||
PrintMainMarkMethod();
|
||||
LINE("")
|
||||
PrintGetNameMethod();
|
||||
PrintGetAssetInfoMethod();
|
||||
}
|
||||
|
||||
private:
|
||||
enum class MemberLoadType
|
||||
{
|
||||
ARRAY_POINTER,
|
||||
@ -277,8 +434,8 @@ class ZoneMarkTemplate::Internal final : BaseTemplate
|
||||
void MarkMember_ArrayPointer(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier) const
|
||||
{
|
||||
LINE(MakeTypeVarName(member->m_member->m_type_declaration->m_type) << " = " << MakeMemberAccess(info, member, modifier) << ";")
|
||||
LINE("MarkArray_" << MakeSafeTypeName(member->m_member->m_type_declaration->m_type) << "(" << MakeEvaluation(modifier.GetArrayPointerCountEvaluation())
|
||||
<< ");")
|
||||
LINE("MarkArray_" << MakeSafeTypeName(member->m_member->m_type_declaration->m_type) << "("
|
||||
<< MakeEvaluation(modifier.GetArrayPointerCountEvaluation()) << ");")
|
||||
}
|
||||
|
||||
void MarkMember_PointerArray(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier) const
|
||||
@ -312,8 +469,8 @@ class ZoneMarkTemplate::Internal final : BaseTemplate
|
||||
void MarkMember_DynamicArray(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier) const
|
||||
{
|
||||
LINE(MakeTypeVarName(member->m_member->m_type_declaration->m_type) << " = " << MakeMemberAccess(info, member, modifier) << ";")
|
||||
LINE("MarkArray_" << MakeSafeTypeName(member->m_member->m_type_declaration->m_type) << "(" << MakeEvaluation(modifier.GetDynamicArraySizeEvaluation())
|
||||
<< ");")
|
||||
LINE("MarkArray_" << MakeSafeTypeName(member->m_member->m_type_declaration->m_type) << "("
|
||||
<< MakeEvaluation(modifier.GetDynamicArraySizeEvaluation()) << ");")
|
||||
}
|
||||
|
||||
void MarkMember_Embedded(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier) const
|
||||
@ -663,158 +820,8 @@ class ZoneMarkTemplate::Internal final : BaseTemplate
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
}
|
||||
|
||||
public:
|
||||
Internal(std::ostream& stream, RenderingContext* context)
|
||||
: BaseTemplate(stream, context)
|
||||
{
|
||||
}
|
||||
|
||||
void Header()
|
||||
{
|
||||
LINE("// ====================================================================")
|
||||
LINE("// This file has been generated by ZoneCodeGenerator.")
|
||||
LINE("// Do not modify. ")
|
||||
LINE("// Any changes will be discarded when regenerating.")
|
||||
LINE("// ====================================================================")
|
||||
LINE("")
|
||||
LINE("#pragma once")
|
||||
LINE("")
|
||||
LINE("#include \"Loading/AssetMarker.h\"")
|
||||
LINE("#include \"Game/" << m_env.m_game << "/" << m_env.m_game << ".h\"")
|
||||
LINE("#include <string>")
|
||||
LINE("")
|
||||
LINE("namespace " << m_env.m_game)
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
LINE("class " << MarkerClassName(m_env.m_asset) << " final : public AssetMarker")
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
LINE(VariableDecl(m_env.m_asset->m_definition))
|
||||
LINE(PointerVariableDecl(m_env.m_asset->m_definition))
|
||||
LINE("")
|
||||
|
||||
m_intendation--;
|
||||
LINE("public:")
|
||||
m_intendation++;
|
||||
|
||||
// Variable Declarations: type varType;
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_info && !type->m_info->m_definition->m_anonymous && !type->m_info->m_is_leaf && !StructureComputations(type->m_info).IsAsset())
|
||||
{
|
||||
LINE(VariableDecl(type->m_type))
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists && !type->m_is_context_asset)
|
||||
{
|
||||
LINE(PointerVariableDecl(type->m_type))
|
||||
}
|
||||
}
|
||||
|
||||
LINE("")
|
||||
|
||||
// Method Declarations
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists && type->m_info->m_requires_marking)
|
||||
{
|
||||
PrintHeaderPtrArrayMarkMethodDeclaration(type->m_type);
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_array_reference_exists && type->m_info && !type->m_info->m_is_leaf && type->m_info->m_requires_marking
|
||||
&& type->m_non_runtime_reference_exists)
|
||||
{
|
||||
PrintHeaderArrayMarkMethodDeclaration(type->m_type);
|
||||
}
|
||||
}
|
||||
for (const auto* type : m_env.m_used_structures)
|
||||
{
|
||||
if (type->m_non_runtime_reference_exists && !type->m_info->m_is_leaf && type->m_info->m_requires_marking
|
||||
&& !StructureComputations(type->m_info).IsAsset())
|
||||
{
|
||||
PrintHeaderMarkMethodDeclaration(type->m_info);
|
||||
}
|
||||
}
|
||||
PrintHeaderMarkMethodDeclaration(m_env.m_asset);
|
||||
LINE("")
|
||||
PrintHeaderGetNameMethodDeclaration(m_env.m_asset);
|
||||
PrintHeaderGetAssetInfoMethodDeclaration(m_env.m_asset);
|
||||
LINE("")
|
||||
PrintHeaderConstructor();
|
||||
PrintHeaderMainMarkMethodDeclaration(m_env.m_asset);
|
||||
|
||||
m_intendation--;
|
||||
LINE("};")
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
}
|
||||
|
||||
void Source()
|
||||
{
|
||||
LINE("// ====================================================================")
|
||||
LINE("// This file has been generated by ZoneCodeGenerator.")
|
||||
LINE("// Do not modify. ")
|
||||
LINE("// Any changes will be discarded when regenerating.")
|
||||
LINE("// ====================================================================")
|
||||
LINE("")
|
||||
LINE("#include \"" << Lower(m_env.m_asset->m_definition->m_name) << "_mark_db.h\"")
|
||||
LINE("#include <cassert>")
|
||||
LINE("")
|
||||
|
||||
if (!m_env.m_referenced_assets.empty())
|
||||
{
|
||||
LINE("// Referenced Assets:")
|
||||
for (const auto* type : m_env.m_referenced_assets)
|
||||
{
|
||||
LINE("#include \"../" << Lower(type->m_type->m_name) << "/" << Lower(type->m_type->m_name) << "_mark_db.h\"")
|
||||
}
|
||||
LINE("")
|
||||
}
|
||||
LINE("using namespace " << m_env.m_game << ";")
|
||||
LINE("")
|
||||
PrintConstructorMethod();
|
||||
|
||||
for (const auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists && type->m_info->m_requires_marking)
|
||||
{
|
||||
LINE("")
|
||||
PrintMarkPtrArrayMethod(type->m_type, type->m_info, type->m_pointer_array_reference_is_reusable);
|
||||
}
|
||||
}
|
||||
for (const auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_array_reference_exists && type->m_info && !type->m_info->m_is_leaf && type->m_info->m_requires_marking
|
||||
&& type->m_non_runtime_reference_exists)
|
||||
{
|
||||
LINE("")
|
||||
PrintMarkArrayMethod(type->m_type, type->m_info);
|
||||
}
|
||||
}
|
||||
for (const auto* type : m_env.m_used_structures)
|
||||
{
|
||||
if (type->m_non_runtime_reference_exists && !type->m_info->m_is_leaf && type->m_info->m_requires_marking
|
||||
&& !StructureComputations(type->m_info).IsAsset())
|
||||
{
|
||||
LINE("")
|
||||
PrintMarkMethod(type->m_info);
|
||||
}
|
||||
}
|
||||
LINE("")
|
||||
PrintMarkMethod(m_env.m_asset);
|
||||
LINE("")
|
||||
PrintMainMarkMethod();
|
||||
LINE("")
|
||||
PrintGetNameMethod();
|
||||
PrintGetAssetInfoMethod();
|
||||
}
|
||||
};
|
||||
};
|
||||
} // namespace
|
||||
|
||||
std::vector<CodeTemplateFile> ZoneMarkTemplate::GetFilesToRender(RenderingContext* context)
|
||||
{
|
||||
@ -840,18 +847,15 @@ std::vector<CodeTemplateFile> ZoneMarkTemplate::GetFilesToRender(RenderingContex
|
||||
|
||||
void ZoneMarkTemplate::RenderFile(std::ostream& stream, const int fileTag, RenderingContext* context)
|
||||
{
|
||||
Internal internal(stream, context);
|
||||
Template t(stream, context);
|
||||
|
||||
if (fileTag == TAG_HEADER)
|
||||
{
|
||||
internal.Header();
|
||||
}
|
||||
else if (fileTag == TAG_SOURCE)
|
||||
{
|
||||
internal.Source();
|
||||
t.Header();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Unknown tag for ZoneMarkTemplate: " << fileTag << "\n";
|
||||
assert(fileTag == TAG_SOURCE);
|
||||
t.Source();
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,6 @@
|
||||
|
||||
class ZoneMarkTemplate final : public ICodeTemplate
|
||||
{
|
||||
static constexpr int TAG_HEADER = 1;
|
||||
static constexpr int TAG_SOURCE = 2;
|
||||
|
||||
class Internal;
|
||||
|
||||
public:
|
||||
std::vector<CodeTemplateFile> GetFilesToRender(RenderingContext* context) override;
|
||||
void RenderFile(std::ostream& stream, int fileTag, RenderingContext* context) override;
|
||||
|
@ -8,8 +8,164 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
class ZoneWriteTemplate::Internal final : BaseTemplate
|
||||
namespace
|
||||
{
|
||||
static constexpr int TAG_HEADER = 1;
|
||||
static constexpr int TAG_SOURCE = 2;
|
||||
|
||||
class Template final : BaseTemplate
|
||||
{
|
||||
public:
|
||||
Template(std::ostream& stream, RenderingContext* context)
|
||||
: BaseTemplate(stream, context)
|
||||
{
|
||||
}
|
||||
|
||||
void Header()
|
||||
{
|
||||
LINE("// ====================================================================")
|
||||
LINE("// This file has been generated by ZoneCodeGenerator.")
|
||||
LINE("// Do not modify. ")
|
||||
LINE("// Any changes will be discarded when regenerating.")
|
||||
LINE("// ====================================================================")
|
||||
LINE("")
|
||||
LINE("#pragma once")
|
||||
LINE("")
|
||||
LINE("#include \"Writing/AssetWriter.h\"")
|
||||
LINE("#include \"Game/" << m_env.m_game << "/" << m_env.m_game << ".h\"")
|
||||
LINE("#include <string>")
|
||||
LINE("")
|
||||
LINE("namespace " << m_env.m_game)
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
LINE("class " << WriterClassName(m_env.m_asset) << " final : public AssetWriter")
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
LINE(VariableDecl(m_env.m_asset->m_definition))
|
||||
LINE(WrittenVariableDecl(m_env.m_asset->m_definition))
|
||||
LINE(PointerVariableDecl(m_env.m_asset->m_definition))
|
||||
LINE(WrittenPointerVariableDecl(m_env.m_asset->m_definition))
|
||||
LINE("")
|
||||
|
||||
// Variable Declarations: type varType;
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_info && !type->m_info->m_definition->m_anonymous && !type->m_info->m_is_leaf && !StructureComputations(type->m_info).IsAsset())
|
||||
{
|
||||
LINE(VariableDecl(type->m_type))
|
||||
LINE(WrittenVariableDecl(type->m_type))
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists && !type->m_is_context_asset)
|
||||
{
|
||||
LINE(PointerVariableDecl(type->m_type))
|
||||
LINE(WrittenPointerVariableDecl(type->m_type))
|
||||
}
|
||||
}
|
||||
|
||||
LINE("")
|
||||
|
||||
// Method Declarations
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists)
|
||||
{
|
||||
PrintHeaderPtrArrayWriteMethodDeclaration(type->m_type);
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_array_reference_exists && type->m_info && !type->m_info->m_is_leaf && type->m_non_runtime_reference_exists)
|
||||
{
|
||||
PrintHeaderArrayWriteMethodDeclaration(type->m_type);
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_structures)
|
||||
{
|
||||
if (type->m_non_runtime_reference_exists && !type->m_info->m_is_leaf && !StructureComputations(type->m_info).IsAsset())
|
||||
{
|
||||
PrintHeaderWriteMethodDeclaration(type->m_info);
|
||||
}
|
||||
}
|
||||
PrintHeaderWriteMethodDeclaration(m_env.m_asset);
|
||||
PrintHeaderTempPtrWriteMethodDeclaration(m_env.m_asset);
|
||||
LINE("")
|
||||
m_intendation--;
|
||||
LINE("public:")
|
||||
m_intendation++;
|
||||
PrintHeaderConstructor();
|
||||
PrintHeaderMainWriteMethodDeclaration(m_env.m_asset);
|
||||
PrintHeaderGetNameMethodDeclaration(m_env.m_asset);
|
||||
|
||||
m_intendation--;
|
||||
LINE("};")
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
}
|
||||
|
||||
void Source()
|
||||
{
|
||||
LINE("// ====================================================================")
|
||||
LINE("// This file has been generated by ZoneCodeGenerator.")
|
||||
LINE("// Do not modify. ")
|
||||
LINE("// Any changes will be discarded when regenerating.")
|
||||
LINE("// ====================================================================")
|
||||
LINE("")
|
||||
LINE("#include \"" << Lower(m_env.m_asset->m_definition->m_name) << "_write_db.h\"")
|
||||
LINE("#include <cassert>")
|
||||
LINE("")
|
||||
|
||||
if (!m_env.m_referenced_assets.empty())
|
||||
{
|
||||
LINE("// Referenced Assets:")
|
||||
for (auto* type : m_env.m_referenced_assets)
|
||||
{
|
||||
LINE("#include \"../" << Lower(type->m_type->m_name) << "/" << Lower(type->m_type->m_name) << "_write_db.h\"")
|
||||
}
|
||||
LINE("")
|
||||
}
|
||||
LINE("using namespace " << m_env.m_game << ";")
|
||||
LINE("")
|
||||
PrintConstructorMethod();
|
||||
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists)
|
||||
{
|
||||
LINE("")
|
||||
PrintWritePtrArrayMethod(type->m_type, type->m_info, type->m_pointer_array_reference_is_reusable);
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_array_reference_exists && type->m_info && !type->m_info->m_is_leaf && type->m_non_runtime_reference_exists)
|
||||
{
|
||||
LINE("")
|
||||
PrintWriteArrayMethod(type->m_type, type->m_info);
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_structures)
|
||||
{
|
||||
if (type->m_non_runtime_reference_exists && !type->m_info->m_is_leaf && !StructureComputations(type->m_info).IsAsset())
|
||||
{
|
||||
LINE("")
|
||||
PrintWriteMethod(type->m_info);
|
||||
}
|
||||
}
|
||||
LINE("")
|
||||
PrintWriteMethod(m_env.m_asset);
|
||||
LINE("")
|
||||
PrintWritePtrMethod(m_env.m_asset);
|
||||
LINE("")
|
||||
PrintMainWriteMethod();
|
||||
LINE("")
|
||||
PrintGetNameMethod();
|
||||
}
|
||||
|
||||
private:
|
||||
enum class MemberWriteType : std::uint8_t
|
||||
{
|
||||
ARRAY_POINTER,
|
||||
@ -87,7 +243,8 @@ class ZoneWriteTemplate::Internal final : BaseTemplate
|
||||
|
||||
void PrintHeaderConstructor() const
|
||||
{
|
||||
LINE(WriterClassName(m_env.m_asset) << "(" << m_env.m_asset->m_definition->GetFullName() << "* asset, const Zone& zone, IZoneOutputStream& stream);")
|
||||
LINE(WriterClassName(m_env.m_asset) << "(" << m_env.m_asset->m_definition->GetFullName()
|
||||
<< "* asset, const Zone& zone, IZoneOutputStream& stream);")
|
||||
}
|
||||
|
||||
void PrintVariableInitialization(const DataDefinition* def) const
|
||||
@ -250,8 +407,9 @@ class ZoneWriteTemplate::Internal final : BaseTemplate
|
||||
else
|
||||
{
|
||||
LINE("m_stream->Write<" << MakeTypeDecl(member->m_member->m_type_declaration.get())
|
||||
<< MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()) << ">(" << MakeMemberAccess(info, member, modifier)
|
||||
<< ", " << MakeEvaluation(modifier.GetArrayPointerCountEvaluation()) << ");")
|
||||
<< MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()) << ">("
|
||||
<< MakeMemberAccess(info, member, modifier) << ", " << MakeEvaluation(modifier.GetArrayPointerCountEvaluation())
|
||||
<< ");")
|
||||
}
|
||||
}
|
||||
|
||||
@ -291,15 +449,16 @@ class ZoneWriteTemplate::Internal final : BaseTemplate
|
||||
else
|
||||
{
|
||||
LINE(MakeTypeVarName(member->m_member->m_type_declaration->m_type) << " = " << MakeMemberAccess(info, member, modifier) << ";")
|
||||
LINE(MakeTypeWrittenVarName(member->m_member->m_type_declaration->m_type) << " = " << MakeWrittenMemberAccess(info, member, modifier) << ";")
|
||||
LINE(MakeTypeWrittenVarName(member->m_member->m_type_declaration->m_type)
|
||||
<< " = " << MakeWrittenMemberAccess(info, member, modifier) << ";")
|
||||
LINE("WriteArray_" << MakeSafeTypeName(member->m_member->m_type_declaration->m_type) << "(false, " << arraySizeStr << ");")
|
||||
}
|
||||
}
|
||||
else if (computations.IsAfterPartialLoad())
|
||||
{
|
||||
LINE("m_stream->Write<" << MakeTypeDecl(member->m_member->m_type_declaration.get())
|
||||
<< MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()) << ">(" << MakeMemberAccess(info, member, modifier)
|
||||
<< ", " << arraySizeStr << ");")
|
||||
<< MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()) << ">("
|
||||
<< MakeMemberAccess(info, member, modifier) << ", " << arraySizeStr << ");")
|
||||
}
|
||||
}
|
||||
|
||||
@ -314,8 +473,8 @@ class ZoneWriteTemplate::Internal final : BaseTemplate
|
||||
else
|
||||
{
|
||||
LINE("m_stream->Write<" << MakeTypeDecl(member->m_member->m_type_declaration.get())
|
||||
<< MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()) << ">(" << MakeMemberAccess(info, member, modifier)
|
||||
<< ", " << MakeEvaluation(modifier.GetDynamicArraySizeEvaluation()) << ");")
|
||||
<< MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()) << ">("
|
||||
<< MakeMemberAccess(info, member, modifier) << ", " << MakeEvaluation(modifier.GetDynamicArraySizeEvaluation()) << ");")
|
||||
}
|
||||
}
|
||||
|
||||
@ -333,15 +492,16 @@ class ZoneWriteTemplate::Internal final : BaseTemplate
|
||||
else
|
||||
{
|
||||
LINE(MakeTypeVarName(member->m_member->m_type_declaration->m_type) << " = &" << MakeMemberAccess(info, member, modifier) << ";")
|
||||
LINE(MakeTypeWrittenVarName(member->m_member->m_type_declaration->m_type) << " = &" << MakeWrittenMemberAccess(info, member, modifier) << ";")
|
||||
LINE(MakeTypeWrittenVarName(member->m_member->m_type_declaration->m_type)
|
||||
<< " = &" << MakeWrittenMemberAccess(info, member, modifier) << ";")
|
||||
LINE("Write_" << MakeSafeTypeName(member->m_member->m_type_declaration->m_type) << "(false);")
|
||||
}
|
||||
}
|
||||
else if (computations.IsAfterPartialLoad())
|
||||
{
|
||||
LINE("m_stream->Write<" << MakeTypeDecl(member->m_member->m_type_declaration.get())
|
||||
<< MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()) << ">(&" << MakeMemberAccess(info, member, modifier)
|
||||
<< ");")
|
||||
<< MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()) << ">(&"
|
||||
<< MakeMemberAccess(info, member, modifier) << ");")
|
||||
}
|
||||
}
|
||||
|
||||
@ -357,8 +517,8 @@ class ZoneWriteTemplate::Internal final : BaseTemplate
|
||||
else
|
||||
{
|
||||
LINE("m_stream->Write<" << MakeTypeDecl(member->m_member->m_type_declaration.get())
|
||||
<< MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()) << ">(" << MakeMemberAccess(info, member, modifier)
|
||||
<< ");")
|
||||
<< MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()) << ">("
|
||||
<< MakeMemberAccess(info, member, modifier) << ");")
|
||||
}
|
||||
}
|
||||
|
||||
@ -461,8 +621,8 @@ class ZoneWriteTemplate::Internal final : BaseTemplate
|
||||
|
||||
if (writeType == MemberWriteType::ARRAY_POINTER)
|
||||
{
|
||||
LINE("m_stream->ReusableAddOffset(" << MakeMemberAccess(info, member, modifier) << ", " << MakeEvaluation(modifier.GetArrayPointerCountEvaluation())
|
||||
<< ");")
|
||||
LINE("m_stream->ReusableAddOffset(" << MakeMemberAccess(info, member, modifier) << ", "
|
||||
<< MakeEvaluation(modifier.GetArrayPointerCountEvaluation()) << ");")
|
||||
}
|
||||
else if (writeType == MemberWriteType::POINTER_ARRAY)
|
||||
{
|
||||
@ -624,7 +784,8 @@ class ZoneWriteTemplate::Internal final : BaseTemplate
|
||||
}
|
||||
}
|
||||
|
||||
void WriteMember_Block(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier, MemberWriteType writeType)
|
||||
void
|
||||
WriteMember_Block(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier, MemberWriteType writeType)
|
||||
{
|
||||
const MemberComputations computations(member);
|
||||
|
||||
@ -1104,157 +1265,8 @@ class ZoneWriteTemplate::Internal final : BaseTemplate
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
}
|
||||
|
||||
public:
|
||||
Internal(std::ostream& stream, RenderingContext* context)
|
||||
: BaseTemplate(stream, context)
|
||||
{
|
||||
}
|
||||
|
||||
void Header()
|
||||
{
|
||||
LINE("// ====================================================================")
|
||||
LINE("// This file has been generated by ZoneCodeGenerator.")
|
||||
LINE("// Do not modify. ")
|
||||
LINE("// Any changes will be discarded when regenerating.")
|
||||
LINE("// ====================================================================")
|
||||
LINE("")
|
||||
LINE("#pragma once")
|
||||
LINE("")
|
||||
LINE("#include \"Writing/AssetWriter.h\"")
|
||||
LINE("#include \"Game/" << m_env.m_game << "/" << m_env.m_game << ".h\"")
|
||||
LINE("#include <string>")
|
||||
LINE("")
|
||||
LINE("namespace " << m_env.m_game)
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
LINE("class " << WriterClassName(m_env.m_asset) << " final : public AssetWriter")
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
LINE(VariableDecl(m_env.m_asset->m_definition))
|
||||
LINE(WrittenVariableDecl(m_env.m_asset->m_definition))
|
||||
LINE(PointerVariableDecl(m_env.m_asset->m_definition))
|
||||
LINE(WrittenPointerVariableDecl(m_env.m_asset->m_definition))
|
||||
LINE("")
|
||||
|
||||
// Variable Declarations: type varType;
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_info && !type->m_info->m_definition->m_anonymous && !type->m_info->m_is_leaf && !StructureComputations(type->m_info).IsAsset())
|
||||
{
|
||||
LINE(VariableDecl(type->m_type))
|
||||
LINE(WrittenVariableDecl(type->m_type))
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists && !type->m_is_context_asset)
|
||||
{
|
||||
LINE(PointerVariableDecl(type->m_type))
|
||||
LINE(WrittenPointerVariableDecl(type->m_type))
|
||||
}
|
||||
}
|
||||
|
||||
LINE("")
|
||||
|
||||
// Method Declarations
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists)
|
||||
{
|
||||
PrintHeaderPtrArrayWriteMethodDeclaration(type->m_type);
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_array_reference_exists && type->m_info && !type->m_info->m_is_leaf && type->m_non_runtime_reference_exists)
|
||||
{
|
||||
PrintHeaderArrayWriteMethodDeclaration(type->m_type);
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_structures)
|
||||
{
|
||||
if (type->m_non_runtime_reference_exists && !type->m_info->m_is_leaf && !StructureComputations(type->m_info).IsAsset())
|
||||
{
|
||||
PrintHeaderWriteMethodDeclaration(type->m_info);
|
||||
}
|
||||
}
|
||||
PrintHeaderWriteMethodDeclaration(m_env.m_asset);
|
||||
PrintHeaderTempPtrWriteMethodDeclaration(m_env.m_asset);
|
||||
LINE("")
|
||||
m_intendation--;
|
||||
LINE("public:")
|
||||
m_intendation++;
|
||||
PrintHeaderConstructor();
|
||||
PrintHeaderMainWriteMethodDeclaration(m_env.m_asset);
|
||||
PrintHeaderGetNameMethodDeclaration(m_env.m_asset);
|
||||
|
||||
m_intendation--;
|
||||
LINE("};")
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
}
|
||||
|
||||
void Source()
|
||||
{
|
||||
LINE("// ====================================================================")
|
||||
LINE("// This file has been generated by ZoneCodeGenerator.")
|
||||
LINE("// Do not modify. ")
|
||||
LINE("// Any changes will be discarded when regenerating.")
|
||||
LINE("// ====================================================================")
|
||||
LINE("")
|
||||
LINE("#include \"" << Lower(m_env.m_asset->m_definition->m_name) << "_write_db.h\"")
|
||||
LINE("#include <cassert>")
|
||||
LINE("")
|
||||
|
||||
if (!m_env.m_referenced_assets.empty())
|
||||
{
|
||||
LINE("// Referenced Assets:")
|
||||
for (auto* type : m_env.m_referenced_assets)
|
||||
{
|
||||
LINE("#include \"../" << Lower(type->m_type->m_name) << "/" << Lower(type->m_type->m_name) << "_write_db.h\"")
|
||||
}
|
||||
LINE("")
|
||||
}
|
||||
LINE("using namespace " << m_env.m_game << ";")
|
||||
LINE("")
|
||||
PrintConstructorMethod();
|
||||
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists)
|
||||
{
|
||||
LINE("")
|
||||
PrintWritePtrArrayMethod(type->m_type, type->m_info, type->m_pointer_array_reference_is_reusable);
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_array_reference_exists && type->m_info && !type->m_info->m_is_leaf && type->m_non_runtime_reference_exists)
|
||||
{
|
||||
LINE("")
|
||||
PrintWriteArrayMethod(type->m_type, type->m_info);
|
||||
}
|
||||
}
|
||||
for (auto* type : m_env.m_used_structures)
|
||||
{
|
||||
if (type->m_non_runtime_reference_exists && !type->m_info->m_is_leaf && !StructureComputations(type->m_info).IsAsset())
|
||||
{
|
||||
LINE("")
|
||||
PrintWriteMethod(type->m_info);
|
||||
}
|
||||
}
|
||||
LINE("")
|
||||
PrintWriteMethod(m_env.m_asset);
|
||||
LINE("")
|
||||
PrintWritePtrMethod(m_env.m_asset);
|
||||
LINE("")
|
||||
PrintMainWriteMethod();
|
||||
LINE("")
|
||||
PrintGetNameMethod();
|
||||
}
|
||||
};
|
||||
};
|
||||
} // namespace
|
||||
|
||||
std::vector<CodeTemplateFile> ZoneWriteTemplate::GetFilesToRender(RenderingContext* context)
|
||||
{
|
||||
@ -1281,18 +1293,15 @@ std::vector<CodeTemplateFile> ZoneWriteTemplate::GetFilesToRender(RenderingConte
|
||||
|
||||
void ZoneWriteTemplate::RenderFile(std::ostream& stream, const int fileTag, RenderingContext* context)
|
||||
{
|
||||
Internal internal(stream, context);
|
||||
Template t(stream, context);
|
||||
|
||||
if (fileTag == TAG_HEADER)
|
||||
{
|
||||
internal.Header();
|
||||
}
|
||||
else if (fileTag == TAG_SOURCE)
|
||||
{
|
||||
internal.Source();
|
||||
t.Header();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Unknown tag for ZoneWriteTemplate: " << fileTag << "\n";
|
||||
assert(fileTag == TAG_SOURCE);
|
||||
t.Source();
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,6 @@
|
||||
|
||||
class ZoneWriteTemplate final : public ICodeTemplate
|
||||
{
|
||||
static constexpr int TAG_HEADER = 1;
|
||||
static constexpr int TAG_SOURCE = 2;
|
||||
|
||||
class Internal;
|
||||
|
||||
public:
|
||||
std::vector<CodeTemplateFile> GetFilesToRender(RenderingContext* context) override;
|
||||
void RenderFile(std::ostream& stream, int fileTag, RenderingContext* context) override;
|
||||
|
@ -17,6 +17,12 @@
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_NAME = "__zonecodegenerator";
|
||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_VALUE = "1";
|
||||
} // namespace
|
||||
|
||||
CommandsFileReader::CommandsFileReader(const ZoneCodeGeneratorArguments* args, std::string filename)
|
||||
: m_args(args),
|
||||
m_filename(std::move(filename)),
|
||||
@ -30,7 +36,7 @@ bool CommandsFileReader::OpenBaseStream()
|
||||
auto stream = std::make_unique<ParserFilesystemStream>(m_filename);
|
||||
if (!stream->IsOpen())
|
||||
{
|
||||
std::cout << "Could not open commands file\n";
|
||||
std::cerr << "Could not open commands file\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -68,7 +74,7 @@ bool CommandsFileReader::ReadCommandsFile(IDataRepository* repository)
|
||||
{
|
||||
if (m_args->m_verbose)
|
||||
{
|
||||
std::cout << "Reading commands file: " << m_filename << "\n";
|
||||
std::cout << std::format("Reading commands file: {}\n", m_filename);
|
||||
}
|
||||
|
||||
if (!OpenBaseStream())
|
||||
@ -84,9 +90,7 @@ bool CommandsFileReader::ReadCommandsFile(IDataRepository* repository)
|
||||
const auto end = std::chrono::steady_clock::now();
|
||||
|
||||
if (m_args->m_verbose)
|
||||
{
|
||||
std::cout << "Processing commands took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms\n";
|
||||
}
|
||||
std::cout << std::format("Processing commands took {}ms\n", std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count());
|
||||
|
||||
if (!result)
|
||||
return false;
|
||||
|
@ -9,8 +9,15 @@
|
||||
|
||||
class CommandsFileReader
|
||||
{
|
||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_NAME = "__zonecodegenerator";
|
||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_VALUE = "1";
|
||||
public:
|
||||
CommandsFileReader(const ZoneCodeGeneratorArguments* args, std::string filename);
|
||||
|
||||
bool ReadCommandsFile(IDataRepository* repository);
|
||||
|
||||
private:
|
||||
bool OpenBaseStream();
|
||||
void SetupStreamProxies();
|
||||
void SetupPostProcessors();
|
||||
|
||||
const ZoneCodeGeneratorArguments* m_args;
|
||||
std::string m_filename;
|
||||
@ -19,13 +26,4 @@ class CommandsFileReader
|
||||
IParserLineStream* m_stream;
|
||||
|
||||
std::vector<std::unique_ptr<IPostProcessor>> m_post_processors;
|
||||
|
||||
bool OpenBaseStream();
|
||||
void SetupStreamProxies();
|
||||
void SetupPostProcessors();
|
||||
|
||||
public:
|
||||
explicit CommandsFileReader(const ZoneCodeGeneratorArguments* args, std::string filename);
|
||||
|
||||
bool ReadCommandsFile(IDataRepository* repository);
|
||||
};
|
||||
|
@ -5,9 +5,9 @@
|
||||
|
||||
class CommandsLexer final : public AbstractLexer<CommandsParserValue>
|
||||
{
|
||||
protected:
|
||||
CommandsParserValue GetNextToken() override;
|
||||
|
||||
public:
|
||||
explicit CommandsLexer(IParserLineStream* stream);
|
||||
|
||||
protected:
|
||||
CommandsParserValue GetNextToken() override;
|
||||
};
|
||||
|
@ -8,11 +8,12 @@
|
||||
|
||||
class CommandsParser final : public AbstractParser<CommandsParserValue, CommandsParserState>
|
||||
{
|
||||
IDataRepository* m_repository;
|
||||
public:
|
||||
CommandsParser(CommandsLexer* lexer, IDataRepository* targetRepository);
|
||||
|
||||
protected:
|
||||
const std::vector<sequence_t*>& GetTestsForState() override;
|
||||
|
||||
public:
|
||||
CommandsParser(CommandsLexer* lexer, IDataRepository* targetRepository);
|
||||
private:
|
||||
IDataRepository* m_repository;
|
||||
};
|
||||
|
@ -1,16 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include "Persistence/IDataRepository.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class CommandsParserState
|
||||
{
|
||||
IDataRepository* m_repository;
|
||||
StructureInformation* m_in_use;
|
||||
public:
|
||||
explicit CommandsParserState(IDataRepository* repository);
|
||||
|
||||
[[nodiscard]] const IDataRepository* GetRepository() const;
|
||||
|
||||
void AddBlock(std::unique_ptr<FastFileBlock> block) const;
|
||||
void SetArchitecture(Architecture architecture) const;
|
||||
void SetGame(std::string gameName) const;
|
||||
|
||||
[[nodiscard]] StructureInformation* GetInUse() const;
|
||||
void SetInUse(StructureInformation* structure);
|
||||
|
||||
bool GetMembersFromTypename(const std::string& typeNameValue, StructureInformation* baseType, std::vector<MemberInformation*>& members) const;
|
||||
bool GetTypenameAndMembersFromTypename(const std::string& typeNameValue, StructureInformation*& structure, std::vector<MemberInformation*>& members) const;
|
||||
|
||||
private:
|
||||
static MemberInformation* GetMemberWithName(const std::string& memberName, StructureInformation* type);
|
||||
static bool GetNextTypenameSeparatorPos(const std::string& typeNameValue, unsigned startPos, unsigned& separatorPos);
|
||||
static bool ExtractMembersFromTypenameInternal(const std::string& typeNameValue,
|
||||
@ -18,18 +30,6 @@ class CommandsParserState
|
||||
StructureInformation* type,
|
||||
std::vector<MemberInformation*>& members);
|
||||
|
||||
public:
|
||||
explicit CommandsParserState(IDataRepository* repository);
|
||||
|
||||
_NODISCARD const IDataRepository* GetRepository() const;
|
||||
|
||||
void AddBlock(std::unique_ptr<FastFileBlock> block) const;
|
||||
void SetArchitecture(Architecture architecture) const;
|
||||
void SetGame(std::string gameName) const;
|
||||
|
||||
_NODISCARD StructureInformation* GetInUse() const;
|
||||
void SetInUse(StructureInformation* structure);
|
||||
|
||||
bool GetMembersFromTypename(const std::string& typeNameValue, StructureInformation* baseType, std::vector<MemberInformation*>& members) const;
|
||||
bool GetTypenameAndMembersFromTypename(const std::string& typeNameValue, StructureInformation*& structure, std::vector<MemberInformation*>& members) const;
|
||||
IDataRepository* m_repository;
|
||||
StructureInformation* m_in_use;
|
||||
};
|
||||
|
@ -52,10 +52,6 @@ enum class CommandsParserValueType
|
||||
class CommandsParserValue final : public IParserValue
|
||||
{
|
||||
public:
|
||||
TokenPos m_pos;
|
||||
CommandsParserValueType m_type;
|
||||
size_t m_hash;
|
||||
|
||||
union ValueType
|
||||
{
|
||||
char char_value;
|
||||
@ -83,25 +79,28 @@ public:
|
||||
static CommandsParserValue TypeName(TokenPos pos, std::string* typeName);
|
||||
static CommandsParserValue OpType(TokenPos pos, const OperationType* operationType);
|
||||
|
||||
private:
|
||||
CommandsParserValue(TokenPos pos, CommandsParserValueType type);
|
||||
|
||||
public:
|
||||
~CommandsParserValue() override;
|
||||
CommandsParserValue(const CommandsParserValue& other) = delete;
|
||||
~CommandsParserValue() override;
|
||||
CommandsParserValue(CommandsParserValue&& other) noexcept;
|
||||
CommandsParserValue& operator=(const CommandsParserValue& other) = delete;
|
||||
CommandsParserValue& operator=(CommandsParserValue&& other) noexcept;
|
||||
|
||||
_NODISCARD bool IsEof() const override;
|
||||
_NODISCARD const TokenPos& GetPos() const override;
|
||||
[[nodiscard]] bool IsEof() const override;
|
||||
[[nodiscard]] const TokenPos& GetPos() const override;
|
||||
|
||||
_NODISCARD char CharacterValue() const;
|
||||
_NODISCARD int IntegerValue() const;
|
||||
_NODISCARD double FloatingPointValue() const;
|
||||
_NODISCARD std::string& StringValue() const;
|
||||
_NODISCARD std::string& IdentifierValue() const;
|
||||
_NODISCARD size_t IdentifierHash() const;
|
||||
_NODISCARD std::string& TypeNameValue() const;
|
||||
_NODISCARD const OperationType* OpTypeValue() const;
|
||||
[[nodiscard]] char CharacterValue() const;
|
||||
[[nodiscard]] int IntegerValue() const;
|
||||
[[nodiscard]] double FloatingPointValue() const;
|
||||
[[nodiscard]] std::string& StringValue() const;
|
||||
[[nodiscard]] std::string& IdentifierValue() const;
|
||||
[[nodiscard]] size_t IdentifierHash() const;
|
||||
[[nodiscard]] std::string& TypeNameValue() const;
|
||||
[[nodiscard]] const OperationType* OpTypeValue() const;
|
||||
|
||||
TokenPos m_pos;
|
||||
CommandsParserValueType m_type;
|
||||
size_t m_hash;
|
||||
|
||||
private:
|
||||
CommandsParserValue(TokenPos pos, CommandsParserValueType type);
|
||||
};
|
||||
|
@ -5,11 +5,12 @@
|
||||
|
||||
class CommandsMatcherCharacter final : public AbstractMatcher<CommandsParserValue>
|
||||
{
|
||||
char m_char;
|
||||
public:
|
||||
explicit CommandsMatcherCharacter(char c);
|
||||
|
||||
protected:
|
||||
MatcherResult<CommandsParserValue> CanMatch(ILexer<CommandsParserValue>* lexer, unsigned tokenOffset) override;
|
||||
|
||||
public:
|
||||
explicit CommandsMatcherCharacter(char c);
|
||||
private:
|
||||
char m_char;
|
||||
};
|
||||
|
@ -10,10 +10,10 @@ class CommandsMatcherFactory final : public AbstractMatcherFactory<CommandsParse
|
||||
public:
|
||||
explicit CommandsMatcherFactory(const IMatcherForLabelSupplier<CommandsParserValue>* labelSupplier);
|
||||
|
||||
_NODISCARD MatcherFactoryWrapper<CommandsParserValue> Type(CommandsParserValueType type) const;
|
||||
_NODISCARD MatcherFactoryWrapper<CommandsParserValue> Keyword(std::string value) const;
|
||||
_NODISCARD MatcherFactoryWrapper<CommandsParserValue> Identifier() const;
|
||||
_NODISCARD MatcherFactoryWrapper<CommandsParserValue> Integer() const;
|
||||
_NODISCARD MatcherFactoryWrapper<CommandsParserValue> FloatingPoint() const;
|
||||
_NODISCARD MatcherFactoryWrapper<CommandsParserValue> Char(char c) const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<CommandsParserValue> Type(CommandsParserValueType type) const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<CommandsParserValue> Keyword(std::string value) const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<CommandsParserValue> Identifier() const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<CommandsParserValue> Integer() const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<CommandsParserValue> FloatingPoint() const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<CommandsParserValue> Char(char c) const;
|
||||
};
|
||||
|
@ -7,12 +7,13 @@
|
||||
|
||||
class CommandsMatcherKeyword final : public AbstractMatcher<CommandsParserValue>
|
||||
{
|
||||
size_t m_hash;
|
||||
std::string m_value;
|
||||
public:
|
||||
explicit CommandsMatcherKeyword(std::string value);
|
||||
|
||||
protected:
|
||||
MatcherResult<CommandsParserValue> CanMatch(ILexer<CommandsParserValue>* lexer, unsigned tokenOffset) override;
|
||||
|
||||
public:
|
||||
explicit CommandsMatcherKeyword(std::string value);
|
||||
private:
|
||||
size_t m_hash;
|
||||
std::string m_value;
|
||||
};
|
||||
|
@ -5,11 +5,12 @@
|
||||
|
||||
class CommandsMatcherValueType final : public AbstractMatcher<CommandsParserValue>
|
||||
{
|
||||
CommandsParserValueType m_type;
|
||||
public:
|
||||
explicit CommandsMatcherValueType(CommandsParserValueType type);
|
||||
|
||||
protected:
|
||||
MatcherResult<CommandsParserValue> CanMatch(ILexer<CommandsParserValue>* lexer, unsigned tokenOffset) override;
|
||||
|
||||
public:
|
||||
explicit CommandsMatcherValueType(CommandsParserValueType type);
|
||||
private:
|
||||
CommandsParserValueType m_type;
|
||||
};
|
||||
|
@ -3,6 +3,15 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_ACTION_NAME = 1;
|
||||
static constexpr auto CAPTURE_TYPE = 2;
|
||||
static constexpr auto CAPTURE_ARG_TYPE = 3;
|
||||
|
||||
static constexpr auto LABEL_ACTION_ARGS = 1;
|
||||
} // namespace
|
||||
|
||||
SequenceAction::SequenceAction()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@ -4,15 +4,9 @@
|
||||
|
||||
class SequenceAction final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_ACTION_NAME = 1;
|
||||
static constexpr auto CAPTURE_TYPE = 2;
|
||||
static constexpr auto CAPTURE_ARG_TYPE = 3;
|
||||
|
||||
static constexpr auto LABEL_ACTION_ARGS = 1;
|
||||
public:
|
||||
SequenceAction();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceAction();
|
||||
};
|
||||
|
@ -3,6 +3,11 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
}
|
||||
|
||||
SequenceAllocAlign::SequenceAllocAlign()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@ -4,11 +4,9 @@
|
||||
|
||||
class SequenceAllocAlign final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
public:
|
||||
SequenceAllocAlign();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceAllocAlign();
|
||||
};
|
||||
|
@ -3,6 +3,11 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_ARCHITECTURE = 1;
|
||||
}
|
||||
|
||||
SequenceArchitecture::SequenceArchitecture()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@ -2,15 +2,16 @@
|
||||
|
||||
#include "Parsing/Commands/Impl/CommandsParser.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
class SequenceArchitecture final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_ARCHITECTURE = 1;
|
||||
|
||||
std::unordered_map<std::string, Architecture> m_architecture_mapping;
|
||||
public:
|
||||
SequenceArchitecture();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceArchitecture();
|
||||
private:
|
||||
std::unordered_map<std::string, Architecture> m_architecture_mapping;
|
||||
};
|
||||
|
@ -4,6 +4,11 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
}
|
||||
|
||||
SequenceArrayCount::SequenceArrayCount()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@ -4,11 +4,9 @@
|
||||
|
||||
class SequenceArrayCount final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
public:
|
||||
SequenceArrayCount();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceArrayCount();
|
||||
};
|
||||
|
@ -4,6 +4,12 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
static constexpr auto CAPTURE_EVALUATION = 2;
|
||||
} // namespace
|
||||
|
||||
SequenceArraySize::SequenceArraySize()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@ -4,12 +4,9 @@
|
||||
|
||||
class SequenceArraySize final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
static constexpr auto CAPTURE_EVALUATION = 2;
|
||||
public:
|
||||
SequenceArraySize();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceArraySize();
|
||||
};
|
||||
|
@ -3,6 +3,12 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
static constexpr auto CAPTURE_ENUM_ENTRY = 2;
|
||||
} // namespace
|
||||
|
||||
SequenceAsset::SequenceAsset()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@ -4,12 +4,9 @@
|
||||
|
||||
class SequenceAsset final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
static constexpr auto CAPTURE_ENUM_ENTRY = 2;
|
||||
public:
|
||||
SequenceAsset();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceAsset();
|
||||
};
|
||||
|
@ -5,6 +5,14 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto TAG_DEFAULT = 1;
|
||||
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
static constexpr auto CAPTURE_ASSET_TYPE_ENUM_ENTRY = 2;
|
||||
} // namespace
|
||||
|
||||
SequenceAssetRef::SequenceAssetRef()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@ -4,14 +4,9 @@
|
||||
|
||||
class SequenceAssetRef final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto TAG_DEFAULT = 1;
|
||||
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
static constexpr auto CAPTURE_ASSET_TYPE_ENUM_ENTRY = 2;
|
||||
public:
|
||||
SequenceAssetRef();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceAssetRef();
|
||||
};
|
||||
|
@ -3,6 +3,14 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto TAG_DEFAULT = 1;
|
||||
|
||||
static constexpr auto CAPTURE_BLOCK_ENUM_ENTRY = 1;
|
||||
static constexpr auto CAPTURE_BLOCK_TYPE = 2;
|
||||
} // namespace
|
||||
|
||||
SequenceBlock::SequenceBlock()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@ -7,19 +7,15 @@
|
||||
|
||||
class SequenceBlock final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto TAG_DEFAULT = 1;
|
||||
|
||||
static constexpr auto CAPTURE_BLOCK_ENUM_ENTRY = 1;
|
||||
static constexpr auto CAPTURE_BLOCK_TYPE = 2;
|
||||
|
||||
std::unordered_map<std::string, FastFileBlockType> m_type_lookup;
|
||||
|
||||
void AddFastFileBlockToLookup(std::string name, FastFileBlockType type);
|
||||
_NODISCARD bool GetFastFileBlockNameByType(const std::string& name, FastFileBlockType& type) const;
|
||||
public:
|
||||
SequenceBlock();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceBlock();
|
||||
private:
|
||||
void AddFastFileBlockToLookup(std::string name, FastFileBlockType type);
|
||||
[[nodiscard]] bool GetFastFileBlockNameByType(const std::string& name, FastFileBlockType& type) const;
|
||||
|
||||
std::unordered_map<std::string, FastFileBlockType> m_type_lookup;
|
||||
};
|
||||
|
@ -4,6 +4,16 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto TAG_ALWAYS = 1;
|
||||
static constexpr auto TAG_NEVER = 2;
|
||||
static constexpr auto TAG_EVALUATION = 3;
|
||||
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
static constexpr auto CAPTURE_EVALUATION = 2;
|
||||
} // namespace
|
||||
|
||||
SequenceCondition::SequenceCondition()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@ -4,16 +4,9 @@
|
||||
|
||||
class SequenceCondition final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto TAG_ALWAYS = 1;
|
||||
static constexpr auto TAG_NEVER = 2;
|
||||
static constexpr auto TAG_EVALUATION = 3;
|
||||
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
static constexpr auto CAPTURE_EVALUATION = 2;
|
||||
public:
|
||||
SequenceCondition();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceCondition();
|
||||
};
|
||||
|
@ -5,30 +5,23 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
SequenceCount::SequenceCount()
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
static constexpr auto TAG_POINTER_RESOLVE = 1;
|
||||
|
||||
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
|
||||
AddLabeledMatchers(CommandsCommonMatchers::Evaluation(this), CommandsCommonMatchers::LABEL_EVALUATION);
|
||||
AddLabeledMatchers(CommandsCommonMatchers::ArrayDef(this), CommandsCommonMatchers::LABEL_ARRAY_DEF);
|
||||
AddMatchers({
|
||||
create.Keyword("set").Capture(CAPTURE_START),
|
||||
create.Keyword("count"),
|
||||
create.OptionalLoop(create.Char('*').Tag(TAG_POINTER_RESOLVE)),
|
||||
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
|
||||
create.OptionalLoop(create.Label(CommandsCommonMatchers::LABEL_ARRAY_DEF).Capture(CAPTURE_ARRAY_INDEX)),
|
||||
create.Label(CommandsCommonMatchers::LABEL_EVALUATION),
|
||||
create.Char(';'),
|
||||
});
|
||||
}
|
||||
static constexpr auto CAPTURE_START = 1;
|
||||
static constexpr auto CAPTURE_TYPE = 2;
|
||||
static constexpr auto CAPTURE_ARRAY_INDEX = 3;
|
||||
|
||||
void SequenceCount::SetCountByArrayIndex(CommandsParserState* state,
|
||||
void SetCountByArrayIndex(CommandsParserState* state,
|
||||
SequenceResult<CommandsParserValue>& result,
|
||||
MemberInformation* member,
|
||||
PointerDeclarationModifier* pointer,
|
||||
std::unique_ptr<IEvaluation> evaluation)
|
||||
{
|
||||
{
|
||||
std::vector<int> arraySizes;
|
||||
std::vector<int> depthSize;
|
||||
for (const auto& modifier : member->m_member->m_type_declaration->m_declaration_modifiers)
|
||||
@ -79,6 +72,25 @@ void SequenceCount::SetCountByArrayIndex(CommandsParserState* state,
|
||||
}
|
||||
|
||||
pointer->m_count_evaluation_by_array_index[currentIndex] = std::move(evaluation);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SequenceCount::SequenceCount()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
||||
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
|
||||
AddLabeledMatchers(CommandsCommonMatchers::Evaluation(this), CommandsCommonMatchers::LABEL_EVALUATION);
|
||||
AddLabeledMatchers(CommandsCommonMatchers::ArrayDef(this), CommandsCommonMatchers::LABEL_ARRAY_DEF);
|
||||
AddMatchers({
|
||||
create.Keyword("set").Capture(CAPTURE_START),
|
||||
create.Keyword("count"),
|
||||
create.OptionalLoop(create.Char('*').Tag(TAG_POINTER_RESOLVE)),
|
||||
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
|
||||
create.OptionalLoop(create.Label(CommandsCommonMatchers::LABEL_ARRAY_DEF).Capture(CAPTURE_ARRAY_INDEX)),
|
||||
create.Label(CommandsCommonMatchers::LABEL_EVALUATION),
|
||||
create.Char(';'),
|
||||
});
|
||||
}
|
||||
|
||||
void SequenceCount::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
|
||||
|
@ -5,21 +5,9 @@
|
||||
|
||||
class SequenceCount final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto TAG_POINTER_RESOLVE = 1;
|
||||
|
||||
static constexpr auto CAPTURE_START = 1;
|
||||
static constexpr auto CAPTURE_TYPE = 2;
|
||||
static constexpr auto CAPTURE_ARRAY_INDEX = 3;
|
||||
|
||||
static void SetCountByArrayIndex(CommandsParserState* state,
|
||||
SequenceResult<CommandsParserValue>& result,
|
||||
MemberInformation* member,
|
||||
PointerDeclarationModifier* pointer,
|
||||
std::unique_ptr<IEvaluation> evaluation);
|
||||
public:
|
||||
SequenceCount();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceCount();
|
||||
};
|
||||
|
@ -3,6 +3,11 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_GAME = 1;
|
||||
}
|
||||
|
||||
SequenceGame::SequenceGame()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@ -4,11 +4,9 @@
|
||||
|
||||
class SequenceGame final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_GAME = 1;
|
||||
public:
|
||||
SequenceGame();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceGame();
|
||||
};
|
||||
|
@ -3,6 +3,11 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
}
|
||||
|
||||
SequenceName::SequenceName()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@ -4,11 +4,9 @@
|
||||
|
||||
class SequenceName final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
public:
|
||||
SequenceName();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceName();
|
||||
};
|
||||
|
@ -5,29 +5,16 @@
|
||||
|
||||
#include <list>
|
||||
|
||||
SequenceReorder::SequenceReorder()
|
||||
namespace
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
static constexpr auto TAG_FIND_FIRST = 1;
|
||||
|
||||
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
|
||||
AddMatchers({
|
||||
create.Keyword("reorder").Capture(CAPTURE_START),
|
||||
create.Optional(create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE)),
|
||||
create.Char(':'),
|
||||
create.Optional(create
|
||||
.And({
|
||||
create.Char('.'),
|
||||
create.Char('.'),
|
||||
create.Char('.'),
|
||||
})
|
||||
.Tag(TAG_FIND_FIRST)),
|
||||
create.Loop(create.Identifier().Capture(CAPTURE_ENTRY)),
|
||||
create.Char(';'),
|
||||
});
|
||||
}
|
||||
static constexpr auto CAPTURE_START = 1;
|
||||
static constexpr auto CAPTURE_TYPE = 2;
|
||||
static constexpr auto CAPTURE_ENTRY = 3;
|
||||
|
||||
StructureInformation* SequenceReorder::GetType(CommandsParserState* state, SequenceResult<CommandsParserValue>& result)
|
||||
{
|
||||
StructureInformation* GetType(CommandsParserState* state, SequenceResult<CommandsParserValue>& result)
|
||||
{
|
||||
if (result.HasNextCapture(CAPTURE_TYPE))
|
||||
{
|
||||
const auto& typeNameToken = result.NextCapture(CAPTURE_TYPE);
|
||||
@ -52,6 +39,28 @@ StructureInformation* SequenceReorder::GetType(CommandsParserState* state, Seque
|
||||
return state->GetInUse();
|
||||
|
||||
throw ParsingException(result.NextCapture(CAPTURE_START).GetPos(), "No type is used. Therefore one needs to be specified directly.");
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SequenceReorder::SequenceReorder()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
||||
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
|
||||
AddMatchers({
|
||||
create.Keyword("reorder").Capture(CAPTURE_START),
|
||||
create.Optional(create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE)),
|
||||
create.Char(':'),
|
||||
create.Optional(create
|
||||
.And({
|
||||
create.Char('.'),
|
||||
create.Char('.'),
|
||||
create.Char('.'),
|
||||
})
|
||||
.Tag(TAG_FIND_FIRST)),
|
||||
create.Loop(create.Identifier().Capture(CAPTURE_ENTRY)),
|
||||
create.Char(';'),
|
||||
});
|
||||
}
|
||||
|
||||
void SequenceReorder::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
|
||||
|
@ -4,17 +4,9 @@
|
||||
|
||||
class SequenceReorder final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto TAG_FIND_FIRST = 1;
|
||||
|
||||
static constexpr auto CAPTURE_START = 1;
|
||||
static constexpr auto CAPTURE_TYPE = 2;
|
||||
static constexpr auto CAPTURE_ENTRY = 3;
|
||||
|
||||
static StructureInformation* GetType(CommandsParserState* state, SequenceResult<CommandsParserValue>& result);
|
||||
public:
|
||||
SequenceReorder();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceReorder();
|
||||
};
|
||||
|
@ -3,6 +3,11 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
}
|
||||
|
||||
SequenceReusable::SequenceReusable()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@ -4,11 +4,9 @@
|
||||
|
||||
class SequenceReusable final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
public:
|
||||
SequenceReusable();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceReusable();
|
||||
};
|
||||
|
@ -3,6 +3,11 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
}
|
||||
|
||||
SequenceScriptString::SequenceScriptString()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@ -4,11 +4,9 @@
|
||||
|
||||
class SequenceScriptString final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
public:
|
||||
SequenceScriptString();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceScriptString();
|
||||
};
|
||||
|
@ -3,6 +3,13 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_START = 1;
|
||||
static constexpr auto CAPTURE_TYPE = 2;
|
||||
static constexpr auto CAPTURE_BLOCK_ENUM_ENTRY = 3;
|
||||
} // namespace
|
||||
|
||||
SequenceSetBlock::SequenceSetBlock()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@ -4,13 +4,9 @@
|
||||
|
||||
class SequenceSetBlock final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_START = 1;
|
||||
static constexpr auto CAPTURE_TYPE = 2;
|
||||
static constexpr auto CAPTURE_BLOCK_ENUM_ENTRY = 3;
|
||||
public:
|
||||
SequenceSetBlock();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceSetBlock();
|
||||
};
|
||||
|
@ -5,6 +5,11 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
}
|
||||
|
||||
SequenceString::SequenceString()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@ -4,11 +4,9 @@
|
||||
|
||||
class SequenceString final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
public:
|
||||
SequenceString();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceString();
|
||||
};
|
||||
|
@ -3,6 +3,11 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
}
|
||||
|
||||
SequenceUse::SequenceUse()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@ -4,11 +4,9 @@
|
||||
|
||||
class SequenceUse final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
public:
|
||||
SequenceUse();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceUse();
|
||||
};
|
||||
|
@ -7,18 +7,12 @@
|
||||
#include "IHeaderBlockVariableDefining.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class HeaderBlockEnum final : public IHeaderBlock, public IHeaderBlockNameHolder, public IHeaderBlockVariableDefining
|
||||
{
|
||||
std::string m_namespace;
|
||||
std::string m_type_name;
|
||||
const BaseTypeDefinition* m_parent_type;
|
||||
bool m_is_typedef;
|
||||
std::vector<std::unique_ptr<EnumMember>> m_members;
|
||||
int m_next_value;
|
||||
EnumDefinition* m_enum_definition;
|
||||
|
||||
std::string m_variable_name;
|
||||
|
||||
public:
|
||||
HeaderBlockEnum(std::string typeName, const BaseTypeDefinition* parentType, bool isTypeDef);
|
||||
|
||||
@ -29,11 +23,22 @@ public:
|
||||
void OnChildBlockClose(HeaderParserState* state, IHeaderBlock* block) override;
|
||||
|
||||
void AddEnumMember(std::unique_ptr<EnumMember> enumMember);
|
||||
_NODISCARD EnumMember* GetEnumMember(const std::string& name) const;
|
||||
_NODISCARD int GetNextEnumMemberValue() const;
|
||||
[[nodiscard]] EnumMember* GetEnumMember(const std::string& name) const;
|
||||
[[nodiscard]] int GetNextEnumMemberValue() const;
|
||||
|
||||
void SetBlockName(const TokenPos& nameTokenPos, std::string name) override;
|
||||
bool IsDefiningVariable() override;
|
||||
DataDefinition* GetVariableType() override;
|
||||
std::string GetVariableName() override;
|
||||
|
||||
private:
|
||||
std::string m_namespace;
|
||||
std::string m_type_name;
|
||||
const BaseTypeDefinition* m_parent_type;
|
||||
bool m_is_typedef;
|
||||
std::vector<std::unique_ptr<EnumMember>> m_members;
|
||||
int m_next_value;
|
||||
EnumDefinition* m_enum_definition;
|
||||
|
||||
std::string m_variable_name;
|
||||
};
|
||||
|
@ -2,10 +2,11 @@
|
||||
|
||||
#include "IHeaderBlock.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class HeaderBlockNamespace final : public IHeaderBlock
|
||||
{
|
||||
std::string m_namespace_name;
|
||||
|
||||
public:
|
||||
explicit HeaderBlockNamespace(std::string namespaceName);
|
||||
|
||||
@ -14,4 +15,6 @@ public:
|
||||
void OnOpen(HeaderParserState* state) override;
|
||||
void OnClose(HeaderParserState* state) override;
|
||||
void OnChildBlockClose(HeaderParserState* state, IHeaderBlock* block) override;
|
||||
|
||||
std::string m_namespace_name;
|
||||
};
|
||||
|
@ -7,23 +7,12 @@
|
||||
#include "IHeaderBlockVariableDefining.h"
|
||||
#include "IHeaderBlockVariableHolder.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class HeaderBlockStruct final : public IHeaderBlock, public IHeaderBlockNameHolder, public IHeaderBlockVariableDefining, public IHeaderBlockVariableHolder
|
||||
{
|
||||
std::string m_namespace;
|
||||
std::string m_type_name;
|
||||
std::vector<std::shared_ptr<Variable>> m_members;
|
||||
StructDefinition* m_struct_definition;
|
||||
|
||||
int m_custom_alignment;
|
||||
|
||||
bool m_is_typedef;
|
||||
bool m_has_custom_align;
|
||||
bool m_is_anonymous;
|
||||
|
||||
std::string m_variable_name;
|
||||
|
||||
public:
|
||||
HeaderBlockStruct(std::string name, bool isTypedef);
|
||||
|
||||
@ -41,4 +30,18 @@ public:
|
||||
bool IsDefiningVariable() override;
|
||||
DataDefinition* GetVariableType() override;
|
||||
std::string GetVariableName() override;
|
||||
|
||||
private:
|
||||
std::string m_namespace;
|
||||
std::string m_type_name;
|
||||
std::vector<std::shared_ptr<Variable>> m_members;
|
||||
StructDefinition* m_struct_definition;
|
||||
|
||||
int m_custom_alignment;
|
||||
|
||||
bool m_is_typedef;
|
||||
bool m_has_custom_align;
|
||||
bool m_is_anonymous;
|
||||
|
||||
std::string m_variable_name;
|
||||
};
|
||||
|
@ -5,21 +5,12 @@
|
||||
#include "IHeaderBlockVariableDefining.h"
|
||||
#include "IHeaderBlockVariableHolder.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class HeaderBlockUnion final : public IHeaderBlock, public IHeaderBlockNameHolder, public IHeaderBlockVariableDefining, public IHeaderBlockVariableHolder
|
||||
{
|
||||
std::string m_namespace;
|
||||
std::string m_type_name;
|
||||
std::vector<std::shared_ptr<Variable>> m_members;
|
||||
UnionDefinition* m_union_definition;
|
||||
|
||||
int m_custom_alignment;
|
||||
|
||||
bool m_is_typedef;
|
||||
bool m_has_custom_align;
|
||||
bool m_is_anonymous;
|
||||
|
||||
std::string m_variable_name;
|
||||
|
||||
public:
|
||||
HeaderBlockUnion(std::string name, bool isTypedef);
|
||||
|
||||
@ -37,4 +28,18 @@ public:
|
||||
bool IsDefiningVariable() override;
|
||||
DataDefinition* GetVariableType() override;
|
||||
std::string GetVariableName() override;
|
||||
|
||||
private:
|
||||
std::string m_namespace;
|
||||
std::string m_type_name;
|
||||
std::vector<std::shared_ptr<Variable>> m_members;
|
||||
UnionDefinition* m_union_definition;
|
||||
|
||||
int m_custom_alignment;
|
||||
|
||||
bool m_is_typedef;
|
||||
bool m_has_custom_align;
|
||||
bool m_is_anonymous;
|
||||
|
||||
std::string m_variable_name;
|
||||
};
|
||||
|
@ -13,8 +13,15 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_NAME = "__zonecodegenerator";
|
||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_VALUE = "1";
|
||||
} // namespace
|
||||
|
||||
HeaderFileReader::HeaderFileReader(const ZoneCodeGeneratorArguments* args, std::string filename)
|
||||
: m_args(args),
|
||||
m_filename(std::move(filename)),
|
||||
@ -29,7 +36,7 @@ bool HeaderFileReader::OpenBaseStream()
|
||||
auto stream = std::make_unique<ParserFilesystemStream>(m_filename);
|
||||
if (!stream->IsOpen())
|
||||
{
|
||||
std::cout << "Could not open header file\n";
|
||||
std::cerr << "Could not open header file\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -65,9 +72,7 @@ void HeaderFileReader::SetupPostProcessors()
|
||||
bool HeaderFileReader::ReadHeaderFile(IDataRepository* repository)
|
||||
{
|
||||
if (m_args->m_verbose)
|
||||
{
|
||||
std::cout << "Reading header file: " << m_filename << "\n";
|
||||
}
|
||||
std::cout << std::format("Reading header file: {}\n", m_filename);
|
||||
|
||||
if (!OpenBaseStream())
|
||||
return false;
|
||||
@ -84,9 +89,7 @@ bool HeaderFileReader::ReadHeaderFile(IDataRepository* repository)
|
||||
const auto end = std::chrono::steady_clock::now();
|
||||
|
||||
if (m_args->m_verbose)
|
||||
{
|
||||
std::cout << "Processing header took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms\n";
|
||||
}
|
||||
std::cout << std::format("Processing header took {}ms\n", std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count());
|
||||
|
||||
if (!result)
|
||||
return false;
|
||||
|
@ -10,8 +10,15 @@
|
||||
|
||||
class HeaderFileReader
|
||||
{
|
||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_NAME = "__zonecodegenerator";
|
||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_VALUE = "1";
|
||||
public:
|
||||
HeaderFileReader(const ZoneCodeGeneratorArguments* args, std::string filename);
|
||||
|
||||
bool ReadHeaderFile(IDataRepository* repository);
|
||||
|
||||
private:
|
||||
bool OpenBaseStream();
|
||||
void SetupStreamProxies();
|
||||
void SetupPostProcessors();
|
||||
|
||||
const ZoneCodeGeneratorArguments* m_args;
|
||||
std::string m_filename;
|
||||
@ -21,13 +28,4 @@ class HeaderFileReader
|
||||
IParserLineStream* m_stream;
|
||||
|
||||
std::vector<std::unique_ptr<IPostProcessor>> m_post_processors;
|
||||
|
||||
bool OpenBaseStream();
|
||||
void SetupStreamProxies();
|
||||
void SetupPostProcessors();
|
||||
|
||||
public:
|
||||
HeaderFileReader(const ZoneCodeGeneratorArguments* args, std::string filename);
|
||||
|
||||
bool ReadHeaderFile(IDataRepository* repository);
|
||||
};
|
||||
|
@ -3,17 +3,19 @@
|
||||
#include "HeaderParserValue.h"
|
||||
#include "Parsing/Impl/AbstractLexer.h"
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
class HeaderLexer final : public AbstractLexer<HeaderParserValue>
|
||||
{
|
||||
std::unordered_map<std::string, HeaderParserValueType> m_keywords;
|
||||
|
||||
void PrepareKeywords();
|
||||
public:
|
||||
explicit HeaderLexer(IParserLineStream* stream);
|
||||
|
||||
protected:
|
||||
HeaderParserValue GetNextToken() override;
|
||||
|
||||
public:
|
||||
explicit HeaderLexer(IParserLineStream* stream);
|
||||
private:
|
||||
void PrepareKeywords();
|
||||
|
||||
std::unordered_map<std::string, HeaderParserValueType> m_keywords;
|
||||
};
|
||||
|
@ -8,11 +8,11 @@
|
||||
|
||||
class HeaderParser final : public AbstractParser<HeaderParserValue, HeaderParserState>
|
||||
{
|
||||
protected:
|
||||
const std::vector<sequence_t*>& GetTestsForState() override;
|
||||
|
||||
public:
|
||||
HeaderParser(HeaderLexer* lexer, const IPackValueSupplier* packValueSupplier);
|
||||
|
||||
bool SaveToRepository(IDataRepository* repository) const;
|
||||
|
||||
protected:
|
||||
const std::vector<sequence_t*>& GetTestsForState() override;
|
||||
};
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "Domain/Definition/EnumDefinition.h"
|
||||
#include "Parsing/Header/Block/HeaderBlockNone.h"
|
||||
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
HeaderParserState::HeaderParserState(const IPackValueSupplier* packValueSupplier)
|
||||
@ -96,7 +97,7 @@ bool HeaderParserState::ResolveForwardDeclarations()
|
||||
|
||||
if (dataDefinition == nullptr)
|
||||
{
|
||||
std::cout << "Forward declaration \"" << forwardDeclaration->GetFullName() << "\" was not defined\n";
|
||||
std::cerr << std::format("Forward declaration \"{}\" was not defined\n", forwardDeclaration->GetFullName());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -12,31 +12,15 @@
|
||||
|
||||
#include <memory>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
class IHeaderBlock;
|
||||
|
||||
class HeaderParserState
|
||||
{
|
||||
std::vector<std::unique_ptr<DataDefinition>> m_header_definitions;
|
||||
|
||||
std::stack<std::unique_ptr<IHeaderBlock>> m_blocks;
|
||||
std::unordered_map<std::string, const DataDefinition*> m_definitions;
|
||||
std::unordered_map<std::string, EnumMember*> m_enum_members;
|
||||
std::unordered_map<std::string, std::unique_ptr<ForwardDeclaration>> m_forward_declarations;
|
||||
|
||||
void AddBaseDataType(const BaseTypeDefinition* baseType);
|
||||
bool ResolveForwardDeclarations();
|
||||
static bool ReplaceForwardDeclarationsInStruct(StructDefinition* structDefinition);
|
||||
static bool ReplaceForwardDeclarationsInTypedef(TypedefDefinition* typedefDefinition);
|
||||
static bool ReplaceForwardDeclarationsInUnion(UnionDefinition* unionDefinition);
|
||||
bool ReplaceForwardDeclarationsInDefinitions();
|
||||
bool MoveDefinitionsToRepository(IDataRepository* repository);
|
||||
|
||||
public:
|
||||
const IPackValueSupplier* const m_pack_value_supplier;
|
||||
NamespaceBuilder m_namespace;
|
||||
|
||||
explicit HeaderParserState(const IPackValueSupplier* packValueSupplier);
|
||||
|
||||
_NODISCARD IHeaderBlock* GetBlock() const;
|
||||
@ -50,4 +34,23 @@ public:
|
||||
EnumMember* FindEnumMember(const std::string& enumMemberName);
|
||||
|
||||
bool SaveToRepository(IDataRepository* repository);
|
||||
|
||||
const IPackValueSupplier* const m_pack_value_supplier;
|
||||
NamespaceBuilder m_namespace;
|
||||
|
||||
private:
|
||||
void AddBaseDataType(const BaseTypeDefinition* baseType);
|
||||
bool ResolveForwardDeclarations();
|
||||
static bool ReplaceForwardDeclarationsInStruct(StructDefinition* structDefinition);
|
||||
static bool ReplaceForwardDeclarationsInTypedef(TypedefDefinition* typedefDefinition);
|
||||
static bool ReplaceForwardDeclarationsInUnion(UnionDefinition* unionDefinition);
|
||||
bool ReplaceForwardDeclarationsInDefinitions();
|
||||
bool MoveDefinitionsToRepository(IDataRepository* repository);
|
||||
|
||||
std::vector<std::unique_ptr<DataDefinition>> m_header_definitions;
|
||||
|
||||
std::stack<std::unique_ptr<IHeaderBlock>> m_blocks;
|
||||
std::unordered_map<std::string, const DataDefinition*> m_definitions;
|
||||
std::unordered_map<std::string, EnumMember*> m_enum_members;
|
||||
std::unordered_map<std::string, std::unique_ptr<ForwardDeclaration>> m_forward_declarations;
|
||||
};
|
||||
|
@ -61,9 +61,6 @@ enum class HeaderParserValueType
|
||||
class HeaderParserValue final : public IParserValue
|
||||
{
|
||||
public:
|
||||
TokenPos m_pos;
|
||||
HeaderParserValueType m_type;
|
||||
|
||||
union ValueType
|
||||
{
|
||||
char char_value;
|
||||
@ -90,23 +87,25 @@ public:
|
||||
static HeaderParserValue Keyword(TokenPos pos, HeaderParserValueType type);
|
||||
static HeaderParserValue TypeName(TokenPos pos, std::string* typeName);
|
||||
|
||||
private:
|
||||
HeaderParserValue(TokenPos pos, HeaderParserValueType type);
|
||||
|
||||
public:
|
||||
~HeaderParserValue() override;
|
||||
HeaderParserValue(const HeaderParserValue& other) = delete;
|
||||
HeaderParserValue(HeaderParserValue&& other) noexcept;
|
||||
HeaderParserValue& operator=(const HeaderParserValue& other) = delete;
|
||||
HeaderParserValue& operator=(HeaderParserValue&& other) noexcept;
|
||||
|
||||
_NODISCARD bool IsEof() const override;
|
||||
_NODISCARD const TokenPos& GetPos() const override;
|
||||
[[nodiscard]] bool IsEof() const override;
|
||||
[[nodiscard]] const TokenPos& GetPos() const override;
|
||||
|
||||
_NODISCARD char CharacterValue() const;
|
||||
_NODISCARD int IntegerValue() const;
|
||||
_NODISCARD double FloatingPointValue() const;
|
||||
_NODISCARD std::string& StringValue() const;
|
||||
_NODISCARD std::string& IdentifierValue() const;
|
||||
_NODISCARD std::string& TypeNameValue() const;
|
||||
[[nodiscard]] char CharacterValue() const;
|
||||
[[nodiscard]] int IntegerValue() const;
|
||||
[[nodiscard]] double FloatingPointValue() const;
|
||||
[[nodiscard]] std::string& StringValue() const;
|
||||
[[nodiscard]] std::string& IdentifierValue() const;
|
||||
[[nodiscard]] std::string& TypeNameValue() const;
|
||||
|
||||
TokenPos m_pos;
|
||||
HeaderParserValueType m_type;
|
||||
|
||||
private:
|
||||
HeaderParserValue(TokenPos pos, HeaderParserValueType type);
|
||||
};
|
||||
|
@ -5,11 +5,12 @@
|
||||
|
||||
class HeaderMatcherCharacter final : public AbstractMatcher<HeaderParserValue>
|
||||
{
|
||||
char m_char;
|
||||
public:
|
||||
explicit HeaderMatcherCharacter(char c);
|
||||
|
||||
protected:
|
||||
MatcherResult<HeaderParserValue> CanMatch(ILexer<HeaderParserValue>* lexer, unsigned tokenOffset) override;
|
||||
|
||||
public:
|
||||
explicit HeaderMatcherCharacter(char c);
|
||||
private:
|
||||
char m_char;
|
||||
};
|
||||
|
@ -8,9 +8,9 @@ class HeaderMatcherFactory final : public AbstractMatcherFactory<HeaderParserVal
|
||||
public:
|
||||
explicit HeaderMatcherFactory(const IMatcherForLabelSupplier<HeaderParserValue>* labelSupplier);
|
||||
|
||||
_NODISCARD MatcherFactoryWrapper<HeaderParserValue> Type(HeaderParserValueType type) const;
|
||||
_NODISCARD MatcherFactoryWrapper<HeaderParserValue> Identifier() const;
|
||||
_NODISCARD MatcherFactoryWrapper<HeaderParserValue> Integer() const;
|
||||
_NODISCARD MatcherFactoryWrapper<HeaderParserValue> FloatingPoint() const;
|
||||
_NODISCARD MatcherFactoryWrapper<HeaderParserValue> Char(char c) const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<HeaderParserValue> Type(HeaderParserValueType type) const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<HeaderParserValue> Identifier() const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<HeaderParserValue> Integer() const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<HeaderParserValue> FloatingPoint() const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<HeaderParserValue> Char(char c) const;
|
||||
};
|
||||
|
@ -5,11 +5,12 @@
|
||||
|
||||
class HeaderMatcherValueType final : public AbstractMatcher<HeaderParserValue>
|
||||
{
|
||||
HeaderParserValueType m_type;
|
||||
public:
|
||||
explicit HeaderMatcherValueType(HeaderParserValueType type);
|
||||
|
||||
protected:
|
||||
MatcherResult<HeaderParserValue> CanMatch(ILexer<HeaderParserValue>* lexer, unsigned tokenOffset) override;
|
||||
|
||||
public:
|
||||
explicit HeaderMatcherValueType(HeaderParserValueType type);
|
||||
private:
|
||||
HeaderParserValueType m_type;
|
||||
};
|
||||
|
@ -4,6 +4,14 @@
|
||||
#include "Parsing/Header/Matcher/HeaderCommonMatchers.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto TAG_SEMICOLON = 1;
|
||||
|
||||
static constexpr auto CAPTURE_NAME = 1;
|
||||
static constexpr auto CAPTURE_CLOSING_PARENTHESIS = 2;
|
||||
} // namespace
|
||||
|
||||
SequenceCloseBlock::SequenceCloseBlock(const bool semicolonRequired)
|
||||
: m_semicolon_required(semicolonRequired)
|
||||
{
|
||||
|
@ -7,16 +7,12 @@
|
||||
|
||||
class SequenceCloseBlock final : public HeaderParser::sequence_t
|
||||
{
|
||||
static constexpr auto TAG_SEMICOLON = 1;
|
||||
|
||||
static constexpr auto CAPTURE_NAME = 1;
|
||||
static constexpr auto CAPTURE_CLOSING_PARENTHESIS = 2;
|
||||
public:
|
||||
explicit SequenceCloseBlock(bool semicolonRequired);
|
||||
|
||||
private:
|
||||
bool m_semicolon_required;
|
||||
|
||||
protected:
|
||||
void ProcessMatch(HeaderParserState* state, SequenceResult<HeaderParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
explicit SequenceCloseBlock(bool semicolonRequired);
|
||||
};
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user