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.
|
Validation and construction through a functional interface.
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
Code t_uw = def_type( name(uw) );
|
Code t_uw = def_type( name(usize) );
|
||||||
Code t_allocator = def_type( name(allocator) );
|
Code t_allocator = def_type( name(allocator) );
|
||||||
Code t_string_const = def_type( name(char), def_specifiers( args( ESpecifier::Const, ESpecifier::Ptr ) ));
|
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(
|
Code header = parse_struct( code(
|
||||||
struct ArrayHeader
|
struct ArrayHeader
|
||||||
{
|
{
|
||||||
uw Num;
|
usize Num;
|
||||||
uw Capacity;
|
usize Capacity;
|
||||||
allocator Allocator;
|
allocator Allocator;
|
||||||
};
|
};
|
||||||
));
|
));
|
||||||
@ -106,8 +106,8 @@ No validation, just glorified text injection.
|
|||||||
Code header = code_str(
|
Code header = code_str(
|
||||||
struct ArrayHeader
|
struct ArrayHeader
|
||||||
{
|
{
|
||||||
uw Num;
|
usize Num;
|
||||||
uw Capacity;
|
usize Capacity;
|
||||||
allocator Allocator;
|
allocator Allocator;
|
||||||
};
|
};
|
||||||
);
|
);
|
||||||
@ -123,8 +123,8 @@ All three constrcuton interfaces will generate the following C code:
|
|||||||
```cpp
|
```cpp
|
||||||
struct ArrayHeader
|
struct ArrayHeader
|
||||||
{
|
{
|
||||||
uw Num;
|
usize Num;
|
||||||
uw Capacity;
|
usize Capacity;
|
||||||
allocator Allocator;
|
allocator Allocator;
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
@ -136,7 +136,7 @@ The width dictates how much the static array can hold before it must give way to
|
|||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
constexpr static
|
constexpr static
|
||||||
uw ArrSpecs_Cap =
|
usize ArrSpecs_Cap =
|
||||||
(
|
(
|
||||||
AST_POD_Size
|
AST_POD_Size
|
||||||
- sizeof(AST*) * 3
|
- sizeof(AST*) * 3
|
||||||
@ -158,7 +158,7 @@ Data Notes:
|
|||||||
* Most of the work is just defining the allocation procedure:
|
* Most of the work is just defining the allocation procedure:
|
||||||
|
|
||||||
```cpp
|
```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.
|
* 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 ];
|
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
|
ssize capacity() const
|
||||||
{
|
{
|
||||||
Header const&
|
Header const&
|
||||||
|
@ -23,9 +23,12 @@ using namespace gen;
|
|||||||
|
|
||||||
int gen_main()
|
int gen_main()
|
||||||
{
|
{
|
||||||
gen::init();
|
ctx = {};
|
||||||
|
gen::init(& ctx);
|
||||||
log_fmt("Generating code for the Gasa module\n");
|
log_fmt("Generating code for the Gasa module\n");
|
||||||
|
|
||||||
|
Array(StrCached)& PreprocessorDefines = ctx.PreprocessorDefines;
|
||||||
|
|
||||||
// Initialize Globals
|
// Initialize Globals
|
||||||
{
|
{
|
||||||
UHT_UCLASS = code_str( UCLASS() );
|
UHT_UCLASS = code_str( UCLASS() );
|
||||||
@ -37,50 +40,50 @@ int gen_main()
|
|||||||
|
|
||||||
// Populate Defines
|
// Populate Defines
|
||||||
{
|
{
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_CLASS));
|
PreprocessorDefines.append( cache_str(str_DECLARE_CLASS));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_RetVal_OneParam));
|
PreprocessorDefines.append( cache_str(str_DECLARE_DELEGATE_RetVal_OneParam));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_RetVal_ThreeParams));
|
PreprocessorDefines.append( cache_str(str_DECLARE_DELEGATE_RetVal_ThreeParams));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_SixParams));
|
PreprocessorDefines.append( cache_str(str_DECLARE_DELEGATE_SixParams));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam));
|
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams));
|
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams));
|
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams));
|
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam));
|
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams));
|
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams));
|
PreprocessorDefines.append( cache_str(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_EVENT_ThreeParams));
|
PreprocessorDefines.append( cache_str(str_DECLARE_EVENT_ThreeParams));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_EVENT_TwoParams));
|
PreprocessorDefines.append( cache_str(str_DECLARE_EVENT_TwoParams));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_FUNCTION));
|
PreprocessorDefines.append( cache_str(str_DECLARE_FUNCTION));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_LOG_CATEGORY_EXTERN));
|
PreprocessorDefines.append( cache_str(str_DECLARE_LOG_CATEGORY_EXTERN));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_OneParam));
|
PreprocessorDefines.append( cache_str(str_DECLARE_MULTICAST_DELEGATE_OneParam));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_ThreeParams));
|
PreprocessorDefines.append( cache_str(str_DECLARE_MULTICAST_DELEGATE_ThreeParams));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_TwoParams));
|
PreprocessorDefines.append( cache_str(str_DECLARE_MULTICAST_DELEGATE_TwoParams));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_TS_MULTICAST_DELEGATE_OneParam));
|
PreprocessorDefines.append( cache_str(str_DECLARE_TS_MULTICAST_DELEGATE_OneParam));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_TS_MULTICAST_DELEGATE_TwoParams));
|
PreprocessorDefines.append( cache_str(str_DECLARE_TS_MULTICAST_DELEGATE_TwoParams));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_TS_MULTICAST_DELEGATE_ThreeParams));
|
PreprocessorDefines.append( cache_str(str_DECLARE_TS_MULTICAST_DELEGATE_ThreeParams));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DEFINE_ACTORDESC_TYPE));
|
PreprocessorDefines.append( cache_str(str_DEFINE_ACTORDESC_TYPE));
|
||||||
PreprocessorDefines.append( get_cached_string(str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL));
|
PreprocessorDefines.append( cache_str(str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL));
|
||||||
PreprocessorDefines.append( get_cached_string(str_ENUM_CLASS_FLAGS));
|
PreprocessorDefines.append( cache_str(str_ENUM_CLASS_FLAGS));
|
||||||
PreprocessorDefines.append( get_cached_string(str_FORCEINLINE_DEBUGGABLE));
|
PreprocessorDefines.append( cache_str(str_FORCEINLINE_DEBUGGABLE));
|
||||||
// PreprocessorDefines.append( get_cached_string(str_FORCEINLINE));
|
// PreprocessorDefines.append( get_cached_string(str_FORCEINLINE));
|
||||||
PreprocessorDefines.append( get_cached_string(str_GENERATED_BODY));
|
PreprocessorDefines.append( cache_str(str_GENERATED_BODY));
|
||||||
PreprocessorDefines.append( get_cached_string(str_GENERATED_UCLASS_BODY));
|
PreprocessorDefines.append( cache_str(str_GENERATED_UCLASS_BODY));
|
||||||
PreprocessorDefines.append( get_cached_string(str_GENERATED_USTRUCT_BODY));
|
PreprocessorDefines.append( cache_str(str_GENERATED_USTRUCT_BODY));
|
||||||
PreprocessorDefines.append( get_cached_string(str_PRAGMA_DISABLE_DEPRECATION_WARNINGS));
|
PreprocessorDefines.append( cache_str(str_PRAGMA_DISABLE_DEPRECATION_WARNINGS));
|
||||||
PreprocessorDefines.append( get_cached_string(str_PRAGMA_ENABLE_DEPRECATION_WARNINGS));
|
PreprocessorDefines.append( cache_str(str_PRAGMA_ENABLE_DEPRECATION_WARNINGS));
|
||||||
PreprocessorDefines.append( get_cached_string(str_PROPERTY_BINDING_IMPLEMENTATION));
|
PreprocessorDefines.append( cache_str(str_PROPERTY_BINDING_IMPLEMENTATION));
|
||||||
PreprocessorDefines.append( get_cached_string(str_RESULT_DECL));
|
PreprocessorDefines.append( cache_str(str_RESULT_DECL));
|
||||||
PreprocessorDefines.append( get_cached_string(str_SLATE_BEGIN_ARGS));
|
PreprocessorDefines.append( cache_str(str_SLATE_BEGIN_ARGS));
|
||||||
PreprocessorDefines.append( get_cached_string(str_SLATE_END_ARGS));
|
PreprocessorDefines.append( cache_str(str_SLATE_END_ARGS));
|
||||||
PreprocessorDefines.append( get_cached_string(str_TEXT));
|
PreprocessorDefines.append( cache_str(str_TEXT));
|
||||||
PreprocessorDefines.append( get_cached_string(str_UCLASS));
|
PreprocessorDefines.append( cache_str(str_UCLASS));
|
||||||
PreprocessorDefines.append( get_cached_string(str_UENUM));
|
PreprocessorDefines.append( cache_str(str_UENUM));
|
||||||
PreprocessorDefines.append( get_cached_string(str_UFUNCTION));
|
PreprocessorDefines.append( cache_str(str_UFUNCTION));
|
||||||
PreprocessorDefines.append( get_cached_string(str_UMETA));
|
PreprocessorDefines.append( cache_str(str_UMETA));
|
||||||
PreprocessorDefines.append( get_cached_string(str_UPARAM));
|
PreprocessorDefines.append( cache_str(str_UPARAM));
|
||||||
PreprocessorDefines.append( get_cached_string(str_UPROPERTY));
|
PreprocessorDefines.append( cache_str(str_UPROPERTY));
|
||||||
PreprocessorDefines.append( get_cached_string(str_USTRUCT));
|
PreprocessorDefines.append( cache_str(str_USTRUCT));
|
||||||
PreprocessorDefines.append( get_cached_string(str_UE_REQUIRES));
|
PreprocessorDefines.append( cache_str(str_UE_REQUIRES));
|
||||||
}
|
}
|
||||||
|
|
||||||
// gen_UGasaAttributeSet();
|
// gen_UGasaAttributeSet();
|
||||||
|
@ -18,52 +18,52 @@ using namespace gen;
|
|||||||
#define path_gasa_game path_module_gasa "Game/"
|
#define path_gasa_game path_module_gasa "Game/"
|
||||||
#define path_gasa_ui path_module_gasa "UI/"
|
#define path_gasa_ui path_module_gasa "UI/"
|
||||||
|
|
||||||
constexpr StrC str_DECLARE_CLASS = txt("DECLARE_CLASS(");
|
constexpr Str str_DECLARE_CLASS = txt("DECLARE_CLASS(");
|
||||||
constexpr StrC str_DECLARE_DELEGATE_RetVal_OneParam = txt("DECLARE_DELEGATE_RetVal_OneParam(");
|
constexpr Str str_DECLARE_DELEGATE_RetVal_OneParam = txt("DECLARE_DELEGATE_RetVal_OneParam(");
|
||||||
constexpr StrC str_DECLARE_DELEGATE_RetVal_ThreeParams = txt("DECLARE_DELEGATE_RetVal_ThreeParams(");
|
constexpr Str str_DECLARE_DELEGATE_RetVal_ThreeParams = txt("DECLARE_DELEGATE_RetVal_ThreeParams(");
|
||||||
constexpr StrC str_DECLARE_DELEGATE_SixParams = txt("DECLARE_DELEGATE_SixParams(");
|
constexpr Str str_DECLARE_DELEGATE_SixParams = txt("DECLARE_DELEGATE_SixParams(");
|
||||||
constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam = txt("DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(");
|
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam = txt("DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(");
|
||||||
constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams(");
|
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams(");
|
||||||
constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams(");
|
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams(");
|
||||||
constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams(");
|
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams(");
|
||||||
constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(");
|
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(");
|
||||||
constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams(");
|
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams(");
|
||||||
constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams(");
|
constexpr Str str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams(");
|
||||||
constexpr StrC str_DECLARE_EVENT_ThreeParams = txt("DECLARE_EVENT_ThreeParams(");
|
constexpr Str str_DECLARE_EVENT_ThreeParams = txt("DECLARE_EVENT_ThreeParams(");
|
||||||
constexpr StrC str_DECLARE_EVENT_TwoParams = txt("DECLARE_EVENT_TwoParams(");
|
constexpr Str str_DECLARE_EVENT_TwoParams = txt("DECLARE_EVENT_TwoParams(");
|
||||||
constexpr StrC str_DECLARE_FUNCTION = txt("DECLARE_FUNCTION(");
|
constexpr Str str_DECLARE_FUNCTION = txt("DECLARE_FUNCTION(");
|
||||||
constexpr StrC str_DECLARE_LOG_CATEGORY_EXTERN = txt("DECLARE_LOG_CATEGORY_EXTERN(");
|
constexpr Str str_DECLARE_LOG_CATEGORY_EXTERN = txt("DECLARE_LOG_CATEGORY_EXTERN(");
|
||||||
constexpr StrC str_DECLARE_MULTICAST_DELEGATE_OneParam = txt("DECLARE_MULTICAST_DELEGATE_OneParam(");
|
constexpr Str str_DECLARE_MULTICAST_DELEGATE_OneParam = txt("DECLARE_MULTICAST_DELEGATE_OneParam(");
|
||||||
constexpr StrC str_DECLARE_MULTICAST_DELEGATE_ThreeParams = txt("DECLARE_MULTICAST_DELEGATE_ThreeParams(");
|
constexpr Str str_DECLARE_MULTICAST_DELEGATE_ThreeParams = txt("DECLARE_MULTICAST_DELEGATE_ThreeParams(");
|
||||||
constexpr StrC str_DECLARE_MULTICAST_DELEGATE_TwoParams = txt("DECLARE_MULTICAST_DELEGATE_TwoParams(");
|
constexpr Str str_DECLARE_MULTICAST_DELEGATE_TwoParams = txt("DECLARE_MULTICAST_DELEGATE_TwoParams(");
|
||||||
constexpr StrC str_DECLARE_TS_MULTICAST_DELEGATE_OneParam = txt("DECLARE_TS_MULTICAST_DELEGATE_OneParam(");
|
constexpr Str str_DECLARE_TS_MULTICAST_DELEGATE_OneParam = txt("DECLARE_TS_MULTICAST_DELEGATE_OneParam(");
|
||||||
constexpr StrC str_DECLARE_TS_MULTICAST_DELEGATE_TwoParams = txt("DECLARE_TS_MULTICAST_DELEGATE_TwoParams(");
|
constexpr Str str_DECLARE_TS_MULTICAST_DELEGATE_TwoParams = txt("DECLARE_TS_MULTICAST_DELEGATE_TwoParams(");
|
||||||
constexpr StrC str_DECLARE_TS_MULTICAST_DELEGATE_ThreeParams = txt("DECLARE_TS_MULTICAST_DELEGATE_ThreeParams(");
|
constexpr Str str_DECLARE_TS_MULTICAST_DELEGATE_ThreeParams = txt("DECLARE_TS_MULTICAST_DELEGATE_ThreeParams(");
|
||||||
constexpr StrC str_DEFINE_ACTORDESC_TYPE = txt("DEFINE_ACTORDESC_TYPE(");
|
constexpr Str str_DEFINE_ACTORDESC_TYPE = txt("DEFINE_ACTORDESC_TYPE(");
|
||||||
constexpr StrC str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL = txt("DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(");
|
constexpr Str str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL = txt("DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(");
|
||||||
constexpr StrC str_ENUM_CLASS_FLAGS = txt("ENUM_CLASS_FLAGS(");
|
constexpr Str str_ENUM_CLASS_FLAGS = txt("ENUM_CLASS_FLAGS(");
|
||||||
// constexpr StrC str_FORCEINLINE = txt("FORCEINLINE");
|
// constexpr StrC str_FORCEINLINE = txt("FORCEINLINE");
|
||||||
constexpr StrC str_FORCEINLINE_DEBUGGABLE = txt("FORCEINLINE_DEBUGGABLE");
|
constexpr Str str_FORCEINLINE_DEBUGGABLE = txt("FORCEINLINE_DEBUGGABLE");
|
||||||
constexpr StrC str_GENERATED_BODY = txt("GENERATED_BODY(");
|
constexpr Str str_GENERATED_BODY = txt("GENERATED_BODY(");
|
||||||
constexpr StrC str_GENERATED_UCLASS_BODY = txt("GENERATED_UCLASS_BODY(");
|
constexpr Str str_GENERATED_UCLASS_BODY = txt("GENERATED_UCLASS_BODY(");
|
||||||
constexpr StrC str_GENERATED_USTRUCT_BODY = txt("GENERATED_USTRUCT_BODY(");
|
constexpr Str str_GENERATED_USTRUCT_BODY = txt("GENERATED_USTRUCT_BODY(");
|
||||||
constexpr StrC str_PRAGMA_DISABLE_DEPRECATION_WARNINGS = txt("PRAGMA_DISABLE_DEPRECATION_WARNINGS");
|
constexpr Str str_PRAGMA_DISABLE_DEPRECATION_WARNINGS = txt("PRAGMA_DISABLE_DEPRECATION_WARNINGS");
|
||||||
constexpr StrC str_PRAGMA_ENABLE_DEPRECATION_WARNINGS = txt("PRAGMA_ENABLE_DEPRECATION_WARNINGS");
|
constexpr Str str_PRAGMA_ENABLE_DEPRECATION_WARNINGS = txt("PRAGMA_ENABLE_DEPRECATION_WARNINGS");
|
||||||
constexpr StrC str_PROPERTY_BINDING_IMPLEMENTATION = txt("PROPERTY_BINDING_IMPLEMENTATION(");
|
constexpr Str str_PROPERTY_BINDING_IMPLEMENTATION = txt("PROPERTY_BINDING_IMPLEMENTATION(");
|
||||||
constexpr StrC str_RESULT_DECL = txt("RESULT_DECL");
|
constexpr Str str_RESULT_DECL = txt("RESULT_DECL");
|
||||||
constexpr StrC str_SLATE_BEGIN_ARGS = txt("SLATE_BEGIN_ARGS(");
|
constexpr Str str_SLATE_BEGIN_ARGS = txt("SLATE_BEGIN_ARGS(");
|
||||||
constexpr StrC str_SLATE_END_ARGS = txt("SLATE_END_ARGS(");
|
constexpr Str str_SLATE_END_ARGS = txt("SLATE_END_ARGS(");
|
||||||
constexpr StrC str_TEXT = txt("TEXT(");
|
constexpr Str str_TEXT = txt("TEXT(");
|
||||||
constexpr StrC str_UCLASS = txt("UCLASS(");
|
constexpr Str str_UCLASS = txt("UCLASS(");
|
||||||
constexpr StrC str_UENUM = txt("UENUM(");
|
constexpr Str str_UENUM = txt("UENUM(");
|
||||||
constexpr StrC str_UFUNCTION = txt("UFUNCTION(");
|
constexpr Str str_UFUNCTION = txt("UFUNCTION(");
|
||||||
constexpr StrC str_UMETA = txt("UMETA(");
|
constexpr Str str_UMETA = txt("UMETA(");
|
||||||
constexpr StrC str_UPARAM = txt("UPARAM(");
|
constexpr Str str_UPARAM = txt("UPARAM(");
|
||||||
constexpr StrC str_UPROPERTY = txt("UPROPERTY(");
|
constexpr Str str_UPROPERTY = txt("UPROPERTY(");
|
||||||
constexpr StrC str_USTRUCT = txt("USTRUCT(");
|
constexpr Str str_USTRUCT = txt("USTRUCT(");
|
||||||
constexpr StrC str_UE_REQUIRES = txt("UE_REQUIRES(");
|
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
|
#pragma region Globals
|
||||||
// These Code objects are created before anything else after gencpp does its initializatioon
|
// These Code objects are created before anything else after gencpp does its initializatioon
|
||||||
@ -74,10 +74,12 @@ global Code UHT_USTRUCT;
|
|||||||
global Code UModule_GASA_API;
|
global Code UModule_GASA_API;
|
||||||
#pragma endregion Globals
|
#pragma endregion Globals
|
||||||
|
|
||||||
|
global Context ctx;
|
||||||
|
|
||||||
inline
|
inline
|
||||||
CodeBody parse_file( char const* path ) {
|
CodeBody parse_file( char const* path ) {
|
||||||
FileContents content = file_read_contents( GlobalAllocator, true, path );
|
FileContents content = file_read_contents( ctx.Allocator_Temp, file_zero_terminate, path );
|
||||||
CodeBody code = parse_global_body( StrC { content.size, (char const*)content.data });
|
CodeBody code = parse_global_body( Str {(char const*)content.data, content.size });
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +94,7 @@ void format_file( char const* path )
|
|||||||
#define cf_format_inplace "-i "
|
#define cf_format_inplace "-i "
|
||||||
#define cf_style "-style=file:" "./scripts/.clang-format "
|
#define cf_style "-style=file:" "./scripts/.clang-format "
|
||||||
#define cf_verbose "-verbose "
|
#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_format_inplace );
|
||||||
command.append( cf_style );
|
command.append( cf_style );
|
||||||
command.append( cf_verbose );
|
command.append( cf_verbose );
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "GasaGenCommon.cpp"
|
#include "GasaGenCommon.cpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
constexpr StrC SBlueprintActionMenu_Construct_Replacement = txt(R"(
|
constexpr Str SBlueprintActionMenu_Construct_Replacement = txt(R"(
|
||||||
void SBlueprintActionMenu::Construct( const FArguments& InArgs, TSharedPtr<FBlueprintEditor> InEditor )
|
void SBlueprintActionMenu::Construct( const FArguments& InArgs, TSharedPtr<FBlueprintEditor> InEditor )
|
||||||
{
|
{
|
||||||
bActionExecuted = false;
|
bActionExecuted = false;
|
||||||
@ -249,23 +249,22 @@ void swap_SBlueprintActionMenu_Construct()
|
|||||||
#define path_SBlueprintActionMenuCpp \
|
#define path_SBlueprintActionMenuCpp \
|
||||||
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Editor\Kismet\Private\SBlueprintActionMenu.cpp)"
|
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Editor\Kismet\Private\SBlueprintActionMenu.cpp)"
|
||||||
|
|
||||||
FileContents content = file_read_contents( GlobalAllocator, true, path_SBlueprintActionMenuCpp );
|
FileContents content = file_read_contents( ctx.Allocator_Temp, true, path_SBlueprintActionMenuCpp );
|
||||||
CodeBody parsed_SBlueprintActionMenu = parse_global_body( StrC { content.size, (char const*)content.data });
|
CodeBody parsed_SBlueprintActionMenu = parse_global_body( Str { (char const*)content.data, content.size });
|
||||||
|
|
||||||
CodeFn signature_to_change = parse_function( code(
|
CodeFn signature_to_change = parse_function( code(
|
||||||
void SBlueprintActionMenu::Construct( const FArguments& InArgs, TSharedPtr<FBlueprintEditor> InEditor ) {}
|
void SBlueprintActionMenu::Construct( const FArguments& InArgs, TSharedPtr<FBlueprintEditor> InEditor ) {}
|
||||||
));
|
));
|
||||||
|
|
||||||
CodeBody changed_SBlueprintActionMenu = def_body(ECode::Global_Body);
|
CodeBody changed_SBlueprintActionMenu = def_body(CT_Global_Body);
|
||||||
for ( Code code : parsed_SBlueprintActionMenu )
|
for ( Code code : parsed_SBlueprintActionMenu )
|
||||||
{
|
{
|
||||||
switch ( code->Type )
|
switch ( code->Type )
|
||||||
{
|
{
|
||||||
using namespace ECode;
|
case CT_Function:
|
||||||
case Function:
|
CodeFn function_def = cast(CodeFn, code);
|
||||||
CodeFn function_def = code.cast<CodeFn>();
|
|
||||||
|
|
||||||
if ( String::are_equal(function_def->Name, signature_to_change->Name)
|
if ( str_are_equal(function_def->Name, signature_to_change->Name)
|
||||||
&& function_def->Params.is_equal(signature_to_change->Params))
|
&& function_def->Params.is_equal(signature_to_change->Params))
|
||||||
{
|
{
|
||||||
code = parse_function( SBlueprintActionMenu_Construct_Replacement );
|
code = parse_function( SBlueprintActionMenu_Construct_Replacement );
|
||||||
|
@ -10,36 +10,36 @@ using namespace gen;
|
|||||||
|
|
||||||
void gen_FGasaDevOptionsCache()
|
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" );
|
CodeBody header_GasaDevOptions = parse_file( path_module_gasa "GasaDevOptions.h" );
|
||||||
CodeClass UGasaDevOptions = NoCode;
|
CodeClass UGasaDevOptions = NullCode;
|
||||||
for (Code entry : header_GasaDevOptions)
|
for (Code entry : header_GasaDevOptions)
|
||||||
{
|
{
|
||||||
if ( entry->Type == ECode::Class && entry->Name.starts_with( txt("UGasaDevOptions")) )
|
if ( entry->Type == CT_Class && entry->Name.starts_with( txt("UGasaDevOptions")) )
|
||||||
{
|
{
|
||||||
UGasaDevOptions = entry.cast<CodeClass>();
|
UGasaDevOptions = cast(CodeClass, entry);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Code member = UGasaDevOptions->Body.begin(); member != UGasaDevOptions->Body.end(); ++ member)
|
for (Code member = UGasaDevOptions->Body.begin(); member != UGasaDevOptions->Body.end(); ++ member)
|
||||||
{
|
{
|
||||||
if ( member->Type == ECode::Untyped && member->Name.starts_with(str_UPROPERTY) )
|
if ( member->Type == CT_Untyped && member->Name.starts_with(str_UPROPERTY) )
|
||||||
++ member;
|
++ member;
|
||||||
if ( member->Type == ECode::Variable
|
if ( member->Type == CT_Variable
|
||||||
&& ( member->ValueType->Name.starts_with( txt("TArray< TSoftObjectPtr"))
|
&& ( member->ValueType->Name.starts_with( txt("TArray< TSoftObjectPtr"))
|
||||||
|| member->ValueType->Name.starts_with( txt("TSoftClassPtr"))
|
|| member->ValueType->Name.starts_with( txt("TSoftClassPtr"))
|
||||||
|| member->ValueType->Name.starts_with( txt("TSoftObjectPtr")) )
|
|| member->ValueType->Name.starts_with( txt("TSoftObjectPtr")) )
|
||||||
)
|
)
|
||||||
GasaDevOptions_UPROPERTIES.append(member.cast<CodeVar>());
|
GasaDevOptions_UPROPERTIES.append(cast(CodeVar, member));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeComment generation_notice = def_comment(txt("Generated by GasaGen/GasaGen_DevOptionsCache.cpp"));
|
CodeComment generation_notice = def_comment(txt("Generated by GasaGen/GasaGen_DevOptionsCache.cpp"));
|
||||||
|
|
||||||
CodeType t_UClassPtr = parse_type(code(UClass*));
|
CodeTypename t_UClassPtr = parse_type(code(UClass*));
|
||||||
CodeType t_UObjectPtr = parse_type(code(UObject*));
|
CodeTypename t_UObjectPtr = parse_type(code(UObject*));
|
||||||
CodeType t_Array_UObjectPtr = parse_type(code(TArray< UObject* >));
|
CodeTypename t_Array_UObjectPtr = parse_type(code(TArray< UObject* >));
|
||||||
|
|
||||||
Builder header = Builder::open( path_module_gasa "GasaDevOptionsCache.h" );
|
Builder header = Builder::open( path_module_gasa "GasaDevOptionsCache.h" );
|
||||||
{
|
{
|
||||||
@ -52,7 +52,7 @@ void gen_FGasaDevOptionsCache()
|
|||||||
header.print( UHT_USTRUCT );
|
header.print( UHT_USTRUCT );
|
||||||
CodeStruct FGasaDevOptionsCache;
|
CodeStruct FGasaDevOptionsCache;
|
||||||
{
|
{
|
||||||
CodeBody body = def_body(ECode::Struct_Body);
|
CodeBody body = def_body(CT_Struct_Body);
|
||||||
{
|
{
|
||||||
body.append(UHT_GENERATED_BODY);
|
body.append(UHT_GENERATED_BODY);
|
||||||
body.append(fmt_newline);
|
body.append(fmt_newline);
|
||||||
@ -74,7 +74,7 @@ void gen_FGasaDevOptionsCache()
|
|||||||
body.append(fmt_newline);
|
body.append(fmt_newline);
|
||||||
body.append( parse_function(code( void CachedDevOptions(); )));
|
body.append( parse_function(code( void CachedDevOptions(); )));
|
||||||
}
|
}
|
||||||
FGasaDevOptionsCache = parse_struct( token_fmt( "body", (StrC)body.to_string(), stringize(
|
FGasaDevOptionsCache = parse_struct( token_fmt( "body", (Str)body.to_strbuilder(), stringize(
|
||||||
struct GASA_API FGasaDevOptionsCache {
|
struct GASA_API FGasaDevOptionsCache {
|
||||||
<body>
|
<body>
|
||||||
};
|
};
|
||||||
@ -88,13 +88,13 @@ void gen_FGasaDevOptionsCache()
|
|||||||
|
|
||||||
Builder source = Builder::open( path_module_gasa "GasaDevOptionsCache.cpp" );
|
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");
|
CodeBody source_GasaDevOptions = parse_file( path_module_gasa "GasaDevOptions.cpp");
|
||||||
for ( Code entry : source_GasaDevOptions )
|
for ( Code entry : source_GasaDevOptions )
|
||||||
{
|
{
|
||||||
if ( entry->Type == ECode::Preprocess_Include )
|
if ( entry->Type == CT_Preprocess_Include )
|
||||||
GasaDevOptions_Includes.append( entry.cast<CodeInclude>() );
|
GasaDevOptions_Includes.append( cast(CodeInclude, entry) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,17 +107,17 @@ void gen_FGasaDevOptionsCache()
|
|||||||
source.print( parse_using(code( using namespace Gasa; )));
|
source.print( parse_using(code( using namespace Gasa; )));
|
||||||
source.print(fmt_newline);
|
source.print(fmt_newline);
|
||||||
|
|
||||||
CodeBody cached_property_assignments = def_body(ECode::Function_Body);
|
CodeBody cached_property_assignments = def_body(CT_Function_Body);
|
||||||
{
|
{
|
||||||
cached_property_assignments.append(fmt_newline);
|
cached_property_assignments.append(fmt_newline);
|
||||||
cached_property_assignments.append(fmt_newline);
|
cached_property_assignments.append(fmt_newline);
|
||||||
for (CodeVar var : GasaDevOptions_UPROPERTIES)
|
for (CodeVar var : GasaDevOptions_UPROPERTIES)
|
||||||
{
|
{
|
||||||
if ( var->ValueType.to_string().starts_with(txt("TArray")) )
|
if ( var->ValueType.to_strbuilder().starts_with(txt("TArray")) )
|
||||||
{
|
{
|
||||||
#pragma push_macro("TEXT")
|
#pragma push_macro("TEXT")
|
||||||
#undef TEXT
|
#undef TEXT
|
||||||
Code assignment = code_fmt( "property_array", (StrC)var->Name, stringize(
|
Code assignment = code_fmt( "property_array", var->Name, stringize(
|
||||||
for ( auto& entry : DevOpts-> <property_array> )
|
for ( auto& entry : DevOpts-> <property_array> )
|
||||||
{
|
{
|
||||||
<property_array>.Push( entry.LoadSynchronous() );
|
<property_array>.Push( entry.LoadSynchronous() );
|
||||||
@ -134,7 +134,7 @@ void gen_FGasaDevOptionsCache()
|
|||||||
|
|
||||||
#pragma push_macro("TEXT")
|
#pragma push_macro("TEXT")
|
||||||
#undef TEXT
|
#undef TEXT
|
||||||
Code assignment = code_fmt( "property", (StrC)var->Name, stringize(
|
Code assignment = code_fmt( "property", var->Name, stringize(
|
||||||
<property> = DevOpts-> <property>.LoadSynchronous();
|
<property> = DevOpts-> <property>.LoadSynchronous();
|
||||||
ensureMsgf(<property> != nullptr, TEXT("<property> is null, DO NOT RUN PIE or else you may get a crash if not handled in BP or C++"));
|
ensureMsgf(<property> != nullptr, TEXT("<property> is null, DO NOT RUN PIE or else you may get a crash if not handled in BP or C++"));
|
||||||
));
|
));
|
||||||
@ -146,7 +146,7 @@ void gen_FGasaDevOptionsCache()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CodeFn CachedDevOptions = parse_function( token_fmt(
|
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(
|
stringize(
|
||||||
void FGasaDevOptionsCache::CachedDevOptions()
|
void FGasaDevOptionsCache::CachedDevOptions()
|
||||||
{
|
{
|
||||||
|
@ -13,10 +13,10 @@ void gen_UHostWidgetController()
|
|||||||
|
|
||||||
CodeBody ori_HostWidgetController_header = parse_file(path_gasa_ui "HostWidgetController.h");
|
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");
|
Str str_UHostWidgetController = txt("UHostWidgetController");
|
||||||
CodeClass ori_UHostWidgetController = NoCode;
|
CodeClass ori_UHostWidgetController = NullCode;
|
||||||
|
|
||||||
Code file_code = ori_HostWidgetController_header.begin();
|
Code file_code = ori_HostWidgetController_header.begin();
|
||||||
for ( ; file_code != ori_HostWidgetController_header.end(); ++ file_code )
|
for ( ; file_code != ori_HostWidgetController_header.end(); ++ file_code )
|
||||||
@ -30,14 +30,14 @@ void gen_UHostWidgetController()
|
|||||||
header_body.append(file_code);
|
header_body.append(file_code);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case ECode::Class:
|
case CT_Class:
|
||||||
if ( ! file_code->Name.starts_with(str_UHostWidgetController))
|
if ( ! file_code->Name.starts_with(str_UHostWidgetController))
|
||||||
continue;
|
continue;
|
||||||
ori_UHostWidgetController = file_code.cast<CodeClass>();
|
ori_UHostWidgetController = cast(CodeClass, file_code);
|
||||||
++ file_code;
|
++ file_code;
|
||||||
goto found;
|
goto found;
|
||||||
|
|
||||||
case ECode::Preprocess_Include:
|
case CT_Preprocess_Include:
|
||||||
header_body.append(file_code);
|
header_body.append(file_code);
|
||||||
|
|
||||||
if ( file_code->Content.starts_with(txt("HostWidgetController.generated.h")))
|
if ( file_code->Content.starts_with(txt("HostWidgetController.generated.h")))
|
||||||
@ -47,7 +47,7 @@ void gen_UHostWidgetController()
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case ECode::Untyped:
|
case CT_Untyped:
|
||||||
header_body.append(file_code);
|
header_body.append(file_code);
|
||||||
|
|
||||||
if (file_code->Content.starts_with( txt("DECLARE_"))
|
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( def_comment( txt("Attribute Events are generated by GasaGen/GasaGen_HostWidgetController.cpp")));
|
||||||
attribute_events.append(fmt_newline);
|
attribute_events.append(fmt_newline);
|
||||||
@ -72,23 +72,23 @@ void gen_UHostWidgetController()
|
|||||||
));
|
));
|
||||||
attribute_events.append(fmt_newline);
|
attribute_events.append(fmt_newline);
|
||||||
attribute_events.append( parse_variable(
|
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);
|
attribute_events.append(fmt_newline);
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( s32 id = 0; id < attribute_fields.num(); ++id )
|
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(
|
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>();
|
CodeClass new_UHostWidgetController = cast(CodeClass, ori_UHostWidgetController.duplicate());
|
||||||
CodeBody new_body = def_body(ECode::Class_Body);
|
CodeBody new_body = def_body(CT_Class_Body);
|
||||||
for (Code code = ori_UHostWidgetController->Body.begin();
|
for (Code code = ori_UHostWidgetController->Body.begin();
|
||||||
code != ori_UHostWidgetController->Body.end();
|
code != ori_UHostWidgetController->Body.end();
|
||||||
++ code )
|
++ code )
|
||||||
@ -99,7 +99,7 @@ void gen_UHostWidgetController()
|
|||||||
new_body.append(code);
|
new_body.append(code);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case ECode::Preprocess_Pragma:
|
case CT_Preprocess_Pragma:
|
||||||
{
|
{
|
||||||
local_persist bool found = false;
|
local_persist bool found = false;
|
||||||
if (found)
|
if (found)
|
||||||
@ -108,7 +108,7 @@ void gen_UHostWidgetController()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CodePragma pragma = code.cast<CodePragma>();
|
CodePragma pragma = cast(CodePragma, code);
|
||||||
if ( pragma->Content.starts_with(txt("region Attribute Events")) )
|
if ( pragma->Content.starts_with(txt("region Attribute Events")) )
|
||||||
{
|
{
|
||||||
new_body.append(pragma);
|
new_body.append(pragma);
|
||||||
@ -116,7 +116,7 @@ void gen_UHostWidgetController()
|
|||||||
|
|
||||||
new_body.append(attribute_events);
|
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->Content.starts_with(txt("endregion Attribute Events")))
|
||||||
++ code;
|
++ code;
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ void gen_UHostWidgetController()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ECode::Untyped:
|
case CT_Untyped:
|
||||||
new_body.append(code);
|
new_body.append(code);
|
||||||
|
|
||||||
if (code->Content.starts_with( txt("GENERATED_BODY")))
|
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 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)
|
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>() ); )
|
stringize( Event_On<field>Changed.Broadcast( GasaAttribs->Get<field>() ); )
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
BroadcastInitialValues = parse_function( token_fmt(
|
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"),
|
"generation_notice", txt("\n// This function is managed by: GenGasa/GenGasa_HostWidgetController.cpp\n\n"),
|
||||||
stringize(
|
stringize(
|
||||||
void UHostWidgetController::BroadcastInitialValues()
|
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);
|
||||||
bindings.append(fmt_newline);
|
bindings.append(fmt_newline);
|
||||||
for (GAS_AttributeEntry field : attribute_fields)
|
for (GAS_AttributeEntry field : attribute_fields)
|
||||||
{
|
{
|
||||||
bindings.append( code_fmt( "field", (StrC)field.Name,
|
bindings.append( code_fmt( "field", field.Name,
|
||||||
stringize(
|
stringize(
|
||||||
FOnGameplayAttributeValueChange& <field>AttributeChangedDelegate = AbilitySystem->GetGameplayAttributeValueChangeDelegate(GasaAttribs->Get<field>Attribute());
|
FOnGameplayAttributeValueChange& <field>AttributeChangedDelegate = AbilitySystem->GetGameplayAttributeValueChangeDelegate(GasaAttribs->Get<field>Attribute());
|
||||||
<field>AttributeChangedDelegate.AddUObject(this, &ThisClass::<field>Changed);
|
<field>AttributeChangedDelegate.AddUObject(this, &ThisClass::<field>Changed);
|
||||||
@ -199,7 +199,7 @@ void gen_UHostWidgetController()
|
|||||||
|
|
||||||
BindCallbacksToDependencies = parse_function( token_fmt(
|
BindCallbacksToDependencies = parse_function( token_fmt(
|
||||||
"generation_notice", txt("\n// This function is managed by: GenGasa/GenGasa_HostWidgetController.cpp\n\n"),
|
"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(
|
stringize(
|
||||||
void UHostWidgetController::BindCallbacksToDependencies()
|
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( def_comment(txt("Attribute Changed Callbacks are generated by GasaGen/GasaGen_HostWidgetController.cpp")));
|
||||||
attribute_callbacks.append(fmt_newline);
|
attribute_callbacks.append(fmt_newline);
|
||||||
|
|
||||||
for ( s32 id = 0; id < attribute_fields.num(); )
|
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(
|
attribute_callbacks.append( parse_function( token_fmt(
|
||||||
"field", (StrC) attribute_field,
|
"field", (Str) attribute_field,
|
||||||
stringize(
|
stringize(
|
||||||
void UHostWidgetController::<field>Changed(FOnAttributeChangeData const& Attribute)
|
void UHostWidgetController::<field>Changed(FOnAttributeChangeData const& Attribute)
|
||||||
{
|
{
|
||||||
@ -248,7 +248,7 @@ void gen_UHostWidgetController()
|
|||||||
{
|
{
|
||||||
switch (code->Type)
|
switch (code->Type)
|
||||||
{
|
{
|
||||||
case ECode::Preprocess_Pragma:
|
case CT_Preprocess_Pragma:
|
||||||
{
|
{
|
||||||
local_persist bool found = false;
|
local_persist bool found = false;
|
||||||
if (found)
|
if (found)
|
||||||
@ -258,7 +258,7 @@ void gen_UHostWidgetController()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CodePragma pragma = code.cast<CodePragma>();
|
CodePragma pragma = cast(CodePragma, code);
|
||||||
if ( pragma->Content.starts_with(txt("region Attribute Changed Callbacks")) )
|
if ( pragma->Content.starts_with(txt("region Attribute Changed Callbacks")) )
|
||||||
{
|
{
|
||||||
source_body.append(fmt_newline);
|
source_body.append(fmt_newline);
|
||||||
@ -267,7 +267,7 @@ void gen_UHostWidgetController()
|
|||||||
|
|
||||||
source_body.append(attribute_callbacks);
|
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->Content.starts_with(txt("endregion Attribute Changed Callbacks")))
|
||||||
++ code;
|
++ code;
|
||||||
|
|
||||||
@ -276,17 +276,17 @@ void gen_UHostWidgetController()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ECode::Function:
|
case CT_Function:
|
||||||
CodeFn function_def = code.cast<CodeFn>();
|
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))
|
&& function_def->Params.is_equal(BroadcastInitialValues->Params))
|
||||||
{
|
{
|
||||||
source_body.append(BroadcastInitialValues);
|
source_body.append(BroadcastInitialValues);
|
||||||
log_fmt("Swapped: %S\n", BroadcastInitialValues->Name);
|
log_fmt("Swapped: %S\n", BroadcastInitialValues->Name);
|
||||||
continue;
|
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))
|
&& function_def->Params.is_equal(BindCallbacksToDependencies->Params))
|
||||||
{
|
{
|
||||||
source_body.append(BindCallbacksToDependencies);
|
source_body.append(BindCallbacksToDependencies);
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
void gen_netslime_interface(CodeClass aclass)
|
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")
|
#pragma push_macro("FORCEINLINE")
|
||||||
#undef FORCEINLINE
|
#undef FORCEINLINE
|
||||||
@ -44,7 +44,7 @@ void gen_netslime_interface(CodeClass aclass)
|
|||||||
net_slime_class_interface.append(NetLog);
|
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 )
|
for(Code code = aclass->Body.begin(); code != aclass->Body.end(); ++ code )
|
||||||
{
|
{
|
||||||
switch (code->Type)
|
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)
|
// 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.
|
// 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;
|
local_persist bool found = false;
|
||||||
if (found || ! code->Content.starts_with( txt("region NetSlime")))
|
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( def_comment( txt("NetSlime interface is generated by GasaGen/GasaGen_NetSlime.cpp")));
|
||||||
new_body.append(net_slime_class_interface);
|
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->Content.starts_with(txt("endregion NetSlime")))
|
||||||
++ code;
|
++ code;
|
||||||
|
|
||||||
@ -85,23 +85,23 @@ void gen_netslime_interface(CodeClass aclass)
|
|||||||
|
|
||||||
void gen_netslime_interfaces()
|
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_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_actors "GasaActor.h")));
|
||||||
// header_paths.append(get_cached_string(txt( path_gasa_characters "GasaCharacter.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 "GasaGameMode.h")));
|
||||||
// header_paths.append(get_cached_string(txt( path_gasa_game "GasaGameState.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 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)
|
for (Code code : original_header)
|
||||||
{
|
{
|
||||||
switch (code->Type) {
|
switch (code->Type) {
|
||||||
case ECode::Class:
|
case CT_Class:
|
||||||
{
|
{
|
||||||
CodeClass aclass = code.cast<CodeClass>();
|
CodeClass aclass = cast(CodeClass, code);
|
||||||
gen_netslime_interface(aclass);
|
gen_netslime_interface(aclass);
|
||||||
header_body.append(aclass);
|
header_body.append(aclass);
|
||||||
}
|
}
|
||||||
|
@ -9,35 +9,35 @@
|
|||||||
|
|
||||||
struct GAS_AttributeEntry
|
struct GAS_AttributeEntry
|
||||||
{
|
{
|
||||||
StringCached Name;
|
StrCached Name;
|
||||||
// StringCached Description;
|
// StringCached Description;
|
||||||
// StringCached Category;
|
// StringCached Category;
|
||||||
StringCached MinName;
|
StrCached MinName;
|
||||||
StringCached MaxName;
|
StrCached MaxName;
|
||||||
float Min;
|
float Min;
|
||||||
float Max;
|
float Max;
|
||||||
};
|
};
|
||||||
|
|
||||||
void def_attribute_properties ( CodeBody body, Array<GAS_AttributeEntry> properties );
|
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_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_getters ( CodeBody body, Array<GAS_AttributeEntry> properties );
|
||||||
void def_attribute_field_value_setters ( 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 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()
|
Array<GAS_AttributeEntry> get_gasa_primary_attribute_fields()
|
||||||
{
|
{
|
||||||
local_persist
|
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)
|
for (local_persist s32 do_once = 0; do_once == 0; ++ do_once)
|
||||||
{
|
{
|
||||||
StringCached str_Strength = get_cached_string(txt("Strength"));
|
StrCached str_Strength = cache_str(txt("Strength"));
|
||||||
StringCached str_Intelligence = get_cached_string(txt("Intelligence"));
|
StrCached str_Intelligence = cache_str(txt("Intelligence"));
|
||||||
StringCached str_Resilience = get_cached_string(txt("Resilience"));
|
StrCached str_Resilience = cache_str(txt("Resilience"));
|
||||||
StringCached str_Vigor = get_cached_string(txt("Vigor"));
|
StrCached str_Vigor = cache_str(txt("Vigor"));
|
||||||
|
|
||||||
GAS_AttributeEntry Strength = { str_Strength, {nullptr}, {nullptr}, 0, 999.f };
|
GAS_AttributeEntry Strength = { str_Strength, {nullptr}, {nullptr}, 0, 999.f };
|
||||||
GAS_AttributeEntry Intelligence = { str_Intelligence, {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()
|
Array<GAS_AttributeEntry> get_gasa_secondary_attribute_fields()
|
||||||
{
|
{
|
||||||
local_persist
|
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)
|
for (local_persist s32 do_once = 0; do_once == 0; ++ do_once)
|
||||||
{
|
{
|
||||||
// StringCached str_Strength = get_cached_string(txt("Strength"));
|
// StrCached str_Strength = cache_str(txt("Strength"));
|
||||||
// StringCached str_Intelligence = get_cached_string(txt("Intelligence"));
|
// StrCached str_Intelligence = cache_str(txt("Intelligence"));
|
||||||
// StringCached str_Resilience = get_cached_string(txt("Resilience"));
|
// StrCached str_Resilience = cache_str(txt("Resilience"));
|
||||||
// StringCached str_Vigor = get_cached_string(txt("Vigor"));
|
// StrCached str_Vigor = cache_str(txt("Vigor"));
|
||||||
//
|
//
|
||||||
// GAS_AttributeEntry Health = { str_Health, {nullptr}, str_MaxHealth, 0, 100.f };
|
// GAS_AttributeEntry Health = { str_Health, {nullptr}, str_MaxHealth, 0, 100.f };
|
||||||
// GAS_AttributeEntry MaxHealth = { str_MaxHealth, {nullptr}, {nullptr}, 0, 99999.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()
|
Array<GAS_AttributeEntry> get_gasa_vital_attribute_fields()
|
||||||
{
|
{
|
||||||
local_persist
|
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)
|
for (local_persist s32 do_once = 0; do_once == 0; ++ do_once)
|
||||||
{
|
{
|
||||||
StringCached str_Health = get_cached_string(txt("Health"));
|
StrCached str_Health = cache_str(txt("Health"));
|
||||||
StringCached str_MaxHealth = get_cached_string(txt("MaxHealth"));
|
StrCached str_MaxHealth = cache_str(txt("MaxHealth"));
|
||||||
StringCached str_Mana = get_cached_string(txt("Mana"));
|
StrCached str_Mana = cache_str(txt("Mana"));
|
||||||
StringCached str_MaxMana = get_cached_string(txt("MaxMana"));
|
StrCached str_MaxMana = cache_str(txt("MaxMana"));
|
||||||
|
|
||||||
GAS_AttributeEntry Health = { str_Health, {nullptr}, str_MaxHealth, 0, 100.f };
|
GAS_AttributeEntry Health = { str_Health, {nullptr}, str_MaxHealth, 0, 100.f };
|
||||||
GAS_AttributeEntry MaxHealth = { str_MaxHealth, {nullptr}, {nullptr}, 0, 99999.f };
|
GAS_AttributeEntry MaxHealth = { str_MaxHealth, {nullptr}, {nullptr}, 0, 99999.f };
|
||||||
@ -99,8 +99,8 @@ Array<GAS_AttributeEntry> get_gasa_vital_attribute_fields()
|
|||||||
|
|
||||||
void gen_UGasaAttributeSet()
|
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"));
|
CodeComment generation_notice = def_comment(txt("Generated by GasaGen/GasaGen_UGasaAttributeSet.cpp"));
|
||||||
|
|
||||||
Array<GAS_AttributeEntry> primary_attribute_fields = get_gasa_primary_attribute_fields();
|
Array<GAS_AttributeEntry> primary_attribute_fields = get_gasa_primary_attribute_fields();
|
||||||
Array<GAS_AttributeEntry> secondary_attribute_fields = get_gasa_secondary_attribute_fields();
|
Array<GAS_AttributeEntry> secondary_attribute_fields = get_gasa_secondary_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();
|
s32 all_attrib_count = primary_attribute_fields.num() + secondary_attribute_fields.num() + vital_attribute_fields.num();
|
||||||
|
|
||||||
Array< GAS_AttributeEntry>
|
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( primary_attribute_fields);
|
||||||
all_attribute_fields.append( secondary_attribute_fields);
|
all_attribute_fields.append( secondary_attribute_fields);
|
||||||
all_attribute_fields.append( vital_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");
|
Builder header = Builder::open( path_gasa_ability_system "GasaAttributeSet.h");
|
||||||
{
|
{
|
||||||
@ -132,7 +132,7 @@ void gen_UGasaAttributeSet()
|
|||||||
|
|
||||||
CodeClass GasaAttributeSet = {};
|
CodeClass GasaAttributeSet = {};
|
||||||
{
|
{
|
||||||
CodeBody body = def_body( CodeT::Class_Body );
|
CodeBody body = def_body( CT_Class_Body );
|
||||||
{
|
{
|
||||||
body.append( UHT_GENERATED_BODY);
|
body.append( UHT_GENERATED_BODY);
|
||||||
body.append( access_public );
|
body.append( access_public );
|
||||||
@ -201,9 +201,9 @@ void gen_UGasaAttributeSet()
|
|||||||
body.append( GetLifetimeOfReplicatedProps );
|
body.append( GetLifetimeOfReplicatedProps );
|
||||||
body.append( def_pragma( txt("endregion UObject")));
|
body.append( def_pragma( txt("endregion UObject")));
|
||||||
}
|
}
|
||||||
GasaAttributeSet = def_class( class_name, body
|
GasaAttributeSet = def_class( class_name, { body
|
||||||
, type_UAttributeSet, AccessSpec::Public
|
, type_UAttributeSet, AccessSpec_Public
|
||||||
, api_attribute
|
, api_attribute }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ void gen_UGasaAttributeSet()
|
|||||||
inlines.print( def_include(txt("AbilitySystemComponent.h")));
|
inlines.print( def_include(txt("AbilitySystemComponent.h")));
|
||||||
inlines.print(fmt_newline);
|
inlines.print(fmt_newline);
|
||||||
|
|
||||||
CodeBody body = def_body(CodeT::Global_Body);
|
CodeBody body = def_body(CT_Global_Body);
|
||||||
{
|
{
|
||||||
def_attribute_field_property_setter_inlines( body, class_name, all_attribute_fields );
|
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("Networking/GasaNetLibrary.h")));
|
||||||
source.print( def_include( txt("GameplayEffectExtension.h")));
|
source.print( def_include( txt("GameplayEffectExtension.h")));
|
||||||
{
|
{
|
||||||
CodeBody body = def_body( CodeT::Global_Body );
|
CodeBody body = def_body( CT_Global_Body );
|
||||||
body.append(fmt_newline);
|
body.append(fmt_newline);
|
||||||
|
|
||||||
CodeConstructor constructor_for_UGasaAttributeSet = parse_constructor( code(
|
CodeConstructor constructor_for_UGasaAttributeSet = parse_constructor( code(
|
||||||
@ -278,32 +278,32 @@ void gen_UGasaAttributeSet()
|
|||||||
CodeFn PostGameplayEffectExecute;
|
CodeFn PostGameplayEffectExecute;
|
||||||
CodeFn PreAttributeChange;
|
CodeFn PreAttributeChange;
|
||||||
{
|
{
|
||||||
CodeBody pre_attribute_clamps = def_body( CodeT::Function_Body );
|
CodeBody pre_attribute_clamps = def_body( CT_Function_Body );
|
||||||
pre_attribute_clamps.append(fmt_newline);
|
pre_attribute_clamps.append(fmt_newline);
|
||||||
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);
|
||||||
post_attribute_clamps.append(fmt_newline);
|
post_attribute_clamps.append(fmt_newline);
|
||||||
|
|
||||||
for (GAS_AttributeEntry field : all_attribute_fields)
|
for (GAS_AttributeEntry field : all_attribute_fields)
|
||||||
{
|
{
|
||||||
String clamp_min;
|
Str clamp_min;
|
||||||
if (field.MinName.Data)
|
if (field.MinName)
|
||||||
clamp_min = get_cached_string(token_fmt( "MinName", (StrC)field.MinName, "Get<MinName>()"));
|
clamp_min = cache_str(token_fmt( "MinName", field.MinName, "Get<MinName>()"));
|
||||||
else
|
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;
|
Str clamp_max;
|
||||||
if (field.MaxName.Data)
|
if (field.MaxName)
|
||||||
clamp_max = get_cached_string(token_fmt( "MaxName", (StrC)field.MaxName, "Get<MaxName>()"));
|
clamp_max = cache_str(token_fmt( "MaxName", field.MaxName, "Get<MaxName>()"));
|
||||||
else
|
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(
|
pre_attribute_clamps.append( code_fmt(
|
||||||
"field", (StrC)field.Name,
|
"field", field.Name,
|
||||||
"clamp_min", (StrC)clamp_min,
|
"clamp_min", clamp_min,
|
||||||
"clamp_max", (StrC)clamp_max,
|
"clamp_max", clamp_max,
|
||||||
stringize(
|
stringize(
|
||||||
if (Attribute == Get<field>Attribute())
|
if (Attribute == Get<field>Attribute())
|
||||||
{
|
{
|
||||||
@ -312,9 +312,9 @@ void gen_UGasaAttributeSet()
|
|||||||
)));
|
)));
|
||||||
|
|
||||||
post_attribute_clamps.append( code_fmt(
|
post_attribute_clamps.append( code_fmt(
|
||||||
"field", (StrC)field.Name,
|
"field", field.Name,
|
||||||
"clamp_min", (StrC)clamp_min,
|
"clamp_min", clamp_min,
|
||||||
"clamp_max", (StrC)clamp_max,
|
"clamp_max", clamp_max,
|
||||||
stringize(
|
stringize(
|
||||||
if ( Data.EvaluatedData.Attribute == Get<field>Attribute() )
|
if ( Data.EvaluatedData.Attribute == Get<field>Attribute() )
|
||||||
{
|
{
|
||||||
@ -328,7 +328,7 @@ void gen_UGasaAttributeSet()
|
|||||||
post_attribute_clamps.append(fmt_newline);
|
post_attribute_clamps.append(fmt_newline);
|
||||||
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)
|
void UGasaAttributeSet::PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue)
|
||||||
{
|
{
|
||||||
Super::PreAttributeChange(Attribute, 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)
|
void UGasaAttributeSet::PostGameplayEffectExecute(FGameplayEffectModCallbackData const& Data)
|
||||||
{
|
{
|
||||||
Super::PostGameplayEffectExecute(Data);
|
Super::PostGameplayEffectExecute(Data);
|
||||||
@ -356,17 +356,17 @@ void gen_UGasaAttributeSet()
|
|||||||
|
|
||||||
CodeFn GetLifetimeOfReplicatedProps;
|
CodeFn GetLifetimeOfReplicatedProps;
|
||||||
{
|
{
|
||||||
CodeBody field_lifetimes = def_body( CodeT::Function_Body);
|
CodeBody field_lifetimes = def_body( CT_Function_Body);
|
||||||
field_lifetimes.append(fmt_newline);
|
field_lifetimes.append(fmt_newline);
|
||||||
field_lifetimes.append(fmt_newline);
|
field_lifetimes.append(fmt_newline);
|
||||||
for (GAS_AttributeEntry field : all_attribute_fields)
|
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>);
|
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
|
void UGasaAttributeSet::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
|
||||||
{
|
{
|
||||||
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||||
@ -387,7 +387,7 @@ void def_attribute_properties( CodeBody body, Array<GAS_AttributeEntry> properti
|
|||||||
{
|
{
|
||||||
for ( GAS_AttributeEntry property : properties )
|
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")
|
UPROPERTY(ReplicatedUsing=Client_OnRep_<property>, EditAnywhere, BlueprintReadWrite, Category="Attributes")
|
||||||
FGameplayAttributeData <property>;
|
FGameplayAttributeData <property>;
|
||||||
));
|
));
|
||||||
@ -404,18 +404,18 @@ void def_attribute_field_on_reps( CodeBody body, Array<GAS_AttributeEntry> prope
|
|||||||
body.append(fmt_newline);
|
body.append(fmt_newline);
|
||||||
body.append( umeta_UFUNCTION );
|
body.append( umeta_UFUNCTION );
|
||||||
body.append(fmt_newline);
|
body.append(fmt_newline);
|
||||||
body.append( code_fmt( "property", (StrC)property.Name, stringize(
|
body.append( code_fmt( "property", property.Name, stringize(
|
||||||
void Client_OnRep_<property>(FGameplayAttributeData& Prev<property>);
|
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 )
|
for ( GAS_AttributeEntry property : properties )
|
||||||
{
|
{
|
||||||
CodeFn generated_get_attribute = parse_function(
|
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(
|
stringize(
|
||||||
static FGameplayAttribute Get<property>Attribute()
|
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 )
|
for ( GAS_AttributeEntry property : properties )
|
||||||
{
|
{
|
||||||
body.append( code_fmt( "property", (StrC)property.Name,
|
body.append( code_fmt( "property", property.Name,
|
||||||
stringize(
|
stringize(
|
||||||
FORCEINLINE float Get<property>() const
|
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 )
|
for ( GAS_AttributeEntry property : properties )
|
||||||
{
|
{
|
||||||
body.append( code_fmt( "property", (StrC)property.Name,
|
body.append( code_fmt( "property", property.Name,
|
||||||
stringize(
|
stringize(
|
||||||
FORCEINLINE void Set<property>(float NewVal);
|
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")));
|
body.append(def_pragma( txt("region Attribute Setters")));
|
||||||
for ( GAS_AttributeEntry property : properties )
|
for ( GAS_AttributeEntry property : properties )
|
||||||
{
|
{
|
||||||
CodeFn generated_get_attribute = parse_function(
|
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(
|
stringize(
|
||||||
FORCEINLINE void <class_name>::Set<property>(float NewVal)
|
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 )
|
for ( GAS_AttributeEntry property : properties )
|
||||||
{
|
{
|
||||||
body.append( code_fmt( "property", (StrC)property.Name,
|
body.append( code_fmt( "property", property.Name,
|
||||||
stringize(
|
stringize(
|
||||||
FORCEINLINE void Init<property>(float NewVal)
|
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(fmt_newline);
|
||||||
body.append(def_pragma( txt("region Rep Notifies")));
|
body.append(def_pragma( txt("region Rep Notifies")));
|
||||||
for ( GAS_AttributeEntry property : properties )
|
for ( GAS_AttributeEntry property : properties )
|
||||||
{
|
{
|
||||||
CodeFn field_impl = parse_function( token_fmt(
|
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(
|
stringize(
|
||||||
void <class_name>::Client_OnRep_<property>(FGameplayAttributeData& Prev<property>)
|
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
|
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(
|
Code rep_notify = code_fmt(
|
||||||
"class_name", class_name
|
"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"
|
"C:/projects/Unreal/Surgo/UE/Engine/Source/Runtime/UMG/Public/Components/ProgressBar.h"
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
content = file_read_contents( GlobalAllocator, true, path_UProgressBar );
|
content = file_read_contents( ctx.Allocator_Temp, true, path_UProgressBar );
|
||||||
CodeBody parsed_uprogressbar = parse_global_body( StrC { content.size, (char const*)content.data });
|
CodeBody parsed_uprogressbar = parse_global_body( Str { (char const*)content.data, content.size });
|
||||||
|
|
||||||
log_fmt("\n\n");
|
log_fmt("\n\n");
|
||||||
for ( Code gcode : parsed_uprogressbar )
|
for ( Code gcode : parsed_uprogressbar )
|
||||||
{
|
{
|
||||||
if ( gcode->Type == CodeT::Class )
|
if ( gcode->Type == CT_Class )
|
||||||
{
|
{
|
||||||
log_fmt("Class %S - Definitions:\n", gcode->Name);
|
log_fmt("Class %S - Definitions:\n", gcode->Name);
|
||||||
|
|
||||||
if (gcode->Body->Type != CodeT::Class_Body)
|
if (gcode->Body->Type != CT_Class_Body)
|
||||||
continue;
|
continue;
|
||||||
for ( Code class_code : gcode->Body->cast<CodeBody>() )
|
for ( Code class_code : cast(CodeBody, gcode->Body) )
|
||||||
{
|
{
|
||||||
switch ( class_code->Type )
|
switch ( class_code->Type )
|
||||||
{
|
{
|
||||||
case CodeT::Variable:
|
case CT_Variable:
|
||||||
case CodeT::Function:
|
case CT_Function:
|
||||||
case CodeT::Function_Fwd:
|
case CT_Function_Fwd:
|
||||||
if ( class_code->Name )
|
if ( class_code->Name )
|
||||||
{
|
{
|
||||||
log_fmt("%s\n", 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)"
|
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Runtime\CoreUObject\Public\UObject\Object.h)"
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
content = file_read_contents( GlobalAllocator, true, path_UObject );
|
content = file_read_contents( ctx.Allocator_Temp, true, path_UObject );
|
||||||
CodeBody parsed_uobject = parse_global_body( StrC { content.size, (char const*)content.data });
|
CodeBody parsed_uobject = parse_global_body( Str { (char const*)content.data, content.size });
|
||||||
|
|
||||||
log_fmt("\n\n");
|
log_fmt("\n\n");
|
||||||
for ( Code gcode : parsed_uobject )
|
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("Class %S - Definitions:\n", gcode->Name);
|
||||||
// log_fmt("%s\n", gcode->to_string() );
|
// log_fmt("%s\n", gcode->to_string() );
|
||||||
|
|
||||||
if (gcode->Body->Type != CodeT::Class_Body)
|
if (gcode->Body->Type != CT_Class_Body)
|
||||||
continue;
|
continue;
|
||||||
for ( Code class_code : gcode->Body->cast<CodeBody>() )
|
for ( Code class_code : cast(CodeBody, gcode->Body) )
|
||||||
{
|
{
|
||||||
switch ( class_code->Type )
|
switch ( class_code->Type )
|
||||||
{
|
{
|
||||||
case CodeT::Constructor:
|
case CT_Constructor:
|
||||||
case CodeT::Constructor_Fwd:
|
case CT_Constructor_Fwd:
|
||||||
case CodeT::Variable:
|
case CT_Variable:
|
||||||
case CodeT::Function:
|
case CT_Function:
|
||||||
case CodeT::Function_Fwd:
|
case CT_Function_Fwd:
|
||||||
if ( class_code->Name )
|
if ( class_code->Name )
|
||||||
{
|
{
|
||||||
log_fmt("%s\n", 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)"
|
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Runtime\Engine\Classes\GameFramework\Actor.h)"
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
content = file_read_contents( GlobalAllocator, true, path_AActor );
|
content = file_read_contents( ctx.Allocator_Temp, true, path_AActor );
|
||||||
CodeBody parsed_aactor = parse_global_body( StrC { content.size, (char const*)content.data });
|
CodeBody parsed_aactor = parse_global_body( Str { (char const*)content.data, content.size });
|
||||||
|
|
||||||
log_fmt("\n\n");
|
log_fmt("\n\n");
|
||||||
for ( Code gcode : parsed_aactor )
|
for ( Code gcode : parsed_aactor )
|
||||||
{
|
{
|
||||||
if ( gcode->Type == CodeT::Class )
|
if ( gcode->Type == CT_Class )
|
||||||
{
|
{
|
||||||
log_fmt("Class %S - Definitions:\n", gcode->Name);
|
log_fmt("Class %S - Definitions:\n", gcode->Name);
|
||||||
|
|
||||||
if (gcode->Body->Type != CodeT::Class_Body)
|
if (gcode->Body->Type != CT_Class_Body)
|
||||||
continue;
|
continue;
|
||||||
for ( Code class_code : gcode->Body->cast<CodeBody>() )
|
for ( Code class_code : cast(CodeBody, gcode->Body) )
|
||||||
{
|
{
|
||||||
switch ( class_code->Type )
|
switch ( class_code->Type )
|
||||||
{
|
{
|
||||||
// case CodeT::Variable:
|
// case CodeT::Variable:
|
||||||
case CodeT::Function:
|
case CT_Function:
|
||||||
case CodeT::Function_Fwd:
|
case CT_Function_Fwd:
|
||||||
if ( class_code->Name )
|
if ( class_code->Name )
|
||||||
{
|
{
|
||||||
log_fmt("%s\n", 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)"
|
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Runtime\Engine\Classes\Components\ActorComponent.h)"
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
content = file_read_contents( GlobalAllocator, true, path_ActorComponent );
|
content = file_read_contents( ctx.Allocator_Temp, true, path_ActorComponent );
|
||||||
CodeBody parsed_actor_component = parse_global_body( StrC { content.size, (char const*)content.data });
|
CodeBody parsed_actor_component = parse_global_body( Str { (char const*)content.data, content.size });
|
||||||
|
|
||||||
for ( Code gcode : parsed_actor_component )
|
for ( Code gcode : parsed_actor_component )
|
||||||
{
|
{
|
||||||
if ( gcode->Type == CodeT::Class )
|
if ( gcode->Type == CT_Class )
|
||||||
{
|
{
|
||||||
log_fmt("\n\n");
|
log_fmt("\n\n");
|
||||||
log_fmt("Class %S - Definitions:\n", gcode->Name);
|
log_fmt("Class %S - Definitions:\n", gcode->Name);
|
||||||
|
|
||||||
if (gcode->Body->Type != CodeT::Class_Body)
|
if (gcode->Body->Type != CT_Class_Body)
|
||||||
continue;
|
continue;
|
||||||
for ( Code class_code : gcode->Body->cast<CodeBody>() )
|
for ( Code class_code : cast(CodeBody, gcode->Body) )
|
||||||
{
|
{
|
||||||
switch ( class_code->Type )
|
switch ( class_code->Type )
|
||||||
{
|
{
|
||||||
case CodeT::Variable:
|
case CT_Variable:
|
||||||
case CodeT::Function:
|
case CT_Function:
|
||||||
case CodeT::Function_Fwd:
|
case CT_Function_Fwd:
|
||||||
if ( class_code->Name )
|
if ( class_code->Name )
|
||||||
{
|
{
|
||||||
log_fmt("%s\n", 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)"
|
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Runtime\Engine\Classes\Components\SceneComponent.h)"
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
content = file_read_contents( GlobalAllocator, true, path_SceneComponent );
|
content = file_read_contents( ctx.Allocator_Temp, true, path_SceneComponent );
|
||||||
CodeBody parsed_scene_component = parse_global_body( StrC { content.size, (char const*)content.data });
|
CodeBody parsed_scene_component = parse_global_body( Str { (char const*)content.data, content.size });
|
||||||
|
|
||||||
for ( Code gcode : parsed_scene_component )
|
for ( Code gcode : parsed_scene_component )
|
||||||
{
|
{
|
||||||
if ( gcode->Type == CodeT::Class )
|
if ( gcode->Type == CT_Class )
|
||||||
{
|
{
|
||||||
log_fmt("\n\n");
|
log_fmt("\n\n");
|
||||||
log_fmt("Class %S - Definitions:\n", gcode->Name);
|
log_fmt("Class %S - Definitions:\n", gcode->Name);
|
||||||
|
|
||||||
if (gcode->Body->Type != CodeT::Class_Body)
|
if (gcode->Body->Type != CT_Class_Body)
|
||||||
continue;
|
continue;
|
||||||
for ( Code class_code : gcode->Body->cast<CodeBody>() )
|
for ( Code class_code : cast(CodeBody, gcode->Body) )
|
||||||
{
|
{
|
||||||
switch ( class_code->Type )
|
switch ( class_code->Type )
|
||||||
{
|
{
|
||||||
case CodeT::Variable:
|
case CT_Variable:
|
||||||
case CodeT::Function:
|
case CT_Function:
|
||||||
case CodeT::Function_Fwd:
|
case CT_Function_Fwd:
|
||||||
if ( class_code->Name )
|
if ( class_code->Name )
|
||||||
{
|
{
|
||||||
log_fmt("%s\n", 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)"
|
R"(C:\projects\Unreal\Surgo\UE\Engine\Plugins\Runtime\GameplayAbilities\Source\GameplayAbilities\Public\AttributeSet.h)"
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
content = file_read_contents( GlobalAllocator, true, path_AttributeSet );
|
content = file_read_contents( ctx.Allocator_Temp, true, path_AttributeSet );
|
||||||
CodeBody parsed_attribute_set = parse_global_body( StrC { content.size, (char const*)content.data });
|
CodeBody parsed_attribute_set = parse_global_body( Str { (char const*)content.data, content.size });
|
||||||
|
|
||||||
for ( Code gcode : parsed_attribute_set )
|
for ( Code gcode : parsed_attribute_set )
|
||||||
{
|
{
|
||||||
if ( gcode->Type == CodeT::Class )
|
if ( gcode->Type == CT_Class )
|
||||||
{
|
{
|
||||||
log_fmt("\n\n");
|
log_fmt("\n\n");
|
||||||
log_fmt("Class %S - Definitions:\n", gcode->Name);
|
log_fmt("Class %S - Definitions:\n", gcode->Name);
|
||||||
|
|
||||||
if (gcode->Body->Type != CodeT::Class_Body)
|
if (gcode->Body->Type != CT_Class_Body)
|
||||||
continue;
|
continue;
|
||||||
for ( Code class_code : gcode->Body->cast<CodeBody>() )
|
for ( Code class_code : cast(CodeBody, gcode->Body) )
|
||||||
{
|
{
|
||||||
switch ( class_code->Type )
|
switch ( class_code->Type )
|
||||||
{
|
{
|
||||||
case CodeT::Variable:
|
case CT_Variable:
|
||||||
case CodeT::Function:
|
case CT_Function:
|
||||||
case CodeT::Function_Fwd:
|
case CT_Function_Fwd:
|
||||||
if ( class_code->Name )
|
if ( class_code->Name )
|
||||||
{
|
{
|
||||||
log_fmt("%s\n", class_code->Name );
|
log_fmt("%s\n", class_code->Name );
|
||||||
|
@ -1,90 +1,93 @@
|
|||||||
// This file was generated automatially by gencpp's unreal.cpp (See: https://github.com/Ed94/gencpp)
|
// This file was generated automatially by gencpp's unreal.cpp (See: https://github.com/Ed94/gencpp)
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic push
|
# pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wunused-const-variable"
|
# pragma clang diagnostic ignored "-Wunused-const-variable"
|
||||||
#pragma clang diagnostic ignored "-Wunused-but-set-variable"
|
# pragma clang diagnostic ignored "-Wunused-but-set-variable"
|
||||||
#pragma clang diagnostic ignored "-Wswitch"
|
# pragma clang diagnostic ignored "-Wswitch"
|
||||||
#pragma clang diagnostic ignored "-Wunused-variable"
|
# pragma clang diagnostic ignored "-Wunused-variable"
|
||||||
#pragma clang diagnostic ignored "-Wunknown-pragmas"
|
# pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||||
#pragma clang diagnostic ignored "-Wvarargs"
|
# pragma clang diagnostic ignored "-Wvarargs"
|
||||||
#pragma clang diagnostic ignored "-Wunused-function"
|
# 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
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#pragma GCC diagnostic push
|
# pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
# pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
||||||
#pragma GCC diagnostic ignored "-Wcomment"
|
# pragma GCC diagnostic ignored "-Wcomment"
|
||||||
#pragma GCC diagnostic ignored "-Wswitch"
|
# pragma GCC diagnostic ignored "-Wswitch"
|
||||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
# pragma GCC diagnostic ignored "-Wunused-variable"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "gen.builder.hpp"
|
#include "gen.builder.hpp"
|
||||||
|
|
||||||
GEN_NS_BEGIN
|
GEN_NS_BEGIN
|
||||||
|
|
||||||
Builder Builder::open( char const* path )
|
#pragma region Builder
|
||||||
|
|
||||||
|
Builder builder_open( char const* path )
|
||||||
{
|
{
|
||||||
Builder result;
|
Builder result;
|
||||||
|
|
||||||
FileError error = file_open_mode( &result.File, EFileMode_WRITE, path );
|
FileError error = file_open_mode( & result.File, EFileMode_WRITE, path );
|
||||||
if ( error != EFileError_NONE )
|
if ( error != EFileError_NONE )
|
||||||
{
|
{
|
||||||
log_failure( "gen::File::open - Could not open file: %s", path );
|
log_failure( "gen::File::open - Could not open file: %s", path);
|
||||||
return result;
|
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 );
|
// log_fmt("$Builder - Opened file: %s\n", result.File.filename );
|
||||||
return result;
|
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();
|
StrBuilder str = code_to_strbuilder(code);
|
||||||
// const sw len = str.length();
|
// const ssize len = str.length();
|
||||||
// log_fmt( "%s - print: %.*s\n", File.filename, len > 80 ? 80 : len, str.Data );
|
// 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 };
|
char buf[ GEN_PRINTF_MAXLEN ] = { 0 };
|
||||||
|
|
||||||
va_list va;
|
res = c_str_fmt_va( buf, count_of( buf ) - 1, fmt, va ) - 1;
|
||||||
va_start( va, fmt );
|
|
||||||
res = str_fmt_va( buf, count_of( buf ) - 1, fmt, va ) - 1;
|
|
||||||
va_end( va );
|
|
||||||
|
|
||||||
// log_fmt( "$%s - print_fmt: %.*s\n", File.filename, res > 80 ? 80 : res, buf );
|
strbuilder_append_c_str_len( (StrBuilder*) & (builder->Buffer), (char const*)buf, res);
|
||||||
Buffer.append( 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 )
|
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 );
|
log_fmt( "Generated: %s\n", builder->File.filename );
|
||||||
file_close( &File );
|
file_close( & builder->File );
|
||||||
Buffer.free();
|
strbuilder_free(& builder->Buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma endregion Builder
|
||||||
|
|
||||||
GEN_NS_END
|
GEN_NS_END
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic pop
|
# pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#pragma GCC diagnostic pop
|
# pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,22 +1,25 @@
|
|||||||
// This file was generated automatially by gencpp's unreal.cpp (See: https://github.com/Ed94/gencpp)
|
// This file was generated automatially by gencpp's unreal.cpp (See: https://github.com/Ed94/gencpp)
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic push
|
# pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wunused-const-variable"
|
# pragma clang diagnostic ignored "-Wunused-const-variable"
|
||||||
#pragma clang diagnostic ignored "-Wunused-but-set-variable"
|
# pragma clang diagnostic ignored "-Wunused-but-set-variable"
|
||||||
#pragma clang diagnostic ignored "-Wswitch"
|
# pragma clang diagnostic ignored "-Wswitch"
|
||||||
#pragma clang diagnostic ignored "-Wunused-variable"
|
# pragma clang diagnostic ignored "-Wunused-variable"
|
||||||
#pragma clang diagnostic ignored "-Wunknown-pragmas"
|
# pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||||
#pragma clang diagnostic ignored "-Wvarargs"
|
# pragma clang diagnostic ignored "-Wvarargs"
|
||||||
#pragma clang diagnostic ignored "-Wunused-function"
|
# 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
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#pragma GCC diagnostic push
|
# pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
# pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
||||||
#pragma GCC diagnostic ignored "-Wcomment"
|
# pragma GCC diagnostic ignored "-Wcomment"
|
||||||
#pragma GCC diagnostic ignored "-Wswitch"
|
# pragma GCC diagnostic ignored "-Wswitch"
|
||||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
# pragma GCC diagnostic ignored "-Wunused-variable"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -25,27 +28,65 @@
|
|||||||
|
|
||||||
GEN_NS_BEGIN
|
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
|
struct Builder
|
||||||
{
|
{
|
||||||
FileInfo File;
|
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 );
|
FORCEINLINE void print( Code code ) { return builder_print(this, code); }
|
||||||
void print_fmt( char const* fmt, ... );
|
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
|
GEN_NS_END
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic pop
|
# pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#pragma GCC diagnostic pop
|
# pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
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
@ -1,22 +1,25 @@
|
|||||||
// This file was generated automatially by gencpp's unreal.cpp (See: https://github.com/Ed94/gencpp)
|
// This file was generated automatially by gencpp's unreal.cpp (See: https://github.com/Ed94/gencpp)
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic push
|
# pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wunused-const-variable"
|
# pragma clang diagnostic ignored "-Wunused-const-variable"
|
||||||
#pragma clang diagnostic ignored "-Wunused-but-set-variable"
|
# pragma clang diagnostic ignored "-Wunused-but-set-variable"
|
||||||
#pragma clang diagnostic ignored "-Wswitch"
|
# pragma clang diagnostic ignored "-Wswitch"
|
||||||
#pragma clang diagnostic ignored "-Wunused-variable"
|
# pragma clang diagnostic ignored "-Wunused-variable"
|
||||||
#pragma clang diagnostic ignored "-Wunknown-pragmas"
|
# pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||||
#pragma clang diagnostic ignored "-Wvarargs"
|
# pragma clang diagnostic ignored "-Wvarargs"
|
||||||
#pragma clang diagnostic ignored "-Wunused-function"
|
# 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
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#pragma GCC diagnostic push
|
# pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
# pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
||||||
#pragma GCC diagnostic ignored "-Wcomment"
|
# pragma GCC diagnostic ignored "-Wcomment"
|
||||||
#pragma GCC diagnostic ignored "-Wswitch"
|
# pragma GCC diagnostic ignored "-Wswitch"
|
||||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
# pragma GCC diagnostic ignored "-Wunused-variable"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "gen.scanner.hpp"
|
#include "gen.scanner.hpp"
|
||||||
@ -28,7 +31,7 @@ GEN_NS_BEGIN
|
|||||||
#define _adt_fprintf( s_, fmt_, ... ) \
|
#define _adt_fprintf( s_, fmt_, ... ) \
|
||||||
do \
|
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; \
|
return EADT_ERROR_OUT_OF_MEMORY; \
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
|
|
||||||
@ -44,7 +47,7 @@ u8 adt_make_branch( ADT_Node* node, AllocatorInfo backing, char const* name, b32
|
|||||||
node->type = type;
|
node->type = type;
|
||||||
node->name = name;
|
node->name = name;
|
||||||
node->parent = parent;
|
node->parent = parent;
|
||||||
node->nodes = Array<ADT_Node>::init( backing );
|
node->nodes = array_init(ADT_Node, backing );
|
||||||
|
|
||||||
if ( ! node->nodes )
|
if ( ! node->nodes )
|
||||||
return EADT_ERROR_OUT_OF_MEMORY;
|
return EADT_ERROR_OUT_OF_MEMORY;
|
||||||
@ -57,12 +60,12 @@ u8 adt_destroy_branch( ADT_Node* node )
|
|||||||
GEN_ASSERT_NOT_NULL( node );
|
GEN_ASSERT_NOT_NULL( node );
|
||||||
if ( ( node->type == EADT_TYPE_OBJECT || node->type == EADT_TYPE_ARRAY ) && node->nodes )
|
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 );
|
adt_destroy_branch( node->nodes + i );
|
||||||
}
|
}
|
||||||
|
|
||||||
node->nodes.free();
|
array_free(node->nodes);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -87,9 +90,9 @@ ADT_Node* adt_find( ADT_Node* node, char const* name, b32 deep_search )
|
|||||||
return NULL;
|
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 );
|
return ( node->nodes + i );
|
||||||
}
|
}
|
||||||
@ -97,7 +100,7 @@ ADT_Node* adt_find( ADT_Node* node, char const* name, b32 deep_search )
|
|||||||
|
|
||||||
if ( 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 );
|
ADT_Node* res = adt_find( node->nodes + i, name, deep_search );
|
||||||
|
|
||||||
@ -115,35 +118,35 @@ internal ADT_Node* _adt_get_value( ADT_Node* node, char const* value )
|
|||||||
{
|
{
|
||||||
case EADT_TYPE_MULTISTRING :
|
case EADT_TYPE_MULTISTRING :
|
||||||
case EADT_TYPE_STRING :
|
case EADT_TYPE_STRING :
|
||||||
{
|
|
||||||
if ( node->string && ! str_compare( node->string, value ) )
|
|
||||||
{
|
{
|
||||||
return node;
|
if ( node->string && ! c_str_compare( node->string, value ) )
|
||||||
|
{
|
||||||
|
return node;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
case EADT_TYPE_INTEGER :
|
case EADT_TYPE_INTEGER :
|
||||||
case EADT_TYPE_REAL :
|
case EADT_TYPE_REAL :
|
||||||
{
|
|
||||||
char back[4096] = { 0 };
|
|
||||||
FileInfo tmp;
|
|
||||||
|
|
||||||
/* allocate a file descriptor for a memory-mapped number to string conversion, input source buffer is not cloned, however. */
|
|
||||||
file_stream_open( &tmp, heap(), (u8*)back, size_of( back ), EFileStream_WRITABLE );
|
|
||||||
adt_print_number( &tmp, node );
|
|
||||||
|
|
||||||
sw fsize = 0;
|
|
||||||
u8* buf = file_stream_buf( &tmp, &fsize );
|
|
||||||
|
|
||||||
if ( ! str_compare( (char const*)buf, value ) )
|
|
||||||
{
|
{
|
||||||
file_close( &tmp );
|
char back[ 4096 ] = { 0 };
|
||||||
return node;
|
FileInfo tmp;
|
||||||
}
|
|
||||||
|
|
||||||
file_close( &tmp );
|
/* allocate a file descriptor for a memory-mapped number to string conversion, input source buffer is not cloned, however. */
|
||||||
}
|
file_stream_open( &tmp, heap(), ( u8* )back, size_of( back ), EFileStream_WRITABLE );
|
||||||
break;
|
adt_print_number( &tmp, node );
|
||||||
|
|
||||||
|
ssize fsize = 0;
|
||||||
|
u8* buf = file_stream_buf( &tmp, &fsize );
|
||||||
|
|
||||||
|
if ( ! c_str_compare( ( char const* )buf, value ) )
|
||||||
|
{
|
||||||
|
file_close( &tmp );
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
file_close( &tmp );
|
||||||
|
}
|
||||||
|
break;
|
||||||
default :
|
default :
|
||||||
break; /* node doesn't support value based lookup */
|
break; /* node doesn't support value based lookup */
|
||||||
}
|
}
|
||||||
@ -153,11 +156,11 @@ 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 )
|
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];
|
ADT_Node* child = &node->nodes[ i ];
|
||||||
if ( _adt_get_value( child, value ) )
|
if ( _adt_get_value( child, value ) )
|
||||||
{
|
{
|
||||||
return node; /* this object does contain a field of a specified value! */
|
return node; /* this object does contain a field of a specified value! */
|
||||||
@ -188,22 +191,22 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined EADT_URI_DEBUG || 0
|
#if defined EADT_URI_DEBUG || 0
|
||||||
str_fmt_out( "uri: %s\n", uri );
|
c_str_fmt_out( "uri: %s\n", uri );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char * p = (char*)uri, *b = p, *e = p;
|
char * p = ( char* )uri, *b = p, *e = p;
|
||||||
ADT_Node* found_node = NULL;
|
ADT_Node* found_node = NULL;
|
||||||
|
|
||||||
b = p;
|
b = p;
|
||||||
p = e = (char*)str_skip( p, '/' );
|
p = e = ( char* )c_str_skip( p, '/' );
|
||||||
char* buf = str_fmt_buf( "%.*s", (int)( e - b ), b );
|
char* buf = c_str_fmt_buf( "%.*s", ( int )( e - b ), b );
|
||||||
|
|
||||||
/* handle field value lookup */
|
/* handle field value lookup */
|
||||||
if ( *b == '[' )
|
if ( *b == '[' )
|
||||||
{
|
{
|
||||||
char *l_p = buf + 1, *l_b = l_p, *l_e = l_p, *l_b2 = l_p, *l_e2 = l_p;
|
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_e = ( char* )c_str_skip( l_p, '=' );
|
||||||
l_e2 = (char*)str_skip( l_p, ']' );
|
l_e2 = ( char* )c_str_skip( l_p, ']' );
|
||||||
|
|
||||||
if ( ( ! *l_e && node->type != EADT_TYPE_ARRAY ) || ! *l_e2 )
|
if ( ( ! *l_e && node->type != EADT_TYPE_ARRAY ) || ! *l_e2 )
|
||||||
{
|
{
|
||||||
@ -228,9 +231,9 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri )
|
|||||||
/* run a value comparison against any child that is an object node */
|
/* run a value comparison against any child that is an object node */
|
||||||
else if ( node->type == EADT_TYPE_ARRAY )
|
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];
|
ADT_Node* child = &node->nodes[ i ];
|
||||||
if ( child->type != EADT_TYPE_OBJECT )
|
if ( child->type != EADT_TYPE_OBJECT )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@ -246,9 +249,9 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri )
|
|||||||
/* [value] */
|
/* [value] */
|
||||||
else
|
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];
|
ADT_Node* child = &node->nodes[ i ];
|
||||||
if ( _adt_get_value( child, l_b2 ) )
|
if ( _adt_get_value( child, l_b2 ) )
|
||||||
{
|
{
|
||||||
found_node = child;
|
found_node = child;
|
||||||
@ -277,10 +280,10 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri )
|
|||||||
/* handle array index lookup */
|
/* handle array index lookup */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sw idx = (sw)str_to_i64( buf, NULL, 10 );
|
ssize idx = ( ssize )c_str_to_i64( buf, NULL, 10 );
|
||||||
if ( idx >= 0 && idx < scast( sw, node->nodes.num() ) )
|
if ( idx >= 0 && idx < scast(ssize, array_num(node->nodes)) )
|
||||||
{
|
{
|
||||||
found_node = &node->nodes[idx];
|
found_node = &node->nodes[ idx ];
|
||||||
|
|
||||||
/* go deeper if uri continues */
|
/* go deeper if uri continues */
|
||||||
if ( *e )
|
if ( *e )
|
||||||
@ -293,7 +296,7 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri )
|
|||||||
return found_node;
|
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 ) )
|
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 )
|
if ( ! parent->nodes )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if ( index < 0 || index > scast( sw, parent->nodes.num() ) )
|
if ( index < 0 || index > scast(ssize, array_num(parent->nodes)) )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ADT_Node o = { 0 };
|
ADT_Node o = { 0 };
|
||||||
o.parent = parent;
|
o.parent = parent;
|
||||||
if ( ! parent->nodes.append_at( o, index ) )
|
if ( ! array_append_at( parent->nodes, o, index ) )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return parent->nodes + index;
|
ADT_Node* node = & parent->nodes[index];
|
||||||
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
ADT_Node* adt_alloc( ADT_Node* parent )
|
ADT_Node* adt_alloc( ADT_Node* parent )
|
||||||
@ -324,7 +328,7 @@ ADT_Node* adt_alloc( ADT_Node* parent )
|
|||||||
if ( ! parent->nodes )
|
if ( ! parent->nodes )
|
||||||
return NULL;
|
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 )
|
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;
|
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( node );
|
||||||
GEN_ASSERT_NOT_NULL( new_parent );
|
GEN_ASSERT_NOT_NULL( new_parent );
|
||||||
@ -378,22 +382,22 @@ ADT_Node* adt_move_node( ADT_Node* node, ADT_Node* new_parent )
|
|||||||
GEN_ASSERT_NOT_NULL( node );
|
GEN_ASSERT_NOT_NULL( node );
|
||||||
GEN_ASSERT_NOT_NULL( new_parent );
|
GEN_ASSERT_NOT_NULL( new_parent );
|
||||||
GEN_ASSERT( new_parent->type == EADT_TYPE_ARRAY || new_parent->type == EADT_TYPE_OBJECT );
|
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 )
|
void adt_swap_nodes( ADT_Node* node, ADT_Node* other_node )
|
||||||
{
|
{
|
||||||
GEN_ASSERT_NOT_NULL( node );
|
GEN_ASSERT_NOT_NULL( node );
|
||||||
GEN_ASSERT_NOT_NULL( other_node );
|
GEN_ASSERT_NOT_NULL( other_node );
|
||||||
ADT_Node* parent = node->parent;
|
ADT_Node* parent = node->parent;
|
||||||
ADT_Node* other_parent = other_node->parent;
|
ADT_Node* other_parent = other_node->parent;
|
||||||
sw index = ( pointer_diff( parent->nodes, node ) / size_of( ADT_Node ) );
|
ssize index = ( pointer_diff( parent->nodes, node ) / size_of( ADT_Node ) );
|
||||||
sw index2 = ( pointer_diff( other_parent->nodes, other_node ) / size_of( ADT_Node ) );
|
ssize index2 = ( pointer_diff( other_parent->nodes, other_node ) / size_of( ADT_Node ) );
|
||||||
ADT_Node temp = parent->nodes[index];
|
ADT_Node temp = parent->nodes[ index ];
|
||||||
temp.parent = other_parent;
|
temp.parent = other_parent;
|
||||||
other_parent->nodes[index2].parent = parent;
|
other_parent->nodes[ index2 ].parent = parent;
|
||||||
parent->nodes[index] = other_parent->nodes[index2];
|
parent->nodes[ index ] = other_parent->nodes[ index2 ];
|
||||||
other_parent->nodes[index2] = temp;
|
other_parent->nodes[ index2 ] = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void adt_remove_node( ADT_Node* node )
|
void adt_remove_node( ADT_Node* node )
|
||||||
@ -401,8 +405,8 @@ void adt_remove_node( ADT_Node* node )
|
|||||||
GEN_ASSERT_NOT_NULL( node );
|
GEN_ASSERT_NOT_NULL( node );
|
||||||
GEN_ASSERT_NOT_NULL( node->parent );
|
GEN_ASSERT_NOT_NULL( node->parent );
|
||||||
ADT_Node* parent = node->parent;
|
ADT_Node* parent = node->parent;
|
||||||
sw index = ( pointer_diff( parent->nodes, node ) / size_of( ADT_Node ) );
|
ssize index = ( pointer_diff( parent->nodes, node ) / size_of( ADT_Node ) );
|
||||||
parent->nodes.remove_at( index );
|
array_remove_at( parent->nodes, index );
|
||||||
}
|
}
|
||||||
|
|
||||||
ADT_Node* adt_append_obj( ADT_Node* parent, char const* name )
|
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 );
|
ADT_Node* o = adt_alloc( parent );
|
||||||
if ( ! o )
|
if ( ! o )
|
||||||
return NULL;
|
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 );
|
adt_remove_node( o );
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -423,7 +427,9 @@ ADT_Node* adt_append_arr( ADT_Node* parent, char const* name )
|
|||||||
ADT_Node* o = adt_alloc( parent );
|
ADT_Node* o = adt_alloc( parent );
|
||||||
if ( ! o )
|
if ( ! o )
|
||||||
return NULL;
|
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 );
|
adt_remove_node( o );
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -468,7 +474,7 @@ char* adt_parse_number_strict( ADT_Node* node, char* base_str )
|
|||||||
while ( *e )
|
while ( *e )
|
||||||
++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;
|
++p;
|
||||||
}
|
}
|
||||||
@ -487,48 +493,48 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
|
|||||||
GEN_ASSERT_NOT_NULL( base_str );
|
GEN_ASSERT_NOT_NULL( base_str );
|
||||||
char *p = base_str, *e = p;
|
char *p = base_str, *e = p;
|
||||||
|
|
||||||
s32 base = 0;
|
s32 base = 0;
|
||||||
s32 base2 = 0;
|
s32 base2 = 0;
|
||||||
u8 base2_offset = 0;
|
u8 base2_offset = 0;
|
||||||
s8 exp = 0, orig_exp = 0;
|
s8 exp = 0, orig_exp = 0;
|
||||||
u8 neg_zero = 0;
|
u8 neg_zero = 0;
|
||||||
u8 lead_digit = 0;
|
u8 lead_digit = 0;
|
||||||
ADT_Type node_type = EADT_TYPE_UNINITIALISED;
|
ADT_Type node_type = EADT_TYPE_UNINITIALISED;
|
||||||
u8 node_props = 0;
|
u8 node_props = 0;
|
||||||
|
|
||||||
/* skip false positives and special cases */
|
/* 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;
|
return ++base_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
node_type = EADT_TYPE_INTEGER;
|
node_type = EADT_TYPE_INTEGER;
|
||||||
neg_zero = false;
|
neg_zero = false;
|
||||||
|
|
||||||
sw ib = 0;
|
ssize ib = 0;
|
||||||
char buf[48] = { 0 };
|
char buf[ 48 ] = { 0 };
|
||||||
|
|
||||||
if ( *e == '+' )
|
if ( *e == '+' )
|
||||||
++e;
|
++e;
|
||||||
else if ( *e == '-' )
|
else if ( *e == '-' )
|
||||||
{
|
{
|
||||||
buf[ib++] = *e++;
|
buf[ ib++ ] = *e++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( *e == '.' )
|
if ( *e == '.' )
|
||||||
{
|
{
|
||||||
node_type = EADT_TYPE_REAL;
|
node_type = EADT_TYPE_REAL;
|
||||||
node_props = EADT_PROPS_IS_PARSED_REAL;
|
node_props = EADT_PROPS_IS_PARSED_REAL;
|
||||||
lead_digit = false;
|
lead_digit = false;
|
||||||
buf[ib++] = '0';
|
buf[ ib++ ] = '0';
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
buf[ib++] = *e;
|
buf[ ib++ ] = *e;
|
||||||
} while ( char_is_digit( *++e ) );
|
} while ( char_is_digit( *++e ) );
|
||||||
}
|
}
|
||||||
else
|
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;
|
node_props = EADT_PROPS_IS_HEX;
|
||||||
}
|
}
|
||||||
@ -541,7 +547,7 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
|
|||||||
|
|
||||||
while ( char_is_hex_digit( *e ) || char_to_lower( *e ) == 'x' )
|
while ( char_is_hex_digit( *e ) || char_to_lower( *e ) == 'x' )
|
||||||
{
|
{
|
||||||
buf[ib++] = *e++;
|
buf[ ib++ ] = *e++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( *e == '.' )
|
if ( *e == '.' )
|
||||||
@ -552,13 +558,13 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
buf[ib++] = *e;
|
buf[ ib++ ] = *e;
|
||||||
++step;
|
++step;
|
||||||
} while ( char_is_digit( *++e ) );
|
} while ( char_is_digit( *++e ) );
|
||||||
|
|
||||||
if ( step < 2 )
|
if ( step < 2 )
|
||||||
{
|
{
|
||||||
buf[ib++] = '0';
|
buf[ ib++ ] = '0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -569,11 +575,11 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
|
|||||||
return ++base_str;
|
return ++base_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
f32 eb = 10;
|
f32 eb = 10;
|
||||||
char expbuf[6] = { 0 };
|
char expbuf[ 6 ] = { 0 };
|
||||||
sw expi = 0;
|
ssize expi = 0;
|
||||||
|
|
||||||
if ( *e && ! ! str_find( "eE", *e ) )
|
if ( *e && ! ! char_first_occurence( "eE", *e ) )
|
||||||
{
|
{
|
||||||
++e;
|
++e;
|
||||||
if ( *e == '+' || *e == '-' || char_is_digit( *e ) )
|
if ( *e == '+' || *e == '-' || char_is_digit( *e ) )
|
||||||
@ -588,43 +594,43 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
|
|||||||
}
|
}
|
||||||
while ( char_is_digit( *e ) )
|
while ( char_is_digit( *e ) )
|
||||||
{
|
{
|
||||||
expbuf[expi++] = *e++;
|
expbuf[ expi++ ] = *e++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 )
|
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
|
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
||||||
/* special case: negative zero */
|
/* special case: negative zero */
|
||||||
if ( node->integer == 0 && buf[0] == '-' )
|
if ( node->integer == 0 && buf[ 0 ] == '-' )
|
||||||
{
|
{
|
||||||
neg_zero = true;
|
neg_zero = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
while ( orig_exp-- > 0 )
|
while ( orig_exp-- > 0 )
|
||||||
{
|
{
|
||||||
node->integer *= (s64)eb;
|
node->integer *= ( s64 )eb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
node->real = str_to_f64( buf, 0 );
|
node->real = c_str_to_f64( buf, 0 );
|
||||||
|
|
||||||
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
||||||
char *q = buf, *base_string = q, *base_string2 = q;
|
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_string = '\0';
|
||||||
base_string2 = base_string + 1;
|
base_string2 = base_string + 1;
|
||||||
char* base_string_off = base_string2;
|
char* base_strbuilder_off = base_string2;
|
||||||
while ( *base_string_off++ == '0' )
|
while ( *base_strbuilder_off++ == '0' )
|
||||||
base2_offset++;
|
base2_offset++;
|
||||||
|
|
||||||
base = (s32)str_to_i64( q, 0, 0 );
|
base = ( s32 )c_str_to_i64( q, 0, 0 );
|
||||||
base2 = (s32)str_to_i64( base_string2, 0, 0 );
|
base2 = ( s32 )c_str_to_i64( base_string2, 0, 0 );
|
||||||
if ( exp )
|
if ( exp )
|
||||||
{
|
{
|
||||||
exp = exp * ( ! ( eb == 10.0f ) ? -1 : 1 );
|
exp = exp * ( ! ( eb == 10.0f ) ? -1 : 1 );
|
||||||
@ -632,7 +638,7 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* special case: negative zero */
|
/* special case: negative zero */
|
||||||
if ( base == 0 && buf[0] == '-' )
|
if ( base == 0 && buf[ 0 ] == '-' )
|
||||||
{
|
{
|
||||||
neg_zero = true;
|
neg_zero = true;
|
||||||
}
|
}
|
||||||
@ -683,67 +689,67 @@ ADT_Error adt_print_number( FileInfo* file, ADT_Node* node )
|
|||||||
switch ( node->type )
|
switch ( node->type )
|
||||||
{
|
{
|
||||||
case EADT_TYPE_INTEGER :
|
case EADT_TYPE_INTEGER :
|
||||||
{
|
|
||||||
if ( node->props == EADT_PROPS_IS_HEX )
|
|
||||||
{
|
{
|
||||||
_adt_fprintf( file, "0x%llx", (long long)node->integer );
|
if ( node->props == EADT_PROPS_IS_HEX )
|
||||||
|
{
|
||||||
|
_adt_fprintf( file, "0x%llx", ( long long )node->integer );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_adt_fprintf( file, "%lld", ( long long )node->integer );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
break;
|
||||||
{
|
|
||||||
_adt_fprintf( file, "%lld", (long long)node->integer );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EADT_TYPE_REAL :
|
case EADT_TYPE_REAL :
|
||||||
{
|
|
||||||
if ( node->props == EADT_PROPS_NAN )
|
|
||||||
{
|
{
|
||||||
_adt_fprintf( file, "NaN" );
|
if ( node->props == EADT_PROPS_NAN )
|
||||||
}
|
{
|
||||||
else if ( node->props == EADT_PROPS_NAN_NEG )
|
_adt_fprintf( file, "NaN" );
|
||||||
{
|
}
|
||||||
_adt_fprintf( file, "-NaN" );
|
else if ( node->props == EADT_PROPS_NAN_NEG )
|
||||||
}
|
{
|
||||||
else if ( node->props == EADT_PROPS_INFINITY )
|
_adt_fprintf( file, "-NaN" );
|
||||||
{
|
}
|
||||||
_adt_fprintf( file, "Infinity" );
|
else if ( node->props == EADT_PROPS_INFINITY )
|
||||||
}
|
{
|
||||||
else if ( node->props == EADT_PROPS_INFINITY_NEG )
|
_adt_fprintf( file, "Infinity" );
|
||||||
{
|
}
|
||||||
_adt_fprintf( file, "-Infinity" );
|
else if ( node->props == EADT_PROPS_INFINITY_NEG )
|
||||||
}
|
{
|
||||||
else if ( node->props == EADT_PROPS_TRUE )
|
_adt_fprintf( file, "-Infinity" );
|
||||||
{
|
}
|
||||||
_adt_fprintf( file, "true" );
|
else if ( node->props == EADT_PROPS_TRUE )
|
||||||
}
|
{
|
||||||
else if ( node->props == EADT_PROPS_FALSE )
|
_adt_fprintf( file, "true" );
|
||||||
{
|
}
|
||||||
_adt_fprintf( file, "false" );
|
else if ( node->props == EADT_PROPS_FALSE )
|
||||||
}
|
{
|
||||||
else if ( node->props == EADT_PROPS_NULL )
|
_adt_fprintf( file, "false" );
|
||||||
{
|
}
|
||||||
_adt_fprintf( file, "null" );
|
else if ( node->props == EADT_PROPS_NULL )
|
||||||
|
{
|
||||||
|
_adt_fprintf( file, "null" );
|
||||||
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
||||||
}
|
}
|
||||||
else if ( node->props == EADT_PROPS_IS_EXP )
|
else if ( node->props == EADT_PROPS_IS_EXP )
|
||||||
{
|
{
|
||||||
_adt_fprintf( file, "%lld.%0*d%llde%lld", (long long)node->base, node->base2_offset, 0, (long long)node->base2, (long long)node->exp );
|
_adt_fprintf( file, "%lld.%0*d%llde%lld", ( long long )node->base, node->base2_offset, 0, ( long long )node->base2, ( long long )node->exp );
|
||||||
}
|
}
|
||||||
else if ( node->props == EADT_PROPS_IS_PARSED_REAL )
|
else if ( node->props == EADT_PROPS_IS_PARSED_REAL )
|
||||||
{
|
{
|
||||||
if ( ! node->lead_digit )
|
if ( ! node->lead_digit )
|
||||||
_adt_fprintf( file, ".%0*d%lld", node->base2_offset, 0, (long long)node->base2 );
|
_adt_fprintf( file, ".%0*d%lld", node->base2_offset, 0, ( long long )node->base2 );
|
||||||
else
|
else
|
||||||
_adt_fprintf( file, "%lld.%0*d%lld", (long long int)node->base2_offset, 0, (int)node->base, (long long)node->base2 );
|
_adt_fprintf( file, "%lld.%0*d%lld", ( long long int )node->base2_offset, 0, ( int )node->base, ( long long )node->base2 );
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_adt_fprintf( file, "%f", node->real );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
break;
|
||||||
{
|
|
||||||
_adt_fprintf( file, "%f", node->real );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return EADT_ERROR_NONE;
|
return EADT_ERROR_NONE;
|
||||||
@ -767,9 +773,9 @@ ADT_Error adt_print_string( FileInfo* file, ADT_Node* node, char const* escaped_
|
|||||||
|
|
||||||
do
|
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 );
|
_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 );
|
_adt_fprintf( file, "%s%c", escape_symbol, *p );
|
||||||
p++;
|
p++;
|
||||||
@ -780,7 +786,7 @@ ADT_Error adt_print_string( FileInfo* file, ADT_Node* node, char const* escaped_
|
|||||||
return EADT_ERROR_NONE;
|
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 );
|
GEN_ASSERT( node );
|
||||||
|
|
||||||
@ -791,12 +797,12 @@ ADT_Error adt_str_to_number( ADT_Node* node )
|
|||||||
return EADT_ERROR_INVALID_TYPE;
|
return EADT_ERROR_INVALID_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
adt_parse_number( node, (char*)node->string );
|
adt_parse_number( node, ( char* )node->string );
|
||||||
|
|
||||||
return EADT_ERROR_NONE;
|
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 );
|
GEN_ASSERT( node );
|
||||||
|
|
||||||
@ -807,7 +813,7 @@ ADT_Error adt_str_to_number_strict( ADT_Node* node )
|
|||||||
return EADT_ERROR_INVALID_TYPE;
|
return EADT_ERROR_INVALID_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
adt_parse_number_strict( node, (char*)node->string );
|
adt_parse_number_strict( node, ( char* )node->string );
|
||||||
|
|
||||||
return EADT_ERROR_NONE;
|
return EADT_ERROR_NONE;
|
||||||
}
|
}
|
||||||
@ -819,9 +825,9 @@ ADT_Error adt_str_to_number_strict( ADT_Node* node )
|
|||||||
#pragma region CSV
|
#pragma region CSV
|
||||||
|
|
||||||
#ifdef GEN_CSV_DEBUG
|
#ifdef GEN_CSV_DEBUG
|
||||||
#define GEN_CSV_ASSERT( msg ) GEN_PANIC( msg )
|
# define GEN_CSV_ASSERT( msg ) GEN_PANIC( msg )
|
||||||
#else
|
#else
|
||||||
#define GEN_CSV_ASSERT( msg )
|
# define GEN_CSV_ASSERT( msg )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header, char delim )
|
u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header, char delim )
|
||||||
@ -837,13 +843,13 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
|||||||
char* beginChar;
|
char* beginChar;
|
||||||
char* endChar;
|
char* endChar;
|
||||||
|
|
||||||
sw columnIndex = 0;
|
ssize columnIndex = 0;
|
||||||
sw totalColumnIndex = 0;
|
ssize totalColumnIndex = 0;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
char delimiter = 0;
|
char delimiter = 0;
|
||||||
currentChar = zpl_cast( char* ) str_trim( currentChar, false );
|
currentChar = ccast( char*, c_str_trim( currentChar, false ));
|
||||||
|
|
||||||
if ( *currentChar == 0 )
|
if ( *currentChar == 0 )
|
||||||
break;
|
break;
|
||||||
@ -851,23 +857,23 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
|||||||
ADT_Node rowItem = { 0 };
|
ADT_Node rowItem = { 0 };
|
||||||
rowItem.type = EADT_TYPE_STRING;
|
rowItem.type = EADT_TYPE_STRING;
|
||||||
|
|
||||||
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
||||||
rowItem.name_style = EADT_NAME_STYLE_NO_QUOTES;
|
rowItem.name_style = EADT_NAME_STYLE_NO_QUOTES;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* handle string literals */
|
/* handle string literals */
|
||||||
if ( *currentChar == '"' )
|
if ( *currentChar == '"' )
|
||||||
{
|
{
|
||||||
currentChar += 1;
|
currentChar += 1;
|
||||||
beginChar = currentChar;
|
beginChar = currentChar;
|
||||||
endChar = currentChar;
|
endChar = currentChar;
|
||||||
rowItem.string = beginChar;
|
rowItem.string = beginChar;
|
||||||
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
||||||
rowItem.name_style = EADT_NAME_STYLE_DOUBLE_QUOTE;
|
rowItem.name_style = EADT_NAME_STYLE_DOUBLE_QUOTE;
|
||||||
#endif
|
#endif
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
endChar = zpl_cast( char* ) str_skip( endChar, '"' );
|
endChar = ccast( char*, c_str_skip( endChar, '"' ));
|
||||||
|
|
||||||
if ( *endChar && *( endChar + 1 ) == '"' )
|
if ( *endChar && *( endChar + 1 ) == '"' )
|
||||||
{
|
{
|
||||||
@ -875,7 +881,8 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
} while ( *endChar );
|
}
|
||||||
|
while ( *endChar );
|
||||||
|
|
||||||
if ( *endChar == 0 )
|
if ( *endChar == 0 )
|
||||||
{
|
{
|
||||||
@ -885,8 +892,8 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
|||||||
}
|
}
|
||||||
|
|
||||||
*endChar = 0;
|
*endChar = 0;
|
||||||
currentChar = zpl_cast( char* ) str_trim( endChar + 1, true );
|
currentChar = ccast( char*, c_str_trim( endChar + 1, true ));
|
||||||
delimiter = *currentChar;
|
delimiter = * currentChar;
|
||||||
|
|
||||||
/* unescape escaped quotes (so that unescaped text escapes :) */
|
/* unescape escaped quotes (so that unescaped text escapes :) */
|
||||||
{
|
{
|
||||||
@ -895,15 +902,16 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
|||||||
{
|
{
|
||||||
if ( *escapedChar == '"' && *( escapedChar + 1 ) == '"' )
|
if ( *escapedChar == '"' && *( escapedChar + 1 ) == '"' )
|
||||||
{
|
{
|
||||||
mem_move( escapedChar, escapedChar + 1, str_len( escapedChar ) );
|
mem_move( escapedChar, escapedChar + 1, c_str_len( escapedChar ) );
|
||||||
}
|
}
|
||||||
escapedChar++;
|
escapedChar++;
|
||||||
} while ( *escapedChar );
|
}
|
||||||
|
while ( *escapedChar );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( *currentChar == delim )
|
else if ( *currentChar == delim )
|
||||||
{
|
{
|
||||||
delimiter = *currentChar;
|
delimiter = * currentChar;
|
||||||
rowItem.string = "";
|
rowItem.string = "";
|
||||||
}
|
}
|
||||||
else if ( *currentChar )
|
else if ( *currentChar )
|
||||||
@ -916,19 +924,20 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
endChar++;
|
endChar++;
|
||||||
} while ( *endChar && *endChar != delim && *endChar != '\n' );
|
}
|
||||||
|
while ( * endChar && * endChar != delim && * endChar != '\n' );
|
||||||
|
|
||||||
if ( *endChar )
|
if ( * endChar )
|
||||||
{
|
{
|
||||||
currentChar = zpl_cast( char* ) str_trim( endChar, true );
|
currentChar = ccast( char*, c_str_trim( endChar, true ));
|
||||||
|
|
||||||
while ( char_is_space( *( endChar - 1 ) ) )
|
while ( char_is_space( *( endChar - 1 ) ) )
|
||||||
{
|
{
|
||||||
endChar--;
|
endChar--;
|
||||||
}
|
}
|
||||||
|
|
||||||
delimiter = *currentChar;
|
delimiter = * currentChar;
|
||||||
*endChar = 0;
|
* endChar = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -941,35 +950,35 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
|||||||
char* num_p = beginChar;
|
char* num_p = beginChar;
|
||||||
|
|
||||||
// We only consider hexadecimal values if they start with 0x
|
// 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
|
num_p += 2; // skip '0x' prefix
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if ( ! char_is_hex_digit( *num_p ) )
|
if (!char_is_hex_digit(*num_p))
|
||||||
{
|
{
|
||||||
skip_number = true;
|
skip_number = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while ( *num_p++ );
|
} while (*num_p++);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
skip_number = true;
|
skip_number = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! skip_number )
|
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 );
|
adt_append_arr( root, NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
root->nodes[columnIndex].nodes.append( rowItem );
|
array_append( root->nodes[ columnIndex ].nodes, rowItem );
|
||||||
|
|
||||||
if ( delimiter == delim )
|
if ( delimiter == delim )
|
||||||
{
|
{
|
||||||
@ -994,9 +1003,10 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
|||||||
if ( delimiter != 0 )
|
if ( delimiter != 0 )
|
||||||
currentChar++;
|
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." );
|
GEN_CSV_ASSERT( "unexpected end of input. stream is empty." );
|
||||||
error = ECSV_Error__UNEXPECTED_END_OF_INPUT;
|
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. */
|
/* consider first row as a header. */
|
||||||
if ( has_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* col = root->nodes + i;
|
||||||
CSV_Object* hdr = col->nodes;
|
CSV_Object* hdr = col->nodes;
|
||||||
col->name = hdr->string;
|
col->name = hdr->string;
|
||||||
col->nodes.remove_at( 0 );
|
array_remove_at(col->nodes, 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1028,36 +1038,36 @@ void _csv_write_record( FileInfo* file, CSV_Object* node )
|
|||||||
switch ( node->type )
|
switch ( node->type )
|
||||||
{
|
{
|
||||||
case EADT_TYPE_STRING :
|
case EADT_TYPE_STRING :
|
||||||
{
|
|
||||||
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
|
||||||
switch ( node->name_style )
|
|
||||||
{
|
{
|
||||||
case EADT_NAME_STYLE_DOUBLE_QUOTE :
|
|
||||||
{
|
|
||||||
str_fmt_file( file, "\"" );
|
|
||||||
adt_print_string( file, node, "\"", "\"" );
|
|
||||||
str_fmt_file( file, "\"" );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EADT_NAME_STYLE_NO_QUOTES :
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
str_fmt_file( file, "%s", node->string );
|
|
||||||
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
||||||
}
|
switch ( node->name_style )
|
||||||
break;
|
{
|
||||||
}
|
case EADT_NAME_STYLE_DOUBLE_QUOTE :
|
||||||
|
{
|
||||||
|
c_str_fmt_file( file, "\"" );
|
||||||
|
adt_print_string( file, node, "\"", "\"" );
|
||||||
|
c_str_fmt_file( file, "\"" );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EADT_NAME_STYLE_NO_QUOTES :
|
||||||
|
{
|
||||||
#endif
|
#endif
|
||||||
}
|
c_str_fmt_file( file, "%s", node->string );
|
||||||
break;
|
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case EADT_TYPE_REAL :
|
case EADT_TYPE_REAL :
|
||||||
case EADT_TYPE_INTEGER :
|
case EADT_TYPE_INTEGER :
|
||||||
{
|
{
|
||||||
adt_print_number( file, node );
|
adt_print_number( file, node );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1074,63 +1084,66 @@ void csv_write_delimiter( FileInfo* file, CSV_Object* obj, char delimiter )
|
|||||||
GEN_ASSERT_NOT_NULL( file );
|
GEN_ASSERT_NOT_NULL( file );
|
||||||
GEN_ASSERT_NOT_NULL( obj );
|
GEN_ASSERT_NOT_NULL( obj );
|
||||||
GEN_ASSERT( obj->nodes );
|
GEN_ASSERT( obj->nodes );
|
||||||
sw cols = obj->nodes.num();
|
ssize cols = array_num(obj->nodes);
|
||||||
if ( cols == 0 )
|
if ( cols == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sw rows = obj->nodes[0].nodes.num();
|
ssize rows = array_num(obj->nodes[ 0 ].nodes);
|
||||||
if ( rows == 0 )
|
if ( rows == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
b32 has_headers = obj->nodes[0].name != NULL;
|
b32 has_headers = obj->nodes[ 0 ].name != NULL;
|
||||||
|
|
||||||
if ( has_headers )
|
if ( has_headers )
|
||||||
{
|
{
|
||||||
for ( sw i = 0; i < cols; i++ )
|
for ( ssize i = 0; i < cols; i++ )
|
||||||
{
|
{
|
||||||
_csv_write_header( file, &obj->nodes[i] );
|
_csv_write_header( file, &obj->nodes[ i ] );
|
||||||
if ( i + 1 != cols )
|
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] );
|
_csv_write_record( file, &obj->nodes[ i ].nodes[ r ] );
|
||||||
if ( i + 1 != cols )
|
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;
|
FileInfo tmp;
|
||||||
file_stream_new( &tmp, a );
|
file_stream_new( &tmp, a );
|
||||||
csv_write_delimiter( &tmp, obj, delimiter );
|
csv_write_delimiter( &tmp, obj, delimiter );
|
||||||
sw fsize;
|
|
||||||
|
ssize fsize;
|
||||||
u8* buf = file_stream_buf( &tmp, &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 );
|
file_close( &tmp );
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef _adt_fprintf
|
||||||
|
|
||||||
#pragma endregion CSV
|
#pragma endregion CSV
|
||||||
|
|
||||||
GEN_NS_END
|
GEN_NS_END
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic pop
|
# pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#pragma GCC diagnostic pop
|
# pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
@ -3,22 +3,25 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic push
|
# pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wunused-const-variable"
|
# pragma clang diagnostic ignored "-Wunused-const-variable"
|
||||||
#pragma clang diagnostic ignored "-Wunused-but-set-variable"
|
# pragma clang diagnostic ignored "-Wunused-but-set-variable"
|
||||||
#pragma clang diagnostic ignored "-Wswitch"
|
# pragma clang diagnostic ignored "-Wswitch"
|
||||||
#pragma clang diagnostic ignored "-Wunused-variable"
|
# pragma clang diagnostic ignored "-Wunused-variable"
|
||||||
#pragma clang diagnostic ignored "-Wunknown-pragmas"
|
# pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||||
#pragma clang diagnostic ignored "-Wvarargs"
|
# pragma clang diagnostic ignored "-Wvarargs"
|
||||||
#pragma clang diagnostic ignored "-Wunused-function"
|
# 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
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#pragma GCC diagnostic push
|
# pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
# pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
||||||
#pragma GCC diagnostic ignored "-Wcomment"
|
# pragma GCC diagnostic ignored "-Wcomment"
|
||||||
#pragma GCC diagnostic ignored "-Wswitch"
|
# pragma GCC diagnostic ignored "-Wswitch"
|
||||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
# pragma GCC diagnostic ignored "-Wunused-variable"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "gen.hpp"
|
#include "gen.hpp"
|
||||||
@ -92,7 +95,7 @@ struct ADT_Node
|
|||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
ADT_Type type : 4;
|
ADT_Type type : 4;
|
||||||
u8 props : 4;
|
u8 props : 4;
|
||||||
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
||||||
u8 cfg_mode : 1;
|
u8 cfg_mode : 1;
|
||||||
u8 name_style : 2;
|
u8 name_style : 2;
|
||||||
@ -106,7 +109,7 @@ struct ADT_Node
|
|||||||
union
|
union
|
||||||
{
|
{
|
||||||
char const* string;
|
char const* string;
|
||||||
Array<ADT_Node> nodes; ///< zpl_array
|
Array(ADT_Node) nodes; ///< zpl_array
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
@ -130,283 +133,283 @@ struct ADT_Node
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* ADT NODE LIMITS
|
/* ADT NODE LIMITS
|
||||||
* delimiter and assignment segment width is limited to 128 whitespace symbols each.
|
* delimiter and assignment segment width is limited to 128 whitespace symbols each.
|
||||||
* real number limits decimal position to 128 places.
|
* real number limits decimal position to 128 places.
|
||||||
* real number exponent is limited to 64 digits.
|
* real number exponent is limited to 64 digits.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialise an ADT object or array
|
* @brief Initialise an ADT object or array
|
||||||
*
|
*
|
||||||
* @param node
|
* @param node
|
||||||
* @param backing Memory allocator used for descendants
|
* @param backing Memory allocator used for descendants
|
||||||
* @param name Node's name
|
* @param name Node's name
|
||||||
* @param is_array
|
* @param is_array
|
||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
u8 adt_make_branch( ADT_Node* node, AllocatorInfo backing, char const* name, b32 is_array );
|
u8 adt_make_branch( ADT_Node* node, AllocatorInfo backing, char const* name, b32 is_array );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destroy an ADT branch and its descendants
|
* @brief Destroy an ADT branch and its descendants
|
||||||
*
|
*
|
||||||
* @param node
|
* @param node
|
||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
u8 adt_destroy_branch( ADT_Node* node );
|
u8 adt_destroy_branch( ADT_Node* node );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialise an ADT leaf
|
* @brief Initialise an ADT leaf
|
||||||
*
|
*
|
||||||
* @param node
|
* @param node
|
||||||
* @param name Node's name
|
* @param name Node's name
|
||||||
* @param type Node's type (use zpl_adt_make_branch for container nodes)
|
* @param type Node's type (use zpl_adt_make_branch for container nodes)
|
||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
u8 adt_make_leaf( ADT_Node* node, char const* name, ADT_Type type );
|
u8 adt_make_leaf( ADT_Node* node, char const* name, ADT_Type type );
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Fetch a node using provided URI string.
|
* @brief Fetch a node using provided URI string.
|
||||||
*
|
*
|
||||||
* This method uses a basic syntax to fetch a node from the ADT. The following features are available
|
* This method uses a basic syntax to fetch a node from the ADT. The following features are available
|
||||||
* to retrieve the data:
|
* to retrieve the data:
|
||||||
*
|
*
|
||||||
* - "a/b/c" navigates through objects "a" and "b" to get to "c"
|
* - "a/b/c" navigates through objects "a" and "b" to get to "c"
|
||||||
* - "arr/[foo=123]/bar" iterates over "arr" to find any object with param "foo" that matches the value "123", then gets its field called "bar"
|
* - "arr/[foo=123]/bar" iterates over "arr" to find any object with param "foo" that matches the value "123", then gets its field called "bar"
|
||||||
* - "arr/3" retrieves the 4th element in "arr"
|
* - "arr/3" retrieves the 4th element in "arr"
|
||||||
* - "arr/[apple]" retrieves the first element of value "apple" in "arr"
|
* - "arr/[apple]" retrieves the first element of value "apple" in "arr"
|
||||||
*
|
*
|
||||||
* @param node ADT node
|
* @param node ADT node
|
||||||
* @param uri Locator string as described above
|
* @param uri Locator string as described above
|
||||||
* @return zpl_adt_node*
|
* @return zpl_adt_node*
|
||||||
*
|
*
|
||||||
* @see code/apps/examples/json_get.c
|
* @see code/apps/examples/json_get.c
|
||||||
*/
|
*/
|
||||||
ADT_Node* adt_query( ADT_Node* node, char const* uri );
|
ADT_Node* adt_query( ADT_Node* node, char const* uri );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Find a field node within an object by the given name.
|
* @brief Find a field node within an object by the given name.
|
||||||
*
|
*
|
||||||
* @param node
|
* @param node
|
||||||
* @param name
|
* @param name
|
||||||
* @param deep_search Perform search recursively
|
* @param deep_search Perform search recursively
|
||||||
* @return zpl_adt_node * node
|
* @return zpl_adt_node * node
|
||||||
*/
|
*/
|
||||||
ADT_Node* adt_find( ADT_Node* node, char const* name, b32 deep_search );
|
ADT_Node* adt_find( ADT_Node* node, char const* name, b32 deep_search );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Allocate an unitialised node within a container at a specified index.
|
* @brief Allocate an unitialised node within a container at a specified index.
|
||||||
*
|
*
|
||||||
* @param parent
|
* @param parent
|
||||||
* @param index
|
* @param index
|
||||||
* @return zpl_adt_node * node
|
* @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.
|
* @brief Allocate an unitialised node within a container.
|
||||||
*
|
*
|
||||||
* @param parent
|
* @param parent
|
||||||
* @return zpl_adt_node * node
|
* @return zpl_adt_node * node
|
||||||
*/
|
*/
|
||||||
ADT_Node* adt_alloc( ADT_Node* parent );
|
ADT_Node* adt_alloc( ADT_Node* parent );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Move an existing node to a new container at a specified index.
|
* @brief Move an existing node to a new container at a specified index.
|
||||||
*
|
*
|
||||||
* @param node
|
* @param node
|
||||||
* @param new_parent
|
* @param new_parent
|
||||||
* @param index
|
* @param index
|
||||||
* @return zpl_adt_node * node
|
* @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.
|
* @brief Move an existing node to a new container.
|
||||||
*
|
*
|
||||||
* @param node
|
* @param node
|
||||||
* @param new_parent
|
* @param new_parent
|
||||||
* @return zpl_adt_node * node
|
* @return zpl_adt_node * node
|
||||||
*/
|
*/
|
||||||
ADT_Node* adt_move_node( ADT_Node* node, ADT_Node* new_parent );
|
ADT_Node* adt_move_node( ADT_Node* node, ADT_Node* new_parent );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Swap two nodes.
|
* @brief Swap two nodes.
|
||||||
*
|
*
|
||||||
* @param node
|
* @param node
|
||||||
* @param other_node
|
* @param other_node
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void adt_swap_nodes( ADT_Node* node, ADT_Node* other_node );
|
void adt_swap_nodes( ADT_Node* node, ADT_Node* other_node );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Remove node from container.
|
* @brief Remove node from container.
|
||||||
*
|
*
|
||||||
* @param node
|
* @param node
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void adt_remove_node( ADT_Node* node );
|
void adt_remove_node( ADT_Node* node );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialise a node as an object
|
* @brief Initialise a node as an object
|
||||||
*
|
*
|
||||||
* @param obj
|
* @param obj
|
||||||
* @param name
|
* @param name
|
||||||
* @param backing
|
* @param backing
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
b8 adt_set_obj( ADT_Node* obj, char const* name, AllocatorInfo backing );
|
b8 adt_set_obj( ADT_Node* obj, char const* name, AllocatorInfo backing );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialise a node as an array
|
* @brief Initialise a node as an array
|
||||||
*
|
*
|
||||||
* @param obj
|
* @param obj
|
||||||
* @param name
|
* @param name
|
||||||
* @param backing
|
* @param backing
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
b8 adt_set_arr( ADT_Node* obj, char const* name, AllocatorInfo backing );
|
b8 adt_set_arr( ADT_Node* obj, char const* name, AllocatorInfo backing );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialise a node as a string
|
* @brief Initialise a node as a string
|
||||||
*
|
*
|
||||||
* @param obj
|
* @param obj
|
||||||
* @param name
|
* @param name
|
||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
b8 adt_set_str( ADT_Node* obj, char const* name, char const* value );
|
b8 adt_set_str( ADT_Node* obj, char const* name, char const* value );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialise a node as a float
|
* @brief Initialise a node as a float
|
||||||
*
|
*
|
||||||
* @param obj
|
* @param obj
|
||||||
* @param name
|
* @param name
|
||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
b8 adt_set_flt( ADT_Node* obj, char const* name, f64 value );
|
b8 adt_set_flt( ADT_Node* obj, char const* name, f64 value );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialise a node as a signed integer
|
* @brief Initialise a node as a signed integer
|
||||||
*
|
*
|
||||||
* @param obj
|
* @param obj
|
||||||
* @param name
|
* @param name
|
||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
b8 adt_set_int( ADT_Node* obj, char const* name, s64 value );
|
b8 adt_set_int( ADT_Node* obj, char const* name, s64 value );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Append a new node to a container as an object
|
* @brief Append a new node to a container as an object
|
||||||
*
|
*
|
||||||
* @param parent
|
* @param parent
|
||||||
* @param name
|
* @param name
|
||||||
* @return*
|
* @return*
|
||||||
*/
|
*/
|
||||||
ADT_Node* adt_append_obj( ADT_Node* parent, char const* name );
|
ADT_Node* adt_append_obj( ADT_Node* parent, char const* name );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Append a new node to a container as an array
|
* @brief Append a new node to a container as an array
|
||||||
*
|
*
|
||||||
* @param parent
|
* @param parent
|
||||||
* @param name
|
* @param name
|
||||||
* @return*
|
* @return*
|
||||||
*/
|
*/
|
||||||
ADT_Node* adt_append_arr( ADT_Node* parent, char const* name );
|
ADT_Node* adt_append_arr( ADT_Node* parent, char const* name );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Append a new node to a container as a string
|
* @brief Append a new node to a container as a string
|
||||||
*
|
*
|
||||||
* @param parent
|
* @param parent
|
||||||
* @param name
|
* @param name
|
||||||
* @param value
|
* @param value
|
||||||
* @return*
|
* @return*
|
||||||
*/
|
*/
|
||||||
ADT_Node* adt_append_str( ADT_Node* parent, char const* name, char const* value );
|
ADT_Node* adt_append_str( ADT_Node* parent, char const* name, char const* value );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Append a new node to a container as a float
|
* @brief Append a new node to a container as a float
|
||||||
*
|
*
|
||||||
* @param parent
|
* @param parent
|
||||||
* @param name
|
* @param name
|
||||||
* @param value
|
* @param value
|
||||||
* @return*
|
* @return*
|
||||||
*/
|
*/
|
||||||
ADT_Node* adt_append_flt( ADT_Node* parent, char const* name, f64 value );
|
ADT_Node* adt_append_flt( ADT_Node* parent, char const* name, f64 value );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Append a new node to a container as a signed integer
|
* @brief Append a new node to a container as a signed integer
|
||||||
*
|
*
|
||||||
* @param parent
|
* @param parent
|
||||||
* @param name
|
* @param name
|
||||||
* @param value
|
* @param value
|
||||||
* @return*
|
* @return*
|
||||||
*/
|
*/
|
||||||
ADT_Node* adt_append_int( ADT_Node* parent, char const* name, s64 value );
|
ADT_Node* adt_append_int( ADT_Node* parent, char const* name, s64 value );
|
||||||
|
|
||||||
/* parser helpers */
|
/* parser helpers */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Parses a text and stores the result into an unitialised node.
|
* @brief Parses a text and stores the result into an unitialised node.
|
||||||
*
|
*
|
||||||
* @param node
|
* @param node
|
||||||
* @param base
|
* @param base
|
||||||
* @return*
|
* @return*
|
||||||
*/
|
*/
|
||||||
char* adt_parse_number( ADT_Node* node, char* base );
|
char* adt_parse_number( ADT_Node* node, char* base );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Parses a text and stores the result into an unitialised node.
|
* @brief Parses a text and stores the result into an unitialised node.
|
||||||
* This function expects the entire input to be a number.
|
* This function expects the entire input to be a number.
|
||||||
*
|
*
|
||||||
* @param node
|
* @param node
|
||||||
* @param base
|
* @param base
|
||||||
* @return*
|
* @return*
|
||||||
*/
|
*/
|
||||||
char* adt_parse_number_strict( ADT_Node* node, char* base_str );
|
char* adt_parse_number_strict( ADT_Node* node, char* base_str );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Parses and converts an existing string node into a number.
|
* @brief Parses and converts an existing string node into a number.
|
||||||
*
|
*
|
||||||
* @param node
|
* @param node
|
||||||
* @return
|
* @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.
|
* @brief Parses and converts an existing string node into a number.
|
||||||
* This function expects the entire input to be a number.
|
* This function expects the entire input to be a number.
|
||||||
*
|
*
|
||||||
* @param node
|
* @param node
|
||||||
* @return
|
* @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.
|
* @brief Prints a number into a file stream.
|
||||||
*
|
*
|
||||||
* The provided file handle can also be a memory mapped stream.
|
* The provided file handle can also be a memory mapped stream.
|
||||||
*
|
*
|
||||||
* @see zpl_file_stream_new
|
* @see zpl_file_stream_new
|
||||||
* @param file
|
* @param file
|
||||||
* @param node
|
* @param node
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ADT_Error adt_print_number( FileInfo* file, ADT_Node* node );
|
ADT_Error adt_print_number( FileInfo* file, ADT_Node* node );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prints a string into a file stream.
|
* @brief Prints a string into a file stream.
|
||||||
*
|
*
|
||||||
* The provided file handle can also be a memory mapped stream.
|
* The provided file handle can also be a memory mapped stream.
|
||||||
*
|
*
|
||||||
* @see zpl_file_stream_new
|
* @see zpl_file_stream_new
|
||||||
* @param file
|
* @param file
|
||||||
* @param node
|
* @param node
|
||||||
* @param escaped_chars
|
* @param escaped_chars
|
||||||
* @param escape_symbol
|
* @param escape_symbol
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ADT_Error adt_print_string( FileInfo* file, ADT_Node* node, char const* escaped_chars, char const* escape_symbol );
|
ADT_Error adt_print_string( FileInfo* file, ADT_Node* node, char const* escaped_chars, char const* escape_symbol );
|
||||||
|
|
||||||
#pragma endregion ADT
|
#pragma endregion ADT
|
||||||
@ -423,198 +426,73 @@ enum CSV_Error : u32
|
|||||||
|
|
||||||
typedef ADT_Node CSV_Object;
|
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 );
|
u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header, char delim );
|
||||||
void csv_free( CSV_Object* obj );
|
void csv_free( CSV_Object* obj );
|
||||||
|
|
||||||
GEN_DEF_INLINE void csv_write( FileInfo* file, CSV_Object* obj );
|
void csv_write( FileInfo* file, CSV_Object* obj );
|
||||||
GEN_DEF_INLINE String csv_write_string( AllocatorInfo a, CSV_Object* obj );
|
StrBuilder csv_write_string( AllocatorInfo a, CSV_Object* obj );
|
||||||
void csv_write_delimiter( FileInfo* file, CSV_Object* obj, char delim );
|
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 */
|
/* 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, ',' );
|
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, ',' );
|
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 endregion CSV
|
||||||
|
|
||||||
|
#pragma region Scanner
|
||||||
|
|
||||||
// This is a simple file reader that reads the entire file into memory.
|
// This is a simple file reader that reads the entire file into memory.
|
||||||
// It has an extra option to skip the first few lines for undesired includes.
|
// 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.
|
// 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 )
|
Code scan_file( char const* path );
|
||||||
{
|
|
||||||
FileInfo file;
|
|
||||||
|
|
||||||
FileError error = file_open_mode( &file, EFileMode_READ, path );
|
CodeBody parse_file( const char* path );
|
||||||
if ( error != EFileError_NONE )
|
|
||||||
{
|
|
||||||
GEN_FATAL( "scan_file: Could not open: %s", path );
|
|
||||||
}
|
|
||||||
|
|
||||||
sw fsize = file_size( &file );
|
// The follow is basic support for light csv parsing (use it as an example)
|
||||||
if ( fsize <= 0 )
|
// Make something robust if its more serious.
|
||||||
{
|
|
||||||
GEN_FATAL( "scan_file: %s is empty", path );
|
|
||||||
}
|
|
||||||
|
|
||||||
String str = String::make_reserve( GlobalAllocator, fsize );
|
typedef struct CSV_Column CSV_Column;
|
||||||
file_read( &file, str, fsize );
|
struct CSV_Column {
|
||||||
str.get_header().Length = fsize;
|
CSV_Object ADT;
|
||||||
|
Array(ADT_Node) Content;
|
||||||
// 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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Parser
|
typedef struct CSV_Columns2 CSV_Columns2;
|
||||||
{
|
struct CSV_Columns2 {
|
||||||
struct ParseFailure
|
CSV_Object ADT;
|
||||||
{
|
Array(ADT_Node) Col_1;
|
||||||
String Reason;
|
Array(ADT_Node) Col_2;
|
||||||
Code Node;
|
};
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
CodeFile scan_file( char const* path )
|
CSV_Column parse_csv_one_column(AllocatorInfo allocator, char const* path);
|
||||||
{
|
CSV_Columns2 parse_csv_two_columns(AllocatorInfo allocator, char const* path);
|
||||||
using namespace Parser;
|
|
||||||
|
|
||||||
CodeFile
|
#pragma endregion Scanner
|
||||||
result = {};
|
|
||||||
result.FilePath = String::make( GlobalAllocator, path );
|
|
||||||
|
|
||||||
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
|
GEN_NS_END
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic pop
|
# pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#pragma GCC diagnostic pop
|
# pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user