#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS #define GEN_ENFORCE_STRONG_CODE_TYPES #define GEN_EXPOSE_BACKEND // #define GEN_DEFINE_ATTRIBUTE_TOKENS #define GEN_IMPLEMENTATION #include "gen.cpp" #include "gen.builder.cpp" // #include "gen.scanner.hpp" using namespace gen; #ifdef GEN_SYSTEM_WINDOWS #include #endif #include "GasaGenCommon.cpp" #include "GasaGen_ue_parse_testing.cpp" #include "GasaGen_UGasaAttributeSet.cpp" #include "GasaGen_ChangeBPActionMenu.cpp" #include "GasaGen_DevOptionsCache.cpp" #include "GasaGen_HostWidgetController.cpp" void gen_UHostWidgetController() { Array attribute_fields = get_gasa_attribute_fields(); CodeBody ori_HostWidgetController_header = parse_file(path_gasa_ui "HostWidgetController.h"); { CodeBody header_body = def_body(ECode::Global_Body); StrC str_UHostWidgetController = txt("UHostWidgetController"); CodeClass ori_UHostWidgetController = NoCode; Code file_code = ori_HostWidgetController_header.begin(); for ( ; file_code != ori_HostWidgetController_header.end(); ++ file_code ) { if (s32 never_enter = 0; never_enter) found: break; switch (file_code->Type) { default: header_body.append(file_code); continue; case ECode::Class: if ( ! file_code->Name.starts_with(str_UHostWidgetController)) continue; ori_UHostWidgetController = file_code.cast(); ++ file_code; goto found; case ECode::Preprocess_Include: header_body.append(file_code); if ( file_code->Content.starts_with(txt("HostWidgetController.generated.h"))) { header_body.append(fmt_newline); header_body.append(fmt_newline); } continue; case ECode::Untyped: header_body.append(file_code); if (file_code->Content.starts_with( txt("DECLARE_")) || file_code->Content.starts_with( txt("UCLASS")) ) header_body.append(fmt_newline); continue; } } CodeBody attribute_events = def_body(ECode::Class_Body); { attribute_events.append( def_comment( txt("Attribute Events are generated by GasaGen/GasaGen_HostWidgetController.cpp"))); attribute_events.append(fmt_newline); for ( s32 id = 0; id < attribute_fields.num(); ) { StringCached attribute_field = attribute_fields[id]; attribute_events.append( code_str( UPROPERTY(BlueprintAssignable, Category = "Attributes") )); attribute_events.append(fmt_newline); attribute_events.append( parse_variable( token_fmt( "field", (StrC) attribute_field, stringize( FAttributeFloatChangedSig Event_OnChanged; )) )); ++ id; if ( id < attribute_fields.num() ) { attribute_events.append(fmt_newline); } } } CodeClass new_UHostWidgetController = ori_UHostWidgetController.duplicate().cast(); CodeBody new_body = def_body(ECode::Class_Body); for (Code code = ori_UHostWidgetController->Body.begin(); code != ori_UHostWidgetController->Body.end(); ++ code ) { switch (code->Type) { default: new_body.append(code); continue; case ECode::Preprocess_Pragma: { local_persist bool found = false; if (found) { new_body.append(code); continue; } CodePragma pragma = code.cast(); if ( pragma->Content.starts_with(txt("region Attribute Events")) ) { new_body.append(pragma); ++ code; new_body.append(attribute_events); while (code->Type != ECode::Preprocess_Pragma || ! code->Content.starts_with(txt("endregion Attribute Events"))) ++ code; new_body.append( code ); found = true; } } break; case ECode::Untyped: new_body.append(code); if (code->Content.starts_with( txt("GENERATED_BODY"))) new_body.append(fmt_newline); } } new_body.append(fmt_newline); new_UHostWidgetController->Body = new_body; header_body.append(new_UHostWidgetController); for (; file_code != ori_HostWidgetController_header.end(); ++ file_code) { header_body.append(file_code); } Builder header = Builder::open(path_gasa_ui "HostWidgetController.h"); header.print(header_body); header.write(); format_file(path_gasa_ui "HostWidgetController.h"); } CodeBody ori_HostWidgetController_source = parse_file(path_gasa_ui "HostWidgetController.cpp"); { CodeBody source_body = def_body(ECode::Global_Body); CodeBody broadcast_calls = def_body(ECode::Function_Body); for (StringCached field : attribute_fields) { broadcast_calls.append( code_fmt( "field", (StrC)field, stringize( Event_OnChanged.Broadcast( GasaAttribs->Get() ); ) )); } CodeFn BroadcastInitialValues = parse_function( token_fmt( "broadcast_calls", (StrC)broadcast_calls.to_string(), stringize( void UHostWidgetController::BroadcastInitialValues() { Super::BroadcastInitialValues(); // Thiis function is managed by: GasaGen/GasaGen_HostWidgetController.cpp UGasaAttributeSet* GasaAttribs = Cast(Data.Attributes); if (GasaAttribs) { } }) )); for ( Code code : ori_HostWidgetController_source) { switch (code->Type) { case ECode::Function: CodeFn function_def = code.cast(); if ( String::are_equal(function_def->Name, BroadcastInitialValues->Name) && function_def->Params.is_equal(BroadcastInitialValues->Params)) { code = BroadcastInitialValues; log_fmt("Swapped: %S", BroadcastInitialValues->Name); } break; } source_body.append(code); } Builder source = Builder::open(path_gasa_ui "HostWidgetController.cpp"); source.print(source_body); source.write(); format_file(path_gasa_ui "HostWidgetController.cpp"); } } int gen_main() { gen::init(); log_fmt("Generating code for the Gasa module\n"); // Initialize Globals { UHT_UCLASS = code_str( UCLASS() ); UHT_UPROPERTY = code_str( UPROPERTY() ); UHT_USTRUCT = code_str( USTRUCT() ); UHT_GENERATED_BODY = code_str( GENERATED_BODY()\n ); UModule_GASA_API = code_str( GASA_API ); } // Populate Defines { PreprocessorDefines.append( get_cached_string(str_DECLARE_CLASS)); PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_RetVal_OneParam)); PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_RetVal_ThreeParams)); PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_SixParams)); PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam)); PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams)); PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams)); PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams)); PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam)); PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams)); PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams)); PreprocessorDefines.append( get_cached_string(str_DECLARE_EVENT_ThreeParams)); PreprocessorDefines.append( get_cached_string(str_DECLARE_EVENT_TwoParams)); PreprocessorDefines.append( get_cached_string(str_DECLARE_FUNCTION)); PreprocessorDefines.append( get_cached_string(str_DECLARE_LOG_CATEGORY_EXTERN)); PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_OneParam)); PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_ThreeParams)); PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_TwoParams)); PreprocessorDefines.append( get_cached_string(str_DEFINE_ACTORDESC_TYPE)); 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_GENERATED_BODY)); PreprocessorDefines.append( get_cached_string(str_GENERATED_UCLASS_BODY)); PreprocessorDefines.append( get_cached_string(str_GENERATED_USTRUCT_BODY)); PreprocessorDefines.append( get_cached_string(str_PRAGMA_DISABLE_DEPRECATION_WARNINGS)); PreprocessorDefines.append( get_cached_string(str_PRAGMA_ENABLE_DEPRECATION_WARNINGS)); PreprocessorDefines.append( get_cached_string(str_PROPERTY_BINDING_IMPLEMENTATION)); PreprocessorDefines.append( get_cached_string(str_RESULT_DECL)); PreprocessorDefines.append( get_cached_string(str_SLATE_BEGIN_ARGS)); PreprocessorDefines.append( get_cached_string(str_SLATE_END_ARGS)); PreprocessorDefines.append( get_cached_string(str_TEXT)); PreprocessorDefines.append( get_cached_string(str_UCLASS)); PreprocessorDefines.append( get_cached_string(str_UENUM)); PreprocessorDefines.append( get_cached_string(str_UFUNCTION)); PreprocessorDefines.append( get_cached_string(str_UMETA)); PreprocessorDefines.append( get_cached_string(str_UPARAM)); PreprocessorDefines.append( get_cached_string(str_UPROPERTY)); PreprocessorDefines.append( get_cached_string(str_USTRUCT)); } gen_UGasaAttributeSet(); gen_FGasaDevOptionsCache(); gen_UHostWidgetController(); // One offs if (0) { ue_parse_testing(); swap_SBlueprintActionMenu_Construct(); } return 0; }