mirror of
https://github.com/Ed94/gencpp.git
synced 2025-02-23 21:58:37 -08:00
Add support for non Specifier enum SuffixSpecs in AST_Fn and parsing (Thanks Unreal)
This commit is contained in:
parent
16fc3fa379
commit
ce2be411d7
@ -400,7 +400,7 @@ struct AST
|
||||
};
|
||||
union {
|
||||
Code NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
|
||||
Code SuffixSpecs; // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed )
|
||||
Code SuffixSpecs; // Typename, Function (Thanks Unreal)
|
||||
Code PostNameMacro; // Only used with parameters for specifically UE_REQUIRES (Thanks Unreal)
|
||||
};
|
||||
};
|
||||
|
@ -575,7 +575,7 @@ struct AST_Fn
|
||||
CodeTypename ReturnType;
|
||||
CodeParams Params;
|
||||
CodeBody Body;
|
||||
char _PAD_PROPERTIES_ [ sizeof(AST*) ];
|
||||
Code SuffixSpecs; // Thanks Unreal
|
||||
};
|
||||
};
|
||||
StrCached Name;
|
||||
|
@ -589,6 +589,10 @@ void fn_to_strbuilder_def(CodeFn self, StrBuilder* result )
|
||||
}
|
||||
}
|
||||
|
||||
// This is bodged in for now SOLEY for Unreal's PURE_VIRTUAL functional macro
|
||||
if ( self->SuffixSpecs )
|
||||
strbuilder_append_fmt( result, " %SB", code_to_strbuilder(self->SuffixSpecs) );
|
||||
|
||||
strbuilder_append_fmt( result, "\n{\n%SB\n}\n", body_to_strbuilder(self->Body) );
|
||||
}
|
||||
|
||||
@ -646,7 +650,12 @@ void fn_to_strbuilder_fwd(CodeFn self, StrBuilder* result )
|
||||
|
||||
if ( self->Specs && specifiers_has(self->Specs, Spec_Pure ) >= 0 )
|
||||
strbuilder_append_str( result, txt(" = 0;") );
|
||||
else if (self->Body)
|
||||
|
||||
// This is bodged in for now SOLEY for Unreal's PURE_VIRTUAL functional macro (I kept it open ended for other jank)
|
||||
if ( self->SuffixSpecs )
|
||||
strbuilder_append_fmt( result, " %SB", code_to_strbuilder(self->SuffixSpecs) );
|
||||
|
||||
if (self->Body)
|
||||
strbuilder_append_fmt( result, " = %SB;", body_to_strbuilder(self->Body) );
|
||||
|
||||
if ( self->InlineCmt )
|
||||
|
@ -550,6 +550,9 @@ void lex_found_token( LexContext* ctx )
|
||||
if ( bitfield_is_set(MacroFlags, macro->Flags, MF_Allow_As_Attribute) ) {
|
||||
ctx->token.Flags |= TF_Attribute;
|
||||
}
|
||||
if ( bitfield_is_set(MacroFlags, macro->Flags, MF_Allow_As_Specifier ) ) {
|
||||
ctx->token.Flags |= TF_Specifier;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1403,6 +1403,18 @@ CodeFn parse_function_after_name(
|
||||
}
|
||||
// <Attributes> <Specifiers> <ReturnType> <Name> ( <Paraemters> ) <Specifiers>
|
||||
|
||||
Code suffix_specs = NullCode;
|
||||
|
||||
// For Unreal's PURE_VIRTUAL Support
|
||||
if ( left )
|
||||
{
|
||||
Macro* macro = lookup_macro( currtok.Text );
|
||||
if (macro && tok_is_specifier(currtok))
|
||||
{
|
||||
suffix_specs = parse_simple_preprocess(Tok_Preprocess_Macro_Expr);
|
||||
}
|
||||
}
|
||||
|
||||
CodeBody body = NullCode;
|
||||
CodeComment inline_cmt = NullCode;
|
||||
if ( check( Tok_BraceCurly_Open ) )
|
||||
@ -1479,6 +1491,9 @@ CodeFn parse_function_after_name(
|
||||
if ( specifiers )
|
||||
result->Specs = specifiers;
|
||||
|
||||
if ( suffix_specs )
|
||||
result->SuffixSpecs = suffix_specs;
|
||||
|
||||
result->ReturnType = ret_type;
|
||||
|
||||
if ( params )
|
||||
|
@ -186,6 +186,8 @@ enum EMacroFlags : u16
|
||||
// (MUST BE OF MT_Statement TYPE)
|
||||
MF_Allow_As_Definition = bit(4),
|
||||
|
||||
MF_Allow_As_Specifier = bit(5), // Created for Unreal's PURE_VIRTUAL
|
||||
|
||||
MF_Null = 0,
|
||||
MF_UnderlyingType = GEN_U16_MAX,
|
||||
};
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#pragma region Macros
|
||||
|
||||
#ifndef GEN_API
|
||||
#if GEN_COMPILER_MSVC
|
||||
#ifdef GEN_DYN_LINK
|
||||
#ifdef GEN_DYN_EXPORT
|
||||
@ -22,6 +23,7 @@
|
||||
#define GEN_API // Empty for static builds
|
||||
#endif
|
||||
#endif
|
||||
#endif // GEN_API
|
||||
|
||||
#ifndef global
|
||||
#define global static // Global variables
|
||||
|
Loading…
x
Reference in New Issue
Block a user