Massive total progress on c_library generation: (Summary of last 3 WIP commits)

- No longer using GEN_API_C_* macros as C-library wont need them and if you need C linkage there is no need to use the c++ library.
- GEN_C_LIKE_CPP replaces GEN_SUPPORT_CPP_MEMBER_FEATURES && GEN_SUPPORT_CPP_REFERENCES
  a. If users don't want to use member functions, function overloading, or referencese they can just this one macro to before including the library.
- Enums aren't accomodated in C++ sources, they entirely converted in c_libray.cpp
- ast.hpp now properly generates with C variant
- Fully prepared code_types.hpp for C library gen (not tested yet)
- Generated enums managed by helper.hpp now properly generate for C library.
This commit is contained in:
2024-12-07 17:58:56 -05:00
parent 451b71884c
commit 1c133bfc8d
4 changed files with 89 additions and 82 deletions

View File

@ -351,7 +351,8 @@ R"(#define AST_ArrSpecs_Cap \
(body_entry->Type) {
case CT_Preprocess_If:
{
ignore_preprocess_cond_block(txt("! GEN_C_LIKE_CPP"), body_entry, body, new_body );
b32 found = ignore_preprocess_cond_block(txt("GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP"), body_entry, body, new_body );
if (found) break;
}
break;
@ -552,25 +553,29 @@ R"(#define AST_ArrSpecs_Cap \
break;
case CT_Enum:
{
if (entry->Name.is_equal(txt("FileOperations")))
continue;
convert_cpp_enum_to_c(cast(CodeEnum, entry), filesystem);
}
break;
case CT_Enum_Fwd:
case CT_Struct_Fwd:
case CT_Struct:
case CT_Union:
case CT_Union_Fwd:
{
if (entry->Name.is_equal(txt("FileOperations")))
continue;
// StrC type_str = codetype_to_keyword_str(entry->Type);
// StrC formated_tmpl = token_fmt_impl( 3,
// "type", type_str
// , "name", entry->Name,
// stringize(
// typedef <type> <name> <name>;
// ));
// CodeTypedef tdef = parse_typedef(formated_tmpl);
// filesystem.append(entry);
// filesystem.append(tdef);
StrC type_str = codetype_to_keyword_str(entry->Type);
StrC formated_tmpl = token_fmt_impl( 3,
"type", type_str
, "name", entry->Name,
stringize(
typedef <type> <name> <name>;
));
CodeTypedef tdef = parse_typedef(formated_tmpl);
filesystem.append(entry);
filesystem.append(tdef);
}
break;