update non-module GasaGen

This commit is contained in:
Edward R. Gonzalez 2024-12-15 14:13:44 -05:00
parent 2cf78790db
commit 0ad0b337b3
14 changed files with 362 additions and 141 deletions

View File

@ -70,7 +70,7 @@ void AGasaCharacter::ApplyEffectToSelf(TSubclassOf<UGameplayEffect> GE, float Le
UAbilitySystemComponent* ASC = GetAbilitySystemComponent();
ensure(ASC);
ensure(GE);
FGameplayEffectContextHandle Context = ASC->MakeEffectContext();
FGameplayEffectContextHandle Context = ASC->MakeEffectContext(); Context.AddSourceObject(this);
FGameplayEffectSpecHandle Spec = ASC->MakeOutgoingSpec(GE, Level, Context );
ASC->ApplyGameplayEffectSpecToTarget( * Spec.Data, ASC );
}

View File

@ -4,9 +4,11 @@
#include "GasaCommon.generated.h"
#ifndef global
#define global
#define internal static
#define local_persist static
#endif
#ifndef ccast
#define ccast( Type, Value ) ( *const_cast<(Type)*>( &( Value ) ) )
@ -15,7 +17,9 @@
#define scast( Type, Value ) static_cast<Type>( Value )
#endif
#ifndef bit
#define bit(position) (1 << position)
#endif
#pragma region Math
#define m_pow2( value ) (value * value)
@ -45,8 +49,10 @@ class UCameraComponent;
class UGameplayEffect;
class UInputAction;
class UInputMappingContext;
class UNamedSlot;
class USphereComponent;
class USpringArmComponent;
class UTextBlock;
class UTexture2D;
#pragma endregion Engine Forwards
@ -68,6 +74,9 @@ class AGasaPlayerController;
class AGasaPlayerState;
class APlayerCharacter;
class UAttributeMenu;
class UAttributeMenu_FramedValue;
class UAttributeMenu_TextValueRow;
class UGasaAbilitySystemComp;
class UGasaAttributeSet;
class UGasaDevOptions;

View File

@ -0,0 +1,3 @@
#include "AttributeMenu.h"

View File

@ -0,0 +1,14 @@
#pragma once
#include "UI/GasaUserWidget.h"
#include "AttributeMenu.generated.h"
UCLASS(Blueprintable)
class GASA_API UAttributeMenu : public UGasaUserWidget
{
GENERATED_BODY()
public:
};

View File

@ -0,0 +1,26 @@
#include "FramedValue.h"
#include "UI/GasaImage.h"
#include "Components/TextBlock.h"
#include "UI/GasaSizeBox.h"
void UAttributeMenu_FramedValue::SetBackgroundBrush(FSlateBrush Brush)
{
BG->SetBrush(Brush);
}
void UAttributeMenu_FramedValue::SetBorderBrush(FSlateBrush Brush)
{
Border->SetBrush(Brush);
}
void UAttributeMenu_FramedValue::SetBoxSize(float Width, float Height)
{
SB_Root->SetWidthOverride(Width);
SB_Root->SetHeightOverride(Height);
}
void UAttributeMenu_FramedValue::SetText(FText Content)
{
Value->SetText(Content);
}

View File

@ -0,0 +1,42 @@
#pragma once
#include "UI/GasaUserWidget.h"
#include "FramedValue.generated.h"
UCLASS(Blueprintable)
class GASA_API UAttributeMenu_FramedValue : public UGasaUserWidget
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Frame", meta=(BindWidget))
UGasaSizeBox* SB_Root;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Frame", meta=(BindWidget))
UGasaImage* BG;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Frame", meta=(BindWidget))
UGasaImage* Border;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Frame", meta=(BindWidget))
UTextBlock* Value;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Frame")
float BoxHeight;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Frame")
float BoxWidth;
UFUNCTION(BlueprintCallable)
void SetBackgroundBrush(FSlateBrush Brush);
UFUNCTION(BlueprintCallable)
void SetBorderBrush(FSlateBrush Brush);
UFUNCTION(BlueprintCallable)
void SetBoxSize(float Width, float Height);
UFUNCTION(BlueprintCallable)
void SetText(FText Content);
};

View File

@ -0,0 +1,21 @@
#include "TextValueRow.h"
#include "Components/TextBlock.h"
#include "UI/GasaSizeBox.h"
void UAttributeMenu_TextValueRow::SetAttributeName(FText Name)
{
TB_AttributeName->SetText(Name);
}
void UAttributeMenu_TextValueRow::SetBoxSize(float Width, float Height)
{
SB_Root->SetWidthOverride(Width);
SB_Root->SetHeightOverride(Height);
}
void UAttributeMenu_TextValueRow::NativePreConstruct()
{
Super::NativePreConstruct();
}

View File

@ -0,0 +1,43 @@
#pragma once
#include "UI/GasaUserWidget.h"
#include "TextValueRow.generated.h"
UCLASS(Blueprintable)
class GASA_API UAttributeMenu_TextValueRow : public UGasaUserWidget
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Frame", meta=(BindWidget))
UGasaSizeBox* SB_Root;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Frame", meta=(BindWidget))
UTextBlock* TB_AttributeName;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Frame", meta=(BindWidget))
UAttributeMenu_FramedValue* Value;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Frame", meta=(BindWidget))
UNamedSlot* NSlot;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Frame")
FText AttributeName;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Frame")
float BoxHeight;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Frame")
float BoxWidth;
UFUNCTION(BlueprintCallable)
void SetAttributeName(FText Name);
UFUNCTION(BlueprintCallable)
void SetBoxSize(float Width, float Height);
#pragma region UserWidget
void NativePreConstruct() override;
#pragma endregion UserWidget
};

View File

@ -196,4 +196,3 @@ void UGlobeProgressBar::Serialize(FStructuredArchive::FRecord Record)
Super::Serialize(Record);
}
#pragma endregion UserWidget

View File

@ -27,8 +27,6 @@ int gen_main()
gen::init(& ctx);
log_fmt("Generating code for the Gasa module\n");
Array(StrCached)& PreprocessorDefines = ctx.PreprocessorDefines;
// Initialize Globals
{
UHT_UCLASS = code_str( UCLASS() );
@ -39,52 +37,60 @@ int gen_main()
}
// Populate Defines
{
PreprocessorDefines.append( cache_str(str_DECLARE_CLASS));
PreprocessorDefines.append( cache_str(str_DECLARE_DELEGATE_RetVal_OneParam));
PreprocessorDefines.append( cache_str(str_DECLARE_DELEGATE_RetVal_ThreeParams));
PreprocessorDefines.append( cache_str(str_DECLARE_DELEGATE_SixParams));
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam));
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams));
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams));
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams));
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam));
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams));
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams));
PreprocessorDefines.append( cache_str(str_DECLARE_EVENT_ThreeParams));
PreprocessorDefines.append( cache_str(str_DECLARE_EVENT_TwoParams));
PreprocessorDefines.append( cache_str(str_DECLARE_FUNCTION));
PreprocessorDefines.append( cache_str(str_DECLARE_LOG_CATEGORY_EXTERN));
PreprocessorDefines.append( cache_str(str_DECLARE_MULTICAST_DELEGATE_OneParam));
PreprocessorDefines.append( cache_str(str_DECLARE_MULTICAST_DELEGATE_ThreeParams));
PreprocessorDefines.append( cache_str(str_DECLARE_MULTICAST_DELEGATE_TwoParams));
PreprocessorDefines.append( cache_str(str_DECLARE_TS_MULTICAST_DELEGATE_OneParam));
PreprocessorDefines.append( cache_str(str_DECLARE_TS_MULTICAST_DELEGATE_TwoParams));
PreprocessorDefines.append( cache_str(str_DECLARE_TS_MULTICAST_DELEGATE_ThreeParams));
PreprocessorDefines.append( cache_str(str_DEFINE_ACTORDESC_TYPE));
PreprocessorDefines.append( cache_str(str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL));
PreprocessorDefines.append( cache_str(str_ENUM_CLASS_FLAGS));
PreprocessorDefines.append( cache_str(str_FORCEINLINE_DEBUGGABLE));
// PreprocessorDefines.append( get_cached_string(str_FORCEINLINE));
PreprocessorDefines.append( cache_str(str_GENERATED_BODY));
PreprocessorDefines.append( cache_str(str_GENERATED_UCLASS_BODY));
PreprocessorDefines.append( cache_str(str_GENERATED_USTRUCT_BODY));
PreprocessorDefines.append( cache_str(str_PRAGMA_DISABLE_DEPRECATION_WARNINGS));
PreprocessorDefines.append( cache_str(str_PRAGMA_ENABLE_DEPRECATION_WARNINGS));
PreprocessorDefines.append( cache_str(str_PROPERTY_BINDING_IMPLEMENTATION));
PreprocessorDefines.append( cache_str(str_RESULT_DECL));
PreprocessorDefines.append( cache_str(str_SLATE_BEGIN_ARGS));
PreprocessorDefines.append( cache_str(str_SLATE_END_ARGS));
PreprocessorDefines.append( cache_str(str_TEXT));
PreprocessorDefines.append( cache_str(str_UCLASS));
PreprocessorDefines.append( cache_str(str_UENUM));
PreprocessorDefines.append( cache_str(str_UFUNCTION));
PreprocessorDefines.append( cache_str(str_UMETA));
PreprocessorDefines.append( cache_str(str_UPARAM));
PreprocessorDefines.append( cache_str(str_UPROPERTY));
PreprocessorDefines.append( cache_str(str_USTRUCT));
PreprocessorDefines.append( cache_str(str_UE_REQUIRES));
}
register_macros( args(
(Macro { str_DECLARE_CLASS, MT_Statement, MF_Functional }),
(Macro { str_DECLARE_DELEGATE_RetVal_OneParam, MT_Statement, MF_Functional }),
(Macro { str_DECLARE_DELEGATE_RetVal_ThreeParams, MT_Statement, MF_Functional }),
(Macro { str_DECLARE_DELEGATE_SixParams, MT_Statement, MF_Functional }),
(Macro { str_DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam, MT_Statement, MF_Functional }),
(Macro { str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams, MT_Statement, MF_Functional }),
(Macro { str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams, MT_Statement, MF_Functional }),
(Macro { str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams, MT_Statement, MF_Functional }),
(Macro { str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam, MT_Statement, MF_Functional }),
(Macro { str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams, MT_Statement, MF_Functional }),
(Macro { str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams, MT_Statement, MF_Functional }),
(Macro { str_DECLARE_EVENT_ThreeParams, MT_Statement, MF_Functional }),
(Macro { str_DECLARE_EVENT_TwoParams, MT_Statement, MF_Functional }),
(Macro { str_DECLARE_FUNCTION, MT_Statement, MF_Functional }),
(Macro { str_DECLARE_LOG_CATEGORY_EXTERN, MT_Statement, MF_Functional | MF_Allow_As_Definition }),
(Macro { str_DECLARE_MULTICAST_DELEGATE_OneParam, MT_Statement, MF_Functional }),
(Macro { str_DECLARE_MULTICAST_DELEGATE_ThreeParams, MT_Statement, MF_Functional }),
(Macro { str_DECLARE_MULTICAST_DELEGATE_TwoParams, MT_Statement, MF_Functional }),
(Macro { str_DECLARE_TS_MULTICAST_DELEGATE_OneParam, MT_Statement, MF_Functional }),
(Macro { str_DECLARE_TS_MULTICAST_DELEGATE_TwoParams, MT_Statement, MF_Functional }),
(Macro { str_DECLARE_TS_MULTICAST_DELEGATE_ThreeParams, MT_Statement, MF_Functional }),
(Macro { str_DEFINE_ACTORDESC_TYPE, MT_Statement, MF_Functional }),
(Macro { str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL, MT_Statement, MF_Functional }),
(Macro { str_ENUM_CLASS_FLAGS, MT_Statement, MF_Functional }),
(Macro { str_GENERATED_BODY, MT_Statement, MF_Functional }),
(Macro { str_GENERATED_UCLASS_BODY, MT_Statement, MF_Functional }),
(Macro { str_GENERATED_USTRUCT_BODY, MT_Statement, MF_Functional }),
(Macro { str_PRAGMA_DISABLE_DEPRECATION_WARNINGS, MT_Statement, MF_Null | MF_Allow_As_Attribute }),
(Macro { str_PRAGMA_ENABLE_DEPRECATION_WARNINGS, MT_Statement, MF_Null | MF_Allow_As_Attribute }),
(Macro { str_PROPERTY_BINDING_IMPLEMENTATION, MT_Statement, MF_Functional }),
(Macro { str_RESULT_DECL, MT_Expression, MF_Functional }),
(Macro { str_SLATE_BEGIN_ARGS, MT_Statement, MF_Functional }),
(Macro { str_SLATE_END_ARGS, MT_Statement, MF_Functional }),
(Macro { str_TEXT, MT_Expression, MF_Functional }),
(Macro { str_UCLASS, MT_Statement, MF_Functional }),
(Macro { str_UENUM, MT_Statement, MF_Functional }),
(Macro { str_UFUNCTION, MT_Statement, MF_Functional }),
(Macro { str_UMETA, MT_Expression, MF_Functional }),
(Macro { str_UPARAM, MT_Expression, MF_Functional }),
(Macro { str_UPROPERTY, MT_Statement, MF_Functional }),
(Macro { str_USTRUCT, MT_Statement, MF_Functional }),
(Macro { str_UE_REQUIRES, MT_Expression, MF_Functional }),
(Macro { str_UE_DEPRECATED, MT_Statement, MF_Functional | MF_Allow_As_Attribute }),
(Macro { str_ACTOR_HAS_LABELS, MT_Expression, MF_Null }),
(Macro { str_HIDE_ACTOR_TRANSFORM_FUNCTIONS, MT_Statement, MF_Functional }),
(Macro { str_SCENECOMPONENT_QUAT_TOLERANCE, MT_Expression, MF_Null }),
(Macro { str_SCENECOMPONENT_ROTATOR_TOLERANCE, MT_Expression, MF_Null }),
(Macro { str_GAMEPLAYATTRIBUTE_REPNOTIFY, MT_Statement, MF_Functional }),
(Macro { str_GAMEPLAYATTRIBUTE_PROPERTY_GETTER, MT_Statement, MF_Functional }),
(Macro { str_GAMEPLAYATTRIBUTE_VALUE_GETTER, MT_Statement, MF_Functional }),
(Macro { str_GAMEPLAYATTRIBUTE_VALUE_SETTER, MT_Statement, MF_Functional }),
(Macro { str_GAMEPLAYATTRIBUTE_VALUE_INITTER, MT_Statement, MF_Functional })
));
// gen_UGasaAttributeSet();
// gen_FGasaDevOptionsCache();

View File

@ -18,50 +18,58 @@ using namespace gen;
#define path_gasa_game path_module_gasa "Game/"
#define path_gasa_ui path_module_gasa "UI/"
constexpr Str str_DECLARE_CLASS = txt("DECLARE_CLASS(");
constexpr Str str_DECLARE_DELEGATE_RetVal_OneParam = txt("DECLARE_DELEGATE_RetVal_OneParam(");
constexpr Str str_DECLARE_DELEGATE_RetVal_ThreeParams = txt("DECLARE_DELEGATE_RetVal_ThreeParams(");
constexpr Str str_DECLARE_DELEGATE_SixParams = txt("DECLARE_DELEGATE_SixParams(");
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam = txt("DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(");
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams(");
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams(");
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams(");
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(");
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams(");
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams(");
constexpr Str str_DECLARE_EVENT_ThreeParams = txt("DECLARE_EVENT_ThreeParams(");
constexpr Str str_DECLARE_EVENT_TwoParams = txt("DECLARE_EVENT_TwoParams(");
constexpr Str str_DECLARE_FUNCTION = txt("DECLARE_FUNCTION(");
constexpr Str str_DECLARE_LOG_CATEGORY_EXTERN = txt("DECLARE_LOG_CATEGORY_EXTERN(");
constexpr Str str_DECLARE_MULTICAST_DELEGATE_OneParam = txt("DECLARE_MULTICAST_DELEGATE_OneParam(");
constexpr Str str_DECLARE_MULTICAST_DELEGATE_ThreeParams = txt("DECLARE_MULTICAST_DELEGATE_ThreeParams(");
constexpr Str str_DECLARE_MULTICAST_DELEGATE_TwoParams = txt("DECLARE_MULTICAST_DELEGATE_TwoParams(");
constexpr Str str_DECLARE_TS_MULTICAST_DELEGATE_OneParam = txt("DECLARE_TS_MULTICAST_DELEGATE_OneParam(");
constexpr Str str_DECLARE_TS_MULTICAST_DELEGATE_TwoParams = txt("DECLARE_TS_MULTICAST_DELEGATE_TwoParams(");
constexpr Str str_DECLARE_TS_MULTICAST_DELEGATE_ThreeParams = txt("DECLARE_TS_MULTICAST_DELEGATE_ThreeParams(");
constexpr Str str_DEFINE_ACTORDESC_TYPE = txt("DEFINE_ACTORDESC_TYPE(");
constexpr Str str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL = txt("DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(");
constexpr Str str_ENUM_CLASS_FLAGS = txt("ENUM_CLASS_FLAGS(");
// constexpr StrC str_FORCEINLINE = txt("FORCEINLINE");
constexpr Str str_FORCEINLINE_DEBUGGABLE = txt("FORCEINLINE_DEBUGGABLE");
constexpr Str str_GENERATED_BODY = txt("GENERATED_BODY(");
constexpr Str str_GENERATED_UCLASS_BODY = txt("GENERATED_UCLASS_BODY(");
constexpr Str str_GENERATED_USTRUCT_BODY = txt("GENERATED_USTRUCT_BODY(");
constexpr Str str_DECLARE_CLASS = txt("DECLARE_CLASS");
constexpr Str str_DECLARE_DELEGATE_RetVal_OneParam = txt("DECLARE_DELEGATE_RetVal_OneParam");
constexpr Str str_DECLARE_DELEGATE_RetVal_ThreeParams = txt("DECLARE_DELEGATE_RetVal_ThreeParams");
constexpr Str str_DECLARE_DELEGATE_SixParams = txt("DECLARE_DELEGATE_SixParams");
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam = txt("DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam");
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams");
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams");
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams");
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam");
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams");
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams");
constexpr Str str_DECLARE_EVENT_ThreeParams = txt("DECLARE_EVENT_ThreeParams");
constexpr Str str_DECLARE_EVENT_TwoParams = txt("DECLARE_EVENT_TwoParams");
constexpr Str str_DECLARE_FUNCTION = txt("DECLARE_FUNCTION");
constexpr Str str_DECLARE_LOG_CATEGORY_EXTERN = txt("DECLARE_LOG_CATEGORY_EXTERN");
constexpr Str str_DECLARE_MULTICAST_DELEGATE_OneParam = txt("DECLARE_MULTICAST_DELEGATE_OneParam");
constexpr Str str_DECLARE_MULTICAST_DELEGATE_ThreeParams = txt("DECLARE_MULTICAST_DELEGATE_ThreeParams");
constexpr Str str_DECLARE_MULTICAST_DELEGATE_TwoParams = txt("DECLARE_MULTICAST_DELEGATE_TwoParams");
constexpr Str str_DECLARE_TS_MULTICAST_DELEGATE_OneParam = txt("DECLARE_TS_MULTICAST_DELEGATE_OneParam");
constexpr Str str_DECLARE_TS_MULTICAST_DELEGATE_TwoParams = txt("DECLARE_TS_MULTICAST_DELEGATE_TwoParams");
constexpr Str str_DECLARE_TS_MULTICAST_DELEGATE_ThreeParams = txt("DECLARE_TS_MULTICAST_DELEGATE_ThreeParams");
constexpr Str str_DEFINE_ACTORDESC_TYPE = txt("DEFINE_ACTORDESC_TYPE");
constexpr Str str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL = txt("DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL");
constexpr Str str_ENUM_CLASS_FLAGS = txt("ENUM_CLASS_FLAGS");
constexpr Str str_GENERATED_BODY = txt("GENERATED_BODY");
constexpr Str str_GENERATED_UCLASS_BODY = txt("GENERATED_UCLASS_BODY");
constexpr Str str_GENERATED_USTRUCT_BODY = txt("GENERATED_USTRUCT_BODY");
constexpr Str str_PRAGMA_DISABLE_DEPRECATION_WARNINGS = txt("PRAGMA_DISABLE_DEPRECATION_WARNINGS");
constexpr Str str_PRAGMA_ENABLE_DEPRECATION_WARNINGS = txt("PRAGMA_ENABLE_DEPRECATION_WARNINGS");
constexpr Str str_PROPERTY_BINDING_IMPLEMENTATION = txt("PROPERTY_BINDING_IMPLEMENTATION(");
constexpr Str str_PROPERTY_BINDING_IMPLEMENTATION = txt("PROPERTY_BINDING_IMPLEMENTATION");
constexpr Str str_RESULT_DECL = txt("RESULT_DECL");
constexpr Str str_SLATE_BEGIN_ARGS = txt("SLATE_BEGIN_ARGS(");
constexpr Str str_SLATE_END_ARGS = txt("SLATE_END_ARGS(");
constexpr Str str_TEXT = txt("TEXT(");
constexpr Str str_UCLASS = txt("UCLASS(");
constexpr Str str_UENUM = txt("UENUM(");
constexpr Str str_UFUNCTION = txt("UFUNCTION(");
constexpr Str str_UMETA = txt("UMETA(");
constexpr Str str_UPARAM = txt("UPARAM(");
constexpr Str str_UPROPERTY = txt("UPROPERTY(");
constexpr Str str_USTRUCT = txt("USTRUCT(");
constexpr Str str_UE_REQUIRES = txt("UE_REQUIRES(");
constexpr Str str_SLATE_BEGIN_ARGS = txt("SLATE_BEGIN_ARGS");
constexpr Str str_SLATE_END_ARGS = txt("SLATE_END_ARGS");
constexpr Str str_TEXT = txt("TEXT");
constexpr Str str_UCLASS = txt("UCLASS");
constexpr Str str_UENUM = txt("UENUM");
constexpr Str str_UFUNCTION = txt("UFUNCTION");
constexpr Str str_UMETA = txt("UMETA");
constexpr Str str_UPARAM = txt("UPARAM");
constexpr Str str_UPROPERTY = txt("UPROPERTY");
constexpr Str str_USTRUCT = txt("USTRUCT");
constexpr Str str_UE_REQUIRES = txt("UE_REQUIRES");
constexpr Str str_UE_DEPRECATED = txt("UE_DEPRECATED");
constexpr Str str_ACTOR_HAS_LABELS = txt("ACTOR_HAS_LABELS");
constexpr Str str_HIDE_ACTOR_TRANSFORM_FUNCTIONS = txt("HIDE_ACTOR_TRANSFORM_FUNCTIONS");
constexpr Str str_SCENECOMPONENT_QUAT_TOLERANCE = txt("SCENECOMPONENT_QUAT_TOLERANCE");
constexpr Str str_SCENECOMPONENT_ROTATOR_TOLERANCE = txt("SCENECOMPONENT_ROTATOR_TOLERANCE");
constexpr Str str_GAMEPLAYATTRIBUTE_REPNOTIFY = txt("GAMEPLAYATTRIBUTE_REPNOTIFY");
constexpr Str str_GAMEPLAYATTRIBUTE_PROPERTY_GETTER = txt("GAMEPLAYATTRIBUTE_PROPERTY_GETTER");
constexpr Str str_GAMEPLAYATTRIBUTE_VALUE_GETTER = txt("GAMEPLAYATTRIBUTE_VALUE_GETTER");
constexpr Str str_GAMEPLAYATTRIBUTE_VALUE_SETTER = txt("GAMEPLAYATTRIBUTE_VALUE_SETTER");
constexpr Str str_GAMEPLAYATTRIBUTE_VALUE_INITTER = txt("GAMEPLAYATTRIBUTE_VALUE_INITTER");
constexpr Str str_GASA_API = txt("GASA_API");

View File

@ -36,7 +36,7 @@ void ue_parse_testing()
case CT_Function_Fwd:
if ( class_code->Name )
{
log_fmt("%s\n", class_code->Name );
log_fmt("%S\n", class_code->Name );
// log_fmt("%s\n", class_code->to_string() );
}
break;
@ -74,7 +74,7 @@ void ue_parse_testing()
case CT_Function_Fwd:
if ( class_code->Name )
{
log_fmt("%s\n", class_code->Name );
log_fmt("%S\n", class_code->Name );
// log_fmt("%s\n", class_code->to_string() );
}
break;
@ -109,7 +109,7 @@ void ue_parse_testing()
case CT_Function_Fwd:
if ( class_code->Name )
{
log_fmt("%s\n", class_code->Name );
log_fmt("%S\n", class_code->Name );
}
break;
}
@ -143,7 +143,7 @@ void ue_parse_testing()
case CT_Function_Fwd:
if ( class_code->Name )
{
log_fmt("%s\n", class_code->Name );
log_fmt("%S\n", class_code->Name );
}
break;
}
@ -177,7 +177,7 @@ void ue_parse_testing()
case CT_Function_Fwd:
if ( class_code->Name )
{
log_fmt("%s\n", class_code->Name );
log_fmt("%S\n", class_code->Name );
}
break;
}
@ -211,7 +211,7 @@ void ue_parse_testing()
case CT_Function_Fwd:
if ( class_code->Name )
{
log_fmt("%s\n", class_code->Name );
log_fmt("%S\n", class_code->Name );
}
break;
}

View File

@ -3498,6 +3498,7 @@ void register_macro( Macro macro ) {
GEN_ASSERT_NOT_NULL(macro.Name.Ptr);
GEN_ASSERT(macro.Name.Len > 0);
u32 key = crc32( macro.Name.Ptr, macro.Name.Len );
macro.Name = cache_str(macro.Name);
hashtable_set( _ctx->Macros, key, macro );
}
@ -3511,6 +3512,7 @@ void register_macros( s32 num, ... )
Macro macro = va_arg(va, Macro);
GEN_ASSERT_NOT_NULL(macro.Name.Ptr);
GEN_ASSERT(macro.Name.Len > 0);
macro.Name = cache_str(macro.Name);
u32 key = crc32( macro.Name.Ptr, macro.Name.Len );
hashtable_set( _ctx->Macros, key, macro );
@ -3527,6 +3529,7 @@ void register_macros( s32 num, Macro* macros )
Macro macro = * macros;
GEN_ASSERT_NOT_NULL(macro.Name.Ptr);
GEN_ASSERT(macro.Name.Len > 0);
macro.Name = cache_str(macro.Name);
u32 key = crc32( macro.Name.Ptr, macro.Name.Len );
hashtable_set( _ctx->Macros, key, macro );
@ -6160,45 +6163,24 @@ void lex_found_token( LexContext* ctx )
ctx->token.Type = macrotype_to_toktype(macro->Type);
b32 is_functional = macro_is_functional(* macro);
resolved_to_macro = has_args ? is_functional : ! is_functional;
if ( ! resolved_to_macro ) {
log_fmt("Info(%d, %d): %S identified as a macro but usage here does not resolve to one (interpreting as identifier)\n"
, ctx->token.Line
, ctx->token.Line
, macro->Name
);
}
}
if ( resolved_to_macro )
{
// TODO(Ed): When we introduce a macro AST (and expression support), we'll properly lex this section.
// Want to ignore any arguments the define may have as they can be execution expressions.
if ( has_args )
{
if ( has_args ) {
ctx->token.Flags |= TF_Macro_Functional;
// move_forward();
// ctx->token.Text.Len++;
// s32 level = 0;
// while ( ctx->left && ((* ctx->scanner) != ')' || level > 0) )
// {
// if ( (* ctx->scanner) == '(' )
// level++;
// else if ( (* ctx->scanner) == ')' && level > 0 )
// level--;
// move_forward();
// ctx->token.Text.Len++;
// }
// move_forward();
// ctx->token.Text.Len++;
}
//if ( (* ctx->scanner) == '\r' && ctx->scanner[1] == '\n' )
//{
// move_forward();
// ctx->token..Text.Length++;
//}
//else if ( (* ctx->scanner) == '\n' )
//{
// move_forward();
// ctx->token..Text.Length++;
//}
if ( bitfield_is_set(MacroFlags, macro->Flags, MF_Allow_As_Attribute) ) {
ctx->token.Flags |= TF_Attribute;
}
}
else
{
@ -7252,6 +7234,7 @@ internal CodeBody parse_global_nspace ( CodeType which
internal Code parse_global_nspace_constructor_destructor( CodeSpecifiers specifiers );
internal Token parse_identifier ( bool* possible_member_function );
internal CodeInclude parse_include ();
internal Code parse_macro_as_definiton ( CodeAttributes attributes, CodeSpecifiers specifiers );
internal CodeOperator parse_operator_after_ret_type ( ModuleFlag mflags, CodeAttributes attributes, CodeSpecifiers specifiers, CodeTypename ret_type );
internal Code parse_operator_function_or_variable( bool expects_function, CodeAttributes attributes, CodeSpecifiers specifiers );
internal CodePragma parse_pragma ();
@ -7626,7 +7609,7 @@ CodeAttributes parse_attributes()
s32 len = 0;
// There can be more than one attribute. If there is flatten them to a single string.
// TODO(Ed): Support keeping an linked list of attributes similar to parameters
// TODO(Ed): Support chaining attributes (Use parameter linkage pattern)
while ( left && tok_is_attribute(currtok) )
{
if ( check( Tok_Attribute_Open ) )
@ -9482,6 +9465,12 @@ Code parse_operator_function_or_variable( bool expects_function, CodeAttributes
Code result = InvalidCode;
Code macro_stmt = parse_macro_as_definiton(attributes, specifiers);
if (macro_stmt) {
parser_pop(& _ctx->parser);
return macro_stmt;
}
CodeTypename type = parser_parse_type( parser_not_from_template, nullptr );
// <Attributes> <Specifiers> <ReturnType/ValueType>
@ -9554,6 +9543,36 @@ Code parse_operator_function_or_variable( bool expects_function, CodeAttributes
return result;
}
internal
Code parse_macro_as_definiton( CodeAttributes attributes, CodeSpecifiers specifiers )
{
push_scope();
if (currtok.Type != Tok_Preprocess_Macro_Stmt ) {
parser_pop(& _ctx->parser);
return NullCode;
}
Macro* macro = lookup_macro(currtok.Text);
b32 can_resolve_to_definition = macro && bitfield_is_set(MacroFlags, macro->Flags, MF_Allow_As_Definition);
if ( ! can_resolve_to_definition) {
parser_pop(& _ctx->parser);
return NullCode;
}
// TODO(Ed): When AST_Macro is made, have it support attributs and specifiers for when its behaving as a declaration/definition.
Code code = parse_simple_preprocess( Tok_Preprocess_Macro_Stmt );
// Attributes and sepcifiers will be collapsed into the macro's serialization.
StrBuilder resolved_definition = strbuilder_fmt_buf(_ctx->Allocator_Temp, "%S %S %S"
, attributes ? strbuilder_to_str( attributes_to_strbuilder(attributes)) : txt("")
, specifiers ? strbuilder_to_str( specifiers_to_strbuilder(specifiers)) : txt("")
, code->Content
);
Code result = untyped_str( strbuilder_to_str(resolved_definition) );
parser_pop(& _ctx->parser);
return result;
}
internal
CodePragma parse_pragma()
{
@ -10809,8 +10828,11 @@ CodeEnum parser_parse_enum( bool inplace_def )
// Unreal UMETA macro support
if ( currtok.Type == Tok_Preprocess_Macro_Expr ) {
eat( Tok_Preprocess_Macro_Expr );
Code macro = parse_simple_preprocess( Tok_Preprocess_Macro_Expr );
// <Name> = <Expression> <Macro>
// We're intentially ignoring this code as its going to be serialized as an untyped string with the rest of the enum "entry".
// TODO(Ed): We need a CodeEnumEntry, AST_EnumEntry types
}
if ( currtok.Type == Tok_Comma )
@ -11108,6 +11130,13 @@ CodeFn parser_parse_function()
}
// <export> <Attributes> <Specifiers>
// Note(Ed): We're enforcing that using this codepath requires non-macro jank.
// Code macro_stmt = parse_macro_as_definiton(attributes, specifiers);
// if (macro_stmt) {
// parser_pop(& _ctx->parser);
// return macro_stmt;
// }
CodeTypename ret_type = parser_parse_type(parser_not_from_template, nullptr);
if ( cast(Code, ret_type) == Code_Invalid ) {
parser_pop(& _ctx->parser);
@ -12496,6 +12525,13 @@ CodeVar parser_parse_variable()
}
// <ModuleFlags> <Attributes> <Specifiers>
// Note(Ed): We're enforcing that using this codepath requires non-macro jank.
// Code macro_stmt = parse_macro_as_definiton(attributes, specifiers);
// if (macro_stmt) {
// parser_pop(& _ctx->parser);
// return macro_stmt;
// }
CodeTypename type = parser_parse_type(parser_not_from_template, nullptr);
// <ModuleFlags> <Attributes> <Specifiers> <ValueType>

View File

@ -640,11 +640,10 @@ FORCEINLINE bool is_trailing( Specifier specifier )
return spec_is_trailing( specifier );
}
#define GEN_DEFINE_ATTRIBUTE_TOKENS \
Entry( Tok_Attribute_API_Export, "GEN_API_Export_Code" ) Entry( Tok_Attribute_API_Import, "GEN_API_Import_Code" ) \
Entry( Tok_Attribute_COREUOBJECT_API, "COREUOBJECT_API" ) Entry( Tok_Attribute_ENGINE_API, "ENGINE_API" ) \
Entry( Tok_Attribute_GAMEPLAYABILITIES_API, "GAMEPLAYABILITIES_API" ) Entry( Tok_Attribute_UMG_API, "UMG_API" ) \
Entry( Tok_Attribute_UE_DEPRECATED, "UE_DEPRECATED" )
#define GEN_DEFINE_ATTRIBUTE_TOKENS \
Entry( Tok_Attribute_API_Export, "GEN_API_Export_Code" ) Entry( Tok_Attribute_API_Import, "GEN_API_Import_Code" ) \
Entry( Tok_Attribute_COREUOBJECT_API, "COREUOBJECT_API" ) Entry( Tok_Attribute_ENGINE_API, "ENGINE_API" ) \
Entry( Tok_Attribute_GAMEPLAYABILITIES_API, "GAMEPLAYABILITIES_API" ) Entry( Tok_Attribute_UMG_API, "UMG_API" )
enum TokType : u32
{
@ -692,6 +691,7 @@ enum TokType : u32
Tok_Operator,
Tok_Preprocess_Hash,
Tok_Preprocess_Define,
Tok_Preprocess_Define_Param,
Tok_Preprocess_If,
Tok_Preprocess_IfDef,
Tok_Preprocess_IfNotDef,
@ -752,7 +752,6 @@ enum TokType : u32
Tok_Attribute_ENGINE_API,
Tok_Attribute_GAMEPLAYABILITIES_API,
Tok_Attribute_UMG_API,
Tok_Attribute_UE_DEPRECATED,
Tok_NumTokens
};
@ -803,6 +802,7 @@ inline Str toktype_to_str( TokType type )
{ "__operator__", sizeof( "__operator__" ) - 1 },
{ "#", sizeof( "#" ) - 1 },
{ "define", sizeof( "define" ) - 1 },
{ "__define_param__", sizeof( "__define_param__" ) - 1 },
{ "if", sizeof( "if" ) - 1 },
{ "ifdef", sizeof( "ifdef" ) - 1 },
{ "ifndef", sizeof( "ifndef" ) - 1 },
@ -863,7 +863,6 @@ inline Str toktype_to_str( TokType type )
{ "ENGINE_API", sizeof( "ENGINE_API" ) - 1 },
{ "GAMEPLAYABILITIES_API", sizeof( "GAMEPLAYABILITIES_API" ) - 1 },
{ "UMG_API", sizeof( "UMG_API" ) - 1 },
{ "UE_DEPRECATED", sizeof( "UE_DEPRECATED" ) - 1 },
};
return lookup[type];
}
@ -1055,8 +1054,22 @@ enum EMacroFlags : u16
{
MF_Functional = bit(0), // Macro has parameters (args expected to be passed)
MF_Expects_Body = bit(1), // Expects to assign a braced scope to its body.
MF_Allow_As_Identifier = bit(2), // lex__eat wil treat this macro as an identifier if the parser attempts to consume it as one.
// ^^^ This is a sort of kludge because we don't support push/pop macro programs rn. ^^^
// lex__eat wil treat this macro as an identifier if the parser attempts to consume it as one.
// ^^^ This is a kludge because we don't support push/pop macro pragmas rn.
MF_Allow_As_Identifier = bit(2),
// lex__eat wil treat this macro as an attribute if the parser attempts to consume it as one.
// ^^^ This a kludge because unreal has a macro that behaves as both a 'statement' and an attribute (UE_DEPRECATED, PRAGMA_ENABLE_DEPRECATION_WARNINGS, etc)
// TODO(Ed): We can keep the MF_Allow_As_Attribute flag for macros, however, we need to add the ability of AST_Attributes to chain themselves.
// Its thats already a thing in the standard language anyway
// & it would allow UE_DEPRECATED, (UE_PROPERTY / UE_FUNCTION) to chain themselves as attributes of a resolved member function/varaible definition
MF_Allow_As_Attribute = bit(3),
// When a macro is encountered after attributs and specifiers while parsing a function, or variable:
// It will consume the macro and treat it as resolving the definition. (Yes this is for Unreal Engine)
// (MUST BE OF MT_Statement TYPE)
MF_Allow_As_Definition = bit(4),
MF_Null = 0,
MF_UnderlyingType = GEN_U16_MAX,
@ -2741,13 +2754,14 @@ struct AST_Body
};
static_assert( sizeof(AST_Body) == sizeof(AST), "ERROR: AST_Body is not the same size as AST");
// TODO(Ed): Support chaining attributes (Use parameter linkage pattern)
struct AST_Attributes
{
union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
StrCached Content;
};
StrCached Name;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;