32. Overlay Widget Controller

This commit is contained in:
2024-04-21 18:56:57 -04:00
parent adfb17b7df
commit 811dc33f4a
40 changed files with 326 additions and 157 deletions

View File

@ -55,7 +55,7 @@ int gen_main()
PreprocessorDefines.append( get_cached_string(str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL));
PreprocessorDefines.append( get_cached_string(str_ENUM_CLASS_FLAGS));
PreprocessorDefines.append( get_cached_string(str_FORCEINLINE_DEBUGGABLE));
PreprocessorDefines.append( get_cached_string(str_FORCEINLINE));
// PreprocessorDefines.append( get_cached_string(str_FORCEINLINE));
PreprocessorDefines.append( get_cached_string(str_GENERATED_BODY));
PreprocessorDefines.append( get_cached_string(str_GENERATED_UCLASS_BODY));
PreprocessorDefines.append( get_cached_string(str_GENERATED_USTRUCT_BODY));

View File

@ -34,7 +34,7 @@ constexpr StrC str_DECLARE_MULTICAST_DELEGATE_TwoParams = txt("
constexpr StrC str_DEFINE_ACTORDESC_TYPE = txt("DEFINE_ACTORDESC_TYPE(");
constexpr StrC str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL = txt("DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(");
constexpr StrC str_ENUM_CLASS_FLAGS = txt("ENUM_CLASS_FLAGS(");
constexpr StrC str_FORCEINLINE = txt("FORCEINLINE");
// constexpr StrC str_FORCEINLINE = txt("FORCEINLINE");
constexpr StrC str_FORCEINLINE_DEBUGGABLE = txt("FORCEINLINE_DEBUGGABLE");
constexpr StrC str_GENERATED_BODY = txt("GENERATED_BODY(");
constexpr StrC str_GENERATED_UCLASS_BODY = txt("GENERATED_UCLASS_BODY(");

View File

@ -34,7 +34,7 @@ void gen_FGasaDevOptionsCache()
}
}
CodeComment generation_notice = def_comment(txt("This was generated by GasaGen/GasaGen.cpp"));
CodeComment generation_notice = def_comment(txt("Generated by GasaGen/GasaGen_DevOptionsCache.cpp"));
Builder header = Builder::open( path_module_gasa "GasaDevOptionsCache.h" );
{
@ -107,13 +107,17 @@ void gen_FGasaDevOptionsCache()
cached_property_assignments.append(fmt_newline);
for (CodeVar var : GasaDevOptions_UPROPERTIES)
{
#pragma push_macro("TEXT")
#undef TEXT
Code assignment = code_fmt( "property", (StrC)var->Name, stringize(
<property> = DevOpts-> <property>.LoadSynchronous();
ensureMsgf(<property> != nullptr, TEXT("<property> is null, DO NOT RUN PIE or else you may get a crash if not handled in BP or C++"));
));
#pragma pop_macro("TEXT")
cached_property_assignments.append(assignment);
cached_property_assignments.append(fmt_newline);
cached_property_assignments.append(fmt_newline);
}
cached_property_assignments.append(fmt_newline);
cached_property_assignments.append(fmt_newline);
}
CodeFn CachedDevOptions = parse_function( token_fmt(

View File

@ -7,18 +7,19 @@
#include "GasaGenCommon.cpp"
#endif
void def_attribute_properties ( CodeBody body, Array<StringCached> properties );
void def_attribute_field_on_reps ( CodeBody body, Array<StringCached> properties );
void def_attribute_field_property_getters( CodeBody body, StrC class_name, Array<StringCached> properties );
void def_attribute_field_value_getters ( CodeBody body, Array<StringCached> properties );
void def_attribute_field_value_setters ( CodeBody body, Array<StringCached> properties );
void def_attribute_field_initers ( CodeBody body, Array<StringCached> properties );
void impl_attribute_fields ( CodeBody body, StrC class_name, Array<StringCached> properties );
void def_attribute_properties ( CodeBody body, Array<StringCached> properties );
void def_attribute_field_on_reps ( CodeBody body, Array<StringCached> properties );
void def_attribute_field_property_getters ( CodeBody body, StrC class_name, Array<StringCached> properties );
void def_attribute_field_value_getters ( CodeBody body, Array<StringCached> properties );
void def_attribute_field_value_setters ( CodeBody body, Array<StringCached> properties );
void def_attribute_field_property_setter_inlines( CodeBody body, StrC class_name, Array<StringCached> properties );
void def_attribute_field_initers ( CodeBody body, Array<StringCached> properties );
void impl_attribute_fields ( CodeBody body, StrC class_name, Array<StringCached> properties );
void gen_UGasaAttributeSet()
{
CodeType type_UAttributeSet = def_type( txt("UAttributeSet") );
CodeComment generation_notice = def_comment(txt("This was generated by GasaGen/GasaGen.cpp"));
CodeComment generation_notice = def_comment(txt("Generated by GasaGen/GasaGen_UGasaAttributeSet.cpp"));
Array<StringCached> attribute_fields = Array<StringCached>::init( GlobalAllocator);
attribute_fields.append( get_cached_string(txt("Health")));
@ -31,10 +32,10 @@ void gen_UGasaAttributeSet()
Builder header = Builder::open( path_gasa_ability_system "GasaAttributeSet.h");
{
header.print(generation_notice);
header.print(pragma_once);
header.print(fmt_newline);
{
CodeInclude Include_AttributeSet = def_include(txt("AttributeSet.h"));
CodeInclude Include_AbilitySystemComponent = def_include(txt("AbilitySystemComponent.h"));
CodeInclude Include_GasaAttributeSet_Generated = def_include(txt("GasaAttributeSet.generated.h"));
CodeAttributes api_attribute= def_attributes( UModule_GASA_API->Name);
@ -59,12 +60,15 @@ void gen_UGasaAttributeSet()
body.append( fmt_newline );
body.append( def_pragma(code( region Getters )));
def_attribute_field_property_getters( body, class_name, attribute_fields );
body.append( fmt_newline );
def_attribute_field_value_getters( body, attribute_fields );
body.append( def_pragma(code( endregion Getters )));
body.append( fmt_newline );
body.append( def_pragma(code( region Setters )));
def_attribute_field_value_setters( body, attribute_fields );
body.append( fmt_newline );
body.append( fmt_newline );
def_attribute_field_initers( body, attribute_fields );
body.append( def_pragma(code( endregion Setters )));
body.append( fmt_newline );
@ -82,34 +86,54 @@ void gen_UGasaAttributeSet()
);
}
CodeNS ns_gasa = parse_namespace( code(
namespace Gasa
{
inline
UGasaAttributeSet const* GetAttributeSet( UAbilitySystemComponent* ASC )
{
return Cast<UGasaAttributeSet>(ASC->GetAttributeSet( UGasaAttributeSet::StaticClass() ));
}
}
));
header.print( Include_AttributeSet);
header.print( Include_AbilitySystemComponent);
header.print( Include_GasaAttributeSet_Generated);
header.print( fmt_newline);
header.print( UHT_UCLASS );
header.print(GasaAttributeSet);
header.print(ns_gasa);
}
header.write();
format_file(path_gasa_ability_system "GasaAttributeSet.h");
}
Builder inlines = Builder::open( path_gasa_ability_system "GasaAttributeSet_Inlines.h");
{
inlines.print(generation_notice);
inlines.print(pragma_once);
inlines.print(fmt_newline);
inlines.print( def_include( txt("GasaAttributeSet.h")));
inlines.print( def_include(txt("AbilitySystemComponent.h")));
inlines.print(fmt_newline);
CodeBody body = def_body(CodeT::Global_Body);
{
def_attribute_field_property_setter_inlines( body, class_name, attribute_fields );
}
inlines.print(body);
inlines.print(fmt_newline);
CodeNS ns_gasa = parse_namespace( code(
namespace Gasa
{
inline
UGasaAttributeSet const* GetAttributeSet( UAbilitySystemComponent* ASC )
{
return Cast<UGasaAttributeSet>(ASC->GetAttributeSet( UGasaAttributeSet::StaticClass() ));
}
}
));
inlines.print(ns_gasa);
inlines.write();
format_file(path_gasa_ability_system "GasaAttributeSet_Inlines.h");
}
Builder source = Builder::open( path_gasa_ability_system "GasaAttributeSet.cpp" );
{
source.print(generation_notice);
header.print(fmt_newline);
source.print( def_include( txt("GasaAttributeSet.h")));
source.print( def_include( txt("GasaAttributeSet_Inlines.h")));
source.print(fmt_newline);
source.print( def_include( txt("AbilitySystemComponent.h")));
source.print( def_include( txt("Net/UnrealNetwork.h")));
@ -231,18 +255,31 @@ void def_attribute_field_value_setters( CodeBody body, Array<StringCached> prope
{
body.append( code_fmt( "property", (StrC)property,
stringize(
FORCEINLINE void Set<property>(float NewVal)
{
UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent();
if (ensure(AbilityComp))
{
AbilityComp->SetNumericAttributeBase(Get<property>Attribute(), NewVal);
};
}
FORCEINLINE void Set<property>(float NewVal);
)));
}
}
void def_attribute_field_property_setter_inlines( CodeBody body, StrC class_name, Array<StringCached> properties )
{
for ( String property : properties )
{
CodeFn generated_get_attribute = parse_function(
token_fmt( "class_name", class_name, "property", (StrC)property,
stringize(
FORCEINLINE void <class_name>::Set<property>(float NewVal)
{
UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent();
if (ensure(AbilityComp))
{
AbilityComp->SetNumericAttributeBase(Get<property>Attribute(), NewVal);
};
}
)));
body.append( generated_get_attribute );
}
}
void def_attribute_field_initers ( CodeBody body, Array<StringCached> properties )
{
for ( String property : properties )

View File

@ -81,7 +81,7 @@ global CodeSpecifiers spec_constexpr;
global CodeSpecifiers spec_constinit;
global CodeSpecifiers spec_extern_linkage;
global CodeSpecifiers spec_final;
global CodeSpecifiers spec_forceinline;
global CodeSpecifiers spec_FORCEINLINE;
global CodeSpecifiers spec_global;
global CodeSpecifiers spec_inline;
global CodeSpecifiers spec_internal_linkage;
@ -2988,12 +2988,12 @@ internal void define_constants()
spec_##Type_ = def_specifiers( num_args( __VA_ARGS__ ), __VA_ARGS__ ); \
spec_##Type_.set_global();
#pragma push_macro( "forceinline" )
#pragma push_macro( "FORCEINLINE" )
#pragma push_macro( "global" )
#pragma push_macro( "internal" )
#pragma push_macro( "local_persist" )
#pragma push_macro( "neverinline" )
#undef forceinline
#undef FORCEINLINE
#undef global
#undef internal
#undef local_persist
@ -3004,7 +3004,7 @@ internal void define_constants()
def_constant_spec( constinit, ESpecifier::Constinit );
def_constant_spec( extern_linkage, ESpecifier::External_Linkage );
def_constant_spec( final, ESpecifier::Final );
def_constant_spec( forceinline, ESpecifier::ForceInline );
def_constant_spec( FORCEINLINE, ESpecifier::ForceInline );
def_constant_spec( global, ESpecifier::Global );
def_constant_spec( inline, ESpecifier::Inline );
def_constant_spec( internal_linkage, ESpecifier::Internal_Linkage );
@ -3025,7 +3025,7 @@ internal void define_constants()
spec_local_persist = def_specifiers( 1, ESpecifier::Local_Persist );
spec_local_persist.set_global();
#pragma pop_macro( "forceinline" )
#pragma pop_macro( "FORCEINLINE" )
#pragma pop_macro( "global" )
#pragma pop_macro( "internal" )
#pragma pop_macro( "local_persist" )
@ -5840,7 +5840,7 @@ namespace parser
{ sizeof( "explicit" ), "explicit" },
{ sizeof( "extern" ), "extern" },
{ sizeof( "final" ), "final" },
{ sizeof( "forceinline" ), "forceinline" },
{ sizeof( "FORCEINLINE" ), "FORCEINLINE" },
{ sizeof( "global" ), "global" },
{ sizeof( "inline" ), "inline" },
{ sizeof( "internal" ), "internal" },
@ -6059,7 +6059,7 @@ namespace parser
}
};
global Arena_128KB defines_map_arena;
global Arena_256KB defines_map_arena;
global HashTable<StrC> defines;
global Array<Token> Tokens;
@ -6110,7 +6110,7 @@ namespace parser
Lex_ReturnNull,
};
forceinline s32 lex_preprocessor_directive( StrC& content, s32& left, char const*& scanner, s32& line, s32& column, HashTable<StrC>& defines, Token& token )
FORCEINLINE s32 lex_preprocessor_directive( StrC& content, s32& left, char const*& scanner, s32& line, s32& column, HashTable<StrC>& defines, Token& token )
{
char const* hash = scanner;
Tokens.append( { hash, 1, TokType::Preprocess_Hash, line, column, TF_Preprocess } );
@ -6344,7 +6344,7 @@ namespace parser
return Lex_Continue; // Skip found token, its all handled here.
}
forceinline void lex_found_token( StrC& content, s32& left, char const*& scanner, s32& line, s32& column, HashTable<StrC>& defines, Token& token )
FORCEINLINE void lex_found_token( StrC& content, s32& left, char const*& scanner, s32& line, s32& column, HashTable<StrC>& defines, Token& token )
{
if ( token.Type != TokType::Invalid )
{
@ -7255,7 +7255,7 @@ namespace parser
{
Tokens = Array<Token>::init_reserve( LexArena, ( LexAllocator_Size - sizeof( Array<Token>::Header ) ) / sizeof( Token ) );
defines_map_arena = Arena_128KB::init();
defines_map_arena = Arena_256KB::init();
defines = HashTable<StrC>::init( defines_map_arena );
}

View File

@ -145,21 +145,21 @@ GEN_NS_BEGIN
#define local_persist static // Local Persisting variables
#ifdef GEN_COMPILER_MSVC
#define forceinline __forceinline
#define FORCEINLINE __forceinline
#define neverinline __declspec( noinline )
#elif defined( GEN_COMPILER_GCC )
#define forceinline inline __attribute__( ( __always_inline__ ) )
#define FORCEINLINE inline __attribute__( ( __always_inline__ ) )
#define neverinline __attribute__( ( __noinline__ ) )
#elif defined( GEN_COMPILER_CLANG )
#if __has_attribute( __always_inline__ )
#define forceinline inline __attribute__( ( __always_inline__ ) )
#define FORCEINLINE inline __attribute__( ( __always_inline__ ) )
#define neverinline __attribute__( ( __noinline__ ) )
#else
#define forceinline
#define FORCEINLINE
#define neverinline
#endif
#else
#define forceinline
#define FORCEINLINE
#define neverinline
#endif

View File

@ -451,7 +451,7 @@ namespace ESpecifier
{ sizeof( "constinit" ), "constinit" },
{ sizeof( "explicit" ), "explicit" },
{ sizeof( "extern" ), "extern" },
{ sizeof( "forceinline" ), "forceinline" },
{ sizeof( "FORCEINLINE" ), "FORCEINLINE" },
{ sizeof( "global" ), "global" },
{ sizeof( "inline" ), "inline" },
{ sizeof( "internal" ), "internal" },
@ -671,7 +671,7 @@ struct Code
Using_Code( Code );
template<class Type>
forceinline Type cast()
FORCEINLINE Type cast()
{
return *rcast( Type*, this );
}
@ -761,7 +761,7 @@ struct AST
neverinline void to_string( String& result );
template<class Type>
forceinline Type cast()
FORCEINLINE Type cast()
{
return *this;
}
@ -6397,7 +6397,7 @@ extern CodeSpecifiers spec_constexpr;
extern CodeSpecifiers spec_constinit;
extern CodeSpecifiers spec_extern_linkage;
extern CodeSpecifiers spec_final;
extern CodeSpecifiers spec_forceinline;
extern CodeSpecifiers spec_FORCEINLINE;
extern CodeSpecifiers spec_global;
extern CodeSpecifiers spec_inline;
extern CodeSpecifiers spec_internal_linkage;