31. Aura HUD (plus other stuff)
- Enabled a few more plugins - Added clang formatting straight from the GasaGen cpp. - Setup auto-generation of the DevOptionsCache - Messed around with generating widgettree hiearchy from template widget
This commit is contained in:
		| @@ -5,109 +5,84 @@ | ||||
| #define GEN_IMPLEMENTATION | ||||
| #include "gen.cpp" | ||||
| #include "gen.builder.cpp" | ||||
| #include "gen.scanner.hpp" | ||||
| // #include "gen.scanner.hpp" | ||||
| using namespace gen; | ||||
|  | ||||
| #ifdef GEN_SYSTEM_WINDOWS | ||||
| 	#include <process.h> | ||||
| #endif | ||||
|  | ||||
| #include "GasaGenCommon.cpp" | ||||
| #include "GasaGen_ue_parse_testing.cpp" | ||||
| #include "GasaGen_UGasaAttributeSet.cpp" | ||||
| #include "GasaGen_ChangeBPActionMenu.cpp" | ||||
| #include "GasaGen_DevOptionsCache.cpp" | ||||
|  | ||||
| int gen_main() | ||||
| { | ||||
| 	gen::init(); | ||||
| 	log_fmt("Generating code for the Gasa module"); | ||||
| 	log_fmt("Generating code for the Gasa module\n"); | ||||
|  | ||||
| 	// Initialize Globals | ||||
| 	umeta_uclass         = code_str( UCLASS() ); | ||||
| 	umeta_generated_body = code_str( GENERATED_BODY() ); | ||||
| 	gasa_api             = code_str( GASA_API ); | ||||
| 	{ | ||||
| 		UHT_UCLASS         = code_str( UCLASS() ); | ||||
| 		UHT_UPROPERTY      = code_str( UPROPERTY() ); | ||||
| 		UHT_USTRUCT        = code_str( USTRUCT() ); | ||||
| 		UHT_GENERATED_BODY = code_str( GENERATED_BODY()\n ); | ||||
| 		UModule_GASA_API   = code_str( GASA_API ); | ||||
| 	} | ||||
|  | ||||
| 	StrC str_GENERATED_BODY                                        = txt("GENERATED_BODY("); | ||||
| 	StrC str_GENERATED_UCLASS_BODY                                 = txt("GENERATED_UCLASS_BODY("); | ||||
| 	StrC str_PROPERTY_BINDING_IMPLEMENTATION                       = txt("PROPERTY_BINDING_IMPLEMENTATION("); | ||||
| 	StrC str_UCLASS                                                = txt("UCLASS("); | ||||
| 	StrC str_UFUNCTION                                             = txt("UFUNCTION("); | ||||
| 	StrC str_UPROPERTY                                             = txt("UPROPERTY("); | ||||
| 	StrC str_DECLARE_LOG_CATEGORY_EXTERN                           = txt("DECLARE_LOG_CATEGORY_EXTERN("); | ||||
| 	StrC str_ENUM_CLASS_FLAGS                                      = txt("ENUM_CLASS_FLAGS("); | ||||
| 	StrC str_DECLARE_CLASS                                         = txt("DECLARE_CLASS("); | ||||
| 	StrC str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL    = txt("DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL("); | ||||
| 	StrC str_TEXT                                                  = txt("TEXT("); | ||||
| 	StrC str_DECLARE_MULTICAST_DELEGATE_OneParam                   = txt("DECLARE_MULTICAST_DELEGATE_OneParam("); | ||||
| 	StrC str_DECLARE_MULTICAST_DELEGATE_TwoParams                  = txt("DECLARE_MULTICAST_DELEGATE_TwoParams("); | ||||
| 	StrC str_DECLARE_MULTICAST_DELEGATE_ThreeParams                = txt("DECLARE_MULTICAST_DELEGATE_ThreeParams("); | ||||
| 	StrC str_DECLARE_DELEGATE_RetVal_OneParam                      = txt("DECLARE_DELEGATE_RetVal_OneParam("); | ||||
| 	StrC str_DECLARE_FUNCTION                                      = txt("DECLARE_FUNCTION("); | ||||
| 	StrC str_RESULT_DECL                                           = txt("RESULT_DECL"); | ||||
| 	StrC str_FORCEINLINE                                           = txt("FORCEINLINE"); | ||||
| 	StrC str_UENUM                                                 = txt("UENUM("); | ||||
| 	StrC str_UMETA                                                 = txt("UMETA("); | ||||
| 	StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams  = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams("); | ||||
| 	StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams("); | ||||
| 	StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams  = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams("); | ||||
| 	StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams  = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams("); | ||||
| 	StrC str_DECLARE_DELEGATE_SixParams                            = txt("DECLARE_DELEGATE_SixParams("); | ||||
| 	StrC str_DECLARE_EVENT_TwoParams                               = txt("DECLARE_EVENT_TwoParams("); | ||||
| 	StrC str_DECLARE_DELEGATE_RetVal_ThreeParams                   = txt("DECLARE_DELEGATE_RetVal_ThreeParams("); | ||||
| 	StrC str_PRAGMA_DISABLE_DEPRECATION_WARNINGS                   = txt("PRAGMA_DISABLE_DEPRECATION_WARNINGS"); | ||||
| 	StrC str_PRAGMA_ENABLE_DEPRECATION_WARNINGS                    = txt("PRAGMA_ENABLE_DEPRECATION_WARNINGS"); | ||||
| 	StrC str_DEFINE_ACTORDESC_TYPE                                 = txt("DEFINE_ACTORDESC_TYPE("); | ||||
| 	StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams   = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams("); | ||||
| 	StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam    = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam("); | ||||
| 	StrC str_UPARAM                                                = txt("UPARAM("); | ||||
| 	StrC str_FORCEINLINE_DEBUGGABLE                                = txt("FORCEINLINE_DEBUGGABLE"); | ||||
| 	StrC str_DECLARE_EVENT_ThreeParams                             = txt("DECLARE_EVENT_ThreeParams("); | ||||
| 	StrC str_USTRUCT                                               = txt("USTRUCT("); | ||||
| 	StrC str_GENERATED_USTRUCT_BODY                                = txt("GENERATED_USTRUCT_BODY("); | ||||
| 	StrC str_SLATE_BEGIN_ARGS = txt("SLATE_BEGIN_ARGS("); | ||||
| 	StrC str_SLATE_END_ARGS = txt("SLATE_END_ARGS("); | ||||
|  | ||||
| 	PreprocessorDefines.append( get_cached_string(str_GENERATED_BODY)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_GENERATED_UCLASS_BODY)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_PROPERTY_BINDING_IMPLEMENTATION)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_UCLASS)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_UFUNCTION)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_UPROPERTY)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_DECLARE_LOG_CATEGORY_EXTERN)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_ENUM_CLASS_FLAGS)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_DECLARE_CLASS)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_TEXT)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_OneParam)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_TwoParams)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_ThreeParams)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_RetVal_OneParam)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_DECLARE_FUNCTION)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_RESULT_DECL)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_FORCEINLINE)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_UENUM)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_UMETA)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_SixParams)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_DECLARE_EVENT_TwoParams)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_RetVal_ThreeParams)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_PRAGMA_DISABLE_DEPRECATION_WARNINGS)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_PRAGMA_ENABLE_DEPRECATION_WARNINGS)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_DEFINE_ACTORDESC_TYPE)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_UPARAM)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_FORCEINLINE_DEBUGGABLE)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_DECLARE_EVENT_ThreeParams)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_USTRUCT)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_GENERATED_USTRUCT_BODY)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_SLATE_BEGIN_ARGS)); | ||||
| 	PreprocessorDefines.append( get_cached_string(str_SLATE_END_ARGS)); | ||||
|  | ||||
| 	// ue_parse_testing(); | ||||
|  | ||||
| 	StrC str_gasa_api = txt("GASA_API"); | ||||
| 	// Populate Defines | ||||
| 	{ | ||||
| 		PreprocessorDefines.append( get_cached_string(str_DECLARE_CLASS)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_RetVal_OneParam)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_RetVal_ThreeParams)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_SixParams)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_DECLARE_EVENT_ThreeParams)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_DECLARE_EVENT_TwoParams)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_DECLARE_FUNCTION)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_DECLARE_LOG_CATEGORY_EXTERN)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_OneParam)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_ThreeParams)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_TwoParams)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_DEFINE_ACTORDESC_TYPE)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_ENUM_CLASS_FLAGS)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_FORCEINLINE_DEBUGGABLE)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_FORCEINLINE)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_GENERATED_BODY)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_GENERATED_UCLASS_BODY)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_GENERATED_USTRUCT_BODY)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_PRAGMA_DISABLE_DEPRECATION_WARNINGS)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_PRAGMA_ENABLE_DEPRECATION_WARNINGS)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_PROPERTY_BINDING_IMPLEMENTATION)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_RESULT_DECL)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_SLATE_BEGIN_ARGS)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_SLATE_END_ARGS)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_TEXT)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_UCLASS)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_UENUM)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_UFUNCTION)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_UMETA)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_UPARAM)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_UPROPERTY)); | ||||
| 		PreprocessorDefines.append( get_cached_string(str_USTRUCT)); | ||||
| 	} | ||||
|  | ||||
| 	gen_UGasaAttributeSet(); | ||||
| 	swap_SBlueprintActionMenu_Construct(); | ||||
| 	gen_FGasaDevOptionsCache(); | ||||
|  | ||||
| 	// One offs | ||||
| 	if (0) | ||||
| 	{ | ||||
| 		ue_parse_testing(); | ||||
| 		swap_SBlueprintActionMenu_Construct(); | ||||
| 	} | ||||
| 	return 0; | ||||
| } | ||||
|   | ||||
| @@ -1,13 +1,95 @@ | ||||
| #pragma once | ||||
| // Used in the GasaGen.cpp translation unit | ||||
| #if GASA_INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #include "gen.hpp" | ||||
| #include "GasaGenCommon.cpp" | ||||
| using namespace gen; | ||||
| #endif | ||||
|  | ||||
| // Program assumes its working directory is the project | ||||
| #define path_config                              "./Source/Config/" | ||||
| #define path_module_gasa                         "./Source/Gasa/" | ||||
| #define path_root                "" | ||||
| #define path_project             path_root        "Project/" | ||||
| #define path_source              path_project     "Source/" | ||||
| #define path_config              path_source      "Config/" | ||||
| #define path_module_gasa         path_source      "Gasa/" | ||||
| #define path_gasa_ability_system path_module_gasa "AbilitySystem/" | ||||
|  | ||||
| constexpr StrC str_DECLARE_CLASS                                         = txt("DECLARE_CLASS("); | ||||
| constexpr StrC str_DECLARE_DELEGATE_RetVal_OneParam                      = txt("DECLARE_DELEGATE_RetVal_OneParam("); | ||||
| constexpr StrC str_DECLARE_DELEGATE_RetVal_ThreeParams                   = txt("DECLARE_DELEGATE_RetVal_ThreeParams("); | ||||
| constexpr StrC str_DECLARE_DELEGATE_SixParams                            = txt("DECLARE_DELEGATE_SixParams("); | ||||
| constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams  = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams("); | ||||
| constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams  = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams("); | ||||
| constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams  = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams("); | ||||
| constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam    = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam("); | ||||
| constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams("); | ||||
| constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams   = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams("); | ||||
| constexpr StrC str_DECLARE_EVENT_ThreeParams                             = txt("DECLARE_EVENT_ThreeParams("); | ||||
| constexpr StrC str_DECLARE_EVENT_TwoParams                               = txt("DECLARE_EVENT_TwoParams("); | ||||
| constexpr StrC str_DECLARE_FUNCTION                                      = txt("DECLARE_FUNCTION("); | ||||
| constexpr StrC str_DECLARE_LOG_CATEGORY_EXTERN                           = txt("DECLARE_LOG_CATEGORY_EXTERN("); | ||||
| constexpr StrC str_DECLARE_MULTICAST_DELEGATE_OneParam                   = txt("DECLARE_MULTICAST_DELEGATE_OneParam("); | ||||
| constexpr StrC str_DECLARE_MULTICAST_DELEGATE_ThreeParams                = txt("DECLARE_MULTICAST_DELEGATE_ThreeParams("); | ||||
| constexpr StrC str_DECLARE_MULTICAST_DELEGATE_TwoParams                  = txt("DECLARE_MULTICAST_DELEGATE_TwoParams("); | ||||
| constexpr StrC str_DEFINE_ACTORDESC_TYPE                                 = txt("DEFINE_ACTORDESC_TYPE("); | ||||
| constexpr StrC str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL    = txt("DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL("); | ||||
| constexpr StrC str_ENUM_CLASS_FLAGS                                      = txt("ENUM_CLASS_FLAGS("); | ||||
| constexpr StrC str_FORCEINLINE                                           = txt("FORCEINLINE"); | ||||
| constexpr StrC str_FORCEINLINE_DEBUGGABLE                                = txt("FORCEINLINE_DEBUGGABLE"); | ||||
| constexpr StrC str_GENERATED_BODY                                        = txt("GENERATED_BODY("); | ||||
| constexpr StrC str_GENERATED_UCLASS_BODY                                 = txt("GENERATED_UCLASS_BODY("); | ||||
| constexpr StrC str_GENERATED_USTRUCT_BODY                                = txt("GENERATED_USTRUCT_BODY("); | ||||
| constexpr StrC str_PRAGMA_DISABLE_DEPRECATION_WARNINGS                   = txt("PRAGMA_DISABLE_DEPRECATION_WARNINGS"); | ||||
| constexpr StrC str_PRAGMA_ENABLE_DEPRECATION_WARNINGS                    = txt("PRAGMA_ENABLE_DEPRECATION_WARNINGS"); | ||||
| constexpr StrC str_PROPERTY_BINDING_IMPLEMENTATION                       = txt("PROPERTY_BINDING_IMPLEMENTATION("); | ||||
| constexpr StrC str_RESULT_DECL                                           = txt("RESULT_DECL"); | ||||
| constexpr StrC str_SLATE_BEGIN_ARGS                                      = txt("SLATE_BEGIN_ARGS("); | ||||
| constexpr StrC str_SLATE_END_ARGS                                        = txt("SLATE_END_ARGS("); | ||||
| constexpr StrC str_TEXT                                                  = txt("TEXT("); | ||||
| constexpr StrC str_UCLASS                                                = txt("UCLASS("); | ||||
| constexpr StrC str_UENUM                                                 = txt("UENUM("); | ||||
| constexpr StrC str_UFUNCTION                                             = txt("UFUNCTION("); | ||||
| constexpr StrC str_UMETA                                                 = txt("UMETA("); | ||||
| constexpr StrC str_UPARAM                                                = txt("UPARAM("); | ||||
| constexpr StrC str_UPROPERTY                                             = txt("UPROPERTY("); | ||||
| constexpr StrC str_USTRUCT                                               = txt("USTRUCT("); | ||||
|  | ||||
| constexpr StrC str_GASA_API = txt("GASA_API"); | ||||
|  | ||||
| #pragma region Globals | ||||
| // These Code objects are created before anything else after gencpp does its initializatioon | ||||
| global Code umeta_uclass; | ||||
| global Code umeta_generated_body; | ||||
| global Code gasa_api; | ||||
| global Code UHT_GENERATED_BODY; | ||||
| global Code UHT_UCLASS; | ||||
| global Code UHT_UPROPERTY; | ||||
| global Code UHT_USTRUCT; | ||||
| global Code UModule_GASA_API; | ||||
| #pragma endregion Globals | ||||
|  | ||||
| inline | ||||
| CodeBody parse_file( char const* path ) { | ||||
| 	FileContents content = file_read_contents( GlobalAllocator, true, path ); | ||||
| 	CodeBody     code    = parse_global_body( StrC { content.size, (char const*)content.data }); | ||||
| 	return code; | ||||
| } | ||||
|  | ||||
| inline | ||||
| void format_file( char const* path ) | ||||
| { | ||||
| 	// Need to execute clang format on the generated file to get it to match the original. | ||||
| 	#define clang_format      "clang-format " | ||||
| 	#define cf_format_inplace "-i " | ||||
| 	#define cf_style          "-style=file:" "./scripts/.clang-format " | ||||
| 	#define cf_verbose        "-verbose " | ||||
| 	String command = String::make( GlobalAllocator, clang_format ); | ||||
| 	command.append( cf_format_inplace ); | ||||
| 	command.append( cf_style ); | ||||
| 	command.append( cf_verbose ); | ||||
| 	command.append( path ); | ||||
| 		log_fmt("\tRunning clang-format on file:\n"); | ||||
| 		system( command ); | ||||
| 		log_fmt("\tclang-format finished reformatting.\n"); | ||||
| 	#undef cf_cmd | ||||
| 	#undef cf_format_inplace | ||||
| 	#undef cf_style | ||||
| 	#undef cf_verbse | ||||
| } | ||||
|   | ||||
| @@ -1,3 +1,12 @@ | ||||
| // Used in the GasaGen.cpp translation unit | ||||
| #if GASA_INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #define GEN_EXPOSE_BACKEND | ||||
| #include "gen.hpp" | ||||
| #include "gen.builder.hpp" | ||||
| #include "GasaGenCommon.cpp" | ||||
| #endif | ||||
|  | ||||
| constexpr StrC SBlueprintActionMenu_Construct_Replacement = txt(R"( | ||||
| void SBlueprintActionMenu::Construct( const FArguments& InArgs, TSharedPtr<FBlueprintEditor> InEditor ) | ||||
| { | ||||
| @@ -255,19 +264,22 @@ void swap_SBlueprintActionMenu_Construct() | ||||
| 			using namespace ECode; | ||||
| 			case Function: | ||||
| 				CodeFn function_def = code.cast<CodeFn>(); | ||||
| 				log_fmt("%S\n", function_def->Name); | ||||
|  | ||||
| 				if ( String::are_equal(function_def->Name, signature_to_change->Name) | ||||
| 				&&  function_def->Params.is_equal(signature_to_change->Params)) | ||||
| 				{ | ||||
| 					code = parse_function( SBlueprintActionMenu_Construct_Replacement ); | ||||
| 					log_fmt("Swapped: %S", function_def->Name); | ||||
| 				} | ||||
| 			break; | ||||
| 		} | ||||
| 		changed_SBlueprintActionMenu.append(code); | ||||
| 	} | ||||
| 	log_fmt("\n"); | ||||
|  | ||||
| 	Builder SBlueprintActionMenu_Changed = Builder::open(path_SBlueprintActionMenuCpp); | ||||
| 	SBlueprintActionMenu_Changed.print( def_comment(txt("This file was regenerated by GasaGen.cpp"))); | ||||
| 	SBlueprintActionMenu_Changed.print(changed_SBlueprintActionMenu); | ||||
| 	SBlueprintActionMenu_Changed.write(); | ||||
| } | ||||
| 	format_file(path_SBlueprintActionMenuCpp); | ||||
| } | ||||
|   | ||||
							
								
								
									
										135
									
								
								Project/Source/GasaGen/GasaGen_DevOptionsCache.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										135
									
								
								Project/Source/GasaGen/GasaGen_DevOptionsCache.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,135 @@ | ||||
| // Used in the GasaGen.cpp translation unit | ||||
| #if GASA_INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #define GEN_EXPOSE_BACKEND | ||||
| #include "gen.hpp" | ||||
| #include "gen.builder.hpp" | ||||
| #include "GasaGenCommon.cpp" | ||||
| using namespace gen; | ||||
| #endif | ||||
|  | ||||
| void gen_FGasaDevOptionsCache() | ||||
| { | ||||
| 	Array<CodeVar> GasaDevOptions_UPROPERTIES = Array<CodeVar>::init(GlobalAllocator); | ||||
| 	{ | ||||
| 		CodeBody  header_GasaDevOptions = parse_file( path_module_gasa "GasaDevOptions.h" ); | ||||
| 		CodeClass UGasaDevOptions = NoCode; | ||||
| 		for (Code entry : header_GasaDevOptions) | ||||
| 		{ | ||||
| 			if ( entry->Type == ECode::Class && entry->Name.starts_with( txt("UGasaDevOptions")) ) | ||||
| 			{ | ||||
| 				UGasaDevOptions = entry.cast<CodeClass>(); | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 		for (Code member = UGasaDevOptions->Body.begin(); member != UGasaDevOptions->Body.end(); ++ member) | ||||
| 		{ | ||||
| 			if ( member->Type == ECode::Untyped && member->Name.starts_with(str_UPROPERTY) ) | ||||
| 				++ member; | ||||
| 			if ( member->Type == ECode::Variable | ||||
| 			&& (	member->ValueType->Name.starts_with( txt("TSoftClassPtr")) | ||||
| 				||  member->ValueType->Name.starts_with( txt("TSoftObjectPtr")) ) | ||||
| 			) | ||||
| 				GasaDevOptions_UPROPERTIES.append(member.cast<CodeVar>()); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	CodeComment generation_notice = def_comment(txt("This was generated by GasaGen/GasaGen.cpp")); | ||||
|  | ||||
| 	Builder header = Builder::open( path_module_gasa "GasaDevOptionsCache.h" ); | ||||
| 	{ | ||||
| 		header.print( generation_notice ); | ||||
| 		header.print( pragma_once ); | ||||
| 		header.print( fmt_newline ); | ||||
| 		header.print( def_include(txt("GasaDevOptionsCache.generated.h"))); | ||||
| 		header.print( fmt_newline ); | ||||
|  | ||||
| 		header.print( UHT_USTRUCT ); | ||||
| 		CodeStruct FGasaDevOptionsCache; | ||||
| 		{ | ||||
| 			CodeBody body = def_body(ECode::Struct_Body); | ||||
| 			{ | ||||
| 				CodeType t_UClassPtr  = parse_type(code(UClass*)); | ||||
| 				CodeType t_UObjectPtr = parse_type(code(UObject*)); | ||||
|  | ||||
| 				body.append(UHT_GENERATED_BODY); | ||||
| 				body.append(fmt_newline); | ||||
| 				for (CodeVar var : GasaDevOptions_UPROPERTIES) | ||||
| 				{ | ||||
| 					if ( var->ValueType->Name.starts_with( txt("TSoftClassPtr") )) { | ||||
| 						body.append(UHT_UPROPERTY); | ||||
| 						body.append( def_variable(t_UClassPtr, var->Name)); | ||||
| 					} | ||||
| 					if ( var->ValueType->Name.starts_with( txt("TSoftObjectPtr") )) { | ||||
| 						body.append(UHT_UPROPERTY); | ||||
| 						body.append( def_variable(t_UObjectPtr, var->Name)); | ||||
| 					} | ||||
| 				} | ||||
| 				body.append(fmt_newline); | ||||
| 				body.append( parse_function(code( void CachedDevOptions(); ))); | ||||
| 			} | ||||
| 			FGasaDevOptionsCache = parse_struct( token_fmt( "body", (StrC)body.to_string(), stringize( | ||||
| 				struct GASA_API FGasaDevOptionsCache { | ||||
| 					<body> | ||||
| 				}; | ||||
| 			))); | ||||
| 		} | ||||
| 		header.print(FGasaDevOptionsCache); | ||||
| 		header.print( fmt_newline ); | ||||
| 		header.write(); | ||||
| 		format_file( path_module_gasa "GasaDevOptionsCache.h" ); | ||||
| 	} | ||||
|  | ||||
| 	Builder source = Builder::open( path_module_gasa "GasaDevOptionsCache.cpp" ); | ||||
| 	{ | ||||
| 		Array<CodeInclude> GasaDevOptions_Includes  = Array<CodeInclude>::init(GlobalAllocator); | ||||
| 		{ | ||||
| 			CodeBody source_GasaDevOptions = parse_file( path_module_gasa "GasaDevOptions.cpp"); | ||||
| 			for ( Code entry : source_GasaDevOptions ) | ||||
| 			{ | ||||
| 				if ( entry->Type == ECode::Preprocess_Include ) | ||||
| 					GasaDevOptions_Includes.append( entry.cast<CodeInclude>() ); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		source.print( generation_notice ); | ||||
| 		source.print( def_include(txt("GasaDevOptionsCache.h"))); | ||||
| 		source.print(fmt_newline); | ||||
| 		for ( CodeInclude include : GasaDevOptions_Includes ) { | ||||
| 			source.print( include ); | ||||
| 		} | ||||
| 		source.print( parse_using(code( using namespace Gasa; ))); | ||||
| 		source.print(fmt_newline); | ||||
|  | ||||
| 		CodeBody cached_property_assignments = def_body(ECode::Function_Body); | ||||
| 		{ | ||||
| 			cached_property_assignments.append(fmt_newline); | ||||
| 			cached_property_assignments.append(fmt_newline); | ||||
| 			for (CodeVar var : GasaDevOptions_UPROPERTIES) | ||||
| 			{ | ||||
| 				Code assignment = code_fmt( "property", (StrC)var->Name, stringize( | ||||
| 					<property> = DevOpts-> <property>.LoadSynchronous(); | ||||
| 				)); | ||||
| 				cached_property_assignments.append(assignment); | ||||
| 			} | ||||
| 			cached_property_assignments.append(fmt_newline); | ||||
| 			cached_property_assignments.append(fmt_newline); | ||||
| 		} | ||||
|  | ||||
| 		CodeFn CachedDevOptions = parse_function( token_fmt( | ||||
| 			"cached_property_assignments", (StrC)cached_property_assignments.to_string(), | ||||
| 		stringize( | ||||
| 			void FGasaDevOptionsCache::CachedDevOptions() | ||||
| 			{ | ||||
| 				UGasaDevOptions* DevOpts = GetMutDevOptions(); | ||||
|  | ||||
| 				<cached_property_assignments> | ||||
|  | ||||
| 				Tag_GlobalPPV = DevOpts->Tag_GlobalPPV; | ||||
| 			}) | ||||
| 		)); | ||||
| 		source.print(CachedDevOptions); | ||||
| 		source.write(); | ||||
| 		format_file( path_module_gasa "GasaDevOptionsCache.cpp" ); | ||||
| 	} | ||||
| } | ||||
| @@ -1,4 +1,11 @@ | ||||
| // Used in the GasaGen.cpp translation unit | ||||
| #if GASA_INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #define GEN_EXPOSE_BACKEND | ||||
| #include "gen.hpp" | ||||
| #include "gen.builder.hpp" | ||||
| #include "GasaGenCommon.cpp" | ||||
| #endif | ||||
|  | ||||
| void def_attribute_properties            ( CodeBody body, Array<StringCached> properties ); | ||||
| void def_attribute_field_on_reps         ( CodeBody body, Array<StringCached> properties ); | ||||
| @@ -30,20 +37,20 @@ void gen_UGasaAttributeSet() | ||||
| 			CodeInclude Include_AbilitySystemComponent     = def_include(txt("AbilitySystemComponent.h")); | ||||
| 			CodeInclude Include_GasaAttributeSet_Generated = def_include(txt("GasaAttributeSet.generated.h")); | ||||
|  | ||||
| 			CodeAttributes api_attribute= def_attributes( gasa_api->Name); | ||||
| 			CodeAttributes api_attribute= def_attributes( UModule_GASA_API->Name); | ||||
|  | ||||
| 			CodeClass GasaAttributeSet = {}; | ||||
| 			{ | ||||
| 				CodeBody body = def_body( CodeT::Class_Body ); | ||||
| 				{ | ||||
| 					body.append( umeta_generated_body); | ||||
| 					body.append( fmt_newline); | ||||
| 					body.append( UHT_GENERATED_BODY); | ||||
| 					body.append( access_public ); | ||||
|  | ||||
| 					def_attribute_properties( body, attribute_fields); | ||||
|  | ||||
| 					body.append(fmt_newline); | ||||
| 					body.append( def_constructor() ); | ||||
| 					body.append(fmt_newline); | ||||
|  | ||||
| 					def_attribute_field_on_reps( body, attribute_fields); | ||||
|  | ||||
| @@ -90,11 +97,12 @@ void gen_UGasaAttributeSet() | ||||
| 			header.print( Include_AbilitySystemComponent); | ||||
| 			header.print( Include_GasaAttributeSet_Generated); | ||||
| 			header.print( fmt_newline); | ||||
| 			header.print(umeta_uclass); | ||||
| 			header.print( UHT_UCLASS ); | ||||
| 			header.print(GasaAttributeSet); | ||||
| 			header.print(ns_gasa); | ||||
| 		} | ||||
| 		header.write(); | ||||
| 		format_file(path_gasa_ability_system "GasaAttributeSet.h"); | ||||
| 	} | ||||
|  | ||||
| 	Builder source = Builder::open( path_gasa_ability_system "GasaAttributeSet.cpp" ); | ||||
| @@ -119,15 +127,15 @@ void gen_UGasaAttributeSet() | ||||
| 					InitMaxMana( 50.f ); | ||||
| 				} | ||||
| 			)); | ||||
|  | ||||
| 			body.append(constructor_for_UGasaAttributeSet ); | ||||
| 			body.append(fmt_newline); | ||||
|  | ||||
| 			impl_attribute_fields( body, class_name, attribute_fields); | ||||
|  | ||||
| 			CodeFn GetLifetimeOfReplicatedProps; | ||||
| 			{ | ||||
| 				CodeBody field_lifetimes = def_body( CodeT::Function_Body); | ||||
| 				field_lifetimes.append(fmt_newline); | ||||
| 				field_lifetimes.append(fmt_newline); | ||||
| 				for (StringCached field : attribute_fields) | ||||
| 				{ | ||||
| 					field_lifetimes.append( code_fmt( "field", (StrC)field, stringize( | ||||
| @@ -148,6 +156,7 @@ void gen_UGasaAttributeSet() | ||||
| 			source.print(body); | ||||
| 		} | ||||
| 		source.write(); | ||||
| 		format_file(path_gasa_ability_system "GasaAttributeSet.cpp"); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -200,12 +209,12 @@ void def_attribute_field_property_getters( CodeBody body, StrC class_name, Array | ||||
| 	} | ||||
| } | ||||
|  | ||||
| #pragma push_macro("FORCEINLINE") | ||||
| #undef FORCEINLINE | ||||
| void def_attribute_field_value_getters( CodeBody body, Array<StringCached> properties ) | ||||
| { | ||||
| 	for ( String property : properties ) | ||||
| 	{ | ||||
| #pragma push_macro(FORCEINLINE) | ||||
| #undef FORCEINLINE | ||||
| 		body.append( code_fmt( "property", (StrC)property, | ||||
| 		stringize( | ||||
| 			FORCEINLINE float Get<property>() const | ||||
| @@ -213,7 +222,6 @@ void def_attribute_field_value_getters( CodeBody body, Array<StringCached> prope | ||||
| 				return <property>.GetCurrentValue(); | ||||
| 			} | ||||
| 		))); | ||||
| #pragma pop_macro(FORCEINLINE) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -267,3 +275,4 @@ void impl_attribute_fields( CodeBody body, StrC class_name, Array<StringCached> | ||||
| 		body.append( field_impl ); | ||||
| 	} | ||||
| } | ||||
| #pragma pop_macro("FORCEINLINE") | ||||
|   | ||||
| @@ -1,3 +1,12 @@ | ||||
| // Used in the GasaGen.cpp translation unit | ||||
| #if GASA_INTELLISENSE_DIRECTIVES | ||||
| #pragma once | ||||
| #define GEN_EXPOSE_BACKEND | ||||
| #include "gen.hpp" | ||||
| #include "gen.builder.hpp" | ||||
| #include "GasaGenCommon.cpp" | ||||
| #endif | ||||
|  | ||||
| void ue_parse_testing() | ||||
| { | ||||
| 	FileContents content; | ||||
| @@ -5,7 +14,7 @@ void ue_parse_testing() | ||||
| #define path_UProgressBar \ | ||||
| 	"C:/projects/Unreal/Surgo/UE/Engine/Source/Runtime/UMG/Public/Components/ProgressBar.h" | ||||
|  | ||||
| #if 0 | ||||
| #if 1 | ||||
| 	content = file_read_contents( GlobalAllocator, true, path_UProgressBar ); | ||||
| 	CodeBody parsed_uprogressbar = parse_global_body( StrC { content.size, (char const*)content.data }); | ||||
|  | ||||
| @@ -40,7 +49,7 @@ void ue_parse_testing() | ||||
| #define path_UObject \ | ||||
| 	R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Runtime\CoreUObject\Public\UObject\Object.h)" | ||||
|  | ||||
| #if 0 | ||||
| #if 1 | ||||
| 	content = file_read_contents( GlobalAllocator, true, path_UObject ); | ||||
| 	CodeBody parsed_uobject = parse_global_body( StrC { content.size, (char const*)content.data }); | ||||
|  | ||||
| @@ -78,7 +87,7 @@ void ue_parse_testing() | ||||
| #define path_AActor \ | ||||
| 	R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Runtime\Engine\Classes\GameFramework\Actor.h)" | ||||
|  | ||||
| #if 0 | ||||
| #if 1 | ||||
| 	content = file_read_contents( GlobalAllocator, true, path_AActor ); | ||||
| 	CodeBody parsed_aactor = parse_global_body( StrC { content.size, (char const*)content.data }); | ||||
|  | ||||
| @@ -112,7 +121,7 @@ void ue_parse_testing() | ||||
| #define path_ActorComponent \ | ||||
| 	R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Runtime\Engine\Classes\Components\ActorComponent.h)" | ||||
|  | ||||
| #if 0 | ||||
| #if 1 | ||||
| 	content = file_read_contents( GlobalAllocator, true, path_ActorComponent ); | ||||
| 	CodeBody parsed_actor_component = parse_global_body( StrC { content.size, (char const*)content.data }); | ||||
|  | ||||
| @@ -146,7 +155,7 @@ void ue_parse_testing() | ||||
| #define path_SceneComponent \ | ||||
| 	R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Runtime\Engine\Classes\Components\SceneComponent.h)" | ||||
|  | ||||
| #if 0 | ||||
| #if 1 | ||||
| 	content = file_read_contents( GlobalAllocator, true, path_SceneComponent ); | ||||
| 	CodeBody parsed_scene_component = parse_global_body( StrC { content.size, (char const*)content.data }); | ||||
|  | ||||
| @@ -180,7 +189,7 @@ void ue_parse_testing() | ||||
| #define path_AttributeSet \ | ||||
| 	R"(C:\projects\Unreal\Surgo\UE\Engine\Plugins\Runtime\GameplayAbilities\Source\GameplayAbilities\Public\AttributeSet.h)" | ||||
|  | ||||
| #if 0 | ||||
| #if 1 | ||||
| 	content = file_read_contents( GlobalAllocator, true, path_AttributeSet ); | ||||
| 	CodeBody parsed_attribute_set = parse_global_body( StrC { content.size, (char const*)content.data }); | ||||
|  | ||||
|   | ||||
| @@ -14,7 +14,6 @@ Builder Builder::open( char const* path ) | ||||
| 		log_failure( "gen::File::open - Could not open file: %s", path ); | ||||
| 		return result; | ||||
| 	} | ||||
|  | ||||
| 	result.Buffer = String::make_reserve( GlobalAllocator, Builder_StrBufferReserve ); | ||||
|  | ||||
| 	// log_fmt("$Builder - Opened file: %s\n", result.File.filename ); | ||||
| @@ -37,7 +36,7 @@ void Builder::print( Code code ) | ||||
| void Builder::print_fmt( char const* fmt, ... ) | ||||
| { | ||||
| 	sw   res; | ||||
| 	char buf[ GEN_PRINTF_MAXLEN ] = { 0 }; | ||||
| 	char buf[GEN_PRINTF_MAXLEN] = { 0 }; | ||||
|  | ||||
| 	va_list va; | ||||
| 	va_start( va, fmt ); | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -192,7 +192,7 @@ s64 str_to_i64( const char* str, char** end_ptr, s32 base ) | ||||
|  | ||||
| 	len = _scan_zpl_i64( str, base, &value ); | ||||
| 	if ( end_ptr ) | ||||
| 		*end_ptr = ( char* )str + len; | ||||
| 		*end_ptr = (char*)str + len; | ||||
| 	return value; | ||||
| } | ||||
|  | ||||
| @@ -213,7 +213,7 @@ void i64_to_str( s64 value, char* string, s32 base ) | ||||
| 	{ | ||||
| 		while ( v > 0 ) | ||||
| 		{ | ||||
| 			*buf++  = _num_to_char_table[ v % base ]; | ||||
| 			*buf++  = _num_to_char_table[v % base]; | ||||
| 			v      /= base; | ||||
| 		} | ||||
| 	} | ||||
| @@ -235,7 +235,7 @@ void u64_to_str( u64 value, char* string, s32 base ) | ||||
| 	{ | ||||
| 		while ( value > 0 ) | ||||
| 		{ | ||||
| 			*buf++  = _num_to_char_table[ value % base ]; | ||||
| 			*buf++  = _num_to_char_table[value % base]; | ||||
| 			value  /= base; | ||||
| 		} | ||||
| 	} | ||||
| @@ -442,8 +442,8 @@ internal sw _print_string( char* text, sw max_len, _format_info* info, char cons | ||||
|  | ||||
| internal sw _print_char( char* text, sw max_len, _format_info* info, char arg ) | ||||
| { | ||||
| 	char str[ 2 ] = ""; | ||||
| 	str[ 0 ]      = arg; | ||||
| 	char str[2] = ""; | ||||
| 	str[0]      = arg; | ||||
| 	return _print_string( text, max_len, info, str ); | ||||
| } | ||||
|  | ||||
| @@ -460,14 +460,14 @@ internal sw _print_repeated_char( char* text, sw max_len, _format_info* info, ch | ||||
|  | ||||
| internal sw _print_i64( char* text, sw max_len, _format_info* info, s64 value ) | ||||
| { | ||||
| 	char num[ 130 ]; | ||||
| 	char num[130]; | ||||
| 	i64_to_str( value, num, info ? info->base : 10 ); | ||||
| 	return _print_string( text, max_len, info, num ); | ||||
| } | ||||
|  | ||||
| internal sw _print_u64( char* text, sw max_len, _format_info* info, u64 value ) | ||||
| { | ||||
| 	char num[ 130 ]; | ||||
| 	char num[130]; | ||||
| 	u64_to_str( value, num, info ? info->base : 10 ); | ||||
| 	return _print_string( text, max_len, info, num ); | ||||
| } | ||||
| @@ -564,7 +564,7 @@ internal sw _print_f64( char* text, sw max_len, _format_info* info, b32 is_hexad | ||||
| 		while ( len-- ) | ||||
| 		{ | ||||
| 			if ( text_begin + len < end ) | ||||
| 				text_begin[ len ] = fill; | ||||
| 				text_begin[len] = fill; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @@ -857,7 +857,7 @@ neverinline sw str_fmt_va( char* text, sw max_len, char const* fmt, va_list va ) | ||||
|  | ||||
| char* str_fmt_buf_va( char const* fmt, va_list va ) | ||||
| { | ||||
| 	local_persist thread_local char buffer[ GEN_PRINTF_MAXLEN ]; | ||||
| 	local_persist thread_local char buffer[GEN_PRINTF_MAXLEN]; | ||||
| 	str_fmt_va( buffer, size_of( buffer ), fmt, va ); | ||||
| 	return buffer; | ||||
| } | ||||
| @@ -874,7 +874,7 @@ char* str_fmt_buf( char const* fmt, ... ) | ||||
|  | ||||
| sw str_fmt_file_va( struct FileInfo* f, char const* fmt, va_list va ) | ||||
| { | ||||
| 	local_persist thread_local char buf[ GEN_PRINTF_MAXLEN ]; | ||||
| 	local_persist thread_local char buf[GEN_PRINTF_MAXLEN]; | ||||
| 	sw                              len = str_fmt_va( buf, size_of( buf ), fmt, va ); | ||||
| 	b32                             res = file_write( f, buf, len - 1 );    // NOTE: prevent extra whitespace | ||||
| 	return res ? len : -1; | ||||
| @@ -924,7 +924,7 @@ sw str_fmt_out_err( char const* fmt, ... ) | ||||
|  | ||||
| #pragma region Hashing | ||||
|  | ||||
| global u32 const _crc32_table[ 256 ] = { | ||||
| global u32 const _crc32_table[256] = { | ||||
| 	0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, | ||||
| 	0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, | ||||
| 	0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, | ||||
| @@ -953,11 +953,11 @@ u32 crc32( void const* data, sw len ) | ||||
| 	u32       result = ~( zpl_cast( u32 ) 0 ); | ||||
| 	u8 const* c      = zpl_cast( u8 const* ) data; | ||||
| 	for ( remaining = len; remaining--; c++ ) | ||||
| 		result = ( result >> 8 ) ^ ( _crc32_table[ ( result ^ *c ) & 0xff ] ); | ||||
| 		result = ( result >> 8 ) ^ ( _crc32_table[( result ^ *c ) & 0xff] ); | ||||
| 	return ~result; | ||||
| } | ||||
|  | ||||
| global u64 const _crc64_table[ 256 ] = { | ||||
| global u64 const _crc64_table[256] = { | ||||
| 	0x0000000000000000ull, 0x7ad870c830358979ull, 0xf5b0e190606b12f2ull, 0x8f689158505e9b8bull, 0xc038e5739841b68full, 0xbae095bba8743ff6ull, | ||||
| 	0x358804e3f82aa47dull, 0x4f50742bc81f2d04ull, 0xab28ecb46814fe75ull, 0xd1f09c7c5821770cull, 0x5e980d24087fec87ull, 0x24407dec384a65feull, | ||||
| 	0x6b1009c7f05548faull, 0x11c8790fc060c183ull, 0x9ea0e857903e5a08ull, 0xe478989fa00bd371ull, 0x7d08ff3b88be6f81ull, 0x07d08ff3b88be6f8ull, | ||||
| @@ -1009,7 +1009,7 @@ u64 crc64( void const* data, sw len ) | ||||
| 	u64       result = ( zpl_cast( u64 ) 0 ); | ||||
| 	u8 const* c      = zpl_cast( u8 const* ) data; | ||||
| 	for ( remaining = len; remaining--; c++ ) | ||||
| 		result = ( result >> 8 ) ^ ( _crc64_table[ ( result ^ *c ) & 0xff ] ); | ||||
| 		result = ( result >> 8 ) ^ ( _crc64_table[( result ^ *c ) & 0xff] ); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| @@ -1363,7 +1363,7 @@ void* Arena::allocator_proc( void* allocator_data, AllocType type, sw size, sw a | ||||
| 			sw    total_size = align_forward_i64( size, alignment ); | ||||
|  | ||||
| 			// NOTE: Out of memory | ||||
| 			if ( arena->TotalUsed + total_size > ( sw )arena->TotalSize ) | ||||
| 			if ( arena->TotalUsed + total_size > (sw)arena->TotalSize ) | ||||
| 			{ | ||||
| 				// zpl__printf_err("%s", "Arena out of memory\n"); | ||||
| 				GEN_FATAL( "Arena out of memory! (Possibly could not fit for the largest size Arena!!)" ); | ||||
| @@ -1495,13 +1495,13 @@ Pool Pool::init_align( AllocatorInfo backing, sw num_blocks, sw block_size, sw b | ||||
| 	curr = data; | ||||
| 	for ( block_index = 0; block_index < num_blocks - 1; block_index++ ) | ||||
| 	{ | ||||
| 		uptr* next = ( uptr* )curr; | ||||
| 		*next      = ( uptr )curr + actual_block_size; | ||||
| 		uptr* next = (uptr*)curr; | ||||
| 		*next      = (uptr)curr + actual_block_size; | ||||
| 		curr       = pointer_add( curr, actual_block_size ); | ||||
| 	} | ||||
|  | ||||
| 	end                = ( uptr* )curr; | ||||
| 	*end               = ( uptr )NULL; | ||||
| 	end                = (uptr*)curr; | ||||
| 	*end               = (uptr)NULL; | ||||
|  | ||||
| 	pool.PhysicalStart = data; | ||||
| 	pool.FreeList      = data; | ||||
| @@ -1520,13 +1520,13 @@ void Pool::clear() | ||||
| 	curr              = PhysicalStart; | ||||
| 	for ( block_index = 0; block_index < NumBlocks - 1; block_index++ ) | ||||
| 	{ | ||||
| 		uptr* next = ( uptr* )curr; | ||||
| 		*next      = ( uptr )curr + actual_block_size; | ||||
| 		uptr* next = (uptr*)curr; | ||||
| 		*next      = (uptr)curr + actual_block_size; | ||||
| 		curr       = pointer_add( curr, actual_block_size ); | ||||
| 	} | ||||
|  | ||||
| 	end      = ( uptr* )curr; | ||||
| 	*end     = ( uptr )NULL; | ||||
| 	end      = (uptr*)curr; | ||||
| 	*end     = (uptr)NULL; | ||||
|  | ||||
| 	FreeList = PhysicalStart; | ||||
| } | ||||
| @@ -1565,7 +1565,7 @@ String String::make_length( AllocatorInfo allocator, char const* str, sw length | ||||
| 	else | ||||
| 		mem_set( result, 0, alloc_size - header_size ); | ||||
|  | ||||
| 	result[ length ] = '\0'; | ||||
| 	result[length] = '\0'; | ||||
|  | ||||
| 	return result; | ||||
| } | ||||
| @@ -1593,7 +1593,7 @@ String String::make_reserve( AllocatorInfo allocator, sw capacity ) | ||||
|  | ||||
| String String::fmt_buf( AllocatorInfo allocator, char const* fmt, ... ) | ||||
| { | ||||
| 	local_persist thread_local char buf[ GEN_PRINTF_MAXLEN ] = { 0 }; | ||||
| 	local_persist thread_local char buf[GEN_PRINTF_MAXLEN] = { 0 }; | ||||
|  | ||||
| 	va_list va; | ||||
| 	va_start( va, fmt ); | ||||
| @@ -1606,7 +1606,7 @@ String String::fmt_buf( AllocatorInfo allocator, char const* fmt, ... ) | ||||
| bool String::append_fmt( char const* fmt, ... ) | ||||
| { | ||||
| 	sw   res; | ||||
| 	char buf[ GEN_PRINTF_MAXLEN ] = { 0 }; | ||||
| 	char buf[GEN_PRINTF_MAXLEN] = { 0 }; | ||||
|  | ||||
| 	va_list va; | ||||
| 	va_start( va, fmt ); | ||||
| @@ -1694,7 +1694,7 @@ internal wchar_t* _alloc_utf8_to_ucs2( AllocatorInfo a, char const* text, sw* w_ | ||||
| 			*w_len_ = 0; | ||||
| 		return NULL; | ||||
| 	} | ||||
| 	w_text[ w_len ] = 0; | ||||
| 	w_text[w_len] = 0; | ||||
| 	if ( w_len_ ) | ||||
| 		*w_len_ = w_len; | ||||
| 	return w_text; | ||||
| @@ -1928,8 +1928,8 @@ neverinline GEN_FILE_OPEN_PROC( _posix_file_open ) | ||||
| internal void _dirinfo_free_entry( DirEntry* entry ); | ||||
|  | ||||
| // TODO : Is this a bad idea? | ||||
| global b32      _std_file_set                     = false; | ||||
| global FileInfo _std_files[ EFileStandard_COUNT ] = { | ||||
| global b32      _std_file_set                   = false; | ||||
| global FileInfo _std_files[EFileStandard_COUNT] = { | ||||
| 	{ { nullptr, nullptr, nullptr, nullptr }, { nullptr }, 0, nullptr, 0, nullptr } | ||||
| }; | ||||
|  | ||||
| @@ -1940,15 +1940,15 @@ FileInfo* file_get_standard( FileStandardType std ) | ||||
| 	if ( ! _std_file_set ) | ||||
| 	{ | ||||
| #define GEN__SET_STD_FILE( type, v ) \ | ||||
| 	_std_files[ type ].fd.p = v;     \ | ||||
| 	_std_files[ type ].ops  = default_file_operations | ||||
| 	_std_files[type].fd.p = v;       \ | ||||
| 	_std_files[type].ops  = default_file_operations | ||||
|         GEN__SET_STD_FILE( EFileStandard_INPUT, GetStdHandle( STD_INPUT_HANDLE ) ); | ||||
|         GEN__SET_STD_FILE( EFileStandard_OUTPUT, GetStdHandle( STD_OUTPUT_HANDLE ) ); | ||||
|         GEN__SET_STD_FILE( EFileStandard_ERROR, GetStdHandle( STD_ERROR_HANDLE ) ); | ||||
| #undef GEN__SET_STD_FILE | ||||
| 		_std_file_set = true; | ||||
| 	} | ||||
| 	return &_std_files[ std ]; | ||||
| 	return &_std_files[std]; | ||||
| } | ||||
|  | ||||
| #else    // POSIX | ||||
| @@ -1958,15 +1958,15 @@ FileInfo* file_get_standard( FileStandardType std ) | ||||
| 	if ( ! _std_file_set ) | ||||
| 	{ | ||||
| #define GEN__SET_STD_FILE( type, v ) \ | ||||
| 	_std_files[ type ].fd.i = v;     \ | ||||
| 	_std_files[ type ].ops  = default_file_operations | ||||
| 	_std_files[type].fd.i = v;       \ | ||||
| 	_std_files[type].ops  = default_file_operations | ||||
| 		GEN__SET_STD_FILE( EFileStandard_INPUT, 0 ); | ||||
| 		GEN__SET_STD_FILE( EFileStandard_OUTPUT, 1 ); | ||||
| 		GEN__SET_STD_FILE( EFileStandard_ERROR, 2 ); | ||||
| #undef GEN__SET_STD_FILE | ||||
| 		_std_file_set = true; | ||||
| 	} | ||||
| 	return &_std_files[ std ]; | ||||
| 	return &_std_files[std]; | ||||
| } | ||||
|  | ||||
| #endif | ||||
| @@ -2082,8 +2082,8 @@ FileContents file_read_contents( AllocatorInfo a, b32 zero_terminate, char const | ||||
| 			file_read_at( &file, result.data, result.size, 0 ); | ||||
| 			if ( zero_terminate ) | ||||
| 			{ | ||||
| 				u8* str      = zpl_cast( u8* ) result.data; | ||||
| 				str[ fsize ] = '\0'; | ||||
| 				u8* str    = zpl_cast( u8* ) result.data; | ||||
| 				str[fsize] = '\0'; | ||||
| 			} | ||||
| 		} | ||||
| 		file_close( &file ); | ||||
| @@ -2111,13 +2111,13 @@ GEN_DEF_INLINE _memory_fd*    _file_stream_from_fd( FileDescriptor fd ); | ||||
| GEN_IMPL_INLINE FileDescriptor _file_stream_fd_make( _memory_fd* d ) | ||||
| { | ||||
| 	FileDescriptor fd = { 0 }; | ||||
| 	fd.p              = ( void* )d; | ||||
| 	fd.p              = (void*)d; | ||||
| 	return fd; | ||||
| } | ||||
|  | ||||
| GEN_IMPL_INLINE _memory_fd* _file_stream_from_fd( FileDescriptor fd ) | ||||
| { | ||||
| 	_memory_fd* d = ( _memory_fd* )fd.p; | ||||
| 	_memory_fd* d = (_memory_fd*)fd.p; | ||||
| 	GEN_ASSERT( d->magic == GEN__FILE_STREAM_FD_MAGIC ); | ||||
| 	return d; | ||||
| } | ||||
| @@ -2126,7 +2126,7 @@ b8 file_stream_new( FileInfo* file, AllocatorInfo allocator ) | ||||
| { | ||||
| 	GEN_ASSERT_NOT_NULL( file ); | ||||
|  | ||||
| 	_memory_fd* d = ( _memory_fd* )alloc( allocator, size_of( _memory_fd ) ); | ||||
| 	_memory_fd* d = (_memory_fd*)alloc( allocator, size_of( _memory_fd ) ); | ||||
|  | ||||
| 	if ( ! d ) | ||||
| 		return false; | ||||
| @@ -2136,7 +2136,7 @@ b8 file_stream_new( FileInfo* file, AllocatorInfo allocator ) | ||||
| 	d->allocator = allocator; | ||||
| 	d->flags     = EFileStream_CLONE_WRITABLE; | ||||
| 	d->cap       = 0; | ||||
| 	d->buf       = Array< u8 >::init( allocator ); | ||||
| 	d->buf       = Array<u8>::init( allocator ); | ||||
|  | ||||
| 	if ( ! d->buf ) | ||||
| 		return false; | ||||
| @@ -2153,7 +2153,7 @@ b8 file_stream_new( FileInfo* file, AllocatorInfo allocator ) | ||||
| b8 file_stream_open( FileInfo* file, AllocatorInfo allocator, u8* buffer, sw size, FileStreamFlags flags ) | ||||
| { | ||||
| 	GEN_ASSERT_NOT_NULL( file ); | ||||
| 	_memory_fd* d = ( _memory_fd* )alloc( allocator, size_of( _memory_fd ) ); | ||||
| 	_memory_fd* d = (_memory_fd*)alloc( allocator, size_of( _memory_fd ) ); | ||||
| 	if ( ! d ) | ||||
| 		return false; | ||||
| 	zero_item( file ); | ||||
| @@ -2162,8 +2162,8 @@ b8 file_stream_open( FileInfo* file, AllocatorInfo allocator, u8* buffer, sw siz | ||||
| 	d->flags     = flags; | ||||
| 	if ( d->flags & EFileStream_CLONE_WRITABLE ) | ||||
| 	{ | ||||
| 		Array< u8 > arr = Array< u8 >::init_reserve( allocator, size ); | ||||
| 		d->buf          = arr; | ||||
| 		Array<u8> arr = Array<u8>::init_reserve( allocator, size ); | ||||
| 		d->buf        = arr; | ||||
|  | ||||
| 		if ( ! d->buf ) | ||||
| 			return false; | ||||
| @@ -2236,11 +2236,11 @@ internal GEN_FILE_WRITE_AT_PROC( _memory_file_write ) | ||||
|  | ||||
| 	if ( d->flags & EFileStream_CLONE_WRITABLE ) | ||||
| 	{ | ||||
| 		Array< u8 > arr = { d->buf }; | ||||
| 		Array<u8> arr = { d->buf }; | ||||
|  | ||||
| 		if ( arr.get_header()->Capacity < new_cap ) | ||||
| 		{ | ||||
| 			if ( ! arr.grow( ( s64 )( new_cap ) ) ) | ||||
| 			if ( ! arr.grow( (s64)( new_cap ) ) ) | ||||
| 				return false; | ||||
| 			d->buf = arr; | ||||
| 		} | ||||
| @@ -2250,7 +2250,7 @@ internal GEN_FILE_WRITE_AT_PROC( _memory_file_write ) | ||||
|  | ||||
| 	if ( ( d->flags & EFileStream_CLONE_WRITABLE ) && extralen > 0 ) | ||||
| 	{ | ||||
| 		Array< u8 > arr = { d->buf }; | ||||
| 		Array<u8> arr = { d->buf }; | ||||
|  | ||||
| 		mem_copy( d->buf + offset + rwlen, pointer_add_const( buffer, rwlen ), extralen ); | ||||
| 		d->cap                     = new_cap; | ||||
| @@ -2273,7 +2273,7 @@ internal GEN_FILE_CLOSE_PROC( _memory_file_close ) | ||||
|  | ||||
| 	if ( d->flags & EFileStream_CLONE_WRITABLE ) | ||||
| 	{ | ||||
| 		Array< u8 > arr = { d->buf }; | ||||
| 		Array<u8> arr = { d->buf }; | ||||
| 		arr.free(); | ||||
| 	} | ||||
|  | ||||
| @@ -2329,7 +2329,7 @@ u64 read_cpu_time_stamp_counter( void ) | ||||
| #elif defined( GEN_SYSTEM_EMSCRIPTEN ) | ||||
| u64 read_cpu_time_stamp_counter( void ) | ||||
| { | ||||
| 	return ( u64 )( emscripten_get_now() * 1e+6 ); | ||||
| 	return (u64)( emscripten_get_now() * 1e+6 ); | ||||
| } | ||||
| #elif defined( GEN_CPU_ARM ) && ! defined( GEN_COMPILER_TINYC ) | ||||
| u64 read_cpu_time_stamp_counter( void ) | ||||
| @@ -2352,7 +2352,7 @@ u64 read_cpu_time_stamp_counter( void ) | ||||
| 		{    // Is it counting? | ||||
| 			asm volatile( "mrc p15, 0, %0, c9, c13, 0" : "=r"( pmccntr ) ); | ||||
| 			// The counter is set up to count every 64th cycle | ||||
| 			return ( ( int64_t )pmccntr ) * 64;    // Should optimize to << 6 | ||||
| 			return ( (int64_t)pmccntr ) * 64;    // Should optimize to << 6 | ||||
| 		} | ||||
| 	} | ||||
| #else | ||||
| @@ -2441,7 +2441,7 @@ u64 time_rel_ms( void ) | ||||
|  | ||||
| f64 time_rel( void ) | ||||
| { | ||||
| 	return ( f64 )( time_rel_ms() * 1e-3 ); | ||||
| 	return (f64)( time_rel_ms() * 1e-3 ); | ||||
| } | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -170,10 +170,10 @@ GEN_NS_BEGIN | ||||
|  | ||||
| // Casting | ||||
|  | ||||
| #define ccast( Type, Value ) ( *const_cast< Type* >( &( Value ) ) ) | ||||
| #define pcast( Type, Value ) ( *reinterpret_cast< Type* >( &( Value ) ) ) | ||||
| #define rcast( Type, Value ) reinterpret_cast< Type >( Value ) | ||||
| #define scast( Type, Value ) static_cast< Type >( Value ) | ||||
| #define ccast( Type, Value ) ( *const_cast<Type*>( &( Value ) ) ) | ||||
| #define pcast( Type, Value ) ( *reinterpret_cast<Type*>( &( Value ) ) ) | ||||
| #define rcast( Type, Value ) reinterpret_cast<Type>( Value ) | ||||
| #define scast( Type, Value ) static_cast<Type>( Value ) | ||||
|  | ||||
| // Num Arguments (Varadics) | ||||
| // #if defined(__GNUC__) || defined(__clang__) | ||||
| @@ -461,19 +461,19 @@ GEN_NS_BEGIN | ||||
| #define labeled_scope_end             } | ||||
|  | ||||
| #define clamp( x, lower, upper )      min( max( ( x ), ( lower ) ), ( upper ) ) | ||||
| #define count_of( x )                 ( ( size_of( x ) / size_of( 0 [ x ] ) ) / ( ( sw )( ! ( size_of( x ) % size_of( 0 [ x ] ) ) ) ) ) | ||||
| #define count_of( x )                 ( ( size_of( x ) / size_of( 0 [x] ) ) / ( (sw)( ! ( size_of( x ) % size_of( 0 [x] ) ) ) ) ) | ||||
| #define is_between( x, lower, upper ) ( ( ( lower ) <= ( x ) ) && ( ( x ) <= ( upper ) ) ) | ||||
| #define max( a, b )                   ( ( a ) > ( b ) ? ( a ) : ( b ) ) | ||||
| #define min( a, b )                   ( ( a ) < ( b ) ? ( a ) : ( b ) ) | ||||
| #define size_of( x )                  ( sw )( sizeof( x ) ) | ||||
|  | ||||
| #if defined( _MSC_VER ) || defined( GEN_COMPILER_TINYC ) | ||||
| #define offset_of( Type, element ) ( ( GEN_NS( gen_sw ) ) & ( ( ( Type* )0 )->element ) ) | ||||
| #define offset_of( Type, element ) ( ( GEN_NS( gen_sw ) ) & ( ( (Type*)0 )->element ) ) | ||||
| #else | ||||
| #define offset_of( Type, element ) __builtin_offsetof( Type, element ) | ||||
| #endif | ||||
|  | ||||
| template< class Type > | ||||
| template<class Type> | ||||
| void swap( Type& a, Type& b ) | ||||
| { | ||||
| 	Type tmp = a; | ||||
| @@ -640,13 +640,13 @@ s32  assert_crash( char const* condition ); | ||||
| void process_exit( u32 code ); | ||||
|  | ||||
| #if Build_Debug | ||||
| #define GEN_FATAL( ... )                                                  \ | ||||
| 	do                                                                    \ | ||||
| 	{                                                                     \ | ||||
| 		local_persist thread_local char buf[ GEN_PRINTF_MAXLEN ] = { 0 }; \ | ||||
|                                                                           \ | ||||
| 		str_fmt( buf, GEN_PRINTF_MAXLEN, __VA_ARGS__ );                   \ | ||||
| 		GEN_PANIC( buf );                                                 \ | ||||
| #define GEN_FATAL( ... )                                                \ | ||||
| 	do                                                                  \ | ||||
| 	{                                                                   \ | ||||
| 		local_persist thread_local char buf[GEN_PRINTF_MAXLEN] = { 0 }; \ | ||||
|                                                                         \ | ||||
| 		str_fmt( buf, GEN_PRINTF_MAXLEN, __VA_ARGS__ );                 \ | ||||
| 		GEN_PANIC( buf );                                               \ | ||||
| 	} while ( 0 ) | ||||
| #else | ||||
|  | ||||
| @@ -662,10 +662,10 @@ void process_exit( u32 code ); | ||||
|  | ||||
| #pragma region Memory | ||||
|  | ||||
| #define kilobytes( x )     ( ( x ) * ( s64 )( 1024 ) ) | ||||
| #define megabytes( x )     ( kilobytes( x ) * ( s64 )( 1024 ) ) | ||||
| #define gigabytes( x )     ( megabytes( x ) * ( s64 )( 1024 ) ) | ||||
| #define terabytes( x )     ( gigabytes( x ) * ( s64 )( 1024 ) ) | ||||
| #define kilobytes( x )     ( ( x ) * (s64)( 1024 ) ) | ||||
| #define megabytes( x )     ( kilobytes( x ) * (s64)( 1024 ) ) | ||||
| #define gigabytes( x )     ( megabytes( x ) * (s64)( 1024 ) ) | ||||
| #define terabytes( x )     ( gigabytes( x ) * (s64)( 1024 ) ) | ||||
|  | ||||
| #define GEN__ONES          ( zpl_cast( uw ) - 1 / GEN_U8_MAX ) | ||||
| #define GEN__HIGHS         ( GEN__ONES * ( GEN_U8_MAX / 2 + 1 ) ) | ||||
| @@ -759,10 +759,10 @@ GEN_DEF_INLINE void* resize( AllocatorInfo a, void* ptr, sw old_size, sw new_siz | ||||
| GEN_DEF_INLINE void* resize_align( AllocatorInfo a, void* ptr, sw old_size, sw new_size, sw alignment ); | ||||
|  | ||||
| //! Allocate memory for an item. | ||||
| #define alloc_item( allocator_, Type ) ( Type* )alloc( allocator_, size_of( Type ) ) | ||||
| #define alloc_item( allocator_, Type ) (Type*)alloc( allocator_, size_of( Type ) ) | ||||
|  | ||||
| //! Allocate memory for an array of items. | ||||
| #define alloc_array( allocator_, Type, count ) ( Type* )alloc( allocator_, size_of( Type ) * ( count ) ) | ||||
| #define alloc_array( allocator_, Type, count ) (Type*)alloc( allocator_, size_of( Type ) * ( count ) ) | ||||
|  | ||||
| /* heap memory analysis tools */ | ||||
| /* define GEN_HEAP_ANALYSIS to enable this feature */ | ||||
| @@ -873,7 +873,7 @@ GEN_IMPL_INLINE void* mem_move( void* dest, void const* source, sw n ) | ||||
| 			{ | ||||
| 				if ( ! n-- ) | ||||
| 					return dest; | ||||
| 				d[ n ] = s[ n ]; | ||||
| 				d[n] = s[n]; | ||||
| 			} | ||||
| 			while ( n >= size_of( sw ) ) | ||||
| 			{ | ||||
| @@ -882,7 +882,7 @@ GEN_IMPL_INLINE void* mem_move( void* dest, void const* source, sw n ) | ||||
| 			} | ||||
| 		} | ||||
| 		while ( n ) | ||||
| 			n--, d[ n ] = s[ n ]; | ||||
| 			n--, d[n] = s[n]; | ||||
| 	} | ||||
|  | ||||
| 	return dest; | ||||
| @@ -897,18 +897,18 @@ GEN_IMPL_INLINE void* mem_set( void* dest, u8 c, sw n ) | ||||
|  | ||||
| 	u8* s = zpl_cast( u8* ) dest; | ||||
| 	sw  k; | ||||
| 	u32 c32 = ( ( u32 )-1 ) / 255 * c; | ||||
| 	u32 c32 = ( (u32)-1 ) / 255 * c; | ||||
|  | ||||
| 	if ( n == 0 ) | ||||
| 		return dest; | ||||
| 	s[ 0 ] = s[ n - 1 ] = c; | ||||
| 	s[0] = s[n - 1] = c; | ||||
| 	if ( n < 3 ) | ||||
| 		return dest; | ||||
| 	s[ 1 ] = s[ n - 2 ] = c; | ||||
| 	s[ 2 ] = s[ n - 3 ] = c; | ||||
| 	s[1] = s[n - 2] = c; | ||||
| 	s[2] = s[n - 3] = c; | ||||
| 	if ( n < 7 ) | ||||
| 		return dest; | ||||
| 	s[ 3 ] = s[ n - 4 ] = c; | ||||
| 	s[3] = s[n - 4] = c; | ||||
| 	if ( n < 9 ) | ||||
| 		return dest; | ||||
|  | ||||
| @@ -1081,7 +1081,7 @@ struct Arena | ||||
| 		GEN_ASSERT( is_power_of_two( alignment ) ); | ||||
|  | ||||
| 		alignment_offset = 0; | ||||
| 		result_pointer   = ( sw )PhysicalStart + TotalUsed; | ||||
| 		result_pointer   = (sw)PhysicalStart + TotalUsed; | ||||
| 		mask             = alignment - 1; | ||||
|  | ||||
| 		if ( result_pointer & mask ) | ||||
| @@ -1124,7 +1124,7 @@ struct Arena | ||||
|  | ||||
| // Just a wrapper around using an arena with memory associated with its scope instead of from an allocator. | ||||
| // Used for static segment or stack allocations. | ||||
| template< s32 Size > | ||||
| template<s32 Size> | ||||
| struct FixedArena | ||||
| { | ||||
| 	static FixedArena init() | ||||
| @@ -1144,21 +1144,21 @@ struct FixedArena | ||||
| 	} | ||||
|  | ||||
| 	Arena arena; | ||||
| 	char  memory[ Size ]; | ||||
| 	char  memory[Size]; | ||||
| }; | ||||
|  | ||||
| using Arena_1KB   = FixedArena< kilobytes( 1 ) >; | ||||
| using Arena_4KB   = FixedArena< kilobytes( 4 ) >; | ||||
| using Arena_8KB   = FixedArena< kilobytes( 8 ) >; | ||||
| using Arena_16KB  = FixedArena< kilobytes( 16 ) >; | ||||
| using Arena_32KB  = FixedArena< kilobytes( 32 ) >; | ||||
| using Arena_64KB  = FixedArena< kilobytes( 64 ) >; | ||||
| using Arena_128KB = FixedArena< kilobytes( 128 ) >; | ||||
| using Arena_256KB = FixedArena< kilobytes( 256 ) >; | ||||
| using Arena_512KB = FixedArena< kilobytes( 512 ) >; | ||||
| using Arena_1MB   = FixedArena< megabytes( 1 ) >; | ||||
| using Arena_2MB   = FixedArena< megabytes( 2 ) >; | ||||
| using Arena_4MB   = FixedArena< megabytes( 4 ) >; | ||||
| using Arena_1KB   = FixedArena<kilobytes( 1 )>; | ||||
| using Arena_4KB   = FixedArena<kilobytes( 4 )>; | ||||
| using Arena_8KB   = FixedArena<kilobytes( 8 )>; | ||||
| using Arena_16KB  = FixedArena<kilobytes( 16 )>; | ||||
| using Arena_32KB  = FixedArena<kilobytes( 32 )>; | ||||
| using Arena_64KB  = FixedArena<kilobytes( 64 )>; | ||||
| using Arena_128KB = FixedArena<kilobytes( 128 )>; | ||||
| using Arena_256KB = FixedArena<kilobytes( 256 )>; | ||||
| using Arena_512KB = FixedArena<kilobytes( 512 )>; | ||||
| using Arena_1MB   = FixedArena<megabytes( 1 )>; | ||||
| using Arena_2MB   = FixedArena<megabytes( 2 )>; | ||||
| using Arena_4MB   = FixedArena<megabytes( 4 )>; | ||||
|  | ||||
| struct Pool | ||||
| { | ||||
| @@ -1313,7 +1313,7 @@ GEN_IMPL_INLINE s32 str_compare( const char* s1, const char* s2 ) | ||||
| 	{ | ||||
| 		s1++, s2++; | ||||
| 	} | ||||
| 	return *( u8* )s1 - *( u8* )s2; | ||||
| 	return *(u8*)s1 - *(u8*)s2; | ||||
| } | ||||
|  | ||||
| GEN_IMPL_INLINE s32 str_compare( const char* s1, const char* s2, sw len ) | ||||
| @@ -1417,11 +1417,11 @@ GEN_IMPL_INLINE char const* str_skip( char const* str, char c ) | ||||
|  | ||||
| GEN_IMPL_INLINE char const* str_skip_any( char const* str, char const* char_list ) | ||||
| { | ||||
| 	char const* closest_ptr     = zpl_cast( char const* ) pointer_add( ( void* )str, str_len( str ) ); | ||||
| 	char const* closest_ptr     = zpl_cast( char const* ) pointer_add( (void*)str, str_len( str ) ); | ||||
| 	sw          char_list_count = str_len( char_list ); | ||||
| 	for ( sw i = 0; i < char_list_count; i++ ) | ||||
| 	{ | ||||
| 		char const* p = str_skip( str, char_list[ i ] ); | ||||
| 		char const* p = str_skip( str, char_list[i] ); | ||||
| 		closest_ptr   = min( closest_ptr, p ); | ||||
| 	} | ||||
| 	return closest_ptr; | ||||
| @@ -1497,34 +1497,34 @@ inline sw log_fmt( char const* fmt, ... ) | ||||
|  | ||||
| #pragma region Containers | ||||
|  | ||||
| template< class TType > | ||||
| template<class TType> | ||||
| struct RemoveConst | ||||
| { | ||||
| 	typedef TType Type; | ||||
| }; | ||||
|  | ||||
| template< class TType > | ||||
| struct RemoveConst< const TType > | ||||
| template<class TType> | ||||
| struct RemoveConst<const TType> | ||||
| { | ||||
| 	typedef TType Type; | ||||
| }; | ||||
|  | ||||
| template< class TType > | ||||
| struct RemoveConst< const TType[] > | ||||
| template<class TType> | ||||
| struct RemoveConst<const TType[]> | ||||
| { | ||||
| 	typedef TType Type[]; | ||||
| }; | ||||
|  | ||||
| template< class TType, uw Size > | ||||
| struct RemoveConst< const TType[ Size ] > | ||||
| template<class TType, uw Size> | ||||
| struct RemoveConst<const TType[Size]> | ||||
| { | ||||
| 	typedef TType Type[ Size ]; | ||||
| 	typedef TType Type[Size]; | ||||
| }; | ||||
|  | ||||
| template< class TType > | ||||
| using TRemoveConst = typename RemoveConst< TType >::Type; | ||||
| template<class TType> | ||||
| using TRemoveConst = typename RemoveConst<TType>::Type; | ||||
|  | ||||
| template< class Type > | ||||
| template<class Type> | ||||
| struct Array | ||||
| { | ||||
| 	struct Header | ||||
| @@ -1570,7 +1570,7 @@ struct Array | ||||
| 			header = get_header(); | ||||
| 		} | ||||
|  | ||||
| 		Data[ header->Num ] = value; | ||||
| 		Data[header->Num] = value; | ||||
| 		header->Num++; | ||||
|  | ||||
| 		return true; | ||||
| @@ -1617,7 +1617,6 @@ struct Array | ||||
| 		mem_move( target + 1, target, ( header->Num - idx ) * sizeof( Type ) ); | ||||
| 		header->Num++; | ||||
|  | ||||
| 		Data[ idx ] = item; | ||||
| 		return true; | ||||
| 	} | ||||
|  | ||||
| @@ -1651,7 +1650,7 @@ struct Array | ||||
| 	Type& back( void ) | ||||
| 	{ | ||||
| 		Header& header = *get_header(); | ||||
| 		return Data[ header.Num - 1 ]; | ||||
| 		return Data[header.Num - 1]; | ||||
| 	} | ||||
|  | ||||
| 	void clear( void ) | ||||
| @@ -1669,7 +1668,7 @@ struct Array | ||||
|  | ||||
| 		for ( sw idx = begin; idx < end; idx++ ) | ||||
| 		{ | ||||
| 			Data[ idx ] = value; | ||||
| 			Data[idx] = value; | ||||
| 		} | ||||
|  | ||||
| 		return true; | ||||
| @@ -1684,8 +1683,8 @@ struct Array | ||||
|  | ||||
| 	Header* get_header( void ) | ||||
| 	{ | ||||
| 		using NonConstType = TRemoveConst< Type >; | ||||
| 		return rcast( Header*, const_cast< NonConstType* >( Data ) ) - 1; | ||||
| 		using NonConstType = TRemoveConst<Type>; | ||||
| 		return rcast( Header*, const_cast<NonConstType*>( Data ) ) - 1; | ||||
| 	} | ||||
|  | ||||
| 	bool grow( uw min_capacity ) | ||||
| @@ -1804,7 +1803,7 @@ struct Array | ||||
|  | ||||
| // TODO(Ed) : This thing needs ALOT of work. | ||||
|  | ||||
| template< typename Type > | ||||
| template<typename Type> | ||||
| struct HashTable | ||||
| { | ||||
| 	struct FindResult | ||||
| @@ -1823,22 +1822,22 @@ struct HashTable | ||||
|  | ||||
| 	static HashTable init( AllocatorInfo allocator ) | ||||
| 	{ | ||||
| 		HashTable< Type > result = { { nullptr }, { nullptr } }; | ||||
| 		HashTable<Type> result = { { nullptr }, { nullptr } }; | ||||
|  | ||||
| 		result.Hashes            = Array< sw >::init( allocator ); | ||||
| 		result.Entries           = Array< Entry >::init( allocator ); | ||||
| 		result.Hashes          = Array<sw>::init( allocator ); | ||||
| 		result.Entries         = Array<Entry>::init( allocator ); | ||||
|  | ||||
| 		return result; | ||||
| 	} | ||||
|  | ||||
| 	static HashTable init_reserve( AllocatorInfo allocator, uw num ) | ||||
| 	{ | ||||
| 		HashTable< Type > result        = { { nullptr }, { nullptr } }; | ||||
| 		HashTable<Type> result          = { { nullptr }, { nullptr } }; | ||||
|  | ||||
| 		result.Hashes                   = Array< sw >::init_reserve( allocator, num ); | ||||
| 		result.Hashes                   = Array<sw>::init_reserve( allocator, num ); | ||||
| 		result.Hashes.get_header()->Num = num; | ||||
|  | ||||
| 		result.Entries                  = Array< Entry >::init_reserve( allocator, num ); | ||||
| 		result.Entries                  = Array<Entry>::init_reserve( allocator, num ); | ||||
|  | ||||
| 		return result; | ||||
| 	} | ||||
| @@ -1846,7 +1845,7 @@ struct HashTable | ||||
| 	void clear( void ) | ||||
| 	{ | ||||
| 		for ( sw idx = 0; idx < Hashes.num(); idx++ ) | ||||
| 			Hashes[ idx ] = -1; | ||||
| 			Hashes[idx] = -1; | ||||
|  | ||||
| 		Hashes.clear(); | ||||
| 		Entries.clear(); | ||||
| @@ -1865,7 +1864,7 @@ struct HashTable | ||||
| 	{ | ||||
| 		sw idx = find( key ).EntryIndex; | ||||
| 		if ( idx >= 0 ) | ||||
| 			return &Entries[ idx ].Value; | ||||
| 			return &Entries[idx].Value; | ||||
|  | ||||
| 		return nullptr; | ||||
| 	} | ||||
| @@ -1878,7 +1877,7 @@ struct HashTable | ||||
|  | ||||
| 		for ( sw idx = 0; idx < Entries.num(); idx++ ) | ||||
| 		{ | ||||
| 			map_proc( Entries[ idx ].Key, Entries[ idx ].Value ); | ||||
| 			map_proc( Entries[idx].Key, Entries[idx].Value ); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @@ -1890,13 +1889,13 @@ struct HashTable | ||||
|  | ||||
| 		for ( sw idx = 0; idx < Entries.num(); idx++ ) | ||||
| 		{ | ||||
| 			map_proc( Entries[ idx ].Key, &Entries[ idx ].Value ); | ||||
| 			map_proc( Entries[idx].Key, &Entries[idx].Value ); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	void grow() | ||||
| 	{ | ||||
| 		sw new_num = Array< Entry >::grow_formula( Entries.num() ); | ||||
| 		sw new_num = Array<Entry>::grow_formula( Entries.num() ); | ||||
| 		rehash( new_num ); | ||||
| 	} | ||||
|  | ||||
| @@ -1905,34 +1904,34 @@ struct HashTable | ||||
| 		sw idx; | ||||
| 		sw last_added_index; | ||||
|  | ||||
| 		HashTable< Type > new_ht         = init_reserve( Hashes.get_header()->Allocator, new_num ); | ||||
| 		HashTable<Type> new_ht         = init_reserve( Hashes.get_header()->Allocator, new_num ); | ||||
|  | ||||
| 		Array< sw >::Header* hash_header = new_ht.Hashes.get_header(); | ||||
| 		Array<sw>::Header* hash_header = new_ht.Hashes.get_header(); | ||||
|  | ||||
| 		for ( idx = 0; idx < new_ht.Hashes.num(); ++idx ) | ||||
| 			new_ht.Hashes[ idx ] = -1; | ||||
| 			new_ht.Hashes[idx] = -1; | ||||
|  | ||||
| 		for ( idx = 0; idx < Entries.num(); ++idx ) | ||||
| 		{ | ||||
| 			Entry& entry = Entries[ idx ]; | ||||
| 			Entry& entry = Entries[idx]; | ||||
|  | ||||
| 			FindResult find_result; | ||||
|  | ||||
| 			if ( new_ht.Hashes.num() == 0 ) | ||||
| 				new_ht.grow(); | ||||
|  | ||||
| 			entry            = Entries[ idx ]; | ||||
| 			entry            = Entries[idx]; | ||||
| 			find_result      = new_ht.find( entry.Key ); | ||||
| 			last_added_index = new_ht.add_entry( entry.Key ); | ||||
|  | ||||
| 			if ( find_result.PrevIndex < 0 ) | ||||
| 				new_ht.Hashes[ find_result.HashIndex ] = last_added_index; | ||||
| 				new_ht.Hashes[find_result.HashIndex] = last_added_index; | ||||
|  | ||||
| 			else | ||||
| 				new_ht.Entries[ find_result.PrevIndex ].Next = last_added_index; | ||||
| 				new_ht.Entries[find_result.PrevIndex].Next = last_added_index; | ||||
|  | ||||
| 			new_ht.Entries[ last_added_index ].Next  = find_result.EntryIndex; | ||||
| 			new_ht.Entries[ last_added_index ].Value = entry.Value; | ||||
| 			new_ht.Entries[last_added_index].Next  = find_result.EntryIndex; | ||||
| 			new_ht.Entries[last_added_index].Value = entry.Value; | ||||
| 		} | ||||
|  | ||||
| 		destroy(); | ||||
| @@ -1944,23 +1943,23 @@ struct HashTable | ||||
| 		sw idx; | ||||
|  | ||||
| 		for ( idx = 0; idx < Entries.num(); idx++ ) | ||||
| 			Entries[ idx ].Next = -1; | ||||
| 			Entries[idx].Next = -1; | ||||
|  | ||||
| 		for ( idx = 0; idx < Hashes.num(); idx++ ) | ||||
| 			Hashes[ idx ] = -1; | ||||
| 			Hashes[idx] = -1; | ||||
|  | ||||
| 		for ( idx = 0; idx < Entries.num(); idx++ ) | ||||
| 		{ | ||||
| 			Entry*     entry; | ||||
| 			FindResult find_result; | ||||
|  | ||||
| 			entry       = &Entries[ idx ]; | ||||
| 			entry       = &Entries[idx]; | ||||
| 			find_result = find( entry->Key ); | ||||
|  | ||||
| 			if ( find_result.PrevIndex < 0 ) | ||||
| 				Hashes[ find_result.HashIndex ] = idx; | ||||
| 				Hashes[find_result.HashIndex] = idx; | ||||
| 			else | ||||
| 				Entries[ find_result.PrevIndex ].Next = idx; | ||||
| 				Entries[find_result.PrevIndex].Next = idx; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @@ -2000,15 +1999,15 @@ struct HashTable | ||||
|  | ||||
| 			if ( find_result.PrevIndex >= 0 ) | ||||
| 			{ | ||||
| 				Entries[ find_result.PrevIndex ].Next = idx; | ||||
| 				Entries[find_result.PrevIndex].Next = idx; | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				Hashes[ find_result.HashIndex ] = idx; | ||||
| 				Hashes[find_result.HashIndex] = idx; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		Entries[ idx ].Value = value; | ||||
| 		Entries[idx].Value = value; | ||||
|  | ||||
| 		if ( full() ) | ||||
| 			grow(); | ||||
| @@ -2017,14 +2016,14 @@ struct HashTable | ||||
| 	sw slot( u64 key ) | ||||
| 	{ | ||||
| 		for ( sw idx = 0; idx < Hashes.num(); ++idx ) | ||||
| 			if ( Hashes[ idx ] == key ) | ||||
| 			if ( Hashes[idx] == key ) | ||||
| 				return idx; | ||||
|  | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| 	Array< sw >    Hashes; | ||||
| 	Array< Entry > Entries; | ||||
| 	Array<sw>    Hashes; | ||||
| 	Array<Entry> Entries; | ||||
|  | ||||
| protected: | ||||
| 	sw add_entry( u64 key ) | ||||
| @@ -2044,15 +2043,15 @@ protected: | ||||
| 		if ( Hashes.num() > 0 ) | ||||
| 		{ | ||||
| 			result.HashIndex  = key % Hashes.num(); | ||||
| 			result.EntryIndex = Hashes[ result.HashIndex ]; | ||||
| 			result.EntryIndex = Hashes[result.HashIndex]; | ||||
|  | ||||
| 			while ( result.EntryIndex >= 0 ) | ||||
| 			{ | ||||
| 				if ( Entries[ result.EntryIndex ].Key == key ) | ||||
| 				if ( Entries[result.EntryIndex].Key == key ) | ||||
| 					break; | ||||
|  | ||||
| 				result.PrevIndex  = result.EntryIndex; | ||||
| 				result.EntryIndex = Entries[ result.EntryIndex ].Next; | ||||
| 				result.EntryIndex = Entries[result.EntryIndex].Next; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| @@ -2082,6 +2081,11 @@ struct StrC | ||||
| 	sw          Len; | ||||
| 	char const* Ptr; | ||||
|  | ||||
| 	char const& operator[]( sw index ) const | ||||
| 	{ | ||||
| 		return Ptr[index]; | ||||
| 	} | ||||
|  | ||||
| 	operator char const*() const | ||||
| 	{ | ||||
| 		return Ptr; | ||||
| @@ -2144,7 +2148,7 @@ struct String | ||||
|  | ||||
| 		for ( sw idx = 0; idx < num_parts; ++idx ) | ||||
| 		{ | ||||
| 			result.append( parts[ idx ] ); | ||||
| 			result.append( parts[idx] ); | ||||
|  | ||||
| 			if ( idx < num_parts - 1 ) | ||||
| 				result.append( glue ); | ||||
| @@ -2159,7 +2163,19 @@ struct String | ||||
| 			return false; | ||||
|  | ||||
| 		for ( sw idx = 0; idx < lhs.length(); ++idx ) | ||||
| 			if ( lhs[ idx ] != rhs[ idx ] ) | ||||
| 			if ( lhs[idx] != rhs[idx] ) | ||||
| 				return false; | ||||
|  | ||||
| 		return true; | ||||
| 	} | ||||
|  | ||||
| 	static bool are_equal( String lhs, StrC rhs ) | ||||
| 	{ | ||||
| 		if ( lhs.length() != (rhs.Len - 1) ) | ||||
| 			return false; | ||||
|  | ||||
| 		for ( sw idx = 0; idx < lhs.length(); ++idx ) | ||||
| 			if ( lhs[idx] != rhs[idx] ) | ||||
| 				return false; | ||||
|  | ||||
| 		return true; | ||||
| @@ -2190,9 +2206,9 @@ struct String | ||||
|  | ||||
| 			mem_copy( Data + curr_len, str, length ); | ||||
|  | ||||
| 			Data[ curr_len + length ] = '\0'; | ||||
| 			Data[curr_len + length] = '\0'; | ||||
|  | ||||
| 			header.Length             = curr_len + length; | ||||
| 			header.Length           = curr_len + length; | ||||
| 		} | ||||
| 		return str; | ||||
| 	} | ||||
| @@ -2218,7 +2234,7 @@ struct String | ||||
|  | ||||
| 	char& back() | ||||
| 	{ | ||||
| 		return Data[ length() - 1 ]; | ||||
| 		return Data[length() - 1]; | ||||
| 	} | ||||
|  | ||||
| 	sw capacity() const | ||||
| @@ -2233,6 +2249,24 @@ struct String | ||||
| 		get_header().Length = 0; | ||||
| 	} | ||||
|  | ||||
| 	b32 starts_with( StrC substring ) const | ||||
| 	{ | ||||
| 		if (substring.Len > length()) | ||||
| 			return false; | ||||
|  | ||||
| 		b32 result = str_compare(Data, substring.Ptr, substring.Len ) == 0; | ||||
| 		return result; | ||||
| 	} | ||||
|  | ||||
| 	b32 starts_with( String substring ) const | ||||
| 	{ | ||||
| 		if (substring.length() > length()) | ||||
| 			return false; | ||||
|  | ||||
| 		b32 result = str_compare(Data, substring, substring.length() - 1 ) == 0; | ||||
| 		return result; | ||||
| 	} | ||||
|  | ||||
| 	String duplicate( AllocatorInfo allocator ) const | ||||
| 	{ | ||||
| 		return make_length( allocator, Data, length() ); | ||||
| @@ -2250,7 +2284,7 @@ struct String | ||||
|  | ||||
| 	Header& get_header() | ||||
| 	{ | ||||
| 		return *( Header* )( Data - sizeof( Header ) ); | ||||
| 		return *(Header*)( Data - sizeof( Header ) ); | ||||
| 	} | ||||
|  | ||||
| 	sw length() const | ||||
| @@ -2298,7 +2332,7 @@ struct String | ||||
| 			read_pos++; | ||||
| 		} | ||||
|  | ||||
| 		write_pos[ 0 ] = '\0';    // Null-terminate the modified string | ||||
| 		write_pos[0] = '\0';    // Null-terminate the modified string | ||||
|  | ||||
| 		// Update the length if needed | ||||
| 		get_header().Length = write_pos - Data; | ||||
| @@ -2322,7 +2356,7 @@ struct String | ||||
| 		if ( Data != start_pos ) | ||||
| 			mem_move( Data, start_pos, len ); | ||||
|  | ||||
| 		Data[ len ]         = '\0'; | ||||
| 		Data[len]           = '\0'; | ||||
|  | ||||
| 		get_header().Length = len; | ||||
| 	} | ||||
| @@ -2335,7 +2369,7 @@ struct String | ||||
| 	// Debug function that provides a copy of the string with whitespace characters visualized. | ||||
| 	String visualize_whitespace() const | ||||
| 	{ | ||||
| 		Header* header = ( Header* )( Data - sizeof( Header ) ); | ||||
| 		Header* header = (Header*)( Data - sizeof( Header ) ); | ||||
|  | ||||
| 		String result  = make_reserve( header->Allocator, length() * 2 );    // Assume worst case for space requirements. | ||||
|  | ||||
| @@ -2420,12 +2454,12 @@ struct String | ||||
|  | ||||
| 	char& operator[]( sw index ) | ||||
| 	{ | ||||
| 		return Data[ index ]; | ||||
| 		return Data[index]; | ||||
| 	} | ||||
|  | ||||
| 	char const& operator[]( sw index ) const | ||||
| 	{ | ||||
| 		return Data[ index ]; | ||||
| 		return Data[index]; | ||||
| 	} | ||||
|  | ||||
| 	char* Data; | ||||
| @@ -2439,7 +2473,7 @@ struct String_POD | ||||
| static_assert( sizeof( String_POD ) == sizeof( String ), "String is not a POD" ); | ||||
|  | ||||
| // Implements basic string interning. Data structure is based off the ZPL Hashtable. | ||||
| using StringTable = HashTable< String const >; | ||||
| using StringTable = HashTable<String const>; | ||||
|  | ||||
| // Represents strings cached with the string table. | ||||
| // Should never be modified, if changed string is desired, cache_string( str ) another. | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -25,7 +25,7 @@ u8 adt_make_branch( ADT_Node* node, AllocatorInfo backing, char const* name, b32 | ||||
| 	node->type   = type; | ||||
| 	node->name   = name; | ||||
| 	node->parent = parent; | ||||
| 	node->nodes  = Array< ADT_Node >::init( backing ); | ||||
| 	node->nodes  = Array<ADT_Node>::init( backing ); | ||||
|  | ||||
| 	if ( ! node->nodes ) | ||||
| 		return EADT_ERROR_OUT_OF_MEMORY; | ||||
| @@ -70,7 +70,7 @@ ADT_Node* adt_find( ADT_Node* node, char const* name, b32 deep_search ) | ||||
|  | ||||
| 	for ( sw i = 0; i < node->nodes.num(); i++ ) | ||||
| 	{ | ||||
| 		if ( ! str_compare( node->nodes[ i ].name, name ) ) | ||||
| 		if ( ! str_compare( node->nodes[i].name, name ) ) | ||||
| 		{ | ||||
| 			return ( node->nodes + i ); | ||||
| 		} | ||||
| @@ -106,17 +106,17 @@ internal ADT_Node* _adt_get_value( ADT_Node* node, char const* value ) | ||||
| 		case EADT_TYPE_INTEGER : | ||||
| 		case EADT_TYPE_REAL : | ||||
| 		{ | ||||
| 			char     back[ 4096 ] = { 0 }; | ||||
| 			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 ); | ||||
| 			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 ) ) | ||||
| 			if ( ! str_compare( (char const*)buf, value ) ) | ||||
| 			{ | ||||
| 				file_close( &tmp ); | ||||
| 				return node; | ||||
| @@ -136,9 +136,9 @@ internal ADT_Node* _adt_get_field( ADT_Node* node, char* name, char* value ) | ||||
| { | ||||
| 	for ( sw i = 0; i < node->nodes.num(); i++ ) | ||||
| 	{ | ||||
| 		if ( ! str_compare( node->nodes[ i ].name, name ) ) | ||||
| 		if ( ! 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 ) ) | ||||
| 			{ | ||||
| 				return node; /* this object does contain a field of a specified value! */ | ||||
| @@ -172,19 +172,19 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri ) | ||||
| 	str_fmt_out( "uri: %s\n", uri ); | ||||
| #endif | ||||
|  | ||||
| 	char *    p = ( char* )uri, *b = p, *e = p; | ||||
| 	char *    p = (char*)uri, *b = p, *e = p; | ||||
| 	ADT_Node* found_node = NULL; | ||||
|  | ||||
| 	b                    = p; | ||||
| 	p = e     = ( char* )str_skip( p, '/' ); | ||||
| 	char* buf = str_fmt_buf( "%.*s", ( int )( e - b ), b ); | ||||
| 	p = e     = (char*)str_skip( p, '/' ); | ||||
| 	char* buf = str_fmt_buf( "%.*s", (int)( e - b ), b ); | ||||
|  | ||||
| 	/* handle field value lookup */ | ||||
| 	if ( *b == '[' ) | ||||
| 	{ | ||||
| 		char *l_p = buf + 1, *l_b = l_p, *l_e = l_p, *l_b2 = l_p, *l_e2 = l_p; | ||||
| 		l_e  = ( char* )str_skip( l_p, '=' ); | ||||
| 		l_e2 = ( char* )str_skip( l_p, ']' ); | ||||
| 		l_e  = (char*)str_skip( l_p, '=' ); | ||||
| 		l_e2 = (char*)str_skip( l_p, ']' ); | ||||
|  | ||||
| 		if ( ( ! *l_e && node->type != EADT_TYPE_ARRAY ) || ! *l_e2 ) | ||||
| 		{ | ||||
| @@ -211,7 +211,7 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri ) | ||||
| 			{ | ||||
| 				for ( sw i = 0; i < node->nodes.num(); i++ ) | ||||
| 				{ | ||||
| 					ADT_Node* child = &node->nodes[ i ]; | ||||
| 					ADT_Node* child = &node->nodes[i]; | ||||
| 					if ( child->type != EADT_TYPE_OBJECT ) | ||||
| 					{ | ||||
| 						continue; | ||||
| @@ -229,7 +229,7 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri ) | ||||
| 		{ | ||||
| 			for ( sw i = 0; i < node->nodes.num(); i++ ) | ||||
| 			{ | ||||
| 				ADT_Node* child = &node->nodes[ i ]; | ||||
| 				ADT_Node* child = &node->nodes[i]; | ||||
| 				if ( _adt_get_value( child, l_b2 ) ) | ||||
| 				{ | ||||
| 					found_node = child; | ||||
| @@ -258,10 +258,10 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri ) | ||||
| 	/* handle array index lookup */ | ||||
| 	else | ||||
| 	{ | ||||
| 		sw idx = ( sw )str_to_i64( buf, NULL, 10 ); | ||||
| 		sw idx = (sw)str_to_i64( buf, NULL, 10 ); | ||||
| 		if ( idx >= 0 && idx < node->nodes.num() ) | ||||
| 		{ | ||||
| 			found_node = &node->nodes[ idx ]; | ||||
| 			found_node = &node->nodes[idx]; | ||||
|  | ||||
| 			/* go deeper if uri continues */ | ||||
| 			if ( *e ) | ||||
| @@ -366,15 +366,15 @@ void adt_swap_nodes( ADT_Node* node, ADT_Node* other_node ) | ||||
| { | ||||
| 	GEN_ASSERT_NOT_NULL( node ); | ||||
| 	GEN_ASSERT_NOT_NULL( other_node ); | ||||
| 	ADT_Node* parent                     = node->parent; | ||||
| 	ADT_Node* other_parent               = other_node->parent; | ||||
| 	sw        index                      = ( pointer_diff( parent->nodes, node ) / size_of( ADT_Node ) ); | ||||
| 	sw        index2                     = ( pointer_diff( other_parent->nodes, other_node ) / size_of( ADT_Node ) ); | ||||
| 	ADT_Node  temp                       = parent->nodes[ index ]; | ||||
| 	temp.parent                          = other_parent; | ||||
| 	other_parent->nodes[ index2 ].parent = parent; | ||||
| 	parent->nodes[ index ]               = other_parent->nodes[ index2 ]; | ||||
| 	other_parent->nodes[ index2 ]        = temp; | ||||
| 	ADT_Node* parent                   = node->parent; | ||||
| 	ADT_Node* other_parent             = other_node->parent; | ||||
| 	sw        index                    = ( pointer_diff( parent->nodes, node ) / size_of( ADT_Node ) ); | ||||
| 	sw        index2                   = ( pointer_diff( other_parent->nodes, other_node ) / size_of( ADT_Node ) ); | ||||
| 	ADT_Node  temp                     = parent->nodes[index]; | ||||
| 	temp.parent                        = other_parent; | ||||
| 	other_parent->nodes[index2].parent = parent; | ||||
| 	parent->nodes[index]               = other_parent->nodes[index2]; | ||||
| 	other_parent->nodes[index2]        = temp; | ||||
| } | ||||
|  | ||||
| void adt_remove_node( ADT_Node* node ) | ||||
| @@ -483,28 +483,28 @@ char* adt_parse_number( ADT_Node* node, char* base_str ) | ||||
| 		return ++base_str; | ||||
| 	} | ||||
|  | ||||
| 	node_type      = EADT_TYPE_INTEGER; | ||||
| 	neg_zero       = false; | ||||
| 	node_type    = EADT_TYPE_INTEGER; | ||||
| 	neg_zero     = false; | ||||
|  | ||||
| 	sw   ib        = 0; | ||||
| 	char buf[ 48 ] = { 0 }; | ||||
| 	sw   ib      = 0; | ||||
| 	char buf[48] = { 0 }; | ||||
|  | ||||
| 	if ( *e == '+' ) | ||||
| 		++e; | ||||
| 	else if ( *e == '-' ) | ||||
| 	{ | ||||
| 		buf[ ib++ ] = *e++; | ||||
| 		buf[ib++] = *e++; | ||||
| 	} | ||||
|  | ||||
| 	if ( *e == '.' ) | ||||
| 	{ | ||||
| 		node_type   = EADT_TYPE_REAL; | ||||
| 		node_props  = EADT_PROPS_IS_PARSED_REAL; | ||||
| 		lead_digit  = false; | ||||
| 		buf[ ib++ ] = '0'; | ||||
| 		node_type  = EADT_TYPE_REAL; | ||||
| 		node_props = EADT_PROPS_IS_PARSED_REAL; | ||||
| 		lead_digit = false; | ||||
| 		buf[ib++]  = '0'; | ||||
| 		do | ||||
| 		{ | ||||
| 			buf[ ib++ ] = *e; | ||||
| 			buf[ib++] = *e; | ||||
| 		} while ( char_is_digit( *++e ) ); | ||||
| 	} | ||||
| 	else | ||||
| @@ -522,7 +522,7 @@ char* adt_parse_number( ADT_Node* node, char* base_str ) | ||||
|  | ||||
| 		while ( char_is_hex_digit( *e ) || char_to_lower( *e ) == 'x' ) | ||||
| 		{ | ||||
| 			buf[ ib++ ] = *e++; | ||||
| 			buf[ib++] = *e++; | ||||
| 		} | ||||
|  | ||||
| 		if ( *e == '.' ) | ||||
| @@ -533,13 +533,13 @@ char* adt_parse_number( ADT_Node* node, char* base_str ) | ||||
|  | ||||
| 			do | ||||
| 			{ | ||||
| 				buf[ ib++ ] = *e; | ||||
| 				buf[ib++] = *e; | ||||
| 				++step; | ||||
| 			} while ( char_is_digit( *++e ) ); | ||||
|  | ||||
| 			if ( step < 2 ) | ||||
| 			{ | ||||
| 				buf[ ib++ ] = '0'; | ||||
| 				buf[ib++] = '0'; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| @@ -550,9 +550,9 @@ char* adt_parse_number( ADT_Node* node, char* base_str ) | ||||
| 		return ++base_str; | ||||
| 	} | ||||
|  | ||||
| 	f32  eb          = 10; | ||||
| 	char expbuf[ 6 ] = { 0 }; | ||||
| 	sw   expi        = 0; | ||||
| 	f32  eb        = 10; | ||||
| 	char expbuf[6] = { 0 }; | ||||
| 	sw   expi      = 0; | ||||
|  | ||||
| 	if ( *e && ! ! str_find( "eE", *e ) ) | ||||
| 	{ | ||||
| @@ -569,11 +569,11 @@ char* adt_parse_number( ADT_Node* node, char* base_str ) | ||||
| 			} | ||||
| 			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)str_to_i64( expbuf, NULL, 10 ); | ||||
| 	} | ||||
|  | ||||
| 	if ( node_type == EADT_TYPE_INTEGER ) | ||||
| @@ -581,14 +581,14 @@ char* adt_parse_number( ADT_Node* node, char* base_str ) | ||||
| 		node->integer = str_to_i64( buf, 0, 0 ); | ||||
| #ifndef GEN_PARSER_DISABLE_ANALYSIS | ||||
| 		/* special case: negative zero */ | ||||
| 		if ( node->integer == 0 && buf[ 0 ] == '-' ) | ||||
| 		if ( node->integer == 0 && buf[0] == '-' ) | ||||
| 		{ | ||||
| 			neg_zero = true; | ||||
| 		} | ||||
| #endif | ||||
| 		while ( orig_exp-- > 0 ) | ||||
| 		{ | ||||
| 			node->integer *= ( s64 )eb; | ||||
| 			node->integer *= (s64)eb; | ||||
| 		} | ||||
| 	} | ||||
| 	else | ||||
| @@ -604,8 +604,8 @@ char* adt_parse_number( ADT_Node* node, char* base_str ) | ||||
| 		while ( *base_string_off++ == '0' ) | ||||
| 			base2_offset++; | ||||
|  | ||||
| 		base  = ( s32 )str_to_i64( q, 0, 0 ); | ||||
| 		base2 = ( s32 )str_to_i64( base_string2, 0, 0 ); | ||||
| 		base  = (s32)str_to_i64( q, 0, 0 ); | ||||
| 		base2 = (s32)str_to_i64( base_string2, 0, 0 ); | ||||
| 		if ( exp ) | ||||
| 		{ | ||||
| 			exp        = exp * ( ! ( eb == 10.0f ) ? -1 : 1 ); | ||||
| @@ -613,7 +613,7 @@ char* adt_parse_number( ADT_Node* node, char* base_str ) | ||||
| 		} | ||||
|  | ||||
| 		/* special case: negative zero */ | ||||
| 		if ( base == 0 && buf[ 0 ] == '-' ) | ||||
| 		if ( base == 0 && buf[0] == '-' ) | ||||
| 		{ | ||||
| 			neg_zero = true; | ||||
| 		} | ||||
| @@ -667,11 +667,11 @@ ADT_Error adt_print_number( FileInfo* file, ADT_Node* node ) | ||||
| 		{ | ||||
| 			if ( node->props == EADT_PROPS_IS_HEX ) | ||||
| 			{ | ||||
| 				_adt_fprintf( file, "0x%llx", ( long long )node->integer ); | ||||
| 				_adt_fprintf( file, "0x%llx", (long long)node->integer ); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				_adt_fprintf( file, "%lld", ( long long )node->integer ); | ||||
| 				_adt_fprintf( file, "%lld", (long long)node->integer ); | ||||
| 			} | ||||
| 		} | ||||
| 		break; | ||||
| @@ -709,14 +709,14 @@ ADT_Error adt_print_number( FileInfo* file, ADT_Node* node ) | ||||
| 			} | ||||
| 			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 ) | ||||
| 			{ | ||||
| 				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 | ||||
| 					_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 | ||||
| 			} | ||||
| 			else | ||||
| @@ -772,7 +772,7 @@ ADT_Error adt_str_to_number( ADT_Node* node ) | ||||
| 		return EADT_ERROR_INVALID_TYPE; | ||||
| 	} | ||||
|  | ||||
| 	adt_parse_number( node, ( char* )node->string ); | ||||
| 	adt_parse_number( node, (char*)node->string ); | ||||
|  | ||||
| 	return EADT_ERROR_NONE; | ||||
| } | ||||
| @@ -788,7 +788,7 @@ ADT_Error adt_str_to_number_strict( ADT_Node* node ) | ||||
| 		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; | ||||
| } | ||||
| @@ -922,7 +922,7 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b | ||||
| 			char* num_p       = beginChar; | ||||
|  | ||||
| 			// We only consider hexadecimal values if they start with 0x | ||||
| 			if ( str_len( num_p ) > 2 && num_p[ 0 ] == '0' && ( num_p[ 1 ] == 'x' || num_p[ 1 ] == 'X' ) ) | ||||
| 			if ( str_len( num_p ) > 2 && num_p[0] == '0' && ( num_p[1] == 'x' || num_p[1] == 'X' ) ) | ||||
| 			{ | ||||
| 				num_p += 2;    // skip '0x' prefix | ||||
| 				do | ||||
| @@ -950,7 +950,7 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b | ||||
| 			adt_append_arr( root, NULL ); | ||||
| 		} | ||||
|  | ||||
| 		root->nodes[ columnIndex ].nodes.append( rowItem ); | ||||
| 		root->nodes[columnIndex].nodes.append( rowItem ); | ||||
|  | ||||
| 		if ( delimiter == delim ) | ||||
| 		{ | ||||
| @@ -1059,17 +1059,17 @@ void csv_write_delimiter( FileInfo* file, CSV_Object* obj, char delimiter ) | ||||
| 	if ( cols == 0 ) | ||||
| 		return; | ||||
|  | ||||
| 	sw rows = obj->nodes[ 0 ].nodes.num(); | ||||
| 	sw rows = obj->nodes[0].nodes.num(); | ||||
| 	if ( rows == 0 ) | ||||
| 		return; | ||||
|  | ||||
| 	b32 has_headers = obj->nodes[ 0 ].name != NULL; | ||||
| 	b32 has_headers = obj->nodes[0].name != NULL; | ||||
|  | ||||
| 	if ( has_headers ) | ||||
| 	{ | ||||
| 		for ( sw i = 0; i < cols; i++ ) | ||||
| 		{ | ||||
| 			_csv_write_header( file, &obj->nodes[ i ] ); | ||||
| 			_csv_write_header( file, &obj->nodes[i] ); | ||||
| 			if ( i + 1 != cols ) | ||||
| 			{ | ||||
| 				str_fmt_file( file, "%c", delimiter ); | ||||
| @@ -1082,7 +1082,7 @@ void csv_write_delimiter( FileInfo* file, CSV_Object* obj, char delimiter ) | ||||
| 	{ | ||||
| 		for ( sw 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 ) | ||||
| 			{ | ||||
| 				str_fmt_file( file, "%c", delimiter ); | ||||
| @@ -1099,7 +1099,7 @@ String csv_write_string_delimiter( AllocatorInfo a, CSV_Object* obj, char delimi | ||||
| 	csv_write_delimiter( &tmp, obj, delimiter ); | ||||
| 	sw     fsize; | ||||
| 	u8*    buf    = file_stream_buf( &tmp, &fsize ); | ||||
| 	String output = String::make_length( a, ( char* )buf, fsize ); | ||||
| 	String output = String::make_length( a, (char*)buf, fsize ); | ||||
| 	file_close( &tmp ); | ||||
| 	return output; | ||||
| } | ||||
|   | ||||
| @@ -86,8 +86,8 @@ struct ADT_Node | ||||
| 	/* adt data */ | ||||
| 	union | ||||
| 	{ | ||||
| 		char const*       string; | ||||
| 		Array< ADT_Node > nodes;    ///< zpl_array | ||||
| 		char const*     string; | ||||
| 		Array<ADT_Node> nodes;    ///< zpl_array | ||||
|  | ||||
| 		struct | ||||
| 		{ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user