mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-25 23:29:09 +00:00
Merge pull request #417 from Laupetin/chore/formatting-for-zcg-templates
chore: use std::format for zcg templates
This commit is contained in:
commit
cf8969c1a6
@ -74,7 +74,7 @@ void BaseTemplate::MakeTypeWrittenPtrVarNameInternal(const DataDefinition* def,
|
||||
|
||||
void BaseTemplate::MakeArrayIndicesInternal(const DeclarationModifierComputations& modifierComputations, std::ostringstream& str)
|
||||
{
|
||||
for (auto index : modifierComputations.GetArrayIndices())
|
||||
for (const auto index : modifierComputations.GetArrayIndices())
|
||||
{
|
||||
str << "[" << index << "]";
|
||||
}
|
||||
@ -115,7 +115,7 @@ std::string BaseTemplate::MakeSafeTypeName(const DataDefinition* def)
|
||||
return str.str();
|
||||
}
|
||||
|
||||
std::string BaseTemplate::MakeMemberAccess(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier)
|
||||
std::string BaseTemplate::MakeMemberAccess(const StructureInformation* info, const MemberInformation* member, const DeclarationModifierComputations& modifier)
|
||||
{
|
||||
std::ostringstream str;
|
||||
MakeTypeVarNameInternal(info->m_definition, str);
|
||||
@ -125,7 +125,8 @@ std::string BaseTemplate::MakeMemberAccess(StructureInformation* info, MemberInf
|
||||
return str.str();
|
||||
}
|
||||
|
||||
std::string BaseTemplate::MakeWrittenMemberAccess(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier)
|
||||
std::string
|
||||
BaseTemplate::MakeWrittenMemberAccess(const StructureInformation* info, const MemberInformation* member, const DeclarationModifierComputations& modifier)
|
||||
{
|
||||
std::ostringstream str;
|
||||
MakeTypeWrittenVarNameInternal(info->m_definition, str);
|
||||
@ -137,7 +138,7 @@ std::string BaseTemplate::MakeWrittenMemberAccess(StructureInformation* info, Me
|
||||
|
||||
std::string BaseTemplate::MakeMemberAccess(const std::string& variableName,
|
||||
StructureInformation* info,
|
||||
MemberInformation* member,
|
||||
const MemberInformation* member,
|
||||
const DeclarationModifierComputations& modifier)
|
||||
{
|
||||
std::ostringstream str;
|
||||
@ -185,13 +186,13 @@ std::string BaseTemplate::MakeArrayIndices(const DeclarationModifierComputations
|
||||
return str.str();
|
||||
}
|
||||
|
||||
std::string BaseTemplate::MakeCustomActionCall(CustomAction* action)
|
||||
std::string BaseTemplate::MakeCustomActionCall(const CustomAction* action)
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << "m_actions." << action->m_action_name << "(";
|
||||
|
||||
auto first = true;
|
||||
for (auto* def : action->m_parameter_types)
|
||||
for (const auto* def : action->m_parameter_types)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
|
@ -7,13 +7,13 @@
|
||||
#include "Domain/Evaluation/Operation.h"
|
||||
#include "Generating/RenderingContext.h"
|
||||
|
||||
#include <format>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
|
||||
class BaseTemplate
|
||||
{
|
||||
protected:
|
||||
static constexpr const char* INTENDATION = " ";
|
||||
static constexpr auto INTENDATION = " ";
|
||||
|
||||
BaseTemplate(std::ostream& stream, RenderingContext* context);
|
||||
|
||||
@ -26,16 +26,17 @@ protected:
|
||||
static std::string MakeTypePtrVarName(const DataDefinition* def);
|
||||
static std::string MakeTypeWrittenPtrVarName(const DataDefinition* def);
|
||||
static std::string MakeSafeTypeName(const DataDefinition* def);
|
||||
static std::string MakeMemberAccess(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier);
|
||||
static std::string MakeWrittenMemberAccess(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier);
|
||||
static std::string MakeMemberAccess(const StructureInformation* info, const MemberInformation* member, const DeclarationModifierComputations& modifier);
|
||||
static std::string
|
||||
MakeWrittenMemberAccess(const StructureInformation* info, const MemberInformation* member, const DeclarationModifierComputations& modifier);
|
||||
static std::string MakeMemberAccess(const std::string& variableName,
|
||||
StructureInformation* info,
|
||||
MemberInformation* member,
|
||||
const MemberInformation* member,
|
||||
const DeclarationModifierComputations& modifier);
|
||||
static std::string MakeTypeDecl(const TypeDeclaration* decl);
|
||||
static std::string MakeFollowingReferences(const std::vector<DeclarationModifier*>& modifiers);
|
||||
static std::string MakeArrayIndices(const DeclarationModifierComputations& modifierComputations);
|
||||
static std::string MakeCustomActionCall(CustomAction* action);
|
||||
static std::string MakeCustomActionCall(const CustomAction* action);
|
||||
static std::string MakeArrayCount(const ArrayDeclarationModifier* arrayModifier);
|
||||
static std::string MakeEvaluation(const IEvaluation* evaluation);
|
||||
|
||||
@ -61,16 +62,34 @@ private:
|
||||
DoIntendation(); \
|
||||
m_out << x << "\n"; \
|
||||
}
|
||||
#define LINEF(...) \
|
||||
{ \
|
||||
DoIntendation(); \
|
||||
m_out << std::format(__VA_ARGS__) << "\n"; \
|
||||
}
|
||||
#define LINE_START(x) \
|
||||
{ \
|
||||
DoIntendation(); \
|
||||
m_out << x; \
|
||||
}
|
||||
#define LINE_STARTF(...) \
|
||||
{ \
|
||||
DoIntendation(); \
|
||||
m_out << std::format(__VA_ARGS__); \
|
||||
}
|
||||
#define LINE_MIDDLE(x) \
|
||||
{ \
|
||||
m_out << x; \
|
||||
}
|
||||
#define LINE_MIDDLEF(...) \
|
||||
{ \
|
||||
m_out << std::format(__VA_ARGS__); \
|
||||
}
|
||||
#define LINE_END(x) \
|
||||
{ \
|
||||
m_out << x << "\n"; \
|
||||
}
|
||||
#define LINE_ENDF(...) \
|
||||
{ \
|
||||
m_out << std::format(__VA_ARGS__) << "\n"; \
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -11,8 +11,8 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr int TAG_HEADER = 1;
|
||||
static constexpr int TAG_SOURCE = 2;
|
||||
constexpr int TAG_HEADER = 1;
|
||||
constexpr int TAG_SOURCE = 2;
|
||||
|
||||
class Template final : BaseTemplate
|
||||
{
|
||||
@ -26,20 +26,21 @@ namespace
|
||||
{
|
||||
LINE("// ====================================================================")
|
||||
LINE("// This file has been generated by ZoneCodeGenerator.")
|
||||
LINE("// Do not modify. ")
|
||||
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\"")
|
||||
LINEF("#include \"Game/{0}/{0}.h\"", m_env.m_game)
|
||||
LINE("")
|
||||
LINE("#include <string>")
|
||||
LINE("")
|
||||
LINE("namespace " << m_env.m_game)
|
||||
LINEF("namespace {0}", m_env.m_game)
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
LINE("class " << MarkerClassName(m_env.m_asset) << " final : public AssetMarker")
|
||||
LINEF("class {0} final : public AssetMarker", MarkerClassName(m_env.m_asset))
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
@ -52,14 +53,14 @@ namespace
|
||||
m_intendation++;
|
||||
|
||||
// Variable Declarations: type varType;
|
||||
for (auto* type : m_env.m_used_types)
|
||||
for (const 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)
|
||||
for (const auto* type : m_env.m_used_types)
|
||||
{
|
||||
if (type->m_pointer_array_reference_exists && !type->m_is_context_asset)
|
||||
{
|
||||
@ -70,14 +71,14 @@ namespace
|
||||
LINE("")
|
||||
|
||||
// Method Declarations
|
||||
for (auto* type : m_env.m_used_types)
|
||||
for (const 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)
|
||||
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)
|
||||
@ -111,11 +112,12 @@ namespace
|
||||
{
|
||||
LINE("// ====================================================================")
|
||||
LINE("// This file has been generated by ZoneCodeGenerator.")
|
||||
LINE("// Do not modify. ")
|
||||
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\"")
|
||||
LINEF("#include \"{0}_mark_db.h\"", Lower(m_env.m_asset->m_definition->m_name))
|
||||
LINE("")
|
||||
LINE("#include <cassert>")
|
||||
LINE("")
|
||||
|
||||
@ -124,11 +126,11 @@ namespace
|
||||
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\"")
|
||||
LINEF("#include \"../{0}/{0}_mark_db.h\"", Lower(type->m_type->m_name))
|
||||
}
|
||||
LINE("")
|
||||
}
|
||||
LINE("using namespace " << m_env.m_game << ";")
|
||||
LINEF("using namespace {0};", m_env.m_game)
|
||||
LINE("")
|
||||
PrintConstructorMethod();
|
||||
|
||||
@ -168,7 +170,7 @@ namespace
|
||||
}
|
||||
|
||||
private:
|
||||
enum class MemberLoadType
|
||||
enum class MemberLoadType : std::uint8_t
|
||||
{
|
||||
ARRAY_POINTER,
|
||||
DYNAMIC_ARRAY,
|
||||
@ -178,78 +180,72 @@ namespace
|
||||
SINGLE_POINTER
|
||||
};
|
||||
|
||||
static std::string MarkerClassName(StructureInformation* asset)
|
||||
static std::string MarkerClassName(const StructureInformation* asset)
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << "Marker_" << asset->m_definition->m_name;
|
||||
return str.str();
|
||||
return std::format("Marker_{0}", asset->m_definition->m_name);
|
||||
}
|
||||
|
||||
static std::string VariableDecl(const DataDefinition* def)
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << def->GetFullName() << "* var" << MakeSafeTypeName(def) << ";";
|
||||
return str.str();
|
||||
return std::format("{0}* var{1};", def->GetFullName(), MakeSafeTypeName(def));
|
||||
}
|
||||
|
||||
static std::string PointerVariableDecl(const DataDefinition* def)
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << def->GetFullName() << "** var" << MakeSafeTypeName(def) << "Ptr;";
|
||||
return str.str();
|
||||
return std::format("{0}** var{1}Ptr;", def->GetFullName(), MakeSafeTypeName(def));
|
||||
}
|
||||
|
||||
void PrintHeaderPtrArrayMarkMethodDeclaration(const DataDefinition* def) const
|
||||
{
|
||||
LINE("void MarkPtrArray_" << MakeSafeTypeName(def) << "(size_t count);")
|
||||
LINEF("void MarkPtrArray_{0}(size_t count);", MakeSafeTypeName(def))
|
||||
}
|
||||
|
||||
void PrintHeaderArrayMarkMethodDeclaration(const DataDefinition* def) const
|
||||
{
|
||||
LINE("void MarkArray_" << MakeSafeTypeName(def) << "(size_t count);")
|
||||
LINEF("void MarkArray_{0}(size_t count);", MakeSafeTypeName(def))
|
||||
}
|
||||
|
||||
void PrintHeaderMarkMethodDeclaration(const StructureInformation* info) const
|
||||
{
|
||||
LINE("void Mark_" << MakeSafeTypeName(info->m_definition) << "();")
|
||||
LINEF("void Mark_{0}();", MakeSafeTypeName(info->m_definition))
|
||||
}
|
||||
|
||||
void PrintHeaderGetAssetInfoMethodDeclaration(const StructureInformation* info) const
|
||||
{
|
||||
LINE("XAssetInfo<" << info->m_definition->GetFullName() << ">* GetAssetInfo(" << info->m_definition->GetFullName() << "* pAsset) const;")
|
||||
LINEF("XAssetInfo<{0}>* GetAssetInfo({0}* pAsset) const;", info->m_definition->GetFullName())
|
||||
}
|
||||
|
||||
void PrintHeaderGetNameMethodDeclaration(const StructureInformation* info) const
|
||||
{
|
||||
LINE("static std::string GetAssetName(" << info->m_definition->GetFullName() << "* pAsset);")
|
||||
LINEF("static std::string GetAssetName({0}* pAsset);", info->m_definition->GetFullName())
|
||||
}
|
||||
|
||||
void PrintHeaderConstructor() const
|
||||
{
|
||||
LINE(MarkerClassName(m_env.m_asset) << "(Zone* zone);")
|
||||
LINEF("{0}(Zone* zone);", MarkerClassName(m_env.m_asset))
|
||||
}
|
||||
|
||||
void PrintHeaderMainMarkMethodDeclaration(const StructureInformation* info) const
|
||||
{
|
||||
LINE("void Mark(" << info->m_definition->GetFullName() << "* pAsset);")
|
||||
LINEF("void Mark({0}* pAsset);", info->m_definition->GetFullName())
|
||||
}
|
||||
|
||||
void PrintVariableInitialization(const DataDefinition* def) const
|
||||
{
|
||||
LINE("var" << def->m_name << " = nullptr;")
|
||||
LINEF("var{0} = nullptr;", def->m_name)
|
||||
}
|
||||
|
||||
void PrintPointerVariableInitialization(const DataDefinition* def) const
|
||||
{
|
||||
LINE("var" << def->m_name << "Ptr = nullptr;")
|
||||
LINEF("var{0}Ptr = nullptr;", def->m_name)
|
||||
}
|
||||
|
||||
void PrintConstructorMethod()
|
||||
{
|
||||
LINE(MarkerClassName(m_env.m_asset) << "::" << MarkerClassName(m_env.m_asset) << "(Zone* zone)")
|
||||
LINEF("{0}::{0}(Zone* zone)", MarkerClassName(m_env.m_asset))
|
||||
|
||||
m_intendation++;
|
||||
LINE(": AssetMarker(" << m_env.m_asset->m_asset_enum_entry->m_name << ", zone)")
|
||||
LINEF(": AssetMarker({0}, zone)", m_env.m_asset->m_asset_enum_entry->m_name)
|
||||
m_intendation--;
|
||||
|
||||
LINE("{")
|
||||
@ -282,20 +278,20 @@ namespace
|
||||
{
|
||||
if (info && !info->m_is_leaf)
|
||||
{
|
||||
LINE(MakeTypeVarName(info->m_definition) << " = *" << MakeTypePtrVarName(def) << ";")
|
||||
LINE("Mark_" << MakeSafeTypeName(def) << "();")
|
||||
LINEF("{0} = *{1};", MakeTypeVarName(info->m_definition), MakeTypePtrVarName(def))
|
||||
LINEF("Mark_{0}();", MakeSafeTypeName(def))
|
||||
}
|
||||
}
|
||||
|
||||
void PrintMarkPtrArrayMethod_PointerCheck(const DataDefinition* def, StructureInformation* info, const bool reusable)
|
||||
{
|
||||
LINE("if (*" << MakeTypePtrVarName(def) << ")")
|
||||
LINEF("if (*{0})", MakeTypePtrVarName(def))
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
if (info && StructureComputations(info).IsAsset())
|
||||
{
|
||||
LINE("AddDependency(" << MarkerClassName(info) << "(m_zone).GetAssetInfo(*" << MakeTypePtrVarName(def) << "));")
|
||||
LINEF("AddDependency({0}(m_zone).GetAssetInfo(*{1}));", MarkerClassName(info), MakeTypePtrVarName(def))
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -308,19 +304,19 @@ namespace
|
||||
|
||||
void PrintMarkPtrArrayMethod(const DataDefinition* def, StructureInformation* info, const bool reusable)
|
||||
{
|
||||
LINE("void " << MarkerClassName(m_env.m_asset) << "::MarkPtrArray_" << MakeSafeTypeName(def) << "(const size_t count)")
|
||||
LINEF("void {0}::MarkPtrArray_{1}(const size_t count)", MarkerClassName(m_env.m_asset), MakeSafeTypeName(def))
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
LINE("assert(" << MakeTypePtrVarName(def) << " != nullptr);")
|
||||
LINEF("assert({0} != nullptr);", MakeTypePtrVarName(def))
|
||||
LINE("")
|
||||
|
||||
LINE(def->GetFullName() << "** var = " << MakeTypePtrVarName(def) << ";")
|
||||
LINE("for(size_t index = 0; index < count; index++)")
|
||||
LINEF("{0}** var = {1};", def->GetFullName(), MakeTypePtrVarName(def))
|
||||
LINE("for (size_t index = 0; index < count; index++)")
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
LINE(MakeTypePtrVarName(def) << " = var;")
|
||||
LINEF("{0} = var;", MakeTypePtrVarName(def))
|
||||
PrintMarkPtrArrayMethod_PointerCheck(def, info, reusable);
|
||||
LINE("")
|
||||
LINE("var++;")
|
||||
@ -333,20 +329,20 @@ namespace
|
||||
|
||||
void PrintMarkArrayMethod(const DataDefinition* def, const StructureInformation* info)
|
||||
{
|
||||
LINE("void " << MarkerClassName(m_env.m_asset) << "::MarkArray_" << MakeSafeTypeName(def) << "(const size_t count)")
|
||||
LINEF("void {0}::MarkArray_{1}(const size_t count)", MarkerClassName(m_env.m_asset), MakeSafeTypeName(def))
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
LINE("assert(" << MakeTypeVarName(def) << " != nullptr);")
|
||||
LINEF("assert({0} != nullptr);", MakeTypeVarName(def))
|
||||
LINE("")
|
||||
|
||||
LINE(def->GetFullName() << "* var = " << MakeTypeVarName(def) << ";")
|
||||
LINE("for(size_t index = 0; index < count; index++)")
|
||||
LINEF("{0}* var = {1};", def->GetFullName(), MakeTypeVarName(def))
|
||||
LINE("for (size_t index = 0; index < count; index++)")
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
LINE(MakeTypeVarName(info->m_definition) << " = var;")
|
||||
LINE("Mark_" << info->m_definition->m_name << "();")
|
||||
LINEF("{0} = var;", MakeTypeVarName(info->m_definition))
|
||||
LINEF("Mark_{0}();", info->m_definition->m_name)
|
||||
LINE("var++;")
|
||||
|
||||
m_intendation--;
|
||||
@ -356,34 +352,34 @@ namespace
|
||||
LINE("}")
|
||||
}
|
||||
|
||||
void MarkMember_ScriptString(StructureInformation* info,
|
||||
MemberInformation* member,
|
||||
void MarkMember_ScriptString(const StructureInformation* info,
|
||||
const MemberInformation* member,
|
||||
const DeclarationModifierComputations& modifier,
|
||||
const MemberLoadType loadType) const
|
||||
{
|
||||
if (loadType == MemberLoadType::ARRAY_POINTER)
|
||||
{
|
||||
LINE("MarkArray_ScriptString(" << MakeMemberAccess(info, member, modifier) << ", " << MakeEvaluation(modifier.GetArrayPointerCountEvaluation())
|
||||
<< ");")
|
||||
LINEF("MarkArray_ScriptString({0}, {1});", MakeMemberAccess(info, member, modifier), MakeEvaluation(modifier.GetArrayPointerCountEvaluation()))
|
||||
}
|
||||
else if (loadType == MemberLoadType::EMBEDDED_ARRAY)
|
||||
{
|
||||
LINE("MarkArray_ScriptString(" << MakeMemberAccess(info, member, modifier) << ", "
|
||||
<< MakeArrayCount(dynamic_cast<ArrayDeclarationModifier*>(modifier.GetDeclarationModifier())) << ");")
|
||||
LINEF("MarkArray_ScriptString({0}, {1});",
|
||||
MakeMemberAccess(info, member, modifier),
|
||||
MakeArrayCount(dynamic_cast<ArrayDeclarationModifier*>(modifier.GetDeclarationModifier())))
|
||||
}
|
||||
else if (loadType == MemberLoadType::EMBEDDED)
|
||||
{
|
||||
LINE("Mark_ScriptString(" << MakeMemberAccess(info, member, modifier) << ");")
|
||||
LINEF("Mark_ScriptString({0});", MakeMemberAccess(info, member, modifier))
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
LINE("#error unsupported loadType " << static_cast<int>(loadType) << " for scriptstring")
|
||||
LINEF("#error unsupported loadType {0} for script string", static_cast<int>(loadType))
|
||||
}
|
||||
}
|
||||
|
||||
void MarkMember_AssetRef(StructureInformation* info,
|
||||
MemberInformation* member,
|
||||
void MarkMember_AssetRef(const StructureInformation* info,
|
||||
const MemberInformation* member,
|
||||
const DeclarationModifierComputations& modifier,
|
||||
const MemberLoadType loadType) const
|
||||
{
|
||||
@ -391,34 +387,38 @@ namespace
|
||||
{
|
||||
if (modifier.IsArray())
|
||||
{
|
||||
LINE("MarkArray_IndirectAssetRef(" << member->m_asset_ref->m_name << ", " << MakeMemberAccess(info, member, modifier) << ", "
|
||||
<< modifier.GetArraySize() << ");")
|
||||
LINEF("MarkArray_IndirectAssetRef({0}, {1}, {2});",
|
||||
member->m_asset_ref->m_name,
|
||||
MakeMemberAccess(info, member, modifier),
|
||||
modifier.GetArraySize())
|
||||
}
|
||||
else
|
||||
{
|
||||
LINE("MarkArray_IndirectAssetRef(" << member->m_asset_ref->m_name << ", " << MakeMemberAccess(info, member, modifier) << ", "
|
||||
<< MakeEvaluation(modifier.GetPointerArrayCountEvaluation()) << ");")
|
||||
LINEF("MarkArray_IndirectAssetRef({0}, {1}, {2});",
|
||||
member->m_asset_ref->m_name,
|
||||
MakeMemberAccess(info, member, modifier),
|
||||
MakeEvaluation(modifier.GetPointerArrayCountEvaluation()))
|
||||
}
|
||||
}
|
||||
else if (loadType == MemberLoadType::SINGLE_POINTER)
|
||||
{
|
||||
LINE("Mark_IndirectAssetRef(" << member->m_asset_ref->m_name << ", " << MakeMemberAccess(info, member, modifier) << ");")
|
||||
LINEF("Mark_IndirectAssetRef({0}, {1});", member->m_asset_ref->m_name, MakeMemberAccess(info, member, modifier))
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
LINE("#error unsupported loadType " << static_cast<int>(loadType) << " for scriptstring")
|
||||
LINEF("#error unsupported loadType {0} for script string", static_cast<int>(loadType))
|
||||
}
|
||||
}
|
||||
|
||||
void MarkMember_Asset(StructureInformation* info,
|
||||
MemberInformation* member,
|
||||
void MarkMember_Asset(const StructureInformation* info,
|
||||
const MemberInformation* member,
|
||||
const DeclarationModifierComputations& modifier,
|
||||
const MemberLoadType loadType) const
|
||||
{
|
||||
if (loadType == MemberLoadType::SINGLE_POINTER)
|
||||
{
|
||||
LINE("AddDependency(" << MarkerClassName(member->m_type) << "(m_zone).GetAssetInfo(" << MakeMemberAccess(info, member, modifier) << "));")
|
||||
LINEF("AddDependency({0}(m_zone).GetAssetInfo({1}));", MarkerClassName(member->m_type), MakeMemberAccess(info, member, modifier))
|
||||
}
|
||||
else if (loadType == MemberLoadType::POINTER_ARRAY)
|
||||
{
|
||||
@ -427,34 +427,35 @@ namespace
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
LINE("#error unsupported loadType " << static_cast<int>(loadType) << " for asset")
|
||||
LINEF("#error unsupported loadType {0} for asset", static_cast<int>(loadType))
|
||||
}
|
||||
}
|
||||
|
||||
void MarkMember_ArrayPointer(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier) const
|
||||
void MarkMember_ArrayPointer(const StructureInformation* info, const 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()) << ");")
|
||||
LINEF("{0} = {1};", MakeTypeVarName(member->m_member->m_type_declaration->m_type), MakeMemberAccess(info, member, modifier))
|
||||
LINEF("MarkArray_{0}({1});",
|
||||
MakeSafeTypeName(member->m_member->m_type_declaration->m_type),
|
||||
MakeEvaluation(modifier.GetArrayPointerCountEvaluation()))
|
||||
}
|
||||
|
||||
void MarkMember_PointerArray(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier) const
|
||||
void MarkMember_PointerArray(const StructureInformation* info, const MemberInformation* member, const DeclarationModifierComputations& modifier) const
|
||||
{
|
||||
LINE(MakeTypePtrVarName(member->m_member->m_type_declaration->m_type) << " = " << MakeMemberAccess(info, member, modifier) << ";")
|
||||
LINEF("{0} = {1};", MakeTypePtrVarName(member->m_member->m_type_declaration->m_type), MakeMemberAccess(info, member, modifier))
|
||||
if (modifier.IsArray())
|
||||
{
|
||||
LINE("MarkPtrArray_" << MakeSafeTypeName(member->m_member->m_type_declaration->m_type) << "(" << modifier.GetArraySize() << ");")
|
||||
LINEF("MarkPtrArray_{0}({1});", MakeSafeTypeName(member->m_member->m_type_declaration->m_type), modifier.GetArraySize())
|
||||
}
|
||||
else
|
||||
{
|
||||
LINE("MarkPtrArray_" << MakeSafeTypeName(member->m_member->m_type_declaration->m_type) << "("
|
||||
<< MakeEvaluation(modifier.GetPointerArrayCountEvaluation()) << ");")
|
||||
LINEF("MarkPtrArray_{0}({1});",
|
||||
MakeSafeTypeName(member->m_member->m_type_declaration->m_type),
|
||||
MakeEvaluation(modifier.GetPointerArrayCountEvaluation()))
|
||||
}
|
||||
}
|
||||
|
||||
void MarkMember_EmbeddedArray(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier) const
|
||||
void MarkMember_EmbeddedArray(const StructureInformation* info, const MemberInformation* member, const DeclarationModifierComputations& modifier) const
|
||||
{
|
||||
const MemberComputations computations(member);
|
||||
std::string arraySizeStr;
|
||||
|
||||
if (modifier.HasDynamicArrayCount())
|
||||
@ -462,31 +463,31 @@ namespace
|
||||
else
|
||||
arraySizeStr = std::to_string(modifier.GetArraySize());
|
||||
|
||||
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) << "(" << arraySizeStr << ");")
|
||||
LINEF("{0} = {1};", MakeTypeVarName(member->m_member->m_type_declaration->m_type), MakeMemberAccess(info, member, modifier))
|
||||
LINEF("MarkArray_{0}({1});", MakeSafeTypeName(member->m_member->m_type_declaration->m_type), arraySizeStr)
|
||||
}
|
||||
|
||||
void MarkMember_DynamicArray(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier) const
|
||||
void MarkMember_DynamicArray(const StructureInformation* info, const 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()) << ");")
|
||||
LINEF("{0} = {1};", MakeTypeVarName(member->m_member->m_type_declaration->m_type), MakeMemberAccess(info, member, modifier))
|
||||
LINEF(
|
||||
"MarkArray_{0}({1});", MakeSafeTypeName(member->m_member->m_type_declaration->m_type), MakeEvaluation(modifier.GetDynamicArraySizeEvaluation()))
|
||||
}
|
||||
|
||||
void MarkMember_Embedded(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier) const
|
||||
void MarkMember_Embedded(const StructureInformation* info, const MemberInformation* member, const DeclarationModifierComputations& modifier) const
|
||||
{
|
||||
LINE(MakeTypeVarName(member->m_member->m_type_declaration->m_type) << " = &" << MakeMemberAccess(info, member, modifier) << ";")
|
||||
LINE("Mark_" << MakeSafeTypeName(member->m_member->m_type_declaration->m_type) << "();")
|
||||
LINEF("{0} = &{1};", MakeTypeVarName(member->m_member->m_type_declaration->m_type), MakeMemberAccess(info, member, modifier))
|
||||
LINEF("Mark_{0}();", MakeSafeTypeName(member->m_member->m_type_declaration->m_type))
|
||||
}
|
||||
|
||||
void MarkMember_SinglePointer(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier) const
|
||||
void MarkMember_SinglePointer(const StructureInformation* info, const MemberInformation* member, const DeclarationModifierComputations& modifier) const
|
||||
{
|
||||
LINE(MakeTypeVarName(member->m_member->m_type_declaration->m_type) << " = " << MakeMemberAccess(info, member, modifier) << ";")
|
||||
LINE("Mark_" << MakeSafeTypeName(member->m_type->m_definition) << "();")
|
||||
LINEF("{0} = {1};", MakeTypeVarName(member->m_member->m_type_declaration->m_type), MakeMemberAccess(info, member, modifier))
|
||||
LINEF("Mark_{0}();", MakeSafeTypeName(member->m_type->m_definition))
|
||||
}
|
||||
|
||||
void MarkMember_TypeCheck(StructureInformation* info,
|
||||
MemberInformation* member,
|
||||
void MarkMember_TypeCheck(const StructureInformation* info,
|
||||
const MemberInformation* member,
|
||||
const DeclarationModifierComputations& modifier,
|
||||
const MemberLoadType loadType) const
|
||||
{
|
||||
@ -531,16 +532,13 @@ namespace
|
||||
break;
|
||||
|
||||
default:
|
||||
LINE("// t=" << static_cast<int>(loadType))
|
||||
LINEF("// t={0}", static_cast<int>(loadType))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool MarkMember_ShouldMakePointerCheck(StructureInformation* info,
|
||||
MemberInformation* member,
|
||||
const DeclarationModifierComputations& modifier,
|
||||
MemberLoadType loadType)
|
||||
static bool MarkMember_ShouldMakePointerCheck(const MemberInformation* member, const DeclarationModifierComputations& modifier, MemberLoadType loadType)
|
||||
{
|
||||
if (loadType != MemberLoadType::ARRAY_POINTER && loadType != MemberLoadType::POINTER_ARRAY && loadType != MemberLoadType::SINGLE_POINTER)
|
||||
{
|
||||
@ -560,14 +558,14 @@ namespace
|
||||
return true;
|
||||
}
|
||||
|
||||
void MarkMember_PointerCheck(StructureInformation* info,
|
||||
MemberInformation* member,
|
||||
void MarkMember_PointerCheck(const StructureInformation* info,
|
||||
const MemberInformation* member,
|
||||
const DeclarationModifierComputations& modifier,
|
||||
const MemberLoadType loadType)
|
||||
{
|
||||
if (MarkMember_ShouldMakePointerCheck(info, member, modifier, loadType))
|
||||
if (MarkMember_ShouldMakePointerCheck(member, modifier, loadType))
|
||||
{
|
||||
LINE("if (" << MakeMemberAccess(info, member, modifier) << ")")
|
||||
LINEF("if ({0})", MakeMemberAccess(info, member, modifier))
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
@ -582,7 +580,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void MarkMember_ReferenceArray(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier)
|
||||
void MarkMember_ReferenceArray(const StructureInformation* info, const MemberInformation* member, const DeclarationModifierComputations& modifier)
|
||||
{
|
||||
auto first = true;
|
||||
for (const auto& entry : modifier.GetArrayEntries())
|
||||
@ -600,7 +598,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void MarkMember_Reference(StructureInformation* info, MemberInformation* member, const DeclarationModifierComputations& modifier)
|
||||
void MarkMember_Reference(const StructureInformation* info, const MemberInformation* member, const DeclarationModifierComputations& modifier)
|
||||
{
|
||||
if (modifier.IsDynamicArray())
|
||||
{
|
||||
@ -633,16 +631,16 @@ namespace
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
LINE("#error MarkMemberReference failed @ " << member->m_member->m_name)
|
||||
LINEF("#error MarkMemberReference failed @ {0}", member->m_member->m_name)
|
||||
}
|
||||
}
|
||||
|
||||
void MarkMember_Condition_Struct(StructureInformation* info, MemberInformation* member)
|
||||
void MarkMember_Condition_Struct(const StructureInformation* info, const MemberInformation* member)
|
||||
{
|
||||
LINE("")
|
||||
if (member->m_condition)
|
||||
{
|
||||
LINE("if (" << MakeEvaluation(member->m_condition.get()) << ")")
|
||||
LINEF("if ({0})", MakeEvaluation(member->m_condition.get()))
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
@ -657,7 +655,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void MarkMember_Condition_Union(StructureInformation* info, MemberInformation* member)
|
||||
void MarkMember_Condition_Union(const StructureInformation* info, const MemberInformation* member)
|
||||
{
|
||||
const MemberComputations computations(member);
|
||||
|
||||
@ -666,7 +664,7 @@ namespace
|
||||
LINE("")
|
||||
if (member->m_condition)
|
||||
{
|
||||
LINE("if (" << MakeEvaluation(member->m_condition.get()) << ")")
|
||||
LINEF("if ({0})", MakeEvaluation(member->m_condition.get()))
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
@ -684,7 +682,7 @@ namespace
|
||||
{
|
||||
if (member->m_condition)
|
||||
{
|
||||
LINE("else if (" << MakeEvaluation(member->m_condition.get()) << ")")
|
||||
LINEF("else if ({0})", MakeEvaluation(member->m_condition.get()))
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
@ -709,7 +707,7 @@ namespace
|
||||
{
|
||||
if (member->m_condition)
|
||||
{
|
||||
LINE("else if (" << MakeEvaluation(member->m_condition.get()) << ")")
|
||||
LINEF("else if ({0})", MakeEvaluation(member->m_condition.get()))
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
@ -720,12 +718,12 @@ namespace
|
||||
}
|
||||
else
|
||||
{
|
||||
LINE("#error Middle member of union must have condition (" << member->m_member->m_name << ")")
|
||||
LINEF("#error Middle member of union must have condition ({0})", member->m_member->m_name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PrintMarkMemberIfNeedsTreatment(StructureInformation* info, MemberInformation* member)
|
||||
void PrintMarkMemberIfNeedsTreatment(const StructureInformation* info, const MemberInformation* member)
|
||||
{
|
||||
const MemberComputations computations(member);
|
||||
if (computations.ShouldIgnore() || computations.IsInRuntimeBlock())
|
||||
@ -741,14 +739,13 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void PrintMarkMethod(StructureInformation* info)
|
||||
void PrintMarkMethod(const StructureInformation* info)
|
||||
{
|
||||
const StructureComputations computations(info);
|
||||
LINE("void " << MarkerClassName(m_env.m_asset) << "::Mark_" << info->m_definition->m_name << "()")
|
||||
LINEF("void {0}::Mark_{1}()", MarkerClassName(m_env.m_asset), info->m_definition->m_name)
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
LINE("assert(" << MakeTypeVarName(info->m_definition) << " != nullptr);")
|
||||
LINEF("assert({0} != nullptr);", MakeTypeVarName(info->m_definition))
|
||||
|
||||
for (const auto& member : info->m_ordered_members)
|
||||
{
|
||||
@ -761,7 +758,7 @@ namespace
|
||||
|
||||
void PrintGetNameMethod()
|
||||
{
|
||||
LINE("std::string " << MarkerClassName(m_env.m_asset) << "::GetAssetName(" << m_env.m_asset->m_definition->GetFullName() << "* pAsset)")
|
||||
LINEF("std::string {0}::GetAssetName({1}* pAsset)", MarkerClassName(m_env.m_asset), m_env.m_asset->m_definition->GetFullName())
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
@ -775,18 +772,18 @@ namespace
|
||||
if (first)
|
||||
{
|
||||
first = false;
|
||||
LINE_MIDDLE("->" << member->m_member->m_name)
|
||||
LINE_MIDDLEF("->{0}", member->m_member->m_name)
|
||||
}
|
||||
else
|
||||
{
|
||||
LINE_MIDDLE("." << member->m_member->m_name)
|
||||
LINE_MIDDLEF(".{0}", member->m_member->m_name)
|
||||
}
|
||||
}
|
||||
LINE_END(";")
|
||||
}
|
||||
else
|
||||
{
|
||||
LINE("return \"" << m_env.m_asset->m_definition->m_name << "\";")
|
||||
LINEF("return \"{0}\";", m_env.m_asset->m_definition->m_name)
|
||||
}
|
||||
|
||||
m_intendation--;
|
||||
@ -795,12 +792,11 @@ namespace
|
||||
|
||||
void PrintGetAssetInfoMethod()
|
||||
{
|
||||
LINE("XAssetInfo<" << m_env.m_asset->m_definition->GetFullName() << ">* " << MarkerClassName(m_env.m_asset) << "::GetAssetInfo("
|
||||
<< m_env.m_asset->m_definition->GetFullName() << "* pAsset) const")
|
||||
LINEF("XAssetInfo<{0}>* {1}::GetAssetInfo({0}* pAsset) const", m_env.m_asset->m_definition->GetFullName(), MarkerClassName(m_env.m_asset))
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
LINE("return reinterpret_cast<XAssetInfo<" << m_env.m_asset->m_definition->GetFullName() << ">*>(GetAssetInfoByName(GetAssetName(pAsset)));")
|
||||
LINEF("return reinterpret_cast<XAssetInfo<{0}>*>(GetAssetInfoByName(GetAssetName(pAsset)));", m_env.m_asset->m_definition->GetFullName())
|
||||
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
@ -808,14 +804,14 @@ namespace
|
||||
|
||||
void PrintMainMarkMethod()
|
||||
{
|
||||
LINE("void " << MarkerClassName(m_env.m_asset) << "::Mark(" << m_env.m_asset->m_definition->GetFullName() << "* pAsset)")
|
||||
LINEF("void {0}::Mark({1}* pAsset)", MarkerClassName(m_env.m_asset), m_env.m_asset->m_definition->GetFullName())
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
LINE("assert(pAsset != nullptr);")
|
||||
LINE("")
|
||||
LINE(MakeTypeVarName(m_env.m_asset->m_definition) << " = pAsset;")
|
||||
LINE("Mark_" << MakeSafeTypeName(m_env.m_asset->m_definition) << "();")
|
||||
LINEF("{0} = pAsset;", MakeTypeVarName(m_env.m_asset->m_definition))
|
||||
LINEF("Mark_{0}();", MakeSafeTypeName(m_env.m_asset->m_definition))
|
||||
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
@ -830,17 +826,8 @@ std::vector<CodeTemplateFile> ZoneMarkTemplate::GetFilesToRender(RenderingContex
|
||||
auto assetName = context->m_asset->m_definition->m_name;
|
||||
utils::MakeStringLowerCase(assetName);
|
||||
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << assetName << '/' << assetName << "_mark_db.h";
|
||||
files.emplace_back(str.str(), TAG_HEADER);
|
||||
}
|
||||
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << assetName << '/' << assetName << "_mark_db.cpp";
|
||||
files.emplace_back(str.str(), TAG_SOURCE);
|
||||
}
|
||||
files.emplace_back(std::format("{0}/{0}_mark_db.h", assetName), TAG_HEADER);
|
||||
files.emplace_back(std::format("{0}/{0}_mark_db.cpp", assetName), TAG_SOURCE);
|
||||
|
||||
return files;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user