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