corrections to c_library.cpp, package_release.ps1 working for all zips

This commit is contained in:
Edward R. Gonzalez 2024-12-11 02:04:22 -05:00
parent caec5d8dfc
commit 401f85f673
12 changed files with 398 additions and 268 deletions

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

@ -137,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 \
@ -1127,7 +1128,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
// Source Content : Reflection and Generation
#pragma region Resolve Dependencies
Code src_impl_start = scan_file( path_base "dependencies/src_start.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" );
@ -1143,6 +1144,7 @@ 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_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" );
@ -1395,8 +1397,74 @@ 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_singleheader.h" );
header.print_fmt( generation_notice );
@ -1409,25 +1477,22 @@ R"(#define <interface_name>( code ) _Generic( (code), \
{
#pragma region Print Dependencies
header.print_fmt( roll_own_dependencies_guard_start );
header.print( refactor(header_platform) );
header.print( r_header_platform );
header.print_fmt( "\nGEN_NS_BEGIN\n" );
header.print( refactor(header_macros) );
header.print( refactor(header_basic_types) );
header.print( refactor(header_debug) );
header.print( refactor_and_format(header_memory) );
header.print( refactor_and_format(header_printing));
header.print( refactor(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( refactor_and_format(containers));
header.print( refactor(header_hashing) );
header.print( refactor_and_format(header_strings));
header.print( refactor_and_format(header_filesystem));
header.print( refactor(header_timing) );
header.print_fmt( "\n#pragma region Parsing\n" );
header.print( refactor_and_format(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 );
@ -1440,35 +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( refactor_and_format(types) );
header.print( rf_types );
header.print( fmt_newline );
header.print( refactor_and_format( ecode ));
header.print( rf_ecode );
header.print( fmt_newline );
header.print( refactor_and_format( eoperator ));
header.print( rf_eoperator );
header.print( fmt_newline );
header.print( refactor_and_format( especifier ));
header.print( rf_especifier );
header.print_fmt("#pragma endregion Types\n\n");
header.print_fmt("#pragma region AST\n");
header.print( refactor_and_format(ast) );
header.print( refactor_and_format(code_types) );
header.print( refactor_and_format(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( refactor_and_format(interface) );
header.print( rf_interface );
header.print(fmt_newline);
header.print_fmt("#pragma region Inlines\n");
header.print( refactor_and_format(inlines) );
header.print( rf_inlines );
header.print_fmt("#pragma endregion Inlines\n");
header.print(fmt_newline);
header.print( refactor_and_format(array_string_cached));
header.print( rf_array_string_cached );
header.print( refactor_and_format(header_end) );
header.print( refactor_and_format(header_builder) );
header.print( refactor_and_format( scan_file( path_base "auxillary/scanner.hpp" )) );
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" );
@ -1484,60 +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( refactor(src_impl_start) );
header.print( refactor(src_debug) );
header.print( refactor(src_string_ops) );
header.print( refactor(src_printing) );
header.print( refactor(src_memory) );
header.print( refactor(src_hashing) );
header.print( refactor(src_strings) );
header.print( refactor(src_filesystem) );
header.print( refactor(src_timing) );
header.print_fmt( "\n#pragma region Parsing\n" );
header.print( refactor_and_format( scan_file( path_base "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( path_base "enums/ETokType.csv", path_base "enums/AttributeTokens.csv", helper_use_c_definition );
header.print_fmt( "\nGEN_NS_BEGIN\n");
header.print( fmt_newline);
header.print( refactor_and_format(array_arena));
header.print( rf_array_arena );
header.print( fmt_newline);
header.print( refactor_and_format(array_pool));
header.print( rf_array_pool);
header.print( refactor(src_static_data) );
header.print( r_src_static_data );
header.print( fmt_newline);
header.print_fmt( "#pragma region AST\n\n" );
header.print( refactor(src_ast_case_macros) );
header.print( refactor(src_ast) );
header.print( refactor(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( refactor(src_interface) );
header.print( refactor_and_format(src_upfront) );
header.print( r_src_interface );
header.print( r_src_upfront );
header.print_fmt( "\n#pragma region Parsing\n\n" );
header.print( refactor_and_format(etoktype) );
header.print( refactor_and_format(src_lexer) );
header.print( rf_etoktype );
header.print( r_src_lexer );
header.print( fmt_newline);
header.print( refactor_and_format(array_code_typename));
header.print( rf_array_code_typename );
header.print( fmt_newline);
header.print( refactor_and_format(src_parser) );
header.print( refactor(src_parsing_interface) );
header.print( rf_src_parser );
header.print( r_src_parsing );
header.print_fmt( "\n#pragma endregion Parsing\n" );
header.print( refactor(src_untyped) );
header.print( r_src_untyped );
header.print_fmt( "\n#pragma endregion Interface\n\n");
header.print( refactor_and_format( scan_file( path_base "auxillary/builder.cpp" )) );
header.print( refactor_and_format( scan_file( path_base "auxillary/scanner.cpp" )) );
header.print( rf_src_builder );
header.print( rf_src_scanner );
header.print_fmt( "GEN_API_C_END\n" );
#pragma endregion Print Components
@ -1546,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

@ -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

@ -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_singleheader.h"
#include "gen/gen.c"
int main()
{

View File

@ -219,8 +219,8 @@ 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");
@ -243,7 +243,7 @@ int gen_main()
}
// gen_builder.cpp
{
Code builder = scan_file( path_base "auxillary/builder.cpp" );
Builder src = builder_open( "gen/gen.builder.cpp" );
@ -253,7 +253,7 @@ int gen_main()
builder_print( & src, builder );
builder_print_fmt( & src, "\nGEN_NS_END\n" );
builder_write( & src);
}
// gen_scanner.hpp
{

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

@ -246,6 +246,7 @@ if ( $c_library )
}
Pop-Location
$includes = @( $path_c_library )
$unit = join-path $path_c_library "gen.c"
$executable = join-path $path_build "gen_c_library_test.exe"

View File

@ -5,8 +5,8 @@ $path_root = Get-ScriptRepoRoot
$path_base = Join-Path $path_root base
$path_base_build = Join-Path $path_base build
$path_c_library = Join-Path $path_root gen_c_library
$path_c_library_build = Join-Path $gen_c_library build
$path_c_library_gen = Join-Path $gen_c_library gen
$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
@ -28,8 +28,11 @@ if ( Test-Path $path_base_build) {
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_segmented_gen -Recurse -Verbose
Remove-Item $path_c_library_gen -Recurse -Verbose
}
if ( Test-Path $path_segmented_build) {
Remove-Item $path_segmented_build -Recurse -Verbose

View File

@ -11,18 +11,18 @@ else {
}
$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 $gen_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
$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
@ -51,37 +51,40 @@ function prep-ReleaseContent()
# Singleheader
prep-ReleaseContent
Copy-Item -Path $path_singleheader\Readme.md -Destination $path_release_content\Readme.md
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_segmented\Readme.md -Destination $path_release_content\Readme.md
Copy-Item -Path $path_segmented_gen\* -Destination $path_release_content
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\Readme.md -Destination $path_release_content\Readme.md
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
# C Library Singleheader
prep-ReleaseContent
Copy-Item -Path $path_c_library\Readme.md -Destination $path_release_content\Readme.md
Copy-Item -Path $path_c_library_gen\gen_singleheader.hpp -Destination $path_release_content\gen.hpp
Compress-Archive -Path $path_release_content\* -DestinationPath $path_release\gencpp_c11_singleheader.zip -Force
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 -Path $path_c_library\Readme.md -Destination $path_release_content\Readme.md
Copy-Item -Path $path_unreal_gen\* -Destination $path_release_content
Compress-Archive -Path $path_release_content\* -DestinationPath $path_release\gencpp_c11_segmented.zip -Force
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
@ -102,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_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)"