From 446c38d8eecc1fd22ea6aa8930d9a8f0864a112e Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Fri, 2 May 2025 15:59:30 +0200 Subject: [PATCH] refactor: reorder members of zcg generated classes --- .../Generating/Templates/ZoneLoadTemplate.cpp | 66 ++++++++++--------- .../Generating/Templates/ZoneMarkTemplate.cpp | 59 +++++++++-------- .../Templates/ZoneWriteTemplate.cpp | 65 +++++++++--------- 3 files changed, 101 insertions(+), 89 deletions(-) diff --git a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneLoadTemplate.cpp b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneLoadTemplate.cpp index b43afe2c..2520d5bf 100644 --- a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneLoadTemplate.cpp +++ b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneLoadTemplate.cpp @@ -47,32 +47,16 @@ namespace LINE("{") m_intendation++; - LINEF("XAssetInfo<{0}>* m_asset_info;", m_env.m_asset->m_definition->GetFullName()) - if (m_env.m_has_actions) - { - LINEF("Actions_{0} m_actions;", m_env.m_asset->m_definition->m_name) - } - LINE(VariableDecl(m_env.m_asset->m_definition)) - LINE(PointerVariableDecl(m_env.m_asset->m_definition)) - LINE("") - - // Variable Declarations: type varType; - 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 (const auto* type : m_env.m_used_types) - { - if (type->m_pointer_array_reference_exists && !type->m_is_context_asset) - { - LINE(PointerVariableDecl(type->m_type)) - } - } + m_intendation--; + LINE("public:") + m_intendation++; + PrintHeaderConstructor(); + PrintHeaderMainLoadMethodDeclaration(m_env.m_asset); LINE("") + m_intendation--; + LINE("private:") + m_intendation++; // Method Declarations for (const auto* type : m_env.m_used_types) @@ -100,11 +84,31 @@ namespace PrintHeaderTempPtrLoadMethodDeclaration(m_env.m_asset); PrintHeaderAssetLoadMethodDeclaration(m_env.m_asset); LINE("") - m_intendation--; - LINE("public:") - m_intendation++; - PrintHeaderConstructor(); - PrintHeaderMainLoadMethodDeclaration(m_env.m_asset); + + LINEF("XAssetInfo<{0}>* m_asset_info;", m_env.m_asset->m_definition->GetFullName()) + if (m_env.m_has_actions) + { + LINEF("Actions_{0} m_actions;", m_env.m_asset->m_definition->m_name) + } + LINE(VariableDecl(m_env.m_asset->m_definition)) + LINE(PointerVariableDecl(m_env.m_asset->m_definition)) + LINE("") + + // Variable Declarations: type varType; + 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 (const auto* type : m_env.m_used_types) + { + if (type->m_pointer_array_reference_exists && !type->m_is_context_asset) + { + LINE(PointerVariableDecl(type->m_type)) + } + } m_intendation--; LINE("};") @@ -142,6 +146,8 @@ namespace LINEF("using namespace {0};", m_env.m_game) LINE("") PrintConstructorMethod(); + LINE("") + PrintMainLoadMethod(); for (const auto* type : m_env.m_used_types) { @@ -173,8 +179,6 @@ namespace PrintLoadPtrMethod(m_env.m_asset); LINE("") PrintLoadAssetMethod(m_env.m_asset); - LINE("") - PrintMainLoadMethod(); } private: diff --git a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneMarkTemplate.cpp b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneMarkTemplate.cpp index 9c8cabe7..f3426a67 100644 --- a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneMarkTemplate.cpp +++ b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneMarkTemplate.cpp @@ -43,32 +43,18 @@ namespace 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 (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 (const auto* type : m_env.m_used_types) - { - if (type->m_pointer_array_reference_exists && !type->m_is_context_asset) - { - LINE(PointerVariableDecl(type->m_type)) - } - } - + PrintHeaderConstructor(); + PrintHeaderMainMarkMethodDeclaration(m_env.m_asset); + PrintHeaderGetAssetInfoMethodDeclaration(m_env.m_asset); LINE("") + m_intendation--; + LINE("private:") + m_intendation++; + // Method Declarations for (const auto* type : m_env.m_used_types) { @@ -94,11 +80,28 @@ namespace } } PrintHeaderMarkMethodDeclaration(m_env.m_asset); + LINE("") - PrintHeaderGetAssetInfoMethodDeclaration(m_env.m_asset); + + LINE(VariableDecl(m_env.m_asset->m_definition)) + LINE(PointerVariableDecl(m_env.m_asset->m_definition)) LINE("") - PrintHeaderConstructor(); - PrintHeaderMainMarkMethodDeclaration(m_env.m_asset); + + // Variable Declarations: type varType; + 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 (const auto* type : m_env.m_used_types) + { + if (type->m_pointer_array_reference_exists && !type->m_is_context_asset) + { + LINE(PointerVariableDecl(type->m_type)) + } + } m_intendation--; LINE("};") @@ -131,6 +134,10 @@ namespace LINEF("using namespace {0};", m_env.m_game) LINE("") PrintConstructorMethod(); + LINE("") + PrintMainMarkMethod(); + LINE("") + PrintGetAssetInfoMethod(); for (const auto* type : m_env.m_used_types) { @@ -160,10 +167,6 @@ namespace } LINE("") PrintMarkMethod(m_env.m_asset); - LINE("") - PrintMainMarkMethod(); - LINE("") - PrintGetAssetInfoMethod(); } private: diff --git a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneWriteTemplate.cpp b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneWriteTemplate.cpp index e929d611..44c5a98c 100644 --- a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneWriteTemplate.cpp +++ b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneWriteTemplate.cpp @@ -42,31 +42,16 @@ namespace 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 (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)) - LINE(WrittenVariableDecl(type->m_type)) - } - } - for (const 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)) - } - } + m_intendation--; + LINE("public:") + m_intendation++; + PrintHeaderConstructor(); + PrintHeaderMainWriteMethodDeclaration(m_env.m_asset); LINE("") + m_intendation--; + LINE("private:") + m_intendation++; // Method Declarations for (const auto* type : m_env.m_used_types) @@ -92,12 +77,32 @@ namespace } PrintHeaderWriteMethodDeclaration(m_env.m_asset); PrintHeaderTempPtrWriteMethodDeclaration(m_env.m_asset); + LINE("") - m_intendation--; - LINE("public:") - m_intendation++; - PrintHeaderConstructor(); - PrintHeaderMainWriteMethodDeclaration(m_env.m_asset); + + 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 (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)) + LINE(WrittenVariableDecl(type->m_type)) + } + } + for (const 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)) + } + } m_intendation--; LINE("};") @@ -131,6 +136,8 @@ namespace LINEF("using namespace {0};", m_env.m_game) LINE("") PrintConstructorMethod(); + LINE("") + PrintMainWriteMethod(); for (const auto* type : m_env.m_used_types) { @@ -160,8 +167,6 @@ namespace PrintWriteMethod(m_env.m_asset); LINE("") PrintWritePtrMethod(m_env.m_asset); - LINE("") - PrintMainWriteMethod(); } private: