mirror of
https://github.com/Ed94/gencpp.git
synced 2025-06-15 03:01:47 -07:00
Progresss
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
#define GEN_ENFORCE_STRONG_CODE_TYPES
|
||||
#define GEN_EXPOSE_BACKEND
|
||||
#define GEN_SUPPORT_CPP_MEMBER_FEATURES 1
|
||||
#define GEN_SUPPORT_CPP_REFERENCES 1
|
||||
#include "../project/gen.cpp"
|
||||
|
||||
#include "helpers/push_ignores.inline.hpp"
|
||||
@ -135,26 +136,40 @@ int gen_main()
|
||||
case ECode::Using:
|
||||
{
|
||||
log_fmt("REPLACE THIS MANUALLY: %S\n", entry->Name);
|
||||
CodeUsing using_ver = entry.cast<CodeUsing>();
|
||||
CodeUsing using_ver = entry.code_cast<CodeUsing>();
|
||||
CodeTypedef typedef_ver = def_typedef(using_ver->Name, using_ver->UnderlyingType);
|
||||
|
||||
memory.append(typedef_ver);
|
||||
}
|
||||
break;
|
||||
case ECode::Function_Fwd:
|
||||
{
|
||||
CodeFn fn = entry.code_cast<CodeFn>();
|
||||
if ( fn->Name.is_equal(txt("free")) )
|
||||
{
|
||||
fn->Name = get_cached_string(txt("gen_free_ptr"));
|
||||
}
|
||||
memory.append(entry);
|
||||
}
|
||||
break;
|
||||
case ECode::Function:
|
||||
{
|
||||
CodeFn fn = entry.cast<CodeFn>();
|
||||
CodeFn fn = entry.code_cast<CodeFn>();
|
||||
s32 constexpr_found = fn->Specs.remove( ESpecifier::Constexpr );
|
||||
if (constexpr_found > -1) {
|
||||
log_fmt("Found constexpr: %S\n", entry->to_string());
|
||||
fn->Specs.append(ESpecifier::Inline);
|
||||
}
|
||||
if ( fn->Name.is_equal(txt("free")) )
|
||||
{
|
||||
fn->Name = get_cached_string(txt("gen_free_ptr"));
|
||||
}
|
||||
memory.append(entry);
|
||||
}
|
||||
break;
|
||||
case ECode::Template:
|
||||
{
|
||||
CodeTemplate tmpl = entry.cast<CodeTemplate>();
|
||||
CodeTemplate tmpl = entry.code_cast<CodeTemplate>();
|
||||
if ( tmpl->Declaration->Name.contains(txt("swap")))
|
||||
{
|
||||
CodeBody macro_swap = parse_global_body( txt(R"(
|
||||
@ -297,7 +312,7 @@ int gen_main()
|
||||
{
|
||||
if ( entry->Name.is_equal(txt("String")) )
|
||||
{
|
||||
CodeTypedef c_def = parse_typedef(code( typedef Type* String; ));
|
||||
CodeTypedef c_def = parse_typedef(code( typedef char* String; ));
|
||||
strings.append(c_def);
|
||||
strings.append(fmt_newline);
|
||||
++ entry;
|
||||
@ -307,6 +322,29 @@ int gen_main()
|
||||
}
|
||||
break;
|
||||
|
||||
case ECode::Struct:
|
||||
{
|
||||
CodeBody body = entry->Body->operator CodeBody();
|
||||
CodeBody new_body = def_body( entry->Body->Type );
|
||||
for ( Code body_entry = body.begin(); body_entry != body.end(); ++ body_entry ) switch
|
||||
(body_entry->Type) {
|
||||
case ECode::Preprocess_If:
|
||||
{
|
||||
b32 found = ignore_preprocess_cond_block(txt("! GEN_COMPILER_C"), body_entry, body );
|
||||
if (found) break;
|
||||
|
||||
new_body.append(body_entry);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
new_body.append(body_entry);
|
||||
break;
|
||||
}
|
||||
entry->Body = rcast(AST*, new_body.ast);
|
||||
strings.append(entry);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
strings.append(entry);
|
||||
break;
|
||||
@ -316,8 +354,8 @@ int gen_main()
|
||||
|
||||
Code filesystem = scan_file( project_dir "dependencies/filesystem.hpp" );
|
||||
Code timing = scan_file( project_dir "dependencies/timing.hpp" );
|
||||
header.print( filesystem );
|
||||
header.print( timing );
|
||||
// header.print( filesystem );
|
||||
// header.print( timing );
|
||||
|
||||
header.print_fmt( "\nGEN_NS_END\n" );
|
||||
header.print_fmt( roll_own_dependencies_guard_end );
|
||||
@ -335,6 +373,7 @@ int gen_main()
|
||||
CodeBody especifier = gen_especifier( project_dir "enums/ESpecifier.csv" );
|
||||
CodeBody ast_inlines = gen_ast_inlines();
|
||||
|
||||
#if 0
|
||||
header.print_fmt("#pragma region Types\n");
|
||||
header.print( types );
|
||||
header.print( fmt_newline );
|
||||
@ -345,6 +384,7 @@ int gen_main()
|
||||
header.print( dump_to_scratch_and_retireve( especifier ));
|
||||
header.print( fmt_newline );
|
||||
header.print_fmt("#pragma endregion Types\n\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
header.print( pop_ignores );
|
||||
|
@ -20,7 +20,7 @@ CodeBody gen_fixed_arenas()
|
||||
inline
|
||||
void fixed_arena_init_<Name>(FixedArena_<Name>* result) {
|
||||
zero_size(& result->memory[0], <Size>);
|
||||
result.arena = arena_init_from_memory(& result->memory[0], <Size>);
|
||||
result->arena = arena_init_from_memory(& result->memory[0], <Size>);
|
||||
}
|
||||
|
||||
inline
|
||||
|
@ -8,7 +8,7 @@ using SwapContentProc = CodeBody(void);
|
||||
b32 ignore_preprocess_cond_block( StrC cond_sig, Code& entry_iter, CodeBody& body )
|
||||
{
|
||||
b32 found = false;
|
||||
CodePreprocessCond cond = entry_iter.cast<CodePreprocessCond>();
|
||||
CodePreprocessCond cond = entry_iter.code_cast<CodePreprocessCond>();
|
||||
if ( cond->Content.contains(cond_sig) )
|
||||
{
|
||||
log_fmt("Preprocess cond found: %S\n", cond->Content);
|
||||
@ -44,7 +44,7 @@ b32 ignore_preprocess_cond_block( StrC cond_sig, Code& entry_iter, CodeBody& bod
|
||||
bool swap_pragma_region_implementation( StrC region_name, SwapContentProc* swap_content, Code& entry_iter, CodeBody& body )
|
||||
{
|
||||
bool found = false;
|
||||
CodePragma possible_region = entry_iter.cast<CodePragma>();
|
||||
CodePragma possible_region = entry_iter.code_cast<CodePragma>();
|
||||
|
||||
String region_sig = string_fmt_buf(GlobalAllocator, "region %s", region_name.Ptr);
|
||||
String endregion_sig = string_fmt_buf(GlobalAllocator, "endregion %s", region_name.Ptr);
|
||||
@ -58,7 +58,7 @@ bool swap_pragma_region_implementation( StrC region_name, SwapContentProc* swap_
|
||||
(entry_iter->Type) {
|
||||
case ECode::Preprocess_Pragma:
|
||||
{
|
||||
CodePragma possible_end_region = entry_iter.cast<CodePragma>();
|
||||
CodePragma possible_end_region = entry_iter.code_cast<CodePragma>();
|
||||
if ( possible_end_region->Content.contains(endregion_sig) ) {
|
||||
// body.append(possible_end_region);
|
||||
continue_for = false;
|
||||
|
7
gen_c_library/gen.c
Normal file
7
gen_c_library/gen.c
Normal file
@ -0,0 +1,7 @@
|
||||
#define GEN_IMPLEMENTATION
|
||||
#include "gen/gen.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
// init();
|
||||
}
|
Reference in New Issue
Block a user