fixes etc for gasa gen
This commit is contained in:
parent
f55e96ec6a
commit
c895772cff
@ -1,42 +1,50 @@
|
|||||||
|
using UnrealBuildTool;
|
||||||
using ModuleRules = UnrealBuildTool.ModuleRules;
|
using ModuleRules = UnrealBuildTool.ModuleRules;
|
||||||
using ReadOnlyTargetRules = UnrealBuildTool.ReadOnlyTargetRules;
|
using ReadOnlyTargetRules = UnrealBuildTool.ReadOnlyTargetRules;
|
||||||
|
|
||||||
public class GasaEditor : ModuleRules
|
public class GasaEditor : ModuleRules
|
||||||
{
|
{
|
||||||
public GasaEditor(ReadOnlyTargetRules Target) : base(Target)
|
public GasaEditor(ReadOnlyTargetRules Target) : base(Target)
|
||||||
{
|
{
|
||||||
#region Engine
|
#region Engine
|
||||||
PrivateIncludePathModuleNames.AddRange(new string[] {
|
|
||||||
"Core",
|
PrivateIncludePathModuleNames.AddRange(new string[]
|
||||||
"CoreUObject",
|
{
|
||||||
"Engine",
|
"Core",
|
||||||
});
|
"CoreUObject",
|
||||||
PrivateDependencyModuleNames.AddRange(new string[] {
|
"Engine",
|
||||||
"Core",
|
});
|
||||||
"Engine",
|
PrivateDependencyModuleNames.AddRange(new string[]
|
||||||
"CoreUObject",
|
{
|
||||||
|
"Core",
|
||||||
|
"Engine",
|
||||||
|
"CoreUObject",
|
||||||
"EditorStyle",
|
"EditorStyle",
|
||||||
"PropertyEditor",
|
"PropertyEditor",
|
||||||
"SlateCore",
|
"SlateCore",
|
||||||
"Slate",
|
"Slate",
|
||||||
"UMG",
|
"UMG",
|
||||||
"UnrealEd",
|
"UnrealEd",
|
||||||
});
|
});
|
||||||
#endregion Engine
|
|
||||||
|
#endregion Engine
|
||||||
|
|
||||||
PublicIncludePaths.Add("GasaEditor");
|
PublicIncludePaths.Add("GasaEditor");
|
||||||
PrivateDependencyModuleNames.Add("Gasa");
|
PrivateDependencyModuleNames.Add("Gasa");
|
||||||
|
|
||||||
bWarningsAsErrors = false;
|
bWarningsAsErrors = false;
|
||||||
ShadowVariableWarningLevel = UnrealBuildTool.WarningLevel.Off;
|
ShadowVariableWarningLevel = UnrealBuildTool.WarningLevel.Off;
|
||||||
UndefinedIdentifierWarningLevel = UnrealBuildTool.WarningLevel.Off;
|
UndefinedIdentifierWarningLevel = UnrealBuildTool.WarningLevel.Off;
|
||||||
|
|
||||||
// gencpp related defines
|
// gencpp related defines
|
||||||
PublicDefinitions.Add("Build_Debug=1");
|
|
||||||
PublicDefinitions.Add("GEN_TIME=1");
|
PublicDefinitions.Add("GEN_TIME=1");
|
||||||
PublicDefinitions.Add("GEN_EXECUTION_EXPRESSION_SUPPORT=0");
|
PublicDefinitions.Add("GEN_EXECUTION_EXPRESSION_SUPPORT=0");
|
||||||
PublicDefinitions.Add("GEN_EXPOSE_BACKEND=1");
|
PublicDefinitions.Add("GEN_EXPOSE_BACKEND=1");
|
||||||
PublicDefinitions.Add("GEN_PARSER_DISABLE_MACRO_TYPEDEF=0");
|
PublicDefinitions.Add("GEN_PARSER_DISABLE_MACRO_TYPEDEF=0");
|
||||||
|
PublicDefinitions.Add("GEN_DONT_USE_NAMESPACE=0");
|
||||||
|
PublicDefinitions.Add("GEN_BUILD_DEBUG=1");
|
||||||
|
PublicDefinitions.Add("GEN_SUPPORT_CPP_REFERENCES=1");
|
||||||
|
|
||||||
|
OptimizeCode = CodeOptimization.Never;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,22 +36,22 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
|
|
||||||
check( asset_name.StartsWith(TEXT("DT_") ))
|
check( asset_name.StartsWith(TEXT("DT_") ))
|
||||||
asset_name = asset_name.RightChop(3);
|
asset_name = asset_name.RightChop(3);
|
||||||
String str_AssetName = to_string(asset_name);
|
Str str_AssetName = to_string(asset_name);
|
||||||
|
|
||||||
String class_name = String::fmt_buf(GlobalAllocator, "U%S", str_AssetName);
|
Str class_name = StrBuilder::fmt_buf(gen_ctx.Allocator_Temp, "U%S", str_AssetName);
|
||||||
String header_file_name = String::fmt_buf(GlobalAllocator, "%S.h", str_AssetName);
|
Str header_file_name = StrBuilder::fmt_buf(gen_ctx.Allocator_Temp, "%S.h", str_AssetName);
|
||||||
String inlines_file_name = String::fmt_buf(GlobalAllocator, "%S_Inlines.h", str_AssetName);
|
Str inlines_file_name = StrBuilder::fmt_buf(gen_ctx.Allocator_Temp, "%S_Inlines.h", str_AssetName);
|
||||||
String path_header_file = String::fmt_buf(GlobalAllocator, path_gasa_ability_system "%S.h", str_AssetName);
|
Str path_header_file = StrBuilder::fmt_buf(gen_ctx.Allocator_Temp, path_gasa_ability_system "%S.h", str_AssetName);
|
||||||
String path_inlines_file = String::fmt_buf(GlobalAllocator, path_gasa_ability_system "%S_Inlines.h", str_AssetName);
|
Str path_inlines_file = StrBuilder::fmt_buf(gen_ctx.Allocator_Temp, path_gasa_ability_system "%S_Inlines.h", str_AssetName);
|
||||||
String path_source_file = String::fmt_buf(GlobalAllocator, path_gasa_ability_system "%S.cpp", str_AssetName);
|
Str path_source_file = StrBuilder::fmt_buf(gen_ctx.Allocator_Temp, path_gasa_ability_system "%S.cpp", str_AssetName);
|
||||||
String uht_include_file = String::fmt_buf(GlobalAllocator, "%S.generated.h", str_AssetName);
|
Str uht_include_file = StrBuilder::fmt_buf(gen_ctx.Allocator_Temp, "%S.generated.h", str_AssetName);
|
||||||
|
|
||||||
CodeType type_UAttributeSet = def_type( txt("UAttributeSet") );
|
CodeTypename type_UAttributeSet = def_type( txt("UAttributeSet") );
|
||||||
CodeComment generation_notice = def_comment(txt("Generated by GasaEditor/GasaGen/GasaGen_AttributeSets.cpp"));
|
CodeComment generation_notice = def_comment(txt("Generated by GasaEditor/GasaGen/GasaGen_AttributeSets.cpp"));
|
||||||
|
|
||||||
CodeAttributes api_attribute = def_attributes( UModule_GASA_API->Name);
|
CodeAttributes api_attribute = def_attributes( UModule_GASA_API->Name);
|
||||||
|
|
||||||
Builder header = builder_open( path_header_file );
|
Builder header = gasa_builder_open( path_header_file );
|
||||||
{
|
{
|
||||||
header.print(generation_notice);
|
header.print(generation_notice);
|
||||||
header.print(pragma_once);
|
header.print(pragma_once);
|
||||||
@ -65,7 +65,7 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
|
|
||||||
gen::CodeClass attribute_set_class = {};
|
gen::CodeClass attribute_set_class = {};
|
||||||
{
|
{
|
||||||
CodeBody body = def_body( CodeT::Class_Body );
|
CodeBody body = def_body( CT_Class_Body );
|
||||||
{
|
{
|
||||||
body.append( UHT_GENERATED_BODY);
|
body.append( UHT_GENERATED_BODY);
|
||||||
body.append( access_public );
|
body.append( access_public );
|
||||||
@ -76,15 +76,15 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
// Generate UPROPERTIES for each attribute field, organized by category
|
// Generate UPROPERTIES for each attribute field, organized by category
|
||||||
for ( TPair< FName, TArray<FAttributeSetField>>& attributes : AttributesByCategory )
|
for ( TPair< FName, TArray<FAttributeSetField>>& attributes : AttributesByCategory )
|
||||||
{
|
{
|
||||||
String category_name = to_string(attributes.Key);
|
Str category_name = to_string(attributes.Key);
|
||||||
CodeComment category_cmt = def_comment(token_fmt("category_name", (StrC)category_name, "<category_name> Attributes"));
|
CodeComment category_cmt = def_comment(token_fmt("category_name", category_name, "<category_name> Attributes"));
|
||||||
body.append(category_cmt);
|
body.append(category_cmt);
|
||||||
body.append(fmt_newline);
|
body.append(fmt_newline);
|
||||||
for (FAttributeSetField attribute : attributes.Value)
|
for (FAttributeSetField attribute : attributes.Value)
|
||||||
{
|
{
|
||||||
Code field_uproperty = code_fmt(
|
Code field_uproperty = code_fmt(
|
||||||
"category", (StrC)to_string(attribute.Category),
|
"category", to_string(attribute.Category),
|
||||||
"property", (StrC)to_string(attribute.Name),
|
"property", to_string(attribute.Name),
|
||||||
stringize(
|
stringize(
|
||||||
UPROPERTY(ReplicatedUsing = Client_OnRep_<property>, EditAnywhere, BlueprintReadWrite, Category = "Attributes|<category>")
|
UPROPERTY(ReplicatedUsing = Client_OnRep_<property>, EditAnywhere, BlueprintReadWrite, Category = "Attributes|<category>")
|
||||||
FGameplayAttributeData <property>;
|
FGameplayAttributeData <property>;
|
||||||
@ -104,7 +104,7 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
body.append(fmt_newline);
|
body.append(fmt_newline);
|
||||||
body.append(umeta_UFUNCTION);
|
body.append(umeta_UFUNCTION);
|
||||||
body.append(fmt_newline);
|
body.append(fmt_newline);
|
||||||
body.append(code_fmt("property", (StrC)to_string(attribute.Name), stringize(
|
body.append(code_fmt("property", to_string(attribute.Name), stringize(
|
||||||
void Client_OnRep_<property>(FGameplayAttributeData& Prev<property>);
|
void Client_OnRep_<property>(FGameplayAttributeData& Prev<property>);
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@ -118,8 +118,8 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
for (FAttributeSetField attribute : attributes.Value)
|
for (FAttributeSetField attribute : attributes.Value)
|
||||||
{
|
{
|
||||||
CodeFn generated_get_attribute = parse_function(token_fmt(
|
CodeFn generated_get_attribute = parse_function(token_fmt(
|
||||||
"class_name", (StrC)class_name,
|
"class_name", class_name,
|
||||||
"property", (StrC)to_string(attribute.Name),
|
"property", to_string(attribute.Name),
|
||||||
stringize(
|
stringize(
|
||||||
static FGameplayAttribute Get<property>Attribute()
|
static FGameplayAttribute Get<property>Attribute()
|
||||||
{
|
{
|
||||||
@ -135,7 +135,7 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
for ( TPair< FName, TArray<FAttributeSetField>>& attributes : AttributesByCategory )
|
for ( TPair< FName, TArray<FAttributeSetField>>& attributes : AttributesByCategory )
|
||||||
for (FAttributeSetField attribute : attributes.Value)
|
for (FAttributeSetField attribute : attributes.Value)
|
||||||
{
|
{
|
||||||
body.append(code_fmt("property", (StrC)to_string(attribute.Name),
|
body.append(code_fmt("property", to_string(attribute.Name),
|
||||||
stringize(
|
stringize(
|
||||||
FORCEINLINE float Get<property>() const
|
FORCEINLINE float Get<property>() const
|
||||||
{
|
{
|
||||||
@ -154,7 +154,7 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
for ( TPair< FName, TArray<FAttributeSetField>>& attributes : AttributesByCategory )
|
for ( TPair< FName, TArray<FAttributeSetField>>& attributes : AttributesByCategory )
|
||||||
for (FAttributeSetField attribute : attributes.Value)
|
for (FAttributeSetField attribute : attributes.Value)
|
||||||
{
|
{
|
||||||
body.append(code_fmt("property", (StrC)to_string(attribute.Name),
|
body.append(code_fmt("property", to_string(attribute.Name),
|
||||||
stringize(
|
stringize(
|
||||||
FORCEINLINE void Set<property>(float NewVal);
|
FORCEINLINE void Set<property>(float NewVal);
|
||||||
)));
|
)));
|
||||||
@ -180,10 +180,10 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
body.append(fmt_newline);
|
body.append(fmt_newline);
|
||||||
}
|
}
|
||||||
|
|
||||||
attribute_set_class = def_class( class_name, body
|
attribute_set_class = def_class( class_name, { body
|
||||||
, type_UAttributeSet, AccessSpec::Public
|
, type_UAttributeSet, AccessSpec_Public
|
||||||
, api_attribute
|
, api_attribute
|
||||||
);
|
});
|
||||||
header.print(UHT_UCLASS);
|
header.print(UHT_UCLASS);
|
||||||
header.print(attribute_set_class);
|
header.print(attribute_set_class);
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
format_file(path_header_file);
|
format_file(path_header_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
Builder inlines = builder_open( path_inlines_file );
|
Builder inlines = gasa_builder_open( path_inlines_file );
|
||||||
{
|
{
|
||||||
inlines.print(generation_notice);
|
inlines.print(generation_notice);
|
||||||
inlines.print(pragma_once);
|
inlines.print(pragma_once);
|
||||||
@ -201,7 +201,7 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
inlines.print(def_include(txt("AbilitySystemComponent.h")));
|
inlines.print(def_include(txt("AbilitySystemComponent.h")));
|
||||||
inlines.print(fmt_newline);
|
inlines.print(fmt_newline);
|
||||||
|
|
||||||
CodeBody body = def_body(ECode::Global_Body);
|
CodeBody body = def_body(CT_Global_Body);
|
||||||
{
|
{
|
||||||
body.append(def_pragma(txt("region Attribute Setters")));
|
body.append(def_pragma(txt("region Attribute Setters")));
|
||||||
{
|
{
|
||||||
@ -209,8 +209,8 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
for (FAttributeSetField attribute : attributes.Value)
|
for (FAttributeSetField attribute : attributes.Value)
|
||||||
{
|
{
|
||||||
CodeFn generated_get_attribute = parse_function(token_fmt(
|
CodeFn generated_get_attribute = parse_function(token_fmt(
|
||||||
"class_name", (StrC)class_name,
|
"class_name", class_name,
|
||||||
"property", (StrC)to_string(attribute.Name),
|
"property", to_string(attribute.Name),
|
||||||
stringize(
|
stringize(
|
||||||
FORCEINLINE void <class_name>::Set<property>(float NewVal)
|
FORCEINLINE void <class_name>::Set<property>(float NewVal)
|
||||||
{
|
{
|
||||||
@ -230,7 +230,7 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
inlines.print(fmt_newline);
|
inlines.print(fmt_newline);
|
||||||
|
|
||||||
CodeNS ns_gasa = parse_namespace(token_fmt(
|
CodeNS ns_gasa = parse_namespace(token_fmt(
|
||||||
"class_name", (StrC)class_name,
|
"class_name", class_name,
|
||||||
stringize(
|
stringize(
|
||||||
namespace Gasa
|
namespace Gasa
|
||||||
{
|
{
|
||||||
@ -247,7 +247,7 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
format_file(path_inlines_file);
|
format_file(path_inlines_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
Builder source = builder_open( path_source_file );
|
Builder source = gasa_builder_open( path_source_file );
|
||||||
{
|
{
|
||||||
source.print(generation_notice);
|
source.print(generation_notice);
|
||||||
header.print(fmt_newline);
|
header.print(fmt_newline);
|
||||||
@ -260,7 +260,7 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
source.print(def_include(txt("Networking/GasaNetLibrary.h")));
|
source.print(def_include(txt("Networking/GasaNetLibrary.h")));
|
||||||
source.print(def_include(txt("GameplayEffectExtension.h")));
|
source.print(def_include(txt("GameplayEffectExtension.h")));
|
||||||
{
|
{
|
||||||
CodeBody body = def_body(CodeT::Global_Body);
|
CodeBody body = def_body(CT_Global_Body);
|
||||||
body.append(fmt_newline);
|
body.append(fmt_newline);
|
||||||
|
|
||||||
CodeConstructor constructor_for_UGasaAttributeSet = parse_constructor(code(
|
CodeConstructor constructor_for_UGasaAttributeSet = parse_constructor(code(
|
||||||
@ -278,8 +278,8 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
for (FAttributeSetField attribute : attributes.Value)
|
for (FAttributeSetField attribute : attributes.Value)
|
||||||
{
|
{
|
||||||
CodeFn field_impl = parse_function(token_fmt(
|
CodeFn field_impl = parse_function(token_fmt(
|
||||||
"class_name", (StrC)class_name,
|
"class_name", class_name,
|
||||||
"property", (StrC)to_string(attribute.Name),
|
"property", to_string(attribute.Name),
|
||||||
"from_notice", txt("\n// From GAMEPLAYATTRIBUTE_REPNOTIFY\n"),
|
"from_notice", txt("\n// From GAMEPLAYATTRIBUTE_REPNOTIFY\n"),
|
||||||
stringize(
|
stringize(
|
||||||
void <class_name>::Client_OnRep_<property>(FGameplayAttributeData & Prev<property>)
|
void <class_name>::Client_OnRep_<property>(FGameplayAttributeData & Prev<property>)
|
||||||
@ -298,8 +298,8 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
CodeFn PostGameplayEffectExecute;
|
CodeFn PostGameplayEffectExecute;
|
||||||
CodeFn PreAttributeChange;
|
CodeFn PreAttributeChange;
|
||||||
{
|
{
|
||||||
CodeBody pre_attribute_clamps = def_body(CodeT::Function_Body);
|
CodeBody pre_attribute_clamps = def_body(CT_Function_Body);
|
||||||
CodeBody post_attribute_clamps = def_body(CodeT::Function_Body);
|
CodeBody post_attribute_clamps = def_body(CT_Function_Body);
|
||||||
|
|
||||||
// Generate field clamping ops for the pre & post functions
|
// Generate field clamping ops for the pre & post functions
|
||||||
{
|
{
|
||||||
@ -311,22 +311,22 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
for (TPair< FName, TArray<FAttributeSetField>>& attributes : AttributesByCategory)
|
for (TPair< FName, TArray<FAttributeSetField>>& attributes : AttributesByCategory)
|
||||||
for (FAttributeSetField attribute : attributes.Value)
|
for (FAttributeSetField attribute : attributes.Value)
|
||||||
{
|
{
|
||||||
String clamp_min;
|
Str clamp_min;
|
||||||
if (attribute.bUseMinAttribute)
|
if (attribute.bUseMinAttribute)
|
||||||
clamp_min = get_cached_string(token_fmt("MinName", (StrC)to_string(attribute.MinAttribute), "Get<MinName>()"));
|
clamp_min = cache_str(token_fmt("MinName", to_string(attribute.MinAttribute), "Get<MinName>()"));
|
||||||
else
|
else
|
||||||
clamp_min = String::fmt_buf(GlobalAllocator, "%f", attribute.MinValue);
|
clamp_min = StrBuilder::fmt_buf(gen_ctx.Allocator_Temp, "%f", attribute.MinValue);
|
||||||
|
|
||||||
String clamp_max;
|
Str clamp_max;
|
||||||
if (attribute.bUseMaxAttribute)
|
if (attribute.bUseMaxAttribute)
|
||||||
clamp_max = get_cached_string(token_fmt("MaxName", (StrC)to_string(attribute.MaxAttribute), "Get<MaxName>()"));
|
clamp_max = cache_str(token_fmt("MaxName", to_string(attribute.MaxAttribute), "Get<MaxName>()"));
|
||||||
else
|
else
|
||||||
clamp_max = String::fmt_buf(GlobalAllocator, "%f", attribute.MaxValue);
|
clamp_max = StrBuilder::fmt_buf(gen_ctx.Allocator_Temp, "%f", attribute.MaxValue);
|
||||||
|
|
||||||
pre_attribute_clamps.append(code_fmt(
|
pre_attribute_clamps.append(code_fmt(
|
||||||
"field", (StrC)to_string(attribute.Name),
|
"field", to_string(attribute.Name),
|
||||||
"clamp_min", (StrC)clamp_min,
|
"clamp_min", clamp_min,
|
||||||
"clamp_max", (StrC)clamp_max,
|
"clamp_max", clamp_max,
|
||||||
stringize(
|
stringize(
|
||||||
if (Attribute == Get<field>Attribute())
|
if (Attribute == Get<field>Attribute())
|
||||||
{
|
{
|
||||||
@ -335,9 +335,9 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
)));
|
)));
|
||||||
|
|
||||||
post_attribute_clamps.append(code_fmt(
|
post_attribute_clamps.append(code_fmt(
|
||||||
"field", (StrC)to_string(attribute.Name),
|
"field", to_string(attribute.Name),
|
||||||
"clamp_min", (StrC)clamp_min,
|
"clamp_min", clamp_min,
|
||||||
"clamp_max", (StrC)clamp_max,
|
"clamp_max", clamp_max,
|
||||||
stringize(
|
stringize(
|
||||||
if (Data.EvaluatedData.Attribute == Get<field>Attribute())
|
if (Data.EvaluatedData.Attribute == Get<field>Attribute())
|
||||||
{
|
{
|
||||||
@ -353,8 +353,8 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
}
|
}
|
||||||
|
|
||||||
PreAttributeChange = parse_function(token_fmt(
|
PreAttributeChange = parse_function(token_fmt(
|
||||||
"class_name", (StrC)class_name,
|
"class_name", class_name,
|
||||||
"attribute_clamps", (StrC)pre_attribute_clamps.to_string(),
|
"attribute_clamps", pre_attribute_clamps.to_strbuilder().to_str(),
|
||||||
stringize(
|
stringize(
|
||||||
void <class_name>::PreAttributeChange(FGameplayAttribute const& Attribute, float& NewValue)
|
void <class_name>::PreAttributeChange(FGameplayAttribute const& Attribute, float& NewValue)
|
||||||
{
|
{
|
||||||
@ -365,8 +365,8 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
)));
|
)));
|
||||||
|
|
||||||
PostGameplayEffectExecute = parse_function(token_fmt(
|
PostGameplayEffectExecute = parse_function(token_fmt(
|
||||||
"class_name", (StrC)class_name,
|
"class_name", class_name,
|
||||||
"attribute_clamps", (StrC)post_attribute_clamps.to_string(),
|
"attribute_clamps", post_attribute_clamps.to_strbuilder().to_str(),
|
||||||
stringize(
|
stringize(
|
||||||
void <class_name>::PostGameplayEffectExecute(FGameplayEffectModCallbackData const& Data)
|
void <class_name>::PostGameplayEffectExecute(FGameplayEffectModCallbackData const& Data)
|
||||||
{
|
{
|
||||||
@ -387,23 +387,23 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
|
|
||||||
CodeFn GetLifetimeOfReplicatedProps;
|
CodeFn GetLifetimeOfReplicatedProps;
|
||||||
{
|
{
|
||||||
CodeBody field_lifetimes = def_body(CodeT::Function_Body);
|
CodeBody field_lifetimes = def_body(CT_Function_Body);
|
||||||
field_lifetimes.append(fmt_newline);
|
field_lifetimes.append(fmt_newline);
|
||||||
field_lifetimes.append(fmt_newline);
|
field_lifetimes.append(fmt_newline);
|
||||||
for (TPair< FName, TArray<FAttributeSetField>>& attributes : AttributesByCategory)
|
for (TPair< FName, TArray<FAttributeSetField>>& attributes : AttributesByCategory)
|
||||||
for (FAttributeSetField attribute : attributes.Value)
|
for (FAttributeSetField attribute : attributes.Value)
|
||||||
{
|
{
|
||||||
field_lifetimes.append(code_fmt(
|
field_lifetimes.append(code_fmt(
|
||||||
"class_name", (StrC)class_name,
|
"class_name", class_name,
|
||||||
"property", (StrC)to_string(attribute.Name),
|
"property", to_string(attribute.Name),
|
||||||
stringize(
|
stringize(
|
||||||
DOREPLIFETIME_DEFAULT_GAS( <class_name>, <property> );
|
DOREPLIFETIME_DEFAULT_GAS( <class_name>, <property> );
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
GetLifetimeOfReplicatedProps = parse_function(token_fmt(
|
GetLifetimeOfReplicatedProps = parse_function(token_fmt(
|
||||||
"class_name", (StrC)class_name,
|
"class_name", class_name,
|
||||||
"property_lifetimes", (StrC)(field_lifetimes.to_string()),
|
"property_lifetimes", field_lifetimes.to_strbuilder().to_str(),
|
||||||
stringize(
|
stringize(
|
||||||
void <class_name>::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
|
void <class_name>::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "ChangeBPActionMenu.h"
|
#include "ChangeBPActionMenu.h"
|
||||||
#include "GasaGen_Common.h"
|
#include "GasaGen_Common.h"
|
||||||
|
|
||||||
constexpr StrC SBlueprintActionMenu_Construct_Replacement = txt(R"(
|
constexpr Str SBlueprintActionMenu_Construct_Replacement = txt(R"(
|
||||||
void SBlueprintActionMenu::Construct( const FArguments& InArgs, TSharedPtr<FBlueprintEditor> InEditor )
|
void SBlueprintActionMenu::Construct( const FArguments& InArgs, TSharedPtr<FBlueprintEditor> InEditor )
|
||||||
{
|
{
|
||||||
bActionExecuted = false;
|
bActionExecuted = false;
|
||||||
@ -244,23 +244,22 @@ void change_SBlueprintActionMenu_Construct()
|
|||||||
#define path_SBlueprintActionMenuCpp \
|
#define path_SBlueprintActionMenuCpp \
|
||||||
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Editor\Kismet\Private\SBlueprintActionMenu.cpp)"
|
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Editor\Kismet\Private\SBlueprintActionMenu.cpp)"
|
||||||
|
|
||||||
FileContents content = file_read_contents( GlobalAllocator, true, path_SBlueprintActionMenuCpp );
|
FileContents content = file_read_contents( gen_ctx.Allocator_Temp, true, path_SBlueprintActionMenuCpp );
|
||||||
CodeBody parsed_SBlueprintActionMenu = parse_global_body( StrC { content.size, (char const*)content.data });
|
CodeBody parsed_SBlueprintActionMenu = parse_global_body( Str { (char const*)content.data, content.size });
|
||||||
|
|
||||||
CodeFn signature_to_change = parse_function( code(
|
CodeFn signature_to_change = parse_function( code(
|
||||||
void SBlueprintActionMenu::Construct( const FArguments& InArgs, TSharedPtr<FBlueprintEditor> InEditor ) {}
|
void SBlueprintActionMenu::Construct( const FArguments& InArgs, TSharedPtr<FBlueprintEditor> InEditor ) {}
|
||||||
));
|
));
|
||||||
|
|
||||||
CodeBody changed_SBlueprintActionMenu = def_body(ECode::Global_Body);
|
CodeBody changed_SBlueprintActionMenu = def_body(CT_Global_Body);
|
||||||
for ( Code code : parsed_SBlueprintActionMenu )
|
for ( Code code : parsed_SBlueprintActionMenu )
|
||||||
{
|
{
|
||||||
switch ( code->Type )
|
switch ( code->Type )
|
||||||
{
|
{
|
||||||
using namespace ECode;
|
case CT_Function:
|
||||||
case Function:
|
CodeFn function_def = cast(CodeFn, code);
|
||||||
CodeFn function_def = code.cast<CodeFn>();
|
|
||||||
|
|
||||||
if ( String::are_equal(function_def->Name, signature_to_change->Name)
|
if ( str_are_equal(function_def->Name, signature_to_change->Name)
|
||||||
&& function_def->Params.is_equal(signature_to_change->Params))
|
&& function_def->Params.is_equal(signature_to_change->Params))
|
||||||
{
|
{
|
||||||
code = parse_function( SBlueprintActionMenu_Construct_Replacement );
|
code = parse_function( SBlueprintActionMenu_Construct_Replacement );
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "GasaGen_Common.h"
|
#include "GasaGen_Common.h"
|
||||||
#include "GasaEditorCommon.h"
|
#include "GasaEditorCommon.h"
|
||||||
|
|
||||||
constexpr StrC SAssetView_Construct_Replacement = txt(R"(
|
constexpr Str SAssetView_Construct_Replacement = txt(R"(
|
||||||
void SAssetView::Construct( const FArguments& InArgs )
|
void SAssetView::Construct( const FArguments& InArgs )
|
||||||
{
|
{
|
||||||
ViewCorrelationGuid = FGuid::NewGuid();
|
ViewCorrelationGuid = FGuid::NewGuid();
|
||||||
@ -391,7 +391,7 @@ void SAssetView::Construct( const FArguments& InArgs )
|
|||||||
}
|
}
|
||||||
})");
|
})");
|
||||||
|
|
||||||
constexpr StrC SAssetView_GetThumbnailScale_Replacement = txt(R"(
|
constexpr Str SAssetView_GetThumbnailScale_Replacement = txt(R"(
|
||||||
float SAssetView::GetThumbnailScale() const
|
float SAssetView::GetThumbnailScale() const
|
||||||
{
|
{
|
||||||
float BaseScale;
|
float BaseScale;
|
||||||
@ -423,7 +423,7 @@ float SAssetView::GetThumbnailScale() const
|
|||||||
return BaseScale * GetTickSpaceGeometry().Scale;
|
return BaseScale * GetTickSpaceGeometry().Scale;
|
||||||
})");
|
})");
|
||||||
|
|
||||||
constexpr StrC SPropertyMenuAssetPicker_Construct_Replacement = txt(R"(
|
constexpr Str SPropertyMenuAssetPicker_Construct_Replacement = txt(R"(
|
||||||
void SPropertyMenuAssetPicker::Construct( const FArguments& InArgs )
|
void SPropertyMenuAssetPicker::Construct( const FArguments& InArgs )
|
||||||
{
|
{
|
||||||
CurrentObject = InArgs._InitialObject;
|
CurrentObject = InArgs._InitialObject;
|
||||||
@ -595,27 +595,26 @@ void change_EditorContentList()
|
|||||||
#define path_PropertyEditorAssetConstantsHeader \
|
#define path_PropertyEditorAssetConstantsHeader \
|
||||||
R"(C:\Projects\Unreal\Surgo\UE\Engine\Source\Editor\PropertyEditor\Private\UserInterface\PropertyEditor\PropertyEditorAssetConstants.h)"
|
R"(C:\Projects\Unreal\Surgo\UE\Engine\Source\Editor\PropertyEditor\Private\UserInterface\PropertyEditor\PropertyEditorAssetConstants.h)"
|
||||||
|
|
||||||
FileContents content = file_read_contents( GlobalAllocator, true, path_PropertyEditorAssetConstantsHeader );
|
FileContents content = file_read_contents( gen_ctx.Allocator_Temp, true, path_PropertyEditorAssetConstantsHeader );
|
||||||
CodeBody parsed_PropertyEditorAssetConstantsHeader = parse_global_body( StrC { content.size, (char const*)content.data });
|
CodeBody parsed_PropertyEditorAssetConstantsHeader = parse_global_body( Str { (char const*)content.data, content.size });
|
||||||
|
|
||||||
CodeBody changed_PropertyEditorAssetConstantsHeader = def_body(ECode::Global_Body);
|
CodeBody changed_PropertyEditorAssetConstantsHeader = def_body(CT_Global_Body);
|
||||||
for ( Code code : parsed_PropertyEditorAssetConstantsHeader )
|
for ( Code code : parsed_PropertyEditorAssetConstantsHeader )
|
||||||
{
|
{
|
||||||
switch ( code->Type )
|
switch ( code->Type )
|
||||||
{
|
{
|
||||||
using namespace ECode;
|
case CT_Namespace:
|
||||||
case Namespace:
|
CodeNS ns = cast(CodeNS, code);
|
||||||
CodeNS ns = code.cast<CodeNS>();
|
|
||||||
for ( Code ns_code : ns->Body )
|
for ( Code ns_code : ns->Body )
|
||||||
{
|
{
|
||||||
switch ( ns_code->Type )
|
switch ( ns_code->Type )
|
||||||
{
|
{
|
||||||
case Variable:
|
case CT_Variable:
|
||||||
CodeVar var = ns_code.cast<CodeVar>();
|
CodeVar var = cast(CodeVar, ns_code);
|
||||||
if ( var->Name.starts_with(txt("ContentBrowserWindowSize")) )
|
if ( var->Name.starts_with(txt("ContentBrowserWindowSize")) )
|
||||||
{
|
{
|
||||||
// Swap value with new value
|
// Swap value with new value
|
||||||
var->Value->Content = get_cached_string(txt("300.0f, 600.0f"));
|
var->Value->Content = cache_str(txt("300.0f, 600.0f"));
|
||||||
Gasa::LogEditor("Swapped: " + to_fstring(var->Name));
|
Gasa::LogEditor("Swapped: " + to_fstring(var->Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -639,8 +638,8 @@ void change_EditorContentList()
|
|||||||
#define path_SAssetView \
|
#define path_SAssetView \
|
||||||
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Editor\ContentBrowser\Private\SAssetView.cpp)"
|
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Editor\ContentBrowser\Private\SAssetView.cpp)"
|
||||||
|
|
||||||
FileContents content = file_read_contents( GlobalAllocator, true, path_SAssetView );
|
FileContents content = file_read_contents( gen_ctx.Allocator_Temp, true, path_SAssetView );
|
||||||
CodeBody parsed_SAssetViewCpp = parse_global_body( StrC { content.size, (char const*)content.data });
|
CodeBody parsed_SAssetViewCpp = parse_global_body( Str { (char const*)content.data, content.size });
|
||||||
|
|
||||||
CodeFn signature_Construct = parse_function( code(
|
CodeFn signature_Construct = parse_function( code(
|
||||||
void SAssetView::Construct( const FArguments& InArgs ) {}
|
void SAssetView::Construct( const FArguments& InArgs ) {}
|
||||||
@ -649,24 +648,23 @@ void change_EditorContentList()
|
|||||||
float SAssetView::GetThumbnailScale() const {}
|
float SAssetView::GetThumbnailScale() const {}
|
||||||
));
|
));
|
||||||
|
|
||||||
CodeBody changed_SAssetViewCpp = def_body(ECode::Global_Body);
|
CodeBody changed_SAssetViewCpp = def_body(CT_Global_Body);
|
||||||
for ( Code code : parsed_SAssetViewCpp )
|
for ( Code code : parsed_SAssetViewCpp )
|
||||||
{
|
{
|
||||||
switch ( code->Type )
|
switch ( code->Type )
|
||||||
{
|
{
|
||||||
using namespace ECode;
|
case CT_Function:
|
||||||
case Function:
|
|
||||||
{
|
{
|
||||||
CodeFn function_def = code.cast<CodeFn>();
|
CodeFn function_def = cast(CodeFn, code);
|
||||||
|
|
||||||
if ( String::are_equal(function_def->Name, signature_Construct->Name)
|
if ( str_are_equal(function_def->Name, signature_Construct->Name)
|
||||||
&& function_def->Params.is_equal(signature_Construct->Params))
|
&& function_def->Params && function_def->Params.is_equal(signature_Construct->Params))
|
||||||
{
|
{
|
||||||
code = parse_function( SAssetView_Construct_Replacement );
|
code = parse_function( SAssetView_Construct_Replacement );
|
||||||
Gasa::LogEditor("Swapped: " + to_fstring(function_def->Name));
|
Gasa::LogEditor("Swapped: " + to_fstring(function_def->Name));
|
||||||
}
|
}
|
||||||
else if ( String::are_equal(function_def->Name, signature_GetThumbnailScale->Name)
|
else if ( str_are_equal(function_def->Name, signature_GetThumbnailScale->Name)
|
||||||
&& function_def->Params.is_equal(signature_GetThumbnailScale->Params))
|
&& function_def->Params && function_def->Params.is_equal(signature_GetThumbnailScale->Params))
|
||||||
{
|
{
|
||||||
code = parse_function( SAssetView_GetThumbnailScale_Replacement );
|
code = parse_function( SAssetView_GetThumbnailScale_Replacement );
|
||||||
Gasa::LogEditor("Swapped: " + to_fstring(function_def->Name));
|
Gasa::LogEditor("Swapped: " + to_fstring(function_def->Name));
|
||||||
@ -689,24 +687,23 @@ void change_EditorContentList()
|
|||||||
#define path_SPropertyMenuAssetPicker \
|
#define path_SPropertyMenuAssetPicker \
|
||||||
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Editor\PropertyEditor\Private\UserInterface\PropertyEditor\SPropertyMenuAssetPicker.cpp)"
|
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Editor\PropertyEditor\Private\UserInterface\PropertyEditor\SPropertyMenuAssetPicker.cpp)"
|
||||||
|
|
||||||
FileContents content = file_read_contents( GlobalAllocator, true, path_SPropertyMenuAssetPicker );
|
FileContents content = file_read_contents( gen_ctx.Allocator_Temp, true, path_SPropertyMenuAssetPicker );
|
||||||
CodeBody parsed = parse_global_body( StrC { content.size, (char const*)content.data });
|
CodeBody parsed = parse_global_body( Str { (char const*)content.data, content.size });
|
||||||
|
|
||||||
CodeFn signature = parse_function( code(
|
CodeFn signature = parse_function( code(
|
||||||
void SPropertyMenuAssetPicker::Construct( const FArguments& InArgs ) {}
|
void SPropertyMenuAssetPicker::Construct( const FArguments& InArgs ) {}
|
||||||
));
|
));
|
||||||
|
|
||||||
CodeBody changed = def_body(ECode::Global_Body);
|
CodeBody changed = def_body(CT_Global_Body);
|
||||||
for ( Code code : parsed )
|
for ( Code code : parsed )
|
||||||
{
|
{
|
||||||
switch ( code->Type )
|
switch ( code->Type )
|
||||||
{
|
{
|
||||||
using namespace ECode;
|
case CT_Function:
|
||||||
case Function:
|
|
||||||
{
|
{
|
||||||
CodeFn function_def = code.cast<CodeFn>();
|
CodeFn function_def = cast(CodeFn, code);
|
||||||
|
|
||||||
if ( String::are_equal(function_def->Name, signature->Name)
|
if ( str_are_equal(function_def->Name, signature->Name)
|
||||||
&& function_def->Params.is_equal(signature->Params))
|
&& function_def->Params.is_equal(signature->Params))
|
||||||
{
|
{
|
||||||
code = parse_function( SPropertyMenuAssetPicker_Construct_Replacement );
|
code = parse_function( SPropertyMenuAssetPicker_Construct_Replacement );
|
||||||
|
@ -8,38 +8,38 @@
|
|||||||
|
|
||||||
void generate_DevOptionsCache()
|
void generate_DevOptionsCache()
|
||||||
{
|
{
|
||||||
Array<CodeVar> GasaDevOptions_UPROPERTIES = Array<CodeVar>::init(GlobalAllocator);
|
Array<CodeVar> GasaDevOptions_UPROPERTIES = Array<CodeVar>::init(gen_ctx.Allocator_Temp);
|
||||||
{
|
{
|
||||||
CodeBody header_GasaDevOptions = parse_file( path_module_gasa "GasaDevOptions.h" );
|
CodeBody header_GasaDevOptions = parse_file( path_module_gasa "GasaDevOptions.h" );
|
||||||
CodeClass UGasaDevOptions = NoCode;
|
CodeClass UGasaDevOptions = NullCode;
|
||||||
for (Code entry : header_GasaDevOptions)
|
for (Code entry : header_GasaDevOptions)
|
||||||
{
|
{
|
||||||
if ( entry->Type == ECode::Class && entry->Name.starts_with( txt("UGasaDevOptions")) )
|
if ( entry->Type == CT_Class && entry->Name.starts_with( txt("UGasaDevOptions")) )
|
||||||
{
|
{
|
||||||
UGasaDevOptions = entry.cast<CodeClass>();
|
UGasaDevOptions = cast(CodeClass, entry);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Code member = UGasaDevOptions->Body.begin(); member != UGasaDevOptions->Body.end(); ++ member)
|
for (Code member = UGasaDevOptions->Body.begin(); member != UGasaDevOptions->Body.end(); ++ member)
|
||||||
{
|
{
|
||||||
if ( member->Type == ECode::Untyped && member->Name.starts_with(str_UPROPERTY) )
|
if ( member->Type == CT_Untyped && member->Name.starts_with(str_UPROPERTY) )
|
||||||
++ member;
|
++ member;
|
||||||
if ( member->Type == ECode::Variable
|
if ( member->Type == CT_Variable
|
||||||
&& ( member->ValueType->Name.starts_with( txt("TArray< TSoftObjectPtr"))
|
&& ( member->ValueType->Name.starts_with( txt("TArray< TSoftObjectPtr"))
|
||||||
|| member->ValueType->Name.starts_with( txt("TSoftClassPtr"))
|
|| member->ValueType->Name.starts_with( txt("TSoftClassPtr"))
|
||||||
|| member->ValueType->Name.starts_with( txt("TSoftObjectPtr")) )
|
|| member->ValueType->Name.starts_with( txt("TSoftObjectPtr")) )
|
||||||
)
|
)
|
||||||
GasaDevOptions_UPROPERTIES.append(member.cast<CodeVar>());
|
GasaDevOptions_UPROPERTIES.append(cast(CodeVar, member));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeComment generation_notice = def_comment(txt("Generated by GasaGen/GasaGen_DevOptionsCache.cpp"));
|
CodeComment generation_notice = def_comment(txt("Generated by GasaGen/GasaGen_DevOptionsCache.cpp"));
|
||||||
|
|
||||||
CodeType t_UClassPtr = parse_type(code(UClass*));
|
CodeTypename t_UClassPtr = parse_type(code(UClass*));
|
||||||
CodeType t_UObjectPtr = parse_type(code(UObject*));
|
CodeTypename t_UObjectPtr = parse_type(code(UObject*));
|
||||||
CodeType t_Array_UObjectPtr = parse_type(code(TArray< UObject* >));
|
CodeTypename t_Array_UObjectPtr = parse_type(code(TArray< UObject* >));
|
||||||
|
|
||||||
Builder header = builder_open( path_module_gasa "GasaDevOptionsCache.h" );
|
Builder header = gasa_builder_open( path_module_gasa "GasaDevOptionsCache.h" );
|
||||||
{
|
{
|
||||||
header.print( generation_notice );
|
header.print( generation_notice );
|
||||||
header.print( pragma_once );
|
header.print( pragma_once );
|
||||||
@ -50,7 +50,7 @@ void generate_DevOptionsCache()
|
|||||||
header.print( UHT_USTRUCT );
|
header.print( UHT_USTRUCT );
|
||||||
CodeStruct FGasaDevOptionsCache;
|
CodeStruct FGasaDevOptionsCache;
|
||||||
{
|
{
|
||||||
CodeBody body = def_body(ECode::Struct_Body);
|
CodeBody body = def_body(CT_Struct_Body);
|
||||||
{
|
{
|
||||||
body.append(UHT_GENERATED_BODY);
|
body.append(UHT_GENERATED_BODY);
|
||||||
body.append(fmt_newline);
|
body.append(fmt_newline);
|
||||||
@ -72,7 +72,7 @@ void generate_DevOptionsCache()
|
|||||||
body.append(fmt_newline);
|
body.append(fmt_newline);
|
||||||
body.append( parse_function(code( void CachedDevOptions(); )));
|
body.append( parse_function(code( void CachedDevOptions(); )));
|
||||||
}
|
}
|
||||||
FGasaDevOptionsCache = parse_struct( token_fmt( "body", (StrC)body.to_string(), stringize(
|
FGasaDevOptionsCache = parse_struct( token_fmt( "body", body.to_strbuilder().to_str(), stringize(
|
||||||
struct GASA_API FGasaDevOptionsCache {
|
struct GASA_API FGasaDevOptionsCache {
|
||||||
<body>
|
<body>
|
||||||
};
|
};
|
||||||
@ -84,15 +84,15 @@ void generate_DevOptionsCache()
|
|||||||
format_file( path_module_gasa "GasaDevOptionsCache.h" );
|
format_file( path_module_gasa "GasaDevOptionsCache.h" );
|
||||||
}
|
}
|
||||||
|
|
||||||
Builder source = builder_open( path_module_gasa "GasaDevOptionsCache.cpp" );
|
Builder source = gasa_builder_open( path_module_gasa "GasaDevOptionsCache.cpp" );
|
||||||
{
|
{
|
||||||
Array<CodeInclude> GasaDevOptions_Includes = Array<CodeInclude>::init(GlobalAllocator);
|
Array<CodeInclude> GasaDevOptions_Includes = Array<CodeInclude>::init(gen_ctx.Allocator_Temp);
|
||||||
{
|
{
|
||||||
CodeBody source_GasaDevOptions = parse_file( path_module_gasa "GasaDevOptions.cpp");
|
CodeBody source_GasaDevOptions = parse_file( path_module_gasa "GasaDevOptions.cpp");
|
||||||
for ( Code entry : source_GasaDevOptions )
|
for ( Code entry : source_GasaDevOptions )
|
||||||
{
|
{
|
||||||
if ( entry->Type == ECode::Preprocess_Include )
|
if ( entry->Type == CT_Preprocess_Include )
|
||||||
GasaDevOptions_Includes.append( entry.cast<CodeInclude>() );
|
GasaDevOptions_Includes.append( cast(CodeInclude, entry));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,17 +105,17 @@ void generate_DevOptionsCache()
|
|||||||
source.print( parse_using(code( using namespace Gasa; )));
|
source.print( parse_using(code( using namespace Gasa; )));
|
||||||
source.print(fmt_newline);
|
source.print(fmt_newline);
|
||||||
|
|
||||||
CodeBody cached_property_assignments = def_body(ECode::Function_Body);
|
CodeBody cached_property_assignments = def_body(CT_Function_Body);
|
||||||
{
|
{
|
||||||
cached_property_assignments.append(fmt_newline);
|
cached_property_assignments.append(fmt_newline);
|
||||||
cached_property_assignments.append(fmt_newline);
|
cached_property_assignments.append(fmt_newline);
|
||||||
for (CodeVar var : GasaDevOptions_UPROPERTIES)
|
for (CodeVar var : GasaDevOptions_UPROPERTIES)
|
||||||
{
|
{
|
||||||
if ( var->ValueType.to_string().starts_with(txt("TArray")) )
|
if ( var->ValueType->Name.starts_with(txt("TArray")) )
|
||||||
{
|
{
|
||||||
#pragma push_macro("TEXT")
|
#pragma push_macro("TEXT")
|
||||||
#undef TEXT
|
#undef TEXT
|
||||||
Code assignment = code_fmt( "property_array", (StrC)var->Name, stringize(
|
Code assignment = code_fmt( "property_array", var->Name, stringize(
|
||||||
for ( auto& entry : DevOpts-> <property_array> )
|
for ( auto& entry : DevOpts-> <property_array> )
|
||||||
{
|
{
|
||||||
<property_array>.Push( entry.LoadSynchronous() );
|
<property_array>.Push( entry.LoadSynchronous() );
|
||||||
@ -132,7 +132,7 @@ void generate_DevOptionsCache()
|
|||||||
|
|
||||||
#pragma push_macro("TEXT")
|
#pragma push_macro("TEXT")
|
||||||
#undef TEXT
|
#undef TEXT
|
||||||
Code assignment = code_fmt( "property", (StrC)var->Name, stringize(
|
Code assignment = code_fmt( "property", var->Name, stringize(
|
||||||
<property> = DevOpts-> <property>.LoadSynchronous();
|
<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++"));
|
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++"));
|
||||||
));
|
));
|
||||||
@ -144,7 +144,7 @@ void generate_DevOptionsCache()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CodeFn CachedDevOptions = parse_function( token_fmt(
|
CodeFn CachedDevOptions = parse_function( token_fmt(
|
||||||
"cached_property_assignments", (StrC)cached_property_assignments.to_string(),
|
"cached_property_assignments", cached_property_assignments.to_strbuilder().to_str(),
|
||||||
stringize(
|
stringize(
|
||||||
void FGasaDevOptionsCache::CachedDevOptions()
|
void FGasaDevOptionsCache::CachedDevOptions()
|
||||||
{
|
{
|
||||||
@ -163,4 +163,3 @@ void generate_DevOptionsCache()
|
|||||||
|
|
||||||
#pragma pop_macro("ensureMsgf")
|
#pragma pop_macro("ensureMsgf")
|
||||||
#pragma pop_macro("GASA_API")
|
#pragma pop_macro("GASA_API")
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
#define LOCTEXT_NAMESPACE "GasaEditor"
|
#define LOCTEXT_NAMESPACE "GasaEditor"
|
||||||
|
|
||||||
global String Project_Path;
|
global Str Project_Path;
|
||||||
global String Root_Path;
|
global Str Root_Path;
|
||||||
|
|
||||||
global Code UHT_GENERATED_BODY;
|
global Code UHT_GENERATED_BODY;
|
||||||
global Code UHT_UCLASS;
|
global Code UHT_UCLASS;
|
||||||
@ -19,6 +19,8 @@ global Code UHT_UPROPERTY;
|
|||||||
global Code UHT_USTRUCT;
|
global Code UHT_USTRUCT;
|
||||||
global Code UModule_GASA_API;
|
global Code UModule_GASA_API;
|
||||||
|
|
||||||
|
global Context gen_ctx = {};
|
||||||
|
|
||||||
void Execute_GasaModule_Codegen()
|
void Execute_GasaModule_Codegen()
|
||||||
{
|
{
|
||||||
FScopedSlowTask SlowTask(100.0f, LOCTEXT("RunningGasaGen", "Running GasaGen..."));
|
FScopedSlowTask SlowTask(100.0f, LOCTEXT("RunningGasaGen", "Running GasaGen..."));
|
||||||
@ -28,7 +30,13 @@ void Execute_GasaModule_Codegen()
|
|||||||
{
|
{
|
||||||
Gasa::LogEditor("Executing: Gasa Module code generation.");
|
Gasa::LogEditor("Executing: Gasa Module code generation.");
|
||||||
|
|
||||||
gen::init();
|
if (gen_ctx.Allocator_Temp.Proc) {
|
||||||
|
gen::reset(& gen_ctx);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gen::init( & gen_ctx);
|
||||||
|
}
|
||||||
|
|
||||||
FString ue_project_path = FPaths::ConvertRelativePathToFull(FPaths::ProjectDir());
|
FString ue_project_path = FPaths::ConvertRelativePathToFull(FPaths::ProjectDir());
|
||||||
FPaths::NormalizeDirectoryName(ue_project_path);
|
FPaths::NormalizeDirectoryName(ue_project_path);
|
||||||
@ -38,8 +46,8 @@ void Execute_GasaModule_Codegen()
|
|||||||
FPaths::NormalizeDirectoryName(ue_root_path);
|
FPaths::NormalizeDirectoryName(ue_root_path);
|
||||||
char const* ue_ansi_rooot_path = TCHAR_TO_ANSI(*ue_project_path);
|
char const* ue_ansi_rooot_path = TCHAR_TO_ANSI(*ue_project_path);
|
||||||
|
|
||||||
Project_Path = String::make_length(GlobalAllocator, ue_ansi_project_path, ue_project_path.Len());
|
Project_Path = StrBuilder::make_length(gen_ctx.Allocator_Temp, ue_ansi_project_path, ue_project_path.Len());
|
||||||
Root_Path = String::make_length(GlobalAllocator, ue_ansi_rooot_path, ue_root_path.Len());
|
Root_Path = StrBuilder::make_length(gen_ctx.Allocator_Temp, ue_ansi_rooot_path, ue_root_path.Len());
|
||||||
|
|
||||||
// Initialize Globals
|
// Initialize Globals
|
||||||
{
|
{
|
||||||
@ -66,62 +74,70 @@ void Execute_GasaModule_Codegen()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Populate Defines
|
// Populate Defines
|
||||||
{
|
register_macros( args(
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_CLASS));
|
(Macro { str_DECLARE_CLASS, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_DELEGATE_RetVal_OneParam));
|
(Macro { str_DECLARE_DELEGATE_RetVal_OneParam, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_DELEGATE_RetVal_ThreeParams));
|
(Macro { str_DECLARE_DELEGATE_RetVal_ThreeParams, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_DELEGATE_SixParams));
|
(Macro { str_DECLARE_DELEGATE_SixParams, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam));
|
(Macro { str_DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams));
|
(Macro { str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams));
|
(Macro { str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams));
|
(Macro { str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam));
|
(Macro { str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams));
|
(Macro { str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams));
|
(Macro { str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_EVENT_ThreeParams));
|
(Macro { str_DECLARE_EVENT_ThreeParams, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_EVENT_TwoParams));
|
(Macro { str_DECLARE_EVENT_TwoParams, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_FUNCTION));
|
(Macro { str_DECLARE_FUNCTION, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_LOG_CATEGORY_EXTERN));
|
(Macro { str_DECLARE_LOG_CATEGORY_EXTERN, MT_Statement, MF_Functional | MF_Allow_As_Definition }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_MULTICAST_DELEGATE_OneParam));
|
(Macro { str_DECLARE_MULTICAST_DELEGATE_OneParam, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_MULTICAST_DELEGATE_ThreeParams));
|
(Macro { str_DECLARE_MULTICAST_DELEGATE_ThreeParams, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_MULTICAST_DELEGATE_TwoParams));
|
(Macro { str_DECLARE_MULTICAST_DELEGATE_TwoParams, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_TS_MULTICAST_DELEGATE_OneParam));
|
(Macro { str_DECLARE_TS_MULTICAST_DELEGATE_OneParam, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_TS_MULTICAST_DELEGATE_TwoParams));
|
(Macro { str_DECLARE_TS_MULTICAST_DELEGATE_TwoParams, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DECLARE_TS_MULTICAST_DELEGATE_ThreeParams));
|
(Macro { str_DECLARE_TS_MULTICAST_DELEGATE_ThreeParams, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DEFINE_ACTORDESC_TYPE));
|
(Macro { str_DEFINE_ACTORDESC_TYPE, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL));
|
(Macro { str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_ENUM_CLASS_FLAGS));
|
(Macro { str_ENUM_CLASS_FLAGS, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_FORCEINLINE_DEBUGGABLE));
|
(Macro { str_GENERATED_BODY, MT_Statement, MF_Functional }),
|
||||||
// PreprocessorDefines.append( get_cached_string(str_FORCEINLINE));
|
(Macro { str_GENERATED_UCLASS_BODY, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_GENERATED_BODY));
|
(Macro { str_GENERATED_USTRUCT_BODY, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_GENERATED_UCLASS_BODY));
|
(Macro { str_PRAGMA_DISABLE_DEPRECATION_WARNINGS, MT_Statement, MF_Null | MF_Allow_As_Attribute }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_GENERATED_USTRUCT_BODY));
|
(Macro { str_PRAGMA_ENABLE_DEPRECATION_WARNINGS, MT_Statement, MF_Null | MF_Allow_As_Attribute }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_PRAGMA_DISABLE_DEPRECATION_WARNINGS));
|
(Macro { str_PROPERTY_BINDING_IMPLEMENTATION, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_PRAGMA_ENABLE_DEPRECATION_WARNINGS));
|
(Macro { str_RESULT_DECL, MT_Expression, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_PROPERTY_BINDING_IMPLEMENTATION));
|
(Macro { str_SLATE_BEGIN_ARGS, MT_Statement, MF_Functional | MF_Expects_Body }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_RESULT_DECL));
|
(Macro { str_SLATE_END_ARGS, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_SLATE_BEGIN_ARGS));
|
(Macro { str_TEXT, MT_Expression, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_SLATE_END_ARGS));
|
(Macro { str_UCLASS, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_TEXT));
|
(Macro { str_UENUM, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_UCLASS));
|
(Macro { str_UFUNCTION, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_UENUM));
|
(Macro { str_UMETA, MT_Expression, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_UFUNCTION));
|
(Macro { str_UPARAM, MT_Expression, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_UMETA));
|
(Macro { str_UPROPERTY, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_UPARAM));
|
(Macro { str_USTRUCT, MT_Statement, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_UPROPERTY));
|
(Macro { str_UE_REQUIRES, MT_Expression, MF_Functional }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_USTRUCT));
|
(Macro { str_UE_DEPRECATED, MT_Statement, MF_Functional | MF_Allow_As_Attribute }),
|
||||||
PreprocessorDefines.append(get_cached_string(str_UE_REQUIRES));
|
(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 }),
|
||||||
|
(Macro { str_LOCTEXT_NAMESPACE, MT_Statement, MF_Null })
|
||||||
|
));
|
||||||
|
|
||||||
// generate_AttributeSets();
|
// register_macros()
|
||||||
//generate_DevOptionsCache();
|
|
||||||
//generate_HostWidgetController();
|
generate_AttributeSets();
|
||||||
|
generate_DevOptionsCache();
|
||||||
|
// generate_HostWidgetController();
|
||||||
change_SBlueprintActionMenu_Construct();
|
change_SBlueprintActionMenu_Construct();
|
||||||
change_EditorContentList();
|
change_EditorContentList();
|
||||||
|
|
||||||
gen::deinit();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef LOCTEXT_NAMESPACE
|
#undef LOCTEXT_NAMESPACE
|
||||||
|
|
||||||
|
@ -17,54 +17,65 @@ using namespace gen;
|
|||||||
#define path_gasa_game path_module_gasa "Game/"
|
#define path_gasa_game path_module_gasa "Game/"
|
||||||
#define path_gasa_ui path_module_gasa "UI/"
|
#define path_gasa_ui path_module_gasa "UI/"
|
||||||
|
|
||||||
constexpr StrC str_DECLARE_CLASS = txt("DECLARE_CLASS(");
|
constexpr Str str_DECLARE_CLASS = txt("DECLARE_CLASS");
|
||||||
constexpr StrC str_DECLARE_DELEGATE_RetVal_OneParam = txt("DECLARE_DELEGATE_RetVal_OneParam(");
|
constexpr Str str_DECLARE_DELEGATE_RetVal_OneParam = txt("DECLARE_DELEGATE_RetVal_OneParam");
|
||||||
constexpr StrC str_DECLARE_DELEGATE_RetVal_ThreeParams = txt("DECLARE_DELEGATE_RetVal_ThreeParams(");
|
constexpr Str str_DECLARE_DELEGATE_RetVal_ThreeParams = txt("DECLARE_DELEGATE_RetVal_ThreeParams");
|
||||||
constexpr StrC str_DECLARE_DELEGATE_SixParams = txt("DECLARE_DELEGATE_SixParams(");
|
constexpr Str str_DECLARE_DELEGATE_SixParams = txt("DECLARE_DELEGATE_SixParams");
|
||||||
constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam = txt("DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(");
|
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam = txt("DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam");
|
||||||
constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams(");
|
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams");
|
||||||
constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams(");
|
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams");
|
||||||
constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams(");
|
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams");
|
||||||
constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(");
|
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam");
|
||||||
constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams(");
|
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams");
|
||||||
constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams(");
|
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams");
|
||||||
constexpr StrC str_DECLARE_EVENT_ThreeParams = txt("DECLARE_EVENT_ThreeParams(");
|
constexpr Str str_DECLARE_EVENT_ThreeParams = txt("DECLARE_EVENT_ThreeParams");
|
||||||
constexpr StrC str_DECLARE_EVENT_TwoParams = txt("DECLARE_EVENT_TwoParams(");
|
constexpr Str str_DECLARE_EVENT_TwoParams = txt("DECLARE_EVENT_TwoParams");
|
||||||
constexpr StrC str_DECLARE_FUNCTION = txt("DECLARE_FUNCTION(");
|
constexpr Str str_DECLARE_FUNCTION = txt("DECLARE_FUNCTION");
|
||||||
constexpr StrC str_DECLARE_LOG_CATEGORY_EXTERN = txt("DECLARE_LOG_CATEGORY_EXTERN(");
|
constexpr Str str_DECLARE_LOG_CATEGORY_EXTERN = txt("DECLARE_LOG_CATEGORY_EXTERN");
|
||||||
constexpr StrC str_DECLARE_MULTICAST_DELEGATE_OneParam = txt("DECLARE_MULTICAST_DELEGATE_OneParam(");
|
constexpr Str str_DECLARE_MULTICAST_DELEGATE_OneParam = txt("DECLARE_MULTICAST_DELEGATE_OneParam");
|
||||||
constexpr StrC str_DECLARE_MULTICAST_DELEGATE_ThreeParams = txt("DECLARE_MULTICAST_DELEGATE_ThreeParams(");
|
constexpr Str str_DECLARE_MULTICAST_DELEGATE_ThreeParams = txt("DECLARE_MULTICAST_DELEGATE_ThreeParams");
|
||||||
constexpr StrC str_DECLARE_MULTICAST_DELEGATE_TwoParams = txt("DECLARE_MULTICAST_DELEGATE_TwoParams(");
|
constexpr Str str_DECLARE_MULTICAST_DELEGATE_TwoParams = txt("DECLARE_MULTICAST_DELEGATE_TwoParams");
|
||||||
constexpr StrC str_DECLARE_TS_MULTICAST_DELEGATE_OneParam = txt("DECLARE_TS_MULTICAST_DELEGATE_OneParam(");
|
constexpr Str str_DECLARE_TS_MULTICAST_DELEGATE_OneParam = txt("DECLARE_TS_MULTICAST_DELEGATE_OneParam");
|
||||||
constexpr StrC str_DECLARE_TS_MULTICAST_DELEGATE_TwoParams = txt("DECLARE_TS_MULTICAST_DELEGATE_TwoParams(");
|
constexpr Str str_DECLARE_TS_MULTICAST_DELEGATE_TwoParams = txt("DECLARE_TS_MULTICAST_DELEGATE_TwoParams");
|
||||||
constexpr StrC str_DECLARE_TS_MULTICAST_DELEGATE_ThreeParams = txt("DECLARE_TS_MULTICAST_DELEGATE_ThreeParams(");
|
constexpr Str str_DECLARE_TS_MULTICAST_DELEGATE_ThreeParams = txt("DECLARE_TS_MULTICAST_DELEGATE_ThreeParams");
|
||||||
constexpr StrC str_DEFINE_ACTORDESC_TYPE = txt("DEFINE_ACTORDESC_TYPE(");
|
constexpr Str 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 Str 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 Str str_ENUM_CLASS_FLAGS = txt("ENUM_CLASS_FLAGS");
|
||||||
// constexpr StrC str_FORCEINLINE = txt("FORCEINLINE");
|
constexpr Str str_GENERATED_BODY = txt("GENERATED_BODY");
|
||||||
constexpr StrC str_FORCEINLINE_DEBUGGABLE = txt("FORCEINLINE_DEBUGGABLE");
|
constexpr Str str_GENERATED_UCLASS_BODY = txt("GENERATED_UCLASS_BODY");
|
||||||
constexpr StrC str_GENERATED_BODY = txt("GENERATED_BODY(");
|
constexpr Str str_GENERATED_USTRUCT_BODY = txt("GENERATED_USTRUCT_BODY");
|
||||||
constexpr StrC str_GENERATED_UCLASS_BODY = txt("GENERATED_UCLASS_BODY(");
|
constexpr Str str_PRAGMA_DISABLE_DEPRECATION_WARNINGS = txt("PRAGMA_DISABLE_DEPRECATION_WARNINGS");
|
||||||
constexpr StrC str_GENERATED_USTRUCT_BODY = txt("GENERATED_USTRUCT_BODY(");
|
constexpr Str str_PRAGMA_ENABLE_DEPRECATION_WARNINGS = txt("PRAGMA_ENABLE_DEPRECATION_WARNINGS");
|
||||||
constexpr StrC str_PRAGMA_DISABLE_DEPRECATION_WARNINGS = txt("PRAGMA_DISABLE_DEPRECATION_WARNINGS");
|
constexpr Str str_PROPERTY_BINDING_IMPLEMENTATION = txt("PROPERTY_BINDING_IMPLEMENTATION");
|
||||||
constexpr StrC str_PRAGMA_ENABLE_DEPRECATION_WARNINGS = txt("PRAGMA_ENABLE_DEPRECATION_WARNINGS");
|
constexpr Str str_RESULT_DECL = txt("RESULT_DECL");
|
||||||
constexpr StrC str_PROPERTY_BINDING_IMPLEMENTATION = txt("PROPERTY_BINDING_IMPLEMENTATION(");
|
constexpr Str str_SLATE_BEGIN_ARGS = txt("SLATE_BEGIN_ARGS");
|
||||||
constexpr StrC str_RESULT_DECL = txt("RESULT_DECL");
|
constexpr Str str_SLATE_END_ARGS = txt("SLATE_END_ARGS");
|
||||||
constexpr StrC str_SLATE_BEGIN_ARGS = txt("SLATE_BEGIN_ARGS(");
|
constexpr Str str_TEXT = txt("TEXT");
|
||||||
constexpr StrC str_SLATE_END_ARGS = txt("SLATE_END_ARGS(");
|
constexpr Str str_UCLASS = txt("UCLASS");
|
||||||
constexpr StrC str_TEXT = txt("TEXT(");
|
constexpr Str str_UENUM = txt("UENUM");
|
||||||
constexpr StrC str_UCLASS = txt("UCLASS(");
|
constexpr Str str_UFUNCTION = txt("UFUNCTION");
|
||||||
constexpr StrC str_UENUM = txt("UENUM(");
|
constexpr Str str_UMETA = txt("UMETA");
|
||||||
constexpr StrC str_UFUNCTION = txt("UFUNCTION(");
|
constexpr Str str_UPARAM = txt("UPARAM");
|
||||||
constexpr StrC str_UMETA = txt("UMETA(");
|
constexpr Str str_UPROPERTY = txt("UPROPERTY");
|
||||||
constexpr StrC str_UPARAM = txt("UPARAM(");
|
constexpr Str str_USTRUCT = txt("USTRUCT");
|
||||||
constexpr StrC str_UPROPERTY = txt("UPROPERTY(");
|
constexpr Str str_UE_REQUIRES = txt("UE_REQUIRES");
|
||||||
constexpr StrC str_USTRUCT = txt("USTRUCT(");
|
constexpr Str str_UE_DEPRECATED = txt("UE_DEPRECATED");
|
||||||
constexpr StrC str_UE_REQUIRES = txt("UE_REQUIRES(");
|
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_LOCTEXT_NAMESPACE = txt("LOCTEXT_NAMESPACE");
|
||||||
|
|
||||||
|
constexpr Str str_GASA_API = txt("GASA_API");
|
||||||
|
|
||||||
#pragma region Globals
|
#pragma region Globals
|
||||||
extern String Project_Path;
|
extern Str Project_Path;
|
||||||
extern String Root_Path;
|
extern Str Root_Path;
|
||||||
|
|
||||||
// These Code objects are created before anything else after gencpp does its initializatioon
|
// These Code objects are created before anything else after gencpp does its initializatioon
|
||||||
extern Code UHT_GENERATED_BODY;
|
extern Code UHT_GENERATED_BODY;
|
||||||
@ -72,24 +83,26 @@ extern Code UHT_UCLASS;
|
|||||||
extern Code UHT_UPROPERTY;
|
extern Code UHT_UPROPERTY;
|
||||||
extern Code UHT_USTRUCT;
|
extern Code UHT_USTRUCT;
|
||||||
extern Code UModule_GASA_API;
|
extern Code UModule_GASA_API;
|
||||||
|
|
||||||
|
extern Context gen_ctx;
|
||||||
#pragma endregion Globals
|
#pragma endregion Globals
|
||||||
|
|
||||||
inline
|
inline
|
||||||
CodeBody parse_file( char const* path ) {
|
CodeBody parse_file( char const* path ) {
|
||||||
String
|
StrBuilder
|
||||||
resolved_path = String::make(GlobalAllocator, StrC(Project_Path));
|
resolved_path = StrBuilder::make(gen_ctx.Allocator_Temp, Project_Path);
|
||||||
resolved_path.append(path);
|
resolved_path.append(path);
|
||||||
|
|
||||||
FileContents content = file_read_contents( GlobalAllocator, true, resolved_path );
|
FileContents content = file_read_contents( gen_ctx.Allocator_Temp, true, resolved_path );
|
||||||
CodeBody code = parse_global_body( StrC { content.size, (char const*)content.data });
|
CodeBody code = parse_global_body( Str { (char const*)content.data, content.size });
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Automatically handles resolving project path
|
// Automatically handles resolving project path
|
||||||
inline
|
inline
|
||||||
Builder builder_open(char const* path) {
|
Builder gasa_builder_open(char const* path) {
|
||||||
String
|
StrBuilder
|
||||||
resolved_path = String::make(GlobalAllocator, StrC(Project_Path));
|
resolved_path = StrBuilder::make(gen_ctx.Allocator_Temp, Project_Path);
|
||||||
resolved_path.append(path);
|
resolved_path.append(path);
|
||||||
return Builder::open( resolved_path );
|
return Builder::open( resolved_path );
|
||||||
}
|
}
|
||||||
@ -100,13 +113,13 @@ Builder builder_open(char const* path) {
|
|||||||
inline
|
inline
|
||||||
void format_file( char const* path, bool relative_path = true )
|
void format_file( char const* path, bool relative_path = true )
|
||||||
{
|
{
|
||||||
String
|
StrBuilder
|
||||||
resolved_path = String::make_reserve(GlobalAllocator, Project_Path.length());
|
resolved_path = StrBuilder::make_reserve(gen_ctx.Allocator_Temp, Project_Path.Len);
|
||||||
if (relative_path)
|
if (relative_path)
|
||||||
resolved_path.append(StrC(Project_Path));
|
resolved_path.append(Project_Path);
|
||||||
resolved_path.append(path);
|
resolved_path.append(path);
|
||||||
|
|
||||||
String style_arg = String::make(GlobalAllocator, txt("-style=file:"));
|
StrBuilder style_arg = StrBuilder::make(gen_ctx.Allocator_Temp, txt("-style=file:"));
|
||||||
style_arg.append(Root_Path);
|
style_arg.append(Root_Path);
|
||||||
style_arg.append("/scripts/.clang-format ");
|
style_arg.append("/scripts/.clang-format ");
|
||||||
|
|
||||||
@ -114,7 +127,7 @@ void format_file( char const* path, bool relative_path = true )
|
|||||||
#define clang_format "clang-format "
|
#define clang_format "clang-format "
|
||||||
#define cf_format_inplace "-i "
|
#define cf_format_inplace "-i "
|
||||||
#define cf_verbose "-verbose "
|
#define cf_verbose "-verbose "
|
||||||
String command = String::make( GlobalAllocator, clang_format );
|
StrBuilder command = StrBuilder::make( gen_ctx.Allocator_Temp, clang_format );
|
||||||
command.append( cf_format_inplace );
|
command.append( cf_format_inplace );
|
||||||
command.append( cf_verbose );
|
command.append( cf_verbose );
|
||||||
command.append( style_arg );
|
command.append( style_arg );
|
||||||
@ -129,19 +142,19 @@ void format_file( char const* path, bool relative_path = true )
|
|||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE
|
FORCEINLINE
|
||||||
String to_string( FString ue_string ) {
|
Str to_string( FString ue_string ) {
|
||||||
char const* ansi_str = TCHAR_TO_ANSI(*ue_string);
|
char const* ansi_str = TCHAR_TO_ANSI(*ue_string);
|
||||||
return String::make_length(GlobalAllocator, ansi_str, ue_string.Len());
|
return StrBuilder::make_length(gen_ctx.Allocator_Temp, ansi_str, ue_string.Len()).to_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE
|
FORCEINLINE
|
||||||
String to_string( FName ue_fname ) {
|
Str to_string( FName ue_fname ) {
|
||||||
char const* ansi_str = TCHAR_TO_ANSI(*ue_fname.ToString());
|
char const* ansi_str = TCHAR_TO_ANSI(*ue_fname.ToString());
|
||||||
return String::make_length(GlobalAllocator, ansi_str, ue_fname.GetStringLength());
|
return StrBuilder::make_length(gen_ctx.Allocator_Temp, ansi_str, ue_fname.GetStringLength()).to_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE
|
FORCEINLINE
|
||||||
FString to_fstring( String string )
|
FString to_fstring( Str string )
|
||||||
{
|
{
|
||||||
return FString::ConstructFromPtrSize( string.Data, string.length() );
|
return FString::ConstructFromPtrSize( string.Ptr, string.Len );
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,9 @@ Builder builder_open( char const* path )
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Buffer = strbuilder_make_reserve( _ctx->Allocator_Temp, _ctx->InitSize_BuilderBuffer );
|
Context* ctx = get_context();
|
||||||
|
GEN_ASSERT_NOT_NULL(ctx);
|
||||||
|
result.Buffer = strbuilder_make_reserve( ctx->Allocator_Temp, ctx->InitSize_BuilderBuffer );
|
||||||
|
|
||||||
// log_fmt("$Builder - Opened file: %s\n", result.File.filename );
|
// log_fmt("$Builder - Opened file: %s\n", result.File.filename );
|
||||||
return result;
|
return result;
|
||||||
|
@ -37,13 +37,14 @@ Builder builder_open ( char const* path );
|
|||||||
void builder_pad_lines ( Builder* builder, s32 num );
|
void builder_pad_lines ( Builder* builder, s32 num );
|
||||||
void builder_print ( Builder* builder, Code code );
|
void builder_print ( Builder* builder, Code code );
|
||||||
void builder_print_fmt_va( Builder* builder, char const* fmt, va_list va );
|
void builder_print_fmt_va( Builder* builder, char const* fmt, va_list va );
|
||||||
void builder_print_fmt ( Builder* builder, char const* fmt, ... ) {
|
void builder_write ( Builder* builder );
|
||||||
|
|
||||||
|
FORCEINLINE void builder_print_fmt ( Builder* builder, char const* fmt, ... ) {
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start( va, fmt );
|
va_start( va, fmt );
|
||||||
builder_print_fmt_va( builder, fmt, va );
|
builder_print_fmt_va( builder, fmt, va );
|
||||||
va_end( va );
|
va_end( va );
|
||||||
}
|
}
|
||||||
void builder_write( Builder* builder );
|
|
||||||
|
|
||||||
struct Builder
|
struct Builder
|
||||||
{
|
{
|
||||||
@ -68,10 +69,10 @@ struct Builder
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
|
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
|
||||||
void builder_pad_lines( Builder& builder, s32 num ) { return builder_pad_lines(& builder, num); }
|
FORCEINLINE void builder_pad_lines( Builder& builder, s32 num ) { return builder_pad_lines(& builder, num); }
|
||||||
void builder_print ( Builder& builder, Code code ) { return builder_print(& builder, code); }
|
FORCEINLINE void builder_print ( Builder& builder, Code code ) { return builder_print(& builder, code); }
|
||||||
void builder_write ( Builder& builder ) { return builder_write(& builder ); }
|
FORCEINLINE void builder_write ( Builder& builder ) { return builder_write(& builder ); }
|
||||||
void builder_print_fmt( Builder& builder, char const* fmt, ...) {
|
FORCEINLINE void builder_print_fmt( Builder& builder, char const* fmt, ...) {
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start( va, fmt );
|
va_start( va, fmt );
|
||||||
builder_print_fmt_va( & builder, fmt, va );
|
builder_print_fmt_va( & builder, fmt, va );
|
||||||
|
@ -3403,6 +3403,10 @@ void deinit(Context* ctx)
|
|||||||
-- context_counter;
|
-- context_counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Context* get_context() {
|
||||||
|
return _ctx;
|
||||||
|
}
|
||||||
|
|
||||||
void reset(Context* ctx)
|
void reset(Context* ctx)
|
||||||
{
|
{
|
||||||
s32 index = 0;
|
s32 index = 0;
|
||||||
@ -4809,7 +4813,7 @@ CodeUsing def_using_namespace( Str name )
|
|||||||
|
|
||||||
CodeVar def_variable( CodeTypename type, Str name, Opts_def_variable p )
|
CodeVar def_variable( CodeTypename type, Str name, Opts_def_variable p )
|
||||||
{
|
{
|
||||||
if ( ! name_check( def_variable, name ) || null_check( def_variable, type ) ) {
|
if ( ! name_check( def_variable, name ) || ! null_check( def_variable, type ) ) {
|
||||||
GEN_DEBUG_TRAP();
|
GEN_DEBUG_TRAP();
|
||||||
return InvalidCode;
|
return InvalidCode;
|
||||||
}
|
}
|
||||||
@ -5786,7 +5790,7 @@ s32 lex_preprocessor_define( LexContext* ctx )
|
|||||||
array_append( _ctx->Lexer_Tokens, opening_paren );
|
array_append( _ctx->Lexer_Tokens, opening_paren );
|
||||||
move_forward();
|
move_forward();
|
||||||
|
|
||||||
Token last_parameter;
|
Token last_parameter = {};
|
||||||
// We need to tokenize the define's arguments now:
|
// We need to tokenize the define's arguments now:
|
||||||
while( ctx->left && * ctx->scanner != ')')
|
while( ctx->left && * ctx->scanner != ')')
|
||||||
{
|
{
|
||||||
@ -9520,7 +9524,40 @@ Code parse_operator_function_or_variable( bool expects_function, CodeAttributes
|
|||||||
// Example : <Capture_Start> <Value> <Comma>
|
// Example : <Capture_Start> <Value> <Comma>
|
||||||
// idx +1 +2
|
// idx +1 +2
|
||||||
bool detected_comma = _ctx->parser.Tokens.Arr[ _ctx->parser.Tokens.Idx + 2 ].Type == Tok_Comma;
|
bool detected_comma = _ctx->parser.Tokens.Arr[ _ctx->parser.Tokens.Idx + 2 ].Type == Tok_Comma;
|
||||||
if ( detected_capture && ! detected_comma )
|
|
||||||
|
b32 detected_non_varadic_unpaired_param = detected_comma && nexttok.Type != Tok_Varadic_Argument;
|
||||||
|
if (! detected_non_varadic_unpaired_param && nexttok.Type == Tok_Preprocess_Macro_Expr) for( s32 break_scope = 0; break_scope == 0; ++ break_scope)
|
||||||
|
{
|
||||||
|
Macro* macro = lookup_macro( nexttok.Text );
|
||||||
|
if (macro == nullptr || ! macro_is_functional(* macro))
|
||||||
|
break;
|
||||||
|
|
||||||
|
// ( <Macro_Expr> (
|
||||||
|
// Idx +1 +2
|
||||||
|
s32 idx = _ctx->parser.Tokens.Idx + 1;
|
||||||
|
s32 level = 0;
|
||||||
|
|
||||||
|
// Find end of the token expression
|
||||||
|
for ( ; idx < array_num(_ctx->parser.Tokens.Arr); idx++ )
|
||||||
|
{
|
||||||
|
Token tok = _ctx->parser.Tokens.Arr[ idx ];
|
||||||
|
|
||||||
|
if ( tok.Type == Tok_Capture_Start )
|
||||||
|
level++;
|
||||||
|
else if ( tok.Type == Tok_Capture_End && level > 0 )
|
||||||
|
level--;
|
||||||
|
if (level == 0 && tok.Type == Tok_Capture_End)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++ idx; // Will incremnt to possible comma position
|
||||||
|
|
||||||
|
if ( _ctx->parser.Tokens.Arr[ idx ].Type != Tok_Comma )
|
||||||
|
break;
|
||||||
|
|
||||||
|
detected_non_varadic_unpaired_param = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( detected_capture && ! detected_non_varadic_unpaired_param )
|
||||||
{
|
{
|
||||||
// Dealing with a function
|
// Dealing with a function
|
||||||
result = cast(Code, parse_function_after_name( ModuleFlag_None, attributes, specifiers, type, name ));
|
result = cast(Code, parse_function_after_name( ModuleFlag_None, attributes, specifiers, type, name ));
|
||||||
@ -10032,7 +10069,7 @@ Code parse_simple_preprocess( TokType which )
|
|||||||
|| str_contains(calling_proc, txt("parse_class_struct_body"))
|
|| str_contains(calling_proc, txt("parse_class_struct_body"))
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (peektok.Type == Tok_Statement_End)
|
if (left && peektok.Type == Tok_Statement_End)
|
||||||
{
|
{
|
||||||
Token stmt_end = currtok;
|
Token stmt_end = currtok;
|
||||||
eat( Tok_Statement_End );
|
eat( Tok_Statement_End );
|
||||||
@ -12045,7 +12082,6 @@ CodeTypedef parser_parse_typedef()
|
|||||||
// valid_macro |= macro && macro_expects_body(* macro));
|
// valid_macro |= macro && macro_expects_body(* macro));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Code macro;
|
|
||||||
if ( valid_macro )
|
if ( valid_macro )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
@ -12893,6 +12929,12 @@ CodeVar parse_variable( Str def )
|
|||||||
#undef parser_use_parenthesis
|
#undef parser_use_parenthesis
|
||||||
#undef parser_strip_formatting_dont_preserve_newlines
|
#undef parser_strip_formatting_dont_preserve_newlines
|
||||||
|
|
||||||
|
#pragma endregion Parsing
|
||||||
|
|
||||||
|
|
||||||
|
#pragma region Untyped
|
||||||
|
|
||||||
|
|
||||||
ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va )
|
ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va )
|
||||||
{
|
{
|
||||||
char const* buf_begin = buf;
|
char const* buf_begin = buf;
|
||||||
@ -13067,8 +13109,7 @@ Code untyped_token_fmt( s32 num_tokens, char const* fmt, ... )
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
#pragma endregion Parsing
|
|
||||||
|
|
||||||
#pragma endregion Interface
|
#pragma endregion Interface
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -883,7 +883,7 @@ template<typename Type> mem_ptr_const to_mem_ptr_const( Type ptr ) { return (mem
|
|||||||
// NOTE: Things that shouldn't happen with a message!
|
// NOTE: Things that shouldn't happen with a message!
|
||||||
#define GEN_PANIC( msg, ... ) GEN_ASSERT_MSG( 0, msg, ##__VA_ARGS__ )
|
#define GEN_PANIC( msg, ... ) GEN_ASSERT_MSG( 0, msg, ##__VA_ARGS__ )
|
||||||
|
|
||||||
#if GEN_BULD_DEBUG
|
#if GEN_BUILD_DEBUG
|
||||||
#define GEN_FATAL( ... ) \
|
#define GEN_FATAL( ... ) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
@ -1138,7 +1138,6 @@ FORCEINLINE void check(Arena& arena) { return arena_check(& arena); }
|
|||||||
#pragma pop_macro("check")
|
#pragma pop_macro("check")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
AllocatorInfo arena_allocator_info( Arena* arena ) {
|
AllocatorInfo arena_allocator_info( Arena* arena ) {
|
||||||
GEN_ASSERT(arena != nullptr);
|
GEN_ASSERT(arena != nullptr);
|
||||||
@ -1301,9 +1300,9 @@ void pool_clear(Pool* pool);
|
|||||||
void pool_free(Pool* pool);
|
void pool_free(Pool* pool);
|
||||||
|
|
||||||
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
|
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
|
||||||
AllocatorInfo allocator_info(Pool& pool) { return pool_allocator_info(& pool); }
|
FORCEINLINE AllocatorInfo allocator_info(Pool& pool) { return pool_allocator_info(& pool); }
|
||||||
void clear(Pool& pool) { return pool_clear(& pool); }
|
FORCEINLINE void clear(Pool& pool) { return pool_clear(& pool); }
|
||||||
void free(Pool& pool) { return pool_free(& pool); }
|
FORCEINLINE void free(Pool& pool) { return pool_free(& pool); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct Pool
|
struct Pool
|
||||||
@ -2042,6 +2041,7 @@ Array<Type> array_init_reserve(AllocatorInfo allocator, ssize capacity)
|
|||||||
return {rcast(Type*, header + 1)};
|
return {rcast(Type*, header + 1)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FORCEINLINE
|
||||||
usize array_grow_formula(ssize value) {
|
usize array_grow_formula(ssize value) {
|
||||||
return 2 * value + 8;
|
return 2 * value + 8;
|
||||||
}
|
}
|
||||||
@ -2101,7 +2101,7 @@ bool array_append_at(Array<Type>* array, Type item, usize idx)
|
|||||||
ArrayHeader* header = array_get_header(* array);
|
ArrayHeader* header = array_get_header(* array);
|
||||||
|
|
||||||
ssize slot = idx;
|
ssize slot = idx;
|
||||||
if (slot >= header->Num)
|
if (slot >= (ssize)(header->Num))
|
||||||
slot = header->Num - 1;
|
slot = header->Num - 1;
|
||||||
|
|
||||||
if (slot < 0)
|
if (slot < 0)
|
||||||
@ -2253,7 +2253,6 @@ bool array_reserve(Array<Type>* array, usize new_capacity)
|
|||||||
{
|
{
|
||||||
GEN_ASSERT( array != nullptr);
|
GEN_ASSERT( array != nullptr);
|
||||||
GEN_ASSERT(* array != nullptr);
|
GEN_ASSERT(* array != nullptr);
|
||||||
GEN_ASSERT(num > 0)
|
|
||||||
ArrayHeader* header = array_get_header(array);
|
ArrayHeader* header = array_get_header(array);
|
||||||
|
|
||||||
if (header->Capacity < new_capacity)
|
if (header->Capacity < new_capacity)
|
||||||
@ -2662,7 +2661,7 @@ HashTableFindResult hashtable__find(HashTable<Type> table, u64 key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename Type> FORCEINLINE
|
template<typename Type> FORCEINLINE
|
||||||
bool hashtable_full(HashTable<Type> table) {
|
b32 hashtable_full(HashTable<Type> table) {
|
||||||
GEN_ASSERT_NOT_NULL(table.Hashes);
|
GEN_ASSERT_NOT_NULL(table.Hashes);
|
||||||
GEN_ASSERT_NOT_NULL(table.Entries);
|
GEN_ASSERT_NOT_NULL(table.Entries);
|
||||||
usize critical_load = usize(HashTable_CriticalLoadScale * f32(array_num(table.Hashes)));
|
usize critical_load = usize(HashTable_CriticalLoadScale * f32(array_num(table.Hashes)));
|
||||||
@ -3089,6 +3088,7 @@ bool strbuilder_append_string(StrBuilder* str, StrBuilder const other) {
|
|||||||
return strbuilder_append_c_str_len(str, (char const*)other, strbuilder_length(other));
|
return strbuilder_append_c_str_len(str, (char const*)other, strbuilder_length(other));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
bool strbuilder_append_fmt(StrBuilder* str, char const* fmt, ...) {
|
bool strbuilder_append_fmt(StrBuilder* str, char const* fmt, ...) {
|
||||||
GEN_ASSERT(str != nullptr);
|
GEN_ASSERT(str != nullptr);
|
||||||
ssize res;
|
ssize res;
|
||||||
@ -3837,6 +3837,435 @@ u64 time_rel_ms( void );
|
|||||||
|
|
||||||
#pragma endregion Timing
|
#pragma endregion Timing
|
||||||
|
|
||||||
|
#pragma region ADT
|
||||||
|
|
||||||
|
enum ADT_Type : u32
|
||||||
|
{
|
||||||
|
EADT_TYPE_UNINITIALISED, /* node was not initialised, this is a programming error! */
|
||||||
|
EADT_TYPE_ARRAY,
|
||||||
|
EADT_TYPE_OBJECT,
|
||||||
|
EADT_TYPE_STRING,
|
||||||
|
EADT_TYPE_MULTISTRING,
|
||||||
|
EADT_TYPE_INTEGER,
|
||||||
|
EADT_TYPE_REAL,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ADT_Props : u32
|
||||||
|
{
|
||||||
|
EADT_PROPS_NONE,
|
||||||
|
EADT_PROPS_NAN,
|
||||||
|
EADT_PROPS_NAN_NEG,
|
||||||
|
EADT_PROPS_INFINITY,
|
||||||
|
EADT_PROPS_INFINITY_NEG,
|
||||||
|
EADT_PROPS_FALSE,
|
||||||
|
EADT_PROPS_TRUE,
|
||||||
|
EADT_PROPS_NULL,
|
||||||
|
EADT_PROPS_IS_EXP,
|
||||||
|
EADT_PROPS_IS_HEX,
|
||||||
|
|
||||||
|
// Used internally so that people can fill in real numbers they plan to write.
|
||||||
|
EADT_PROPS_IS_PARSED_REAL,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ADT_NamingStyle : u32
|
||||||
|
{
|
||||||
|
EADT_NAME_STYLE_DOUBLE_QUOTE,
|
||||||
|
EADT_NAME_STYLE_SINGLE_QUOTE,
|
||||||
|
EADT_NAME_STYLE_NO_QUOTES,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ADT_AssignStyle : u32
|
||||||
|
{
|
||||||
|
EADT_ASSIGN_STYLE_COLON,
|
||||||
|
EADT_ASSIGN_STYLE_EQUALS,
|
||||||
|
EADT_ASSIGN_STYLE_LINE,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ADT_DelimStyle : u32
|
||||||
|
{
|
||||||
|
EADT_DELIM_STYLE_COMMA,
|
||||||
|
EADT_DELIM_STYLE_LINE,
|
||||||
|
EADT_DELIM_STYLE_NEWLINE,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ADT_Error : u32
|
||||||
|
{
|
||||||
|
EADT_ERROR_NONE,
|
||||||
|
EADT_ERROR_INTERNAL,
|
||||||
|
EADT_ERROR_ALREADY_CONVERTED,
|
||||||
|
EADT_ERROR_INVALID_TYPE,
|
||||||
|
EADT_ERROR_OUT_OF_MEMORY,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ADT_Node
|
||||||
|
{
|
||||||
|
char const* name;
|
||||||
|
struct ADT_Node* parent;
|
||||||
|
|
||||||
|
/* properties */
|
||||||
|
ADT_Type type : 4;
|
||||||
|
u8 props : 4;
|
||||||
|
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
||||||
|
u8 cfg_mode : 1;
|
||||||
|
u8 name_style : 2;
|
||||||
|
u8 assign_style : 2;
|
||||||
|
u8 delim_style : 2;
|
||||||
|
u8 delim_line_width : 4;
|
||||||
|
u8 assign_line_width : 4;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* adt data */
|
||||||
|
union
|
||||||
|
{
|
||||||
|
char const* string;
|
||||||
|
Array(ADT_Node) nodes; ///< zpl_array
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
|
f64 real;
|
||||||
|
s64 integer;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
||||||
|
/* number analysis */
|
||||||
|
s32 base;
|
||||||
|
s32 base2;
|
||||||
|
u8 base2_offset : 4;
|
||||||
|
s8 exp : 4;
|
||||||
|
u8 neg_zero : 1;
|
||||||
|
u8 lead_digit : 1;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ADT NODE LIMITS
|
||||||
|
* delimiter and assignment segment width is limited to 128 whitespace symbols each.
|
||||||
|
* real number limits decimal position to 128 places.
|
||||||
|
* real number exponent is limited to 64 digits.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialise an ADT object or array
|
||||||
|
*
|
||||||
|
* @param node
|
||||||
|
* @param backing Memory allocator used for descendants
|
||||||
|
* @param name Node's name
|
||||||
|
* @param is_array
|
||||||
|
* @return error code
|
||||||
|
*/
|
||||||
|
u8 adt_make_branch( ADT_Node* node, AllocatorInfo backing, char const* name, b32 is_array );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Destroy an ADT branch and its descendants
|
||||||
|
*
|
||||||
|
* @param node
|
||||||
|
* @return error code
|
||||||
|
*/
|
||||||
|
u8 adt_destroy_branch( ADT_Node* node );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialise an ADT leaf
|
||||||
|
*
|
||||||
|
* @param node
|
||||||
|
* @param name Node's name
|
||||||
|
* @param type Node's type (use zpl_adt_make_branch for container nodes)
|
||||||
|
* @return error code
|
||||||
|
*/
|
||||||
|
u8 adt_make_leaf( ADT_Node* node, char const* name, ADT_Type type );
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fetch a node using provided URI string.
|
||||||
|
*
|
||||||
|
* This method uses a basic syntax to fetch a node from the ADT. The following features are available
|
||||||
|
* to retrieve the data:
|
||||||
|
*
|
||||||
|
* - "a/b/c" navigates through objects "a" and "b" to get to "c"
|
||||||
|
* - "arr/[foo=123]/bar" iterates over "arr" to find any object with param "foo" that matches the value "123", then gets its field called "bar"
|
||||||
|
* - "arr/3" retrieves the 4th element in "arr"
|
||||||
|
* - "arr/[apple]" retrieves the first element of value "apple" in "arr"
|
||||||
|
*
|
||||||
|
* @param node ADT node
|
||||||
|
* @param uri Locator string as described above
|
||||||
|
* @return zpl_adt_node*
|
||||||
|
*
|
||||||
|
* @see code/apps/examples/json_get.c
|
||||||
|
*/
|
||||||
|
ADT_Node* adt_query( ADT_Node* node, char const* uri );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Find a field node within an object by the given name.
|
||||||
|
*
|
||||||
|
* @param node
|
||||||
|
* @param name
|
||||||
|
* @param deep_search Perform search recursively
|
||||||
|
* @return zpl_adt_node * node
|
||||||
|
*/
|
||||||
|
ADT_Node* adt_find( ADT_Node* node, char const* name, b32 deep_search );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Allocate an unitialised node within a container at a specified index.
|
||||||
|
*
|
||||||
|
* @param parent
|
||||||
|
* @param index
|
||||||
|
* @return zpl_adt_node * node
|
||||||
|
*/
|
||||||
|
ADT_Node* adt_alloc_at( ADT_Node* parent, ssize index );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Allocate an unitialised node within a container.
|
||||||
|
*
|
||||||
|
* @param parent
|
||||||
|
* @return zpl_adt_node * node
|
||||||
|
*/
|
||||||
|
ADT_Node* adt_alloc( ADT_Node* parent );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Move an existing node to a new container at a specified index.
|
||||||
|
*
|
||||||
|
* @param node
|
||||||
|
* @param new_parent
|
||||||
|
* @param index
|
||||||
|
* @return zpl_adt_node * node
|
||||||
|
*/
|
||||||
|
ADT_Node* adt_move_node_at( ADT_Node* node, ADT_Node* new_parent, ssize index );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Move an existing node to a new container.
|
||||||
|
*
|
||||||
|
* @param node
|
||||||
|
* @param new_parent
|
||||||
|
* @return zpl_adt_node * node
|
||||||
|
*/
|
||||||
|
ADT_Node* adt_move_node( ADT_Node* node, ADT_Node* new_parent );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Swap two nodes.
|
||||||
|
*
|
||||||
|
* @param node
|
||||||
|
* @param other_node
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void adt_swap_nodes( ADT_Node* node, ADT_Node* other_node );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Remove node from container.
|
||||||
|
*
|
||||||
|
* @param node
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void adt_remove_node( ADT_Node* node );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialise a node as an object
|
||||||
|
*
|
||||||
|
* @param obj
|
||||||
|
* @param name
|
||||||
|
* @param backing
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
b8 adt_set_obj( ADT_Node* obj, char const* name, AllocatorInfo backing );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialise a node as an array
|
||||||
|
*
|
||||||
|
* @param obj
|
||||||
|
* @param name
|
||||||
|
* @param backing
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
b8 adt_set_arr( ADT_Node* obj, char const* name, AllocatorInfo backing );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialise a node as a string
|
||||||
|
*
|
||||||
|
* @param obj
|
||||||
|
* @param name
|
||||||
|
* @param value
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
b8 adt_set_str( ADT_Node* obj, char const* name, char const* value );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialise a node as a float
|
||||||
|
*
|
||||||
|
* @param obj
|
||||||
|
* @param name
|
||||||
|
* @param value
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
b8 adt_set_flt( ADT_Node* obj, char const* name, f64 value );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialise a node as a signed integer
|
||||||
|
*
|
||||||
|
* @param obj
|
||||||
|
* @param name
|
||||||
|
* @param value
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
b8 adt_set_int( ADT_Node* obj, char const* name, s64 value );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Append a new node to a container as an object
|
||||||
|
*
|
||||||
|
* @param parent
|
||||||
|
* @param name
|
||||||
|
* @return*
|
||||||
|
*/
|
||||||
|
ADT_Node* adt_append_obj( ADT_Node* parent, char const* name );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Append a new node to a container as an array
|
||||||
|
*
|
||||||
|
* @param parent
|
||||||
|
* @param name
|
||||||
|
* @return*
|
||||||
|
*/
|
||||||
|
ADT_Node* adt_append_arr( ADT_Node* parent, char const* name );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Append a new node to a container as a string
|
||||||
|
*
|
||||||
|
* @param parent
|
||||||
|
* @param name
|
||||||
|
* @param value
|
||||||
|
* @return*
|
||||||
|
*/
|
||||||
|
ADT_Node* adt_append_str( ADT_Node* parent, char const* name, char const* value );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Append a new node to a container as a float
|
||||||
|
*
|
||||||
|
* @param parent
|
||||||
|
* @param name
|
||||||
|
* @param value
|
||||||
|
* @return*
|
||||||
|
*/
|
||||||
|
ADT_Node* adt_append_flt( ADT_Node* parent, char const* name, f64 value );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Append a new node to a container as a signed integer
|
||||||
|
*
|
||||||
|
* @param parent
|
||||||
|
* @param name
|
||||||
|
* @param value
|
||||||
|
* @return*
|
||||||
|
*/
|
||||||
|
ADT_Node* adt_append_int( ADT_Node* parent, char const* name, s64 value );
|
||||||
|
|
||||||
|
/* parser helpers */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Parses a text and stores the result into an unitialised node.
|
||||||
|
*
|
||||||
|
* @param node
|
||||||
|
* @param base
|
||||||
|
* @return*
|
||||||
|
*/
|
||||||
|
char* adt_parse_number( ADT_Node* node, char* base );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Parses a text and stores the result into an unitialised node.
|
||||||
|
* This function expects the entire input to be a number.
|
||||||
|
*
|
||||||
|
* @param node
|
||||||
|
* @param base
|
||||||
|
* @return*
|
||||||
|
*/
|
||||||
|
char* adt_parse_number_strict( ADT_Node* node, char* base_str );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Parses and converts an existing string node into a number.
|
||||||
|
*
|
||||||
|
* @param node
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ADT_Error adt_c_str_to_number( ADT_Node* node );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Parses and converts an existing string node into a number.
|
||||||
|
* This function expects the entire input to be a number.
|
||||||
|
*
|
||||||
|
* @param node
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ADT_Error adt_c_str_to_number_strict( ADT_Node* node );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Prints a number into a file stream.
|
||||||
|
*
|
||||||
|
* The provided file handle can also be a memory mapped stream.
|
||||||
|
*
|
||||||
|
* @see zpl_file_stream_new
|
||||||
|
* @param file
|
||||||
|
* @param node
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ADT_Error adt_print_number( FileInfo* file, ADT_Node* node );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Prints a string into a file stream.
|
||||||
|
*
|
||||||
|
* The provided file handle can also be a memory mapped stream.
|
||||||
|
*
|
||||||
|
* @see zpl_file_stream_new
|
||||||
|
* @param file
|
||||||
|
* @param node
|
||||||
|
* @param escaped_chars
|
||||||
|
* @param escape_symbol
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ADT_Error adt_print_string( FileInfo* file, ADT_Node* node, char const* escaped_chars, char const* escape_symbol );
|
||||||
|
|
||||||
|
#pragma endregion ADT
|
||||||
|
|
||||||
|
#pragma region CSV
|
||||||
|
|
||||||
|
enum CSV_Error : u32
|
||||||
|
{
|
||||||
|
ECSV_Error__NONE,
|
||||||
|
ECSV_Error__INTERNAL,
|
||||||
|
ECSV_Error__UNEXPECTED_END_OF_INPUT,
|
||||||
|
ECSV_Error__MISMATCHED_ROWS,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef ADT_Node CSV_Object;
|
||||||
|
|
||||||
|
u8 csv_parse( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header );
|
||||||
|
u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header, char delim );
|
||||||
|
void csv_free( CSV_Object* obj );
|
||||||
|
|
||||||
|
void csv_write( FileInfo* file, CSV_Object* obj );
|
||||||
|
StrBuilder csv_write_string( AllocatorInfo a, CSV_Object* obj );
|
||||||
|
void csv_write_delimiter( FileInfo* file, CSV_Object* obj, char delim );
|
||||||
|
StrBuilder csv_write_strbuilder_delimiter( AllocatorInfo a, CSV_Object* obj, char delim );
|
||||||
|
|
||||||
|
/* inline */
|
||||||
|
|
||||||
|
inline
|
||||||
|
u8 csv_parse( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header )
|
||||||
|
{
|
||||||
|
return csv_parse_delimiter( root, text, allocator, has_header, ',' );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
void csv_write( FileInfo* file, CSV_Object* obj )
|
||||||
|
{
|
||||||
|
csv_write_delimiter( file, obj, ',' );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
StrBuilder csv_write_string( AllocatorInfo a, CSV_Object* obj )
|
||||||
|
{
|
||||||
|
return csv_write_strbuilder_delimiter( a, obj, ',' );
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma endregion CSV
|
||||||
|
|
||||||
GEN_NS_END
|
GEN_NS_END
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
|
@ -640,10 +640,11 @@ FORCEINLINE bool is_trailing( Specifier specifier )
|
|||||||
return spec_is_trailing( specifier );
|
return spec_is_trailing( specifier );
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GEN_DEFINE_ATTRIBUTE_TOKENS \
|
#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_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_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_GAMEPLAYABILITIES_API, "GAMEPLAYABILITIES_API" ) Entry( Tok_Attribute_UMG_API, "UMG_API" ) \
|
||||||
|
Entry( Tok_Attribute_GASA_API, "GASA_API" )
|
||||||
|
|
||||||
enum TokType : u32
|
enum TokType : u32
|
||||||
{
|
{
|
||||||
@ -752,6 +753,7 @@ enum TokType : u32
|
|||||||
Tok_Attribute_ENGINE_API,
|
Tok_Attribute_ENGINE_API,
|
||||||
Tok_Attribute_GAMEPLAYABILITIES_API,
|
Tok_Attribute_GAMEPLAYABILITIES_API,
|
||||||
Tok_Attribute_UMG_API,
|
Tok_Attribute_UMG_API,
|
||||||
|
Tok_Attribute_GASA_API,
|
||||||
Tok_NumTokens
|
Tok_NumTokens
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -863,6 +865,7 @@ inline Str toktype_to_str( TokType type )
|
|||||||
{ "ENGINE_API", sizeof( "ENGINE_API" ) - 1 },
|
{ "ENGINE_API", sizeof( "ENGINE_API" ) - 1 },
|
||||||
{ "GAMEPLAYABILITIES_API", sizeof( "GAMEPLAYABILITIES_API" ) - 1 },
|
{ "GAMEPLAYABILITIES_API", sizeof( "GAMEPLAYABILITIES_API" ) - 1 },
|
||||||
{ "UMG_API", sizeof( "UMG_API" ) - 1 },
|
{ "UMG_API", sizeof( "UMG_API" ) - 1 },
|
||||||
|
{ "GASA_API", sizeof( "GASA_API" ) - 1 },
|
||||||
};
|
};
|
||||||
return lookup[type];
|
return lookup[type];
|
||||||
}
|
}
|
||||||
@ -1029,6 +1032,7 @@ TokType macrotype_to_toktype( MacroType type ) {
|
|||||||
return Tok_Invalid;
|
return Tok_Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
Str macrotype_to_str( MacroType type )
|
Str macrotype_to_str( MacroType type )
|
||||||
{
|
{
|
||||||
local_persist
|
local_persist
|
||||||
@ -1093,6 +1097,11 @@ b32 macro_expects_body( Macro macro ) {
|
|||||||
return bitfield_is_set( b16, macro.Flags, MF_Expects_Body );
|
return bitfield_is_set( b16, macro.Flags, MF_Expects_Body );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
|
||||||
|
FORCEINLINE b32 is_functional( Macro macro ) { return bitfield_is_set( b16, macro.Flags, MF_Functional ); }
|
||||||
|
FORCEINLINE b32 expects_body ( Macro macro ) { return bitfield_is_set( b16, macro.Flags, MF_Expects_Body ); }
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef HashTable(Macro) MacroTable;
|
typedef HashTable(Macro) MacroTable;
|
||||||
#pragma endregion Types
|
#pragma endregion Types
|
||||||
|
|
||||||
@ -3980,6 +3989,9 @@ GEN_API void init(Context* ctx);
|
|||||||
// However on Windows at least, it doesn't need to occur as the OS will clean up after the process.
|
// However on Windows at least, it doesn't need to occur as the OS will clean up after the process.
|
||||||
GEN_API void deinit(Context* ctx);
|
GEN_API void deinit(Context* ctx);
|
||||||
|
|
||||||
|
// Retrieves the active context (not usually needed, but here in case...)
|
||||||
|
GEN_API Context* get_context();
|
||||||
|
|
||||||
// Clears the allocations, but doesn't free the memoery, then calls init() again.
|
// Clears the allocations, but doesn't free the memoery, then calls init() again.
|
||||||
// Ease of use.
|
// Ease of use.
|
||||||
GEN_API void reset(Context* ctx);
|
GEN_API void reset(Context* ctx);
|
||||||
@ -4576,9 +4588,9 @@ FORCEINLINE void define_params_append (CodeDefineParams appendee
|
|||||||
FORCEINLINE CodeDefineParams define_params_get (CodeDefineParams self, s32 idx ) { return (CodeDefineParams) (Code) params_get( cast(CodeParams, self), idx); }
|
FORCEINLINE CodeDefineParams define_params_get (CodeDefineParams self, s32 idx ) { return (CodeDefineParams) (Code) params_get( cast(CodeParams, self), idx); }
|
||||||
FORCEINLINE bool define_params_has_entries(CodeDefineParams self) { return params_has_entries( cast(CodeParams, self)); }
|
FORCEINLINE bool define_params_has_entries(CodeDefineParams self) { return params_has_entries( cast(CodeParams, self)); }
|
||||||
|
|
||||||
CodeDefineParams begin_CodeDefineParams(CodeDefineParams params) { return (CodeDefineParams) (Code) begin_CodeParams( cast(CodeParams, (Code)params)); }
|
FORCEINLINE CodeDefineParams begin_CodeDefineParams(CodeDefineParams params) { return (CodeDefineParams) (Code) begin_CodeParams( cast(CodeParams, (Code)params)); }
|
||||||
CodeDefineParams end_CodeDefineParams (CodeDefineParams params) { return (CodeDefineParams) (Code) end_CodeParams ( cast(CodeParams, (Code)params)); }
|
FORCEINLINE CodeDefineParams end_CodeDefineParams (CodeDefineParams params) { return (CodeDefineParams) (Code) end_CodeParams ( cast(CodeParams, (Code)params)); }
|
||||||
CodeDefineParams next_CodeDefineParams (CodeDefineParams params, CodeDefineParams entry_iter) { return (CodeDefineParams) (Code) next_CodeParams ( cast(CodeParams, (Code)params), cast(CodeParams, (Code)entry_iter)); }
|
FORCEINLINE CodeDefineParams next_CodeDefineParams (CodeDefineParams params, CodeDefineParams entry_iter) { return (CodeDefineParams) (Code) next_CodeParams ( cast(CodeParams, (Code)params), cast(CodeParams, (Code)entry_iter)); }
|
||||||
|
|
||||||
#if GEN_COMPILER_CPP
|
#if GEN_COMPILER_CPP
|
||||||
FORCEINLINE
|
FORCEINLINE
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -28,435 +28,6 @@
|
|||||||
|
|
||||||
GEN_NS_BEGIN
|
GEN_NS_BEGIN
|
||||||
|
|
||||||
#pragma region ADT
|
|
||||||
|
|
||||||
enum ADT_Type : u32
|
|
||||||
{
|
|
||||||
EADT_TYPE_UNINITIALISED, /* node was not initialised, this is a programming error! */
|
|
||||||
EADT_TYPE_ARRAY,
|
|
||||||
EADT_TYPE_OBJECT,
|
|
||||||
EADT_TYPE_STRING,
|
|
||||||
EADT_TYPE_MULTISTRING,
|
|
||||||
EADT_TYPE_INTEGER,
|
|
||||||
EADT_TYPE_REAL,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ADT_Props : u32
|
|
||||||
{
|
|
||||||
EADT_PROPS_NONE,
|
|
||||||
EADT_PROPS_NAN,
|
|
||||||
EADT_PROPS_NAN_NEG,
|
|
||||||
EADT_PROPS_INFINITY,
|
|
||||||
EADT_PROPS_INFINITY_NEG,
|
|
||||||
EADT_PROPS_FALSE,
|
|
||||||
EADT_PROPS_TRUE,
|
|
||||||
EADT_PROPS_NULL,
|
|
||||||
EADT_PROPS_IS_EXP,
|
|
||||||
EADT_PROPS_IS_HEX,
|
|
||||||
|
|
||||||
// Used internally so that people can fill in real numbers they plan to write.
|
|
||||||
EADT_PROPS_IS_PARSED_REAL,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ADT_NamingStyle : u32
|
|
||||||
{
|
|
||||||
EADT_NAME_STYLE_DOUBLE_QUOTE,
|
|
||||||
EADT_NAME_STYLE_SINGLE_QUOTE,
|
|
||||||
EADT_NAME_STYLE_NO_QUOTES,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ADT_AssignStyle : u32
|
|
||||||
{
|
|
||||||
EADT_ASSIGN_STYLE_COLON,
|
|
||||||
EADT_ASSIGN_STYLE_EQUALS,
|
|
||||||
EADT_ASSIGN_STYLE_LINE,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ADT_DelimStyle : u32
|
|
||||||
{
|
|
||||||
EADT_DELIM_STYLE_COMMA,
|
|
||||||
EADT_DELIM_STYLE_LINE,
|
|
||||||
EADT_DELIM_STYLE_NEWLINE,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ADT_Error : u32
|
|
||||||
{
|
|
||||||
EADT_ERROR_NONE,
|
|
||||||
EADT_ERROR_INTERNAL,
|
|
||||||
EADT_ERROR_ALREADY_CONVERTED,
|
|
||||||
EADT_ERROR_INVALID_TYPE,
|
|
||||||
EADT_ERROR_OUT_OF_MEMORY,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ADT_Node
|
|
||||||
{
|
|
||||||
char const* name;
|
|
||||||
struct ADT_Node* parent;
|
|
||||||
|
|
||||||
/* properties */
|
|
||||||
ADT_Type type : 4;
|
|
||||||
u8 props : 4;
|
|
||||||
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
|
||||||
u8 cfg_mode : 1;
|
|
||||||
u8 name_style : 2;
|
|
||||||
u8 assign_style : 2;
|
|
||||||
u8 delim_style : 2;
|
|
||||||
u8 delim_line_width : 4;
|
|
||||||
u8 assign_line_width : 4;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* adt data */
|
|
||||||
union
|
|
||||||
{
|
|
||||||
char const* string;
|
|
||||||
Array(ADT_Node) nodes; ///< zpl_array
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
union
|
|
||||||
{
|
|
||||||
f64 real;
|
|
||||||
s64 integer;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
|
||||||
/* number analysis */
|
|
||||||
s32 base;
|
|
||||||
s32 base2;
|
|
||||||
u8 base2_offset : 4;
|
|
||||||
s8 exp : 4;
|
|
||||||
u8 neg_zero : 1;
|
|
||||||
u8 lead_digit : 1;
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ADT NODE LIMITS
|
|
||||||
* delimiter and assignment segment width is limited to 128 whitespace symbols each.
|
|
||||||
* real number limits decimal position to 128 places.
|
|
||||||
* real number exponent is limited to 64 digits.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialise an ADT object or array
|
|
||||||
*
|
|
||||||
* @param node
|
|
||||||
* @param backing Memory allocator used for descendants
|
|
||||||
* @param name Node's name
|
|
||||||
* @param is_array
|
|
||||||
* @return error code
|
|
||||||
*/
|
|
||||||
u8 adt_make_branch( ADT_Node* node, AllocatorInfo backing, char const* name, b32 is_array );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Destroy an ADT branch and its descendants
|
|
||||||
*
|
|
||||||
* @param node
|
|
||||||
* @return error code
|
|
||||||
*/
|
|
||||||
u8 adt_destroy_branch( ADT_Node* node );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialise an ADT leaf
|
|
||||||
*
|
|
||||||
* @param node
|
|
||||||
* @param name Node's name
|
|
||||||
* @param type Node's type (use zpl_adt_make_branch for container nodes)
|
|
||||||
* @return error code
|
|
||||||
*/
|
|
||||||
u8 adt_make_leaf( ADT_Node* node, char const* name, ADT_Type type );
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Fetch a node using provided URI string.
|
|
||||||
*
|
|
||||||
* This method uses a basic syntax to fetch a node from the ADT. The following features are available
|
|
||||||
* to retrieve the data:
|
|
||||||
*
|
|
||||||
* - "a/b/c" navigates through objects "a" and "b" to get to "c"
|
|
||||||
* - "arr/[foo=123]/bar" iterates over "arr" to find any object with param "foo" that matches the value "123", then gets its field called "bar"
|
|
||||||
* - "arr/3" retrieves the 4th element in "arr"
|
|
||||||
* - "arr/[apple]" retrieves the first element of value "apple" in "arr"
|
|
||||||
*
|
|
||||||
* @param node ADT node
|
|
||||||
* @param uri Locator string as described above
|
|
||||||
* @return zpl_adt_node*
|
|
||||||
*
|
|
||||||
* @see code/apps/examples/json_get.c
|
|
||||||
*/
|
|
||||||
ADT_Node* adt_query( ADT_Node* node, char const* uri );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Find a field node within an object by the given name.
|
|
||||||
*
|
|
||||||
* @param node
|
|
||||||
* @param name
|
|
||||||
* @param deep_search Perform search recursively
|
|
||||||
* @return zpl_adt_node * node
|
|
||||||
*/
|
|
||||||
ADT_Node* adt_find( ADT_Node* node, char const* name, b32 deep_search );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Allocate an unitialised node within a container at a specified index.
|
|
||||||
*
|
|
||||||
* @param parent
|
|
||||||
* @param index
|
|
||||||
* @return zpl_adt_node * node
|
|
||||||
*/
|
|
||||||
ADT_Node* adt_alloc_at( ADT_Node* parent, ssize index );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Allocate an unitialised node within a container.
|
|
||||||
*
|
|
||||||
* @param parent
|
|
||||||
* @return zpl_adt_node * node
|
|
||||||
*/
|
|
||||||
ADT_Node* adt_alloc( ADT_Node* parent );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Move an existing node to a new container at a specified index.
|
|
||||||
*
|
|
||||||
* @param node
|
|
||||||
* @param new_parent
|
|
||||||
* @param index
|
|
||||||
* @return zpl_adt_node * node
|
|
||||||
*/
|
|
||||||
ADT_Node* adt_move_node_at( ADT_Node* node, ADT_Node* new_parent, ssize index );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Move an existing node to a new container.
|
|
||||||
*
|
|
||||||
* @param node
|
|
||||||
* @param new_parent
|
|
||||||
* @return zpl_adt_node * node
|
|
||||||
*/
|
|
||||||
ADT_Node* adt_move_node( ADT_Node* node, ADT_Node* new_parent );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Swap two nodes.
|
|
||||||
*
|
|
||||||
* @param node
|
|
||||||
* @param other_node
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void adt_swap_nodes( ADT_Node* node, ADT_Node* other_node );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Remove node from container.
|
|
||||||
*
|
|
||||||
* @param node
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void adt_remove_node( ADT_Node* node );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialise a node as an object
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* @param name
|
|
||||||
* @param backing
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
b8 adt_set_obj( ADT_Node* obj, char const* name, AllocatorInfo backing );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialise a node as an array
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* @param name
|
|
||||||
* @param backing
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
b8 adt_set_arr( ADT_Node* obj, char const* name, AllocatorInfo backing );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialise a node as a string
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* @param name
|
|
||||||
* @param value
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
b8 adt_set_str( ADT_Node* obj, char const* name, char const* value );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialise a node as a float
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* @param name
|
|
||||||
* @param value
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
b8 adt_set_flt( ADT_Node* obj, char const* name, f64 value );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialise a node as a signed integer
|
|
||||||
*
|
|
||||||
* @param obj
|
|
||||||
* @param name
|
|
||||||
* @param value
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
b8 adt_set_int( ADT_Node* obj, char const* name, s64 value );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Append a new node to a container as an object
|
|
||||||
*
|
|
||||||
* @param parent
|
|
||||||
* @param name
|
|
||||||
* @return*
|
|
||||||
*/
|
|
||||||
ADT_Node* adt_append_obj( ADT_Node* parent, char const* name );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Append a new node to a container as an array
|
|
||||||
*
|
|
||||||
* @param parent
|
|
||||||
* @param name
|
|
||||||
* @return*
|
|
||||||
*/
|
|
||||||
ADT_Node* adt_append_arr( ADT_Node* parent, char const* name );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Append a new node to a container as a string
|
|
||||||
*
|
|
||||||
* @param parent
|
|
||||||
* @param name
|
|
||||||
* @param value
|
|
||||||
* @return*
|
|
||||||
*/
|
|
||||||
ADT_Node* adt_append_str( ADT_Node* parent, char const* name, char const* value );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Append a new node to a container as a float
|
|
||||||
*
|
|
||||||
* @param parent
|
|
||||||
* @param name
|
|
||||||
* @param value
|
|
||||||
* @return*
|
|
||||||
*/
|
|
||||||
ADT_Node* adt_append_flt( ADT_Node* parent, char const* name, f64 value );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Append a new node to a container as a signed integer
|
|
||||||
*
|
|
||||||
* @param parent
|
|
||||||
* @param name
|
|
||||||
* @param value
|
|
||||||
* @return*
|
|
||||||
*/
|
|
||||||
ADT_Node* adt_append_int( ADT_Node* parent, char const* name, s64 value );
|
|
||||||
|
|
||||||
/* parser helpers */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Parses a text and stores the result into an unitialised node.
|
|
||||||
*
|
|
||||||
* @param node
|
|
||||||
* @param base
|
|
||||||
* @return*
|
|
||||||
*/
|
|
||||||
char* adt_parse_number( ADT_Node* node, char* base );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Parses a text and stores the result into an unitialised node.
|
|
||||||
* This function expects the entire input to be a number.
|
|
||||||
*
|
|
||||||
* @param node
|
|
||||||
* @param base
|
|
||||||
* @return*
|
|
||||||
*/
|
|
||||||
char* adt_parse_number_strict( ADT_Node* node, char* base_str );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Parses and converts an existing string node into a number.
|
|
||||||
*
|
|
||||||
* @param node
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ADT_Error adt_c_str_to_number( ADT_Node* node );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Parses and converts an existing string node into a number.
|
|
||||||
* This function expects the entire input to be a number.
|
|
||||||
*
|
|
||||||
* @param node
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ADT_Error adt_c_str_to_number_strict( ADT_Node* node );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Prints a number into a file stream.
|
|
||||||
*
|
|
||||||
* The provided file handle can also be a memory mapped stream.
|
|
||||||
*
|
|
||||||
* @see zpl_file_stream_new
|
|
||||||
* @param file
|
|
||||||
* @param node
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ADT_Error adt_print_number( FileInfo* file, ADT_Node* node );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Prints a string into a file stream.
|
|
||||||
*
|
|
||||||
* The provided file handle can also be a memory mapped stream.
|
|
||||||
*
|
|
||||||
* @see zpl_file_stream_new
|
|
||||||
* @param file
|
|
||||||
* @param node
|
|
||||||
* @param escaped_chars
|
|
||||||
* @param escape_symbol
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ADT_Error adt_print_string( FileInfo* file, ADT_Node* node, char const* escaped_chars, char const* escape_symbol );
|
|
||||||
|
|
||||||
#pragma endregion ADT
|
|
||||||
|
|
||||||
#pragma region CSV
|
|
||||||
|
|
||||||
enum CSV_Error : u32
|
|
||||||
{
|
|
||||||
ECSV_Error__NONE,
|
|
||||||
ECSV_Error__INTERNAL,
|
|
||||||
ECSV_Error__UNEXPECTED_END_OF_INPUT,
|
|
||||||
ECSV_Error__MISMATCHED_ROWS,
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef ADT_Node CSV_Object;
|
|
||||||
|
|
||||||
u8 csv_parse( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header );
|
|
||||||
u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header, char delim );
|
|
||||||
void csv_free( CSV_Object* obj );
|
|
||||||
|
|
||||||
void csv_write( FileInfo* file, CSV_Object* obj );
|
|
||||||
StrBuilder csv_write_string( AllocatorInfo a, CSV_Object* obj );
|
|
||||||
void csv_write_delimiter( FileInfo* file, CSV_Object* obj, char delim );
|
|
||||||
StrBuilder csv_write_strbuilder_delimiter( AllocatorInfo a, CSV_Object* obj, char delim );
|
|
||||||
|
|
||||||
/* inline */
|
|
||||||
|
|
||||||
inline
|
|
||||||
u8 csv_parse( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header )
|
|
||||||
{
|
|
||||||
return csv_parse_delimiter( root, text, allocator, has_header, ',' );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
void csv_write( FileInfo* file, CSV_Object* obj )
|
|
||||||
{
|
|
||||||
csv_write_delimiter( file, obj, ',' );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
StrBuilder csv_write_string( AllocatorInfo a, CSV_Object* obj )
|
|
||||||
{
|
|
||||||
return csv_write_strbuilder_delimiter( a, obj, ',' );
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma endregion CSV
|
|
||||||
|
|
||||||
#pragma region Scanner
|
#pragma region Scanner
|
||||||
|
|
||||||
// This is a simple file reader that reads the entire file into memory.
|
// This is a simple file reader that reads the entire file into memory.
|
||||||
|
@ -39,7 +39,9 @@ Builder builder_open( char const* path )
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Buffer = strbuilder_make_reserve( _ctx->Allocator_Temp, _ctx->InitSize_BuilderBuffer );
|
Context* ctx = get_context();
|
||||||
|
GEN_ASSERT_NOT_NULL(ctx);
|
||||||
|
result.Buffer = strbuilder_make_reserve( ctx->Allocator_Temp, ctx->InitSize_BuilderBuffer );
|
||||||
|
|
||||||
// log_fmt("$Builder - Opened file: %s\n", result.File.filename );
|
// log_fmt("$Builder - Opened file: %s\n", result.File.filename );
|
||||||
return result;
|
return result;
|
||||||
|
@ -3403,6 +3403,10 @@ void deinit(Context* ctx)
|
|||||||
-- context_counter;
|
-- context_counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Context* get_context() {
|
||||||
|
return _ctx;
|
||||||
|
}
|
||||||
|
|
||||||
void reset(Context* ctx)
|
void reset(Context* ctx)
|
||||||
{
|
{
|
||||||
s32 index = 0;
|
s32 index = 0;
|
||||||
|
@ -883,7 +883,7 @@ template<typename Type> mem_ptr_const to_mem_ptr_const( Type ptr ) { return (mem
|
|||||||
// NOTE: Things that shouldn't happen with a message!
|
// NOTE: Things that shouldn't happen with a message!
|
||||||
#define GEN_PANIC( msg, ... ) GEN_ASSERT_MSG( 0, msg, ##__VA_ARGS__ )
|
#define GEN_PANIC( msg, ... ) GEN_ASSERT_MSG( 0, msg, ##__VA_ARGS__ )
|
||||||
|
|
||||||
#if GEN_BULD_DEBUG
|
#if GEN_BUILD_DEBUG
|
||||||
#define GEN_FATAL( ... ) \
|
#define GEN_FATAL( ... ) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
|
@ -886,7 +886,7 @@ inline TokType str_to_toktype( Str str )
|
|||||||
|
|
||||||
enum TokFlags : u32
|
enum TokFlags : u32
|
||||||
{
|
{
|
||||||
TF_Operator = bit(0),
|
TF_Operator = bit(0),
|
||||||
TF_Assign = bit(1),
|
TF_Assign = bit(1),
|
||||||
TF_Preprocess = bit(2),
|
TF_Preprocess = bit(2),
|
||||||
TF_Preprocess_Cond = bit(3),
|
TF_Preprocess_Cond = bit(3),
|
||||||
@ -3980,6 +3980,9 @@ GEN_API void init(Context* ctx);
|
|||||||
// However on Windows at least, it doesn't need to occur as the OS will clean up after the process.
|
// However on Windows at least, it doesn't need to occur as the OS will clean up after the process.
|
||||||
GEN_API void deinit(Context* ctx);
|
GEN_API void deinit(Context* ctx);
|
||||||
|
|
||||||
|
// Retrieves the active context (not usually needed, but here in case...)
|
||||||
|
GEN_API Context* get_contex();
|
||||||
|
|
||||||
// Clears the allocations, but doesn't free the memoery, then calls init() again.
|
// Clears the allocations, but doesn't free the memoery, then calls init() again.
|
||||||
// Ease of use.
|
// Ease of use.
|
||||||
GEN_API void reset(Context* ctx);
|
GEN_API void reset(Context* ctx);
|
||||||
|
Loading…
Reference in New Issue
Block a user