mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 15:54:45 -08:00
began to setup generation of Array_ssize and StringTable in the c-library
Still need to confirm if the these old templates require updates compared to the c++ impl
This commit is contained in:
parent
1c3134218e
commit
47b9c37e94
@ -102,6 +102,7 @@ int gen_main()
|
|||||||
|
|
||||||
PreprocessorDefines.append(txt("GEN_API_C_BEGIN"));
|
PreprocessorDefines.append(txt("GEN_API_C_BEGIN"));
|
||||||
PreprocessorDefines.append(txt("GEN_API_C_END"));
|
PreprocessorDefines.append(txt("GEN_API_C_END"));
|
||||||
|
PreprocessorDefines.append(txt("HashTable("));
|
||||||
|
|
||||||
Code push_ignores = scan_file( project_dir "helpers/push_ignores.inline.hpp" );
|
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 pop_ignores = scan_file( project_dir "helpers/pop_ignores.inline.hpp" );
|
||||||
@ -295,6 +296,11 @@ int gen_main()
|
|||||||
containers.append( gen_array_base() );
|
containers.append( gen_array_base() );
|
||||||
containers.append( gen_hashtable_base() );
|
containers.append( gen_hashtable_base() );
|
||||||
|
|
||||||
|
containers.append(fmt_newline);
|
||||||
|
|
||||||
|
CodeBody array_ssize = gen_array(txt("ssize"), txt("Array_ssize"));
|
||||||
|
containers.append(array_ssize);
|
||||||
|
|
||||||
containers.append( def_pragma(code(endregion Containers)));
|
containers.append( def_pragma(code(endregion Containers)));
|
||||||
}
|
}
|
||||||
header.print(fmt_newline);
|
header.print(fmt_newline);
|
||||||
@ -373,6 +379,22 @@ int gen_main()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CT_Typedef:
|
||||||
|
{
|
||||||
|
StrC name_string_table = txt("StringTable");
|
||||||
|
|
||||||
|
CodeTypedef td = cast(CodeTypedef, entry);
|
||||||
|
if (td->Name.contains(name_string_table))
|
||||||
|
{
|
||||||
|
CodeBody ht = gen_hashtable(name_string_table, name_string_table);
|
||||||
|
strings.append(ht);
|
||||||
|
strings.append(td);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
strings.append(td);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
strings.append(entry);
|
strings.append(entry);
|
||||||
break;
|
break;
|
||||||
|
@ -18,7 +18,7 @@ CodeBody gen_hashtable_base()
|
|||||||
));
|
));
|
||||||
|
|
||||||
Code define_type = untyped_str(txt(
|
Code define_type = untyped_str(txt(
|
||||||
R"(#define Hashtable(_type) HTE_##_type
|
R"(#define HashTable(_type) struct _type
|
||||||
)"
|
)"
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -27,14 +27,10 @@ R"(#define Hashtable(_type) HTE_##_type
|
|||||||
|
|
||||||
CodeBody gen_hashtable( StrC type, StrC hashtable_name )
|
CodeBody gen_hashtable( StrC type, StrC hashtable_name )
|
||||||
{
|
{
|
||||||
String
|
|
||||||
fn = String::make_reserve( GlobalAllocator, hashtable_name.Len + sizeof("gen") );
|
|
||||||
fn.append_fmt( "%.*s", hashtable_name.Len, hashtable_name.Ptr );
|
|
||||||
str_to_lower(fn.Data);
|
|
||||||
|
|
||||||
String
|
String tbl_type = {(char*) hashtable_name.duplicate(GlobalAllocator).Ptr};
|
||||||
tbl_type = String::make_reserve( GlobalAllocator, hashtable_name.Len + sizeof("gen") );
|
String fn = tbl_type.duplicate(GlobalAllocator);
|
||||||
tbl_type.append_fmt( "%.*s", hashtable_name.Len, hashtable_name.Ptr );
|
str_to_lower(fn.Data);
|
||||||
|
|
||||||
String name_lower = String::make( GlobalAllocator, hashtable_name );
|
String name_lower = String::make( GlobalAllocator, hashtable_name );
|
||||||
str_to_lower( name_lower.Data );
|
str_to_lower( name_lower.Data );
|
||||||
|
@ -4957,6 +4957,13 @@ CodeTypedef parse_typedef()
|
|||||||
Context.Scope->Name = name;
|
Context.Scope->Name = name;
|
||||||
eat( Tok_Preprocess_Macro );
|
eat( Tok_Preprocess_Macro );
|
||||||
// <ModuleFalgs> typedef <Preprocessed_Macro>
|
// <ModuleFalgs> typedef <Preprocessed_Macro>
|
||||||
|
|
||||||
|
if ( currtok.Type == Tok_Identifier )
|
||||||
|
{
|
||||||
|
type = untyped_str({ name.Length, name.Text });
|
||||||
|
name = currtok;
|
||||||
|
eat(Tok_Identifier);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user