Compare commits

..

4 Commits

24 changed files with 458 additions and 333 deletions

View File

@ -128,12 +128,12 @@ int gen_main()
header.print( debug );
CodeBody parsed_memory = parse_file( project_dir "dependencies/memory.hpp" );
CodeBody memory = def_body(ECode::Global_Body);
CodeBody memory = def_body(CT_Global_Body);
for ( Code entry = parsed_memory.begin(); entry != parsed_memory.end(); ++ entry )
{
switch (entry->Type)
{
case ECode::Using:
case CT_Using:
{
log_fmt("REPLACE THIS MANUALLY: %S\n", entry->Name);
CodeUsing using_ver = cast(CodeUsing, entry);
@ -142,7 +142,7 @@ int gen_main()
memory.append(typedef_ver);
}
break;
case ECode::Function_Fwd:
case CT_Function_Fwd:
{
CodeFn fn = cast(CodeFn, entry);
if ( fn->Name.is_equal(txt("free")) )
@ -152,13 +152,13 @@ int gen_main()
memory.append(entry);
}
break;
case ECode::Function:
case CT_Function:
{
CodeFn fn = cast(CodeFn, entry);
s32 constexpr_found = fn->Specs.remove( ESpecifier::Constexpr );
s32 constexpr_found = fn->Specs.remove( Spec_Constexpr );
if (constexpr_found > -1) {
log_fmt("Found constexpr: %S\n", entry.to_string());
fn->Specs.append(ESpecifier::Inline);
fn->Specs.append(Spec_Inline);
}
if ( fn->Name.is_equal(txt("free")) )
{
@ -167,7 +167,7 @@ int gen_main()
memory.append(entry);
}
break;
case ECode::Template:
case CT_Template:
{
CodeTemplate tmpl = cast(CodeTemplate, entry);
if ( tmpl->Declaration->Name.contains(txt("swap")))
@ -186,14 +186,14 @@ int gen_main()
}
}
break;
case ECode::Class:
case ECode::Struct:
case CT_Class:
case CT_Struct:
{
CodeBody body = cast(CodeBody, entry->Body);
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:
case CT_Preprocess_If:
{
ignore_preprocess_cond_block(txt("GEN_SUPPORT_CPP_MEMBER_FEATURES"), body_entry, body );
}
@ -208,7 +208,7 @@ int gen_main()
memory.append(entry);
}
break;
case ECode::Preprocess_If:
case CT_Preprocess_If:
{
b32 found = ignore_preprocess_cond_block(txt("GEN_SUPPORT_CPP_MEMBER_FEATURES"), entry, parsed_memory );
if (found) break;
@ -216,7 +216,7 @@ int gen_main()
memory.append(entry);
}
break;
case ECode::Preprocess_IfDef:
case CT_Preprocess_IfDef:
{
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_memory );
if (found) break;
@ -224,7 +224,7 @@ int gen_main()
memory.append(entry);
}
break;
case ECode::Preprocess_Pragma:
case CT_Preprocess_Pragma:
{
b32 found = swap_pragma_region_implementation( txt("FixedArena"), gen_fixed_arenas, entry, memory);
if (found) break;
@ -244,12 +244,12 @@ int gen_main()
header.print( string_ops );
CodeBody printing_parsed = parse_file( project_dir "dependencies/printing.hpp" );
CodeBody printing = def_body(ECode::Global_Body);
CodeBody printing = def_body(CT_Global_Body);
for ( Code entry = printing_parsed.begin(); entry != printing_parsed.end(); ++ entry )
{
switch (entry->Type)
{
case ECode::Preprocess_IfDef:
case CT_Preprocess_IfDef:
{
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, printing_parsed );
if (found) break;
@ -257,7 +257,7 @@ int gen_main()
printing.append(entry);
}
break;
case ECode::Variable:
case CT_Variable:
{
if (contains(entry->Name, txt("Msg_Invalid_Value")))
{
@ -275,7 +275,7 @@ int gen_main()
}
header.print(dump_to_scratch_and_retireve(printing));
CodeBody containers = def_body(ECode::Global_Body);
CodeBody containers = def_body(CT_Global_Body);
{
containers.append( def_pragma(code(region Containers)));
@ -291,24 +291,24 @@ int gen_main()
header.print( hashing );
CodeBody parsed_strings = parse_file( project_dir "dependencies/strings.hpp" );
CodeBody strings = def_body(ECode::Global_Body);
CodeBody strings = def_body(CT_Global_Body);
for ( Code entry = parsed_strings.begin(); entry != parsed_strings.end(); ++ entry )
{
switch (entry->Type)
{
case ECode::Preprocess_If:
case CT_Preprocess_If:
{
ignore_preprocess_cond_block(txt("! GEN_COMPILER_C"), entry, parsed_strings);
}
break;
case ECode::Preprocess_IfDef:
case CT_Preprocess_IfDef:
{
ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_strings );
}
break;
case ECode::Struct_Fwd:
case CT_Struct_Fwd:
{
if ( entry->Name.is_equal(txt("String")) )
{
@ -322,13 +322,13 @@ int gen_main()
}
break;
case ECode::Struct:
case CT_Struct:
{
CodeBody body = cast(CodeBody, entry->Body);
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:
case CT_Preprocess_If:
{
b32 found = ignore_preprocess_cond_block(txt("! GEN_COMPILER_C"), body_entry, body );
if (found) break;

View File

@ -5,7 +5,7 @@ using namespace gen;
CodeBody gen_fixed_arenas()
{
CodeBody result = def_body(ECode::Global_Body);
CodeBody result = def_body(CT_Global_Body);
result.append(def_pragma(txt("region FixedArena")));
char const* template_struct = stringize(

View File

@ -17,13 +17,13 @@ b32 ignore_preprocess_cond_block( StrC cond_sig, Code& entry_iter, CodeBody& bod
s32 depth = 1;
++ entry_iter; for(b32 continue_for = true; continue_for && entry_iter != body.end(); ) switch
(entry_iter->Type) {
case ECode::Preprocess_If:
case ECode::Preprocess_IfDef:
case ECode::Preprocess_IfNotDef:
case CT_Preprocess_If:
case CT_Preprocess_IfDef:
case CT_Preprocess_IfNotDef:
depth ++;
break;
case ECode::Preprocess_EndIf:
case CT_Preprocess_EndIf:
{
depth --;
if (depth == 0) {
@ -56,7 +56,7 @@ bool swap_pragma_region_implementation( StrC region_name, SwapContentProc* swap_
++ entry_iter; for(b32 continue_for = true; continue_for; ++entry_iter) switch
(entry_iter->Type) {
case ECode::Preprocess_Pragma:
case CT_Preprocess_Pragma:
{
CodePragma possible_end_region = cast(CodePragma, entry_iter);
if ( possible_end_region->Content.contains(endregion_sig) ) {

View File

@ -43,7 +43,7 @@ void Builder::print_fmt( char const* fmt, ... )
va_end( va );
// log_fmt( "$%s - print_fmt: %.*s\n", File.filename, res > 80 ? 80 : res, buf );
append( & Buffer, buf, res );
append( (String*) & Buffer, (char const*)buf, res );
}
void Builder::write()

View File

@ -39,7 +39,7 @@ Code scan_file( char const* path )
const StrC def_intellisense = txt("GEN_INTELLISENSE_DIRECTIVES" );
bool found_directive = false;
char const* scanner = str.Data;
char const* scanner = (char const*)str;
s32 left = fsize;
while ( left )
{
@ -94,7 +94,7 @@ Code scan_file( char const* path )
move_fwd();
// sptr skip_size = fsize - left;
if ( (scanner + 2) >= ( str.Data + fsize ) )
if ( (scanner + 2) >= ( (char const*) str + fsize ) )
{
mem_move( str, scanner, left );
get_header(str)->Length = left;
@ -106,7 +106,6 @@ Code scan_file( char const* path )
break;
}
}
move_fwd();
@ -117,7 +116,7 @@ Code scan_file( char const* path )
}
file_close( & file );
return untyped_str( str );
return untyped_str( to_strc(str) );
}
#if 0

View File

@ -654,8 +654,8 @@ bool is_equal( Code self, Code other )
"so it must be verified by eye for now\n" \
"AST Content:\n%S\n" \
"Other Content:\n%S\n" \
, visualize_whitespace(self->content) \
, visualize_whitespace(other->content) \
, visualize_whitespace(self->content, GlobalAllocator) \
, visualize_whitespace(other->content, GlobalAllocator) \
); \
}
@ -711,7 +711,6 @@ bool is_equal( Code self, Code other )
case CT_Untyped:
{
check_member_content( Content );
return true;
}

View File

@ -4,7 +4,7 @@
#endif
String to_string(CodeAttributes attributes) {
return GEN_NS duplicate( attributes->Content, GlobalAllocator );
return {(char*) duplicate( attributes->Content, GlobalAllocator ).Ptr};
}
String to_string(CodeBody body)
@ -68,7 +68,7 @@ void to_string_export( CodeBody body, String* result )
String to_string(CodeComment comment)
{
return GEN_NS duplicate( comment->Content, GlobalAllocator );
return {(char*) duplicate( comment->Content, GlobalAllocator ).Ptr};
}
String to_string(CodeConstructor self)
@ -97,17 +97,17 @@ void to_string_def(CodeConstructor self, String* result )
}
if ( self->Params )
append_fmt( result, "( %S )", GEN_NS to_string(self->Params) );
append_fmt( result, "( %S )", to_string(self->Params) );
else
append( result, "()" );
if ( self->InitializerList )
append_fmt( result, " : %S", GEN_NS to_string(self->InitializerList) );
append_fmt( result, " : %S", to_string(self->InitializerList) );
if ( self->InlineCmt )
append_fmt( result, " // %S", self->InlineCmt->Content );
append_fmt( result, " // %SC", self->InlineCmt->Content );
append_fmt( result, "\n{\n%S\n}\n", GEN_NS to_string(self->Body) );
append_fmt( result, "\n{\n%S\n}\n", to_string(self->Body) );
}
void to_string_fwd(CodeConstructor self, String* result )
@ -121,15 +121,15 @@ void to_string_fwd(CodeConstructor self, String* result )
}
if ( self->Params )
append_fmt( result, "( %S )", GEN_NS to_string(self->Params) );
append_fmt( result, "( %S )", to_string(self->Params) );
else
append_fmt( result, "()");
if (self->Body)
append_fmt( result, " = %S", GEN_NS to_string(self->Body) );
append_fmt( result, " = %S", to_string(self->Body) );
if ( self->InlineCmt )
append_fmt( result, "; // %S\n", self->InlineCmt->Content );
append_fmt( result, "; // %SC\n", self->InlineCmt->Content );
else
append( result, ";\n" );
}
@ -168,7 +168,7 @@ void to_string_def( CodeClass self, String* result )
{
char const* access_level = to_str( ast->ParentAccess );
append_fmt( result, "%S : %s %S", ast->Name, access_level, to_string(ast->ParentType) );
append_fmt( result, "%SC : %s %S", ast->Name, access_level, to_string(ast->ParentType) );
CodeTypename interface = cast(CodeTypename, ast->ParentType->Next);
if ( interface )
@ -187,10 +187,10 @@ void to_string_def( CodeClass self, String* result )
if ( ast->InlineCmt )
{
append_fmt( result, " // %S", ast->InlineCmt->Content );
append_fmt( result, " // %SC", ast->InlineCmt->Content );
}
append_fmt( result, "\n{\n%S\n}", GEN_NS to_string(ast->Body) );
append_fmt( result, "\n{\n%S\n}", to_string(ast->Body) );
if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != CT_Typedef && ast->Parent->Type != CT_Variable ) )
append( result, ";\n");
@ -205,15 +205,15 @@ void to_string_fwd( CodeClass self, String* result )
append( result, "export " );
if ( ast->Attributes )
append_fmt( result, "class %S %S", to_string(ast->Attributes), ast->Name );
append_fmt( result, "class %S %SC", to_string(ast->Attributes), ast->Name );
else append_fmt( result, "class %S", ast->Name );
else append_fmt( result, "class %SC", ast->Name );
// Check if it can have an end-statement
if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != CT_Typedef && ast->Parent->Type != CT_Variable ) )
{
if ( ast->InlineCmt )
append_fmt( result, "; // %S\n", ast->InlineCmt->Content );
append_fmt( result, "; // %SC\n", ast->InlineCmt->Content );
else
append( result,";\n");
}
@ -221,12 +221,12 @@ void to_string_fwd( CodeClass self, String* result )
String to_string(CodeDefine define)
{
return string_fmt_buf( GlobalAllocator, "#define %S %S\n", define->Name, define->Content );
return string_fmt_buf( GlobalAllocator, "#define %SC %SC\n", define->Name, define->Content );
}
void to_string(CodeDefine define, String* result )
{
append_fmt( result, "#define %S %S\n", define->Name, define->Content );
append_fmt( result, "#define %SC %SC\n", define->Name, define->Content );
}
String to_string(CodeDestructor self)
@ -248,19 +248,19 @@ void to_string_def(CodeDestructor self, String* result )
{
if ( self->Name )
{
append_fmt( result, "%S()", self->Name );
append_fmt( result, "%SC()", self->Name );
}
else if ( self->Specs )
{
if ( has(self->Specs, Spec_Virtual ) )
append_fmt( result, "virtual ~%S()", self->Parent->Name );
append_fmt( result, "virtual ~%SC()", self->Parent->Name );
else
append_fmt( result, "~%S()", self->Parent->Name );
append_fmt( result, "~%SC()", self->Parent->Name );
}
else
append_fmt( result, "~%S()", self->Parent->Name );
append_fmt( result, "~%SC()", self->Parent->Name );
append_fmt( result, "\n{\n%S\n}\n", GEN_NS to_string(self->Body) );
append_fmt( result, "\n{\n%S\n}\n", to_string(self->Body) );
}
void to_string_fwd(CodeDestructor self, String* result )
@ -268,20 +268,20 @@ void to_string_fwd(CodeDestructor self, String* result )
if ( self->Specs )
{
if ( has(self->Specs, Spec_Virtual ) )
append_fmt( result, "virtual ~%S();\n", self->Parent->Name );
append_fmt( result, "virtual ~%SC();\n", self->Parent->Name );
else
append_fmt( result, "~%S()", self->Parent->Name );
append_fmt( result, "~%SC()", self->Parent->Name );
if ( has(self->Specs, Spec_Pure ) )
append( result, " = 0;" );
else if (self->Body)
append_fmt( result, " = %S;", GEN_NS to_string(self->Body) );
append_fmt( result, " = %S;", to_string(self->Body) );
}
else
append_fmt( result, "~%S();", self->Parent->Name );
append_fmt( result, "~%SC();", self->Parent->Name );
if ( self->InlineCmt )
append_fmt( result, " %S", self->InlineCmt->Content );
append_fmt( result, " %SC", self->InlineCmt->Content );
else
append( result, "\n");
}
@ -317,24 +317,24 @@ void to_string_def(CodeEnum self, String* result )
append( result, "enum " );
if ( self->Attributes )
append_fmt( result, "%S ", GEN_NS to_string(self->Attributes) );
append_fmt( result, "%S ", to_string(self->Attributes) );
if ( self->UnderlyingType )
append_fmt( result, "%S : %S\n{\n%S\n}"
append_fmt( result, "%SC : %S\n{\n%S\n}"
, self->Name
, to_string(self->UnderlyingType)
, GEN_NS to_string(self->Body)
, to_string(self->Body)
);
else if ( self->UnderlyingTypeMacro )
append_fmt( result, "%S : %S\n{\n%S\n}"
append_fmt( result, "%SC : %S\n{\n%S\n}"
, self->Name
, GEN_NS to_string(self->UnderlyingTypeMacro)
, GEN_NS to_string(self->Body)
, to_string(self->UnderlyingTypeMacro)
, to_string(self->Body)
);
else append_fmt( result, "%S\n{\n%S\n}", self->Name, GEN_NS to_string(self->Body) );
else append_fmt( result, "%SC\n{\n%S\n}", self->Name, to_string(self->Body) );
}
else append_fmt( result, "enum %S\n{\n%S\n}", self->Name, GEN_NS to_string(self->Body) );
else append_fmt( result, "enum %SC\n{\n%S\n}", self->Name, to_string(self->Body) );
if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) )
append( result, ";\n");
@ -346,17 +346,17 @@ void to_string_fwd(CodeEnum self, String* result )
append( result, "export " );
if ( self->Attributes )
append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) );
append_fmt( result, "%S ", to_string(self->Attributes) );
if ( self->UnderlyingType )
append_fmt( result, "enum %S : %S", self->Name, to_string(self->UnderlyingType) );
append_fmt( result, "enum %SC : %S", self->Name, to_string(self->UnderlyingType) );
else
append_fmt( result, "enum %S", self->Name );
append_fmt( result, "enum %SC", self->Name );
if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) )
{
if ( self->InlineCmt )
append_fmt( result, "; %S", self->InlineCmt->Content );
append_fmt( result, "; %SC", self->InlineCmt->Content );
else
append( result, ";\n");
}
@ -373,21 +373,21 @@ void to_string_class_def(CodeEnum self, String* result )
if ( self->Attributes )
{
append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) );
append_fmt( result, "%S ", to_string(self->Attributes) );
}
if ( self->UnderlyingType )
{
append_fmt( result, "%S : %S\n{\n%S\n}", self->Name, to_string(self->UnderlyingType), GEN_NS to_string(self->Body) );
append_fmt( result, "%SC : %S\n{\n%S\n}", self->Name, to_string(self->UnderlyingType), to_string(self->Body) );
}
else
{
append_fmt( result, "%S\n{\n%S\n}", self->Name, GEN_NS to_string(self->Body) );
append_fmt( result, "%SC\n{\n%S\n}", self->Name, to_string(self->Body) );
}
}
else
{
append_fmt( result, "enum class %S\n{\n%S\n}", GEN_NS to_string(self->Body) );
append_fmt( result, "enum %SC\n{\n%S\n}", self->Name, to_string(self->Body) );
}
if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) )
@ -402,14 +402,14 @@ void to_string_class_fwd(CodeEnum self, String* result )
append( result, "enum class " );
if ( self->Attributes )
append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) );
append_fmt( result, "%S ", to_string(self->Attributes) );
append_fmt( result, "%S : %S", self->Name, to_string(self->UnderlyingType) );
append_fmt( result, "%SC : %S", self->Name, to_string(self->UnderlyingType) );
if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) )
{
if ( self->InlineCmt )
append_fmt( result, "; %S", self->InlineCmt->Content );
append_fmt( result, "; %SC", self->InlineCmt->Content );
else
append( result, ";\n");
}
@ -417,25 +417,25 @@ void to_string_class_fwd(CodeEnum self, String* result )
String to_string(CodeExec exec)
{
return GEN_NS duplicate( exec->Content, GlobalAllocator );
return {(char*) duplicate( exec->Content, GlobalAllocator ).Ptr};
}
void to_string(CodeExtern self, String* result )
{
if ( self->Body )
append_fmt( result, "extern \"%S\"\n{\n%S\n}\n", self->Name, GEN_NS to_string(self->Body) );
append_fmt( result, "extern \"%SC\"\n{\n%S\n}\n", self->Name, to_string(self->Body) );
else
append_fmt( result, "extern \"%S\"\n{}\n", self->Name );
append_fmt( result, "extern \"%SC\"\n{}\n", self->Name );
}
String to_string(CodeInclude include)
{
return string_fmt_buf( GlobalAllocator, "#include %S\n", include->Content );
return string_fmt_buf( GlobalAllocator, "#include %SC\n", include->Content );
}
void to_string( CodeInclude include, String* result )
{
append_fmt( result, "#include %S\n", include->Content );
append_fmt( result, "#include %SC\n", include->Content );
}
String to_string(CodeFriend self)
@ -447,15 +447,15 @@ String to_string(CodeFriend self)
void to_string(CodeFriend self, String* result )
{
append_fmt( result, "friend %S", GEN_NS to_string(self->Declaration) );
append_fmt( result, "friend %S", to_string(self->Declaration) );
if ( self->Declaration->Type != CT_Function && (* result)[ length(* result) - 1 ] != ';' )
if ( self->Declaration->Type != CT_Function && self->Declaration->Type != CT_Operator && (* result)[ length(* result) - 1 ] != ';' )
{
append( result, ";" );
}
if ( self->InlineCmt )
append_fmt( result, " %S", self->InlineCmt->Content );
append_fmt( result, " %SC", self->InlineCmt->Content );
else
append( result, "\n");
}
@ -481,7 +481,7 @@ void to_string_def(CodeFn self, String* result )
append( result, "export" );
if ( self->Attributes )
append_fmt( result, " %S ",GEN_NS to_string(self->Attributes) );
append_fmt( result, " %S ", to_string(self->Attributes) );
bool prefix_specs = false;
if ( self->Specs )
@ -502,13 +502,13 @@ void to_string_def(CodeFn self, String* result )
append( result, "\n" );
if ( self->ReturnType )
append_fmt( result, "%S %S(", to_string(self->ReturnType), self->Name );
append_fmt( result, "%S %SC(", to_string(self->ReturnType), self->Name );
else
append_fmt( result, "%S(", self->Name );
append_fmt( result, "%SC(", self->Name );
if ( self->Params )
append_fmt( result, "%S)", GEN_NS to_string(self->Params) );
append_fmt( result, "%S)", to_string(self->Params) );
else
append( result, ")" );
@ -525,7 +525,7 @@ void to_string_def(CodeFn self, String* result )
}
}
append_fmt( result, "\n{\n%S\n}\n", GEN_NS to_string(self->Body) );
append_fmt( result, "\n{\n%S\n}\n", to_string(self->Body) );
}
void to_string_fwd(CodeFn self, String* result )
@ -534,7 +534,7 @@ void to_string_fwd(CodeFn self, String* result )
append( result, "export " );
if ( self->Attributes )
append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) );
append_fmt( result, "%S ", to_string(self->Attributes) );
b32 prefix_specs = false;
if ( self->Specs )
@ -557,13 +557,13 @@ void to_string_fwd(CodeFn self, String* result )
}
if ( self->ReturnType )
append_fmt( result, "%S %S(", to_string(self->ReturnType), self->Name );
append_fmt( result, "%S %SC(", to_string(self->ReturnType), self->Name );
else
append_fmt( result, "%S(", self->Name );
append_fmt( result, "%SC(", self->Name );
if ( self->Params )
append_fmt( result, "%S)", GEN_NS to_string(self->Params) );
append_fmt( result, "%S)", to_string(self->Params) );
else
append( result, ")" );
@ -583,10 +583,10 @@ void to_string_fwd(CodeFn self, String* result )
if ( self->Specs && has(self->Specs, Spec_Pure ) >= 0 )
append( result, " = 0;" );
else if (self->Body)
append_fmt( result, " = %S;", GEN_NS to_string(self->Body) );
append_fmt( result, " = %S;", to_string(self->Body) );
if ( self->InlineCmt )
append_fmt( result, "; %S", self->InlineCmt->Content );
append_fmt( result, "; %SC", self->InlineCmt->Content );
else
append( result, ";\n" );
}
@ -606,7 +606,7 @@ void to_string(CodeModule self, String* result )
if (((u32(ModuleFlag_Import) & u32(self->ModuleFlags)) == u32(ModuleFlag_Import)))
append( result, "import ");
append_fmt( result, "%S;\n", self->Name );
append_fmt( result, "%SC;\n", self->Name );
}
String to_string(CodeNS self)
@ -621,7 +621,7 @@ void to_string(CodeNS self, String* result )
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
append( result, "export " );
append_fmt( result, "namespace %S\n{\n%S\n}\n", self->Name, to_string(self->Body) );
append_fmt( result, "namespace %SC\n{\n%S\n}\n", self->Name, to_string(self->Body) );
}
String to_string(CodeOperator self)
@ -647,10 +647,10 @@ void to_string_def(CodeOperator self, String* result )
append( result, "export " );
if ( self->Attributes )
append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) );
append_fmt( result, "%S ", to_string(self->Attributes) );
if ( self->Attributes )
append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) );
append_fmt( result, "%S ", to_string(self->Attributes) );
if ( self->Specs )
{
@ -670,10 +670,10 @@ void to_string_def(CodeOperator self, String* result )
}
if ( self->ReturnType )
append_fmt( result, "%S %S (", GEN_NS to_string(self->ReturnType), self->Name );
append_fmt( result, "%S %SC (", to_string(self->ReturnType), self->Name );
if ( self->Params )
append_fmt( result, "%S)", GEN_NS to_string(self->Params) );
append_fmt( result, "%S)", to_string(self->Params) );
else
append( result, ")" );
@ -691,7 +691,7 @@ void to_string_def(CodeOperator self, String* result )
}
append_fmt( result, "\n{\n%S\n}\n"
, GEN_NS to_string(self->Body)
, to_string(self->Body)
);
}
@ -701,7 +701,7 @@ void to_string_fwd(CodeOperator self, String* result )
append( result, "export " );
if ( self->Attributes )
append_fmt( result, "%S\n",GEN_NS to_string(self->Attributes) );
append_fmt( result, "%S\n", to_string(self->Attributes) );
if ( self->Specs )
{
@ -720,10 +720,10 @@ void to_string_fwd(CodeOperator self, String* result )
append( result, "\n" );
}
append_fmt( result, "%S %S (", to_string(self->ReturnType), self->Name );
append_fmt( result, "%S %SC (", to_string(self->ReturnType), self->Name );
if ( self->Params )
append_fmt( result, "%S)", GEN_NS to_string(self->Params) );
append_fmt( result, "%S)", to_string(self->Params) );
else
append_fmt( result, ")" );
@ -741,7 +741,7 @@ void to_string_fwd(CodeOperator self, String* result )
}
if ( self->InlineCmt )
append_fmt( result, "; %S", self->InlineCmt->Content );
append_fmt( result, "; %SC", self->InlineCmt->Content );
else
append( result, ";\n" );
}
@ -774,8 +774,8 @@ void to_string_def(CodeOpCast self, String* result )
}
}
if ( self->Name && length(self->Name) )
append_fmt( result, "%Soperator %S()", self->Name, to_string(self->ValueType) );
if ( self->Name && self->Name.Len )
append_fmt( result, "%SC operator %S()", self->Name, to_string(self->ValueType) );
else
append_fmt( result, "operator %S()", to_string(self->ValueType) );
@ -788,14 +788,14 @@ void to_string_def(CodeOpCast self, String* result )
}
}
append_fmt( result, "\n{\n%S\n}\n", GEN_NS to_string(self->Body) );
append_fmt( result, "\n{\n%S\n}\n", to_string(self->Body) );
return;
}
if ( self->Name && length(self->Name) )
append_fmt( result, "%Soperator %S()\n{\n%S\n}\n", self->Name, to_string(self->ValueType), GEN_NS to_string(self->Body) );
if ( self->Name && self->Name.Len )
append_fmt( result, "%SC operator %S()\n{\n%S\n}\n", self->Name, to_string(self->ValueType), to_string(self->Body) );
else
append_fmt( result, "operator %S()\n{\n%S\n}\n", to_string(self->ValueType), GEN_NS to_string(self->Body) );
append_fmt( result, "operator %S()\n{\n%S\n}\n", to_string(self->ValueType), to_string(self->Body) );
}
void to_string_fwd(CodeOpCast self, String* result )
@ -823,7 +823,7 @@ void to_string_fwd(CodeOpCast self, String* result )
}
if ( self->InlineCmt )
append_fmt( result, "; %S", self->InlineCmt->Content );
append_fmt( result, "; %SC", self->InlineCmt->Content );
else
append( result, ";\n" );
return;
@ -848,16 +848,16 @@ void to_string( CodeParam self, String* result )
if ( ast->Macro )
{
// Related to parsing: ( <macro>, ... )
GEN_NS append( result, ast->Macro.ast->Content );
append( result, ast->Macro.ast->Content );
// Could also be: ( <macro> <type <name>, ... )
}
if ( ast->Name )
{
if ( ast->ValueType.ast == nullptr )
append_fmt( result, " %S", ast->Name );
append_fmt( result, " %SC", ast->Name );
else
append_fmt( result, " %S %S", to_string(ast->ValueType), ast->Name );
append_fmt( result, " %S %SC", to_string(ast->ValueType), ast->Name );
}
else if ( ast->ValueType )
@ -865,11 +865,11 @@ void to_string( CodeParam self, String* result )
if ( ast->PostNameMacro )
{
append_fmt( result, " %S", GEN_NS to_string(ast->PostNameMacro) );
append_fmt( result, " %S", to_string(ast->PostNameMacro) );
}
if ( ast->Value )
append_fmt( result, " = %S", GEN_NS to_string(ast->Value) );
append_fmt( result, " = %S", to_string(ast->Value) );
if ( ast->NumEntries - 1 > 0 )
{
@ -909,22 +909,22 @@ String to_string(CodePreprocessCond self)
void to_string_if(CodePreprocessCond cond, String* result )
{
append_fmt( result, "#if %S\n", cond->Content );
append_fmt( result, "#if %SC\n", cond->Content );
}
void to_string_ifdef(CodePreprocessCond cond, String* result )
{
append_fmt( result, "#ifdef %S\n", cond->Content );
append_fmt( result, "#ifdef %SC\n", cond->Content );
}
void to_string_ifndef(CodePreprocessCond cond, String* result )
{
append_fmt( result, "#ifndef %S\n", cond->Content );
append_fmt( result, "#ifndef %SC\n", cond->Content );
}
void to_string_elif(CodePreprocessCond cond, String* result )
{
append_fmt( result, "#elif %S\n", cond->Content );
append_fmt( result, "#elif %SC\n", cond->Content );
}
void to_string_else(CodePreprocessCond cond, String* result )
@ -946,7 +946,7 @@ String to_string(CodePragma self)
void to_string(CodePragma self, String* result )
{
append_fmt( result, "#pragma %S\n", self->Content );
append_fmt( result, "#pragma %SC\n", self->Content );
}
String to_string(CodeSpecifiers self)
@ -998,14 +998,14 @@ void to_string_def( CodeStruct self, String* result )
if ( ast->Attributes )
{
append_fmt( result, "%S ",GEN_NS to_string(ast->Attributes) );
append_fmt( result, "%S ", to_string(ast->Attributes) );
}
if ( ast->ParentType )
{
char const* access_level = to_str( ast->ParentAccess );
append_fmt( result, "%S : %s %S", ast->Name, access_level, GEN_NS to_string(ast->ParentType) );
append_fmt( result, "%SC : %s %S", ast->Name, access_level, to_string(ast->ParentType) );
CodeTypename interface = cast(CodeTypename, ast->ParentType->Next);
if ( interface )
@ -1013,7 +1013,7 @@ void to_string_def( CodeStruct self, String* result )
while ( interface )
{
append_fmt( result, ", %S", GEN_NS to_string(interface) );
append_fmt( result, ", %S", to_string(interface) );
interface = interface->Next ? cast( CodeTypename, interface->Next) : CodeTypename { nullptr };
}
}
@ -1024,10 +1024,10 @@ void to_string_def( CodeStruct self, String* result )
if ( ast->InlineCmt )
{
append_fmt( result, " // %S", ast->InlineCmt->Content );
append_fmt( result, " // %SC", ast->InlineCmt->Content );
}
append_fmt( result, "\n{\n%S\n}", GEN_NS to_string(ast->Body) );
append_fmt( result, "\n{\n%S\n}", to_string(ast->Body) );
if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != CT_Typedef && ast->Parent->Type != CT_Variable ) )
append( result, ";\n");
@ -1042,14 +1042,14 @@ void to_string_fwd( CodeStruct self, String* result )
append( result, "export " );
if ( ast->Attributes )
append_fmt( result, "struct %S %S", GEN_NS to_string(ast->Attributes), ast->Name );
append_fmt( result, "struct %S %SC", to_string(ast->Attributes), ast->Name );
else append_fmt( result, "struct %S", ast->Name );
else append_fmt( result, "struct %SC", ast->Name );
if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != CT_Typedef && ast->Parent->Type != CT_Variable ) )
{
if ( ast->InlineCmt )
append_fmt( result, "; %S", ast->InlineCmt->Content );
append_fmt( result, "; %SC", ast->InlineCmt->Content );
else
append( result, ";\n");
}
@ -1068,9 +1068,9 @@ void to_string(CodeTemplate self, String* result )
append( result, "export " );
if ( self->Params )
append_fmt( result, "template< %S >\n%S", GEN_NS to_string(self->Params), GEN_NS to_string(self->Declaration) );
append_fmt( result, "template< %S >\n%S", to_string(self->Params), to_string(self->Declaration) );
else
append_fmt( result, "template<>\n%S", GEN_NS to_string(self->Declaration) );
append_fmt( result, "template<>\n%S", to_string(self->Declaration) );
}
String to_string(CodeTypedef self)
@ -1089,18 +1089,18 @@ void to_string(CodeTypedef self, String* result )
// Determines if the typedef is a function typename
if ( self->UnderlyingType->ReturnType )
append( result, GEN_NS to_string(self->UnderlyingType) );
append( result, to_string(self->UnderlyingType) );
else
append_fmt( result, "%S %S", GEN_NS to_string(self->UnderlyingType), self->Name );
append_fmt( result, "%S %SC", to_string(self->UnderlyingType), self->Name );
if ( self->UnderlyingType->Type == CT_Typename && self->UnderlyingType->ArrExpr )
{
append_fmt( result, "[ %S ];", GEN_NS to_string(self->UnderlyingType->ArrExpr) );
append_fmt( result, "[ %S ];", to_string(self->UnderlyingType->ArrExpr) );
Code next_arr_expr = self->UnderlyingType->ArrExpr->Next;
while ( next_arr_expr )
{
append_fmt( result, "[ %S ];", GEN_NS to_string(next_arr_expr) );
append_fmt( result, "[ %S ];", to_string(next_arr_expr) );
next_arr_expr = next_arr_expr->Next;
}
}
@ -1110,7 +1110,7 @@ void to_string(CodeTypedef self, String* result )
}
if ( self->InlineCmt )
append_fmt( result, " %S", self->InlineCmt->Content);
append_fmt( result, " %SC", self->InlineCmt->Content);
else
append( result, "\n");
}
@ -1128,13 +1128,13 @@ void to_string(CodeTypename self, String* result )
if ( self->ReturnType && self->Params )
{
if ( self->Attributes )
append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) );
append_fmt( result, "%S ", to_string(self->Attributes) );
else
{
if ( self->Specs )
append_fmt( result, "%S ( %S ) ( %S ) %S", self->ReturnType.to_string(), self->Name, self->Params.to_string(), self->Specs.to_string() );
append_fmt( result, "%S ( %SC ) ( %S ) %S", to_string(self->ReturnType), self->Name, to_string(self->Params), to_string(self->Specs) );
else
append_fmt( result, "%S ( %S ) ( %S )", self->ReturnType.to_string(), self->Name, self->Params.to_string() );
append_fmt( result, "%S ( %SC ) ( %S )", to_string(self->ReturnType), self->Name, to_string(self->Params) );
}
break;
@ -1143,13 +1143,13 @@ void to_string(CodeTypename self, String* result )
if ( self->ReturnType && self->Params )
{
if ( self->Attributes )
append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) );
append_fmt( result, "%S ", to_string(self->Attributes) );
else
{
if ( self->Specs )
append_fmt( result, "%S %S ( %S ) %S", GEN_NS to_string(self->ReturnType), self->Name, GEN_NS to_string(self->Params), GEN_NS to_string(self->Specs) );
append_fmt( result, "%S %SC ( %S ) %S", to_string(self->ReturnType), self->Name, to_string(self->Params), to_string(self->Specs) );
else
append_fmt( result, "%S %S ( %S )", GEN_NS to_string(self->ReturnType), self->Name, GEN_NS to_string(self->Params) );
append_fmt( result, "%S %SC ( %S )", to_string(self->ReturnType), self->Name, to_string(self->Params) );
}
return;
@ -1157,12 +1157,12 @@ void to_string(CodeTypename self, String* result )
#endif
if ( self->Attributes )
append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) );
append_fmt( result, "%S ", to_string(self->Attributes) );
if ( self->Specs )
append_fmt( result, "%S %S", self->Name, GEN_NS to_string(self->Specs) );
append_fmt( result, "%SC %S", self->Name, to_string(self->Specs) );
else
append_fmt( result, "%S", self->Name );
append_fmt( result, "%SC", self->Name );
if ( self->IsParamPack )
append( result, "...");
@ -1183,11 +1183,11 @@ void to_string(CodeUnion self, String* result )
append( result, "union " );
if ( self->Attributes )
append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) );
append_fmt( result, "%S ", to_string(self->Attributes) );
if ( self->Name )
{
append_fmt( result, "%S\n{\n%S\n}"
append_fmt( result, "%SC\n{\n%S\n}"
, self->Name
, GEN_NS to_string(self->Body)
);
@ -1225,20 +1225,20 @@ void to_string(CodeUsing self, String* result )
append( result, "export " );
if ( self->Attributes )
append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) );
append_fmt( result, "%S ", to_string(self->Attributes) );
if ( self->UnderlyingType )
{
append_fmt( result, "using %S = %S", self->Name, GEN_NS to_string(self->UnderlyingType) );
append_fmt( result, "using %SC = %S", self->Name, to_string(self->UnderlyingType) );
if ( self->UnderlyingType->ArrExpr )
{
append_fmt( result, "[ %S ]", GEN_NS to_string(self->UnderlyingType->ArrExpr) );
append_fmt( result, "[ %S ]", to_string(self->UnderlyingType->ArrExpr) );
Code next_arr_expr = self->UnderlyingType->ArrExpr->Next;
while ( next_arr_expr )
{
append_fmt( result, "[ %S ]", GEN_NS to_string(next_arr_expr) );
append_fmt( result, "[ %S ]", to_string(next_arr_expr) );
next_arr_expr = next_arr_expr->Next;
}
}
@ -1246,10 +1246,10 @@ void to_string(CodeUsing self, String* result )
append( result, ";" );
}
else
append_fmt( result, "using %S;", self->Name );
append_fmt( result, "using %SC;", self->Name );
if ( self->InlineCmt )
append_fmt( result, " %S\n", self->InlineCmt->Content );
append_fmt( result, " %SC\n", self->InlineCmt->Content );
else
append( result, "\n");
}
@ -1257,9 +1257,9 @@ void to_string(CodeUsing self, String* result )
void to_string_ns(CodeUsing self, String* result )
{
if ( self->InlineCmt )
append_fmt( result, "using namespace $S; %S", self->Name, self->InlineCmt->Content );
append_fmt( result, "using namespace $SC; %SC", self->Name, self->InlineCmt->Content );
else
append_fmt( result, "using namespace %s;\n", self->Name );
append_fmt( result, "using namespace %SC;\n", self->Name );
}
String to_string(CodeVar self)
@ -1276,18 +1276,18 @@ void to_string(CodeVar self, String* result )
// Its a comma-separated variable ( a NextVar )
if ( self->Specs )
append_fmt( result, "%S ", GEN_NS to_string(self->Specs) );
append_fmt( result, "%S ", to_string(self->Specs) );
append( result, self->Name );
if ( self->ValueType->ArrExpr )
{
append_fmt( result, "[ %S ]", GEN_NS to_string(self->ValueType->ArrExpr) );
append_fmt( result, "[ %S ]", to_string(self->ValueType->ArrExpr) );
Code next_arr_expr = self->ValueType->ArrExpr->Next;
while ( next_arr_expr )
{
append_fmt( result, "[ %S ]", GEN_NS to_string(next_arr_expr) );
append_fmt( result, "[ %S ]", to_string(next_arr_expr) );
next_arr_expr = next_arr_expr->Next;
}
}
@ -1295,14 +1295,14 @@ void to_string(CodeVar self, String* result )
if ( self->Value )
{
if ( self->VarConstructorInit )
append_fmt( result, "( %S ", GEN_NS to_string(self->Value) );
append_fmt( result, "( %S ", to_string(self->Value) );
else
append_fmt( result, " = %S", GEN_NS to_string(self->Value) );
append_fmt( result, " = %S", to_string(self->Value) );
}
// Keep the chain going...
if ( self->NextVar )
append_fmt( result, ", %S", self->NextVar.to_string() );
append_fmt( result, ", %S", to_string(self->NextVar) );
if ( self->VarConstructorInit )
append( result, " )");
@ -1316,44 +1316,44 @@ void to_string(CodeVar self, String* result )
if ( self->Attributes || self->Specs )
{
if ( self->Attributes )
append_fmt( result, "%S ", GEN_NS to_string(self->Specs) );
append_fmt( result, "%S ", to_string(self->Specs) );
if ( self->Specs )
append_fmt( result, "%S\n", GEN_NS to_string(self->Specs) );
append_fmt( result, "%S\n", to_string(self->Specs) );
append_fmt( result, "%S %S", GEN_NS to_string(self->ValueType), self->Name );
append_fmt( result, "%S %SC", to_string(self->ValueType), self->Name );
if ( self->ValueType->ArrExpr )
{
append_fmt( result, "[ %S ]", GEN_NS to_string(self->ValueType->ArrExpr) );
append_fmt( result, "[ %S ]", to_string(self->ValueType->ArrExpr) );
Code next_arr_expr = self->ValueType->ArrExpr->Next;
while ( next_arr_expr )
{
append_fmt( result, "[ %S ]", GEN_NS to_string(next_arr_expr) );
append_fmt( result, "[ %S ]", to_string(next_arr_expr) );
next_arr_expr = next_arr_expr->Next;
}
}
if ( self->BitfieldSize )
append_fmt( result, " : %S", GEN_NS to_string(self->BitfieldSize) );
append_fmt( result, " : %S", to_string(self->BitfieldSize) );
if ( self->Value )
{
if ( self->VarConstructorInit )
append_fmt( result, "( %S ", GEN_NS to_string(self->Value) );
append_fmt( result, "( %S ", to_string(self->Value) );
else
append_fmt( result, " = %S", GEN_NS to_string(self->Value) );
append_fmt( result, " = %S", to_string(self->Value) );
}
if ( self->NextVar )
append_fmt( result, ", %S", self->NextVar.to_string() );
append_fmt( result, ", %S", to_string(self->NextVar) );
if ( self->VarConstructorInit )
append( result, " )");
if ( self->InlineCmt )
append_fmt( result, "; %S", self->InlineCmt->Content);
append_fmt( result, "; %SC", self->InlineCmt->Content);
else
append( result, ";\n" );
@ -1361,33 +1361,33 @@ void to_string(CodeVar self, String* result )
}
if ( self->BitfieldSize )
append_fmt( result, "%S %S : %S", GEN_NS to_string(self->ValueType), self->Name, GEN_NS to_string(self->BitfieldSize) );
append_fmt( result, "%S %SC : %S", to_string(self->ValueType), self->Name, to_string(self->BitfieldSize) );
else if ( self->ValueType->ArrExpr )
{
append_fmt( result, "%S %S[ %S ]", GEN_NS to_string(self->ValueType), self->Name, GEN_NS to_string(self->ValueType->ArrExpr) );
append_fmt( result, "%S %SC[ %S ]", to_string(self->ValueType), self->Name, to_string(self->ValueType->ArrExpr) );
Code next_arr_expr = self->ValueType->ArrExpr->Next;
while ( next_arr_expr )
{
append_fmt( result, "[ %S ]", GEN_NS to_string(next_arr_expr) );
append_fmt( result, "[ %S ]", to_string(next_arr_expr) );
next_arr_expr = next_arr_expr->Next;
}
}
else
append_fmt( result, "%S %S", GEN_NS to_string(self->ValueType), self->Name );
append_fmt( result, "%S %SC", to_string(self->ValueType), self->Name );
if ( self->Value )
{
if ( self->VarConstructorInit )
append_fmt( result, "( %S ", GEN_NS to_string(self->Value) );
append_fmt( result, "( %S ", to_string(self->Value) );
else
append_fmt( result, " = %S", GEN_NS to_string(self->Value) );
append_fmt( result, " = %S", to_string(self->Value) );
}
if ( self->NextVar )
append_fmt( result, ", %S", self->NextVar.to_string() );
append_fmt( result, ", %S", to_string( self->NextVar) );
if ( self->VarConstructorInit )
append( result, " )");
@ -1395,7 +1395,7 @@ void to_string(CodeVar self, String* result )
append( result, ";" );
if ( self->InlineCmt )
append_fmt( result, " %S", self->InlineCmt->Content);
append_fmt( result, " %SC", self->InlineCmt->Content);
else
append( result, "\n");
}

View File

@ -211,9 +211,9 @@ struct CodeSpecifiers
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
Using_Code( CodeSpecifiers );
bool append( SpecifierT spec ) { return GEN_NS append(* this, spec); }
s32 has( SpecifierT spec ) { return GEN_NS has(* this, spec); }
s32 remove( SpecifierT to_remove ) { return GEN_NS remove(* this, to_remove); }
bool append( Specifier spec ) { return GEN_NS append(* this, spec); }
s32 has( Specifier spec ) { return GEN_NS has(* this, spec); }
s32 remove( Specifier to_remove ) { return GEN_NS remove(* this, to_remove); }
String to_string() { return GEN_NS to_string(* this ); }
void to_string( String& result ) { return GEN_NS to_string(* this, & result); }
#endif
@ -959,7 +959,7 @@ struct CodeTypedef
struct CodeUnion
{
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
Using_Code( CodeUnion );
String to_string() { return GEN_NS to_string(* this); }
@ -974,7 +974,7 @@ struct CodeUnion
struct CodeUsing
{
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
Using_Code( CodeUsing );
String to_string() { return GEN_NS to_string(* this); }
@ -990,7 +990,7 @@ struct CodeUsing
struct CodeVar
{
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
Using_Code( CodeVar );
String to_string() { return GEN_NS to_string(* this); }

View File

@ -5,8 +5,6 @@
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
typedef enum CodeType_Def CodeType;
enum CodeType_Def : u32
{
CT_Invalid,
@ -71,6 +69,7 @@ enum CodeType_Def : u32
CT_Variable,
CT_NumTypes
};
typedef enum CodeType_Def CodeType;
inline StrC to_str( CodeType type )
{

View File

@ -5,8 +5,6 @@
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
typedef enum Operator_Def Operator;
enum Operator_Def : u32
{
Op_Invalid,
@ -58,6 +56,7 @@ enum Operator_Def : u32
Op_DeleteArray,
NumOps
};
typedef enum Operator_Def Operator;
inline StrC to_str( Operator op )
{

View File

@ -5,8 +5,6 @@
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
typedef enum Specifier_Def Specifier;
enum Specifier_Def : u32
{
Spec_Invalid,
@ -37,6 +35,7 @@ enum Specifier_Def : u32
Spec_Volatile,
Spec_NumSpecifiers
};
typedef enum Specifier_Def Specifier;
inline bool is_trailing( Specifier specifier )
{

View File

@ -8,8 +8,6 @@
GEN_NS_PARSER_BEGIN
#define GEN_DEFINE_ATTRIBUTE_TOKENS Entry( Tok_Attribute_API_Export, "GEN_API_Export_Code" ) Entry( Tok_Attribute_API_Import, "GEN_API_Import_Code" )
typedef enum TokType_Def TokType;
enum TokType_Def : u32
{
Tok_Invalid,
@ -111,6 +109,7 @@ enum TokType_Def : u32
Tok_Attribute_API_Import,
Tok_NumTokens
};
typedef enum TokType_Def TokType;
inline StrC to_str( TokType type )
{

View File

@ -134,7 +134,7 @@ Code begin( CodeBody body) {
}
inline
Code end(CodeBody body ){
return { rcast(AST*, body.ast)->Back->Next };
return { nullptr };
}
#pragma endregion CodeBody

View File

@ -75,8 +75,8 @@ internal
void define_constants()
{
Code_Global = make_code();
scast(String, Code_Global->Name) = get_cached_string( txt("Global Code") );
scast(String, Code_Global->Content) = Code_Global->Name;
Code_Global->Name = get_cached_string( txt("Global Code") );
Code_Global->Content = Code_Global->Name;
Code_Invalid = make_code();
set_global(Code_Invalid);
@ -403,9 +403,9 @@ StringCached get_cached_string( StrC str )
}
String result = string_make( get_string_allocator( str.Len ), str );
set<StringCached>(& StringCache, key, result );
set(& StringCache, key, { length(result), result } );
return result;
return { length(result), result };
}
// Used internally to retireve a Code object form the CodePool.

View File

@ -11,13 +11,13 @@ ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va )
local_persist
Arena tok_map_arena;
HashTable<StrC> tok_map;
HashTable(StrC) tok_map;
{
local_persist
char tok_map_mem[ TokenFmt_TokenMap_MemSize ];
tok_map_arena = arena_init_from_memory( tok_map_mem, sizeof(tok_map_mem) );
tok_map = hashtable_init<StrC>( allocator_info(& tok_map_arena) );
tok_map = hashtable_init(StrC, allocator_info(& tok_map_arena) );
s32 left = num_tokens - 1;

View File

@ -485,7 +485,7 @@ CodeComment def_comment( StrC content )
Code
result = make_code();
result->Type = CT_Comment;
result->Name = get_cached_string( cmt_formatted );
result->Name = get_cached_string( { length(cmt_formatted), cmt_formatted } );
result->Content = result->Name;
free(& cmt_formatted);

View File

@ -357,7 +357,7 @@ s32 lex_preprocessor_directive( LexContext* ctx )
, current
, preprocess_content.Line
, preprocess_content.Column
, directive_str.Data
, (char*) directive_str
);
return Lex_ReturnNull;
}
@ -578,11 +578,11 @@ TokArray lex( StrC content )
return { {}, 0 };
}
foreach( StringCached, entry, PreprocessorDefines )
foreach( StringCached*, entry, PreprocessorDefines )
{
s32 length = 0;
char const* scanner = entry.Data;
while ( GEN_NS length(entry) > length && (char_is_alphanumeric( *scanner ) || *scanner == '_') )
char const* scanner = * entry;
while ( entry->Len > length && (char_is_alphanumeric( *scanner ) || *scanner == '_') )
{
c.scanner++;
length ++;
@ -592,8 +592,8 @@ TokArray lex( StrC content )
length++;
}
u64 key = crc32( entry.Data, length );
set(& c.defines, key, (StrC)entry );
u64 key = crc32( * entry, length );
set(& c.defines, key, (StrC) * entry );
}
clear(Tokens);

View File

@ -669,7 +669,7 @@ CodeAttributes parse_attributes()
Code result = make_code();
result->Type = CT_PlatformAttributes;
result->Name = get_cached_string( name_stripped );
result->Name = get_cached_string( { length(name_stripped), name_stripped } );
result->Content = result->Name;
// result->Token =
@ -905,11 +905,11 @@ CodeBody parse_class_struct_body( TokType which, Token name )
break;
case Tok_Operator:
if ( currtok.Text[0] != '~' )
{
log_failure( "Operator token found in global body but not destructor unary negation\n%s", to_string(Context) );
return InvalidCode;
}
//if ( currtok.Text[0] != '~' )
//{
// log_failure( "Operator token found in global body but not destructor unary negation\n%s", to_string(Context) );
// return InvalidCode;
//}
member = parse_destructor();
// ~<Name>()
@ -1047,10 +1047,10 @@ CodeBody parse_class_struct_body( TokType which, Token name )
if ( attributes )
{
String fused = string_make_reserve( GlobalAllocator, length(attributes->Content) + length(more_attributes->Content) );
String fused = string_make_reserve( GlobalAllocator, attributes->Content.Len + more_attributes->Content.Len );
append_fmt( & fused, "%S %S", attributes->Content, more_attributes->Content );
attributes->Name = get_cached_string(fused);
attributes->Name = get_cached_string({ length(fused), fused });
attributes->Content = attributes->Name;
// <Attributes> <Specifiers> <Attributes>
}
@ -1344,7 +1344,7 @@ CodeDefine parse_define()
return define;
}
define->Content = get_cached_string( strip_formatting( to_str(currtok), strip_formatting_dont_preserve_newlines ) );
define->Content = get_cached_string( to_strc( strip_formatting( to_str(currtok), strip_formatting_dont_preserve_newlines )) );
eat( Tok_Preprocess_Content );
// #define <Name> <Content>
@ -1494,7 +1494,7 @@ CodeFn parse_function_after_name(
CodeFn
result = (CodeFn) make_code();
result->Name = get_cached_string( name_stripped );
result->Name = get_cached_string( to_strc(name_stripped) );
result->ModuleFlags = mflags;
if ( body )
@ -2730,7 +2730,7 @@ CodeParam parse_params( bool use_template_capture )
eat( currtok.Type );
}
value = untyped_str( strip_formatting( to_str(value_tok), strip_formatting_dont_preserve_newlines ) );
value = untyped_str( to_strc(strip_formatting( to_str(value_tok), strip_formatting_dont_preserve_newlines )) );
// ( <Macro> <ValueType> <Name> = <Expression>
}
}
@ -2845,7 +2845,7 @@ CodeParam parse_params( bool use_template_capture )
eat( currtok.Type );
}
value = untyped_str( strip_formatting( to_str(value_tok), strip_formatting_dont_preserve_newlines ) );
value = untyped_str( to_strc(strip_formatting( to_str(value_tok), strip_formatting_dont_preserve_newlines )) );
// ( <Macro> <ValueType> <Name> = <Expression>, <Macro> <ValueType> <Name> = <Expression>
}
// ( <Macro> <ValueType> <Name> = <Expression>, <Macro> <ValueType> <Name> = <Expression>, ..
@ -3860,6 +3860,7 @@ CodeFriend parse_friend()
// friend
CodeFn function = { nullptr };
CodeOperator op = { nullptr };
// Type declaration or return type
CodeTypename type = parse_type();
@ -3893,6 +3894,12 @@ CodeFriend parse_friend()
// function->Params = params;
}
// Operator declaration or definition
if ( currtok.Type == Tok_Decl_Operator )
{
op = parse_operator_after_ret_type( ModuleFlag_None, NullCode, NullCode, type );
}
CodeComment inline_cmt = NullCode;
if ( function && function->Type == CT_Function_Fwd )
{
@ -3912,6 +3919,8 @@ CodeFriend parse_friend()
if ( function )
result->Declaration = function;
else if ( op )
result->Declaration = op;
else
result->Declaration = type;
@ -4132,7 +4141,7 @@ CodeOpCast parse_operator_cast( CodeSpecifiers specifiers )
Code type = parse_type();
// <Specifiers> <Qualifier> :: ... operator <UnderlyingType>
Context.Scope->Name = { type->Name.Data, length(type->Name) };
Context.Scope->Name = { type->Name.Ptr, type->Name.Len };
eat( Tok_Capture_Start );
eat( Tok_Capture_End );
@ -4820,7 +4829,7 @@ else if ( currtok.Type == Tok_DeclType )
}
#endif
result->Name = get_cached_string( name_stripped );
result->Name = get_cached_string( to_strc(name_stripped) );
if ( attributes )
result->Attributes = attributes;

View File

@ -152,7 +152,7 @@ bool append(Array<Type>* array, Type value)
if (header->Num == header->Capacity)
{
if (!grow(array, header->Capacity))
if ( ! grow(array, header->Capacity))
return false;
header = get_header(* array);
}
@ -170,12 +170,12 @@ bool append(Array<Type>* array, Type* items, usize item_num)
if (header->Num + item_num > header->Capacity)
{
if (!grow(array, header->Capacity + item_num))
if ( ! grow(array, header->Capacity + item_num))
return false;
header = get_header(array);
}
mem_copy(array.Data + header->Num, items, item_num * sizeof(Type));
mem_copy((Type*)array + header->Num, items, item_num * sizeof(Type));
header->Num += item_num;
return true;

View File

@ -212,11 +212,7 @@
// This is intended to only really be used internally or with the C-library variant
// C++ users can just use the for-range directly.
#if GEN_COMPILER_C
# define foreach(Type, entry_id, iterable) for ( Type entry_id = begin(iterable); entry_id != end(iterable); entry_id = next(iterable, entry_id) )
#else
# define foreach(Type, entry_id, iterable) for ( Type entry_id : iterable )
#endif
#define foreach(Type, entry_id, iterable) for ( Type entry_id = begin(iterable); entry_id != end(iterable); entry_id = next(iterable, entry_id) )
#if GEN_COMPILER_C
# if __STDC_VERSION__ >= 202311L

View File

@ -420,6 +420,15 @@ neverinline ssize str_fmt_va( char* text, ssize max_len, char const* fmt, va_lis
case 'S':
{
if ( *(fmt + 1) == 'C' )
{
++ fmt;
StrC gen_str = va_arg( va, StrC);
info.precision = gen_str.Len;
len = _print_string( text, remaining, &info, gen_str.Ptr );
break;
}
String gen_str = String { va_arg( va, char*) };
info.precision = length(gen_str);

View File

@ -5,6 +5,16 @@
#pragma region Strings
struct StrC;
bool are_equal (StrC lhs, StrC rhs);
char const* back (StrC str);
bool contains (StrC str, StrC substring);
StrC duplicate (StrC str, AllocatorInfo allocator);
b32 starts_with (StrC str, StrC substring);
StrC to_str (char const* bad_string);
StrC visualize_whitespace(StrC str, AllocatorInfo allocator);
// Constant string with length.
struct StrC
{
@ -14,15 +24,71 @@ struct StrC
#if ! GEN_COMPILER_C
operator char const* () const { return Ptr; }
char const& operator[]( ssize index ) const { return Ptr[index]; }
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
bool is_equal (StrC rhs) const { return GEN_NS are_equal(* this, rhs); }
char const* back () const { return GEN_NS back(* this); }
bool contains (StrC substring) const { return GEN_NS contains(* this, substring); }
StrC duplicate (AllocatorInfo allocator) const { return GEN_NS duplicate(* this, allocator); }
b32 starts_with (StrC substring) const { return GEN_NS starts_with(* this, substring); }
StrC visualize_whitespace(AllocatorInfo allocator) const { return GEN_NS visualize_whitespace(* this, allocator); }
#endif
#endif
};
#define cast_to_strc( str ) * rcast( StrC*, (str) - sizeof(ssize) )
#define txt( text ) StrC { sizeof( text ) - 1, ( text ) }
inline char const* begin(StrC str) { return str.Ptr; }
inline char const* end (StrC str) { return str.Ptr + str.Len; }
inline char const* next (StrC str, char const* iter) { return iter + 1; }
inline
StrC to_str( char const* str ) {
return { str_len( str ), str };
bool are_equal(StrC lhs, StrC rhs)
{
if (lhs.Len != rhs.Len)
return false;
for (ssize idx = 0; idx < lhs.Len; ++idx)
if (lhs[idx] != rhs[idx])
return false;
return true;
}
inline
char const* back(StrC str) {
return & str.Ptr[str.Len - 1];
}
inline
bool contains(StrC str, StrC substring)
{
if (substring.Len > str.Len)
return false;
ssize main_len = str.Len;
ssize sub_len = substring.Len;
for (ssize idx = 0; idx <= main_len - sub_len; ++idx)
{
if (str_compare(str.Ptr + idx, substring.Ptr, sub_len) == 0)
return true;
}
return false;
}
inline
b32 starts_with(StrC str, StrC substring) {
if (substring.Len > str.Len)
return false;
b32 result = str_compare(str.Ptr, substring.Ptr, substring.Len) == 0;
return result;
}
inline
StrC to_str( char const* bad_str ) {
return { str_len( bad_str ), bad_str };
}
// Dynamic String
@ -31,7 +97,12 @@ StrC to_str( char const* str ) {
// I kept it for simplicty of porting but its not necessary to keep it that way.
#pragma region String
struct StringHeader;
#if GEN_COMPILER_C || ! GEN_SUPPORT_CPP_MEMBER_FEATURES
typedef char* String;
#else
struct String;
#endif
usize string_grow_formula(usize value);
@ -65,6 +136,7 @@ b32 starts_with (String const str, StrC substring);
b32 starts_with (String const str, String substring);
void skip_line (String str);
void strip_space (String str);
StrC to_strc (String str);
void trim (String str, char const* cut_set);
void trim_space (String str);
String visualize_whitespace(String const str);
@ -75,12 +147,11 @@ struct StringHeader {
ssize Length;
};
#if ! GEN_COMPILER_C
#if ! GEN_COMPILER_C && GEN_SUPPORT_CPP_MEMBER_FEATURES
struct String
{
char* Data;
forceinline operator bool() { return Data != nullptr; }
forceinline operator char*() { return Data; }
forceinline operator char const*() const { return Data; }
forceinline operator StrC() const { return { GEN_NS length(* this), Data }; }
@ -98,10 +169,14 @@ struct String
forceinline char& operator[](ssize index) { return Data[index]; }
forceinline char const& operator[](ssize index) const { return Data[index]; }
bool operator==(std::nullptr_t) const { return Data == nullptr; }
bool operator!=(std::nullptr_t) const { return Data != nullptr; }
friend bool operator==(std::nullptr_t, const String str) { return str.Data == nullptr; }
friend bool operator!=(std::nullptr_t, const String str) { return str.Data != nullptr; }
forceinline char* begin() const { return Data; }
forceinline char* end() const { return Data + GEN_NS length(* this); }
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
#pragma region Member Mapping
forceinline static String make(AllocatorInfo allocator, char const* str) { return GEN_NS string_make(allocator, str); }
forceinline static String make(AllocatorInfo allocator, StrC str) { return GEN_NS string_make(allocator, str); }
@ -151,6 +226,7 @@ struct String
forceinline b32 starts_with(String substring) const { return GEN_NS starts_with(* this, substring); }
forceinline void skip_line() { GEN_NS skip_line(* this); }
forceinline void strip_space() { GEN_NS strip_space(* this); }
forceinline StrC to_strc() { return { length(), Data}; }
forceinline void trim(char const* cut_set) { GEN_NS trim(* this, cut_set); }
forceinline void trim_space() { GEN_NS trim_space(* this); }
forceinline String visualize_whitespace() const { return GEN_NS visualize_whitespace(* this); }
@ -168,26 +244,25 @@ struct String
return GEN_NS append(this, buf, res);
}
#pragma endregion Member Mapping
#endif
};
#endif
#if GEN_SUPPORT_CPP_REFERENCES
bool make_space_for(String& str, char const* to_append, ssize add_len);
bool append(String& str, char c);
bool append(String& str, char const* str_to_append);
bool append(String& str, char const* str_to_append, ssize length);
bool append(String& str, StrC str_to_append);
bool append(String& str, const String other);
bool append_fmt(String& str, char const* fmt, ...);
char& back(String& str);
void clear(String& str);
void free(String& str);
#endif
inline char* begin(String str) { return ((char*) str); }
inline char* end (String str) { return ((char*) str + length(str)); }
inline char* next (String str, char* iter) { return ((char*) iter + 1); }
inline char* begin(String str) { return str; }
inline char* end(String str) { return scast(char*, str) + length(str); }
inline char* next(String str) { return scast(char*, str) + 1; }
#if GEN_SUPPORT_CPP_REFERENCES
inline bool make_space_for(String& str, char const* to_append, ssize add_len);
inline bool append(String& str, char c);
inline bool append(String& str, char const* str_to_append);
inline bool append(String& str, char const* str_to_append, ssize length);
inline bool append(String& str, StrC str_to_append);
inline bool append(String& str, const String other);
inline bool append_fmt(String& str, char const* fmt, ...);
inline char& back(String& str);
inline void clear(String& str);
inline void free(String& str);
#endif
inline
usize string_grow_formula(usize value) {
@ -249,7 +324,7 @@ String string_join(AllocatorInfo allocator, char const** parts, ssize num_parts,
inline
bool append(String* str, char c) {
GEN_ASSERT(str != nullptr);
return append(str, &c, 1);
return append( str, (char const*)& c, (ssize)1);
}
inline
@ -288,9 +363,9 @@ bool append(String* str, StrC str_to_append) {
}
inline
bool append(String* str, const String other) {
bool append(String* str, String const other) {
GEN_ASSERT(str != nullptr);
return append(str, other, length(other));
return append(str, (char const*)other, length(other));
}
bool append_fmt(String* str, char const* fmt, ...) {
@ -303,7 +378,7 @@ bool append_fmt(String* str, char const* fmt, ...) {
res = str_fmt_va(buf, count_of(buf) - 1, fmt, va) - 1;
va_end(va);
return append(str, buf, res);
return append(str, (char const*)buf, res);
}
inline
@ -464,7 +539,7 @@ b32 starts_with(String const str, StrC substring) {
if (substring.Len > length(str))
return false;
b32 result = str_compare(str.Data, substring.Ptr, substring.Len) == 0;
b32 result = str_compare(str, substring.Ptr, substring.Len) == 0;
return result;
}
@ -473,7 +548,7 @@ b32 starts_with(String const str, String substring) {
if (length(substring) > length(str))
return false;
b32 result = str_compare(str.Data, substring.Data, length(substring) - 1) == 0;
b32 result = str_compare(str, substring, length(substring) - 1) == 0;
return result;
}
@ -481,18 +556,18 @@ inline
void skip_line(String str)
{
#define current (*scanner)
char* scanner = str.Data;
char* scanner = str;
while (current != '\r' && current != '\n') {
++scanner;
}
s32 new_length = scanner - str.Data;
s32 new_length = scanner - str;
if (current == '\r') {
new_length += 1;
}
mem_move(str.Data, scanner, new_length);
mem_move((char*)str, scanner, new_length);
StringHeader* header = get_header(str);
header->Length = new_length;
@ -518,7 +593,12 @@ void strip_space(String str)
write_pos[0] = '\0'; // Null-terminate the modified string
// Update the length if needed
get_header(str)->Length = write_pos - str.Data;
get_header(str)->Length = write_pos - str;
}
inline
StrC to_strc(String str) {
return { length(str), (char const*)str };
}
inline
@ -526,8 +606,8 @@ void trim(String str, char const* cut_set)
{
ssize len = 0;
char* start_pos = str.Data;
char* end_pos = str.Data + length(str) - 1;
char* start_pos = str;
char* end_pos = scast(char*, str) + length(str) - 1;
while (start_pos <= end_pos && char_first_occurence(cut_set, *start_pos))
start_pos++;
@ -537,10 +617,10 @@ void trim(String str, char const* cut_set)
len = scast(ssize, (start_pos > end_pos) ? 0 : ((end_pos - start_pos) + 1));
if (str.Data != start_pos)
mem_move(str.Data, start_pos, len);
if (str != start_pos)
mem_move(str, start_pos, len);
str.Data[len] = '\0';
str[len] = '\0';
get_header(str)->Length = len;
}
@ -556,7 +636,7 @@ String visualize_whitespace(String const str)
StringHeader* header = (StringHeader*)(scast(char const*, str) - sizeof(StringHeader));
String result = string_make_reserve(header->Allocator, length(str) * 2); // Assume worst case for space requirements.
for (auto c : str) switch (c)
foreach (char*, c, str) switch ( * c )
{
case ' ':
append(& result, txt("·"));
@ -590,11 +670,47 @@ struct String_POD {
};
static_assert( sizeof( String_POD ) == sizeof( String ), "String is not a POD" );
// Implements basic string interning. Data structure is based off the ZPL Hashtable.
typedef HashTable<String const> StringTable;
inline
StrC duplicate(StrC str, AllocatorInfo allocator) {
String result = string_make_length(allocator, str.Ptr, str.Len);
return { get_header(result)->Length, result };
}
inline
StrC visualize_whitespace(StrC str, AllocatorInfo allocator)
{
String result = string_make_reserve(allocator, str.Len * 2); // Assume worst case for space requirements.
foreach (char const*, c, str) switch ( * c )
{
case ' ':
append(& result, txt("·"));
break;
case '\t':
append(& result, txt(""));
break;
case '\n':
append(& result, txt(""));
break;
case '\r':
append(& result, txt(""));
break;
case '\v':
append(& result, txt(""));
break;
case '\f':
append(& result, txt(""));
break;
default:
append(& result, c);
break;
}
return to_strc(result);
}
// Represents strings cached with the string table.
// Should never be modified, if changed string is desired, cache_string( str ) another.
typedef String const StringCached;
typedef StrC StringCached;
// Implements basic string interning. Data structure is based off the ZPL Hashtable.
typedef HashTable<StringCached> StringTable;
#pragma endregion Strings

View File

@ -31,11 +31,11 @@ CodeBody gen_ecode( char const* path )
append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", code, code );
}
CodeEnum enum_code = parse_enum(gen::token_fmt_impl((3 + 1) / 2, "entries", (StrC)enum_entries, "enum CodeType_Def : u32 { <entries> CT_NumTypes };"));
CodeEnum enum_code = parse_enum(gen::token_fmt_impl((3 + 1) / 2, "entries", to_strc(enum_entries), "enum CodeType_Def : u32 { <entries> CT_NumTypes };"));
#pragma push_macro("local_persist")
#undef local_persist
CodeFn to_str = parse_function( token_fmt( "entries", (StrC)to_str_entries, stringize(
CodeFn to_str = parse_function( token_fmt( "entries", to_strc(to_str_entries), stringize(
inline
StrC to_str( CodeType type )
{
@ -53,7 +53,7 @@ CodeBody gen_ecode( char const* path )
//CodeUsing code_t = def_using( name(CodeT), def_type( name(ECode::Type) ) );
CodeTypedef code_t = parse_typedef(code(typedef enum CodeType_Def CodeType; ));
return def_global_body( args( code_t, enum_code, to_str, fmt_newline ) );
return def_global_body( args( enum_code, code_t, to_str, fmt_newline ) );
}
CodeBody gen_eoperator( char const* path )
@ -81,7 +81,7 @@ CodeBody gen_eoperator( char const* path )
append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
}
CodeEnum enum_code = parse_enum(token_fmt("entries", (StrC)enum_entries, stringize(
CodeEnum enum_code = parse_enum(token_fmt("entries", to_strc(enum_entries), stringize(
enum Operator_Def : u32
{
<entries>
@ -91,7 +91,7 @@ CodeBody gen_eoperator( char const* path )
#pragma push_macro("local_persist")
#undef local_persist
CodeFn to_str = parse_function(token_fmt("entries", (StrC)to_str_entries, stringize(
CodeFn to_str = parse_function(token_fmt("entries", to_strc(to_str_entries), stringize(
inline
StrC to_str( Operator op )
{
@ -109,7 +109,7 @@ CodeBody gen_eoperator( char const* path )
//CodeUsing operator_t = def_using( name(OperatorT), def_type( name(EOperator::Type) ) );
CodeTypedef operator_t = parse_typedef(code( typedef enum Operator_Def Operator; ));
return def_global_body( args( operator_t, enum_code, to_str, fmt_newline ) );
return def_global_body( args( enum_code, operator_t, to_str, fmt_newline ) );
}
CodeBody gen_especifier( char const* path )
@ -137,7 +137,7 @@ CodeBody gen_especifier( char const* path )
append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
}
CodeEnum enum_code = parse_enum(token_fmt("entries", (StrC)enum_entries, stringize(
CodeEnum enum_code = parse_enum(token_fmt("entries", to_strc(enum_entries), stringize(
enum Specifier_Def : u32
{
<entries>
@ -145,7 +145,7 @@ CodeBody gen_especifier( char const* path )
};
)));
CodeFn is_trailing = parse_function(token_fmt("specifier", (StrC)to_str_entries, stringize(
CodeFn is_trailing = parse_function(token_fmt("specifier", to_strc(to_str_entries), stringize(
inline
bool is_trailing( Specifier specifier )
{
@ -163,7 +163,7 @@ CodeBody gen_especifier( char const* path )
#undef do_once_end
#undef forceinline
#undef neverinline
CodeFn to_str = parse_function(token_fmt("entries", (StrC)to_str_entries, stringize(
CodeFn to_str = parse_function(token_fmt("entries", to_strc(to_str_entries), stringize(
inline
StrC to_str( Specifier type )
{
@ -176,7 +176,7 @@ CodeBody gen_especifier( char const* path )
}
)));
CodeFn to_type = parse_function( token_fmt( "entries", (StrC)to_str_entries, stringize(
CodeFn to_type = parse_function( token_fmt( "entries", to_strc(to_str_entries), stringize(
inline
Specifier to_specifier( StrC str )
{
@ -214,7 +214,7 @@ CodeBody gen_especifier( char const* path )
//CodeUsing specifier_t = def_using( name(SpecifierT), def_type( name(ESpecifier::Type) ) );
CodeTypedef specifier_t = parse_typedef( code(typedef enum Specifier_Def Specifier; ));
return def_global_body( args( specifier_t, enum_code, is_trailing, to_str, to_type, fmt_newline ) );
return def_global_body( args( enum_code, specifier_t, is_trailing, to_str, to_type, fmt_newline ) );
}
CodeBody gen_etoktype( char const* etok_path, char const* attr_path )
@ -271,11 +271,11 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path )
#pragma push_macro("GEN_DEFINE_ATTRIBUTE_TOKENS")
#undef GEN_DEFINE_ATTRIBUTE_TOKENS
CodeDefine attribute_entires_def = def_define( name(GEN_DEFINE_ATTRIBUTE_TOKENS), attribute_define_entries );
CodeDefine attribute_entires_def = def_define( name(GEN_DEFINE_ATTRIBUTE_TOKENS), to_strc(attribute_define_entries) );
#pragma pop_macro("GEN_DEFINE_ATTRIBUTE_TOKENS")
// We cannot parse this enum, it has Attribute names as enums
CodeEnum enum_code = parse_enum(token_fmt("entries", (StrC)enum_entries, "attribute_toks", (StrC)attribute_entries, stringize(
CodeEnum enum_code = parse_enum(token_fmt("entries", to_str(enum_entries), "attribute_toks", to_str(attribute_entries), stringize(
enum TokType_Def : u32
{
<entries>
@ -290,7 +290,7 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path )
#undef local_persist
#undef do_once_start
#undef do_once_end
CodeFn to_str = parse_function(token_fmt("entries", (StrC)to_str_entries, "attribute_toks", (StrC)to_str_attributes, stringize(
CodeFn to_str = parse_function(token_fmt("entries", to_strc(to_str_entries), "attribute_toks", to_strc(to_str_attributes), stringize(
inline
StrC to_str( TokType type )
{
@ -304,7 +304,7 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path )
}
)));
CodeFn to_type = parse_function( token_fmt( "entries", (StrC)to_str_entries, stringize(
CodeFn to_type = parse_function( token_fmt( "entries", to_strc(to_str_entries), stringize(
inline
TokType to_toktype( StrC str )
{
@ -341,8 +341,8 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path )
return def_global_body( args(
attribute_entires_def,
td_toktype,
enum_code,
td_toktype,
to_str,
to_type
));

View File

@ -7,6 +7,7 @@
# pragma clang diagnostic ignored "-Wunknown-pragmas"
# pragma clang diagnostic ignored "-Wvarargs"
# pragma clang diagnostic ignored "-Wunused-function"
# pragma clang diagnostic ignored "-Wbraced-scalar-init"
#endif
#ifdef __GNUC__