From 62b0ed21127b38c6d90d5055e1139ae256af34cd Mon Sep 17 00:00:00 2001 From: Ed_ Date: Tue, 25 Jul 2023 15:12:51 -0400 Subject: [PATCH] Finished initial implmentation bootstrap generation and singleheader implementation. --- .gitignore | 2 + .vscode/launch.json | 9 ++ Readme.md | 4 +- project/components/AttributeTokens.csv | 0 project/components/ECode.csv | 0 project/components/EOperator.csv | 0 project/components/ESpecifier.csv | 0 project/components/ETokType.csv | 0 project/components/gen.header_end.hpp | 2 +- project/components/gen.header_start.hpp | 2 +- project/components/gen.impl_start.cpp | 9 ++ project/dependencies/gen.dep.cpp | 19 --- project/dependencies/gen.dep.hpp | 20 --- project/dependencies/gen.header_start.hpp | 8 -- project/dependencies/gen.printing.hpp | 2 +- project/filesystem/gen.scanner.hpp | 2 +- project/gen.bootstrap.cpp | 127 +++++++++++++++-- project/gen.cpp | 5 +- project/gen.dep.cpp | 19 +++ project/gen.dep.hpp | 28 ++++ project/gen.hpp | 8 ++ scripts/bootstrap.ci.ps1 | 4 +- scripts/clean.ps1 | 8 +- scripts/singleheader.ci.ps1 | 6 +- singleheader/components/gen.header_start.hpp | 5 +- singleheader/gen.singleheader.cpp | 142 ++++++++++++++++--- 26 files changed, 336 insertions(+), 95 deletions(-) create mode 100644 project/components/AttributeTokens.csv create mode 100644 project/components/ECode.csv create mode 100644 project/components/EOperator.csv create mode 100644 project/components/ESpecifier.csv create mode 100644 project/components/ETokType.csv create mode 100644 project/components/gen.impl_start.cpp delete mode 100644 project/dependencies/gen.dep.cpp delete mode 100644 project/dependencies/gen.dep.hpp create mode 100644 project/gen.dep.cpp create mode 100644 project/gen.dep.hpp diff --git a/.gitignore b/.gitignore index c52c02d..c095119 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ build/* **/*.gen.* **/gen/gen.hpp **/gen/gen.cpp +**/gen/gen_dep.hpp +**/gen/gen_dep.cpp gencpp.hpp gencpp.cpp diff --git a/.vscode/launch.json b/.vscode/launch.json index 7b1d7c6..73b31b1 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -31,6 +31,15 @@ "args": [], "cwd": "${workspaceFolder}/project/", "visualizerFile": "${workspaceFolder}/scripts/gencpp.natvis" + }, + { + "type": "cppvsdbg", + "request": "launch", + "name": "Debug singleheader vsdbg", + "program": "${workspaceFolder}/singleheader/build/gencpp_singleheader.exe", + "args": [], + "cwd": "${workspaceFolder}/singleheader/", + "visualizerFile": "${workspaceFolder}/scripts/gencpp.natvis" } ] } diff --git a/Readme.md b/Readme.md index 3fc44da..8ac04ac 100644 --- a/Readme.md +++ b/Readme.md @@ -171,8 +171,8 @@ An example of building is provided within project, singleheader, and test. **Project** -`gen.bootstrap.cpp` generates a segmented version of the library following a more traditional cpp convention. -With the exception that: *The component hpp and cpp files are all included into their respective header and source* +`gen.bootstrap.cpp` generates a segmented version of the library where code is divided into `gen.hpp`, `gen.cpp`, `gen_dep.hpp`, and `gen_dep.cpp`. +(Similar whats there already, but with the includes injected) **Singleheader** diff --git a/project/components/AttributeTokens.csv b/project/components/AttributeTokens.csv new file mode 100644 index 0000000..e69de29 diff --git a/project/components/ECode.csv b/project/components/ECode.csv new file mode 100644 index 0000000..e69de29 diff --git a/project/components/EOperator.csv b/project/components/EOperator.csv new file mode 100644 index 0000000..e69de29 diff --git a/project/components/ESpecifier.csv b/project/components/ESpecifier.csv new file mode 100644 index 0000000..e69de29 diff --git a/project/components/ETokType.csv b/project/components/ETokType.csv new file mode 100644 index 0000000..e69de29 diff --git a/project/components/gen.header_end.hpp b/project/components/gen.header_end.hpp index 5b616c6..ac408f9 100644 --- a/project/components/gen.header_end.hpp +++ b/project/components/gen.header_end.hpp @@ -402,7 +402,7 @@ StrC token_fmt_impl( sw num, ... ) # define GEN_MAX_NAME_LENGTH 128 #endif #ifndef GEN_MAX_UNTYPED_STR_LENGTH -# define GEN_MAX_UNTYPED_STR_LENGTH kilobytes(640) +# define GEN_MAX_UNTYPED_STR_LENGTH megabytes(1) #endif #ifndef GEN_TOKEN_FMT_TOKEN_MAP_MEM_SIZE # define GEN_TOKEN_FMT_TOKEN_MAP_MEM_SIZE kilobytes(4) diff --git a/project/components/gen.header_start.hpp b/project/components/gen.header_start.hpp index 4639849..42e210e 100644 --- a/project/components/gen.header_start.hpp +++ b/project/components/gen.header_start.hpp @@ -13,5 +13,5 @@ //! If its desired to roll your own dependencies, define GEN_ROLL_OWN_DEPENDENCIES before including this file. // Dependencies are derived from the c-zpl library: https://github.com/zpl-c/zpl #ifndef GEN_ROLL_OWN_DEPENDENCIES -# include "dependencies/gen.dep.hpp" +# include "gen.dep.hpp" #endif diff --git a/project/components/gen.impl_start.cpp b/project/components/gen.impl_start.cpp new file mode 100644 index 0000000..51b55e2 --- /dev/null +++ b/project/components/gen.impl_start.cpp @@ -0,0 +1,9 @@ +#if ! defined(GEN_DONT_ENFORCE_GEN_TIME_GUARD) && ! defined(GEN_TIME) +# error Gen.hpp : GEN_TIME not defined +#endif + +//! If its desired to roll your own dependencies, define GEN_ROLL_OWN_DEPENDENCIES before including this file. +//! Dependencies are derived from the c-zpl library: https://github.com/zpl-c/zpl +#ifndef GEN_ROLL_OWN_DEPENDENCIES +# include "gen.dep.cpp" +#endif diff --git a/project/dependencies/gen.dep.cpp b/project/dependencies/gen.dep.cpp deleted file mode 100644 index b084629..0000000 --- a/project/dependencies/gen.dep.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// This file is intended to be included within gen.cpp (There is no pragma diagnostic ignores) -#include "gen.dep.hpp" - -#include "gen.impl_start.cpp" - -GEN_NS_BEGIN - -#include "gen.debug.cpp" -#include "gen.string_ops.cpp" -#include "gen.printing.cpp" -#include "gen.memory.cpp" -#include "gen.parsing.cpp" -#include "gen.hashing.cpp" -#include "gen.string.cpp" -#include "gen.timing.cpp" - -#include "gen.file_handling.cpp" - -GEN_NS_END diff --git a/project/dependencies/gen.dep.hpp b/project/dependencies/gen.dep.hpp deleted file mode 100644 index b750b47..0000000 --- a/project/dependencies/gen.dep.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// This file is intended to be included within gen.hpp (There is no pragma diagnostic ignores) -#pragma once - -#include "gen.header_start.hpp" - -GEN_NS_BEGIN - -#include "gen.macros.hpp" -#include "gen.basic_types.hpp" -#include "gen.debug.hpp" -#include "gen.memory.hpp" -#include "gen.string_ops.hpp" -#include "gen.printing.hpp" -#include "gen.containers.hpp" -#include "gen.string.hpp" -#include "gen.file_handling.hpp" -#include "gen.parsing.hpp" -#include "gen.timing.hpp" - -GEN_NS_END diff --git a/project/dependencies/gen.header_start.hpp b/project/dependencies/gen.header_start.hpp index a09facf..138d8fc 100644 --- a/project/dependencies/gen.header_start.hpp +++ b/project/dependencies/gen.header_start.hpp @@ -129,11 +129,3 @@ # include # endif #pragma endregion Mandatory Includes - -#ifdef GEN_DONT_USE_NAMESPACE -# define GEN_NS_BEGIN -# define GEN_NS_END -#else -# define GEN_NS_BEGIN namespace gen { -# define GEN_NS_END } -#endif diff --git a/project/dependencies/gen.printing.hpp b/project/dependencies/gen.printing.hpp index dd632b6..c27c34a 100644 --- a/project/dependencies/gen.printing.hpp +++ b/project/dependencies/gen.printing.hpp @@ -1,7 +1,7 @@ struct FileInfo; #ifndef GEN_PRINTF_MAXLEN -# define GEN_PRINTF_MAXLEN 65536 +# define GEN_PRINTF_MAXLEN kilobytes(128) #endif // NOTE: A locally persisting buffer is used internally diff --git a/project/filesystem/gen.scanner.hpp b/project/filesystem/gen.scanner.hpp index 342f062..e454aa0 100644 --- a/project/filesystem/gen.scanner.hpp +++ b/project/filesystem/gen.scanner.hpp @@ -10,7 +10,7 @@ Code scan_file( char const* path ) FileError error = file_open_mode( & file, EFileMode_READ, path ); if ( error != EFileError_NONE ) { - fatal( "scan_file: Could not open genc.macro.h: %s", path ); + fatal( "scan_file: Could not open: %s", path ); } sw fsize = file_size( & file ); diff --git a/project/gen.bootstrap.cpp b/project/gen.bootstrap.cpp index aa9688c..f045f56 100644 --- a/project/gen.bootstrap.cpp +++ b/project/gen.bootstrap.cpp @@ -35,36 +35,135 @@ int gen_main() Code push_ignores = scan_file( "helpers/gen.push_ignores.inline.hpp" ); Code pop_ignores = scan_file( "helpers/gen.pop_ignores.inline.hpp" ); - Builder gen_deps_header; + // gen_dep.hpp { + Code header_start = scan_file( "dependencies/gen.header_start.hpp" ); + Code nspace_macro = untyped_str( namespace_by_default ? nspace_default : nspace_non_default ); + Code macros = scan_file( "dependencies/gen.macros.hpp" ); + Code basic_types = scan_file( "dependencies/gen.basic_types.hpp" ); + Code debug = scan_file( "dependencies/gen.debug.hpp" ); + Code memory = scan_file( "dependencies/gen.memory.hpp" ); + Code string_ops = scan_file( "dependencies/gen.string_ops.hpp" ); + Code printing = scan_file( "dependencies/gen.printing.hpp" ); + Code containers = scan_file( "dependencies/gen.containers.hpp" ); + Code string = scan_file( "dependencies/gen.string.hpp" ); + Code file_handling = scan_file( "dependencies/gen.file_handling.hpp" ); + Code parsing = scan_file( "dependencies/gen.parsing.hpp" ); + Code timing = scan_file( "dependencies/gen.timing.hpp" ); + Builder + deps_header; + deps_header.open("gen/gen_dep.hpp"); + deps_header.print_fmt("// This file is intended to be included within gen.cpp (There is no pragma diagnostic ignores)\n\n"); + deps_header.print_fmt("#pragma once\n\n"); + deps_header.print( push_ignores ); + deps_header.print( header_start ); + deps_header.print( nspace_macro ); + deps_header.print_fmt( "GEN_NS_BEGIN\n\n"); + deps_header.print( macros ); + deps_header.print( basic_types ); + deps_header.print( debug ); + deps_header.print( memory ); + deps_header.print( string_ops ); + deps_header.print( printing ); + deps_header.print( containers ); + deps_header.print( string ); + deps_header.print( file_handling ); + deps_header.print( parsing ); + deps_header.print( timing ); + deps_header.print_fmt( "GEN_NS_END\n\n"); + deps_header.print( pop_ignores ); + deps_header.write(); } - Builder gen_deps_impl; + // gen_dep.cpp { + CodeInclude header = def_include( txt_StrC("gen_dep.hpp") ); + Code impl_start = scan_file( "dependencies/gen.impl_start.cpp" ); + Code debug = scan_file( "dependencies/gen.debug.cpp" ); + Code string_ops = scan_file( "dependencies/gen.string_ops.cpp" ); + Code printing = scan_file( "dependencies/gen.printing.cpp" ); + Code memory = scan_file( "dependencies/gen.memory.cpp" ); + Code parsing = scan_file( "dependencies/gen.parsing.cpp" ); + Code hashing = scan_file( "dependencies/gen.hashing.cpp" ); + Code string = scan_file( "dependencies/gen.string.cpp" ); + Code timing = scan_file( "dependencies/gen.timing.cpp" ); + Builder + deps_impl; + deps_impl.open("gen/gen_dep.cpp"); + deps_impl.print_fmt("// This file is intended to be included within gen.cpp (There is no pragma diagnostic ignores)\n\n"); + deps_impl.print( impl_start ); + deps_impl.print( header ); + deps_impl.print_fmt( "\nGEN_NS_BEGIN\n"); + deps_impl.print( debug ); + deps_impl.print( string_ops ); + deps_impl.print( printing ); + deps_impl.print( memory ); + deps_impl.print( parsing ); + deps_impl.print( string ); + deps_impl.print( timing ); + deps_impl.print_fmt( "GEN_NS_END\n\n"); + deps_impl.write(); } - Builder gen_header; + // gen.hpp { Code header_start = scan_file( "components/gen.header_start.hpp" ); Code nspace_macro = untyped_str( namespace_by_default ? nspace_default : nspace_non_default ); + Code types = scan_file( "components/gen.types.hpp" ); + Code data_structs = scan_file( "components/gen.data_structures.hpp" ); + Code interface = scan_file( "components/gen.interface.hpp" ); + Code header_end = scan_file( "components/gen.header_end.hpp" ); - gen_header.open( "gen/gen.hpp" ); - gen_header.print_fmt("#pragma once\n\n"); - gen_header.print( push_ignores ); - gen_header.print( header_start ); - gen_header.print( nspace_macro ); - gen_header.print_fmt( "GEN_NS_BEGIN\n"); - - gen_header.print_fmt( "\nGEN_NS_END\n\n"); - gen_header.print( pop_ignores ); - gen_header.write(); + Builder + header; + header.open( "gen/gen.hpp" ); + header.print_fmt("#pragma once\n\n"); + header.print( push_ignores ); + header.print( header_start ); + header.print( nspace_macro ); + header.print_fmt( "GEN_NS_BEGIN\n\n"); + header.print( types ); + header.print( data_structs ); + header.print( interface ); + header.print( header_end ); + header.print_fmt( "GEN_NS_END\n\n"); + header.print( pop_ignores ); + header.write(); } - Builder gen_impl; + // gen.cpp { + Code impl_start = scan_file( "components/gen.impl_start.cpp" ); + CodeInclude header = def_include( txt_StrC("gen.hpp") ); + Code data = scan_file( "components/gen.data.cpp" ); + Code ast_case_macros = scan_file( "components/gen.ast_case_macros.cpp" ); + Code ast = scan_file( "components/gen.ast.cpp" ); + Code interface = scan_file( "components/gen.interface.cpp" ); + Code upfront = scan_file( "components/gen.interface.upfront.cpp" ); + Code parsing = scan_file( "components/gen.interface.parsing.cpp" ); + Code untyped = scan_file( "components/gen.untyped.cpp" ); + Code builder = scan_file( "filesystem/gen.builder.cpp" ); + + Builder + impl; + impl.open( "gen/gen.cpp" ); + impl.print( push_ignores ); + impl.print( impl_start ); + impl.print( header ); + impl.print_fmt( "\nGEN_NS_BEGIN\n\n"); + impl.print( data ); + impl.print( ast_case_macros ); + impl.print( ast ); + impl.print( interface ); + impl.print( upfront ); + impl.print( parsing ); + impl.print( untyped ); + impl.print_fmt( "GEN_NS_END\n\n"); + impl.print( pop_ignores ); + impl.write(); } gen::deinit(); diff --git a/project/gen.cpp b/project/gen.cpp index bd3aead..75f9608 100644 --- a/project/gen.cpp +++ b/project/gen.cpp @@ -3,14 +3,13 @@ // ReSharper disable CppClangTidyClangDiagnosticSwitchEnum #if ! defined(GEN_DONT_ENFORCE_GEN_TIME_GUARD) && ! defined(GEN_TIME) -#error Gen.hpp : GEN_TIME not defined +# error Gen.hpp : GEN_TIME not defined #endif - //! If its desired to roll your own dependencies, define GEN_ROLL_OWN_DEPENDENCIES before including this file. //! Dependencies are derived from the c-zpl library: https://github.com/zpl-c/zpl #ifndef GEN_ROLL_OWN_DEPENDENCIES -# include "dependencies/gen.dep.cpp" +# include "gen.dep.cpp" #endif #include "gen.hpp" diff --git a/project/gen.dep.cpp b/project/gen.dep.cpp new file mode 100644 index 0000000..a7589b7 --- /dev/null +++ b/project/gen.dep.cpp @@ -0,0 +1,19 @@ +// This file is intended to be included within gen.cpp (There is no pragma diagnostic ignores) +#include "gen.dep.hpp" + +#include "dependencies/gen.impl_start.cpp" + +GEN_NS_BEGIN + +#include "dependencies/gen.debug.cpp" +#include "dependencies/gen.string_ops.cpp" +#include "dependencies/gen.printing.cpp" +#include "dependencies/gen.memory.cpp" +#include "dependencies/gen.parsing.cpp" +#include "dependencies/gen.hashing.cpp" +#include "dependencies/gen.string.cpp" +#include "dependencies/gen.timing.cpp" + +#include "dependencies/gen.file_handling.cpp" + +GEN_NS_END diff --git a/project/gen.dep.hpp b/project/gen.dep.hpp new file mode 100644 index 0000000..b6d6303 --- /dev/null +++ b/project/gen.dep.hpp @@ -0,0 +1,28 @@ +// This file is intended to be included within gen.hpp (There is no pragma diagnostic ignores) +#pragma once + +#include "dependencies/gen.header_start.hpp" + +#ifdef GEN_DONT_USE_NAMESPACE +# define GEN_NS_BEGIN +# define GEN_NS_END +#else +# define GEN_NS_BEGIN namespace gen { +# define GEN_NS_END } +#endif + +GEN_NS_BEGIN + +#include "dependencies/gen.macros.hpp" +#include "dependencies/gen.basic_types.hpp" +#include "dependencies/gen.debug.hpp" +#include "dependencies/gen.memory.hpp" +#include "dependencies/gen.string_ops.hpp" +#include "dependencies/gen.printing.hpp" +#include "dependencies/gen.containers.hpp" +#include "dependencies/gen.string.hpp" +#include "dependencies/gen.file_handling.hpp" +#include "dependencies/gen.parsing.hpp" +#include "dependencies/gen.timing.hpp" + +GEN_NS_END diff --git a/project/gen.hpp b/project/gen.hpp index 158f9f9..8d553f9 100644 --- a/project/gen.hpp +++ b/project/gen.hpp @@ -11,6 +11,14 @@ #include "helpers/gen.push_ignores.inline.hpp" #include "components/gen.header_start.hpp" +#ifdef GEN_DONT_USE_NAMESPACE +# define GEN_NS_BEGIN +# define GEN_NS_END +#else +# define GEN_NS_BEGIN namespace gen { +# define GEN_NS_END } +#endif + GEN_NS_BEGIN #include "components/gen.types.hpp" diff --git a/scripts/bootstrap.ci.ps1 b/scripts/bootstrap.ci.ps1 index 8a3158a..d75ff42 100644 --- a/scripts/bootstrap.ci.ps1 +++ b/scripts/bootstrap.ci.ps1 @@ -60,10 +60,10 @@ $formatParams = @( '-verbose' ) -$include = @('gencpp.hpp', 'gencpp.cpp') +$include = @('gen.hpp', 'gen.cpp', 'gen_dep.hpp', 'gen_dep.cpp') $exclude = $null -$targetFiles = @(Get-ChildItem -Recurse -Path $path_project -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName) +$targetFiles = @(Get-ChildItem -Recurse -Path $path_project_gen -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName) clang-format $formatParams $targetFiles Write-Host "`nFormatting complete" diff --git a/scripts/clean.ps1 b/scripts/clean.ps1 index c49abf5..758ba53 100644 --- a/scripts/clean.ps1 +++ b/scripts/clean.ps1 @@ -9,6 +9,7 @@ $path_project_build = Join-Path $path_project build $path_singleheader_build = Join-Path $path_singleheader build $path_project_gen = Join-Path $path_project gen $path_singleheader_gen = Join-Path $path_singleheader gen +$path_x64 = Join-Path $path_root x64 if ( Test-Path $path_project_build) { @@ -30,7 +31,12 @@ if ( Test-Path $path_gen_build ) Remove-Item $path_gen_build -Recurse } -[string[]] $include = 'gen.hpp', 'gen.cpp' +if ( Test-Path $path_x64) +{ + Remove-Item $path_x64 -Recurse +} + +[string[]] $include = 'gen.hpp', 'gen.cpp', 'gen_dep.hpp', 'gen_dep.cpp' [string[]] $exclude = $files = Get-ChildItem -Recurse -Path $path_project_gen -Include $include -Exclude $exclude diff --git a/scripts/singleheader.ci.ps1 b/scripts/singleheader.ci.ps1 index a9a042e..0f84a66 100644 --- a/scripts/singleheader.ci.ps1 +++ b/scripts/singleheader.ci.ps1 @@ -18,7 +18,7 @@ $path_singleheader = Join-Path $path_root singleheader $path_singleheader_build = Join-Path $path_singleheader build $path_singleheader_gen = Join-Path $path_singleheader gen -write-host "`n`nBuilding gencpp bootstrap`n" +write-host "`n`nBuilding gencpp singleheader`n" if ( -not( Test-Path $path_singleheader_build) ) { @@ -49,7 +49,7 @@ if ( -not(Test-Path($path_singleheader_gen) )) { # Run meta-program $gencpp_singleheader = Join-Path $path_singleheader_build gencpp_singleheader.exe -Write-Host `nRunning gencpp bootstrap... +Write-Host `nRunning gencpp singleheader... & $gencpp_singleheader # Format generated files @@ -60,7 +60,7 @@ $formatParams = @( '-verbose' ) -$include = @('gencpp.hpp') +$include = @('gen.hpp') $exclude = $null $targetFiles = @(Get-ChildItem -Recurse -Path $path_project -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName) diff --git a/singleheader/components/gen.header_start.hpp b/singleheader/components/gen.header_start.hpp index 3c607b6..7a21966 100644 --- a/singleheader/components/gen.header_start.hpp +++ b/singleheader/components/gen.header_start.hpp @@ -5,7 +5,10 @@ Public Address: https://github.com/Ed94/gencpp + + This is a single header variant of the library. + Define GEN_IMPLEMENTATION before including this file in a single compilation unit. */ #if ! defined(GEN_DONT_ENFORCE_GEN_TIME_GUARD) && ! defined(GEN_TIME) # error Gen.hpp : GEN_TIME not defined -#endif +#endif \ No newline at end of file diff --git a/singleheader/gen.singleheader.cpp b/singleheader/gen.singleheader.cpp index 0967a6c..55b3182 100644 --- a/singleheader/gen.singleheader.cpp +++ b/singleheader/gen.singleheader.cpp @@ -28,49 +28,155 @@ constexpr StrC nspace_non_default = txt_StrC(R"( #endif )"); -constexpr StrC gen_implementation_guard = txt_StrC(R"( +constexpr StrC implementation_guard_start = txt_StrC(R"( #pragma region GENCPP IMPLEMENTATION GUARD #if ! defined(GEN_IMPLEMENTATION) # define GEN_IMPLEMENTATION )"); -constexpr StrC gen_implementation_end = txt_StrC(R"( +constexpr StrC implementation_guard_end = txt_StrC(R"( #endif #pragma endregion GENCPP IMPLEMENTATION GUARD )"); +constexpr StrC roll_own_dependencies_guard_start = txt_StrC(R"( +//! If its desired to roll your own dependencies, define GEN_ROLL_OWN_DEPENDENCIES before including this file. +// Dependencies are derived from the c-zpl library: https://github.com/zpl-c/zpl +#ifndef GEN_ROLL_OWN_DEPENDENCIES + +)"); + +constexpr StrC roll_own_dependencies_guard_end = txt_StrC(R"( +// GEN_ROLL_OWN_DEPENDENCIES +#endif + +)"); + int gen_main() { gen::init(); - Code push_ignores = scan_file( "../project/helpers/gen.push_ignores.inline.hpp" ); - Code pop_ignores = scan_file( "../project/helpers/gen.pop_ignores.inline.hpp" ); +#define project_dir "../project/" + + Code push_ignores = scan_file( project_dir "helpers/gen.push_ignores.inline.hpp" ); + Code pop_ignores = scan_file( project_dir "helpers/gen.pop_ignores.inline.hpp" ); Code header_start = scan_file( "components/gen.header_start.hpp" ); Code nspace_macro = untyped_str( namespace_by_default ? nspace_default : nspace_non_default ); - Builder gen_header; - gen_header.open( "gen/gen.hpp" ); - gen_header.print( push_ignores ); + Builder + header; + header.open( "gen/gen.hpp" ); + header.print( push_ignores ); + + header.print_fmt("#pragma once\n\n"); // Headers - gen_header.print_fmt("#pragma once\n\n"); - gen_header.print( header_start ); - gen_header.print( nspace_macro ); - gen_header.print_fmt( "GEN_NS_BEGIN\n"); + { + header.print( header_start ); + header.print( nspace_macro ); - gen_header.print_fmt( "\nGEN_NS_END\n"); + { + header.print_fmt( roll_own_dependencies_guard_start ); + + Code header_start = scan_file( project_dir "dependencies/gen.header_start.hpp" ); + Code macros = scan_file( project_dir "dependencies/gen.macros.hpp" ); + Code basic_types = scan_file( project_dir "dependencies/gen.basic_types.hpp" ); + Code debug = scan_file( project_dir "dependencies/gen.debug.hpp" ); + Code memory = scan_file( project_dir "dependencies/gen.memory.hpp" ); + Code string_ops = scan_file( project_dir "dependencies/gen.string_ops.hpp" ); + Code printing = scan_file( project_dir "dependencies/gen.printing.hpp" ); + Code containers = scan_file( project_dir "dependencies/gen.containers.hpp" ); + Code string = scan_file( project_dir "dependencies/gen.string.hpp" ); + Code file_handling = scan_file( project_dir "dependencies/gen.file_handling.hpp" ); + Code parsing = scan_file( project_dir "dependencies/gen.parsing.hpp" ); + Code timing = scan_file( project_dir "dependencies/gen.timing.hpp" ); + + header.print_fmt( "GEN_NS_BEGIN\n\n" ); + header.print( header_start ); + header.print( macros ); + header.print( basic_types ); + header.print( debug ); + header.print( memory ); + header.print( string_ops ); + header.print( printing ); + header.print( containers ); + header.print( string ); + header.print( file_handling ); + header.print( parsing ); + header.print( timing ); + header.print_fmt( "GEN_NS_END\n" ); + + header.print_fmt( roll_own_dependencies_guard_end ); + } + + Code types = scan_file( project_dir "components/gen.types.hpp" ); + Code data_structs = scan_file( project_dir "components/gen.data_structures.hpp" ); + Code interface = scan_file( project_dir "components/gen.interface.hpp" ); + Code header_end = scan_file( project_dir "components/gen.header_end.hpp" ); + + header.print_fmt( "GEN_NS_BEGIN\n\n" ); + header.print( types ); + header.print( data_structs ); + header.print( interface ); + header.print( header_end ); + header.print_fmt( "GEN_NS_END\n" ); + } // Implementation + { + header.print_fmt( "%s\n", (char const*) implementation_guard_start ); + { + header.print_fmt( roll_own_dependencies_guard_start ); - gen_header.print_fmt( "%s\n\n", (char const*) gen_implementation_guard ); - gen_header.print_fmt( "GEN_NS_BEGIN\n"); + Code impl_start = scan_file( project_dir "dependencies/gen.impl_start.cpp" ); + Code debug = scan_file( project_dir "dependencies/gen.debug.cpp" ); + Code string_ops = scan_file( project_dir "dependencies/gen.string_ops.cpp" ); + Code printing = scan_file( project_dir "dependencies/gen.printing.cpp" ); + Code memory = scan_file( project_dir "dependencies/gen.memory.cpp" ); + Code parsing = scan_file( project_dir "dependencies/gen.parsing.cpp" ); + Code hashing = scan_file( project_dir "dependencies/gen.hashing.cpp" ); + Code string = scan_file( project_dir "dependencies/gen.string.cpp" ); + Code timing = scan_file( project_dir "dependencies/gen.timing.cpp" ); - gen_header.print_fmt( "\nGEN_NS_END\n"); - gen_header.print_fmt( "%s\n", (char const*) gen_implementation_end ); + header.print_fmt( "GEN_NS_BEGIN\n\n"); + header.print( impl_start ); + header.print( debug ); + header.print( string_ops ); + header.print( printing ); + header.print( memory ); + header.print( parsing ); + header.print( hashing ); + header.print( string ); + header.print( timing ); + header.print_fmt( "GEN_NS_END\n"); - gen_header.print( pop_ignores ); - gen_header.write(); + header.print_fmt( roll_own_dependencies_guard_end ); + } + + Code data = scan_file( project_dir "components/gen.data.cpp" ); + Code ast_case_macros = scan_file( project_dir "components/gen.ast_case_macros.cpp" ); + Code ast = scan_file( project_dir "components/gen.ast.cpp" ); + Code interface = scan_file( project_dir "components/gen.interface.cpp" ); + Code upfront = scan_file( project_dir "components/gen.interface.upfront.cpp" ); + Code parsing = scan_file( project_dir "components/gen.interface.parsing.cpp" ); + Code untyped = scan_file( project_dir "components/gen.untyped.cpp" ); + + header.print_fmt( "GEN_NS_BEGIN\n\n"); + header.print( data ); + header.print( ast_case_macros ); + header.print( ast ); + header.print( interface ); + header.print( upfront ); + header.print( parsing ); + header.print( untyped ); + header.print_fmt( "GEN_NS_END\n"); + + header.print_fmt( "%s\n", (char const*) implementation_guard_end ); + } + + header.print( pop_ignores ); + header.write(); gen::deinit(); return 0;