Compare commits

...

8 Commits

Author SHA1 Message Date
Ed_
401f85f673 corrections to c_library.cpp, package_release.ps1 working for all zips 2024-12-11 02:04:22 -05:00
Ed_
caec5d8dfc fix clang format for enum_underlying 2024-12-11 00:13:36 -05:00
Ed_
44d0a9cf9d c_library compiles 2024-12-10 23:35:47 -05:00
Ed_
c0aa4fee95 updates on package_release.ps1 and clean.ps1 2024-12-10 22:42:07 -05:00
Ed_
913d9bf26b fixed clean script 2024-12-10 22:27:35 -05:00
Ed_
c8d6c27f07 singleheader compiles again 2024-12-10 22:20:40 -05:00
Ed_
aecc2c59dd segemented builds 2024-12-10 21:59:13 -05:00
Ed_
0e32838da1 base works 2024-12-10 21:35:46 -05:00
28 changed files with 788 additions and 718 deletions

View File

@ -115,7 +115,7 @@ The vast majority of macros should be single-line subsitutions that either add:
## On base code generation
There are ***five*** header files which are automatically generated by [base_codegen.hpp](./helpers/base_codegen.hpp). They are all located in [components/gen](./components/gen/).
There are ***five*** header files which are automatically generated using [base_codegen.hpp](./helpers/base_codegen.hpp) by [base.cpp](./base.cpp). They are all located in [components/gen](./components/gen/).
* [`ecode.hpp`](./components/gen/ecode.hpp): `CodeType` enum definition and related implementaiton. Generation is based off of [`ECodeType.csv](./enums/ECodeTypes.csv).
* [`especifier.hpp`](./components/gen/especifier.hpp): `Specifier` enum definition, etc. Generated using [`ESpecifier.csv`](./enums/ESpecifier.csv).

View File

@ -116,4 +116,33 @@ Code scan_file( char const* path )
return untyped_str( string_to_strc(str) );
}
CodeBody parse_file( const char* path ) {
FileContents file = file_read_contents( GlobalAllocator, true, path );
StrC content = { file.size, (char const*)file.data };
CodeBody code = parse_global_body( content );
log_fmt("\nParsed: %s\n", path);
return code;
}
CSV_Column parse_csv_one_column(AllocatorInfo allocator, char const* path) {
FileContents content = file_read_contents( allocator, file_zero_terminate, path );
Arena csv_arena = arena_init_from_memory(content.data, content.size);
CSV_Column result;
csv_parse( & result.ADT, rcast(char*, content.data), allocator, false );
result.Content = result.ADT.nodes[0].nodes;
return result;
}
CSV_Columns2 parse_csv_two_columns(AllocatorInfo allocator, char const* path) {
FileContents content = file_read_contents( allocator, file_zero_terminate, path );
Arena csv_arena = arena_init_from_memory(content.data, content.size);
CSV_Columns2 result;
csv_parse( & result.ADT, rcast(char*, content.data), allocator, false );
result.Col_1 = result.ADT.nodes[0].nodes;
result.Col_2 = result.ADT.nodes[1].nodes;
return result;
}
#pragma endregion Scanner

View File

@ -22,14 +22,7 @@
// 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
CodeBody parse_file( const char* path )
{
FileContents file = file_read_contents( GlobalAllocator, true, path );
CodeBody code = parse_global_body( { file.size, (char const*)file.data } );
log_fmt("\nParsed: %s\n", path);
return code;
}
CodeBody parse_file( const char* path );
// The follow is basic support for light csv parsing (use it as an example)
// Make something robust if its more serious.
@ -37,41 +30,17 @@ CodeBody parse_file( const char* path )
typedef struct CSV_Column CSV_Column;
struct CSV_Column {
CSV_Object ADT;
Array<ADT_Node> Content;
Array(ADT_Node) Content;
};
typedef struct CSV_Columns2 CSV_Columns2;
struct CSV_Columns2 {
CSV_Object ADT;
Array<ADT_Node> Col_1;
Array<ADT_Node> Col_2;
Array(ADT_Node) Col_1;
Array(ADT_Node) 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) );
file_read_contents( arena_allocator_info( & scratch), file_zero_terminate, path );
CSV_Column result;
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) );
file_read_contents( arena_allocator_info( & scratch), file_zero_terminate, path );
CSV_Columns2 result;
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;
}
CSV_Column parse_csv_one_column(AllocatorInfo allocator, char const* path);
CSV_Columns2 parse_csv_two_columns(AllocatorInfo allocator, char const* path);
#pragma endregion Scanner

View File

@ -3,7 +3,6 @@
#define GEN_EXPOSE_BACKEND
#define GEN_C_LIKE_CPP 1
#include "gen.cpp"
#include "helpers/push_ignores.inline.hpp"
#include <stdlib.h>
@ -16,7 +15,7 @@ GEN_NS_END
using namespace gen;
constexpr char const* path_format_style = "../scripts/.clang-format";
constexpr char const* scratch_file = "gen/scratch.hpp";
constexpr char const* scratch_file = "build/scratch.hpp";
Code format( Code code ) {
return code_refactor_and_format(code, scratch_file, nullptr, path_format_style );
@ -26,20 +25,18 @@ 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 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) )
));
CodeBody ecode = gen_ecode ( "enums/ECodeTypes.csv" );
CodeBody eoperator = gen_eoperator ( "enums/EOperator.csv" );

View File

@ -346,7 +346,7 @@ void enum_to_string_def(CodeEnum self, String* result )
, body_to_string(self->Body)
);
else if ( self->UnderlyingTypeMacro )
string_append_fmt( result, "%SC %S\n\n{\n%S\n}"
string_append_fmt( result, "%SC %S\n{\n%S\n}"
, self->Name
, code_to_string(self->UnderlyingTypeMacro)
, body_to_string(self->Body)

View File

@ -391,7 +391,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
}
#define null_check( Context_, Code_ ) \
if ( Code_ != nullptr ) \
if ( Code_ == nullptr ) \
{ \
log_failure( "gen::" stringize(Context_) ": " stringize(Code_) " provided is null" ); \
return InvalidCode; \

View File

@ -317,7 +317,7 @@
// ^ Selects the comma ^ is the type ^ is the function ^ Insert a comma
// The slot won't exist if that comma is not found. |
// For the occastion where an expression didn't resolve to a selection option the "default: <value>" wilbe set to:
// For the occastion where an expression didn't resolve to a selection option the "default: <value>" will be set to:
typedef struct GENCPP_NO_RESOLVED_GENERIC_SELECTION GENCPP_NO_RESOLVED_GENERIC_SELECTION;
struct GENCPP_NO_RESOLVED_GENERIC_SELECTION {
void* _THE_VOID_SLOT_;
@ -327,7 +327,7 @@ GENCPP_NO_RESOLVED_GENERIC_SELECTION const gen_generic_selection_fail = {0};
// ----------------------------------------------------------------------------------------------------------------------------------
// Below are generated on demand for an overlaod depdendent on a type:
// -----------------------------------------------------------------------------------------------------#define GEN_FUNCTION_GENERIC_EXAMPLE( selector_arg ) _Generic( k
// ----------------------------------------------------------------------------------------------------------------------------------
#define GEN_FUNCTION_GENERIC_EXAMPLE( selector_arg ) _Generic( \
(selector_arg), /* Select Via Expression*/ \
/* Extendibility slots: */ \
@ -338,8 +338,7 @@ GENCPP_NO_RESOLVED_GENERIC_SELECTION const gen_generic_selection_fail = {0};
// ----------------------------------------------------------------------------------------------------------------------------------
// Then each definiton of a function has an associated define:
// #define <function_id_macro> GEN_GENERIC_FUNCTION_ARG_SIGNATURE( <function_id>, <arguments> )
#define GEN_GENERIC_FUNCTION_ARG_SIGNATURE( name_of_function, type_delimiter ) type_delimiter name_of_function
#// #define GENERIC_SLOT_<#>_<generic identifier> <typename>, <function_to_resolve>
// Then somehwere later on
// <etc> <return_type> <function_id> ( <arguments> ) { <implementation> }
@ -347,11 +346,11 @@ GENCPP_NO_RESOLVED_GENERIC_SELECTION const gen_generic_selection_fail = {0};
// Concrete example:
// To add support for long:
#define GEN_EXAMPLE_HASH__ARGS_SIG_1 GEN_GENERIC_FUNCTION_ARG_SIGNATURE( hash__P_long, long long )
#define GENERIC_SLOT_1_gen_example_hash long, gen_example_hash__P_long
size_t gen_example_hash__P_long( long val ) { return val * 2654435761ull; }
// To add support for long long:
#define GEN_EXAMPLE_HASH__ARGS_SIG_2 GEN_GENERIC_FUNCTION_ARG_SIGNATURE( hash__P_long_long, long long )
#define GENERIC_SLOT_2_gen_example_hash long long, gen_example_hash__P_long_long
size_t gen_example_hash__P_long_long( long long val ) { return val * 2654435761ull; }
// If using an Editor with support for syntax hightlighting macros: HASH__ARGS_SIG_1 and HASH_ARGS_SIG_2 should show color highlighting indicating the slot is enabled,
@ -394,6 +393,7 @@ size_t gen_example_hash__P_long_long( long long val ) { return val * 2654435761u
// Used to keep the _Generic keyword happy as bare types are not considered "expressions"
#define GEN_TYPE_TO_EXP(type) (* (type*)NULL)
// Instead of using this macro, you'll see it directly expanded by the code generation.
// typedef void* GEN_GenericExampleType;
// GEN_FUNCTION_GENERIC_EXAMPLE_DIRECT_TYPE( GEN_GenericExampleType );

View File

@ -9,8 +9,10 @@ using namespace gen;
CodeBody gen_ecode( char const* path, bool use_c_definition = false )
{
CSV_Columns2 csv_enum = parse_csv_two_columns(GlobalAllocator, path );
FixedArena_32KB scratch; fixed_arena_init(& scratch);
AllocatorInfo scratch_info = fixed_arena_allocator_info(& scratch);
CSV_Columns2 csv_enum = parse_csv_two_columns( scratch_info, path );
String enum_entries = string_make_reserve( GlobalAllocator, kilobytes(1) );
String to_str_entries = string_make_reserve( GlobalAllocator, kilobytes(1) );
String to_keyword_str_entries = string_make_reserve( GlobalAllocator, kilobytes(1) );
@ -91,10 +93,12 @@ CodeBody gen_ecode( char const* path, bool use_c_definition = false )
CodeBody gen_eoperator( char const* path, bool use_c_definition = false )
{
CSV_Columns2 csv_enum = parse_csv_two_columns(GlobalAllocator, path);
FixedArena_16KB scratch; fixed_arena_init(& scratch);
AllocatorInfo scratch_info = fixed_arena_allocator_info(& scratch);
String enum_entries = string_make_reserve( GlobalAllocator, kilobytes(1) );
String to_str_entries = string_make_reserve( GlobalAllocator, kilobytes(1) );
CSV_Columns2 csv_enum = parse_csv_two_columns( scratch_info, path );
String enum_entries = string_make_reserve( GlobalAllocator, 32 );
String to_str_entries = string_make_reserve( GlobalAllocator, 32 );
for (usize idx = 0; idx < array_num(csv_enum.Col_1); idx++) {
char const* enum_str = csv_enum.Col_1[idx].string;
@ -175,10 +179,12 @@ CodeBody gen_eoperator( char const* path, bool use_c_definition = false )
CodeBody gen_especifier( char const* path, bool use_c_definition = false )
{
CSV_Columns2 csv_enum = parse_csv_two_columns(GlobalAllocator, path);
FixedArena_16KB scratch; fixed_arena_init(& scratch);
AllocatorInfo scratch_info = fixed_arena_allocator_info(& scratch);
String enum_entries = string_make_reserve( GlobalAllocator, kilobytes(1) );
String to_str_entries = string_make_reserve( GlobalAllocator, kilobytes(1) );
CSV_Columns2 csv_enum = parse_csv_two_columns( scratch_info, path );
String enum_entries = string_make_reserve( scratch_info, kilobytes(1) );
String to_str_entries = string_make_reserve( scratch_info, kilobytes(1) );
for (usize idx = 0; idx < array_num(csv_enum.Col_1); idx++)
{
@ -314,31 +320,29 @@ CodeBody gen_especifier( char const* path, bool use_c_definition = false )
CodeBody gen_etoktype( char const* etok_path, char const* attr_path, bool use_c_definition = false )
{
char scratch_mem[kilobytes(16)];
Arena scratch = arena_init_from_memory( scratch_mem, sizeof(scratch_mem) );
AllocatorInfo scratch_info = arena_allocator_info(& scratch);
FixedArena_64KB scratch; fixed_arena_init(& scratch);
AllocatorInfo scratch_info = fixed_arena_allocator_info(& scratch);
FileContents enum_content = file_read_contents( scratch_info, file_zero_terminate, etok_path );
CSV_Object csv_enum_nodes;
csv_parse( &csv_enum_nodes, rcast(char*, enum_content.data), GlobalAllocator, false );
csv_parse( &csv_enum_nodes, rcast(char*, enum_content.data), scratch_info, false );
FileContents attrib_content = file_read_contents( scratch_info, file_zero_terminate, attr_path );
CSV_Object csv_attr_nodes;
csv_parse( &csv_attr_nodes, rcast(char*, attrib_content.data), GlobalAllocator, false );
csv_parse( &csv_attr_nodes, rcast(char*, attrib_content.data), scratch_info, false );
Array<ADT_Node> enum_strs = csv_enum_nodes.nodes[0].nodes;
Array<ADT_Node> enum_str_strs = csv_enum_nodes.nodes[1].nodes;
Array<ADT_Node> attribute_strs = csv_attr_nodes.nodes[0].nodes;
Array<ADT_Node> attribute_str_strs = csv_attr_nodes.nodes[1].nodes;
String enum_entries = string_make_reserve( GlobalAllocator, kilobytes(2) );
String to_str_entries = string_make_reserve( GlobalAllocator, kilobytes(4) );
String attribute_entries = string_make_reserve( GlobalAllocator, kilobytes(2) );
String to_str_attributes = string_make_reserve( GlobalAllocator, kilobytes(4) );
String attribute_define_entries = string_make_reserve( GlobalAllocator, kilobytes(4) );
String enum_entries = string_make_reserve( scratch_info, kilobytes(2) );
String to_str_entries = string_make_reserve( scratch_info, kilobytes(4) );
String attribute_entries = string_make_reserve( scratch_info, kilobytes(2) );
String to_str_attributes = string_make_reserve( scratch_info, kilobytes(4) );
String attribute_define_entries = string_make_reserve( scratch_info, kilobytes(4) );
for (usize idx = 0; idx < array_num(enum_strs); idx++)
{

View File

@ -22,7 +22,6 @@ void clang_format_file( char const* path, char const* style_path )
{
GEN_ASSERT_NOT_NULL(path);
String resolved_path = string_make_strc(GlobalAllocator, to_strc_from_c_str(path));
String style_arg;
if (style_path) {
style_arg = string_make_strc(GlobalAllocator, txt("-style=file:"));
@ -38,10 +37,7 @@ void clang_format_file( char const* path, char const* style_path )
string_append_strc( & command, cf_verbose );
string_append_string( & command, style_arg );
string_append_string( & command, resolved_path );
log_fmt("\tRunning clang-format:\n");
system( command );
log_fmt("\tclang-format finished formatting.\n");
}
// Will refactor a file with the given script at the provided path.
@ -53,16 +49,12 @@ void refactor_file( char const* path, char const* refactor_script )
GEN_ASSERT_NOT_NULL(refactor_script);
String command = string_make_strc(GlobalAllocator, txt("refactor "));
string_append_strc( & command, txt("-debug ") );
// 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");
#undef refactor
log_fmt("\n");
}
// Does either of the above or both to the provided code.
@ -71,7 +63,7 @@ Code code_refactor_and_format( Code code, char const* scratch_path, char const*
{
GEN_ASSERT(code);
GEN_ASSERT_NOT_NULL(scratch_path);
Builder scratch_file = builder_open("gen/scratch.hpp");
Builder scratch_file = builder_open( scratch_path );
builder_print( & scratch_file, code);
builder_write(& scratch_file);
@ -83,6 +75,6 @@ Code code_refactor_and_format( Code code, char const* scratch_path, char const*
}
Code result = scan_file( scratch_path );
remove("gen/scratch.hpp");
::remove(scratch_path);
return result;
}

View File

@ -3,22 +3,16 @@
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
#define GEN_ENFORCE_STRONG_CODE_TYPES
#define GEN_EXPOSE_BACKEND
#include "../project/gen.cpp"
#include "gen.cpp"
#include "helpers/push_ignores.inline.hpp"
#include "helpers/helper.hpp"
#include <stdlib.h>
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 "components/memory.fixed_arena.hpp"
#include "components/misc.hpp"
#include "components/containers.array.hpp"
@ -52,47 +46,22 @@ constexpr StrC implementation_guard_end = txt(R"(
#pragma endregion GENCPP IMPLEMENTATION GUARD
)");
void CHANGE_format_file( char const* path )
{
String resolved_path = String::make(GlobalAllocator, to_strc_from_c_str(path));
#define path_refactor_script "./c_library.refactor"
#define path_format_style "../scripts/.clang-format "
#define scratch_file "gen/scratch.hpp"
#define path_base "../base/"
String style_arg = String::make(GlobalAllocator, txt("-style=file:"));
style_arg.append("../scripts/.clang-format ");
// Need to execute clang format on the generated file to get it to match the original.
#define clang_format "clang-format "
#define cf_format_inplace "-i "
#define cf_verbose "-verbose "
String command = String::make( GlobalAllocator, clang_format );
command.append( cf_format_inplace );
command.append( cf_verbose );
command.append( style_arg );
command.append( resolved_path );
log_fmt("\tRunning clang-format on file:\n");
system( command );
log_fmt("\tclang-format finished reformatting.\n");
#undef cf_cmd
#undef cf_format_inplace
#undef cf_style
#undef cf_verbse
Code refactor( Code code ) {
return code_refactor_and_format(code, scratch_file, path_refactor_script, nullptr );
}
Code CHANGE_format_code_to_untyped( Code code )
{
Builder ecode_file_temp = Builder::open("gen/scratch.hpp");
ecode_file_temp.print(code);
ecode_file_temp.write();
format_file("gen/scratch.hpp");
Code result = scan_file( "gen/scratch.hpp" );
remove("gen/scratch.hpp");
return result;
Code refactor_and_format( Code code ) {
return code_refactor_and_format(code, scratch_file, path_refactor_script, path_format_style );
}
constexpr bool helper_use_c_definition = true;
int gen_main()
{
#define project_dir "../project/"
gen::init();
PreprocessorDefines.append(txt("GEN_API_C_BEGIN"));
@ -109,22 +78,22 @@ int gen_main()
PreprocessorDefines.append(txt("GEN_PARAM_DEFAULT"));
//PreprocessorDefines.append(txt("GEN_EXECUTION_EXPRESSION_SUPPORT"));
Code push_ignores = scan_file( project_dir "helpers/push_ignores.inline.hpp" );
Code pop_ignores = scan_file( project_dir "helpers/pop_ignores.inline.hpp" );
Code push_ignores = scan_file( path_base "helpers/push_ignores.inline.hpp" );
Code pop_ignores = scan_file( path_base "helpers/pop_ignores.inline.hpp" );
Code c_library_header_start = scan_file( "components/header_start.hpp" );
// Header Content: Reflection and Generation
#pragma region Resolve Dependencies
Code header_platform = scan_file( project_dir "dependencies/platform.hpp" );
Code header_macros = scan_file( project_dir "dependencies/macros.hpp" );
Code header_basic_types = scan_file( project_dir "dependencies/basic_types.hpp" );
Code header_debug = scan_file( project_dir "dependencies/debug.hpp" );
Code header_string_ops = scan_file( project_dir "dependencies/string_ops.hpp" );
Code header_hashing = scan_file( project_dir "dependencies/hashing.hpp" );
Code header_timing = scan_file( project_dir "dependencies/timing.hpp" );
Code header_platform = scan_file( path_base "dependencies/platform.hpp" );
Code header_macros = scan_file( path_base "dependencies/macros.hpp" );
Code header_basic_types = scan_file( path_base "dependencies/basic_types.hpp" );
Code header_debug = scan_file( path_base "dependencies/debug.hpp" );
Code header_string_ops = scan_file( path_base "dependencies/string_ops.hpp" );
Code header_hashing = scan_file( path_base "dependencies/hashing.hpp" );
Code header_timing = scan_file( path_base "dependencies/timing.hpp" );
CodeBody parsed_header_memory = parse_file( project_dir "dependencies/memory.hpp" );
CodeBody parsed_header_memory = parse_file( path_base "dependencies/memory.hpp" );
CodeBody header_memory = def_body(CT_Global_Body);
for ( Code entry = parsed_header_memory.begin(); entry != parsed_header_memory.end(); ++ entry ) switch (entry->Type)
{
@ -168,6 +137,7 @@ int gen_main()
CodeTemplate tmpl = cast(CodeTemplate, entry);
if ( tmpl->Declaration->Name.contains(txt("swap")))
{
log_fmt("SWAPPED");
CodeBody macro_swap = parse_global_body( txt(R"(
#define swap( a, b ) \
do \
@ -253,7 +223,7 @@ do \
break;
}
CodeBody parsed_header_printing = parse_file( project_dir "dependencies/printing.hpp" );
CodeBody parsed_header_printing = parse_file( path_base "dependencies/printing.hpp" );
CodeBody header_printing = def_body(CT_Global_Body);
for ( Code entry = parsed_header_printing.begin(); entry != parsed_header_printing.end(); ++ entry ) switch (entry->Type)
{
@ -284,7 +254,7 @@ do \
Code array_ssize = gen_array(txt("gen_ssize"), txt("Array_gen_ssize"));
Code array_string_cached = gen_array(txt("gen_StringCached"), txt("Array_gen_StringCached"));
CodeBody parsed_header_strings = parse_file( project_dir "dependencies/strings.hpp" );
CodeBody parsed_header_strings = parse_file( path_base "dependencies/strings.hpp" );
CodeBody header_strings = def_body(CT_Global_Body);
for ( Code entry = parsed_header_strings.begin(); entry != parsed_header_strings.end(); ++ entry ) switch (entry->Type)
{
@ -390,7 +360,7 @@ do \
CodeBody array_u8 = gen_array(txt("gen_u8"), txt("Array_gen_u8"));
CodeBody parsed_header_filesystem = parse_file( project_dir "dependencies/filesystem.hpp" );
CodeBody parsed_header_filesystem = parse_file( path_base "dependencies/filesystem.hpp" );
CodeBody header_filesystem = def_body(CT_Global_Body);
for ( Code entry = parsed_header_filesystem.begin(); entry != parsed_header_filesystem.end(); ++ entry ) switch (entry->Type)
{
@ -449,7 +419,7 @@ do \
CodeBody array_adt_node = gen_array(txt("gen_ADT_Node"), txt("Array_gen_ADT_Node"));
CodeBody parsed_header_parsing = parse_file( project_dir "dependencies/parsing.hpp" );
CodeBody parsed_header_parsing = parse_file( path_base "dependencies/parsing.hpp" );
CodeBody header_parsing = def_body(CT_Global_Body);
for ( Code entry = parsed_header_parsing.begin(); entry != parsed_header_parsing.end(); ++ entry ) switch (entry->Type)
{
@ -544,11 +514,11 @@ do \
// Only has operator overload definitions that C doesn't need.
// CodeBody ast_inlines = gen_ast_inlines();
CodeBody ecode = gen_ecode ( project_dir "enums/ECodeTypes.csv", helper_use_c_definition );
CodeBody eoperator = gen_eoperator ( project_dir "enums/EOperator.csv", helper_use_c_definition );
CodeBody especifier = gen_especifier( project_dir "enums/ESpecifier.csv", helper_use_c_definition );
CodeBody ecode = gen_ecode ( path_base "enums/ECodeTypes.csv", helper_use_c_definition );
CodeBody eoperator = gen_eoperator ( path_base "enums/EOperator.csv", helper_use_c_definition );
CodeBody especifier = gen_especifier( path_base "enums/ESpecifier.csv", helper_use_c_definition );
CodeBody parsed_types = parse_file( project_dir "components/types.hpp" );
CodeBody parsed_types = parse_file( path_base "components/types.hpp" );
CodeBody types = def_body(CT_Global_Body);
for ( Code entry = parsed_types.begin(); entry != parsed_types.end(); ++ entry ) switch(entry->Type)
{
@ -620,7 +590,7 @@ do \
// Used to track which functions need generic selectors.
Array(CodeFn) code_c_interface = array_init_reserve<CodeFn>(GlobalAllocator, 16);
CodeBody parsed_ast = parse_file( project_dir "components/ast.hpp" );
CodeBody parsed_ast = parse_file( path_base "components/ast.hpp" );
CodeBody ast = def_body(CT_Global_Body);
for ( Code entry = parsed_ast.begin(); entry != parsed_ast.end(); ++ entry ) switch (entry->Type)
{
@ -789,7 +759,7 @@ R"(#define AST_ArrSpecs_Cap \
txt("CodeVar"),
};
CodeBody parsed_code_types = parse_file( project_dir "components/code_types.hpp" );
CodeBody parsed_code_types = parse_file( path_base "components/code_types.hpp" );
CodeBody code_types = def_body(CT_Global_Body);
for ( Code entry = parsed_code_types.begin(); entry != parsed_code_types.end(); ++ entry ) switch( entry->Type )
{
@ -891,7 +861,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
break;
}
CodeBody parsed_ast_types = parse_file( project_dir "components/ast_types.hpp" );
CodeBody parsed_ast_types = parse_file( path_base "components/ast_types.hpp" );
CodeBody ast_types = def_body(CT_Global_Body);
for ( Code entry = parsed_ast_types.begin(); entry != parsed_ast_types.end(); ++ entry ) switch( entry->Type )
{
@ -922,7 +892,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
StrC cpp_size = to_strc_from_c_str(conversion_buf);
union_entry->ValueType->ArrExpr = untyped_str( cpp_size );
union_entry->InlineCmt = untyped_str(token_fmt("arr_exp", arr_exp,
"// Had to hardcode _PAD_ because (<arr_exp>) was 67 bytes in C (Injected C++ size_of(AST_<Type>::_PAD_) from C++ side)\n"
"// Had to hardcode _PAD_ because (<arr_exp>) was 67 bytes in C\n"
));
}
}
@ -938,7 +908,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
break;
}
CodeBody parsed_interface = parse_file( project_dir "components/interface.hpp" );
CodeBody parsed_interface = parse_file( path_base "components/interface.hpp" );
CodeBody interface = def_body(CT_Global_Body);
for ( Code entry = parsed_interface.begin(); entry != parsed_interface.end(); ++ entry ) switch( entry->Type )
{
@ -1027,7 +997,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
break;
}
CodeBody parsed_inlines = parse_file( project_dir "components/inlines.hpp" );
CodeBody parsed_inlines = parse_file( path_base "components/inlines.hpp" );
CodeBody inlines = def_body(CT_Global_Body);
for ( Code entry = parsed_inlines.begin(); entry != parsed_inlines.end(); ++ entry ) switch( entry->Type )
{
@ -1062,7 +1032,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
break;
}
CodeBody parsed_header_builder = parse_file( project_dir "auxillary/builder.hpp" );
CodeBody parsed_header_builder = parse_file( path_base "auxillary/builder.hpp" );
CodeBody header_builder = def_body(CT_Global_Body);
for ( Code entry = parsed_header_builder.begin(); entry != parsed_header_builder.end(); ++ entry ) switch( entry->Type )
{
@ -1120,7 +1090,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
}
s32 idx = 0;
CodeBody parsed_header_end = parse_file( project_dir "components/header_end.hpp" );
CodeBody parsed_header_end = parse_file( path_base "components/header_end.hpp" );
CodeBody header_end = def_body(CT_Global_Body);
for ( Code entry = parsed_header_end.begin(); entry != parsed_header_end.end(); ++ entry, ++ idx ) switch( entry->Type )
{
@ -1158,15 +1128,15 @@ R"(#define <interface_name>( code ) _Generic( (code), \
// Source Content : Reflection and Generation
#pragma region Resolve Dependencies
Code src_impl_start = scan_file( project_dir "dependencies/src_start.cpp" );
Code src_debug = scan_file( project_dir "dependencies/debug.cpp" );
Code src_string_ops = scan_file( project_dir "dependencies/string_ops.cpp" );
Code src_printing = scan_file( project_dir "dependencies/printing.cpp" );
Code src_memory = scan_file( project_dir "dependencies/memory.cpp" );
Code src_hashing = scan_file( project_dir "dependencies/hashing.cpp" );
Code src_strings = scan_file( project_dir "dependencies/strings.cpp" );
Code src_filesystem = scan_file( project_dir "dependencies/filesystem.cpp" );
Code src_timing = scan_file( project_dir "dependencies/timing.cpp" );
Code src_dep_start = scan_file( path_base "dependencies/src_start.cpp" );
Code src_debug = scan_file( path_base "dependencies/debug.cpp" );
Code src_string_ops = scan_file( path_base "dependencies/string_ops.cpp" );
Code src_printing = scan_file( path_base "dependencies/printing.cpp" );
Code src_memory = scan_file( path_base "dependencies/memory.cpp" );
Code src_hashing = scan_file( path_base "dependencies/hashing.cpp" );
Code src_strings = scan_file( path_base "dependencies/strings.cpp" );
Code src_filesystem = scan_file( path_base "dependencies/filesystem.cpp" );
Code src_timing = scan_file( path_base "dependencies/timing.cpp" );
#pragma endregion Resolve Dependencies
#pragma region Resolve Components
@ -1174,14 +1144,15 @@ R"(#define <interface_name>( code ) _Generic( (code), \
CodeBody array_pool = gen_array(txt("gen_Pool"), txt("Array_gen_Pool"));
CodeBody array_token = gen_array(txt("gen_Token"), txt("Array_gen_Token"));
Code src_static_data = scan_file( project_dir "components/static_data.cpp" );
Code src_ast_case_macros = scan_file( project_dir "components/ast_case_macros.cpp" );
Code src_code_serialization = scan_file( project_dir "components/code_serialization.cpp" );
Code src_interface = scan_file( project_dir "components/interface.cpp" );
Code src_parsing_interface = scan_file( project_dir "components/interface.parsing.cpp" );
Code src_untyped = scan_file( project_dir "components/interface.untyped.cpp" );
Code src_start = scan_file( "components/src_start.c" );
Code src_static_data = scan_file( path_base "components/static_data.cpp" );
Code src_ast_case_macros = scan_file( path_base "components/ast_case_macros.cpp" );
Code src_code_serialization = scan_file( path_base "components/code_serialization.cpp" );
Code src_interface = scan_file( path_base "components/interface.cpp" );
Code src_parsing_interface = scan_file( path_base "components/interface.parsing.cpp" );
Code src_untyped = scan_file( path_base "components/interface.untyped.cpp" );
CodeBody parsed_src_ast = parse_file( project_dir "components/ast.cpp" );
CodeBody parsed_src_ast = parse_file( path_base "components/ast.cpp" );
CodeBody src_ast = def_body(CT_Global_Body);
for ( Code entry = parsed_src_ast.begin(); entry != parsed_src_ast.end(); ++ entry ) switch( entry ->Type )
{
@ -1216,7 +1187,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
break;
}
CodeBody parsed_src_upfront = parse_file( project_dir "components/interface.upfront.cpp" );
CodeBody parsed_src_upfront = parse_file( path_base "components/interface.upfront.cpp" );
CodeBody src_upfront = def_body(CT_Global_Body);
for ( Code entry = parsed_src_upfront.begin(); entry != parsed_src_upfront.end(); ++ entry ) switch( entry ->Type )
{
@ -1269,7 +1240,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
break;
}
CodeBody parsed_src_lexer = parse_file( project_dir "components/lexer.cpp" );
CodeBody parsed_src_lexer = parse_file( path_base "components/lexer.cpp" );
CodeBody src_lexer = def_body(CT_Global_Body);
for ( Code entry = parsed_src_lexer.begin(); entry != parsed_src_lexer.end(); ++ entry ) switch( entry ->Type )
{
@ -1363,7 +1334,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
CodeBody array_code_typename = gen_array(txt("gen_CodeTypename"), txt("Array_gen_CodeTypename"));
CodeBody parsed_src_parser = parse_file( project_dir "components/parser.cpp" );
CodeBody parsed_src_parser = parse_file( path_base "components/parser.cpp" );
CodeBody src_parser = def_body(CT_Global_Body);
for ( Code entry = parsed_src_parser.begin(); entry != parsed_src_parser.end(); ++ entry ) switch( entry ->Type )
{
@ -1426,10 +1397,76 @@ R"(#define <interface_name>( code ) _Generic( (code), \
containers.append( fmt_newline);
}
// Printing : Everything below is jsut serialization & formatting ot a single-file.
// Printing : Everything below is jsut serialization & formatting to a singleheader file & segmented set of files
#pragma region Refactored / Formatted
Code r_header_platform = refactor(header_platform);
Code r_header_macros = refactor(header_macros);
Code r_header_basic_types = refactor(header_basic_types);
Code r_header_debug = refactor(header_debug);
Code rf_header_memory = refactor_and_format(header_memory);
Code rf_header_printing = refactor_and_format(header_printing);
Code r_header_string_ops = refactor(header_string_ops);
Code rf_containers = refactor_and_format(containers);
Code r_header_hashing = refactor(header_hashing);
Code rf_header_strings = refactor_and_format(header_strings);
Code rf_header_filesystem = refactor_and_format(header_filesystem);
Code r_header_timing = refactor(header_timing);
Code rf_header_parsing = refactor_and_format(header_parsing);
Code rf_types = refactor_and_format(types);
Code rf_ecode = refactor_and_format(ecode);
Code rf_eoperator = refactor_and_format(eoperator);
Code rf_especifier = refactor_and_format(especifier);
Code rf_ast = refactor_and_format(ast);
Code rf_code_types = refactor_and_format(code_types);
Code rf_ast_types = refactor_and_format(ast_types);
Code rf_interface = refactor_and_format(interface);
Code rf_inlines = refactor_and_format(inlines);
Code rf_array_string_cached = refactor_and_format(array_string_cached);
Code rf_header_end = refactor_and_format(header_end);
Code rf_header_builder = refactor_and_format(header_builder);
Code rf_header_scanner = refactor_and_format( scan_file( path_base "auxillary/scanner.hpp" ));
Code r_src_dep_start = refactor(src_dep_start);
Code r_src_debug = refactor(src_debug);
Code r_src_string_ops = refactor(src_string_ops);
Code r_src_printing = refactor(src_printing);
Code r_src_memory = refactor(src_memory);
Code r_src_hashing = refactor(src_hashing);
Code r_src_strings = refactor(src_strings);
Code r_src_filesystem = refactor(src_filesystem);
Code r_src_timing = refactor(src_timing);
Code rf_src_parsing = refactor_and_format( scan_file( path_base "dependencies/parsing.cpp" ));
Code rf_array_arena = refactor_and_format(array_arena);
Code rf_array_pool = refactor_and_format(array_pool);
Code r_src_static_data = refactor(src_static_data);
Code r_src_ast_case_macros = refactor(src_ast_case_macros);
Code r_src_ast = refactor(src_ast);
Code r_src_code_serialization = refactor(src_code_serialization);
Code r_src_interface = refactor(src_interface);
Code r_src_upfront = refactor_and_format(src_upfront);
Code r_src_lexer = refactor_and_format(src_lexer);
Code rf_array_code_typename = refactor_and_format(array_code_typename);
Code rf_src_parser = refactor_and_format(src_parser);
Code r_src_parsing = refactor(src_parsing_interface);
Code r_src_untyped = refactor(src_untyped);
CodeBody etoktype = gen_etoktype( path_base "enums/ETokType.csv", path_base "enums/AttributeTokens.csv", helper_use_c_definition );
Code rf_etoktype = refactor_and_format(etoktype);
Code rf_src_builder = refactor_and_format( scan_file( path_base "auxillary/builder.cpp" ));
Code rf_src_scanner = refactor_and_format( scan_file( path_base "auxillary/scanner.cpp" ));
#pragma endregion Refactored / Formatted
#pragma region Singleheader
Builder
header = Builder::open( "gen/gen.h" );
header = Builder::open( "gen/gen_singleheader.h" );
header.print_fmt( generation_notice );
header.print_fmt("#pragma once\n\n");
header.print( push_ignores );
@ -1440,25 +1477,22 @@ R"(#define <interface_name>( code ) _Generic( (code), \
{
#pragma region Print Dependencies
header.print_fmt( roll_own_dependencies_guard_start );
header.print( header_platform );
header.print( r_header_platform );
header.print_fmt( "\nGEN_NS_BEGIN\n" );
header.print( header_macros );
header.print( header_basic_types );
header.print( header_debug );
header.print( format_code_to_untyped(header_memory) );
header.print( format_code_to_untyped(header_printing));
header.print( header_string_ops );
header.print( r_header_macros );
header.print( r_header_basic_types );
header.print( r_header_debug );
header.print( rf_header_memory );
header.print( rf_header_printing);
header.print( r_header_string_ops );
header.print( fmt_newline);
header.print( format_code_to_untyped(containers));
header.print( header_hashing );
header.print( format_code_to_untyped(header_strings));
header.print( format_code_to_untyped(header_filesystem));
header.print( header_timing );
header.print_fmt( "\n#pragma region Parsing\n" );
header.print( format_code_to_untyped(header_parsing) );
header.print_fmt( "#pragma endregion Parsing\n" );
header.print( rf_containers);
header.print( r_header_hashing );
header.print( rf_header_strings);
header.print( rf_header_filesystem);
header.print( r_header_timing );
header.print(rf_header_parsing );
header.print_fmt( "\nGEN_NS_END\n" );
header.print_fmt( roll_own_dependencies_guard_end );
@ -1471,36 +1505,34 @@ R"(#define <interface_name>( code ) _Generic( (code), \
header.print_fmt( "GEN_API_C_BEGIN\n\n" );
header.print_fmt("#pragma region Types\n");
header.print( format_code_to_untyped(types) );
header.print( rf_types );
header.print( fmt_newline );
header.print( format_code_to_untyped( ecode ));
header.print( rf_ecode );
header.print( fmt_newline );
header.print( format_code_to_untyped( eoperator ));
header.print( rf_eoperator );
header.print( fmt_newline );
header.print( format_code_to_untyped( especifier ));
header.print( rf_especifier );
header.print_fmt("#pragma endregion Types\n\n");
header.print_fmt("#pragma region AST\n");
header.print( format_code_to_untyped(ast) );
header.print( format_code_to_untyped(code_types) );
header.print( format_code_to_untyped(ast_types) );
header.print( rf_ast );
header.print( rf_code_types );
header.print( rf_ast_types );
header.print_fmt("\n#pragma endregion AST\n");
header.print( format_code_to_untyped(interface) );
header.print( rf_interface );
header.print(fmt_newline);
header.print_fmt("#pragma region Inlines\n");
header.print( format_code_to_untyped(inlines) );
header.print( rf_inlines );
header.print_fmt("#pragma endregion Inlines\n");
header.print(fmt_newline);
header.print( format_code_to_untyped(array_string_cached));
header.print( rf_array_string_cached );
header.print( format_code_to_untyped(header_end) );
header.print_fmt( "\n#pragma region Builder\n" );
header.print( format_code_to_untyped(header_builder) );
header.print_fmt( "\n#pragma endregion Builder\n" );
header.print( rf_header_end );
header.print( rf_header_builder );
header.print( rf_header_scanner );
header.print_fmt( "\nGEN_API_C_END\n" );
header.print_fmt( "GEN_NS_END\n\n" );
@ -1516,65 +1548,55 @@ R"(#define <interface_name>( code ) _Generic( (code), \
header.print_fmt( "GEN_NS_BEGIN\n");
header.print_fmt( "GEN_API_C_BEGIN\n" );
header.print( src_impl_start );
header.print( src_debug );
header.print( src_string_ops );
header.print( src_printing );
header.print( src_memory );
header.print( src_hashing );
header.print( src_strings );
header.print( src_filesystem );
header.print( src_timing );
header.print_fmt( "\n#pragma region Parsing\n" );
header.print( scan_file( project_dir "dependencies/parsing.cpp" ) );
header.print_fmt( "\n#pragma endregion Parsing\n\n" );
header.print( r_src_dep_start );
header.print( r_src_debug );
header.print( r_src_string_ops );
header.print( r_src_printing );
header.print( r_src_memory );
header.print( r_src_hashing );
header.print( r_src_strings );
header.print( r_src_filesystem );
header.print( r_src_timing );
header.print( rf_src_parsing );
header.print_fmt( "GEN_NS_END\n");
header.print_fmt( roll_own_dependencies_guard_end );
#pragma endregion Print Dependencies
#pragma region Print Components
CodeBody etoktype = gen_etoktype( project_dir "enums/ETokType.csv", project_dir "enums/AttributeTokens.csv", helper_use_c_definition );
header.print_fmt( "\nGEN_NS_BEGIN\n");
header.print( fmt_newline);
header.print( format_code_to_untyped(array_arena));
header.print( rf_array_arena );
header.print( fmt_newline);
header.print( format_code_to_untyped(array_pool));
header.print( rf_array_pool);
header.print( src_static_data );
header.print( r_src_static_data );
header.print( fmt_newline);
header.print_fmt( "#pragma region AST\n\n" );
header.print( src_ast_case_macros );
header.print( src_ast );
header.print( src_code_serialization );
header.print( r_src_ast_case_macros );
header.print( r_src_ast );
header.print( r_src_code_serialization );
header.print_fmt( "#pragma endregion AST\n\n" );
header.print_fmt( "#pragma region Interface\n" );
header.print( src_interface );
header.print( format_code_to_untyped(src_upfront) );
header.print( r_src_interface );
header.print( r_src_upfront );
header.print_fmt( "\n#pragma region Parsing\n\n" );
header.print( format_code_to_untyped(etoktype) );
header.print( format_code_to_untyped(src_lexer) );
header.print( rf_etoktype );
header.print( r_src_lexer );
header.print( fmt_newline);
header.print( format_code_to_untyped(array_code_typename));
header.print( rf_array_code_typename );
header.print( fmt_newline);
header.print( format_code_to_untyped(src_parser) );
header.print( src_parsing_interface );
header.print( rf_src_parser );
header.print( r_src_parsing );
header.print_fmt( "\n#pragma endregion Parsing\n" );
header.print( src_untyped );
header.print( r_src_untyped );
header.print_fmt( "\n#pragma endregion Interface\n\n");
header.print_fmt( "#pragma region Builder\n" );
header.print( scan_file( project_dir "auxillary/builder.cpp" ) );
header.print_fmt( "#pragma endregion Builder\n\n" );
header.print_fmt( "\n#pragma region Scanner\n" );
header.print( scan_file( project_dir "auxillary/scanner.hpp" ) );
header.print_fmt( "#pragma endregion Scanner\n\n" );
header.print( rf_src_builder );
header.print( rf_src_scanner );
header.print_fmt( "GEN_API_C_END\n" );
#pragma endregion Print Components
@ -1583,8 +1605,148 @@ R"(#define <interface_name>( code ) _Generic( (code), \
}
header.print( pop_ignores );
header.write();
#pragma endregion Singleheader
#pragma region Segmented
// gen_dep.h
{
Builder header = Builder::open( "gen/gen.dep.h");
builder_print_fmt( header, generation_notice );
builder_print_fmt( header, "// This file is intended to be included within gen.hpp (There is no pragma diagnostic ignores)\n" );
header.print( r_header_platform );
header.print_fmt( "\nGEN_NS_BEGIN\n" );
header.print( r_header_macros );
header.print( r_header_basic_types );
header.print( r_header_debug );
header.print( rf_header_memory );
header.print( rf_header_printing);
header.print( r_header_string_ops );
header.print( fmt_newline);
header.print( rf_containers);
header.print( r_header_hashing );
header.print( rf_header_strings);
header.print( rf_header_filesystem);
header.print( r_header_timing );
header.print(rf_header_parsing );
header.print_fmt( "\nGEN_NS_END\n" );
header.write();
}
// gen_dep.c
{
Builder src = Builder::open( "gen/gen.dep.c" );
src.print_fmt( "GEN_NS_BEGIN\n");
src.print_fmt( "GEN_API_C_BEGIN\n" );
builder_print_fmt(src, generation_notice );
builder_print_fmt( src, "// This file is intended to be included within gen.cpp (There is no pragma diagnostic ignores)\n" );
src.print( r_src_dep_start );
src.print( r_src_debug );
src.print( r_src_string_ops );
src.print( r_src_printing );
src.print( r_src_memory );
src.print( r_src_hashing );
src.print( r_src_strings );
src.print( r_src_filesystem );
src.print( r_src_timing );
src.print( rf_src_parsing );
src.print_fmt( "GEN_NS_END\n");
src.write();
}
// gen.h
{
Builder header = builder_open( "gen/gen.h" );
builder_print_fmt( header, generation_notice );
builder_print_fmt( header, "#pragma once\n\n" );
builder_print( header, push_ignores );
header.print( c_library_header_start );
header.print( scan_file( "components/header_seg_includes.h" ));
header.print( fmt_newline );
header.print_fmt( "GEN_NS_BEGIN\n" );
header.print_fmt( "GEN_API_C_BEGIN\n\n" );
header.print_fmt("#pragma region Types\n");
header.print( rf_types );
header.print( fmt_newline );
header.print( rf_ecode );
header.print( fmt_newline );
header.print( rf_eoperator );
header.print( fmt_newline );
header.print( rf_especifier );
header.print_fmt("#pragma endregion Types\n\n");
header.print_fmt("#pragma region AST\n");
header.print( rf_ast );
header.print( rf_code_types );
header.print( rf_ast_types );
header.print_fmt("\n#pragma endregion AST\n");
header.print( rf_interface );
header.print(fmt_newline);
header.print_fmt("#pragma region Inlines\n");
header.print( rf_inlines );
header.print_fmt("#pragma endregion Inlines\n");
header.print(fmt_newline);
header.print( rf_array_string_cached );
header.print( rf_header_end );
header.print( rf_header_builder );
header.print( rf_header_scanner );
header.print_fmt( "\nGEN_API_C_END\n" );
header.print_fmt( "GEN_NS_END\n\n" );
builder_print( header, pop_ignores );
builder_write(header);
}
// gen.c
{
Builder src = Builder::open( "gen/gen.c" );
builder_print_fmt( src, generation_notice );
builder_print( src, push_ignores );
builder_print( src, src_start );
src.print_fmt( "\nGEN_NS_BEGIN\n");
src.print( fmt_newline);
src.print( rf_array_arena );
src.print( fmt_newline);
src.print( rf_array_pool);
src.print( r_src_static_data );
src.print( fmt_newline);
src.print_fmt( "#pragma region AST\n\n" );
src.print( r_src_ast_case_macros );
src.print( r_src_ast );
src.print( r_src_code_serialization );
src.print_fmt( "#pragma endregion AST\n\n" );
src.print_fmt( "#pragma region Interface\n" );
src.print( r_src_interface );
src.print( r_src_upfront );
src.print_fmt( "\n#pragma region Parsing\n\n" );
src.print( rf_etoktype );
src.print( r_src_lexer );
src.print( fmt_newline);
src.print( rf_array_code_typename );
src.print( fmt_newline);
src.print( rf_src_parser );
src.print( r_src_parsing );
src.print_fmt( "\n#pragma endregion Parsing\n" );
src.print( r_src_untyped );
src.print_fmt( "\n#pragma endregion Interface\n\n");
src.print( rf_src_builder );
src.print( rf_src_scanner );
src.print_fmt( "GEN_API_C_END\n" );
src.write();
}
#pragma endregion Segmented
gen::deinit();
return 0;
#undef project_dir
}

View File

@ -56,25 +56,29 @@ word hash, gen_hash
// Basic Types
word u8, gen_u8
word s8, gen_s8
word u16, gen_u16
word s16, gen_s16
word u32, gen_u32
word s32, gen_s32
word u64, gen_u64
word s64, gen_s64
word usize, gen_usize
word ssize, gen_ssize
word sptr, gen_sptr
word uptr, gen_uptr
word f32, gen_f32
word f64, gen_f64
word b8, gen_b8
word b16, gen_b16
word b32, gen_b32
word mem_ptr, gen_mem_ptr
word mem_ptr_const, gen_mem_ptr_cnst
word u8, gen_u8
word s8, gen_s8
word u16, gen_u16
word s16, gen_s16
word u32, gen_u32
word s32, gen_s32
word u64, gen_u64
word s64, gen_s64
word usize, gen_usize
word ssize, gen_ssize
word sptr, gen_sptr
word uptr, gen_uptr
word f32, gen_f32
word f64, gen_f64
word b8, gen_b8
word b16, gen_b16
word b32, gen_b32
word mem_ptr, gen_mem_ptr
word mem_ptr_const, gen_mem_ptr_const
word to_uptr, gen_to_uptr
word to_sptr, gen_to_sptr
word to_mem_ptr, gen_to_mem_ptr
word to_mem_ptr_const, gen_to_mem_ptr_const
// Debug

View File

@ -1,6 +1,5 @@
#pragma once
#include "../project/gen.hpp"
#include "gen.hpp"
using namespace gen;

View File

@ -1,6 +1,5 @@
#pragma once
#include "../project/gen.hpp"
#include "gen.hpp"
#include "containers.array.hpp"
using namespace gen;

View File

@ -0,0 +1,9 @@
#if ! defined(GEN_DONT_ENFORCE_GEN_TIME_GUARD) && ! defined(GEN_TIME)
# error Gen.h : 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.h"
#endif

View File

@ -1,5 +1,5 @@
#pragma once
#include "../project/gen.hpp"
#include "gen.hpp"
using namespace gen;

View File

@ -1,5 +1,5 @@
#pragma once
#include "../project/gen.hpp"
#include "gen.hpp"
using namespace gen;

View File

@ -0,0 +1,11 @@
#if ! defined(GEN_DONT_ENFORCE_GEN_TIME_GUARD) && ! defined(GEN_TIME)
# error Gen.hpp : GEN_TIME not defined
#endif
#include "gen.h"
//! 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.c"
#endif

View File

@ -1,5 +1,5 @@
#define GEN_IMPLEMENTATION
#include "gen/gen.h"
#include "gen/gen.c"
int main()
{

View File

@ -1,11 +1,14 @@
// Includes are exposed to base directory
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
#define GEN_ENFORCE_STRONG_CODE_TYPES
#define GEN_EXPOSE_BACKEND
#define GEN_C_LIKE_CPP 1
#include "../base/gen.cpp"
#include "gen.cpp"
#include "helpers/push_ignores.inline.hpp"
#include <stdlib.h>
GEN_NS_BEGIN
#include "helpers/base_codegen.hpp"
#include "helpers/misc.hpp"
@ -19,9 +22,9 @@ constexpr char const* generation_notice =
#include <cstdlib> // for system()
constexpr char const* path_format_style = "../scripts/.clang-format ";
constexpr char const* scratch_file = "gen/scratch.hpp";
constexpr char const* path_base = "../base/";
#define path_format_style "../scripts/.clang-format "
#define scratch_file "gen/scratch.hpp"
#define path_base "../base/"
Code format( Code code ) {
return code_refactor_and_format(code, scratch_file, nullptr, path_format_style );
@ -31,25 +34,26 @@ int gen_main()
{
gen::init();
Code push_ignores = scan_file( path_base "helpers/push_ignores.inline.hpp" );
Code pop_ignores = scan_file( path_base "helpers/pop_ignores.inline.hpp" );
Code push_ignores = scan_file( (path_base "helpers/push_ignores.inline.hpp") );
Code pop_ignores = scan_file( (path_base "helpers/pop_ignores.inline.hpp") );
// gen_dep.hpp
{
Code platform = scan_file( "dependencies/platform.hpp" );
Code macros = scan_file( "dependencies/macros.hpp" );
Code basic_types = scan_file( "dependencies/basic_types.hpp" );
Code debug = scan_file( "dependencies/debug.hpp" );
Code memory = scan_file( "dependencies/memory.hpp" );
Code string_ops = scan_file( "dependencies/string_ops.hpp" );
Code printing = scan_file( "dependencies/printing.hpp" );
Code containers = scan_file( "dependencies/containers.hpp" );
Code hashing = scan_file( "dependencies/hashing.hpp" );
Code strings = scan_file( "dependencies/strings.hpp" );
Code filesystem = scan_file( "dependencies/filesystem.hpp" );
Code timing = scan_file( "dependencies/timing.hpp" );
Code platform = scan_file( path_base "dependencies/platform.hpp" );
Code macros = scan_file( path_base "dependencies/macros.hpp" );
Code basic_types = scan_file( path_base "dependencies/basic_types.hpp" );
Code debug = scan_file( path_base "dependencies/debug.hpp" );
Code memory = scan_file( path_base "dependencies/memory.hpp" );
Code string_ops = scan_file( path_base "dependencies/string_ops.hpp" );
Code printing = scan_file( path_base "dependencies/printing.hpp" );
Code containers = scan_file( path_base "dependencies/containers.hpp" );
Code hashing = scan_file( path_base "dependencies/hashing.hpp" );
Code strings = scan_file( path_base "dependencies/strings.hpp" );
Code filesystem = scan_file( path_base "dependencies/filesystem.hpp" );
Code timing = scan_file( path_base "dependencies/timing.hpp" );
Code parsing = scan_file( path_base "dependencies/parsing.hpp" );
Builder _header = builder_open("gen/gen.dep.hpp");
Builder _header = builder_open( "gen/gen.dep.hpp");
Builder* header = & _header;
builder_print_fmt( header, generation_notice );
builder_print_fmt( header, "// This file is intended to be included within gen.hpp (There is no pragma diagnostic ignores)\n" );
@ -67,6 +71,7 @@ int gen_main()
builder_print( header, strings );
builder_print( header, filesystem );
builder_print( header, timing );
builder_print( header, parsing );
builder_print_fmt( header, "\nGEN_NS_END\n" );
builder_write(header);
@ -74,15 +79,16 @@ int gen_main()
// gen_dep.cpp
{
Code src_start = scan_file( "dependencies/src_start.cpp" );
Code debug = scan_file( "dependencies/debug.cpp" );
Code string_ops = scan_file( "dependencies/string_ops.cpp" );
Code printing = scan_file( "dependencies/printing.cpp" );
Code memory = scan_file( "dependencies/memory.cpp" );
Code hashing = scan_file( "dependencies/hashing.cpp" );
Code strings = scan_file( "dependencies/strings.cpp" );
Code filesystem = scan_file( "dependencies/filesystem.cpp" );
Code timing = scan_file( "dependencies/timing.cpp" );
Code src_start = scan_file( path_base "dependencies/src_start.cpp" );
Code debug = scan_file( path_base "dependencies/debug.cpp" );
Code string_ops = scan_file( path_base "dependencies/string_ops.cpp" );
Code printing = scan_file( path_base "dependencies/printing.cpp" );
Code memory = scan_file( path_base "dependencies/memory.cpp" );
Code hashing = scan_file( path_base "dependencies/hashing.cpp" );
Code strings = scan_file( path_base "dependencies/strings.cpp" );
Code filesystem = scan_file( path_base "dependencies/filesystem.cpp" );
Code timing = scan_file( path_base "dependencies/timing.cpp" );
Code parsing = scan_file( path_base "dependencies/parsing.cpp" );
Builder _src = builder_open( "gen/gen.dep.cpp" );
Builder* src = & _src;
@ -99,6 +105,7 @@ int gen_main()
builder_print( src, strings );
builder_print( src, filesystem );
builder_print( src, timing );
builder_print( src, parsing );
builder_print_fmt( src, "\nGEN_NS_END\n" );
builder_write(src);
@ -115,18 +122,18 @@ int gen_main()
// gen.hpp
{
Code header_start = scan_file( "components/header_start.hpp" );
Code types = scan_file( "components/types.hpp" );
Code ast = scan_file( "components/ast.hpp" );
Code ast_types = scan_file( "components/ast_types.hpp" );
Code code_types = scan_file( "components/code_types.hpp" );
Code interface = scan_file( "components/interface.hpp" );
Code inlines = scan_file( "components/inlines.hpp" );
Code header_end = scan_file( "components/header_end.hpp" );
Code header_start = scan_file( path_base "components/header_start.hpp" );
Code types = scan_file( path_base "components/types.hpp" );
Code ast = scan_file( path_base "components/ast.hpp" );
Code ast_types = scan_file( path_base "components/ast_types.hpp" );
Code code_types = scan_file( path_base "components/code_types.hpp" );
Code interface = scan_file( path_base "components/interface.hpp" );
Code inlines = scan_file( path_base "components/inlines.hpp" );
Code header_end = scan_file( path_base "components/header_end.hpp" );
CodeBody ecode = gen_ecode ( "enums/ECodeTypes.csv" );
CodeBody eoperator = gen_eoperator ( "enums/EOperator.csv" );
CodeBody especifier = gen_especifier( "enums/ESpecifier.csv" );
CodeBody ecode = gen_ecode ( path_base "enums/ECodeTypes.csv" );
CodeBody eoperator = gen_eoperator ( path_base "enums/EOperator.csv" );
CodeBody especifier = gen_especifier( path_base "enums/ESpecifier.csv" );
CodeBody ast_inlines = gen_ast_inlines();
Builder _header = builder_open( "gen/gen.hpp" );
@ -167,43 +174,23 @@ int gen_main()
builder_print_fmt( header, "GEN_NS_END\n\n" );
builder_print( header, pop_ignores );
builder_write(header);
Builder header_ecode = builder_open( "components/gen/ecode.hpp" );
builder_print( & header_ecode, gen_component_header );
builder_print( & header_ecode, format(ecode) );
builder_write( & header_ecode);
Builder header_eoperator = builder_open( "components/gen/eoperator.hpp" );
builder_print( & header_eoperator, gen_component_header );
builder_print( & header_eoperator, format(eoperator) );
builder_write( & header_eoperator );
Builder header_especifier = builder_open( "components/gen/especifier.hpp" );
builder_print( & header_especifier, gen_component_header );
builder_print( & header_especifier, format(especifier) );
builder_write( & header_especifier);
Builder header_ast_inlines = builder_open( "components/gen/ast_inlines.hpp" );
builder_print( & header_ast_inlines, gen_component_header );
builder_print( & header_ast_inlines, format(ast_inlines) );
builder_write( & header_ast_inlines);
}
// gen.cpp
{
Code src_start = scan_file( "components/src_start.cpp" );
Code static_data = scan_file( "components/static_data.cpp" );
Code ast_case_macros = scan_file( "components/ast_case_macros.cpp" );
Code ast = scan_file( "components/ast.cpp" );
Code code_serialization = scan_file( "components/code_serialization.cpp" );
Code interface = scan_file( "components/interface.cpp" );
Code upfront = scan_file( "components/interface.upfront.cpp" );
Code lexer = scan_file( "components/lexer.cpp" );
Code parser = scan_file( "components/parser.cpp" );
Code parsing_interface = scan_file( "components/interface.parsing.cpp" );
Code untyped = scan_file( "components/interface.untyped.cpp" );
Code src_start = scan_file( path_base "components/src_start.cpp" );
Code static_data = scan_file( path_base "components/static_data.cpp" );
Code ast_case_macros = scan_file( path_base "components/ast_case_macros.cpp" );
Code ast = scan_file( path_base "components/ast.cpp" );
Code code_serialization = scan_file( path_base "components/code_serialization.cpp" );
Code interface = scan_file( path_base "components/interface.cpp" );
Code upfront = scan_file( path_base "components/interface.upfront.cpp" );
Code lexer = scan_file( path_base "components/lexer.cpp" );
Code parser = scan_file( path_base "components/parser.cpp" );
Code parsing_interface = scan_file( path_base "components/interface.parsing.cpp" );
Code untyped = scan_file( path_base "components/interface.untyped.cpp" );
CodeBody etoktype = gen_etoktype( "enums/ETokType.csv", "enums/AttributeTokens.csv" );
CodeBody etoktype = gen_etoktype( path_base "enums/ETokType.csv", path_base "enums/AttributeTokens.csv" );
CodeBody nspaced_etoktype = def_global_body( args(
etoktype
));
@ -232,23 +219,18 @@ int gen_main()
builder_print( src, lexer );
builder_print( src, parser );
builder_print( src, parsing_interface );
builder_print( src, untyped );
builder_print_fmt( src, "\n#pragma endregion Parsing\n\n" );
builder_print( src, untyped );
builder_print_fmt( src, "#pragma endregion Interface\n\n" );
builder_print_fmt( src, "GEN_NS_END\n\n");
builder_print( src, pop_ignores );
builder_write(src);
Builder src_etoktype = builder_open( "components/gen/etoktype.cpp" );
builder_print( & src_etoktype, gen_component_header );
builder_print( & src_etoktype, formatted_toktype );
builder_write( & src_etoktype);
}
// gen_builder.hpp
{
Code builder = scan_file( "auxillary/builder.hpp" );
Code builder = scan_file( path_base "auxillary/builder.hpp" );
Builder header = builder_open( "gen/gen.builder.hpp" );
builder_print_fmt( & header, generation_notice );
@ -261,8 +243,8 @@ int gen_main()
}
// gen_builder.cpp
Code builder = scan_file( "auxillary/builder.cpp" );
{
Code builder = scan_file( path_base "auxillary/builder.cpp" );
Builder src = builder_open( "gen/gen.builder.cpp" );
builder_print_fmt( & src, generation_notice );
@ -271,19 +253,17 @@ int gen_main()
builder_print( & src, builder );
builder_print_fmt( & src, "\nGEN_NS_END\n" );
builder_write( & src);
}
// gen_scanner.hpp
{
Code parsing = scan_file( "dependencies/parsing.hpp" );
Code scanner = scan_file( "auxillary/scanner.hpp" );
Code scanner = scan_file( path_base "auxillary/scanner.hpp" );
Builder header = builder_open( "gen/gen.scanner.hpp" );
builder_print_fmt( & header, generation_notice );
builder_print_fmt( & header, "#pragma once\n\n" );
builder_print( & header, def_include( txt("gen.hpp") ) );
builder_print_fmt( & header, "\nGEN_NS_BEGIN\n" );
builder_print( & header, parsing );
builder_print( & header, scanner );
builder_print_fmt( & header, "\nGEN_NS_END\n" );
builder_write(& header);
@ -291,14 +271,12 @@ int gen_main()
// gen_scanner.cpp
{
Code parsing = scan_file( "dependencies/parsing.cpp" );
Code scanner = scan_file( "auxillary/scanner.cpp" );
Code scanner = scan_file( path_base "auxillary/scanner.cpp" );
Builder src = builder_open( "gen/gen.scanner.cpp" );
builder_print_fmt( & src, generation_notice );
builder_print( & src, def_include( txt("gen.scanner.hpp") ) );
builder_print_fmt( & src, "\nGEN_NS_BEGIN\n" );
builder_print( & src, parsing );
builder_print( & src, scanner );
builder_print_fmt( & src, "GEN_NS_END\n" );
builder_write( & src);

View File

@ -3,17 +3,23 @@
See Readme.md for more information from the project repository.
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.
! ----------------------------------------------------------------------- VERSION: v0.20-Alpha !
! ============================================================================================ !
! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION !
! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL !
! ============================================================================================ !
Public Address:
https://github.com/Ed94/gencpp --------------------------------------------------------------.
| _____ _____ _ _ |
| / ____) / ____} | | | |
| | / ___ ___ _ __ ___ _ __ _ __ | {___ | |__ _ _, __ _, ___ __| | |
| | |{_ |/ _ \ '_ \ / __} '_ l| '_ l `\___ \| __/ _` |/ _` |/ _ \/ _` | |
| | l__j | ___/ | | | {__; |+l } |+l | ____) | l| (_| | {_| | ___/ (_| | |
| \_____|\___}_l |_|\___} ,__/| ,__/ (_____/ \__\__/_|\__, |\___}\__,_l |
| Singleheader | | | | __} | |
| l_l l_l {___/ |
! ----------------------------------------------------------------------- VERSION: v0.20-Alpha |
! ============================================================================================ |
! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION |
! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL |
! ============================================================================================ /
*/
#if ! defined(GEN_DONT_ENFORCE_GEN_TIME_GUARD) && ! defined(GEN_TIME)
# error Gen.hpp : GEN_TIME not defined

View File

@ -2,20 +2,15 @@
#define GEN_ENFORCE_STRONG_CODE_TYPES
#define GEN_EXPOSE_BACKEND
#include "gen.cpp"
#include "helpers/push_ignores.inline.hpp"
#include "helpers/helper.hpp"
#include <stdlib.h>
GEN_NS_BEGIN
#include "dependencies/parsing.cpp"
#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 <cstdlib> // for system()
using namespace gen;
constexpr char const* generation_notice =
@ -49,49 +44,20 @@ global bool generate_builder = true;
global bool generate_editor = true;
global bool generate_scanner = true;
void format_file( char const* path )
{
String resolved_path = String::make(GlobalAllocator, to_str(path));
#define path_format_style "../scripts/.clang-format "
#define scratch_file "gen/scratch.hpp"
#define path_base "../base/"
String style_arg = String::make(GlobalAllocator, txt("-style=file:"));
style_arg.append("../scripts/.clang-format ");
// Need to execute clang format on the generated file to get it to match the original.
#define clang_format "clang-format "
#define cf_format_inplace "-i "
#define cf_verbose "-verbose "
String command = String::make( GlobalAllocator, clang_format );
command.append( cf_format_inplace );
command.append( cf_verbose );
command.append( style_arg );
command.append( resolved_path );
log_fmt("\tRunning clang-format on file:\n");
system( command );
log_fmt("\tclang-format finished reformatting.\n");
#undef cf_cmd
#undef cf_format_inplace
#undef cf_style
#undef cf_verbse
}
Code dump_to_scratch_and_retireve( Code code )
{
Builder ecode_file_temp = Builder::open("gen/scratch.hpp");
ecode_file_temp.print(code);
ecode_file_temp.write();
format_file("gen/scratch.hpp");
Code result = scan_file( "gen/scratch.hpp" );
remove("gen/scratch.hpp");
return result;
Code format( Code code ) {
return code_refactor_and_format(code, scratch_file, nullptr, path_format_style );
}
int gen_main()
{
#define project_dir "../project/"
gen::init();
Code push_ignores = scan_file( project_dir "helpers/push_ignores.inline.hpp" );
Code pop_ignores = scan_file( project_dir "helpers/pop_ignores.inline.hpp" );
Code push_ignores = scan_file( path_base "helpers/push_ignores.inline.hpp" );
Code pop_ignores = scan_file( path_base "helpers/pop_ignores.inline.hpp" );
Code single_header_start = scan_file( "components/header_start.hpp" );
Builder
@ -106,18 +72,18 @@ int gen_main()
if ( generate_gen_dep )
{
Code platform = scan_file( project_dir "dependencies/platform.hpp" );
Code macros = scan_file( project_dir "dependencies/macros.hpp" );
Code basic_types = scan_file( project_dir "dependencies/basic_types.hpp" );
Code debug = scan_file( project_dir "dependencies/debug.hpp" );
Code memory = scan_file( project_dir "dependencies/memory.hpp" );
Code string_ops = scan_file( project_dir "dependencies/string_ops.hpp" );
Code printing = scan_file( project_dir "dependencies/printing.hpp" );
Code containers = scan_file( project_dir "dependencies/containers.hpp" );
Code hashing = scan_file( project_dir "dependencies/hashing.hpp" );
Code strings = scan_file( project_dir "dependencies/strings.hpp" );
Code filesystem = scan_file( project_dir "dependencies/filesystem.hpp" );
Code timing = scan_file( project_dir "dependencies/timing.hpp" );
Code platform = scan_file( path_base "dependencies/platform.hpp" );
Code macros = scan_file( path_base "dependencies/macros.hpp" );
Code basic_types = scan_file( path_base "dependencies/basic_types.hpp" );
Code debug = scan_file( path_base "dependencies/debug.hpp" );
Code memory = scan_file( path_base "dependencies/memory.hpp" );
Code string_ops = scan_file( path_base "dependencies/string_ops.hpp" );
Code printing = scan_file( path_base "dependencies/printing.hpp" );
Code containers = scan_file( path_base "dependencies/containers.hpp" );
Code hashing = scan_file( path_base "dependencies/hashing.hpp" );
Code strings = scan_file( path_base "dependencies/strings.hpp" );
Code filesystem = scan_file( path_base "dependencies/filesystem.hpp" );
Code timing = scan_file( path_base "dependencies/timing.hpp" );
header.print_fmt( roll_own_dependencies_guard_start );
header.print( platform );
@ -135,11 +101,8 @@ int gen_main()
header.print( filesystem );
header.print( timing );
if ( generate_scanner )
{
header.print_fmt( "\n#pragma region Parsing\n" );
header.print( scan_file( project_dir "dependencies/parsing.hpp" ) );
header.print_fmt( "#pragma endregion Parsing\n\n" );
if ( generate_scanner ) {
header.print( scan_file( path_base "dependencies/parsing.hpp" ) );
}
header.print_fmt( "GEN_NS_END\n" );
@ -147,17 +110,17 @@ int gen_main()
header.print( fmt_newline );
}
Code types = scan_file( project_dir "components/types.hpp" );
Code ast = scan_file( project_dir "components/ast.hpp" );
Code ast_types = scan_file( project_dir "components/ast_types.hpp" );
Code code_types = scan_file( project_dir "components/code_types.hpp" );
Code interface = scan_file( project_dir "components/interface.hpp" );
Code inlines = scan_file( project_dir "components/inlines.hpp" );
Code header_end = scan_file( project_dir "components/header_end.hpp" );
Code types = scan_file( path_base "components/types.hpp" );
Code ast = scan_file( path_base "components/ast.hpp" );
Code ast_types = scan_file( path_base "components/ast_types.hpp" );
Code code_types = scan_file( path_base "components/code_types.hpp" );
Code interface = scan_file( path_base "components/interface.hpp" );
Code inlines = scan_file( path_base "components/inlines.hpp" );
Code header_end = scan_file( path_base "components/header_end.hpp" );
CodeBody ecode = gen_ecode ( project_dir "enums/ECodeTypes.csv" );
CodeBody eoperator = gen_eoperator ( project_dir "enums/EOperator.csv" );
CodeBody especifier = gen_especifier( project_dir "enums/ESpecifier.csv" );
CodeBody ecode = gen_ecode ( path_base "enums/ECodeTypes.csv" );
CodeBody eoperator = gen_eoperator ( path_base "enums/EOperator.csv" );
CodeBody especifier = gen_especifier( path_base "enums/ESpecifier.csv" );
CodeBody ast_inlines = gen_ast_inlines();
header.print_fmt( "GEN_NS_BEGIN\n\n" );
@ -165,11 +128,11 @@ int gen_main()
header.print_fmt("#pragma region Types\n");
header.print( types );
header.print( fmt_newline );
header.print( dump_to_scratch_and_retireve( ecode ));
header.print( format( ecode ));
header.print( fmt_newline );
header.print( dump_to_scratch_and_retireve( eoperator ));
header.print( format( eoperator ));
header.print( fmt_newline );
header.print( dump_to_scratch_and_retireve( especifier ));
header.print( format( especifier ));
header.print( fmt_newline );
header.print_fmt("#pragma endregion Types\n\n");
@ -183,17 +146,14 @@ int gen_main()
header.print_fmt( "\n#pragma region Inlines\n" );
header.print( inlines );
header.print( dump_to_scratch_and_retireve( ast_inlines ));
header.print( format( ast_inlines ));
header.print( fmt_newline );
header.print_fmt( "#pragma endregion Inlines\n" );
header.print( header_end );
if ( generate_builder )
{
header.print_fmt( "\n#pragma region Builder\n" );
header.print( scan_file( project_dir "auxillary/builder.hpp" ) );
header.print_fmt( "#pragma endregion Builder\n" );
if ( generate_builder ) {
header.print( scan_file( path_base "auxillary/builder.hpp" ) );
}
header.print_fmt( "GEN_NS_END\n" );
@ -205,15 +165,15 @@ int gen_main()
if ( generate_gen_dep )
{
Code impl_start = scan_file( project_dir "dependencies/src_start.cpp" );
Code debug = scan_file( project_dir "dependencies/debug.cpp" );
Code string_ops = scan_file( project_dir "dependencies/string_ops.cpp" );
Code printing = scan_file( project_dir "dependencies/printing.cpp" );
Code memory = scan_file( project_dir "dependencies/memory.cpp" );
Code hashing = scan_file( project_dir "dependencies/hashing.cpp" );
Code strings = scan_file( project_dir "dependencies/strings.cpp" );
Code filesystem = scan_file( project_dir "dependencies/filesystem.cpp" );
Code timing = scan_file( project_dir "dependencies/timing.cpp" );
Code impl_start = scan_file( path_base "dependencies/src_start.cpp" );
Code debug = scan_file( path_base "dependencies/debug.cpp" );
Code string_ops = scan_file( path_base "dependencies/string_ops.cpp" );
Code printing = scan_file( path_base "dependencies/printing.cpp" );
Code memory = scan_file( path_base "dependencies/memory.cpp" );
Code hashing = scan_file( path_base "dependencies/hashing.cpp" );
Code strings = scan_file( path_base "dependencies/strings.cpp" );
Code filesystem = scan_file( path_base "dependencies/filesystem.cpp" );
Code timing = scan_file( path_base "dependencies/timing.cpp" );
header.print_fmt( roll_own_dependencies_guard_start );
header.print_fmt( "GEN_NS_BEGIN\n\n");
@ -228,10 +188,9 @@ int gen_main()
header.print( filesystem );
header.print( timing );
if ( generate_scanner )
{
if ( generate_scanner ) {
header.print_fmt( "\n#pragma region Parsing\n" );
header.print( scan_file( project_dir "dependencies/parsing.cpp" ) );
header.print( scan_file( path_base "dependencies/parsing.cpp" ) );
header.print_fmt( "#pragma endregion Parsing\n\n" );
}
@ -239,18 +198,18 @@ int gen_main()
header.print_fmt( roll_own_dependencies_guard_end );
}
Code static_data = scan_file( project_dir "components/static_data.cpp" );
Code ast_case_macros = scan_file( project_dir "components/ast_case_macros.cpp" );
Code ast = scan_file( project_dir "components/ast.cpp" );
Code code = scan_file( project_dir "components/code_serialization.cpp" );
Code interface = scan_file( project_dir "components/interface.cpp" );
Code upfront = scan_file( project_dir "components/interface.upfront.cpp" );
Code lexer = scan_file( project_dir "components/lexer.cpp" );
Code parser = scan_file( project_dir "components/parser.cpp" );
Code parsing_interface = scan_file( project_dir "components/interface.parsing.cpp" );
Code untyped = scan_file( project_dir "components/interface.untyped.cpp" );
Code static_data = scan_file( path_base "components/static_data.cpp" );
Code ast_case_macros = scan_file( path_base "components/ast_case_macros.cpp" );
Code ast = scan_file( path_base "components/ast.cpp" );
Code code = scan_file( path_base "components/code_serialization.cpp" );
Code interface = scan_file( path_base "components/interface.cpp" );
Code upfront = scan_file( path_base "components/interface.upfront.cpp" );
Code lexer = scan_file( path_base "components/lexer.cpp" );
Code parser = scan_file( path_base "components/parser.cpp" );
Code parsing_interface = scan_file( path_base "components/interface.parsing.cpp" );
Code untyped = scan_file( path_base "components/interface.untyped.cpp" );
CodeBody etoktype = gen_etoktype( project_dir "enums/ETokType.csv", project_dir "enums/AttributeTokens.csv" );
CodeBody etoktype = gen_etoktype( path_base "enums/ETokType.csv", path_base "enums/AttributeTokens.csv" );
CodeNS parser_nspace = def_namespace( name(parser), def_namespace_body( args(etoktype)) );
header.print_fmt( "\nGEN_NS_BEGIN\n");
@ -266,7 +225,7 @@ int gen_main()
header.print( interface );
header.print( upfront );
header.print_fmt( "\n#pragma region Parsing\n\n" );
header.print( dump_to_scratch_and_retireve(parser_nspace) );
header.print( format(parser_nspace) );
header.print( lexer );
header.print( parser );
header.print( parsing_interface );
@ -274,29 +233,18 @@ int gen_main()
header.print( untyped );
header.print_fmt( "\n#pragma endregion Interface\n\n");
if ( generate_builder )
{
header.print_fmt( "#pragma region Builder\n" );
header.print( scan_file( project_dir "auxillary/builder.cpp" ) );
header.print_fmt( "\n#pragma endregion Builder\n\n" );
if ( generate_builder ) {
header.print( scan_file( path_base "auxillary/builder.cpp" ) );
}
// Scanner header depends on implementation
if ( generate_scanner )
{
header.print_fmt( "\n#pragma region Scanner\n" );
header.print( scan_file( project_dir "auxillary/scanner.hpp" ) );
header.print_fmt( "#pragma endregion Scanner\n\n" );
if ( generate_scanner ) {
header.print( scan_file( path_base "auxillary/scanner.hpp" ) );
}
#if 0
if ( generate_scanner )
{
header.print_fmt( "#pragma region Scanner\n\n" );
header.print( scan_file( project_dir "auxillary/scanner.cpp" ) );
header.print_fmt( "#pragma endregion Scanner\n\n" );
if ( generate_scanner ) {
header.print( scan_file( path_base "auxillary/scanner.cpp" ) );
}
#endif
header.print_fmt( "GEN_NS_END\n");
@ -308,5 +256,4 @@ int gen_main()
gen::deinit();
return 0;
#undef project_dir
}

View File

@ -2,22 +2,15 @@
#define GEN_ENFORCE_STRONG_CODE_TYPES
#define GEN_EXPOSE_BACKEND
#include "gen.cpp"
#include "helpers/push_ignores.inline.hpp"
#include "helpers/helper.hpp"
#include <stdlib.h>
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 <cstdlib> // for system()
using namespace gen;
constexpr char const* generation_notice =
@ -52,49 +45,20 @@ global bool generate_builder = true;
global bool generate_editor = true;
global bool generate_scanner = true;
void format_file( char const* path )
{
String resolved_path = String::make(GlobalAllocator, to_strc_from_c_str(path));
#define path_format_style "../scripts/.clang-format "
#define scratch_file "gen/scratch.hpp"
#define path_base "../base/"
String style_arg = String::make(GlobalAllocator, txt("-style=file:"));
style_arg.append("../scripts/.clang-format ");
// Need to execute clang format on the generated file to get it to match the original.
#define clang_format "clang-format "
#define cf_format_inplace "-i "
#define cf_verbose "-verbose "
String command = String::make( GlobalAllocator, clang_format );
command.append( cf_format_inplace );
command.append( cf_verbose );
command.append( style_arg );
command.append( resolved_path );
log_fmt("\tRunning clang-format on file:\n");
system( command );
log_fmt("\tclang-format finished reformatting.\n");
#undef cf_cmd
#undef cf_format_inplace
#undef cf_style
#undef cf_verbse
}
Code dump_to_scratch_and_retireve( Code code )
{
Builder ecode_file_temp = Builder::open("gen/scratch.hpp");
ecode_file_temp.print(code);
ecode_file_temp.write();
format_file("gen/scratch.hpp");
Code result = scan_file( "gen/scratch.hpp" );
remove("gen/scratch.hpp");
return result;
Code format( Code code ) {
return code_refactor_and_format(code, scratch_file, nullptr, path_format_style );
}
int gen_main()
{
#define project_dir "../project/"
gen::init();
Code push_ignores = scan_file( project_dir "helpers/push_ignores.inline.hpp" );
Code pop_ignores = scan_file( project_dir "helpers/pop_ignores.inline.hpp" );
Code push_ignores = scan_file( path_base "helpers/push_ignores.inline.hpp" );
Code pop_ignores = scan_file( path_base "helpers/pop_ignores.inline.hpp" );
Code ue_forceinline = code_str(FORCEINLINE);
// Code
@ -103,7 +67,7 @@ int gen_main()
{
CodeBody macros = def_body( CT_Global_Body );
{
FileContents content = file_read_contents( GlobalAllocator, true, project_dir "dependencies/macros.hpp" );
FileContents content = file_read_contents( GlobalAllocator, true, path_base "dependencies/macros.hpp" );
CodeBody ori_macros = parse_global_body( StrC { content.size, (char const*)content.data });
for (Code code = ori_macros.begin();
@ -132,17 +96,17 @@ int gen_main()
}
}
Code platform = scan_file( project_dir "dependencies/platform.hpp" );
Code basic_types = scan_file( project_dir "dependencies/basic_types.hpp" );
Code debug = scan_file( project_dir "dependencies/debug.hpp" );
Code memory = scan_file( project_dir "dependencies/memory.hpp" );
Code string_ops = scan_file( project_dir "dependencies/string_ops.hpp" );
Code printing = scan_file( project_dir "dependencies/printing.hpp" );
Code containers = scan_file( project_dir "dependencies/containers.hpp" );
Code hashing = scan_file( project_dir "dependencies/hashing.hpp" );
Code strings = scan_file( project_dir "dependencies/strings.hpp" );
Code filesystem = scan_file( project_dir "dependencies/filesystem.hpp" );
Code timing = scan_file( project_dir "dependencies/timing.hpp" );
Code platform = scan_file( path_base "dependencies/platform.hpp" );
Code basic_types = scan_file( path_base "dependencies/basic_types.hpp" );
Code debug = scan_file( path_base "dependencies/debug.hpp" );
Code memory = scan_file( path_base "dependencies/memory.hpp" );
Code string_ops = scan_file( path_base "dependencies/string_ops.hpp" );
Code printing = scan_file( path_base "dependencies/printing.hpp" );
Code containers = scan_file( path_base "dependencies/containers.hpp" );
Code hashing = scan_file( path_base "dependencies/hashing.hpp" );
Code strings = scan_file( path_base "dependencies/strings.hpp" );
Code filesystem = scan_file( path_base "dependencies/filesystem.hpp" );
Code timing = scan_file( path_base "dependencies/timing.hpp" );
Builder
header = Builder::open("gen/gen.dep.hpp");
@ -153,7 +117,7 @@ int gen_main()
header.print_fmt( "\nGEN_NS_BEGIN\n" );
header.print( fmt_newline);
header.print( dump_to_scratch_and_retireve(macros) );
header.print( format(macros) );
header.print( basic_types );
header.print( debug );
header.print( memory );
@ -173,15 +137,15 @@ int gen_main()
// gen_dep.cpp
{
Code src_start = scan_file( project_dir "dependencies/src_start.cpp" );
Code debug = scan_file( project_dir "dependencies/debug.cpp" );
Code string_ops = scan_file( project_dir "dependencies/string_ops.cpp" );
Code printing = scan_file( project_dir "dependencies/printing.cpp" );
Code memory = scan_file( project_dir "dependencies/memory.cpp" );
Code hashing = scan_file( project_dir "dependencies/hashing.cpp" );
Code strings = scan_file( project_dir "dependencies/strings.cpp" );
Code filesystem = scan_file( project_dir "dependencies/filesystem.cpp" );
Code timing = scan_file( project_dir "dependencies/timing.cpp" );
Code src_start = scan_file( path_base "dependencies/src_start.cpp" );
Code debug = scan_file( path_base "dependencies/debug.cpp" );
Code string_ops = scan_file( path_base "dependencies/string_ops.cpp" );
Code printing = scan_file( path_base "dependencies/printing.cpp" );
Code memory = scan_file( path_base "dependencies/memory.cpp" );
Code hashing = scan_file( path_base "dependencies/hashing.cpp" );
Code strings = scan_file( path_base "dependencies/strings.cpp" );
Code filesystem = scan_file( path_base "dependencies/filesystem.cpp" );
Code timing = scan_file( path_base "dependencies/timing.cpp" );
Builder
src = Builder::open( "gen/gen.dep.cpp" );
@ -210,17 +174,17 @@ int gen_main()
// gen.hpp
{
Code header_start = scan_file( "components/header_start.hpp" );
Code types = scan_file( project_dir "components/types.hpp" );
Code ast = scan_file( project_dir "components/ast.hpp" );
Code ast_types = scan_file( project_dir "components/ast_types.hpp" );
Code code_types = scan_file( project_dir "components/code_types.hpp" );
Code interface = scan_file( project_dir "components/interface.hpp" );
Code inlines = scan_file( project_dir "components/inlines.hpp" );
Code header_end = scan_file( project_dir "components/header_end.hpp" );
Code types = scan_file( path_base "components/types.hpp" );
Code ast = scan_file( path_base "components/ast.hpp" );
Code ast_types = scan_file( path_base "components/ast_types.hpp" );
Code code_types = scan_file( path_base "components/code_types.hpp" );
Code interface = scan_file( path_base "components/interface.hpp" );
Code inlines = scan_file( path_base "components/inlines.hpp" );
Code header_end = scan_file( path_base "components/header_end.hpp" );
CodeBody ecode = gen_ecode ( project_dir "enums/ECodeTypes.csv" );
CodeBody eoperator = gen_eoperator ( project_dir "enums/EOperator.csv" );
CodeBody especifier = gen_especifier( project_dir "enums/ESpecifier.csv" );
CodeBody ecode = gen_ecode ( path_base "enums/ECodeTypes.csv" );
CodeBody eoperator = gen_eoperator ( path_base "enums/EOperator.csv" );
CodeBody especifier = gen_especifier( path_base "enums/ESpecifier.csv" );
CodeBody ast_inlines = gen_ast_inlines();
Builder
@ -235,11 +199,11 @@ int gen_main()
header.print_fmt( "#pragma region Types\n" );
header.print( types );
header.print( fmt_newline );
header.print( dump_to_scratch_and_retireve(ecode) );
header.print( format(ecode) );
header.print( fmt_newline );
header.print( dump_to_scratch_and_retireve(eoperator) );
header.print( format(eoperator) );
header.print( fmt_newline );
header.print( dump_to_scratch_and_retireve(especifier) );
header.print( format(especifier) );
header.print( fmt_newline );
header.print_fmt( "#pragma endregion Types\n\n" );
@ -254,7 +218,7 @@ int gen_main()
header.print_fmt( "\n#pragma region Inlines\n" );
header.print( inlines );
header.print( fmt_newline );
header.print( dump_to_scratch_and_retireve(ast_inlines) );
header.print( format(ast_inlines) );
header.print( fmt_newline );
header.print_fmt( "#pragma endregion Inlines\n" );
@ -267,22 +231,21 @@ int gen_main()
// gen.cpp
{
Code src_start = scan_file( "components/src_start.cpp" );
Code static_data = scan_file( project_dir "components/static_data.cpp" );
Code ast_case_macros = scan_file( project_dir "components/ast_case_macros.cpp" );
Code ast = scan_file( project_dir "components/ast.cpp" );
Code code_serialization = scan_file( project_dir "components/code_serialization.cpp" );
Code interface = scan_file( project_dir "components/interface.cpp" );
Code upfront = scan_file( project_dir "components/interface.upfront.cpp" );
Code lexer = scan_file( project_dir "components/lexer.cpp" );
Code parser = scan_file( project_dir "components/parser.cpp" );
Code parsing_interface = scan_file( project_dir "components/interface.parsing.cpp" );
Code untyped = scan_file( project_dir "components/interface.untyped.cpp" );
Code static_data = scan_file( path_base "components/static_data.cpp" );
Code ast_case_macros = scan_file( path_base "components/ast_case_macros.cpp" );
Code ast = scan_file( path_base "components/ast.cpp" );
Code code_serialization = scan_file( path_base "components/code_serialization.cpp" );
Code interface = scan_file( path_base "components/interface.cpp" );
Code upfront = scan_file( path_base "components/interface.upfront.cpp" );
Code lexer = scan_file( path_base "components/lexer.cpp" );
Code parser = scan_file( path_base "components/parser.cpp" );
Code parsing_interface = scan_file( path_base "components/interface.parsing.cpp" );
Code untyped = scan_file( path_base "components/interface.untyped.cpp" );
// Note(Ed): The Attribute tokens need to be expanded and regenerated on a per-project/installation of this library for a specific codebase of Unreal.
// We can support an arbitrary set of modules or plugin apis for parsing
// but its up to the user to define them all (This will just provide whats I've used up till now).
CodeBody etoktype = gen_etoktype( project_dir "enums/ETokType.csv", "enums/AttributeTokens.csv" );
CodeNS nspaced_etoktype = def_namespace( name(parser), def_namespace_body( args(etoktype)) );
CodeBody etoktype = gen_etoktype( path_base "enums/ETokType.csv", "enums/AttributeTokens.csv" );
Builder
src = Builder::open( "gen/gen.cpp" );
@ -305,7 +268,7 @@ int gen_main()
src.print( interface );
src.print( upfront );
src.print_fmt( "\n#pragma region Parsing\n\n" );
src.print( dump_to_scratch_and_retireve(nspaced_etoktype) );
src.print( format(etoktype) );
src.print( lexer );
src.print( parser );
src.print( parsing_interface );
@ -320,7 +283,7 @@ int gen_main()
// gen_builder.hpp
{
Code builder = scan_file( project_dir "auxillary/builder.hpp" );
Code builder = scan_file( path_base "auxillary/builder.hpp" );
Builder
header = Builder::open( "gen/gen.builder.hpp" );
@ -339,7 +302,7 @@ int gen_main()
// gen_builder.cpp
{
Code builder = scan_file( project_dir "auxillary/builder.cpp" );
Code builder = scan_file( path_base "auxillary/builder.cpp" );
Builder
src = Builder::open( "gen/gen.builder.cpp" );
@ -357,8 +320,8 @@ int gen_main()
// gen_scanner.hpp
{
Code parsing = scan_file( project_dir "dependencies/parsing.hpp" );
Code scanner = scan_file( project_dir "auxillary/scanner.hpp" );
Code parsing = scan_file( path_base "dependencies/parsing.hpp" );
Code scanner = scan_file( path_base "auxillary/scanner.hpp" );
Builder
header = Builder::open( "gen/gen.scanner.hpp" );
@ -378,8 +341,8 @@ int gen_main()
// gen.scanner.cpp
{
Code parsing = scan_file( project_dir "dependencies/parsing.cpp" );
Code scanner = scan_file( project_dir "auxillary/scanner.cpp" );
Code parsing = scan_file( path_base "dependencies/parsing.cpp" );
Code scanner = scan_file( path_base "auxillary/scanner.cpp" );
Builder
src = Builder::open( "gen/gen.scanner.cpp" );

View File

@ -1,9 +1,23 @@
# 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]
# AttributeMacros: [
# ]
StatementMacros: [
GEN_NS_BEGIN,
GEN_NS_END,
GEN_NS_PARSER_BEGIN,
GEN_NS_PARSER_END,
GEN_API_C_BEGIN,
GEN_API_C_END,
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT
]
Macros:
- enum_underlying(type)=type
- gen_enum_underlying(type)=type
TypenameMacros: [Array, Hashtable]
SkipMacroDefinitionBody: true
SkipMacroDefinitionBody: false
AccessModifierOffset: -4

View File

@ -4,7 +4,6 @@
$devshell = Join-Path $PSScriptRoot 'helpers/devshell.ps1'
$misc = Join-Path $PSScriptRoot 'helpers/misc.psm1'
$refactor_c_library = Join-Path $PSScriptRoot 'refactor_c_library.ps1'
$refactor_unreal = Join-Path $PSScriptRoot 'refactor_unreal.ps1'
$incremental_checks = Join-Path $PSScriptRoot 'helpers/incremental_checks.ps1'
$vendor_toolchain = Join-Path $PSScriptRoot 'helpers/vendor_toolchain.ps1'
@ -20,7 +19,7 @@ Push-Location $path_root
$release = $null
$verbose = $false
$base = $false
[bool] $segemented = $false
[bool] $segmented = $false
[bool] $singleheader = $false
[bool] $c_library = $false
[bool] $unreal = $false
@ -37,7 +36,7 @@ if ( $args ) { $args | ForEach-Object {
"release" { $release = $true }
"debug" { $release = $false }
"base" { $base = $true }
"segemented" { $segemented = $true }
"segmented" { $segmented = $true }
"singleheader" { $singleheader = $true }
"c_library" { $c_library = $true }
"unreal" { $unreal = $true }
@ -115,13 +114,13 @@ if ( $base )
$flag_link_win_subsystem_console
)
$includes = @( $path_project)
$includes = @( $path_base)
$unit = join-path $path_base "base.cpp"
$executable = join-path $path_build "base.exe"
$result = build-simple $path_build $includes $compiler_args $linker_args $unit $executable
Push-Location $path_project
Push-Location $path_base
if ( Test-Path( $executable ) ) {
write-host "`nRunning base"
$time_taken = Measure-Command { & $executable
@ -129,7 +128,7 @@ if ( $base )
write-host `t $_ -ForegroundColor Green
}
}
write-host "`bbase completed in $($time_taken.TotalMilliseconds) ms"
write-host "`nbase completed in $($time_taken.TotalMilliseconds) ms"
}
Pop-Location
}
@ -153,13 +152,13 @@ if ( $segmented )
$flag_link_win_subsystem_console
)
$includes = @( $path_project)
$includes = @( $path_base)
$unit = join-path $path_segmented "segmented.cpp"
$executable = join-path $path_build "segmented.exe"
$result = build-simple $path_build $includes $compiler_args $linker_args $unit $executable
Push-Location $path_project
Push-Location $path_segmented
if ( Test-Path( $executable ) ) {
write-host "`nRunning segmented"
$time_taken = Measure-Command { & $executable
@ -184,7 +183,7 @@ if ( $singleheader )
New-Item -ItemType Directory -Path $path_gen
}
$includes = @( $path_project )
$includes = @( $path_base )
$unit = join-path $path_singleheader "singleheader.cpp"
$executable = join-path $path_build "singleheader.exe"
@ -222,7 +221,7 @@ if ( $c_library )
New-Item -ItemType Directory -Path $path_gen
}
$includes = @( $path_project )
$includes = @( $path_base )
$unit = join-path $path_c_library "c_library.cpp"
$executable = join-path $path_build "c_library.exe"
@ -247,8 +246,7 @@ if ( $c_library )
}
Pop-Location
. $refactor_c_library
$includes = @( $path_c_library )
$unit = join-path $path_c_library "gen.c"
$executable = join-path $path_build "gen_c_library_test.exe"
@ -289,7 +287,7 @@ if ( $unreal )
New-Item -ItemType Directory -Path $path_gen
}
$includes = @( $path_project )
$includes = @( $path_base )
$unit = join-path $path_unreal "unreal.cpp"
$executable = join-path $path_build "unreal.exe"

View File

@ -1,10 +1,19 @@
$path_root = git rev-parse --show-toplevel
$misc = Join-Path $PSScriptRoot 'helpers/misc.psm1'
Import-Module $misc
$path_root = Get-ScriptRepoRoot
$path_base = Join-Path $path_root base
$path_base_build = Join-Path $path_base build
$path_singleheader = Join-Path $path_root singleheader
$path_c_library = Join-Path $path_root gen_c_library
$path_c_library_build = Join-Path $path_c_library build
$path_c_library_gen = Join-Path $path_c_library gen
$path_segmented = Join-Path $path_root gen_segmented
$path_segmented_build = Join-Path $path_segmented build
$path_segmented_gen = Join-Path $path_segmented gen
$path_singleheader = Join-Path $path_root gen_singleheader
$path_singleheader_build = Join-Path $path_singleheader build
$path_singleheader_gen = Join-Path $path_singleheader gen
$path_unreal = Join-Path $paht_root unreal
$path_unreal = Join-Path $path_root gen_unreal_engine
$path_unreal_build = Join-Path $path_unreal build
$path_unreal_gen = Join-Path $path_unreal gen
$path_test = Join-Path $path_root test
@ -13,30 +22,45 @@ $path_test_gen = Join-Path $path_test gen
$path_x64 = Join-Path $path_root x64
$path_release = Join-Path $path_root release
if ( Test-Path $path_project_build) {
Remove-Item $path_project_build -Recurse
if ( Test-Path $path_base_build) {
Remove-Item $path_base_build -Recurse -Verbose
}
if ( Test-Path $path_project_gen ) {
Remove-Item $path_project_gen -Recurse
if ( Test-Path $path_segmented_build) {
Remove-Item $path_segmented_build -Recurse -Verbose
}
if ( Test-Path $path_c_library_build ) {
Remove-Item $path_c_library_build -Recurse -Verbose
}
if ( Test-Path $path_c_library_gen ) {
Remove-Item $path_c_library_gen -Recurse -Verbose
}
if ( Test-Path $path_segmented_build) {
Remove-Item $path_segmented_build -Recurse -Verbose
}
if ( Test-Path $path_segmented_gen ) {
Remove-Item $path_segmented_gen -Recurse -Verbose
}
if ( Test-Path $path_singleheader_build) {
Remove-Item $path_singleheader_build -Recurse
Remove-Item $path_singleheader_build -Recurse -Verbose
}
if ( Test-Path $path_singleheader_gen ) {
Remove-Item $path_singleheader_gen -Recurse
Remove-Item $path_singleheader_gen -Recurse -Verbose
}
if ( Test-Path $path_unreal ) {
Remove-Item $path_unreal_build -Recurse
if ( Test-Path $path_unreal_build ) {
Remove-Item $path_unreal_build -Recurse -Verbose
}
if ( Test-Path $path_unreal_gen ) {
Remove-Item $path_unreal_gen -Recurse -Verbose
}
if ( Test-Path $path_test_build ) {
Remove-Item $path_test_build -Recurse
Remove-Item $path_test_build -Recurse -Verbose
}
if ( Test-Path $path_test_gen ) {
Remove-Item $path_test_gen -Recurse
Remove-Item $path_test_gen -Recurse -Verbose
}
if ( Test-Path $path_x64) {
Remove-Item $path_x64 -Recurse
Remove-Item $path_x64 -Recurse -Verbose
}
if ( Test-Path $path_release ) {
Remove-Item $path_release -Recurse
Remove-Item $path_release -Recurse -Verbose
}

View File

@ -1,24 +1,28 @@
cls
$misc = Join-Path $PSScriptRoot 'helpers/misc.psm1'
Import-Module $misc
$build = Join-Path $PSScriptRoot 'build.ci.ps1'
if ( $IsWindows ) {
& $build release msvc bootstrap singleheader unreal msvc debug
& $build release msvc base segmented singleheader unreal c_library msvc debug
}
else {
& $build release clang bootstrap singleheader unreal msvc debug
& $build release clang base segmented singleheader unreal c_library msvc debug
}
$path_root = git rev-parse --show-toplevel
$path_docs = Join-Path $path_root docs
$path_project = Join-Path $path_root project
$path_project_gen = Join-Path $path_project gen
$path_singleheader = Join-Path $path_root singleheader
$path_singleheader_gen = Join-Path $path_singleheader gen
$path_unreal = Join-Path $path_root unreal_engine
$path_unreal_gen = Join-Path $path_unreal gen
$path_release = Join-Path $path_root release
$path_release_content = Join-Path $path_release content
$path_root = Get-ScriptRepoRoot
$path_docs = Join-Path $path_root docs
$path_base = Join-Path $path_root base
$path_c_library = Join-Path $path_root gen_c_library
$path_c_library_gen = Join-Path $path_c_library gen
$path_segmented = Join-Path $path_root gen_segmented
$path_segmented_gen = Join-Path $path_segmented gen
$path_singleheader = Join-Path $path_root gen_singleheader
$path_singleheader_gen = Join-Path $path_singleheader gen
$path_unreal = Join-Path $path_root gen_unreal_engine
$path_unreal_gen = Join-Path $path_unreal gen
$path_release = Join-Path $path_root release
$path_release_content = Join-Path $path_release content
if ( -not(Test-Path $path_release) ) {
New-Item -ItemType Directory -Path $path_release
@ -47,33 +51,53 @@ function prep-ReleaseContent()
# Singleheader
prep-ReleaseContent
Copy-Item -Path $path_singleheader_gen\gen.hpp -Destination $path_release_content\gen.hpp
Copy-Item -Verbose -Path $path_singleheader\Readme.md -Destination $path_release_content
Copy-Item -Verbose -Path $path_singleheader_gen\gen.hpp -Destination $path_release_content
Compress-Archive -Path $path_release_content\* -DestinationPath $path_release\gencpp_singleheader.zip -Force
Remove-Item -Path $path_release_content -Recurse
# Segmented
prep-ReleaseContent
Copy-Item -Path $path_project_gen\* -Destination $path_release_content
Compress-Archive -Path $path_release_content\* -DestinationPath $path_release\gencpp_segmented.zip -Force
Copy-Item -Verbose -Path $path_segmented\Readme.md -Destination $path_release_content
Copy-Item -Verbose -Path $path_segmented_gen\* -Destination $path_release_content
Compress-Archive -Path $path_release_content\* -DestinationPath $path_release\gencpp_segmented.zip -Force
Remove-Item -Path $path_release_content -Recurse
# Unreal
prep-ReleaseContent
Copy-Item -Path $path_unreal_gen\* -Destination $path_release_content
Copy-Item -Verbose -Path $path_unreal\Readme.md -Destination $path_release_content
Copy-Item -Verbose -Path $path_unreal_gen\* -Destination $path_release_content
Compress-Archive -Path $path_release_content\* -DestinationPath $path_release\gencpp_unreal.zip -Force
Remove-Item -Path $path_release_content -Recurse
# As Is
# C Library Singleheader
prep-ReleaseContent
Copy-Item -Verbose -Path $path_c_library\Readme.md -Destination $path_release_content
Copy-Item -Verbose -Path $path_c_library_gen\gen_singleheader.h -Destination $path_release_content\gen.h
Compress-Archive -Path $path_release_content\* -DestinationPath $path_release\gencpp_c11_singleheader.zip -Force
Remove-Item -Path $path_release_content -Recurse
# C Library Segmented
prep-ReleaseContent
Copy-Item -Verbose -Path $path_c_library\Readme.md -Destination $path_release_content
Copy-Item -Verbose -Path $path_c_library_gen\gen.dep.c -Destination $path_release_content
Copy-Item -Verbose -Path $path_c_library_gen\gen.dep.h -Destination $path_release_content
Copy-Item -Verbose -Path $path_c_library_gen\gen.c -Destination $path_release_content
Copy-Item -Verbose -Path $path_c_library_gen\gen.h -Destination $path_release_content
Compress-Archive -Path $path_release_content\* -DestinationPath $path_release\gencpp_c11_segmented.zip -Force
Remove-Item -Path $path_release_content -Recurse
# Base
prep-ReleaseContent
Copy-Item -Verbose -Path $path_project\gen.hpp -Destination $path_release_content
Copy-Item -Verbose -Path $path_project\gen.cpp -Destination $path_release_content
Copy-Item -Verbose -Path $path_project\gen.dep.hpp -Destination $path_release_content
Copy-Item -Verbose -Path $path_project\gen.dep.cpp -Destination $path_release_content
Copy-Item -Verbose -Path $path_project\auxillary\builder.hpp -Destination $path_release_content\auxillary
Copy-Item -Verbose -Path $path_project\auxillary\builder.cpp -Destination $path_release_content\auxillary
Copy-Item -Verbose -Path $path_project\auxillary\scanner.hpp -Destination $path_release_content\auxillary
Copy-Item -Verbose -Path $path_project\auxillary\scanner.cpp -Destination $path_release_content\auxillary
Copy-Item -Verbose -Path $path_base\gen.hpp -Destination $path_release_content
Copy-Item -Verbose -Path $path_base\gen.cpp -Destination $path_release_content
Copy-Item -Verbose -Path $path_base\gen.dep.hpp -Destination $path_release_content
Copy-Item -Verbose -Path $path_base\gen.dep.cpp -Destination $path_release_content
Copy-Item -Verbose -Path $path_base\auxillary\builder.hpp -Destination $path_release_content\auxillary
Copy-Item -Verbose -Path $path_base\auxillary\builder.cpp -Destination $path_release_content\auxillary
Copy-Item -Verbose -Path $path_base\auxillary\scanner.hpp -Destination $path_release_content\auxillary
Copy-Item -Verbose -Path $path_base\auxillary\scanner.cpp -Destination $path_release_content\auxillary
New-Item -ItemType Directory -Force -Path "$path_release_content\components"
New-Item -ItemType Directory -Force -Path "$path_release_content\components\gen"
@ -81,11 +105,11 @@ New-Item -ItemType Directory -Force -Path "$path_release_content\dependencies"
New-Item -ItemType Directory -Force -Path "$path_release_content\enums"
New-Item -ItemType Directory -Force -Path "$path_release_content\helpers"
Get-ChildItem -Verbose -Path "$path_project\components\*" -Include *.cpp,*.hpp | Copy-Item -Destination "$path_release_content\components"
Get-ChildItem -Verbose -Path "$path_project\components\gen\*" -Include *.cpp,*.hpp | Copy-Item -Destination "$path_release_content\components\gen"
Get-ChildItem -Verbose -Path "$path_project\dependencies\*" -Include *.cpp,*.hpp | Copy-Item -Destination "$path_release_content\dependencies"
Get-ChildItem -Verbose -Path "$path_project\enums\*" -Include *.csv | Copy-Item -Destination "$path_release_content\enums"
Get-ChildItem -Verbose -Path "$path_project\helpers\*" -Include *.cpp,*.hpp | Copy-Item -Destination "$path_release_content\helpers"
Get-ChildItem -Verbose -Path "$path_base\components\*" -Include *.cpp,*.hpp | Copy-Item -Verbose -Destination "$path_release_content\components"
Get-ChildItem -Verbose -Path "$path_base\components\gen\*" -Include *.cpp,*.hpp | Copy-Item -Verbose -Destination "$path_release_content\components\gen"
Get-ChildItem -Verbose -Path "$path_base\dependencies\*" -Include *.cpp,*.hpp | Copy-Item -Verbose -Destination "$path_release_content\dependencies"
Get-ChildItem -Verbose -Path "$path_base\enums\*" -Include *.csv | Copy-Item -Verbose -Destination "$path_release_content\enums"
Get-ChildItem -Verbose -Path "$path_base\helpers\*" -Include *.cpp,*.hpp | Copy-Item -Verbose -Destination "$path_release_content\helpers"
Compress-Archive -Path $path_release_content\** -DestinationPath $path_release\gencpp_as_is.zip -Force
Compress-Archive -Path $path_release_content\** -DestinationPath $path_release\gencpp_base.zip -Force
Remove-Item -Path $path_release_content -Recurse

View File

@ -1,59 +0,0 @@
[string] $format = $false
foreach ( $arg in $args )
{
if ( $arg -eq "format" )
{
$format = $true
}
}
[string[]] $include = 'gen.h'
[string[]] $exclude
$path_root = git rev-parse --show-toplevel
$path_project = Join-Path $path_root project
$path_scripts = Join-Path $path_root scripts
$path_helpers = Join-Path $path_scripts helpers
$path_c_library = Join-Path $path_root gen_c_library
$path_c_library_gen = Join-Path $path_c_library gen
$file_spec = Join-Path $path_c_library c_library.refactor
# Gather the files to be formatted.
$targetFiles = @()
$targetFiles += Get-ChildItem -Recurse -Path $path_c_library_gen -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName
# $targetFiles += Get-ChildItem -Recurse -Path $path_project -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName
# $targetFiles += Get-ChildItem -Recurse -Path $path_singleheader_comp -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName
# Format the files.
$formatParams = @(
'-i' # In-place
'-style=file:./.clang-format' # Search for a .clang-format file in the parent directory of the source file.
'-verbose'
)
write-host "Beginning refactor...`n"
Write-Host $targetFiles
$refactorParams = @(
"-debug",
"-num=$($targetFiles.Count)"
"-src=$($targetFiles)",
"-spec=$($file_spec)"
)
$refactor = join-path $path_helpers refactor.exe
write-host "& $refactor $refactorParams"
& $refactor $refactorParams
Write-Host "`nRefactoring complete`n`n"
if ( $format -eq $true ) {
Write-Host "Beginning format...`n"
& clang-format $formatParams $targetFiles
Write-Host "`nFormatting complete"
}

View File

@ -36,7 +36,7 @@ $formatParams = @(
write-host "Beginning refactor...`n"
$refactorParams = @(
"-debug",
# "-debug",
"-num=$($targetFiles.Count)"
"-src=$($targetFiles)",
"-spec=$($file_spec)"