From 9b059dca47bdf8384530b5553998eabb5dd869d1 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Fri, 6 Dec 2024 00:33:58 -0500 Subject: [PATCH] C-library Finished setting up header dependencies ( --- gen_c_library/c_library.cpp | 43 +++++++++++++++++++++++++++-- project/dependencies/filesystem.hpp | 5 ++-- project/helpers/helper.hpp | 10 +++---- 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/gen_c_library/c_library.cpp b/gen_c_library/c_library.cpp index ecfe547..1941792 100644 --- a/gen_c_library/c_library.cpp +++ b/gen_c_library/c_library.cpp @@ -142,7 +142,6 @@ int gen_main() Code debug = scan_file( project_dir "dependencies/debug.hpp" ); Code string_ops = scan_file( project_dir "dependencies/string_ops.hpp" ); Code hashing = scan_file( project_dir "dependencies/hashing.hpp" ); - Code filesystem = scan_file( project_dir "dependencies/filesystem.hpp" ); Code timing = scan_file( project_dir "dependencies/timing.hpp" ); CodeBody parsed_memory = parse_file( project_dir "dependencies/memory.hpp" ); @@ -387,6 +386,44 @@ int gen_main() } } + CodeBody parsed_filesystem = parse_file( project_dir "dependencies/filesystem.hpp" ); + CodeBody filesystem = def_body(CT_Global_Body); + for ( Code entry = parsed_filesystem.begin(); entry != parsed_filesystem.end(); ++ entry ) + { + switch (entry->Type) + { + case CT_Preprocess_IfDef: + { + b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_filesystem, filesystem ); + if (found) break; + + filesystem.append(entry); + } + break; + case CT_Variable: + { + CodeVar var = cast(CodeVar, entry); + if (var->Specs.has(Spec_Constexpr) > -1) + { + CodeDefine define = def_define(entry->Name, entry->Value->Content); + filesystem.append(define); + continue; + } + //if ( strc_contains(entry->Name, txt("Msg_Invalid_Value"))) + //{ + // CodeDefine define = def_define(entry->Name, entry->Value->Content); + // printing.append(define); + // continue; + //} + filesystem.append(entry); + } + break; + default: + filesystem.append(entry); + break; + } + } + CodeBody containers = def_body(CT_Global_Body); { CodeBody array_ssize = gen_array(txt("ssize"), txt("Array_ssize")); @@ -421,8 +458,8 @@ int gen_main() header.print( dump_to_scratch_and_retireve(containers)); header.print( hashing ); header.print( dump_to_scratch_and_retireve(strings)); - // header.print( filesystem ); - // header.print( timing ); + header.print( dump_to_scratch_and_retireve(filesystem)); + header.print( timing ); header.print_fmt( "\nGEN_NS_END\n" ); header.print_fmt( roll_own_dependencies_guard_end ); #pragma endregion Print Dependencies diff --git a/project/dependencies/filesystem.hpp b/project/dependencies/filesystem.hpp index 8151151..9602e5c 100644 --- a/project/dependencies/filesystem.hpp +++ b/project/dependencies/filesystem.hpp @@ -194,6 +194,7 @@ b32 file_read_at( FileInfo* file, void* buffer, ssize size, s64 offset ); */ b32 file_read_at_check( FileInfo* file, void* buffer, ssize size, s64 offset, ssize* bytes_read ); +typedef struct FileContents FileContents; struct FileContents { AllocatorInfo allocator; @@ -201,8 +202,8 @@ struct FileContents ssize size; }; -constexpr b32 zero_terminate = true; -constexpr b32 no_zero_terminate = false; +constexpr b32 file_zero_terminate = true; +constexpr b32 file_no_zero_terminate = false; /** * Reads the whole file contents diff --git a/project/helpers/helper.hpp b/project/helpers/helper.hpp index c847fa8..3205a87 100644 --- a/project/helpers/helper.hpp +++ b/project/helpers/helper.hpp @@ -13,7 +13,7 @@ CodeBody gen_ecode( char const* path ) char scratch_mem[kilobytes(1)]; Arena scratch = arena_init_from_memory( scratch_mem, sizeof(scratch_mem) ); - file_read_contents( arena_allocator_info( & scratch), zero_terminate, path ); + file_read_contents( arena_allocator_info( & scratch), file_zero_terminate, path ); CSV_Object csv_nodes; csv_parse( &csv_nodes, scratch_mem, GlobalAllocator, false ); @@ -63,7 +63,7 @@ CodeBody gen_eoperator( char const* path ) char scratch_mem[kilobytes(4)]; Arena scratch = arena_init_from_memory( scratch_mem, sizeof(scratch_mem) ); - file_read_contents( arena_allocator_info(& scratch), zero_terminate, path ); + file_read_contents( arena_allocator_info(& scratch), file_zero_terminate, path ); CSV_Object csv_nodes; csv_parse( &csv_nodes, scratch_mem, GlobalAllocator, false ); @@ -119,7 +119,7 @@ CodeBody gen_especifier( char const* path ) char scratch_mem[kilobytes(4)]; Arena scratch = arena_init_from_memory( scratch_mem, sizeof(scratch_mem) ); - file_read_contents( arena_allocator_info(& scratch), zero_terminate, path ); + file_read_contents( arena_allocator_info(& scratch), file_zero_terminate, path ); CSV_Object csv_nodes; csv_parse( &csv_nodes, scratch_mem, GlobalAllocator, false ); @@ -226,12 +226,12 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path ) AllocatorInfo scratch_info = arena_allocator_info(& scratch); - FileContents enum_content = file_read_contents( scratch_info, zero_terminate, etok_path ); + 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 ); - FileContents attrib_content = file_read_contents( scratch_info, zero_terminate, attr_path ); + 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 );