diff --git a/Readme.md b/Readme.md index 14f6c4c..3ebac5c 100644 --- a/Readme.md +++ b/Readme.md @@ -19,7 +19,7 @@ If your going to metaprogram, you can never have enough docs on your tooling... * [Parser Algo](./docs/Parser_Algo.md): In-depth breakdown of the parser's implementation. * [base](./base/Readme.md): Essential (base) library. * [gen_c_library](./gen_c_library/Readme.md): C11 library variant generation (single header and segmeented). -* [gen_segmented](./gen_segemented/Readme.md): Segemented C++ (`gen.`, `gen.dep.`) generation +* [gen_segmented](./gen_segmented/Readme.md): Segemented C++ (`gen.`, `gen.dep.`) generation * [gen_singleheader](./gen_singleheader/Readme.md): Singlehader C++ generation `gen.hpp` * [gen_unreal_engine](./gen_unreal_engine/Readme.md): Unreal Engine thirdparty code generation. diff --git a/base/Readme.md b/base/Readme.md index 4acf5b2..6ba1c3c 100644 --- a/base/Readme.md +++ b/base/Readme.md @@ -16,7 +16,7 @@ Standard formats: * **helpers**: Contains helper functionality used by base and other libraries to regenerate or generate the other library formats. * `base_codegen.hpp`: Helps with self-hosted code generation of enums, and operator overload inlines of the code types. * `..inline.`: macros that are meant to be injected at specific locations of the library. - * `misc.hpp`: + * `misc.hpp`: Misc functionality used by the library generation metaprograms. * `undef.macros.h`: Undefines all macros from library that original were intended to leak into user code. * **auxillary**: Non-essential tooling: * `Builder`: Similar conceptually to Jai programming language's *builder*, just opens a file and prepares a string buffer to serialize code into (`builder_print`, `builder_print_fmt`). Then write & close the file when completed (`builder_write`). @@ -125,6 +125,8 @@ There are ***five*** header files which are automatically generated by [base_cod * [`AttributeTokens.csv`](./enums/AttributeTokens.csv): Provides tokens entries that should be considered as attributes by the lexer and parser. Sspecfiically macro attributes such as those use for exporting symbols. * [`ast_inlines.hpp`](./components/gen/ast_inlines.hpp): Member trivial `operator` definitions for C++ code types. Does not use a csv. +[`misc.hpp`](./helpers/misc.hpp): Has shared functions used by the library generation meta-programs throughout this codebase. + ## On multi-threading Currently unsupported. I want the library to be *stable* and *correct*, with the addition of exhausting all basic single-threaded optimizations before I consider multi-threading. diff --git a/base/auxillary/builder.hpp b/base/auxillary/builder.hpp index 7d92fda..3c37fba 100644 --- a/base/auxillary/builder.hpp +++ b/base/auxillary/builder.hpp @@ -13,6 +13,7 @@ # include "components/inlines.hpp" # include "components/gen/ast_inlines.hpp" # include "components/header_end.hpp" +using namespace gen; #endif #pragma region Builder diff --git a/base/auxillary/scanner.cpp b/base/auxillary/scanner.cpp index 5231a14..a7a50f9 100644 --- a/base/auxillary/scanner.cpp +++ b/base/auxillary/scanner.cpp @@ -2,4 +2,118 @@ # include "scanner.hpp" #endif +#pragma region Scanner +Code scan_file( char const* path ) +{ + FileInfo file; + + FileError error = file_open_mode( & file, EFileMode_READ, path ); + if ( error != EFileError_NONE ) + { + GEN_FATAL( "scan_file: Could not open: %s", path ); + } + + ssize fsize = file_size( & file ); + if ( fsize <= 0 ) + { + GEN_FATAL("scan_file: %s is empty", path ); + } + + String str = string_make_reserve( GlobalAllocator, fsize ); + file_read( & file, str, fsize ); + string_get_header(str)->Length = fsize; + + // Skip GEN_INTELLISENSE_DIRECTIVES preprocessor blocks + // Its designed so that the directive should be the first thing in the file. + // Anything that comes before it will also be omitted. + { + #define current (*scanner) + #define matched 0 + #define move_fwd() do { ++ scanner; -- left; } while (0) + const StrC directive_start = txt( "ifdef" ); + const StrC directive_end = txt( "endif" ); + const StrC def_intellisense = txt("GEN_INTELLISENSE_DIRECTIVES" ); + + bool found_directive = false; + char const* scanner = (char const*)str; + s32 left = fsize; + while ( left ) + { + // Processing directive. + if ( current == '#' ) + { + move_fwd(); + while ( left && char_is_space( current ) ) + move_fwd(); + + if ( ! found_directive ) + { + if ( left && str_compare_len( scanner, directive_start.Ptr, directive_start.Len ) == matched ) + { + scanner += directive_start.Len; + left -= directive_start.Len; + + while ( left && char_is_space( current ) ) + move_fwd(); + + if ( left && str_compare_len( scanner, def_intellisense.Ptr, def_intellisense.Len ) == matched ) + { + scanner += def_intellisense.Len; + left -= def_intellisense.Len; + + found_directive = true; + } + } + + // Skip to end of line + while ( left && current != '\r' && current != '\n' ) + move_fwd(); + move_fwd(); + + if ( left && current == '\n' ) + move_fwd(); + + continue; + } + + if ( left && str_compare_len( scanner, directive_end.Ptr, directive_end.Len ) == matched ) + { + scanner += directive_end.Len; + left -= directive_end.Len; + + // Skip to end of line + while ( left && current != '\r' && current != '\n' ) + move_fwd(); + move_fwd(); + + if ( left && current == '\n' ) + move_fwd(); + + // sptr skip_size = fsize - left; + if ( (scanner + 2) >= ( (char const*) str + fsize ) ) + { + mem_move( str, scanner, left ); + string_get_header(str)->Length = left; + break; + } + + mem_move( str, scanner, left ); + string_get_header(str)->Length = left; + + break; + } + } + + move_fwd(); + } + #undef move_fwd + #undef matched + #undef current + } + + file_close( & file ); + return untyped_str( string_to_strc(str) ); +} + +#pragma endregion Scanner diff --git a/base/auxillary/scanner.hpp b/base/auxillary/scanner.hpp index 4ef4222..d42acb7 100644 --- a/base/auxillary/scanner.hpp +++ b/base/auxillary/scanner.hpp @@ -20,119 +20,9 @@ // This is a simple file reader that reads the entire file into memory. // It has an extra option to skip the first few lines for undesired includes. // This is done so that includes can be kept in dependency and component files so that intellisense works. +Code scan_file( char const* path ); + inline -Code scan_file( char const* path ) -{ - FileInfo file; - - FileError error = file_open_mode( & file, EFileMode_READ, path ); - if ( error != EFileError_NONE ) - { - GEN_FATAL( "scan_file: Could not open: %s", path ); - } - - ssize fsize = file_size( & file ); - if ( fsize <= 0 ) - { - GEN_FATAL("scan_file: %s is empty", path ); - } - - String str = string_make_reserve( GlobalAllocator, fsize ); - file_read( & file, str, fsize ); - string_get_header(str)->Length = fsize; - - // Skip GEN_INTELLISENSE_DIRECTIVES preprocessor blocks - // Its designed so that the directive should be the first thing in the file. - // Anything that comes before it will also be omitted. - { - #define current (*scanner) - #define matched 0 - #define move_fwd() do { ++ scanner; -- left; } while (0) - const StrC directive_start = txt( "ifdef" ); - const StrC directive_end = txt( "endif" ); - const StrC def_intellisense = txt("GEN_INTELLISENSE_DIRECTIVES" ); - - bool found_directive = false; - char const* scanner = (char const*)str; - s32 left = fsize; - while ( left ) - { - // Processing directive. - if ( current == '#' ) - { - move_fwd(); - while ( left && char_is_space( current ) ) - move_fwd(); - - if ( ! found_directive ) - { - if ( left && str_compare_len( scanner, directive_start.Ptr, directive_start.Len ) == matched ) - { - scanner += directive_start.Len; - left -= directive_start.Len; - - while ( left && char_is_space( current ) ) - move_fwd(); - - if ( left && str_compare_len( scanner, def_intellisense.Ptr, def_intellisense.Len ) == matched ) - { - scanner += def_intellisense.Len; - left -= def_intellisense.Len; - - found_directive = true; - } - } - - // Skip to end of line - while ( left && current != '\r' && current != '\n' ) - move_fwd(); - move_fwd(); - - if ( left && current == '\n' ) - move_fwd(); - - continue; - } - - if ( left && str_compare_len( scanner, directive_end.Ptr, directive_end.Len ) == matched ) - { - scanner += directive_end.Len; - left -= directive_end.Len; - - // Skip to end of line - while ( left && current != '\r' && current != '\n' ) - move_fwd(); - move_fwd(); - - if ( left && current == '\n' ) - move_fwd(); - - // sptr skip_size = fsize - left; - if ( (scanner + 2) >= ( (char const*) str + fsize ) ) - { - mem_move( str, scanner, left ); - string_get_header(str)->Length = left; - break; - } - - mem_move( str, scanner, left ); - string_get_header(str)->Length = left; - - break; - } - } - - move_fwd(); - } - #undef move_fwd - #undef matched - #undef current - } - - file_close( & file ); - return untyped_str( string_to_strc(str) ); -} - CodeBody parse_file( const char* path ) { FileContents file = file_read_contents( GlobalAllocator, true, path ); @@ -146,17 +36,18 @@ CodeBody parse_file( const char* path ) typedef struct CSV_Column CSV_Column; struct CSV_Column { - CSV_Object Owner; + CSV_Object ADT; Array Content; }; typedef struct CSV_Columns2 CSV_Columns2; struct CSV_Columns2 { - CSV_Object Owner; + CSV_Object ADT; Array Col_1; Array Col_2; }; +inline CSV_Column parse_csv_one_column(AllocatorInfo allocator, char const* path) { char scratch_mem[kilobytes(32)]; Arena scratch = arena_init_from_memory( scratch_mem, sizeof(scratch_mem) ); @@ -164,11 +55,12 @@ CSV_Column parse_csv_one_column(AllocatorInfo allocator, char const* path) { file_read_contents( arena_allocator_info( & scratch), file_zero_terminate, path ); CSV_Column result; - csv_parse( & result.owner, scratch_mem, allocator, false ); - result.Content = csv_nodes.nodes[0].nodes; + csv_parse( & result.ADT, scratch_mem, allocator, false ); + result.Content = result.ADT.nodes[0].nodes; return result; } +inline CSV_Columns2 parse_csv_two_columns(AllocatorInfo allocator, char const* path) { char scratch_mem[kilobytes(32)]; Arena scratch = arena_init_from_memory( scratch_mem, sizeof(scratch_mem) ); @@ -176,9 +68,9 @@ CSV_Columns2 parse_csv_two_columns(AllocatorInfo allocator, char const* path) { file_read_contents( arena_allocator_info( & scratch), file_zero_terminate, path ); CSV_Columns2 result; - csv_parse( & result.owner, scratch_mem, allocator, false ); - result.Col_1 = csv_nodes.nodes[0].nodes; - result.Col_2 = csv_nodes.nodes[1].nodes; + csv_parse( & result.ADT, scratch_mem, allocator, false ); + result.Col_1 = result.ADT.nodes[0].nodes; + result.Col_2 = result.ADT.nodes[1].nodes; return result; } diff --git a/base/base.cpp b/base/base.cpp index 35703b6..3d11507 100644 --- a/base/base.cpp +++ b/base/base.cpp @@ -2,22 +2,17 @@ #define GEN_ENFORCE_STRONG_CODE_TYPES #define GEN_EXPOSE_BACKEND #define GEN_C_LIKE_CPP 1 -#include "../project/gen.cpp" +#include "gen.cpp" #include "helpers/push_ignores.inline.hpp" -#include "helpers/helper.hpp" + +#include GEN_NS_BEGIN -#include "helpers/push_container_defines.inline.hpp" -#include "dependencies/parsing.cpp" -#include "helpers/pop_container_defines.inline.hpp" +#include "helpers/base_codegen.hpp" +#include "helpers/misc.hpp" GEN_NS_END -#include "auxillary/builder.hpp" -#include "auxillary/builder.cpp" -#include "auxillary/scanner.hpp" -#include "auxillary/misc.hpp" - using namespace gen; constexpr char const* path_format_style = "../scripts/.clang-format"; @@ -27,8 +22,25 @@ Code format( Code code ) { return code_refactor_and_format(code, scratch_file, nullptr, path_format_style ); } +constexpr char const* generation_notice = +"// This file was generated automatially by gencpp's bootstrap.cpp " +"(See: https://github.com/Ed94/gencpp)\n\n"; + +CodeBody gen_component_header = def_global_body( args( + def_preprocess_cond( PreprocessCond_IfDef, txt("GEN_INTELLISENSE_DIRECTIVES") ), + pragma_once, + def_include(txt("components/types.hpp")), + preprocess_endif, + fmt_newline, + untyped_str( to_strc_from_c_str(generation_notice) ) +)); + int gen_main() { + gen::init(); + + __debugbreak(); + CodeBody ecode = gen_ecode ( "enums/ECodeTypes.csv" ); CodeBody eoperator = gen_eoperator ( "enums/EOperator.csv" ); CodeBody especifier = gen_especifier( "enums/ESpecifier.csv" ); @@ -53,4 +65,7 @@ int gen_main() builder_print( & header_ast_inlines, gen_component_header ); builder_print( & header_ast_inlines, format(ast_inlines) ); builder_write( & header_ast_inlines); -} \ No newline at end of file + + gen::deinit(); + return 0; +} diff --git a/base/components/interface.parsing.cpp b/base/components/interface.parsing.cpp index ef88579..d983e07 100644 --- a/base/components/interface.parsing.cpp +++ b/base/components/interface.parsing.cpp @@ -8,8 +8,6 @@ // Publically Exposed Interface -void parser_define_macro( StrC ) - CodeClass parse_class( StrC def ) { GEN_USING_NS_PARSER; diff --git a/base/components/interface.upfront.cpp b/base/components/interface.upfront.cpp index 134d60b..af815e8 100644 --- a/base/components/interface.upfront.cpp +++ b/base/components/interface.upfront.cpp @@ -644,7 +644,7 @@ CodeDefine def_define( StrC name, StrC content, Opts_def_define p ) // Add the define to PreprocessorDefines for usage in parsing s32 lex_id_len = 0; for (; lex_id_len < result->Name.Len; ++ lex_id_len ) { - if ( reuslt->Name.Ptr[lex_id_len] == '(' ) + if ( result->Name.Ptr[lex_id_len] == '(' ) break; } StrC lex_id = { lex_id_len, result->Name.Ptr }; diff --git a/base/dependencies/basic_types.hpp b/base/dependencies/basic_types.hpp index b2711a6..79b8df3 100644 --- a/base/dependencies/basic_types.hpp +++ b/base/dependencies/basic_types.hpp @@ -1,6 +1,5 @@ #ifdef GEN_INTELLISENSE_DIRECTIVES # pragma once -# include "platform.hpp" # include "macros.hpp" #endif diff --git a/base/dependencies/debug.cpp b/base/dependencies/debug.cpp index 6c188c1..b10a98a 100644 --- a/base/dependencies/debug.cpp +++ b/base/dependencies/debug.cpp @@ -1,7 +1,5 @@ #ifdef GEN_INTELLISENSE_DIRECTIVES # pragma once -# include "debug.hpp" -# include "basic_types.hpp" # include "src_start.cpp" #endif diff --git a/base/dependencies/debug.hpp b/base/dependencies/debug.hpp index eae52d1..06b5ea6 100644 --- a/base/dependencies/debug.hpp +++ b/base/dependencies/debug.hpp @@ -1,6 +1,9 @@ #ifdef GEN_INTELLISENSE_DIRECTIVES # pragma once +# include "dependencies/platform.hpp" +# include "dependencies/macros.hpp" # include "basic_types.hpp" +# include "macros.hpp" #endif #pragma region Debug diff --git a/base/dependencies/macros.hpp b/base/dependencies/macros.hpp index e762c67..44a0c8e 100644 --- a/base/dependencies/macros.hpp +++ b/base/dependencies/macros.hpp @@ -1,5 +1,6 @@ #ifdef GEN_INTELLISENSE_DIRECTIVES # pragma once +# include "platform.hpp" #endif #pragma region Macros diff --git a/base/dependencies/parsing.hpp b/base/dependencies/parsing.hpp index b0a721d..5cf9317 100644 --- a/base/dependencies/parsing.hpp +++ b/base/dependencies/parsing.hpp @@ -1,5 +1,6 @@ #ifdef GEN_INTELLISENSE_DIRECTIVES # pragma once +# include "timing.hpp" #endif #pragma region ADT diff --git a/base/dependencies/printing.cpp b/base/dependencies/printing.cpp index 02f83dd..9e41358 100644 --- a/base/dependencies/printing.cpp +++ b/base/dependencies/printing.cpp @@ -1,7 +1,5 @@ #ifdef GEN_INTELLISENSE_DIRECTIVES # pragma once -# include "filesystem.hpp" -# include "strings.hpp" # include "string_ops.cpp" #endif diff --git a/base/dependencies/src_start.cpp b/base/dependencies/src_start.cpp index 02d804e..29597f0 100644 --- a/base/dependencies/src_start.cpp +++ b/base/dependencies/src_start.cpp @@ -1,4 +1,5 @@ #ifdef GEN_INTELLISENSE_DIRECTIVES +# pragma once # include "header_start.hpp" #endif diff --git a/base/dependencies/string_ops.cpp b/base/dependencies/string_ops.cpp index 954d40a..dd72075 100644 --- a/base/dependencies/string_ops.cpp +++ b/base/dependencies/string_ops.cpp @@ -1,6 +1,5 @@ #ifdef GEN_INTELLISENSE_DIRECTIVES # pragma once -# include "string_ops.hpp" # include "debug.cpp" #endif diff --git a/base/gen.cpp b/base/gen.cpp index 0417deb..d45d6e4 100644 --- a/base/gen.cpp +++ b/base/gen.cpp @@ -37,6 +37,9 @@ GEN_NS_BEGIN #include "components/interface.parsing.cpp" #include "components/interface.untyped.cpp" +#include "auxillary/builder.cpp" +#include "auxillary/scanner.cpp" + GEN_NS_END #include "helpers/pop_container_defines.inline.hpp" diff --git a/base/gen.dep.cpp b/base/gen.dep.cpp index 16ad02f..6a6a9b9 100644 --- a/base/gen.dep.cpp +++ b/base/gen.dep.cpp @@ -13,5 +13,6 @@ GEN_NS_BEGIN #include "dependencies/strings.cpp" #include "dependencies/filesystem.cpp" #include "dependencies/timing.cpp" +#include "dependencies/parsing.cpp" GEN_NS_END diff --git a/base/gen.dep.hpp b/base/gen.dep.hpp index babc921..8283b8d 100644 --- a/base/gen.dep.hpp +++ b/base/gen.dep.hpp @@ -16,5 +16,6 @@ GEN_NS_BEGIN #include "dependencies/strings.hpp" #include "dependencies/filesystem.hpp" #include "dependencies/timing.hpp" +#include "dependencies/parsing.hpp" GEN_NS_END diff --git a/base/helpers/base_codegen.hpp b/base/helpers/base_codegen.hpp index d133cbb..63590fd 100644 --- a/base/helpers/base_codegen.hpp +++ b/base/helpers/base_codegen.hpp @@ -1,11 +1,11 @@ #pragma once -#include "gen.hpp" +#if GEN_INTELLISENSE_DIRECTIVES +# include "../gen.hpp" +# include "misc.hpp" using namespace gen; - -#include "dependencies/parsing.hpp" -#include "misc.hpp" +#endif CodeBody gen_ecode( char const* path, bool use_c_definition = false ) { @@ -182,8 +182,8 @@ CodeBody gen_especifier( char const* path, bool use_c_definition = false ) for (usize idx = 0; idx < array_num(csv_enum.Col_1); idx++) { - char const* enum_str = enum_strs[idx].string; - char const* entry_to_str = str_strs [idx].string; + char const* enum_str = csv_enum.Col_1[idx].string; + char const* entry_to_str = csv_enum.Col_2[idx].string; string_append_fmt( & enum_entries, "Spec_%s,\n", enum_str ); string_append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str); diff --git a/base/helpers/misc.hpp b/base/helpers/misc.hpp index 16016bc..0f31e91 100644 --- a/base/helpers/misc.hpp +++ b/base/helpers/misc.hpp @@ -1,23 +1,19 @@ +#pragma once #ifdef GEN_INTELLISENSE_DIRECTIVES -#pragma once -#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS -#define GEN_ENFORCE_STRONG_CODE_TYPES -#define GEN_EXPOSE_BACKEND -#include "../gen.cpp" +# define GEN_DEFINE_LIBRARY_CODE_CONSTANTS +# define GEN_ENFORCE_STRONG_CODE_TYPES +# define GEN_EXPOSE_BACKEND +# include "gen.hpp" +# include "helpers/push_ignores.inline.hpp" +# include "helpers/helper.hpp" +# include "auxillary/builder.hpp" +# include "auxillary/builder.cpp" +# include "auxillary/scanner.hpp" -#include "helpers/push_ignores.inline.hpp" -#include "helpers/helper.hpp" +#include -GEN_NS_BEGIN -#include "helpers/push_container_defines.inline.hpp" -#include "dependencies/parsing.cpp" -#include "helpers/pop_container_defines.inline.hpp" -GEN_NS_END - -#include "auxillary/builder.hpp" -#include "auxillary/builder.cpp" -#include "auxillary/scanner.hpp" +using namespace gen; #endif // Will format a file with the given style at the provided path. @@ -29,13 +25,13 @@ void clang_format_file( char const* path, char const* style_path ) String style_arg; if (style_path) { - stle_arg = string_make_strc(GlobalAllocator, txt("-style=file:")); + style_arg = string_make_strc(GlobalAllocator, txt("-style=file:")); string_append_fmt( & style_arg, "%s ", style_path ); } - StrC clang_format = txt("clang-format ") - StrC cf_format_inplace = txt("-i ") - StrC cf_verbose = txt("-verbose ") + StrC clang_format = txt("clang-format "); + StrC cf_format_inplace = txt("-i "); + StrC cf_verbose = txt("-verbose "); String command = string_make_strc( GlobalAllocator, clang_format ); string_append_strc( & command, cf_format_inplace ); @@ -53,31 +49,34 @@ void clang_format_file( char const* path, char const* style_path ) // (See: ./gencpp/scripts/build.ci.ps1 for how) void refactor_file( char const* path, char const* refactor_script ) { - GEN_ASSERT_NOT_NULL(path, refactor_script); + GEN_ASSERT_NOT_NULL(path); + GEN_ASSERT_NOT_NULL(refactor_script); - #define refactor - - String command = string_make_strc(GlobalAllocator, txt("refactor"))); + String command = string_make_strc(GlobalAllocator, txt("refactor ")); + string_append_strc( & command, txt("-debug ") ); + string_append_strc( & command, txt("-num=1 ") ); + string_append_fmt( & command, "-src=%s ", path ); + string_append_fmt( & command,"-spec=%s ", refactor_script ); log_fmt("\tBeginning refactor:\n"); system(command); - log_fmt("\nRefactoring complete.\n"); + log_fmt("\nRefactoring complete.\n"); #undef refactor } // Does either of the above or both to the provided code. // Code returned will be untyped content (its be serialized) -Code code_refactor_and_format( Code code, char const* scratch_path, char const* refactor_script, char_const* clang_format_sytle_path ) +Code code_refactor_and_format( Code code, char const* scratch_path, char const* refactor_script, char const* clang_format_sytle_path ) { - GEN_ASSERT_NOT_NULL(code); + GEN_ASSERT(code); GEN_ASSERT_NOT_NULL(scratch_path); Builder scratch_file = builder_open("gen/scratch.hpp"); builder_print( & scratch_file, code); builder_write(& scratch_file); if (refactor_script) { - refactor_file(scratch_path, refactor_script) + refactor_file(scratch_path, refactor_script); } if ( clang_format_sytle_path ) { clang_format_file(scratch_path, clang_format_sytle_path); diff --git a/gen_segemented/Readme.md b/gen_segmented/Readme.md similarity index 100% rename from gen_segemented/Readme.md rename to gen_segmented/Readme.md diff --git a/gen_segemented/segemented.cpp b/gen_segmented/segemented.cpp similarity index 97% rename from gen_segemented/segemented.cpp rename to gen_segmented/segemented.cpp index cdf68a9..48d2138 100644 --- a/gen_segemented/segemented.cpp +++ b/gen_segmented/segemented.cpp @@ -2,22 +2,15 @@ #define GEN_ENFORCE_STRONG_CODE_TYPES #define GEN_EXPOSE_BACKEND #define GEN_C_LIKE_CPP 1 -#include "../project/gen.cpp" +#include "../base/gen.cpp" #include "helpers/push_ignores.inline.hpp" -#include "helpers/helper.hpp" GEN_NS_BEGIN -#include "helpers/push_container_defines.inline.hpp" -#include "dependencies/parsing.cpp" -#include "helpers/pop_container_defines.inline.hpp" +#include "helpers/base_codegen.hpp" +#include "helpers/misc.hpp" GEN_NS_END -#include "auxillary/builder.hpp" -#include "auxillary/builder.cpp" -#include "auxillary/scanner.hpp" -#include "auxillary/misc.hpp" - using namespace gen; constexpr char const* generation_notice = diff --git a/scripts/.clang-format b/scripts/.clang-format index eeda36b..06dbeaa 100644 --- a/scripts/.clang-format +++ b/scripts/.clang-format @@ -1,5 +1,10 @@ # Format Style Options - Created with Clang Power Tools --- +AttributeMacros: [enum_underlying] +StatementMacros: [GEN_NS_BEGIN, GEN_NS_END, GEN_NS_PARSER_BEGIN, GEN_NS_PARSER_END, GEN_API_C_BEGIN, GEN_API_C_END] +TypenameMacros: [Array, Hashtable] +SkipMacroDefinitionBody: true + AccessModifierOffset: -4 AlignAfterOpenBracket: BlockIndent diff --git a/scripts/Readme.md b/scripts/Readme.md index 0aac815..852e982 100644 --- a/scripts/Readme.md +++ b/scripts/Readme.md @@ -4,23 +4,10 @@ Generation, testing, and cleanup scripts for the test directory are found here a ## Refactoring -`refactor.ps1` Provides a way to run the [refactor](github.com/Ed94/refactor) program. It uses the `gencpp.refactor` script to complete a mass refactor of all content within the files of the specified within the script. +`refactor.ps1` Provides a way to run the [refactor](github.com/Ed94/refactor) program. It uses the a `.refactor` script (such as [`gencpp.refactor`](../base/gencpp.refactor)) to complete a mass refactor of all content within the files of the specified within the script. -Currently `refactor` only supports naive sort of *find and replace* feature set and will not be able to rename identifiers excluisvely to a specific context (such as only renaming member names of a specific struct, etc). - -**Note: The following macros are used with specifiers and token parsing within the library:** - -* global -* internal -* local_persist -* forceinline -* neverinline - -IF they are changed the following files would need adjustment: - -* `./project/enums/ESpecifier.csv` -* `./project/enums/ETokType.csv` -* `./project/helpers/helper.hpp` +Currently `refactor` only supports naive sort of *find and replace* feature set and will not be able to rename identifiers excluisvely to a specific context (such as only renaming member names of a specific struct, etc). +Its main uage is the [c_library generation](../gen_c_library/). ## Build & Run Scripts @@ -28,13 +15,14 @@ IF they are changed the following files would need adjustment: Remove any generated content from the repository. **`build.ps1`** -Build bootstrap, singleheader, or tests. Supports MSVC or clang, release or debug. +Build c_library, segmented, singleheader, unreal. Supports msvc or clang, release or debug. ``` args: - bootstrap + c_library + segemented singleheader - test + unreal clang msvc : By default this project builds with clang, specifying msvc will build with MSVC. debug @@ -42,6 +30,6 @@ args: ``` **`package_release.ps1`** -Will build the project as fast as possible, then package the release into a zip file. +Will build the build all, then package the release into a zip file. *Note: My env is Windows 11 with MSVC 2022 and clang 16.0.6* diff --git a/scripts/build.ci.ps1 b/scripts/build.ci.ps1 index f31d68c..1c76b7a 100644 --- a/scripts/build.ci.ps1 +++ b/scripts/build.ci.ps1 @@ -19,6 +19,7 @@ Push-Location $path_root $vendor = $null $release = $null $verbose = $false + $base = $false [bool] $segemented = $false [bool] $singleheader = $false [bool] $c_library = $false @@ -35,6 +36,7 @@ if ( $args ) { $args | ForEach-Object { "verbose" { $verbose = $true } "release" { $release = $true } "debug" { $release = $false } + "base" { $base = $true } "segemented" { $segemented = $true } "singleheader" { $singleheader = $true } "c_library" { $c_library = $true } @@ -67,7 +69,13 @@ else { $optimize = $true } -if ( $segmented -eq $false -and $singleheader -eq $false -and $c_library -eq $false -and $unreal -eq $false -and $test -eq $false ) { +$cannot_build = $base -eq $false +$cannot_build = $cannot_build -and $segmented -eq $false +$cannot_build = $cannot_build -and $singleheader -eq $false +$cannot_build = $cannot_build -and $c_library -eq $false +$cannot_build = $cannot_build -and $unreal -eq $false +$cannot_build = $cannot_build -and $test -eq $false +if ( $cannot_build ) { throw "No build target specified. One must be specified, this script will not assume one" } @@ -83,9 +91,9 @@ $path_base = Join-Path $path_root base $path_c_library = join-Path $path_root gen_c_library $path_segmented = Join-Path $path_root gen_segmented $path_singleheader = Join-Path $path_root gen_singleheader -$path_scripts = Join-Path $path_root scripts $path_unreal = Join-Path $path_root gen_unreal_engine $path_test = Join-Path $path_root test +$path_scripts = Join-Path $path_root scripts if ( $base ) { @@ -115,13 +123,13 @@ if ( $base ) Push-Location $path_project if ( Test-Path( $executable ) ) { - write-host "`nRunning bootstrap" + write-host "`nRunning base" $time_taken = Measure-Command { & $executable | ForEach-Object { write-host `t $_ -ForegroundColor Green } } - write-host "`nBootstrap completed in $($time_taken.TotalMilliseconds) ms" + write-host "`bbase completed in $($time_taken.TotalMilliseconds) ms" } Pop-Location } @@ -153,7 +161,7 @@ if ( $segmented ) Push-Location $path_project if ( Test-Path( $executable ) ) { - write-host "`nRunning bootstrap" + write-host "`nRunning segmented" $time_taken = Measure-Command { & $executable | ForEach-Object { write-host `t $_ -ForegroundColor Green