wip updating gencpp to latest
testing new library
This commit is contained in:
parent
feea8361b5
commit
6fb7aed7e8
@ -67,7 +67,7 @@ Example using each construction interface:
|
||||
Validation and construction through a functional interface.
|
||||
|
||||
```cpp
|
||||
Code t_uw = def_type( name(uw) );
|
||||
Code t_uw = def_type( name(usize) );
|
||||
Code t_allocator = def_type( name(allocator) );
|
||||
Code t_string_const = def_type( name(char), def_specifiers( args( ESpecifier::Const, ESpecifier::Ptr ) ));
|
||||
|
||||
@ -90,8 +90,8 @@ Validation through ast construction.
|
||||
Code header = parse_struct( code(
|
||||
struct ArrayHeader
|
||||
{
|
||||
uw Num;
|
||||
uw Capacity;
|
||||
usize Num;
|
||||
usize Capacity;
|
||||
allocator Allocator;
|
||||
};
|
||||
));
|
||||
@ -106,8 +106,8 @@ No validation, just glorified text injection.
|
||||
Code header = code_str(
|
||||
struct ArrayHeader
|
||||
{
|
||||
uw Num;
|
||||
uw Capacity;
|
||||
usize Num;
|
||||
usize Capacity;
|
||||
allocator Allocator;
|
||||
};
|
||||
);
|
||||
@ -123,8 +123,8 @@ All three constrcuton interfaces will generate the following C code:
|
||||
```cpp
|
||||
struct ArrayHeader
|
||||
{
|
||||
uw Num;
|
||||
uw Capacity;
|
||||
usize Num;
|
||||
usize Capacity;
|
||||
allocator Allocator;
|
||||
};
|
||||
```
|
||||
|
@ -136,7 +136,7 @@ The width dictates how much the static array can hold before it must give way to
|
||||
|
||||
```cpp
|
||||
constexpr static
|
||||
uw ArrSpecs_Cap =
|
||||
usize ArrSpecs_Cap =
|
||||
(
|
||||
AST_POD_Size
|
||||
- sizeof(AST*) * 3
|
||||
@ -158,7 +158,7 @@ Data Notes:
|
||||
* Most of the work is just defining the allocation procedure:
|
||||
|
||||
```cpp
|
||||
void* ( void* allocator_data, AllocType type, sw size, sw alignment, void* old_memory, sw old_size, u64 flags );
|
||||
void* ( void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags );
|
||||
```
|
||||
|
||||
* ASTs are wrapped for the user in a Code struct which is a wrapper for a AST* type.
|
||||
|
@ -2293,6 +2293,44 @@ struct String
|
||||
return Data[ length() - 1 ];
|
||||
}
|
||||
|
||||
bool contains(StrC substring) const
|
||||
{
|
||||
Header const& header = * rcast( Header const*, Data - sizeof( Header ));
|
||||
|
||||
if (substring.Len > header.Length)
|
||||
return false;
|
||||
|
||||
ssize main_len = header.Length;
|
||||
ssize sub_len = substring.Len;
|
||||
|
||||
for (ssize i = 0; i <= main_len - sub_len; ++i)
|
||||
{
|
||||
if (str_compare(Data + i, substring.Ptr, sub_len) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool contains(String const& substring) const
|
||||
{
|
||||
Header const& header = * rcast( Header const*, Data - sizeof( Header ));
|
||||
|
||||
if (substring.length() > header.Length)
|
||||
return false;
|
||||
|
||||
ssize main_len = header.Length;
|
||||
ssize sub_len = substring.length();
|
||||
|
||||
for (ssize i = 0; i <= main_len - sub_len; ++i)
|
||||
{
|
||||
if (str_compare(Data + i, substring.Data, sub_len) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ssize capacity() const
|
||||
{
|
||||
Header const&
|
||||
|
@ -23,9 +23,12 @@ using namespace gen;
|
||||
|
||||
int gen_main()
|
||||
{
|
||||
gen::init();
|
||||
ctx = {};
|
||||
gen::init(& ctx);
|
||||
log_fmt("Generating code for the Gasa module\n");
|
||||
|
||||
Array(StrCached)& PreprocessorDefines = ctx.PreprocessorDefines;
|
||||
|
||||
// Initialize Globals
|
||||
{
|
||||
UHT_UCLASS = code_str( UCLASS() );
|
||||
@ -37,50 +40,50 @@ int gen_main()
|
||||
|
||||
// Populate Defines
|
||||
{
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_CLASS));
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_RetVal_OneParam));
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_RetVal_ThreeParams));
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_SixParams));
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam));
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams));
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams));
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams));
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam));
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams));
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams));
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_EVENT_ThreeParams));
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_EVENT_TwoParams));
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_FUNCTION));
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_LOG_CATEGORY_EXTERN));
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_OneParam));
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_ThreeParams));
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_TwoParams));
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_TS_MULTICAST_DELEGATE_OneParam));
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_TS_MULTICAST_DELEGATE_TwoParams));
|
||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_TS_MULTICAST_DELEGATE_ThreeParams));
|
||||
PreprocessorDefines.append( get_cached_string(str_DEFINE_ACTORDESC_TYPE));
|
||||
PreprocessorDefines.append( get_cached_string(str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL));
|
||||
PreprocessorDefines.append( get_cached_string(str_ENUM_CLASS_FLAGS));
|
||||
PreprocessorDefines.append( get_cached_string(str_FORCEINLINE_DEBUGGABLE));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_CLASS));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_DELEGATE_RetVal_OneParam));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_DELEGATE_RetVal_ThreeParams));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_DELEGATE_SixParams));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_EVENT_ThreeParams));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_EVENT_TwoParams));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_FUNCTION));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_LOG_CATEGORY_EXTERN));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_MULTICAST_DELEGATE_OneParam));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_MULTICAST_DELEGATE_ThreeParams));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_MULTICAST_DELEGATE_TwoParams));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_TS_MULTICAST_DELEGATE_OneParam));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_TS_MULTICAST_DELEGATE_TwoParams));
|
||||
PreprocessorDefines.append( cache_str(str_DECLARE_TS_MULTICAST_DELEGATE_ThreeParams));
|
||||
PreprocessorDefines.append( cache_str(str_DEFINE_ACTORDESC_TYPE));
|
||||
PreprocessorDefines.append( cache_str(str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL));
|
||||
PreprocessorDefines.append( cache_str(str_ENUM_CLASS_FLAGS));
|
||||
PreprocessorDefines.append( cache_str(str_FORCEINLINE_DEBUGGABLE));
|
||||
// PreprocessorDefines.append( get_cached_string(str_FORCEINLINE));
|
||||
PreprocessorDefines.append( get_cached_string(str_GENERATED_BODY));
|
||||
PreprocessorDefines.append( get_cached_string(str_GENERATED_UCLASS_BODY));
|
||||
PreprocessorDefines.append( get_cached_string(str_GENERATED_USTRUCT_BODY));
|
||||
PreprocessorDefines.append( get_cached_string(str_PRAGMA_DISABLE_DEPRECATION_WARNINGS));
|
||||
PreprocessorDefines.append( get_cached_string(str_PRAGMA_ENABLE_DEPRECATION_WARNINGS));
|
||||
PreprocessorDefines.append( get_cached_string(str_PROPERTY_BINDING_IMPLEMENTATION));
|
||||
PreprocessorDefines.append( get_cached_string(str_RESULT_DECL));
|
||||
PreprocessorDefines.append( get_cached_string(str_SLATE_BEGIN_ARGS));
|
||||
PreprocessorDefines.append( get_cached_string(str_SLATE_END_ARGS));
|
||||
PreprocessorDefines.append( get_cached_string(str_TEXT));
|
||||
PreprocessorDefines.append( get_cached_string(str_UCLASS));
|
||||
PreprocessorDefines.append( get_cached_string(str_UENUM));
|
||||
PreprocessorDefines.append( get_cached_string(str_UFUNCTION));
|
||||
PreprocessorDefines.append( get_cached_string(str_UMETA));
|
||||
PreprocessorDefines.append( get_cached_string(str_UPARAM));
|
||||
PreprocessorDefines.append( get_cached_string(str_UPROPERTY));
|
||||
PreprocessorDefines.append( get_cached_string(str_USTRUCT));
|
||||
PreprocessorDefines.append( get_cached_string(str_UE_REQUIRES));
|
||||
PreprocessorDefines.append( cache_str(str_GENERATED_BODY));
|
||||
PreprocessorDefines.append( cache_str(str_GENERATED_UCLASS_BODY));
|
||||
PreprocessorDefines.append( cache_str(str_GENERATED_USTRUCT_BODY));
|
||||
PreprocessorDefines.append( cache_str(str_PRAGMA_DISABLE_DEPRECATION_WARNINGS));
|
||||
PreprocessorDefines.append( cache_str(str_PRAGMA_ENABLE_DEPRECATION_WARNINGS));
|
||||
PreprocessorDefines.append( cache_str(str_PROPERTY_BINDING_IMPLEMENTATION));
|
||||
PreprocessorDefines.append( cache_str(str_RESULT_DECL));
|
||||
PreprocessorDefines.append( cache_str(str_SLATE_BEGIN_ARGS));
|
||||
PreprocessorDefines.append( cache_str(str_SLATE_END_ARGS));
|
||||
PreprocessorDefines.append( cache_str(str_TEXT));
|
||||
PreprocessorDefines.append( cache_str(str_UCLASS));
|
||||
PreprocessorDefines.append( cache_str(str_UENUM));
|
||||
PreprocessorDefines.append( cache_str(str_UFUNCTION));
|
||||
PreprocessorDefines.append( cache_str(str_UMETA));
|
||||
PreprocessorDefines.append( cache_str(str_UPARAM));
|
||||
PreprocessorDefines.append( cache_str(str_UPROPERTY));
|
||||
PreprocessorDefines.append( cache_str(str_USTRUCT));
|
||||
PreprocessorDefines.append( cache_str(str_UE_REQUIRES));
|
||||
}
|
||||
|
||||
// gen_UGasaAttributeSet();
|
||||
|
@ -18,52 +18,52 @@ using namespace gen;
|
||||
#define path_gasa_game path_module_gasa "Game/"
|
||||
#define path_gasa_ui path_module_gasa "UI/"
|
||||
|
||||
constexpr StrC str_DECLARE_CLASS = txt("DECLARE_CLASS(");
|
||||
constexpr StrC str_DECLARE_DELEGATE_RetVal_OneParam = txt("DECLARE_DELEGATE_RetVal_OneParam(");
|
||||
constexpr StrC str_DECLARE_DELEGATE_RetVal_ThreeParams = txt("DECLARE_DELEGATE_RetVal_ThreeParams(");
|
||||
constexpr StrC str_DECLARE_DELEGATE_SixParams = txt("DECLARE_DELEGATE_SixParams(");
|
||||
constexpr StrC 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 StrC 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 StrC 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 StrC 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 StrC str_DECLARE_EVENT_TwoParams = txt("DECLARE_EVENT_TwoParams(");
|
||||
constexpr StrC str_DECLARE_FUNCTION = txt("DECLARE_FUNCTION(");
|
||||
constexpr StrC str_DECLARE_LOG_CATEGORY_EXTERN = txt("DECLARE_LOG_CATEGORY_EXTERN(");
|
||||
constexpr StrC str_DECLARE_MULTICAST_DELEGATE_OneParam = txt("DECLARE_MULTICAST_DELEGATE_OneParam(");
|
||||
constexpr StrC str_DECLARE_MULTICAST_DELEGATE_ThreeParams = txt("DECLARE_MULTICAST_DELEGATE_ThreeParams(");
|
||||
constexpr StrC 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 StrC 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 StrC str_DEFINE_ACTORDESC_TYPE = txt("DEFINE_ACTORDESC_TYPE(");
|
||||
constexpr StrC str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL = txt("DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(");
|
||||
constexpr StrC str_ENUM_CLASS_FLAGS = txt("ENUM_CLASS_FLAGS(");
|
||||
constexpr Str str_DECLARE_CLASS = txt("DECLARE_CLASS(");
|
||||
constexpr Str str_DECLARE_DELEGATE_RetVal_OneParam = txt("DECLARE_DELEGATE_RetVal_OneParam(");
|
||||
constexpr Str str_DECLARE_DELEGATE_RetVal_ThreeParams = txt("DECLARE_DELEGATE_RetVal_ThreeParams(");
|
||||
constexpr Str str_DECLARE_DELEGATE_SixParams = txt("DECLARE_DELEGATE_SixParams(");
|
||||
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam = txt("DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(");
|
||||
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams(");
|
||||
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams(");
|
||||
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams(");
|
||||
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(");
|
||||
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams(");
|
||||
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams(");
|
||||
constexpr Str str_DECLARE_EVENT_ThreeParams = txt("DECLARE_EVENT_ThreeParams(");
|
||||
constexpr Str str_DECLARE_EVENT_TwoParams = txt("DECLARE_EVENT_TwoParams(");
|
||||
constexpr Str str_DECLARE_FUNCTION = txt("DECLARE_FUNCTION(");
|
||||
constexpr Str str_DECLARE_LOG_CATEGORY_EXTERN = txt("DECLARE_LOG_CATEGORY_EXTERN(");
|
||||
constexpr Str str_DECLARE_MULTICAST_DELEGATE_OneParam = txt("DECLARE_MULTICAST_DELEGATE_OneParam(");
|
||||
constexpr Str str_DECLARE_MULTICAST_DELEGATE_ThreeParams = txt("DECLARE_MULTICAST_DELEGATE_ThreeParams(");
|
||||
constexpr Str str_DECLARE_MULTICAST_DELEGATE_TwoParams = txt("DECLARE_MULTICAST_DELEGATE_TwoParams(");
|
||||
constexpr Str str_DECLARE_TS_MULTICAST_DELEGATE_OneParam = txt("DECLARE_TS_MULTICAST_DELEGATE_OneParam(");
|
||||
constexpr Str str_DECLARE_TS_MULTICAST_DELEGATE_TwoParams = txt("DECLARE_TS_MULTICAST_DELEGATE_TwoParams(");
|
||||
constexpr Str str_DECLARE_TS_MULTICAST_DELEGATE_ThreeParams = txt("DECLARE_TS_MULTICAST_DELEGATE_ThreeParams(");
|
||||
constexpr Str str_DEFINE_ACTORDESC_TYPE = txt("DEFINE_ACTORDESC_TYPE(");
|
||||
constexpr Str str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL = txt("DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(");
|
||||
constexpr Str str_ENUM_CLASS_FLAGS = txt("ENUM_CLASS_FLAGS(");
|
||||
// constexpr StrC str_FORCEINLINE = txt("FORCEINLINE");
|
||||
constexpr StrC str_FORCEINLINE_DEBUGGABLE = txt("FORCEINLINE_DEBUGGABLE");
|
||||
constexpr StrC str_GENERATED_BODY = txt("GENERATED_BODY(");
|
||||
constexpr StrC str_GENERATED_UCLASS_BODY = txt("GENERATED_UCLASS_BODY(");
|
||||
constexpr StrC str_GENERATED_USTRUCT_BODY = txt("GENERATED_USTRUCT_BODY(");
|
||||
constexpr StrC str_PRAGMA_DISABLE_DEPRECATION_WARNINGS = txt("PRAGMA_DISABLE_DEPRECATION_WARNINGS");
|
||||
constexpr StrC str_PRAGMA_ENABLE_DEPRECATION_WARNINGS = txt("PRAGMA_ENABLE_DEPRECATION_WARNINGS");
|
||||
constexpr StrC str_PROPERTY_BINDING_IMPLEMENTATION = txt("PROPERTY_BINDING_IMPLEMENTATION(");
|
||||
constexpr StrC str_RESULT_DECL = txt("RESULT_DECL");
|
||||
constexpr StrC str_SLATE_BEGIN_ARGS = txt("SLATE_BEGIN_ARGS(");
|
||||
constexpr StrC str_SLATE_END_ARGS = txt("SLATE_END_ARGS(");
|
||||
constexpr StrC str_TEXT = txt("TEXT(");
|
||||
constexpr StrC str_UCLASS = txt("UCLASS(");
|
||||
constexpr StrC str_UENUM = txt("UENUM(");
|
||||
constexpr StrC str_UFUNCTION = txt("UFUNCTION(");
|
||||
constexpr StrC str_UMETA = txt("UMETA(");
|
||||
constexpr StrC str_UPARAM = txt("UPARAM(");
|
||||
constexpr StrC str_UPROPERTY = txt("UPROPERTY(");
|
||||
constexpr StrC str_USTRUCT = txt("USTRUCT(");
|
||||
constexpr StrC str_UE_REQUIRES = txt("UE_REQUIRES(");
|
||||
constexpr Str str_FORCEINLINE_DEBUGGABLE = txt("FORCEINLINE_DEBUGGABLE");
|
||||
constexpr Str str_GENERATED_BODY = txt("GENERATED_BODY(");
|
||||
constexpr Str str_GENERATED_UCLASS_BODY = txt("GENERATED_UCLASS_BODY(");
|
||||
constexpr Str str_GENERATED_USTRUCT_BODY = txt("GENERATED_USTRUCT_BODY(");
|
||||
constexpr Str str_PRAGMA_DISABLE_DEPRECATION_WARNINGS = txt("PRAGMA_DISABLE_DEPRECATION_WARNINGS");
|
||||
constexpr Str str_PRAGMA_ENABLE_DEPRECATION_WARNINGS = txt("PRAGMA_ENABLE_DEPRECATION_WARNINGS");
|
||||
constexpr Str str_PROPERTY_BINDING_IMPLEMENTATION = txt("PROPERTY_BINDING_IMPLEMENTATION(");
|
||||
constexpr Str str_RESULT_DECL = txt("RESULT_DECL");
|
||||
constexpr Str str_SLATE_BEGIN_ARGS = txt("SLATE_BEGIN_ARGS(");
|
||||
constexpr Str str_SLATE_END_ARGS = txt("SLATE_END_ARGS(");
|
||||
constexpr Str str_TEXT = txt("TEXT(");
|
||||
constexpr Str str_UCLASS = txt("UCLASS(");
|
||||
constexpr Str str_UENUM = txt("UENUM(");
|
||||
constexpr Str str_UFUNCTION = txt("UFUNCTION(");
|
||||
constexpr Str str_UMETA = txt("UMETA(");
|
||||
constexpr Str str_UPARAM = txt("UPARAM(");
|
||||
constexpr Str str_UPROPERTY = txt("UPROPERTY(");
|
||||
constexpr Str str_USTRUCT = txt("USTRUCT(");
|
||||
constexpr Str str_UE_REQUIRES = txt("UE_REQUIRES(");
|
||||
|
||||
constexpr StrC str_GASA_API = txt("GASA_API");
|
||||
constexpr Str str_GASA_API = txt("GASA_API");
|
||||
|
||||
#pragma region Globals
|
||||
// These Code objects are created before anything else after gencpp does its initializatioon
|
||||
@ -74,10 +74,12 @@ global Code UHT_USTRUCT;
|
||||
global Code UModule_GASA_API;
|
||||
#pragma endregion Globals
|
||||
|
||||
global Context ctx;
|
||||
|
||||
inline
|
||||
CodeBody parse_file( char const* path ) {
|
||||
FileContents content = file_read_contents( GlobalAllocator, true, path );
|
||||
CodeBody code = parse_global_body( StrC { content.size, (char const*)content.data });
|
||||
FileContents content = file_read_contents( ctx.Allocator_Temp, file_zero_terminate, path );
|
||||
CodeBody code = parse_global_body( Str {(char const*)content.data, content.size });
|
||||
return code;
|
||||
}
|
||||
|
||||
@ -92,7 +94,7 @@ void format_file( char const* path )
|
||||
#define cf_format_inplace "-i "
|
||||
#define cf_style "-style=file:" "./scripts/.clang-format "
|
||||
#define cf_verbose "-verbose "
|
||||
String command = String::make( GlobalAllocator, clang_format );
|
||||
StrBuilder command = StrBuilder::make( ctx.Allocator_Temp, clang_format );
|
||||
command.append( cf_format_inplace );
|
||||
command.append( cf_style );
|
||||
command.append( cf_verbose );
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "GasaGenCommon.cpp"
|
||||
#endif
|
||||
|
||||
constexpr StrC SBlueprintActionMenu_Construct_Replacement = txt(R"(
|
||||
constexpr Str SBlueprintActionMenu_Construct_Replacement = txt(R"(
|
||||
void SBlueprintActionMenu::Construct( const FArguments& InArgs, TSharedPtr<FBlueprintEditor> InEditor )
|
||||
{
|
||||
bActionExecuted = false;
|
||||
@ -249,23 +249,22 @@ void swap_SBlueprintActionMenu_Construct()
|
||||
#define path_SBlueprintActionMenuCpp \
|
||||
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Editor\Kismet\Private\SBlueprintActionMenu.cpp)"
|
||||
|
||||
FileContents content = file_read_contents( GlobalAllocator, true, path_SBlueprintActionMenuCpp );
|
||||
CodeBody parsed_SBlueprintActionMenu = parse_global_body( StrC { content.size, (char const*)content.data });
|
||||
FileContents content = file_read_contents( ctx.Allocator_Temp, true, path_SBlueprintActionMenuCpp );
|
||||
CodeBody parsed_SBlueprintActionMenu = parse_global_body( Str { (char const*)content.data, content.size });
|
||||
|
||||
CodeFn signature_to_change = parse_function( code(
|
||||
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 )
|
||||
{
|
||||
switch ( code->Type )
|
||||
{
|
||||
using namespace ECode;
|
||||
case Function:
|
||||
CodeFn function_def = code.cast<CodeFn>();
|
||||
case CT_Function:
|
||||
CodeFn function_def = cast(CodeFn, code);
|
||||
|
||||
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))
|
||||
{
|
||||
code = parse_function( SBlueprintActionMenu_Construct_Replacement );
|
||||
|
@ -10,36 +10,36 @@ using namespace gen;
|
||||
|
||||
void gen_FGasaDevOptionsCache()
|
||||
{
|
||||
Array<CodeVar> GasaDevOptions_UPROPERTIES = Array<CodeVar>::init(GlobalAllocator);
|
||||
Array<CodeVar> GasaDevOptions_UPROPERTIES = Array<CodeVar>::init(ctx.Allocator_Temp);
|
||||
{
|
||||
CodeBody header_GasaDevOptions = parse_file( path_module_gasa "GasaDevOptions.h" );
|
||||
CodeClass UGasaDevOptions = NoCode;
|
||||
CodeClass UGasaDevOptions = NullCode;
|
||||
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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
if ( member->Type == ECode::Variable
|
||||
if ( member->Type == CT_Variable
|
||||
&& ( member->ValueType->Name.starts_with( txt("TArray< TSoftObjectPtr"))
|
||||
|| member->ValueType->Name.starts_with( txt("TSoftClassPtr"))
|
||||
|| 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"));
|
||||
|
||||
CodeType t_UClassPtr = parse_type(code(UClass*));
|
||||
CodeType t_UObjectPtr = parse_type(code(UObject*));
|
||||
CodeType t_Array_UObjectPtr = parse_type(code(TArray< UObject* >));
|
||||
CodeTypename t_UClassPtr = parse_type(code(UClass*));
|
||||
CodeTypename t_UObjectPtr = parse_type(code(UObject*));
|
||||
CodeTypename t_Array_UObjectPtr = parse_type(code(TArray< UObject* >));
|
||||
|
||||
Builder header = Builder::open( path_module_gasa "GasaDevOptionsCache.h" );
|
||||
{
|
||||
@ -52,7 +52,7 @@ void gen_FGasaDevOptionsCache()
|
||||
header.print( UHT_USTRUCT );
|
||||
CodeStruct FGasaDevOptionsCache;
|
||||
{
|
||||
CodeBody body = def_body(ECode::Struct_Body);
|
||||
CodeBody body = def_body(CT_Struct_Body);
|
||||
{
|
||||
body.append(UHT_GENERATED_BODY);
|
||||
body.append(fmt_newline);
|
||||
@ -74,7 +74,7 @@ void gen_FGasaDevOptionsCache()
|
||||
body.append(fmt_newline);
|
||||
body.append( parse_function(code( void CachedDevOptions(); )));
|
||||
}
|
||||
FGasaDevOptionsCache = parse_struct( token_fmt( "body", (StrC)body.to_string(), stringize(
|
||||
FGasaDevOptionsCache = parse_struct( token_fmt( "body", (Str)body.to_strbuilder(), stringize(
|
||||
struct GASA_API FGasaDevOptionsCache {
|
||||
<body>
|
||||
};
|
||||
@ -88,13 +88,13 @@ void gen_FGasaDevOptionsCache()
|
||||
|
||||
Builder source = Builder::open( path_module_gasa "GasaDevOptionsCache.cpp" );
|
||||
{
|
||||
Array<CodeInclude> GasaDevOptions_Includes = Array<CodeInclude>::init(GlobalAllocator);
|
||||
Array<CodeInclude> GasaDevOptions_Includes = Array<CodeInclude>::init(ctx.Allocator_Temp);
|
||||
{
|
||||
CodeBody source_GasaDevOptions = parse_file( path_module_gasa "GasaDevOptions.cpp");
|
||||
for ( Code entry : source_GasaDevOptions )
|
||||
{
|
||||
if ( entry->Type == ECode::Preprocess_Include )
|
||||
GasaDevOptions_Includes.append( entry.cast<CodeInclude>() );
|
||||
if ( entry->Type == CT_Preprocess_Include )
|
||||
GasaDevOptions_Includes.append( cast(CodeInclude, entry) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,17 +107,17 @@ void gen_FGasaDevOptionsCache()
|
||||
source.print( parse_using(code( using namespace Gasa; )));
|
||||
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);
|
||||
for (CodeVar var : GasaDevOptions_UPROPERTIES)
|
||||
{
|
||||
if ( var->ValueType.to_string().starts_with(txt("TArray")) )
|
||||
if ( var->ValueType.to_strbuilder().starts_with(txt("TArray")) )
|
||||
{
|
||||
#pragma push_macro("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> )
|
||||
{
|
||||
<property_array>.Push( entry.LoadSynchronous() );
|
||||
@ -134,7 +134,7 @@ void gen_FGasaDevOptionsCache()
|
||||
|
||||
#pragma push_macro("TEXT")
|
||||
#undef TEXT
|
||||
Code assignment = code_fmt( "property", (StrC)var->Name, stringize(
|
||||
Code assignment = code_fmt( "property", var->Name, stringize(
|
||||
<property> = DevOpts-> <property>.LoadSynchronous();
|
||||
ensureMsgf(<property> != nullptr, TEXT("<property> is null, DO NOT RUN PIE or else you may get a crash if not handled in BP or C++"));
|
||||
));
|
||||
@ -146,7 +146,7 @@ void gen_FGasaDevOptionsCache()
|
||||
}
|
||||
|
||||
CodeFn CachedDevOptions = parse_function( token_fmt(
|
||||
"cached_property_assignments", (StrC)cached_property_assignments.to_string(),
|
||||
"cached_property_assignments", (Str)cached_property_assignments.to_strbuilder(),
|
||||
stringize(
|
||||
void FGasaDevOptionsCache::CachedDevOptions()
|
||||
{
|
||||
|
@ -13,10 +13,10 @@ void gen_UHostWidgetController()
|
||||
|
||||
CodeBody ori_HostWidgetController_header = parse_file(path_gasa_ui "HostWidgetController.h");
|
||||
{
|
||||
CodeBody header_body = def_body(ECode::Global_Body);
|
||||
CodeBody header_body = def_body(CT_Global_Body);
|
||||
|
||||
StrC str_UHostWidgetController = txt("UHostWidgetController");
|
||||
CodeClass ori_UHostWidgetController = NoCode;
|
||||
Str str_UHostWidgetController = txt("UHostWidgetController");
|
||||
CodeClass ori_UHostWidgetController = NullCode;
|
||||
|
||||
Code file_code = ori_HostWidgetController_header.begin();
|
||||
for ( ; file_code != ori_HostWidgetController_header.end(); ++ file_code )
|
||||
@ -30,14 +30,14 @@ void gen_UHostWidgetController()
|
||||
header_body.append(file_code);
|
||||
continue;
|
||||
|
||||
case ECode::Class:
|
||||
case CT_Class:
|
||||
if ( ! file_code->Name.starts_with(str_UHostWidgetController))
|
||||
continue;
|
||||
ori_UHostWidgetController = file_code.cast<CodeClass>();
|
||||
ori_UHostWidgetController = cast(CodeClass, file_code);
|
||||
++ file_code;
|
||||
goto found;
|
||||
|
||||
case ECode::Preprocess_Include:
|
||||
case CT_Preprocess_Include:
|
||||
header_body.append(file_code);
|
||||
|
||||
if ( file_code->Content.starts_with(txt("HostWidgetController.generated.h")))
|
||||
@ -47,7 +47,7 @@ void gen_UHostWidgetController()
|
||||
}
|
||||
continue;
|
||||
|
||||
case ECode::Untyped:
|
||||
case CT_Untyped:
|
||||
header_body.append(file_code);
|
||||
|
||||
if (file_code->Content.starts_with( txt("DECLARE_"))
|
||||
@ -58,7 +58,7 @@ void gen_UHostWidgetController()
|
||||
}
|
||||
}
|
||||
|
||||
CodeBody attribute_events = def_body(ECode::Class_Body);
|
||||
CodeBody attribute_events = def_body(CT_Class_Body);
|
||||
{
|
||||
attribute_events.append( def_comment( txt("Attribute Events are generated by GasaGen/GasaGen_HostWidgetController.cpp")));
|
||||
attribute_events.append(fmt_newline);
|
||||
@ -72,23 +72,23 @@ void gen_UHostWidgetController()
|
||||
));
|
||||
attribute_events.append(fmt_newline);
|
||||
attribute_events.append( parse_variable(
|
||||
token_fmt( "field", (StrC) attribute_field.Name, stringize( FAttributeChangedSig Event_On<field>Changed; ))
|
||||
token_fmt( "field", attribute_field.Name, stringize( FAttributeChangedSig Event_On<field>Changed; ))
|
||||
));
|
||||
attribute_events.append(fmt_newline);
|
||||
}
|
||||
|
||||
for ( s32 id = 0; id < attribute_fields.num(); ++id )
|
||||
{
|
||||
StringCached attribute_field = attribute_fields[id].Name;
|
||||
StrCached attribute_field = attribute_fields[id].Name;
|
||||
|
||||
attribute_events.append( parse_function(
|
||||
token_fmt( "field", (StrC) attribute_field, stringize( void <field>Changed(FOnAttributeChangeData const& Data); ))
|
||||
token_fmt( "field", attribute_field, stringize( void <field>Changed(FOnAttributeChangeData const& Data); ))
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
CodeClass new_UHostWidgetController = ori_UHostWidgetController.duplicate().cast<CodeClass>();
|
||||
CodeBody new_body = def_body(ECode::Class_Body);
|
||||
CodeClass new_UHostWidgetController = cast(CodeClass, ori_UHostWidgetController.duplicate());
|
||||
CodeBody new_body = def_body(CT_Class_Body);
|
||||
for (Code code = ori_UHostWidgetController->Body.begin();
|
||||
code != ori_UHostWidgetController->Body.end();
|
||||
++ code )
|
||||
@ -99,7 +99,7 @@ void gen_UHostWidgetController()
|
||||
new_body.append(code);
|
||||
continue;
|
||||
|
||||
case ECode::Preprocess_Pragma:
|
||||
case CT_Preprocess_Pragma:
|
||||
{
|
||||
local_persist bool found = false;
|
||||
if (found)
|
||||
@ -108,7 +108,7 @@ void gen_UHostWidgetController()
|
||||
continue;
|
||||
}
|
||||
|
||||
CodePragma pragma = code.cast<CodePragma>();
|
||||
CodePragma pragma = cast(CodePragma, code);
|
||||
if ( pragma->Content.starts_with(txt("region Attribute Events")) )
|
||||
{
|
||||
new_body.append(pragma);
|
||||
@ -116,7 +116,7 @@ void gen_UHostWidgetController()
|
||||
|
||||
new_body.append(attribute_events);
|
||||
|
||||
while (code->Type != ECode::Preprocess_Pragma
|
||||
while (code->Type != CT_Preprocess_Pragma
|
||||
|| ! code->Content.starts_with(txt("endregion Attribute Events")))
|
||||
++ code;
|
||||
|
||||
@ -126,7 +126,7 @@ void gen_UHostWidgetController()
|
||||
}
|
||||
break;
|
||||
|
||||
case ECode::Untyped:
|
||||
case CT_Untyped:
|
||||
new_body.append(code);
|
||||
|
||||
if (code->Content.starts_with( txt("GENERATED_BODY")))
|
||||
@ -150,20 +150,20 @@ void gen_UHostWidgetController()
|
||||
|
||||
CodeBody ori_HostWidgetController_source = parse_file(path_gasa_ui "HostWidgetController.cpp");
|
||||
{
|
||||
CodeBody source_body = def_body(ECode::Global_Body);
|
||||
CodeBody source_body = def_body(CT_Global_Body);
|
||||
|
||||
CodeFn BroadcastInitialValues = NoCode;
|
||||
CodeFn BroadcastInitialValues = NullCode;
|
||||
{
|
||||
CodeBody broadcast_calls = def_body(ECode::Function_Body);
|
||||
CodeBody broadcast_calls = def_body(CT_Function_Body);
|
||||
for (GAS_AttributeEntry field : attribute_fields)
|
||||
{
|
||||
broadcast_calls.append( code_fmt( "field", (StrC)field.Name,
|
||||
broadcast_calls.append( code_fmt( "field", field.Name,
|
||||
stringize( Event_On<field>Changed.Broadcast( GasaAttribs->Get<field>() ); )
|
||||
));
|
||||
}
|
||||
|
||||
BroadcastInitialValues = parse_function( token_fmt(
|
||||
"broadcast_calls", (StrC)broadcast_calls.to_string(),
|
||||
"broadcast_calls", (Str)broadcast_calls.to_strbuilder(),
|
||||
"generation_notice", txt("\n// This function is managed by: GenGasa/GenGasa_HostWidgetController.cpp\n\n"),
|
||||
stringize(
|
||||
void UHostWidgetController::BroadcastInitialValues()
|
||||
@ -181,14 +181,14 @@ void gen_UHostWidgetController()
|
||||
));
|
||||
}
|
||||
|
||||
CodeFn BindCallbacksToDependencies = NoCode;
|
||||
CodeFn BindCallbacksToDependencies = NullCode;
|
||||
{
|
||||
CodeBody bindings = def_body(ECode::Function_Body);
|
||||
CodeBody bindings = def_body(CT_Function_Body);
|
||||
bindings.append(fmt_newline);
|
||||
bindings.append(fmt_newline);
|
||||
for (GAS_AttributeEntry field : attribute_fields)
|
||||
{
|
||||
bindings.append( code_fmt( "field", (StrC)field.Name,
|
||||
bindings.append( code_fmt( "field", field.Name,
|
||||
stringize(
|
||||
FOnGameplayAttributeValueChange& <field>AttributeChangedDelegate = AbilitySystem->GetGameplayAttributeValueChangeDelegate(GasaAttribs->Get<field>Attribute());
|
||||
<field>AttributeChangedDelegate.AddUObject(this, &ThisClass::<field>Changed);
|
||||
@ -199,7 +199,7 @@ void gen_UHostWidgetController()
|
||||
|
||||
BindCallbacksToDependencies = parse_function( token_fmt(
|
||||
"generation_notice", txt("\n// This function is managed by: GenGasa/GenGasa_HostWidgetController.cpp\n\n"),
|
||||
"bindings", (StrC)bindings.to_string(),
|
||||
"bindings", (Str)bindings.to_strbuilder(),
|
||||
stringize(
|
||||
void UHostWidgetController::BindCallbacksToDependencies()
|
||||
{
|
||||
@ -215,17 +215,17 @@ void gen_UHostWidgetController()
|
||||
));
|
||||
}
|
||||
|
||||
CodeBody attribute_callbacks = def_body(ECode::Global_Body);
|
||||
CodeBody attribute_callbacks = def_body(CT_Global_Body);
|
||||
{
|
||||
attribute_callbacks.append( def_comment(txt("Attribute Changed Callbacks are generated by GasaGen/GasaGen_HostWidgetController.cpp")));
|
||||
attribute_callbacks.append(fmt_newline);
|
||||
|
||||
for ( s32 id = 0; id < attribute_fields.num(); )
|
||||
{
|
||||
StringCached attribute_field = attribute_fields[id].Name;
|
||||
StrCached attribute_field = attribute_fields[id].Name;
|
||||
|
||||
attribute_callbacks.append( parse_function( token_fmt(
|
||||
"field", (StrC) attribute_field,
|
||||
"field", (Str) attribute_field,
|
||||
stringize(
|
||||
void UHostWidgetController::<field>Changed(FOnAttributeChangeData const& Attribute)
|
||||
{
|
||||
@ -248,7 +248,7 @@ void gen_UHostWidgetController()
|
||||
{
|
||||
switch (code->Type)
|
||||
{
|
||||
case ECode::Preprocess_Pragma:
|
||||
case CT_Preprocess_Pragma:
|
||||
{
|
||||
local_persist bool found = false;
|
||||
if (found)
|
||||
@ -258,7 +258,7 @@ void gen_UHostWidgetController()
|
||||
continue;
|
||||
}
|
||||
|
||||
CodePragma pragma = code.cast<CodePragma>();
|
||||
CodePragma pragma = cast(CodePragma, code);
|
||||
if ( pragma->Content.starts_with(txt("region Attribute Changed Callbacks")) )
|
||||
{
|
||||
source_body.append(fmt_newline);
|
||||
@ -267,7 +267,7 @@ void gen_UHostWidgetController()
|
||||
|
||||
source_body.append(attribute_callbacks);
|
||||
|
||||
while (code->Type != ECode::Preprocess_Pragma
|
||||
while (code->Type != CT_Preprocess_Pragma
|
||||
|| ! code->Content.starts_with(txt("endregion Attribute Changed Callbacks")))
|
||||
++ code;
|
||||
|
||||
@ -276,17 +276,17 @@ void gen_UHostWidgetController()
|
||||
}
|
||||
break;
|
||||
|
||||
case ECode::Function:
|
||||
CodeFn function_def = code.cast<CodeFn>();
|
||||
case CT_Function:
|
||||
CodeFn function_def = cast(CodeFn, code);
|
||||
|
||||
if ( String::are_equal(function_def->Name, BroadcastInitialValues->Name)
|
||||
if ( str_are_equal(function_def->Name, BroadcastInitialValues->Name)
|
||||
&& function_def->Params.is_equal(BroadcastInitialValues->Params))
|
||||
{
|
||||
source_body.append(BroadcastInitialValues);
|
||||
log_fmt("Swapped: %S\n", BroadcastInitialValues->Name);
|
||||
continue;
|
||||
}
|
||||
else if (String::are_equal(function_def->Name, BindCallbacksToDependencies->Name)
|
||||
else if (str_are_equal(function_def->Name, BindCallbacksToDependencies->Name)
|
||||
&& function_def->Params.is_equal(BindCallbacksToDependencies->Params))
|
||||
{
|
||||
source_body.append(BindCallbacksToDependencies);
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
void gen_netslime_interface(CodeClass aclass)
|
||||
{
|
||||
CodeBody net_slime_class_interface = def_body(ECode::Class_Body);
|
||||
CodeBody net_slime_class_interface = def_body(CT_Class_Body);
|
||||
{
|
||||
#pragma push_macro("FORCEINLINE")
|
||||
#undef FORCEINLINE
|
||||
@ -44,7 +44,7 @@ void gen_netslime_interface(CodeClass aclass)
|
||||
net_slime_class_interface.append(NetLog);
|
||||
}
|
||||
|
||||
CodeBody new_body = def_body(ECode::Class_Body);
|
||||
CodeBody new_body = def_body(CT_Class_Body);
|
||||
for(Code code = aclass->Body.begin(); code != aclass->Body.end(); ++ code )
|
||||
{
|
||||
switch (code->Type)
|
||||
@ -55,7 +55,7 @@ void gen_netslime_interface(CodeClass aclass)
|
||||
|
||||
// TODO(Ed): Could this be turned into a singly? void find_and_swap_region_pragma(CodeClass, StrC region)
|
||||
// IT could return void if its assumed that the Code passed will have destructive edits to the body.
|
||||
case ECode::Preprocess_Pragma:
|
||||
case CT_Preprocess_Pragma:
|
||||
{
|
||||
local_persist bool found = false;
|
||||
if (found || ! code->Content.starts_with( txt("region NetSlime")))
|
||||
@ -71,7 +71,7 @@ void gen_netslime_interface(CodeClass aclass)
|
||||
new_body.append( def_comment( txt("NetSlime interface is generated by GasaGen/GasaGen_NetSlime.cpp")));
|
||||
new_body.append(net_slime_class_interface);
|
||||
|
||||
while (code->Type != ECode::Preprocess_Pragma
|
||||
while (code->Type != CT_Preprocess_Pragma
|
||||
|| ! code->Content.starts_with(txt("endregion NetSlime")))
|
||||
++ code;
|
||||
|
||||
@ -85,23 +85,23 @@ void gen_netslime_interface(CodeClass aclass)
|
||||
|
||||
void gen_netslime_interfaces()
|
||||
{
|
||||
Array<StringCached> header_paths = Array<StringCached>::init_reserve(GlobalAllocator, 32);
|
||||
Array<StrCached> header_paths = Array<StrCached>::init_reserve(ctx.Allocator_Temp, 32);
|
||||
// header_paths.append(get_cached_string(txt( path_module_gasa "GasaObject.h")));
|
||||
// header_paths.append(get_cached_string(txt( path_gasa_actors "GasaActor.h")));
|
||||
// header_paths.append(get_cached_string(txt( path_gasa_characters "GasaCharacter.h")));
|
||||
// header_paths.append(get_cached_string(txt( path_gasa_game "GasaGameMode.h")));
|
||||
// header_paths.append(get_cached_string(txt( path_gasa_game "GasaGameState.h")));
|
||||
|
||||
for (StringCached path : header_paths)
|
||||
for (StrCached path : header_paths)
|
||||
{
|
||||
CodeBody original_header = parse_file(path);
|
||||
CodeBody header_body = def_body(ECode::Global_Body);
|
||||
CodeBody header_body = def_body(CT_Global_Body);
|
||||
for (Code code : original_header)
|
||||
{
|
||||
switch (code->Type) {
|
||||
case ECode::Class:
|
||||
case CT_Class:
|
||||
{
|
||||
CodeClass aclass = code.cast<CodeClass>();
|
||||
CodeClass aclass = cast(CodeClass, code);
|
||||
gen_netslime_interface(aclass);
|
||||
header_body.append(aclass);
|
||||
}
|
||||
|
@ -9,35 +9,35 @@
|
||||
|
||||
struct GAS_AttributeEntry
|
||||
{
|
||||
StringCached Name;
|
||||
StrCached Name;
|
||||
// StringCached Description;
|
||||
// StringCached Category;
|
||||
StringCached MinName;
|
||||
StringCached MaxName;
|
||||
StrCached MinName;
|
||||
StrCached MaxName;
|
||||
float Min;
|
||||
float Max;
|
||||
};
|
||||
|
||||
void def_attribute_properties ( CodeBody body, Array<GAS_AttributeEntry> properties );
|
||||
void def_attribute_field_on_reps ( CodeBody body, Array<GAS_AttributeEntry> properties );
|
||||
void def_attribute_field_property_getters ( CodeBody body, StrC class_name, Array<GAS_AttributeEntry> properties );
|
||||
void def_attribute_field_property_getters ( CodeBody body, Str class_name, Array<GAS_AttributeEntry> properties );
|
||||
void def_attribute_field_value_getters ( CodeBody body, Array<GAS_AttributeEntry> properties );
|
||||
void def_attribute_field_value_setters ( CodeBody body, Array<GAS_AttributeEntry> properties );
|
||||
void def_attribute_field_property_setter_inlines( CodeBody body, StrC class_name, Array<GAS_AttributeEntry> properties );
|
||||
void def_attribute_field_property_setter_inlines( CodeBody body, Str class_name, Array<GAS_AttributeEntry> properties );
|
||||
void def_attribute_field_initers ( CodeBody body, Array<GAS_AttributeEntry> properties );
|
||||
void impl_attribute_fields ( CodeBody body, StrC class_name, Array<GAS_AttributeEntry> properties );
|
||||
void impl_attribute_fields ( CodeBody body, Str class_name, Array<GAS_AttributeEntry> properties );
|
||||
|
||||
Array<GAS_AttributeEntry> get_gasa_primary_attribute_fields()
|
||||
{
|
||||
local_persist
|
||||
Array<GAS_AttributeEntry> attribute_fields = Array<GAS_AttributeEntry>::init_reserve(GlobalAllocator, 64);
|
||||
Array<GAS_AttributeEntry> attribute_fields = Array<GAS_AttributeEntry>::init_reserve(ctx.Allocator_Temp, 64);
|
||||
|
||||
for (local_persist s32 do_once = 0; do_once == 0; ++ do_once)
|
||||
{
|
||||
StringCached str_Strength = get_cached_string(txt("Strength"));
|
||||
StringCached str_Intelligence = get_cached_string(txt("Intelligence"));
|
||||
StringCached str_Resilience = get_cached_string(txt("Resilience"));
|
||||
StringCached str_Vigor = get_cached_string(txt("Vigor"));
|
||||
StrCached str_Strength = cache_str(txt("Strength"));
|
||||
StrCached str_Intelligence = cache_str(txt("Intelligence"));
|
||||
StrCached str_Resilience = cache_str(txt("Resilience"));
|
||||
StrCached str_Vigor = cache_str(txt("Vigor"));
|
||||
|
||||
GAS_AttributeEntry Strength = { str_Strength, {nullptr}, {nullptr}, 0, 999.f };
|
||||
GAS_AttributeEntry Intelligence = { str_Intelligence, {nullptr}, {nullptr}, 0, 999.f };
|
||||
@ -55,14 +55,14 @@ Array<GAS_AttributeEntry> get_gasa_primary_attribute_fields()
|
||||
Array<GAS_AttributeEntry> get_gasa_secondary_attribute_fields()
|
||||
{
|
||||
local_persist
|
||||
Array<GAS_AttributeEntry> attribute_fields = Array<GAS_AttributeEntry>::init_reserve(GlobalAllocator, 64);
|
||||
Array<GAS_AttributeEntry> attribute_fields = Array<GAS_AttributeEntry>::init_reserve(ctx.Allocator_Temp, 64);
|
||||
|
||||
for (local_persist s32 do_once = 0; do_once == 0; ++ do_once)
|
||||
{
|
||||
// StringCached str_Strength = get_cached_string(txt("Strength"));
|
||||
// StringCached str_Intelligence = get_cached_string(txt("Intelligence"));
|
||||
// StringCached str_Resilience = get_cached_string(txt("Resilience"));
|
||||
// StringCached str_Vigor = get_cached_string(txt("Vigor"));
|
||||
// StrCached str_Strength = cache_str(txt("Strength"));
|
||||
// StrCached str_Intelligence = cache_str(txt("Intelligence"));
|
||||
// StrCached str_Resilience = cache_str(txt("Resilience"));
|
||||
// StrCached str_Vigor = cache_str(txt("Vigor"));
|
||||
//
|
||||
// GAS_AttributeEntry Health = { str_Health, {nullptr}, str_MaxHealth, 0, 100.f };
|
||||
// GAS_AttributeEntry MaxHealth = { str_MaxHealth, {nullptr}, {nullptr}, 0, 99999.f };
|
||||
@ -75,14 +75,14 @@ Array<GAS_AttributeEntry> get_gasa_secondary_attribute_fields()
|
||||
Array<GAS_AttributeEntry> get_gasa_vital_attribute_fields()
|
||||
{
|
||||
local_persist
|
||||
Array<GAS_AttributeEntry> attribute_fields = Array<GAS_AttributeEntry>::init_reserve(GlobalAllocator, 64);
|
||||
Array<GAS_AttributeEntry> attribute_fields = Array<GAS_AttributeEntry>::init_reserve(ctx.Allocator_Temp, 64);
|
||||
|
||||
for (local_persist s32 do_once = 0; do_once == 0; ++ do_once)
|
||||
{
|
||||
StringCached str_Health = get_cached_string(txt("Health"));
|
||||
StringCached str_MaxHealth = get_cached_string(txt("MaxHealth"));
|
||||
StringCached str_Mana = get_cached_string(txt("Mana"));
|
||||
StringCached str_MaxMana = get_cached_string(txt("MaxMana"));
|
||||
StrCached str_Health = cache_str(txt("Health"));
|
||||
StrCached str_MaxHealth = cache_str(txt("MaxHealth"));
|
||||
StrCached str_Mana = cache_str(txt("Mana"));
|
||||
StrCached str_MaxMana = cache_str(txt("MaxMana"));
|
||||
|
||||
GAS_AttributeEntry Health = { str_Health, {nullptr}, str_MaxHealth, 0, 100.f };
|
||||
GAS_AttributeEntry MaxHealth = { str_MaxHealth, {nullptr}, {nullptr}, 0, 99999.f };
|
||||
@ -99,7 +99,7 @@ Array<GAS_AttributeEntry> get_gasa_vital_attribute_fields()
|
||||
|
||||
void gen_UGasaAttributeSet()
|
||||
{
|
||||
CodeType type_UAttributeSet = def_type( txt("UAttributeSet") );
|
||||
CodeTypename type_UAttributeSet = def_type( txt("UAttributeSet") );
|
||||
CodeComment generation_notice = def_comment(txt("Generated by GasaGen/GasaGen_UGasaAttributeSet.cpp"));
|
||||
|
||||
Array<GAS_AttributeEntry> primary_attribute_fields = get_gasa_primary_attribute_fields();
|
||||
@ -109,12 +109,12 @@ void gen_UGasaAttributeSet()
|
||||
s32 all_attrib_count = primary_attribute_fields.num() + secondary_attribute_fields.num() + vital_attribute_fields.num();
|
||||
|
||||
Array< GAS_AttributeEntry>
|
||||
all_attribute_fields = Array<GAS_AttributeEntry>::init_reserve(GlobalAllocator, all_attrib_count);
|
||||
all_attribute_fields = Array<GAS_AttributeEntry>::init_reserve(ctx.Allocator_Temp, all_attrib_count);
|
||||
all_attribute_fields.append( primary_attribute_fields);
|
||||
all_attribute_fields.append( secondary_attribute_fields);
|
||||
all_attribute_fields.append( vital_attribute_fields);
|
||||
|
||||
StrC class_name = txt("UGasaAttributeSet");
|
||||
Str class_name = txt("UGasaAttributeSet");
|
||||
|
||||
Builder header = Builder::open( path_gasa_ability_system "GasaAttributeSet.h");
|
||||
{
|
||||
@ -132,7 +132,7 @@ void gen_UGasaAttributeSet()
|
||||
|
||||
CodeClass GasaAttributeSet = {};
|
||||
{
|
||||
CodeBody body = def_body( CodeT::Class_Body );
|
||||
CodeBody body = def_body( CT_Class_Body );
|
||||
{
|
||||
body.append( UHT_GENERATED_BODY);
|
||||
body.append( access_public );
|
||||
@ -201,9 +201,9 @@ void gen_UGasaAttributeSet()
|
||||
body.append( GetLifetimeOfReplicatedProps );
|
||||
body.append( def_pragma( txt("endregion UObject")));
|
||||
}
|
||||
GasaAttributeSet = def_class( class_name, body
|
||||
, type_UAttributeSet, AccessSpec::Public
|
||||
, api_attribute
|
||||
GasaAttributeSet = def_class( class_name, { body
|
||||
, type_UAttributeSet, AccessSpec_Public
|
||||
, api_attribute }
|
||||
);
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ void gen_UGasaAttributeSet()
|
||||
inlines.print( def_include(txt("AbilitySystemComponent.h")));
|
||||
inlines.print(fmt_newline);
|
||||
|
||||
CodeBody body = def_body(CodeT::Global_Body);
|
||||
CodeBody body = def_body(CT_Global_Body);
|
||||
{
|
||||
def_attribute_field_property_setter_inlines( body, class_name, all_attribute_fields );
|
||||
}
|
||||
@ -259,7 +259,7 @@ void gen_UGasaAttributeSet()
|
||||
source.print( def_include( txt("Networking/GasaNetLibrary.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);
|
||||
|
||||
CodeConstructor constructor_for_UGasaAttributeSet = parse_constructor( code(
|
||||
@ -278,32 +278,32 @@ void gen_UGasaAttributeSet()
|
||||
CodeFn PostGameplayEffectExecute;
|
||||
CodeFn PreAttributeChange;
|
||||
{
|
||||
CodeBody pre_attribute_clamps = def_body( CodeT::Function_Body );
|
||||
CodeBody pre_attribute_clamps = def_body( CT_Function_Body );
|
||||
pre_attribute_clamps.append(fmt_newline);
|
||||
pre_attribute_clamps.append(fmt_newline);
|
||||
|
||||
CodeBody post_attribute_clamps = def_body( CodeT::Function_Body );
|
||||
CodeBody post_attribute_clamps = def_body( CT_Function_Body );
|
||||
post_attribute_clamps.append(fmt_newline);
|
||||
post_attribute_clamps.append(fmt_newline);
|
||||
|
||||
for (GAS_AttributeEntry field : all_attribute_fields)
|
||||
{
|
||||
String clamp_min;
|
||||
if (field.MinName.Data)
|
||||
clamp_min = get_cached_string(token_fmt( "MinName", (StrC)field.MinName, "Get<MinName>()"));
|
||||
Str clamp_min;
|
||||
if (field.MinName)
|
||||
clamp_min = cache_str(token_fmt( "MinName", field.MinName, "Get<MinName>()"));
|
||||
else
|
||||
clamp_min = String::fmt_buf(GlobalAllocator, "%f", field.Min);
|
||||
clamp_min = StrBuilder::fmt_buf(ctx.Allocator_Temp, "%f", field.Min).to_str();
|
||||
|
||||
String clamp_max;
|
||||
if (field.MaxName.Data)
|
||||
clamp_max = get_cached_string(token_fmt( "MaxName", (StrC)field.MaxName, "Get<MaxName>()"));
|
||||
Str clamp_max;
|
||||
if (field.MaxName)
|
||||
clamp_max = cache_str(token_fmt( "MaxName", field.MaxName, "Get<MaxName>()"));
|
||||
else
|
||||
clamp_max = String::fmt_buf(GlobalAllocator, "%f", field.Max);
|
||||
clamp_max = StrBuilder::fmt_buf(ctx.Allocator_Temp, "%f", field.Max).to_str();
|
||||
|
||||
pre_attribute_clamps.append( code_fmt(
|
||||
"field", (StrC)field.Name,
|
||||
"clamp_min", (StrC)clamp_min,
|
||||
"clamp_max", (StrC)clamp_max,
|
||||
"field", field.Name,
|
||||
"clamp_min", clamp_min,
|
||||
"clamp_max", clamp_max,
|
||||
stringize(
|
||||
if (Attribute == Get<field>Attribute())
|
||||
{
|
||||
@ -312,9 +312,9 @@ void gen_UGasaAttributeSet()
|
||||
)));
|
||||
|
||||
post_attribute_clamps.append( code_fmt(
|
||||
"field", (StrC)field.Name,
|
||||
"clamp_min", (StrC)clamp_min,
|
||||
"clamp_max", (StrC)clamp_max,
|
||||
"field", field.Name,
|
||||
"clamp_min", clamp_min,
|
||||
"clamp_max", clamp_max,
|
||||
stringize(
|
||||
if ( Data.EvaluatedData.Attribute == Get<field>Attribute() )
|
||||
{
|
||||
@ -328,7 +328,7 @@ void gen_UGasaAttributeSet()
|
||||
post_attribute_clamps.append(fmt_newline);
|
||||
post_attribute_clamps.append(fmt_newline);
|
||||
|
||||
PreAttributeChange = parse_function( token_fmt( "attribute_clamps", (StrC)pre_attribute_clamps.to_string(), stringize(
|
||||
PreAttributeChange = parse_function( token_fmt( "attribute_clamps", (Str)pre_attribute_clamps.to_strbuilder(), stringize(
|
||||
void UGasaAttributeSet::PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue)
|
||||
{
|
||||
Super::PreAttributeChange(Attribute, NewValue);
|
||||
@ -337,7 +337,7 @@ void gen_UGasaAttributeSet()
|
||||
}
|
||||
)));
|
||||
|
||||
PostGameplayEffectExecute = parse_function( token_fmt( "attribute_clamps", (StrC)post_attribute_clamps.to_string(), stringize(
|
||||
PostGameplayEffectExecute = parse_function( token_fmt( "attribute_clamps", (Str)post_attribute_clamps.to_strbuilder(), stringize(
|
||||
void UGasaAttributeSet::PostGameplayEffectExecute(FGameplayEffectModCallbackData const& Data)
|
||||
{
|
||||
Super::PostGameplayEffectExecute(Data);
|
||||
@ -356,17 +356,17 @@ void gen_UGasaAttributeSet()
|
||||
|
||||
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);
|
||||
for (GAS_AttributeEntry field : all_attribute_fields)
|
||||
{
|
||||
field_lifetimes.append( code_fmt( "field", (StrC)field.Name, stringize(
|
||||
field_lifetimes.append( code_fmt( "field", field.Name, stringize(
|
||||
DOREPLIFETIME_DEFAULT_GAS(UGasaAttributeSet, <field>);
|
||||
)));
|
||||
}
|
||||
|
||||
GetLifetimeOfReplicatedProps = parse_function( token_fmt( "field_lifetimes", (StrC)(field_lifetimes.to_string()), stringize(
|
||||
GetLifetimeOfReplicatedProps = parse_function( token_fmt( "field_lifetimes", (Str)(field_lifetimes.to_strbuilder()), stringize(
|
||||
void UGasaAttributeSet::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
|
||||
{
|
||||
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||
@ -387,7 +387,7 @@ void def_attribute_properties( CodeBody body, Array<GAS_AttributeEntry> properti
|
||||
{
|
||||
for ( GAS_AttributeEntry property : properties )
|
||||
{
|
||||
Code field_uproperty = code_fmt( "property", (StrC)property.Name, stringize(
|
||||
Code field_uproperty = code_fmt( "property", property.Name, stringize(
|
||||
UPROPERTY(ReplicatedUsing=Client_OnRep_<property>, EditAnywhere, BlueprintReadWrite, Category="Attributes")
|
||||
FGameplayAttributeData <property>;
|
||||
));
|
||||
@ -404,18 +404,18 @@ void def_attribute_field_on_reps( CodeBody body, Array<GAS_AttributeEntry> prope
|
||||
body.append(fmt_newline);
|
||||
body.append( umeta_UFUNCTION );
|
||||
body.append(fmt_newline);
|
||||
body.append( code_fmt( "property", (StrC)property.Name, stringize(
|
||||
body.append( code_fmt( "property", property.Name, stringize(
|
||||
void Client_OnRep_<property>(FGameplayAttributeData& Prev<property>);
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
void def_attribute_field_property_getters( CodeBody body, StrC class_name, Array<GAS_AttributeEntry> properties )
|
||||
void def_attribute_field_property_getters( CodeBody body, Str class_name, Array<GAS_AttributeEntry> properties )
|
||||
{
|
||||
for ( GAS_AttributeEntry property : properties )
|
||||
{
|
||||
CodeFn generated_get_attribute = parse_function(
|
||||
token_fmt( "class_name", class_name, "property", (StrC)property.Name,
|
||||
token_fmt( "class_name", class_name, "property", property.Name,
|
||||
stringize(
|
||||
static FGameplayAttribute Get<property>Attribute()
|
||||
{
|
||||
@ -433,7 +433,7 @@ void def_attribute_field_value_getters( CodeBody body, Array<GAS_AttributeEntry>
|
||||
{
|
||||
for ( GAS_AttributeEntry property : properties )
|
||||
{
|
||||
body.append( code_fmt( "property", (StrC)property.Name,
|
||||
body.append( code_fmt( "property", property.Name,
|
||||
stringize(
|
||||
FORCEINLINE float Get<property>() const
|
||||
{
|
||||
@ -447,20 +447,20 @@ void def_attribute_field_value_setters( CodeBody body, Array<GAS_AttributeEntry>
|
||||
{
|
||||
for ( GAS_AttributeEntry property : properties )
|
||||
{
|
||||
body.append( code_fmt( "property", (StrC)property.Name,
|
||||
body.append( code_fmt( "property", property.Name,
|
||||
stringize(
|
||||
FORCEINLINE void Set<property>(float NewVal);
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
void def_attribute_field_property_setter_inlines( CodeBody body, StrC class_name, Array<GAS_AttributeEntry> properties )
|
||||
void def_attribute_field_property_setter_inlines( CodeBody body, Str class_name, Array<GAS_AttributeEntry> properties )
|
||||
{
|
||||
body.append(def_pragma( txt("region Attribute Setters")));
|
||||
for ( GAS_AttributeEntry property : properties )
|
||||
{
|
||||
CodeFn generated_get_attribute = parse_function(
|
||||
token_fmt( "class_name", class_name, "property", (StrC)property.Name,
|
||||
token_fmt( "class_name", class_name, "property", property.Name,
|
||||
stringize(
|
||||
FORCEINLINE void <class_name>::Set<property>(float NewVal)
|
||||
{
|
||||
@ -480,7 +480,7 @@ void def_attribute_field_initers ( CodeBody body, Array<GAS_AttributeEntry> prop
|
||||
{
|
||||
for ( GAS_AttributeEntry property : properties )
|
||||
{
|
||||
body.append( code_fmt( "property", (StrC)property.Name,
|
||||
body.append( code_fmt( "property", property.Name,
|
||||
stringize(
|
||||
FORCEINLINE void Init<property>(float NewVal)
|
||||
{
|
||||
@ -491,14 +491,14 @@ void def_attribute_field_initers ( CodeBody body, Array<GAS_AttributeEntry> prop
|
||||
}
|
||||
}
|
||||
|
||||
void impl_attribute_fields( CodeBody body, StrC class_name, Array<GAS_AttributeEntry> properties )
|
||||
void impl_attribute_fields( CodeBody body, Str class_name, Array<GAS_AttributeEntry> properties )
|
||||
{
|
||||
body.append(fmt_newline);
|
||||
body.append(def_pragma( txt("region Rep Notifies")));
|
||||
for ( GAS_AttributeEntry property : properties )
|
||||
{
|
||||
CodeFn field_impl = parse_function( token_fmt(
|
||||
"class_name", class_name, "property", (StrC)property.Name, "from_notice", txt("\n// From GAMEPLAYATTRIBUTE_REPNOTIFY\n"),
|
||||
"class_name", class_name, "property", property.Name, "from_notice", txt("\n// From GAMEPLAYATTRIBUTE_REPNOTIFY\n"),
|
||||
stringize(
|
||||
void <class_name>::Client_OnRep_<property>(FGameplayAttributeData& Prev<property>)
|
||||
{
|
||||
@ -515,7 +515,7 @@ void impl_attribute_fields( CodeBody body, StrC class_name, Array<GAS_AttributeE
|
||||
}
|
||||
|
||||
inline
|
||||
Code gen_GAMEPLAYATTRIBUTE_REPNOTIFY(StrC class_name, StrC property_name, StrC old_value)
|
||||
Code gen_GAMEPLAYATTRIBUTE_REPNOTIFY(Str class_name, Str property_name, Str old_value)
|
||||
{
|
||||
Code rep_notify = code_fmt(
|
||||
"class_name", class_name
|
||||
|
@ -15,25 +15,25 @@ void ue_parse_testing()
|
||||
"C:/projects/Unreal/Surgo/UE/Engine/Source/Runtime/UMG/Public/Components/ProgressBar.h"
|
||||
|
||||
#if 1
|
||||
content = file_read_contents( GlobalAllocator, true, path_UProgressBar );
|
||||
CodeBody parsed_uprogressbar = parse_global_body( StrC { content.size, (char const*)content.data });
|
||||
content = file_read_contents( ctx.Allocator_Temp, true, path_UProgressBar );
|
||||
CodeBody parsed_uprogressbar = parse_global_body( Str { (char const*)content.data, content.size });
|
||||
|
||||
log_fmt("\n\n");
|
||||
for ( Code gcode : parsed_uprogressbar )
|
||||
{
|
||||
if ( gcode->Type == CodeT::Class )
|
||||
if ( gcode->Type == CT_Class )
|
||||
{
|
||||
log_fmt("Class %S - Definitions:\n", gcode->Name);
|
||||
|
||||
if (gcode->Body->Type != CodeT::Class_Body)
|
||||
if (gcode->Body->Type != CT_Class_Body)
|
||||
continue;
|
||||
for ( Code class_code : gcode->Body->cast<CodeBody>() )
|
||||
for ( Code class_code : cast(CodeBody, gcode->Body) )
|
||||
{
|
||||
switch ( class_code->Type )
|
||||
{
|
||||
case CodeT::Variable:
|
||||
case CodeT::Function:
|
||||
case CodeT::Function_Fwd:
|
||||
case CT_Variable:
|
||||
case CT_Function:
|
||||
case CT_Function_Fwd:
|
||||
if ( class_code->Name )
|
||||
{
|
||||
log_fmt("%s\n", class_code->Name );
|
||||
@ -50,28 +50,28 @@ void ue_parse_testing()
|
||||
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Runtime\CoreUObject\Public\UObject\Object.h)"
|
||||
|
||||
#if 1
|
||||
content = file_read_contents( GlobalAllocator, true, path_UObject );
|
||||
CodeBody parsed_uobject = parse_global_body( StrC { content.size, (char const*)content.data });
|
||||
content = file_read_contents( ctx.Allocator_Temp, true, path_UObject );
|
||||
CodeBody parsed_uobject = parse_global_body( Str { (char const*)content.data, content.size });
|
||||
|
||||
log_fmt("\n\n");
|
||||
for ( Code gcode : parsed_uobject )
|
||||
{
|
||||
if ( gcode->Type == CodeT::Class )
|
||||
if ( gcode->Type == CT_Class )
|
||||
{
|
||||
log_fmt("Class %S - Definitions:\n", gcode->Name);
|
||||
// log_fmt("%s\n", gcode->to_string() );
|
||||
|
||||
if (gcode->Body->Type != CodeT::Class_Body)
|
||||
if (gcode->Body->Type != CT_Class_Body)
|
||||
continue;
|
||||
for ( Code class_code : gcode->Body->cast<CodeBody>() )
|
||||
for ( Code class_code : cast(CodeBody, gcode->Body) )
|
||||
{
|
||||
switch ( class_code->Type )
|
||||
{
|
||||
case CodeT::Constructor:
|
||||
case CodeT::Constructor_Fwd:
|
||||
case CodeT::Variable:
|
||||
case CodeT::Function:
|
||||
case CodeT::Function_Fwd:
|
||||
case CT_Constructor:
|
||||
case CT_Constructor_Fwd:
|
||||
case CT_Variable:
|
||||
case CT_Function:
|
||||
case CT_Function_Fwd:
|
||||
if ( class_code->Name )
|
||||
{
|
||||
log_fmt("%s\n", class_code->Name );
|
||||
@ -88,25 +88,25 @@ void ue_parse_testing()
|
||||
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Runtime\Engine\Classes\GameFramework\Actor.h)"
|
||||
|
||||
#if 1
|
||||
content = file_read_contents( GlobalAllocator, true, path_AActor );
|
||||
CodeBody parsed_aactor = parse_global_body( StrC { content.size, (char const*)content.data });
|
||||
content = file_read_contents( ctx.Allocator_Temp, true, path_AActor );
|
||||
CodeBody parsed_aactor = parse_global_body( Str { (char const*)content.data, content.size });
|
||||
|
||||
log_fmt("\n\n");
|
||||
for ( Code gcode : parsed_aactor )
|
||||
{
|
||||
if ( gcode->Type == CodeT::Class )
|
||||
if ( gcode->Type == CT_Class )
|
||||
{
|
||||
log_fmt("Class %S - Definitions:\n", gcode->Name);
|
||||
|
||||
if (gcode->Body->Type != CodeT::Class_Body)
|
||||
if (gcode->Body->Type != CT_Class_Body)
|
||||
continue;
|
||||
for ( Code class_code : gcode->Body->cast<CodeBody>() )
|
||||
for ( Code class_code : cast(CodeBody, gcode->Body) )
|
||||
{
|
||||
switch ( class_code->Type )
|
||||
{
|
||||
// case CodeT::Variable:
|
||||
case CodeT::Function:
|
||||
case CodeT::Function_Fwd:
|
||||
case CT_Function:
|
||||
case CT_Function_Fwd:
|
||||
if ( class_code->Name )
|
||||
{
|
||||
log_fmt("%s\n", class_code->Name );
|
||||
@ -122,25 +122,25 @@ void ue_parse_testing()
|
||||
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Runtime\Engine\Classes\Components\ActorComponent.h)"
|
||||
|
||||
#if 1
|
||||
content = file_read_contents( GlobalAllocator, true, path_ActorComponent );
|
||||
CodeBody parsed_actor_component = parse_global_body( StrC { content.size, (char const*)content.data });
|
||||
content = file_read_contents( ctx.Allocator_Temp, true, path_ActorComponent );
|
||||
CodeBody parsed_actor_component = parse_global_body( Str { (char const*)content.data, content.size });
|
||||
|
||||
for ( Code gcode : parsed_actor_component )
|
||||
{
|
||||
if ( gcode->Type == CodeT::Class )
|
||||
if ( gcode->Type == CT_Class )
|
||||
{
|
||||
log_fmt("\n\n");
|
||||
log_fmt("Class %S - Definitions:\n", gcode->Name);
|
||||
|
||||
if (gcode->Body->Type != CodeT::Class_Body)
|
||||
if (gcode->Body->Type != CT_Class_Body)
|
||||
continue;
|
||||
for ( Code class_code : gcode->Body->cast<CodeBody>() )
|
||||
for ( Code class_code : cast(CodeBody, gcode->Body) )
|
||||
{
|
||||
switch ( class_code->Type )
|
||||
{
|
||||
case CodeT::Variable:
|
||||
case CodeT::Function:
|
||||
case CodeT::Function_Fwd:
|
||||
case CT_Variable:
|
||||
case CT_Function:
|
||||
case CT_Function_Fwd:
|
||||
if ( class_code->Name )
|
||||
{
|
||||
log_fmt("%s\n", class_code->Name );
|
||||
@ -156,25 +156,25 @@ void ue_parse_testing()
|
||||
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Runtime\Engine\Classes\Components\SceneComponent.h)"
|
||||
|
||||
#if 1
|
||||
content = file_read_contents( GlobalAllocator, true, path_SceneComponent );
|
||||
CodeBody parsed_scene_component = parse_global_body( StrC { content.size, (char const*)content.data });
|
||||
content = file_read_contents( ctx.Allocator_Temp, true, path_SceneComponent );
|
||||
CodeBody parsed_scene_component = parse_global_body( Str { (char const*)content.data, content.size });
|
||||
|
||||
for ( Code gcode : parsed_scene_component )
|
||||
{
|
||||
if ( gcode->Type == CodeT::Class )
|
||||
if ( gcode->Type == CT_Class )
|
||||
{
|
||||
log_fmt("\n\n");
|
||||
log_fmt("Class %S - Definitions:\n", gcode->Name);
|
||||
|
||||
if (gcode->Body->Type != CodeT::Class_Body)
|
||||
if (gcode->Body->Type != CT_Class_Body)
|
||||
continue;
|
||||
for ( Code class_code : gcode->Body->cast<CodeBody>() )
|
||||
for ( Code class_code : cast(CodeBody, gcode->Body) )
|
||||
{
|
||||
switch ( class_code->Type )
|
||||
{
|
||||
case CodeT::Variable:
|
||||
case CodeT::Function:
|
||||
case CodeT::Function_Fwd:
|
||||
case CT_Variable:
|
||||
case CT_Function:
|
||||
case CT_Function_Fwd:
|
||||
if ( class_code->Name )
|
||||
{
|
||||
log_fmt("%s\n", class_code->Name );
|
||||
@ -190,25 +190,25 @@ void ue_parse_testing()
|
||||
R"(C:\projects\Unreal\Surgo\UE\Engine\Plugins\Runtime\GameplayAbilities\Source\GameplayAbilities\Public\AttributeSet.h)"
|
||||
|
||||
#if 1
|
||||
content = file_read_contents( GlobalAllocator, true, path_AttributeSet );
|
||||
CodeBody parsed_attribute_set = parse_global_body( StrC { content.size, (char const*)content.data });
|
||||
content = file_read_contents( ctx.Allocator_Temp, true, path_AttributeSet );
|
||||
CodeBody parsed_attribute_set = parse_global_body( Str { (char const*)content.data, content.size });
|
||||
|
||||
for ( Code gcode : parsed_attribute_set )
|
||||
{
|
||||
if ( gcode->Type == CodeT::Class )
|
||||
if ( gcode->Type == CT_Class )
|
||||
{
|
||||
log_fmt("\n\n");
|
||||
log_fmt("Class %S - Definitions:\n", gcode->Name);
|
||||
|
||||
if (gcode->Body->Type != CodeT::Class_Body)
|
||||
if (gcode->Body->Type != CT_Class_Body)
|
||||
continue;
|
||||
for ( Code class_code : gcode->Body->cast<CodeBody>() )
|
||||
for ( Code class_code : cast(CodeBody, gcode->Body) )
|
||||
{
|
||||
switch ( class_code->Type )
|
||||
{
|
||||
case CodeT::Variable:
|
||||
case CodeT::Function:
|
||||
case CodeT::Function_Fwd:
|
||||
case CT_Variable:
|
||||
case CT_Function:
|
||||
case CT_Function_Fwd:
|
||||
if ( class_code->Name )
|
||||
{
|
||||
log_fmt("%s\n", class_code->Name );
|
||||
|
@ -9,6 +9,9 @@
|
||||
# pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||
# pragma clang diagnostic ignored "-Wvarargs"
|
||||
# pragma clang diagnostic ignored "-Wunused-function"
|
||||
# pragma clang diagnostic ignored "-Wbraced-scalar-init"
|
||||
# pragma clang diagnostic ignored "-W#pragma-messages"
|
||||
# pragma clang diagnostic ignored "-Wstatic-in-inline"
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
@ -23,7 +26,9 @@
|
||||
|
||||
GEN_NS_BEGIN
|
||||
|
||||
Builder Builder::open( char const* path )
|
||||
#pragma region Builder
|
||||
|
||||
Builder builder_open( char const* path )
|
||||
{
|
||||
Builder result;
|
||||
|
||||
@ -34,51 +39,49 @@ Builder Builder::open( char const* path )
|
||||
return result;
|
||||
}
|
||||
|
||||
result.Buffer = String::make_reserve( GlobalAllocator, Builder_StrBufferReserve );
|
||||
result.Buffer = strbuilder_make_reserve( _ctx->Allocator_Temp, _ctx->InitSize_BuilderBuffer );
|
||||
|
||||
// log_fmt("$Builder - Opened file: %s\n", result.File.filename );
|
||||
return result;
|
||||
}
|
||||
|
||||
void Builder::pad_lines( s32 num )
|
||||
void builder_pad_lines( Builder* builder, s32 num )
|
||||
{
|
||||
Buffer.append( "\n" );
|
||||
strbuilder_append_str( & builder->Buffer, txt("\n") );
|
||||
}
|
||||
|
||||
void Builder::print( Code code )
|
||||
void builder_print( Builder* builder, Code code )
|
||||
{
|
||||
String str = code->to_string();
|
||||
// const sw len = str.length();
|
||||
StrBuilder str = code_to_strbuilder(code);
|
||||
// const ssize len = str.length();
|
||||
// log_fmt( "%s - print: %.*s\n", File.filename, len > 80 ? 80 : len, str.Data );
|
||||
Buffer.append( str );
|
||||
strbuilder_append_string( & builder->Buffer, str );
|
||||
}
|
||||
|
||||
void Builder::print_fmt( char const* fmt, ... )
|
||||
void builder_print_fmt_va( Builder* builder, char const* fmt, va_list va )
|
||||
{
|
||||
sw res;
|
||||
ssize res;
|
||||
char buf[ GEN_PRINTF_MAXLEN ] = { 0 };
|
||||
|
||||
va_list va;
|
||||
va_start( va, fmt );
|
||||
res = str_fmt_va( buf, count_of( buf ) - 1, fmt, va ) - 1;
|
||||
va_end( va );
|
||||
res = c_str_fmt_va( buf, count_of( buf ) - 1, fmt, va ) - 1;
|
||||
|
||||
// log_fmt( "$%s - print_fmt: %.*s\n", File.filename, res > 80 ? 80 : res, buf );
|
||||
Buffer.append( buf, res );
|
||||
strbuilder_append_c_str_len( (StrBuilder*) & (builder->Buffer), (char const*)buf, res);
|
||||
}
|
||||
|
||||
void Builder::write()
|
||||
void builder_write(Builder* builder)
|
||||
{
|
||||
b32 result = file_write( &File, Buffer, Buffer.length() );
|
||||
b32 result = file_write( & builder->File, builder->Buffer, strbuilder_length(builder->Buffer) );
|
||||
|
||||
if ( result == false )
|
||||
log_failure( "gen::File::write - Failed to write to file: %s\n", file_name( &File ) );
|
||||
log_failure("gen::File::write - Failed to write to file: %s\n", file_name( & builder->File ) );
|
||||
|
||||
log_fmt( "Generated: %s\n", File.filename );
|
||||
file_close( &File );
|
||||
Buffer.free();
|
||||
log_fmt( "Generated: %s\n", builder->File.filename );
|
||||
file_close( & builder->File );
|
||||
strbuilder_free(& builder->Buffer);
|
||||
}
|
||||
|
||||
#pragma endregion Builder
|
||||
|
||||
GEN_NS_END
|
||||
|
||||
#ifdef __clang__
|
||||
|
@ -9,6 +9,9 @@
|
||||
# pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||
# pragma clang diagnostic ignored "-Wvarargs"
|
||||
# pragma clang diagnostic ignored "-Wunused-function"
|
||||
# pragma clang diagnostic ignored "-Wbraced-scalar-init"
|
||||
# pragma clang diagnostic ignored "-W#pragma-messages"
|
||||
# pragma clang diagnostic ignored "-Wstatic-in-inline"
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
@ -25,21 +28,59 @@
|
||||
|
||||
GEN_NS_BEGIN
|
||||
|
||||
#pragma region Builder
|
||||
|
||||
struct Builder;
|
||||
typedef struct Builder Builder;
|
||||
|
||||
Builder builder_open ( char const* path );
|
||||
void builder_pad_lines ( Builder* builder, s32 num );
|
||||
void builder_print ( Builder* builder, Code code );
|
||||
void builder_print_fmt_va( Builder* builder, char const* fmt, va_list va );
|
||||
void builder_print_fmt ( Builder* builder, char const* fmt, ... ) {
|
||||
va_list va;
|
||||
va_start( va, fmt );
|
||||
builder_print_fmt_va( builder, fmt, va );
|
||||
va_end( va );
|
||||
}
|
||||
void builder_write( Builder* builder );
|
||||
|
||||
struct Builder
|
||||
{
|
||||
FileInfo File;
|
||||
String Buffer;
|
||||
StrBuilder Buffer;
|
||||
|
||||
static Builder open( char const* path );
|
||||
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
|
||||
FORCEINLINE static Builder open( char const* path ) { return builder_open(path); }
|
||||
|
||||
void pad_lines( s32 num );
|
||||
FORCEINLINE void pad_lines( s32 num ) { return builder_pad_lines(this, num); }
|
||||
|
||||
void print( Code );
|
||||
void print_fmt( char const* fmt, ... );
|
||||
FORCEINLINE void print( Code code ) { return builder_print(this, code); }
|
||||
FORCEINLINE void print_fmt( char const* fmt, ... ) {
|
||||
va_list va;
|
||||
va_start( va, fmt );
|
||||
builder_print_fmt_va( this, fmt, va );
|
||||
va_end( va );
|
||||
}
|
||||
|
||||
void write();
|
||||
FORCEINLINE void write() { return builder_write(this); }
|
||||
#endif
|
||||
};
|
||||
|
||||
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
|
||||
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); }
|
||||
void builder_write ( Builder& builder ) { return builder_write(& builder ); }
|
||||
void builder_print_fmt( Builder& builder, char const* fmt, ...) {
|
||||
va_list va;
|
||||
va_start( va, fmt );
|
||||
builder_print_fmt_va( & builder, fmt, va );
|
||||
va_end( va );
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma endregion Builder
|
||||
|
||||
GEN_NS_END
|
||||
|
||||
#ifdef __clang__
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -9,6 +9,9 @@
|
||||
# pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||
# pragma clang diagnostic ignored "-Wvarargs"
|
||||
# pragma clang diagnostic ignored "-Wunused-function"
|
||||
# pragma clang diagnostic ignored "-Wbraced-scalar-init"
|
||||
# pragma clang diagnostic ignored "-W#pragma-messages"
|
||||
# pragma clang diagnostic ignored "-Wstatic-in-inline"
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
@ -28,7 +31,7 @@ GEN_NS_BEGIN
|
||||
#define _adt_fprintf( s_, fmt_, ... ) \
|
||||
do \
|
||||
{ \
|
||||
if ( str_fmt_file( s_, fmt_, ##__VA_ARGS__ ) < 0 ) \
|
||||
if ( c_str_fmt_file( s_, fmt_, ##__VA_ARGS__ ) < 0 ) \
|
||||
return EADT_ERROR_OUT_OF_MEMORY; \
|
||||
} while ( 0 )
|
||||
|
||||
@ -44,7 +47,7 @@ u8 adt_make_branch( ADT_Node* node, AllocatorInfo backing, char const* name, b32
|
||||
node->type = type;
|
||||
node->name = name;
|
||||
node->parent = parent;
|
||||
node->nodes = Array<ADT_Node>::init( backing );
|
||||
node->nodes = array_init(ADT_Node, backing );
|
||||
|
||||
if ( ! node->nodes )
|
||||
return EADT_ERROR_OUT_OF_MEMORY;
|
||||
@ -57,12 +60,12 @@ u8 adt_destroy_branch( ADT_Node* node )
|
||||
GEN_ASSERT_NOT_NULL( node );
|
||||
if ( ( node->type == EADT_TYPE_OBJECT || node->type == EADT_TYPE_ARRAY ) && node->nodes )
|
||||
{
|
||||
for ( sw i = 0; i < scast( sw, node->nodes.num() ); ++i )
|
||||
for ( ssize i = 0; i < scast(ssize, array_num(node->nodes)); ++i )
|
||||
{
|
||||
adt_destroy_branch( node->nodes + i );
|
||||
}
|
||||
|
||||
node->nodes.free();
|
||||
array_free(node->nodes);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -87,9 +90,9 @@ ADT_Node* adt_find( ADT_Node* node, char const* name, b32 deep_search )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for ( sw i = 0; i < scast( sw, node->nodes.num() ); i++ )
|
||||
for ( ssize i = 0; i < scast(ssize, array_num(node->nodes)); i++ )
|
||||
{
|
||||
if ( ! str_compare( node->nodes[i].name, name ) )
|
||||
if ( ! c_str_compare( node->nodes[ i ].name, name ) )
|
||||
{
|
||||
return ( node->nodes + i );
|
||||
}
|
||||
@ -97,7 +100,7 @@ ADT_Node* adt_find( ADT_Node* node, char const* name, b32 deep_search )
|
||||
|
||||
if ( deep_search )
|
||||
{
|
||||
for ( sw i = 0; i < scast( sw, node->nodes.num() ); i++ )
|
||||
for ( ssize i = 0; i < scast(ssize, array_num(node->nodes)); i++ )
|
||||
{
|
||||
ADT_Node* res = adt_find( node->nodes + i, name, deep_search );
|
||||
|
||||
@ -116,7 +119,7 @@ internal ADT_Node* _adt_get_value( ADT_Node* node, char const* value )
|
||||
case EADT_TYPE_MULTISTRING :
|
||||
case EADT_TYPE_STRING :
|
||||
{
|
||||
if ( node->string && ! str_compare( node->string, value ) )
|
||||
if ( node->string && ! c_str_compare( node->string, value ) )
|
||||
{
|
||||
return node;
|
||||
}
|
||||
@ -132,10 +135,10 @@ internal ADT_Node* _adt_get_value( ADT_Node* node, char const* value )
|
||||
file_stream_open( &tmp, heap(), ( u8* )back, size_of( back ), EFileStream_WRITABLE );
|
||||
adt_print_number( &tmp, node );
|
||||
|
||||
sw fsize = 0;
|
||||
ssize fsize = 0;
|
||||
u8* buf = file_stream_buf( &tmp, &fsize );
|
||||
|
||||
if ( ! str_compare( (char const*)buf, value ) )
|
||||
if ( ! c_str_compare( ( char const* )buf, value ) )
|
||||
{
|
||||
file_close( &tmp );
|
||||
return node;
|
||||
@ -153,9 +156,9 @@ internal ADT_Node* _adt_get_value( ADT_Node* node, char const* value )
|
||||
|
||||
internal ADT_Node* _adt_get_field( ADT_Node* node, char* name, char* value )
|
||||
{
|
||||
for ( sw i = 0; i < scast( sw, node->nodes.num() ); i++ )
|
||||
for ( ssize i = 0; i < scast(ssize, array_num(node->nodes)); i++ )
|
||||
{
|
||||
if ( ! str_compare( node->nodes[i].name, name ) )
|
||||
if ( ! c_str_compare( node->nodes[ i ].name, name ) )
|
||||
{
|
||||
ADT_Node* child = &node->nodes[ i ];
|
||||
if ( _adt_get_value( child, value ) )
|
||||
@ -188,22 +191,22 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri )
|
||||
}
|
||||
|
||||
#if defined EADT_URI_DEBUG || 0
|
||||
str_fmt_out( "uri: %s\n", uri );
|
||||
c_str_fmt_out( "uri: %s\n", uri );
|
||||
#endif
|
||||
|
||||
char * p = ( char* )uri, *b = p, *e = p;
|
||||
ADT_Node* found_node = NULL;
|
||||
|
||||
b = p;
|
||||
p = e = (char*)str_skip( p, '/' );
|
||||
char* buf = str_fmt_buf( "%.*s", (int)( e - b ), b );
|
||||
p = e = ( char* )c_str_skip( p, '/' );
|
||||
char* buf = c_str_fmt_buf( "%.*s", ( int )( e - b ), b );
|
||||
|
||||
/* handle field value lookup */
|
||||
if ( *b == '[' )
|
||||
{
|
||||
char *l_p = buf + 1, *l_b = l_p, *l_e = l_p, *l_b2 = l_p, *l_e2 = l_p;
|
||||
l_e = (char*)str_skip( l_p, '=' );
|
||||
l_e2 = (char*)str_skip( l_p, ']' );
|
||||
l_e = ( char* )c_str_skip( l_p, '=' );
|
||||
l_e2 = ( char* )c_str_skip( l_p, ']' );
|
||||
|
||||
if ( ( ! *l_e && node->type != EADT_TYPE_ARRAY ) || ! *l_e2 )
|
||||
{
|
||||
@ -228,7 +231,7 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri )
|
||||
/* run a value comparison against any child that is an object node */
|
||||
else if ( node->type == EADT_TYPE_ARRAY )
|
||||
{
|
||||
for ( sw i = 0; i < scast( sw, node->nodes.num() ); i++ )
|
||||
for ( ssize i = 0; i < scast(ssize, array_num(node->nodes)); i++ )
|
||||
{
|
||||
ADT_Node* child = &node->nodes[ i ];
|
||||
if ( child->type != EADT_TYPE_OBJECT )
|
||||
@ -246,7 +249,7 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri )
|
||||
/* [value] */
|
||||
else
|
||||
{
|
||||
for ( sw i = 0; i < scast( sw, node->nodes.num() ); i++ )
|
||||
for ( ssize i = 0; i < scast(ssize, array_num(node->nodes)); i++ )
|
||||
{
|
||||
ADT_Node* child = &node->nodes[ i ];
|
||||
if ( _adt_get_value( child, l_b2 ) )
|
||||
@ -277,8 +280,8 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri )
|
||||
/* handle array index lookup */
|
||||
else
|
||||
{
|
||||
sw idx = (sw)str_to_i64( buf, NULL, 10 );
|
||||
if ( idx >= 0 && idx < scast( sw, node->nodes.num() ) )
|
||||
ssize idx = ( ssize )c_str_to_i64( buf, NULL, 10 );
|
||||
if ( idx >= 0 && idx < scast(ssize, array_num(node->nodes)) )
|
||||
{
|
||||
found_node = &node->nodes[ idx ];
|
||||
|
||||
@ -293,7 +296,7 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri )
|
||||
return found_node;
|
||||
}
|
||||
|
||||
ADT_Node* adt_alloc_at( ADT_Node* parent, sw index )
|
||||
ADT_Node* adt_alloc_at( ADT_Node* parent, ssize index )
|
||||
{
|
||||
if ( ! parent || ( parent->type != EADT_TYPE_OBJECT && parent->type != EADT_TYPE_ARRAY ) )
|
||||
{
|
||||
@ -303,15 +306,16 @@ ADT_Node* adt_alloc_at( ADT_Node* parent, sw index )
|
||||
if ( ! parent->nodes )
|
||||
return NULL;
|
||||
|
||||
if ( index < 0 || index > scast( sw, parent->nodes.num() ) )
|
||||
if ( index < 0 || index > scast(ssize, array_num(parent->nodes)) )
|
||||
return NULL;
|
||||
|
||||
ADT_Node o = { 0 };
|
||||
o.parent = parent;
|
||||
if ( ! parent->nodes.append_at( o, index ) )
|
||||
if ( ! array_append_at( parent->nodes, o, index ) )
|
||||
return NULL;
|
||||
|
||||
return parent->nodes + index;
|
||||
ADT_Node* node = & parent->nodes[index];
|
||||
return node;
|
||||
}
|
||||
|
||||
ADT_Node* adt_alloc( ADT_Node* parent )
|
||||
@ -324,7 +328,7 @@ ADT_Node* adt_alloc( ADT_Node* parent )
|
||||
if ( ! parent->nodes )
|
||||
return NULL;
|
||||
|
||||
return adt_alloc_at( parent, parent->nodes.num() );
|
||||
return adt_alloc_at( parent, array_num(parent->nodes) );
|
||||
}
|
||||
|
||||
b8 adt_set_obj( ADT_Node* obj, char const* name, AllocatorInfo backing )
|
||||
@ -358,7 +362,7 @@ b8 adt_set_int( ADT_Node* obj, char const* name, s64 value )
|
||||
return true;
|
||||
}
|
||||
|
||||
ADT_Node* adt_move_node_at( ADT_Node* node, ADT_Node* new_parent, sw index )
|
||||
ADT_Node* adt_move_node_at( ADT_Node* node, ADT_Node* new_parent, ssize index )
|
||||
{
|
||||
GEN_ASSERT_NOT_NULL( node );
|
||||
GEN_ASSERT_NOT_NULL( new_parent );
|
||||
@ -378,7 +382,7 @@ ADT_Node* adt_move_node( ADT_Node* node, ADT_Node* new_parent )
|
||||
GEN_ASSERT_NOT_NULL( node );
|
||||
GEN_ASSERT_NOT_NULL( new_parent );
|
||||
GEN_ASSERT( new_parent->type == EADT_TYPE_ARRAY || new_parent->type == EADT_TYPE_OBJECT );
|
||||
return adt_move_node_at( node, new_parent, new_parent->nodes.num() );
|
||||
return adt_move_node_at( node, new_parent, array_num(new_parent->nodes) );
|
||||
}
|
||||
|
||||
void adt_swap_nodes( ADT_Node* node, ADT_Node* other_node )
|
||||
@ -387,8 +391,8 @@ void adt_swap_nodes( ADT_Node* node, ADT_Node* other_node )
|
||||
GEN_ASSERT_NOT_NULL( other_node );
|
||||
ADT_Node* parent = node->parent;
|
||||
ADT_Node* other_parent = other_node->parent;
|
||||
sw index = ( pointer_diff( parent->nodes, node ) / size_of( ADT_Node ) );
|
||||
sw index2 = ( pointer_diff( other_parent->nodes, other_node ) / size_of( ADT_Node ) );
|
||||
ssize index = ( pointer_diff( parent->nodes, node ) / size_of( ADT_Node ) );
|
||||
ssize index2 = ( pointer_diff( other_parent->nodes, other_node ) / size_of( ADT_Node ) );
|
||||
ADT_Node temp = parent->nodes[ index ];
|
||||
temp.parent = other_parent;
|
||||
other_parent->nodes[ index2 ].parent = parent;
|
||||
@ -401,8 +405,8 @@ void adt_remove_node( ADT_Node* node )
|
||||
GEN_ASSERT_NOT_NULL( node );
|
||||
GEN_ASSERT_NOT_NULL( node->parent );
|
||||
ADT_Node* parent = node->parent;
|
||||
sw index = ( pointer_diff( parent->nodes, node ) / size_of( ADT_Node ) );
|
||||
parent->nodes.remove_at( index );
|
||||
ssize index = ( pointer_diff( parent->nodes, node ) / size_of( ADT_Node ) );
|
||||
array_remove_at( parent->nodes, index );
|
||||
}
|
||||
|
||||
ADT_Node* adt_append_obj( ADT_Node* parent, char const* name )
|
||||
@ -410,7 +414,7 @@ ADT_Node* adt_append_obj( ADT_Node* parent, char const* name )
|
||||
ADT_Node* o = adt_alloc( parent );
|
||||
if ( ! o )
|
||||
return NULL;
|
||||
if ( adt_set_obj( o, name, parent->nodes.get_header()->Allocator ) )
|
||||
if ( adt_set_obj( o, name, array_get_header(parent->nodes)->Allocator ) )
|
||||
{
|
||||
adt_remove_node( o );
|
||||
return NULL;
|
||||
@ -423,7 +427,9 @@ ADT_Node* adt_append_arr( ADT_Node* parent, char const* name )
|
||||
ADT_Node* o = adt_alloc( parent );
|
||||
if ( ! o )
|
||||
return NULL;
|
||||
if ( adt_set_arr( o, name, parent->nodes.get_header()->Allocator ) )
|
||||
|
||||
ArrayHeader* node_header = array_get_header(parent->nodes);
|
||||
if ( adt_set_arr( o, name, node_header->Allocator ) )
|
||||
{
|
||||
adt_remove_node( o );
|
||||
return NULL;
|
||||
@ -468,7 +474,7 @@ char* adt_parse_number_strict( ADT_Node* node, char* base_str )
|
||||
while ( *e )
|
||||
++e;
|
||||
|
||||
while ( *p && ( str_find( "eE.+-", *p ) || char_is_hex_digit( *p ) ) )
|
||||
while ( *p && ( char_first_occurence( "eE.+-", *p ) || char_is_hex_digit( *p ) ) )
|
||||
{
|
||||
++p;
|
||||
}
|
||||
@ -497,7 +503,7 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
|
||||
u8 node_props = 0;
|
||||
|
||||
/* skip false positives and special cases */
|
||||
if ( ! ! str_find( "eE", *p ) || ( ! ! str_find( ".+-", *p ) && ! char_is_hex_digit( *( p + 1 ) ) && *( p + 1 ) != '.' ) )
|
||||
if ( ! ! char_first_occurence( "eE", *p ) || ( ! ! char_first_occurence( ".+-", *p ) && ! char_is_hex_digit( *( p + 1 ) ) && *( p + 1 ) != '.' ) )
|
||||
{
|
||||
return ++base_str;
|
||||
}
|
||||
@ -505,7 +511,7 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
|
||||
node_type = EADT_TYPE_INTEGER;
|
||||
neg_zero = false;
|
||||
|
||||
sw ib = 0;
|
||||
ssize ib = 0;
|
||||
char buf[ 48 ] = { 0 };
|
||||
|
||||
if ( *e == '+' )
|
||||
@ -528,7 +534,7 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! str_compare( e, "0x", 2 ) || ! str_compare( e, "0X", 2 ) )
|
||||
if ( ! c_str_compare_len( e, "0x", 2 ) || ! c_str_compare_len( e, "0X", 2 ) )
|
||||
{
|
||||
node_props = EADT_PROPS_IS_HEX;
|
||||
}
|
||||
@ -571,9 +577,9 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
|
||||
|
||||
f32 eb = 10;
|
||||
char expbuf[ 6 ] = { 0 };
|
||||
sw expi = 0;
|
||||
ssize expi = 0;
|
||||
|
||||
if ( *e && ! ! str_find( "eE", *e ) )
|
||||
if ( *e && ! ! char_first_occurence( "eE", *e ) )
|
||||
{
|
||||
++e;
|
||||
if ( *e == '+' || *e == '-' || char_is_digit( *e ) )
|
||||
@ -592,12 +598,12 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
|
||||
}
|
||||
}
|
||||
|
||||
orig_exp = exp = (u8)str_to_i64( expbuf, NULL, 10 );
|
||||
orig_exp = exp = ( u8 )c_str_to_i64( expbuf, NULL, 10 );
|
||||
}
|
||||
|
||||
if ( node_type == EADT_TYPE_INTEGER )
|
||||
{
|
||||
node->integer = str_to_i64( buf, 0, 0 );
|
||||
node->integer = c_str_to_i64( buf, 0, 0 );
|
||||
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
||||
/* special case: negative zero */
|
||||
if ( node->integer == 0 && buf[ 0 ] == '-' )
|
||||
@ -612,19 +618,19 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
|
||||
}
|
||||
else
|
||||
{
|
||||
node->real = str_to_f64( buf, 0 );
|
||||
node->real = c_str_to_f64( buf, 0 );
|
||||
|
||||
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
||||
char *q = buf, *base_string = q, *base_string2 = q;
|
||||
base_string = zpl_cast( char* ) str_skip( base_string, '.' );
|
||||
base_string = ccast( char*, c_str_skip( base_string, '.' ));
|
||||
*base_string = '\0';
|
||||
base_string2 = base_string + 1;
|
||||
char* base_string_off = base_string2;
|
||||
while ( *base_string_off++ == '0' )
|
||||
char* base_strbuilder_off = base_string2;
|
||||
while ( *base_strbuilder_off++ == '0' )
|
||||
base2_offset++;
|
||||
|
||||
base = (s32)str_to_i64( q, 0, 0 );
|
||||
base2 = (s32)str_to_i64( base_string2, 0, 0 );
|
||||
base = ( s32 )c_str_to_i64( q, 0, 0 );
|
||||
base2 = ( s32 )c_str_to_i64( base_string2, 0, 0 );
|
||||
if ( exp )
|
||||
{
|
||||
exp = exp * ( ! ( eb == 10.0f ) ? -1 : 1 );
|
||||
@ -767,9 +773,9 @@ ADT_Error adt_print_string( FileInfo* file, ADT_Node* node, char const* escaped_
|
||||
|
||||
do
|
||||
{
|
||||
p = str_skip_any( p, escaped_chars );
|
||||
p = c_str_skip_any( p, escaped_chars );
|
||||
_adt_fprintf( file, "%.*s", pointer_diff( b, p ), b );
|
||||
if ( *p && ! ! str_find( escaped_chars, *p ) )
|
||||
if ( *p && ! ! char_first_occurence( escaped_chars, *p ) )
|
||||
{
|
||||
_adt_fprintf( file, "%s%c", escape_symbol, *p );
|
||||
p++;
|
||||
@ -780,7 +786,7 @@ ADT_Error adt_print_string( FileInfo* file, ADT_Node* node, char const* escaped_
|
||||
return EADT_ERROR_NONE;
|
||||
}
|
||||
|
||||
ADT_Error adt_str_to_number( ADT_Node* node )
|
||||
ADT_Error adt_c_str_to_number( ADT_Node* node )
|
||||
{
|
||||
GEN_ASSERT( node );
|
||||
|
||||
@ -796,7 +802,7 @@ ADT_Error adt_str_to_number( ADT_Node* node )
|
||||
return EADT_ERROR_NONE;
|
||||
}
|
||||
|
||||
ADT_Error adt_str_to_number_strict( ADT_Node* node )
|
||||
ADT_Error adt_c_str_to_number_strict( ADT_Node* node )
|
||||
{
|
||||
GEN_ASSERT( node );
|
||||
|
||||
@ -837,13 +843,13 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
||||
char* beginChar;
|
||||
char* endChar;
|
||||
|
||||
sw columnIndex = 0;
|
||||
sw totalColumnIndex = 0;
|
||||
ssize columnIndex = 0;
|
||||
ssize totalColumnIndex = 0;
|
||||
|
||||
do
|
||||
{
|
||||
char delimiter = 0;
|
||||
currentChar = zpl_cast( char* ) str_trim( currentChar, false );
|
||||
currentChar = ccast( char*, c_str_trim( currentChar, false ));
|
||||
|
||||
if ( *currentChar == 0 )
|
||||
break;
|
||||
@ -867,7 +873,7 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
||||
#endif
|
||||
do
|
||||
{
|
||||
endChar = zpl_cast( char* ) str_skip( endChar, '"' );
|
||||
endChar = ccast( char*, c_str_skip( endChar, '"' ));
|
||||
|
||||
if ( *endChar && *( endChar + 1 ) == '"' )
|
||||
{
|
||||
@ -875,7 +881,8 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
||||
}
|
||||
else
|
||||
break;
|
||||
} while ( *endChar );
|
||||
}
|
||||
while ( *endChar );
|
||||
|
||||
if ( *endChar == 0 )
|
||||
{
|
||||
@ -885,7 +892,7 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
||||
}
|
||||
|
||||
*endChar = 0;
|
||||
currentChar = zpl_cast( char* ) str_trim( endChar + 1, true );
|
||||
currentChar = ccast( char*, c_str_trim( endChar + 1, true ));
|
||||
delimiter = * currentChar;
|
||||
|
||||
/* unescape escaped quotes (so that unescaped text escapes :) */
|
||||
@ -895,10 +902,11 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
||||
{
|
||||
if ( *escapedChar == '"' && *( escapedChar + 1 ) == '"' )
|
||||
{
|
||||
mem_move( escapedChar, escapedChar + 1, str_len( escapedChar ) );
|
||||
mem_move( escapedChar, escapedChar + 1, c_str_len( escapedChar ) );
|
||||
}
|
||||
escapedChar++;
|
||||
} while ( *escapedChar );
|
||||
}
|
||||
while ( *escapedChar );
|
||||
}
|
||||
}
|
||||
else if ( *currentChar == delim )
|
||||
@ -916,11 +924,12 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
||||
do
|
||||
{
|
||||
endChar++;
|
||||
} while ( *endChar && *endChar != delim && *endChar != '\n' );
|
||||
}
|
||||
while ( * endChar && * endChar != delim && * endChar != '\n' );
|
||||
|
||||
if ( * endChar )
|
||||
{
|
||||
currentChar = zpl_cast( char* ) str_trim( endChar, true );
|
||||
currentChar = ccast( char*, c_str_trim( endChar, true ));
|
||||
|
||||
while ( char_is_space( *( endChar - 1 ) ) )
|
||||
{
|
||||
@ -941,7 +950,7 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
||||
char* num_p = beginChar;
|
||||
|
||||
// We only consider hexadecimal values if they start with 0x
|
||||
if ( str_len( num_p ) > 2 && num_p[0] == '0' && ( num_p[1] == 'x' || num_p[1] == 'X' ) )
|
||||
if ( c_str_len(num_p) > 2 && num_p[0] == '0' && (num_p[1] == 'x' || num_p[1] == 'X') )
|
||||
{
|
||||
num_p += 2; // skip '0x' prefix
|
||||
do
|
||||
@ -960,16 +969,16 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
||||
|
||||
if (!skip_number)
|
||||
{
|
||||
adt_str_to_number( &rowItem );
|
||||
adt_c_str_to_number(&rowItem);
|
||||
}
|
||||
}
|
||||
|
||||
if ( columnIndex >= scast( sw, root->nodes.num() ) )
|
||||
if ( columnIndex >= scast(ssize, array_num(root->nodes)) )
|
||||
{
|
||||
adt_append_arr( root, NULL );
|
||||
}
|
||||
|
||||
root->nodes[columnIndex].nodes.append( rowItem );
|
||||
array_append( root->nodes[ columnIndex ].nodes, rowItem );
|
||||
|
||||
if ( delimiter == delim )
|
||||
{
|
||||
@ -994,9 +1003,10 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
||||
if ( delimiter != 0 )
|
||||
currentChar++;
|
||||
}
|
||||
} while ( *currentChar );
|
||||
}
|
||||
while ( *currentChar );
|
||||
|
||||
if ( root->nodes.num() == 0 )
|
||||
if (array_num( root->nodes) == 0 )
|
||||
{
|
||||
GEN_CSV_ASSERT( "unexpected end of input. stream is empty." );
|
||||
error = ECSV_Error__UNEXPECTED_END_OF_INPUT;
|
||||
@ -1006,12 +1016,12 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
||||
/* consider first row as a header. */
|
||||
if ( has_header )
|
||||
{
|
||||
for ( sw i = 0; i < scast( sw, root->nodes.num() ); i++ )
|
||||
for ( ssize i = 0; i < scast(ssize, array_num(root->nodes)); i++ )
|
||||
{
|
||||
CSV_Object* col = root->nodes + i;
|
||||
CSV_Object* hdr = col->nodes;
|
||||
col->name = hdr->string;
|
||||
col->nodes.remove_at( 0 );
|
||||
array_remove_at(col->nodes, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1034,16 +1044,16 @@ void _csv_write_record( FileInfo* file, CSV_Object* node )
|
||||
{
|
||||
case EADT_NAME_STYLE_DOUBLE_QUOTE :
|
||||
{
|
||||
str_fmt_file( file, "\"" );
|
||||
c_str_fmt_file( file, "\"" );
|
||||
adt_print_string( file, node, "\"", "\"" );
|
||||
str_fmt_file( file, "\"" );
|
||||
c_str_fmt_file( file, "\"" );
|
||||
}
|
||||
break;
|
||||
|
||||
case EADT_NAME_STYLE_NO_QUOTES :
|
||||
{
|
||||
#endif
|
||||
str_fmt_file( file, "%s", node->string );
|
||||
c_str_fmt_file( file, "%s", node->string );
|
||||
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
||||
}
|
||||
break;
|
||||
@ -1074,11 +1084,11 @@ void csv_write_delimiter( FileInfo* file, CSV_Object* obj, char delimiter )
|
||||
GEN_ASSERT_NOT_NULL( file );
|
||||
GEN_ASSERT_NOT_NULL( obj );
|
||||
GEN_ASSERT( obj->nodes );
|
||||
sw cols = obj->nodes.num();
|
||||
ssize cols = array_num(obj->nodes);
|
||||
if ( cols == 0 )
|
||||
return;
|
||||
|
||||
sw rows = obj->nodes[0].nodes.num();
|
||||
ssize rows = array_num(obj->nodes[ 0 ].nodes);
|
||||
if ( rows == 0 )
|
||||
return;
|
||||
|
||||
@ -1086,43 +1096,46 @@ void csv_write_delimiter( FileInfo* file, CSV_Object* obj, char delimiter )
|
||||
|
||||
if ( has_headers )
|
||||
{
|
||||
for ( sw i = 0; i < cols; i++ )
|
||||
for ( ssize i = 0; i < cols; i++ )
|
||||
{
|
||||
_csv_write_header( file, &obj->nodes[ i ] );
|
||||
if ( i + 1 != cols )
|
||||
{
|
||||
str_fmt_file( file, "%c", delimiter );
|
||||
c_str_fmt_file( file, "%c", delimiter );
|
||||
}
|
||||
}
|
||||
str_fmt_file( file, "\n" );
|
||||
c_str_fmt_file( file, "\n" );
|
||||
}
|
||||
|
||||
for ( sw r = 0; r < rows; r++ )
|
||||
for ( ssize r = 0; r < rows; r++ )
|
||||
{
|
||||
for ( sw i = 0; i < cols; i++ )
|
||||
for ( ssize i = 0; i < cols; i++ )
|
||||
{
|
||||
_csv_write_record( file, &obj->nodes[ i ].nodes[ r ] );
|
||||
if ( i + 1 != cols )
|
||||
{
|
||||
str_fmt_file( file, "%c", delimiter );
|
||||
c_str_fmt_file( file, "%c", delimiter );
|
||||
}
|
||||
}
|
||||
str_fmt_file( file, "\n" );
|
||||
c_str_fmt_file( file, "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
String csv_write_string_delimiter( AllocatorInfo a, CSV_Object* obj, char delimiter )
|
||||
StrBuilder csv_write_strbuilder_delimiter( AllocatorInfo a, CSV_Object* obj, char delimiter )
|
||||
{
|
||||
FileInfo tmp;
|
||||
file_stream_new( &tmp, a );
|
||||
csv_write_delimiter( &tmp, obj, delimiter );
|
||||
sw fsize;
|
||||
|
||||
ssize fsize;
|
||||
u8* buf = file_stream_buf( &tmp, &fsize );
|
||||
String output = String::make_length( a, (char*)buf, fsize );
|
||||
StrBuilder output = strbuilder_make_length( a, ( char* )buf, fsize );
|
||||
file_close( &tmp );
|
||||
return output;
|
||||
}
|
||||
|
||||
#undef _adt_fprintf
|
||||
|
||||
#pragma endregion CSV
|
||||
|
||||
GEN_NS_END
|
||||
|
@ -11,6 +11,9 @@
|
||||
# pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||
# pragma clang diagnostic ignored "-Wvarargs"
|
||||
# pragma clang diagnostic ignored "-Wunused-function"
|
||||
# pragma clang diagnostic ignored "-Wbraced-scalar-init"
|
||||
# pragma clang diagnostic ignored "-W#pragma-messages"
|
||||
# pragma clang diagnostic ignored "-Wstatic-in-inline"
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
@ -106,7 +109,7 @@ struct ADT_Node
|
||||
union
|
||||
{
|
||||
char const* string;
|
||||
Array<ADT_Node> nodes; ///< zpl_array
|
||||
Array(ADT_Node) nodes; ///< zpl_array
|
||||
|
||||
struct
|
||||
{
|
||||
@ -201,7 +204,7 @@ ADT_Node* adt_find( ADT_Node* node, char const* name, b32 deep_search );
|
||||
* @param index
|
||||
* @return zpl_adt_node * node
|
||||
*/
|
||||
ADT_Node* adt_alloc_at( ADT_Node* parent, sw index );
|
||||
ADT_Node* adt_alloc_at( ADT_Node* parent, ssize index );
|
||||
|
||||
/**
|
||||
* @brief Allocate an unitialised node within a container.
|
||||
@ -219,7 +222,7 @@ ADT_Node* adt_alloc( ADT_Node* parent );
|
||||
* @param index
|
||||
* @return zpl_adt_node * node
|
||||
*/
|
||||
ADT_Node* adt_move_node_at( ADT_Node* node, ADT_Node* new_parent, sw index );
|
||||
ADT_Node* adt_move_node_at( ADT_Node* node, ADT_Node* new_parent, ssize index );
|
||||
|
||||
/**
|
||||
* @brief Move an existing node to a new container.
|
||||
@ -372,7 +375,7 @@ char* adt_parse_number_strict( ADT_Node* node, char* base_str );
|
||||
* @param node
|
||||
* @return
|
||||
*/
|
||||
ADT_Error adt_str_to_number( ADT_Node* node );
|
||||
ADT_Error adt_c_str_to_number( ADT_Node* node );
|
||||
|
||||
/**
|
||||
* @brief Parses and converts an existing string node into a number.
|
||||
@ -381,7 +384,7 @@ ADT_Error adt_str_to_number( ADT_Node* node );
|
||||
* @param node
|
||||
* @return
|
||||
*/
|
||||
ADT_Error adt_str_to_number_strict( ADT_Node* node );
|
||||
ADT_Error adt_c_str_to_number_strict( ADT_Node* node );
|
||||
|
||||
/**
|
||||
* @brief Prints a number into a file stream.
|
||||
@ -423,192 +426,67 @@ enum CSV_Error : u32
|
||||
|
||||
typedef ADT_Node CSV_Object;
|
||||
|
||||
GEN_DEF_INLINE u8 csv_parse( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header );
|
||||
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 );
|
||||
|
||||
GEN_DEF_INLINE void csv_write( FileInfo* file, CSV_Object* obj );
|
||||
GEN_DEF_INLINE String csv_write_string( AllocatorInfo a, 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 );
|
||||
String csv_write_string_delimiter( AllocatorInfo a, CSV_Object* obj, char delim );
|
||||
StrBuilder csv_write_strbuilder_delimiter( AllocatorInfo a, CSV_Object* obj, char delim );
|
||||
|
||||
/* inline */
|
||||
|
||||
GEN_IMPL_INLINE u8 csv_parse( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header )
|
||||
inline
|
||||
u8 csv_parse( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header )
|
||||
{
|
||||
return csv_parse_delimiter( root, text, allocator, has_header, ',' );
|
||||
}
|
||||
|
||||
GEN_IMPL_INLINE void csv_write( FileInfo* file, CSV_Object* obj )
|
||||
inline
|
||||
void csv_write( FileInfo* file, CSV_Object* obj )
|
||||
{
|
||||
csv_write_delimiter( file, obj, ',' );
|
||||
}
|
||||
|
||||
GEN_IMPL_INLINE String csv_write_string( AllocatorInfo a, CSV_Object* obj )
|
||||
inline
|
||||
StrBuilder csv_write_string( AllocatorInfo a, CSV_Object* obj )
|
||||
{
|
||||
return csv_write_string_delimiter( a, obj, ',' );
|
||||
return csv_write_strbuilder_delimiter( a, obj, ',' );
|
||||
}
|
||||
|
||||
#pragma endregion CSV
|
||||
|
||||
#pragma region Scanner
|
||||
|
||||
// This is a simple file reader that reads the entire file into memory.
|
||||
// It has an extra option to skip the first few lines for undesired includes.
|
||||
// This is done so that includes can be kept in dependency and component files so that intellisense works.
|
||||
inline Code scan_file( char const* path )
|
||||
{
|
||||
FileInfo file;
|
||||
Code scan_file( char const* path );
|
||||
|
||||
FileError error = file_open_mode( &file, EFileMode_READ, path );
|
||||
if ( error != EFileError_NONE )
|
||||
{
|
||||
GEN_FATAL( "scan_file: Could not open: %s", path );
|
||||
}
|
||||
CodeBody parse_file( const char* path );
|
||||
|
||||
sw fsize = file_size( &file );
|
||||
if ( fsize <= 0 )
|
||||
{
|
||||
GEN_FATAL( "scan_file: %s is empty", path );
|
||||
}
|
||||
// The follow is basic support for light csv parsing (use it as an example)
|
||||
// Make something robust if its more serious.
|
||||
|
||||
String str = String::make_reserve( GlobalAllocator, fsize );
|
||||
file_read( &file, str, fsize );
|
||||
str.get_header().Length = fsize;
|
||||
|
||||
// Skip GEN_INTELLISENSE_DIRECTIVES preprocessor blocks
|
||||
// Its designed so that the directive should be the first thing in the file.
|
||||
// Anything that comes before it will also be omitted.
|
||||
{
|
||||
#define current ( *scanner )
|
||||
#define matched 0
|
||||
#define move_fwd() \
|
||||
do \
|
||||
{ \
|
||||
++scanner; \
|
||||
--left; \
|
||||
} while ( 0 )
|
||||
const StrC directive_start = txt( "ifdef" );
|
||||
const StrC directive_end = txt( "endif" );
|
||||
const StrC def_intellisense = txt( "GEN_INTELLISENSE_DIRECTIVES" );
|
||||
|
||||
bool found_directive = false;
|
||||
char const* scanner = str.Data;
|
||||
s32 left = fsize;
|
||||
while ( left )
|
||||
{
|
||||
// Processing directive.
|
||||
if ( current == '#' )
|
||||
{
|
||||
move_fwd();
|
||||
while ( left && char_is_space( current ) )
|
||||
move_fwd();
|
||||
|
||||
if ( ! found_directive )
|
||||
{
|
||||
if ( left && str_compare( scanner, directive_start.Ptr, directive_start.Len ) == matched )
|
||||
{
|
||||
scanner += directive_start.Len;
|
||||
left -= directive_start.Len;
|
||||
|
||||
while ( left && char_is_space( current ) )
|
||||
move_fwd();
|
||||
|
||||
if ( left && str_compare( scanner, def_intellisense.Ptr, def_intellisense.Len ) == matched )
|
||||
{
|
||||
scanner += def_intellisense.Len;
|
||||
left -= def_intellisense.Len;
|
||||
|
||||
found_directive = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Skip to end of line
|
||||
while ( left && current != '\r' && current != '\n' )
|
||||
move_fwd();
|
||||
move_fwd();
|
||||
|
||||
if ( left && current == '\n' )
|
||||
move_fwd();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( left && str_compare( scanner, directive_end.Ptr, directive_end.Len ) == matched )
|
||||
{
|
||||
scanner += directive_end.Len;
|
||||
left -= directive_end.Len;
|
||||
|
||||
// Skip to end of line
|
||||
while ( left && current != '\r' && current != '\n' )
|
||||
move_fwd();
|
||||
move_fwd();
|
||||
|
||||
if ( left && current == '\n' )
|
||||
move_fwd();
|
||||
|
||||
// sptr skip_size = fsize - left;
|
||||
if ( ( scanner + 2 ) >= ( str.Data + fsize ) )
|
||||
{
|
||||
mem_move( str, scanner, left );
|
||||
str.get_header().Length = left;
|
||||
break;
|
||||
}
|
||||
|
||||
mem_move( str, scanner, left );
|
||||
str.get_header().Length = left;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
move_fwd();
|
||||
}
|
||||
#undef move_fwd
|
||||
#undef matched
|
||||
#undef current
|
||||
}
|
||||
|
||||
file_close( &file );
|
||||
return untyped_str( str );
|
||||
}
|
||||
|
||||
#if 0
|
||||
struct CodeFile
|
||||
{
|
||||
using namespace Parser;
|
||||
|
||||
String FilePath;
|
||||
TokArray Tokens;
|
||||
Array<ParseFailure> ParseFailures;
|
||||
Code CodeRoot;
|
||||
typedef struct CSV_Column CSV_Column;
|
||||
struct CSV_Column {
|
||||
CSV_Object ADT;
|
||||
Array(ADT_Node) Content;
|
||||
};
|
||||
|
||||
namespace Parser
|
||||
{
|
||||
struct ParseFailure
|
||||
{
|
||||
String Reason;
|
||||
Code Node;
|
||||
typedef struct CSV_Columns2 CSV_Columns2;
|
||||
struct CSV_Columns2 {
|
||||
CSV_Object ADT;
|
||||
Array(ADT_Node) Col_1;
|
||||
Array(ADT_Node) Col_2;
|
||||
};
|
||||
}
|
||||
|
||||
CodeFile scan_file( char const* path )
|
||||
{
|
||||
using namespace Parser;
|
||||
CSV_Column parse_csv_one_column(AllocatorInfo allocator, char const* path);
|
||||
CSV_Columns2 parse_csv_two_columns(AllocatorInfo allocator, char const* path);
|
||||
|
||||
CodeFile
|
||||
result = {};
|
||||
result.FilePath = String::make( GlobalAllocator, path );
|
||||
#pragma endregion Scanner
|
||||
|
||||
Code code = scan_file( path );
|
||||
result.CodeRoot = code;
|
||||
|
||||
ParseContext context = parser_get_last_context();
|
||||
result.Tokens = context.Tokens;
|
||||
result.ParseFailures = context.Failures;
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
GEN_NS_END
|
||||
|
||||
#ifdef __clang__
|
||||
|
Loading…
Reference in New Issue
Block a user