2024-10-24 17:28:52 -07:00
|
|
|
#include "DevOptionsCache.h"
|
2024-10-21 19:39:40 -07:00
|
|
|
#include "GasaGen_Common.h"
|
|
|
|
|
|
|
|
#pragma push_macro("GASA_API")
|
|
|
|
#pragma push_macro("ensureMsgf")
|
|
|
|
#undef GASA_API
|
|
|
|
#undef ensureMsgf
|
|
|
|
|
|
|
|
void generate_DevOptionsCache()
|
|
|
|
{
|
2024-12-15 15:22:59 -08:00
|
|
|
Array<CodeVar> GasaDevOptions_UPROPERTIES = Array<CodeVar>::init(gen_ctx.Allocator_Temp);
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
CodeBody header_GasaDevOptions = parse_file( path_module_gasa "GasaDevOptions.h" );
|
2024-12-15 15:22:59 -08:00
|
|
|
CodeClass UGasaDevOptions = NullCode;
|
2024-10-21 19:39:40 -07:00
|
|
|
for (Code entry : header_GasaDevOptions)
|
|
|
|
{
|
2024-12-15 15:22:59 -08:00
|
|
|
if ( entry->Type == CT_Class && entry->Name.starts_with( txt("UGasaDevOptions")) )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
2024-12-15 15:22:59 -08:00
|
|
|
UGasaDevOptions = cast(CodeClass, entry);
|
2024-10-21 19:39:40 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (Code member = UGasaDevOptions->Body.begin(); member != UGasaDevOptions->Body.end(); ++ member)
|
|
|
|
{
|
2024-12-15 15:22:59 -08:00
|
|
|
if ( member->Type == CT_Untyped && member->Name.starts_with(str_UPROPERTY) )
|
2024-10-21 19:39:40 -07:00
|
|
|
++ member;
|
2024-12-15 15:22:59 -08:00
|
|
|
if ( member->Type == CT_Variable
|
2024-10-21 19:39:40 -07:00
|
|
|
&& ( member->ValueType->Name.starts_with( txt("TArray< TSoftObjectPtr"))
|
|
|
|
|| member->ValueType->Name.starts_with( txt("TSoftClassPtr"))
|
|
|
|
|| member->ValueType->Name.starts_with( txt("TSoftObjectPtr")) )
|
|
|
|
)
|
2024-12-15 15:22:59 -08:00
|
|
|
GasaDevOptions_UPROPERTIES.append(cast(CodeVar, member));
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CodeComment generation_notice = def_comment(txt("Generated by GasaGen/GasaGen_DevOptionsCache.cpp"));
|
|
|
|
|
2024-12-15 15:22:59 -08:00
|
|
|
CodeTypename t_UClassPtr = parse_type(code(UClass*));
|
|
|
|
CodeTypename t_UObjectPtr = parse_type(code(UObject*));
|
|
|
|
CodeTypename t_Array_UObjectPtr = parse_type(code(TArray< UObject* >));
|
2024-10-21 19:39:40 -07:00
|
|
|
|
2024-12-15 15:22:59 -08:00
|
|
|
Builder header = gasa_builder_open( path_module_gasa "GasaDevOptionsCache.h" );
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
header.print( generation_notice );
|
|
|
|
header.print( pragma_once );
|
|
|
|
header.print( fmt_newline );
|
|
|
|
header.print( def_include(txt("GasaDevOptionsCache.generated.h")));
|
|
|
|
header.print( fmt_newline );
|
|
|
|
|
|
|
|
header.print( UHT_USTRUCT );
|
|
|
|
CodeStruct FGasaDevOptionsCache;
|
|
|
|
{
|
2024-12-15 15:22:59 -08:00
|
|
|
CodeBody body = def_body(CT_Struct_Body);
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
body.append(UHT_GENERATED_BODY);
|
|
|
|
body.append(fmt_newline);
|
|
|
|
for (CodeVar var : GasaDevOptions_UPROPERTIES)
|
|
|
|
{
|
|
|
|
if ( var->ValueType->Name.starts_with( txt("TSoftClassPtr") )) {
|
|
|
|
body.append(UHT_UPROPERTY);
|
|
|
|
body.append( def_variable(t_UClassPtr, var->Name));
|
|
|
|
}
|
|
|
|
if ( var->ValueType->Name.starts_with( txt("TSoftObjectPtr") )) {
|
|
|
|
body.append(UHT_UPROPERTY);
|
|
|
|
body.append( def_variable(t_UObjectPtr, var->Name));
|
|
|
|
}
|
|
|
|
if ( var->ValueType->Name.starts_with( txt("TArray< TSoftObjectPtr") )) {
|
|
|
|
body.append(UHT_UPROPERTY);
|
|
|
|
body.append( def_variable(t_Array_UObjectPtr, var->Name));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
body.append(fmt_newline);
|
|
|
|
body.append( parse_function(code( void CachedDevOptions(); )));
|
|
|
|
}
|
2024-12-15 15:22:59 -08:00
|
|
|
FGasaDevOptionsCache = parse_struct( token_fmt( "body", body.to_strbuilder().to_str(), stringize(
|
2024-10-21 19:39:40 -07:00
|
|
|
struct GASA_API FGasaDevOptionsCache {
|
|
|
|
<body>
|
|
|
|
};
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
header.print(FGasaDevOptionsCache);
|
|
|
|
header.print( fmt_newline );
|
|
|
|
header.write();
|
|
|
|
format_file( path_module_gasa "GasaDevOptionsCache.h" );
|
|
|
|
}
|
|
|
|
|
2024-12-15 15:22:59 -08:00
|
|
|
Builder source = gasa_builder_open( path_module_gasa "GasaDevOptionsCache.cpp" );
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
2024-12-15 15:22:59 -08:00
|
|
|
Array<CodeInclude> GasaDevOptions_Includes = Array<CodeInclude>::init(gen_ctx.Allocator_Temp);
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
CodeBody source_GasaDevOptions = parse_file( path_module_gasa "GasaDevOptions.cpp");
|
|
|
|
for ( Code entry : source_GasaDevOptions )
|
|
|
|
{
|
2024-12-15 15:22:59 -08:00
|
|
|
if ( entry->Type == CT_Preprocess_Include )
|
|
|
|
GasaDevOptions_Includes.append( cast(CodeInclude, entry));
|
2024-10-21 19:39:40 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
source.print( generation_notice );
|
|
|
|
source.print( def_include(txt("GasaDevOptionsCache.h")));
|
|
|
|
source.print(fmt_newline);
|
|
|
|
for ( CodeInclude include : GasaDevOptions_Includes ) {
|
|
|
|
source.print( include );
|
|
|
|
}
|
|
|
|
source.print( parse_using(code( using namespace Gasa; )));
|
|
|
|
source.print(fmt_newline);
|
|
|
|
|
2024-12-15 15:22:59 -08:00
|
|
|
CodeBody cached_property_assignments = def_body(CT_Function_Body);
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
cached_property_assignments.append(fmt_newline);
|
|
|
|
cached_property_assignments.append(fmt_newline);
|
|
|
|
for (CodeVar var : GasaDevOptions_UPROPERTIES)
|
|
|
|
{
|
2024-12-15 15:22:59 -08:00
|
|
|
if ( var->ValueType->Name.starts_with(txt("TArray")) )
|
2024-10-21 19:39:40 -07:00
|
|
|
{
|
|
|
|
#pragma push_macro("TEXT")
|
|
|
|
#undef TEXT
|
2024-12-15 15:22:59 -08:00
|
|
|
Code assignment = code_fmt( "property_array", var->Name, stringize(
|
2024-10-21 19:39:40 -07:00
|
|
|
for ( auto& entry : DevOpts-> <property_array> )
|
|
|
|
{
|
|
|
|
<property_array>.Push( entry.LoadSynchronous() );
|
|
|
|
ensureMsgf(entry != nullptr, TEXT("An <property_array> entry 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);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma push_macro("TEXT")
|
|
|
|
#undef TEXT
|
2024-12-15 15:22:59 -08:00
|
|
|
Code assignment = code_fmt( "property", var->Name, stringize(
|
2024-10-21 19:39:40 -07:00
|
|
|
<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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CodeFn CachedDevOptions = parse_function( token_fmt(
|
2024-12-15 15:22:59 -08:00
|
|
|
"cached_property_assignments", cached_property_assignments.to_strbuilder().to_str(),
|
2024-10-21 19:39:40 -07:00
|
|
|
stringize(
|
|
|
|
void FGasaDevOptionsCache::CachedDevOptions()
|
|
|
|
{
|
|
|
|
UGasaDevOptions* DevOpts = GetMutDevOptions();
|
|
|
|
|
|
|
|
<cached_property_assignments>
|
|
|
|
|
|
|
|
Tag_GlobalPPV = DevOpts->Tag_GlobalPPV;
|
|
|
|
})
|
|
|
|
));
|
|
|
|
source.print(CachedDevOptions);
|
|
|
|
source.write();
|
|
|
|
format_file( path_module_gasa "GasaDevOptionsCache.cpp" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma pop_macro("ensureMsgf")
|
|
|
|
#pragma pop_macro("GASA_API")
|