mirror of
				https://github.com/Ed94/gencpp.git
				synced 2025-10-30 14:30:53 -07:00 
			
		
		
		
	Compare commits
	
		
			53 Commits
		
	
	
		
			v0.9-Alpha
			...
			v0.16-Alph
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 9bd6dac783 | |||
| 212d907d73 | |||
| c1ab233686 | |||
| b42b224c0d | |||
| 041671762b | |||
| d0f3b6187e | |||
| b22f589203 | |||
| 4af85f8612 | |||
| e9c151f85d | |||
| a900e86b65 | |||
| d5a4b77033 | |||
| eaba60f80b | |||
| 912cc6b538 | |||
| 3dd5482a46 | |||
| 632fa10027 | |||
| 6498b13658 | |||
| 7f562cd77f | |||
| 3a0e971ebf | |||
| 4997cb5878 | |||
| 729c891cbd | |||
| 754bcfb31e | |||
| a8708abf8b | |||
| 4b48b96a79 | |||
| 9495fc2985 | |||
| 378de73a7d | |||
| 35ac0c1048 | |||
| 2c893d5e35 | |||
| 6ea40094ee | |||
| 0a8d3bfc6a | |||
| 212b4e6d16 | |||
| d606c790ca | |||
| 2bfbef1d0c | |||
| f1fb75cc1c | |||
| 2200bcde9a | |||
| 3e249d9bc5 | |||
| 3868e1e811 | |||
| 543427dfe5 | |||
| f2d4ec96f0 | |||
| 1076818250 | |||
| c4c308c8ba | |||
| a4d9a63d71 | |||
| 0197afd543 | |||
| 7249a7317d | |||
| abf51e4aa9 | |||
| 9b6dc3cbd8 | |||
| 9edcbad907 | |||
| a6766cf0b1 | |||
| 8635b0fd1b | |||
| 30eec99628 | |||
| f9117a2353 | |||
| c81f4b34ee | |||
| c97762ac16 | |||
| 5e79e8ba65 | 
							
								
								
									
										28
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										28
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -16,19 +16,15 @@ | |||||||
| gencpp.hpp | gencpp.hpp | ||||||
| gencpp.cpp | gencpp.cpp | ||||||
|  |  | ||||||
| # Build results | **/*.lib | ||||||
| [Dd]ebug/ | **/*.pdb | ||||||
| [Dd]ebugPublic/ | **/*.exe | ||||||
| [Rr]elease/ | **/*.dll | ||||||
| [Rr]eleases/ |  | ||||||
| x64/ | release/** | ||||||
| x86/ |  | ||||||
| [Ww][Ii][Nn]32/ | # Unreal | ||||||
| [Aa][Rr][Mm]/ | **/Unreal/*.h | ||||||
| [Aa][Rr][Mm]64/ | **/Unreal/*.cpp | ||||||
| bld/ | ! **/Unreal/validate.unreal.cpp | ||||||
| [Bb]in/ | project/auxillary/vis_ast/dependencies/temp | ||||||
| [Oo]bj/ |  | ||||||
| [Ll]og/ |  | ||||||
| [Ll]ogs/ |  | ||||||
| vc140.pdb |  | ||||||
|   | |||||||
							
								
								
									
										8
									
								
								.vscode/c_cpp_properties.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								.vscode/c_cpp_properties.json
									
									
									
									
										vendored
									
									
								
							| @@ -10,8 +10,10 @@ | |||||||
|                 "UNICODE", |                 "UNICODE", | ||||||
|                 "_UNICODE", |                 "_UNICODE", | ||||||
|                 "GEN_TIME", |                 "GEN_TIME", | ||||||
|                 "GEN_IMPLEMENTATION" |                 "GEN_IMPLEMENTATION", | ||||||
|                 // "GEN_DONT_USE_NAMESPACE" |                 // "GEN_DONT_USE_NAMESPACE" | ||||||
|  |                 "GEN_INTELLISENSE_DIRECTIVES", | ||||||
|  |                 "INTELLISENSE_DIRECTIVES" | ||||||
|             ], |             ], | ||||||
|             "windowsSdkVersion": "10.0.19041.0", |             "windowsSdkVersion": "10.0.19041.0", | ||||||
|             "compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/cl.exe", |             "compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/cl.exe", | ||||||
| @@ -28,8 +30,10 @@ | |||||||
|                 "UNICODE", |                 "UNICODE", | ||||||
|                 "_UNICODE", |                 "_UNICODE", | ||||||
|                 "GEN_TIME", |                 "GEN_TIME", | ||||||
|                 "GEN_IMPLEMENTATION" |                 "GEN_IMPLEMENTATION", | ||||||
|                 // "GEN_DONT_USE_NAMESPACE" |                 // "GEN_DONT_USE_NAMESPACE" | ||||||
|  |                 "GEN_INTELLISENSE_DIRECTIVES", | ||||||
|  |                 "INTELLISENSE_DIRECTIVES" | ||||||
|             ], |             ], | ||||||
|             "windowsSdkVersion": "10.0.19041.0", |             "windowsSdkVersion": "10.0.19041.0", | ||||||
|             "compilerPath": "C:/Users/Ed/scoop/apps/llvm/current/bin/clang++.exe", |             "compilerPath": "C:/Users/Ed/scoop/apps/llvm/current/bin/clang++.exe", | ||||||
|   | |||||||
							
								
								
									
										9
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							| @@ -40,6 +40,15 @@ | |||||||
| 			"args": [], | 			"args": [], | ||||||
| 			"cwd": "${workspaceFolder}/singleheader/", | 			"cwd": "${workspaceFolder}/singleheader/", | ||||||
| 			"visualizerFile": "${workspaceFolder}/scripts/gencpp.natvis" | 			"visualizerFile": "${workspaceFolder}/scripts/gencpp.natvis" | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			"type": "cppvsdbg", | ||||||
|  | 			"request": "launch", | ||||||
|  | 			"name": "Debug raylib refactor vsdbg", | ||||||
|  | 			"program": "${workspaceFolder}/project/auxillary/vis_ast/dependencies/raylib/build/raylib_refactor.exe", | ||||||
|  | 			"args": [], | ||||||
|  | 			"cwd": "${workspaceFolder}/project/auxillary/vis_ast/dependencies/temp/raylib-master/src/", | ||||||
|  | 			"visualizerFile": "${workspaceFolder}/scripts/gencpp.natvis" | ||||||
| 		} | 		} | ||||||
| 	] | 	] | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										8
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
								
							| @@ -24,7 +24,13 @@ | |||||||
| 		"filesystem": "cpp", | 		"filesystem": "cpp", | ||||||
| 		"format": "cpp", | 		"format": "cpp", | ||||||
| 		"ratio": "cpp", | 		"ratio": "cpp", | ||||||
| 		"xstring": "cpp" | 		"xstring": "cpp", | ||||||
|  | 		"functional": "cpp", | ||||||
|  | 		"vector": "cpp", | ||||||
|  | 		"list": "cpp", | ||||||
|  | 		"xhash": "cpp", | ||||||
|  | 		"glfw3.h": "c", | ||||||
|  | 		"stdbool.h": "c" | ||||||
| 	}, | 	}, | ||||||
| 	"C_Cpp.intelliSenseEngineFallback": "disabled", | 	"C_Cpp.intelliSenseEngineFallback": "disabled", | ||||||
| 	"mesonbuild.configureOnOpen": true, | 	"mesonbuild.configureOnOpen": true, | ||||||
|   | |||||||
							
								
								
									
										15
									
								
								Readme.md
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								Readme.md
									
									
									
									
									
								
							| @@ -5,14 +5,19 @@ An attempt at simple staged metaprogramming for c/c++. | |||||||
| The library API is a composition of code element constructors.   | The library API is a composition of code element constructors.   | ||||||
| These build up a code AST to then serialize with a file builder. | These build up a code AST to then serialize with a file builder. | ||||||
|  |  | ||||||
| This code base attempts follow the [handmade philosophy](https://handmade.network/manifesto),   | This code base attempts follow the [handmade philosophy](https://handmade.network/manifesto).   | ||||||
| its not meant to be a black box metaprogramming utility, it should be easy to intergrate into a user's project domain. | Its not meant to be a black box metaprogramming utility, it should be easy to intergrate into a user's project domain.   | ||||||
|  |  | ||||||
| ## Notes | ## Notes | ||||||
|  |  | ||||||
| The project has reached an *alpha* state, all the current functionality works for the test cases but it will most likely break in many other cases.   | **On Partial Hiatus: Working on handmade hero for now. Only fixes will be pushed as I come across them until I get what I want done from the series** | ||||||
|  |  | ||||||
| A `natvis` and `natstepfilter` are provided in the scripts directory. | This project is still in development (very much an alpha state), so expect bugs and missing features.   | ||||||
|  | See [issues](https://github.com/Ed94/gencpp/issues) for a list of known bugs or todos. | ||||||
|  |  | ||||||
|  | The library can already be used to generate code just fine, but the parser is where the most work is needed. If your C++ isn't "down to earth" expect issues. | ||||||
|  |  | ||||||
|  | A `natvis` and `natstepfilter` are provided in the scripts directory (its outdated, I'll update this readme when its not). | ||||||
|  |  | ||||||
| ***The editor and scanner have not been implemented yet. The scanner will come first, then the editor.*** | ***The editor and scanner have not been implemented yet. The scanner will come first, then the editor.*** | ||||||
|  |  | ||||||
| @@ -123,7 +128,7 @@ struct ArrayHeader | |||||||
| ``` | ``` | ||||||
|  |  | ||||||
| **Note: The formatting shown here is not how it will look. For your desired formatting its recommended to run a pass through the files with an auto-formatter.** | **Note: The formatting shown here is not how it will look. For your desired formatting its recommended to run a pass through the files with an auto-formatter.** | ||||||
| *(The library currently uses clang-format for formatting, beaware its pretty slow...)* | *(The library currently uses clang-format for formatting, beware its pretty slow...)* | ||||||
|  |  | ||||||
| ## Building | ## Building | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										37
									
								
								docs/AST_Design.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								docs/AST_Design.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | |||||||
|  | # Forward | ||||||
|  |  | ||||||
|  | Was never satisfied with how I did the wrap of the management of the AST.   | ||||||
|  | For C++, the current design may be as good as it gets for the limitations of the langauge. | ||||||
|  |  | ||||||
|  | I'll at least try in this issue to brainstorm something simpiler without losing ergonomics.   | ||||||
|  | This will also be a good place to document the current design. | ||||||
|  |  | ||||||
|  | ## Current Design | ||||||
|  |  | ||||||
|  | `AST` is the actual managed node object for the library.   | ||||||
|  | Its raw and really not meant to be used directly. | ||||||
|  |  | ||||||
|  | All user interaction must be with its pointer so the type they deal with is `AST*`.   | ||||||
|  | For user-facing code, they should never be giveen a nullptr. Instead, they should be given a designated `Invalid` AST node. | ||||||
|  |  | ||||||
|  | In order to abstract away constant use of `AST*`, I wanted to provide a wrapper for it. | ||||||
|  |  | ||||||
|  | The simpliest being just a type alias. | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | using Code = AST*; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | This is what the genc library would have to use due to its constraints of a langauge. | ||||||
|  | Anything else and it would either be an unergonomic mess of struct wrapping with a mess of macros & procedures to interface with it. | ||||||
|  |  | ||||||
|  | Further, to provide intuitive filters on the AST, there are AST types (covered in [AST_Types.md](AST_Types.md)). | ||||||
|  |  | ||||||
|  | These are pure PODS that just have the lay members relevant to the type of AST node they represent.   | ||||||
|  | Each of them has a Code type alias specific to it. | ||||||
|  |  | ||||||
|  | Again, the simpliest case for these would be a type alias. | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | using struct AST_Typedef CodeTypedef; | ||||||
|  | ``` | ||||||
							
								
								
									
										688
									
								
								docs/AST_Types.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										688
									
								
								docs/AST_Types.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,688 @@ | |||||||
|  | # AST Types Documentation | ||||||
|  |  | ||||||
|  | While the Readme for docs covers the data layout per AST, this will focus on the AST types avaialble, and their nuances. | ||||||
|  |  | ||||||
|  | ## Body | ||||||
|  |  | ||||||
|  | These are containers representing a scope body of a definition that can be of the following `ECode` type: | ||||||
|  |  | ||||||
|  | * Class_Body | ||||||
|  | * Enum_Body | ||||||
|  | * Export_Body | ||||||
|  | * Extern_Linkage_Body | ||||||
|  | * Function_Body | ||||||
|  | * Global_Body | ||||||
|  | * Namespace_Body | ||||||
|  | * Struct_Body | ||||||
|  | * Union_Body | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | Code         Front; | ||||||
|  | Code         Back; | ||||||
|  | Code         Parent; | ||||||
|  | StringCached Name; | ||||||
|  | CodeT        Type; | ||||||
|  | s32          NumEntries; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | The `Front` member represents the start of the link list and `Back` the end. | ||||||
|  | NumEntries is the number of entries in the body. | ||||||
|  |  | ||||||
|  | Parent should have a compatible ECode type for the type of defintion used. | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | Will output only the entries, the braces are handled by the parent. | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | <Front>... | ||||||
|  | <Back> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Attributes | ||||||
|  |  | ||||||
|  | Represent standard or vendor specific C/C++ attributes. | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | StringCached  Content; | ||||||
|  | Code          Prev; | ||||||
|  | Code          Next; | ||||||
|  | Code          Parent; | ||||||
|  | StringCached  Name; | ||||||
|  | CodeT         Type; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | <Content> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | While the parser supports the `__declspec` and `__attribute__` syntax, the upfront constructor ( def_attributes ) must have the user specify the entire attribute, including the `[[]]`, `__declspec` or `__attribute__` parts. | ||||||
|  |  | ||||||
|  | ## Comment | ||||||
|  |  | ||||||
|  | Stores a comment. | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | StringCached  Content; | ||||||
|  | Code          Prev; | ||||||
|  | Code          Next; | ||||||
|  | Code          Parent; | ||||||
|  | StringCached  Name; | ||||||
|  | CodeT         Type; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | <Content> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | The parser will perserve comments found if residing with a body or in accepted inline-to-definition locations. | ||||||
|  | Otherwise they will be skipped by the TokArray::__eat and TokArray::current( skip foramtting enabled ) functions. | ||||||
|  |  | ||||||
|  | The upfront constructor: `def_comment` expects to recieve a comment without the `//` or `/* */` parts. It will add them during construction. | ||||||
|  |  | ||||||
|  | ## Class & Struct | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | CodeComment    InlineCmt;  // Only supported by forward declarations | ||||||
|  | CodeAttributes Attributes; | ||||||
|  | CodeType       ParentType; | ||||||
|  | CodeBody       Body; | ||||||
|  | CodeType       Prev;       // Used to store references to interfaces | ||||||
|  | CodeType       Next;       // Used to store references to interfaces | ||||||
|  | Code           Parent; | ||||||
|  | StringCached   Name; | ||||||
|  | CodeT          Type; | ||||||
|  | ModuleFlag     ModuleFlags; | ||||||
|  | AccessSpec     ParentAccess; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | // Class_Fwd | ||||||
|  | <ModuleFlags> <class/struct> <Name>; <InlineCmt> | ||||||
|  |  | ||||||
|  | // Class | ||||||
|  | <ModuleFlags> <class/struct> <Attributes> <Name> : <ParentAccess> <ParentType>, public <ParentType->Next>, ... <InlineCmt> | ||||||
|  | { | ||||||
|  |     <Body> | ||||||
|  | }; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | You'll notice that only one parent type is supported only with parent access. This library only supports single inheritance, the rest must be done through interfaces. | ||||||
|  |  | ||||||
|  | ## Constructor | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | CodeComment InlineCmt;  // Only supported by forward declarations | ||||||
|  | Code        InitializerList; | ||||||
|  | CodeParam   Params; | ||||||
|  | Code        Body; | ||||||
|  | Code        Prev; | ||||||
|  | Code        Next; | ||||||
|  | Code        Parent; | ||||||
|  | CodeT       Type; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | // Constructor_Fwd | ||||||
|  | <Specs> <Parent->Name>( <Params> ); <InlineCmt> | ||||||
|  |  | ||||||
|  | // Constructor | ||||||
|  | <Specs> <Parent->Name>( <Params> ) <InlineCmt> | ||||||
|  |     : <InitializerList> | ||||||
|  | { | ||||||
|  |     <Body> | ||||||
|  | } | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Define | ||||||
|  |  | ||||||
|  | Represents a preprocessor define | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | StringCached  Content; | ||||||
|  | Code          Prev; | ||||||
|  | Code          Next; | ||||||
|  | Code          Parent; | ||||||
|  | StringCached  Name; | ||||||
|  | CodeT         Type; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | #define <Name> <Content> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Destructor | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | CodeComment    InlineCmt; | ||||||
|  | CodeSpecifiers Specs; | ||||||
|  | Code           Body; | ||||||
|  | Code           Prev; | ||||||
|  | Code           Next; | ||||||
|  | Code           Parent; | ||||||
|  | CodeT          Type; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | // Destructor_Fwd | ||||||
|  | <Specs> ~<Parent->Name>( <Params> ) <Specs>; <InlineCmt> | ||||||
|  |  | ||||||
|  | // Destructor | ||||||
|  | <Specs> ~<Parent->Name>( <Params> ) <Specs> | ||||||
|  | { | ||||||
|  |     <Body> | ||||||
|  | } | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Enum | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | CodeComment    InlineCmt; | ||||||
|  | CodeAttributes Attributes; | ||||||
|  | CodeType       UnderlyingType; | ||||||
|  | CodeBody       Body; | ||||||
|  | Code           Prev; | ||||||
|  | Code           Next; | ||||||
|  | Code           Parent; | ||||||
|  | StringCached   Name; | ||||||
|  | CodeT          Type; | ||||||
|  | ModuleFlag     ModuleFlags; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | // Enum_Fwd | ||||||
|  | <ModuleFlags> enum class <Name> : <UnderlyingType>; <InlineCmt> | ||||||
|  |  | ||||||
|  | // Enum | ||||||
|  | <ModuleFlags> <enum or enum class> <Name> : <UnderlyingType> | ||||||
|  | { | ||||||
|  |     <Body> | ||||||
|  | }; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Execution | ||||||
|  |  | ||||||
|  | Just represents an execution body. Equivalent to an untyped body. | ||||||
|  | Will be obsolute when function body parsing is implemented. | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | StringCached Content; | ||||||
|  | Code         Prev; | ||||||
|  | Code         Next; | ||||||
|  | Code         Parent; | ||||||
|  | StringCached Name; | ||||||
|  | CodeT        Type; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | <Content> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## External Linkage | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | CodeBody     Body; | ||||||
|  | Code         Prev; | ||||||
|  | Code         Next; | ||||||
|  | Code         Parent; | ||||||
|  | StringCached Name; | ||||||
|  | CodeT        Type; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | extern "<Name>" | ||||||
|  | { | ||||||
|  |     <Body> | ||||||
|  | } | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Include | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | StringCached Content; | ||||||
|  | Code         Prev; | ||||||
|  | Code         Next; | ||||||
|  | Code         Parent; | ||||||
|  | StringCached Name; | ||||||
|  | CodeT        Type; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | #include <Content> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Friend | ||||||
|  |  | ||||||
|  | This library (until its necessary become some third-party library to do otherwise) does not support friend declarations with in-statment function definitions. | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | CodeComment  InlineCmt; | ||||||
|  | Code         Declaration; | ||||||
|  | Code         Prev; | ||||||
|  | Code         Next; | ||||||
|  | Code         Parent; | ||||||
|  | StringCached Name; | ||||||
|  | CodeT        Type; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | friend <Declaration>; <InlineCmt> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Function | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | CodeComment    InlineCmt; | ||||||
|  | CodeAttributes Attributes; | ||||||
|  | CodeSpecifiers Specs; | ||||||
|  | CodeType       ReturnType; | ||||||
|  | CodeParam      Params; | ||||||
|  | CodeBody       Body; | ||||||
|  | Code           Prev; | ||||||
|  | Code           Parent; | ||||||
|  | Code           Next; | ||||||
|  | StringCached   Name; | ||||||
|  | CodeT          Type; | ||||||
|  | ModuleFlag     ModuleFlags; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | // Function_Fwd | ||||||
|  | <ModuleFlags> <Attributes> <Specs> <ReturnType> <Name>( <Params> ) <Specs>; <InlineCmt> | ||||||
|  |  | ||||||
|  | // Function | ||||||
|  | <ModuleFlags> <Attributes> <Specs> <ReturnType> <Name>( <Params> ) <Specs> | ||||||
|  | { | ||||||
|  |     <Body> | ||||||
|  | } | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Module | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | Code         Prev; | ||||||
|  | Code         Next; | ||||||
|  | Code         Parent; | ||||||
|  | StringCached Name; | ||||||
|  | CodeT        Type; | ||||||
|  | ModuleFlag   ModuleFlags; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | <ModuleFlags> module <Name>; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Namespace | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | CodeBody     Body; | ||||||
|  | Code         Prev; | ||||||
|  | Code         Next; | ||||||
|  | Code         Parent; | ||||||
|  | StringCached Name; | ||||||
|  | CodeT        Type; | ||||||
|  | ModuleFlag   ModuleFlags; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | <ModuleFlags> namespace <Name> | ||||||
|  | { | ||||||
|  |     <Body> | ||||||
|  | } | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Operator Overload | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | CodeComment    InlineCmt; | ||||||
|  | CodeAttributes Attributes; | ||||||
|  | CodeSpecifiers Specs; | ||||||
|  | CodeType       ReturnType; | ||||||
|  | CodeParam      Params; | ||||||
|  | CodeBody       Body; | ||||||
|  | Code           Prev; | ||||||
|  | Code           Next; | ||||||
|  | Code           Parent; | ||||||
|  | StringCached   Name; | ||||||
|  | CodeT          Type; | ||||||
|  | ModuleFlag     ModuleFlags; | ||||||
|  | OperatorT      Op; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | // Operator_Fwd | ||||||
|  | <ModuleFlags> <Attributes> <Specs> <ReturnType> operator <Op>( <Params> ) <Specs>; <InlineCmt> | ||||||
|  |  | ||||||
|  | // Operator | ||||||
|  | <ModuleFlags> <Attributes> <Specs> <ReturnType> <Name>operator <Op>( <Params> ) <Specs> | ||||||
|  | { | ||||||
|  |     <Body> | ||||||
|  | } | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Operator Cast Overload ( User-Defined Type Conversion ) | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | CodeComment    InlineCmt; | ||||||
|  | CodeSpecifiers Specs; | ||||||
|  | CodeType       ValueType; | ||||||
|  | CodeBody       Body; | ||||||
|  | Code           Prev; | ||||||
|  | Code           Next; | ||||||
|  | Code           Parent; | ||||||
|  | StringCached   Name; | ||||||
|  | CodeT          Type; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | // Operator_Cast_Fwd | ||||||
|  | <Specs> operator <ValueType>() <Specs>; <InlineCmt> | ||||||
|  |  | ||||||
|  | // Operator_Cast | ||||||
|  | <Specs> <Name>operator <ValueType>() <Specs> | ||||||
|  | { | ||||||
|  |     <Body> | ||||||
|  | } | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Parameters | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | CodeType     ValueType; | ||||||
|  | Code         Value; | ||||||
|  | CodeParam    Last; | ||||||
|  | CodeParam    Next; | ||||||
|  | Code         Parent; | ||||||
|  | StringCached Name; | ||||||
|  | CodeT        Type; | ||||||
|  | s32          NumEntries; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | <ValueType> <Name>, <Next>... <Last> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Pragma | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | StringCached Content; | ||||||
|  | Code         Prev; | ||||||
|  | Code         Next; | ||||||
|  | Code         Parent; | ||||||
|  | StringCached Name; | ||||||
|  | CodeT        Type; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | #pragma <Content> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Preprocessor Conditional | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | StringCached Content; | ||||||
|  | Code         Prev; | ||||||
|  | Code         Next; | ||||||
|  | Code         Parent; | ||||||
|  | StringCached Name; | ||||||
|  | CodeT        Type; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | #<based off Type> <Content> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Specifiers | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | SpecifierT        ArrSpecs[ AST::ArrSpecs_Cap ]; | ||||||
|  | Code              Prev; | ||||||
|  | Code              Next; | ||||||
|  | Code              Parent; | ||||||
|  | StringCached      Name; | ||||||
|  | CodeT             Type; | ||||||
|  | s32               NumEntries; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | <Spec>, ... | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Template | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | CodeParam    Params; | ||||||
|  | Code         Declaration; | ||||||
|  | Code         Prev; | ||||||
|  | Code         Next; | ||||||
|  | Code         Parent; | ||||||
|  | StringCached Name; | ||||||
|  | CodeT        Type; | ||||||
|  | ModuleFlag   ModuleFlags; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | <ModuleFlags> | ||||||
|  | template< <Params> > | ||||||
|  | <Declaration> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Typename | ||||||
|  |  | ||||||
|  | Typenames represent the type "symbol". | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | CodeAttributes Attributes; | ||||||
|  | CodeSpecifiers Specs; | ||||||
|  | CodeReturnType ReturnType; | ||||||
|  | CodeParam      Params; | ||||||
|  | Code           ArrExpr; | ||||||
|  | Code           Prev; | ||||||
|  | Code           Next; | ||||||
|  | Code           Parent; | ||||||
|  | StringCached   Name; | ||||||
|  | CodeT          Type; | ||||||
|  | b32            IsParamPack; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | <Attributes> <Name> <Specs> <IsParamPack ?: ...> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Typedef | ||||||
|  |  | ||||||
|  | Behave as usual except function or macro typedefs.   | ||||||
|  | Those don't use the underlying type field as everything was serialized under the Name field. | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | CodeComment  InlineCmt; | ||||||
|  | Code         UnderlyingType; | ||||||
|  | Code         Prev; | ||||||
|  | Code         Next; | ||||||
|  | Code         Parent; | ||||||
|  | StringCached Name; | ||||||
|  | CodeT        Type; | ||||||
|  | ModuleFlag   ModuleFlags; | ||||||
|  | b32          IsFunction; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | // Regular | ||||||
|  | <ModuleFlags> typedef <UnderlyingType> <Name>; <InlineCmt> | ||||||
|  |  | ||||||
|  | // Functions | ||||||
|  | <ModuleFlags> typedef <Name>; <InlineCmt> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Union | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | CodeAttributes Attributes; | ||||||
|  | CodeBody       Body; | ||||||
|  | Code           Prev; | ||||||
|  | Code           Next; | ||||||
|  | Code           Parent; | ||||||
|  | StringCached   Name; | ||||||
|  | CodeT          Type; | ||||||
|  | ModuleFlag     ModuleFlags; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | <ModuleFlags> union <Attributes> <Name> | ||||||
|  | { | ||||||
|  |     <Body> | ||||||
|  | } | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Using | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | CodeComment    InlineCmt; | ||||||
|  | CodeAttributes Attributes; | ||||||
|  | CodeType       UnderlyingType; | ||||||
|  | Code           Prev; | ||||||
|  | Code           Next; | ||||||
|  | Code           Parent; | ||||||
|  | StringCached   Name; | ||||||
|  | CodeT          Type; | ||||||
|  | ModuleFlag     ModuleFlags; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | // Regular | ||||||
|  | <ModuleFlags> using <Attributes> <Name> = <UnderlyingType>; <InlineCmt> | ||||||
|  |  | ||||||
|  | // Namespace | ||||||
|  | <ModuleFlags> using namespace <Name>; <InlineCmt> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Variable | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | CodeComment    InlineCmt; | ||||||
|  | CodeAttributes Attributes; | ||||||
|  | CodeSpecifiers Specs; | ||||||
|  | CodeType       ValueType; | ||||||
|  | Code           BitfieldSize; | ||||||
|  | Code           Value; | ||||||
|  | Code           Prev; | ||||||
|  | Code           Next; | ||||||
|  | Code           Parent; | ||||||
|  | StringCached   Name; | ||||||
|  | CodeT          Type; | ||||||
|  | ModuleFlag     ModuleFlags; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Serialization: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | // Regular | ||||||
|  | <ModuleFlags> <Attributes> <Specs> <ValueType> <Name> = <Value>; <InlineCmt> | ||||||
|  |  | ||||||
|  | // Bitfield | ||||||
|  | <ModuleFlags> <Attributes> <Specs> <ValueType> <Name> : <BitfieldSize> = <Value>; <InlineCmt> | ||||||
|  | ``` | ||||||
							
								
								
									
										89
									
								
								docs/Parser_Algo.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								docs/Parser_Algo.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,89 @@ | |||||||
|  | # Parser's Algorithim | ||||||
|  |  | ||||||
|  | gencpp uses a hand-written recursive descent parser. Both the lexer and parser handle a full C/C++ file in a single pass. | ||||||
|  |  | ||||||
|  | ## Notable implementation background | ||||||
|  |  | ||||||
|  | ### Lexer | ||||||
|  |  | ||||||
|  | The lex procedure does the lexical pass of content provided as a `StrC` type. | ||||||
|  | The tokens are stored (for now) in `gen::Parser::Tokens`. | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  | ```cpp | ||||||
|  | Array<Token> Arr; | ||||||
|  | s32          Idx; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  |  | ||||||
|  | What token types are supported can be found in [ETokType.csv](../project/enums/ETokType.csv) you can also find the token types in [ETokType.h](../project/components/gen/etoktype.cpp) , which is the generated enum from the csv file. | ||||||
|  |  | ||||||
|  | Tokens are defined with the struct `gen::Parser::Token`: | ||||||
|  |  | ||||||
|  | Fields: | ||||||
|  | ```cpp | ||||||
|  | char const* Text; | ||||||
|  | sptr        Length; | ||||||
|  | TokType     Type; | ||||||
|  | s32         Line; | ||||||
|  | s32         Column; | ||||||
|  | bool 	    IsAssign; | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | `IsAssign` is a flag that is set when the token is an assignment operator. Which is used for various purposes: | ||||||
|  |  | ||||||
|  | * Using statment assignment | ||||||
|  | * Parameter argument default value assignment | ||||||
|  | * Variable declaration initialization assignment | ||||||
|  |  | ||||||
|  | I plan to replace IsAssign with a general flags field and properly keep track of all operator types instead of abstracting it away to `ETokType::Operator`. | ||||||
|  |  | ||||||
|  | Traversing the tokens is done with the following interface macros: | ||||||
|  |  | ||||||
|  | | Macro | Description | | ||||||
|  | | --- | --- | | ||||||
|  | | `currtok_noskip` | Get the current token without skipping whitespace | | ||||||
|  | | `currtok` | Get the current token, skip any whitespace tokens | | ||||||
|  | | `prevtok` | Get the previous token (does not skip whitespace) | | ||||||
|  | | `nexttok` | Get the next token (does not skip whitespace) | | ||||||
|  | | `eat( Token Type )` | Check to see if the current token is of the given type, if so, advance Token's index to the next token | | ||||||
|  | | `left` | Get the number of tokens left in the token array | | ||||||
|  | | `check_noskip` | Check to see if the current token is of the given type, without skipping whitespace | | ||||||
|  | | `check` | Check to see if the current token is of the given type, skip any whitespace tokens | | ||||||
|  |  | ||||||
|  | ### Parser | ||||||
|  |  | ||||||
|  | The parser has a limited user interface, only specific types of definitions or statements are expected to be provided by the user directly when using to construct an AST dynamically (See SOA for example). It however does attempt to provide capability to parse a full C/C++ from production codebases.  | ||||||
|  |  | ||||||
|  | Each public user interface procedure has the following format: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  | CodeStruct parse_<definition type>( StrC def ) | ||||||
|  | { | ||||||
|  |     check_parse_args( def ); | ||||||
|  |     using namespace Parser; | ||||||
|  |  | ||||||
|  |     TokArray toks = lex( def ); | ||||||
|  |     if ( toks.Arr == nullptr ) | ||||||
|  |         return CodeInvalid; | ||||||
|  |  | ||||||
|  |     // Parse the tokens and return a constructed AST using internal procedures | ||||||
|  |     ... | ||||||
|  | } | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | The most top-level parsing procedure used for C/C++ file parsing is `parse_global_body`: | ||||||
|  |  | ||||||
|  | It uses a helper procedure called `parse_global_nspace`. | ||||||
|  |  | ||||||
|  | Each internal procedure will be  | ||||||
|  |  | ||||||
|  | ## parse_global_nspace | ||||||
|  |  | ||||||
|  | 1. Make sure the type provided to the helper function is a `Namespace_Body`, `Global_Body`, `Export_Body`, `Extern_Linkage_body`. | ||||||
|  | 2. If its not a `Global_Body` eat the opening brace for the scope. | ||||||
|  | 3.  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ## parse_type | ||||||
|  |  | ||||||
| @@ -1,9 +1,12 @@ | |||||||
| # Parsing | # Parsing | ||||||
|  |  | ||||||
| The library features a naive parser tailored for only what the library needs to construct the supported syntax of C++ into its AST. | The library features a naive parser tailored for only what the library needs to construct the supported syntax of C++ into its AST. | ||||||
| This parser does not, and should not do the compiler's job. By only supporting this minimal set of features, the parser is kept (so far) under 5000 loc. |  | ||||||
|  |  | ||||||
| The parsing implementation supports the following for the user: | This parser does not, and should not do the compiler's job. By only supporting this minimal set of features, the parser is kept (so far) around 5500 loc. I hope to keep it under 10k loc worst case. | ||||||
|  |  | ||||||
|  | You can think of this parser of a frontend parser vs a semantic parser. Its intuitively similar to WYSIWYG. What you precerive as the syntax from the user-side before the compiler gets a hold of it, is what you get. | ||||||
|  |  | ||||||
|  | User exposed interface: | ||||||
|  |  | ||||||
| ```cpp | ```cpp | ||||||
| CodeClass       parse_class        ( StrC class_def       ); | CodeClass       parse_class        ( StrC class_def       ); | ||||||
| @@ -27,10 +30,12 @@ CodeUsing       parse_using        ( StrC using_def       ); | |||||||
| CodeVar         parse_variable     ( StrC var_def         ); | CodeVar         parse_variable     ( StrC var_def         ); | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|  | To parse file buffers, use the `parse_global_body` function. | ||||||
|  |  | ||||||
| ***Parsing will aggregate any tokens within a function body or expression statement to an untyped Code AST.*** | ***Parsing will aggregate any tokens within a function body or expression statement to an untyped Code AST.*** | ||||||
|  |  | ||||||
| Everything is done in one pass for both the preprocessor directives and the rest of the language.   | Everything is done in one pass for both the preprocessor directives and the rest of the language.   | ||||||
| The parser performs no macro expansion as the scope of gencpp feature-set is to only support the preprocessor for the goal of having rudimentary awareness of preprocessor ***conditionals***,  ***defines***, and ***includes***, and ***pragmas***.   | The parser performs no macro expansion as the scope of gencpp feature-set is to only support the preprocessor for the goal of having rudimentary awareness of preprocessor ***conditionals***,  ***defines***, ***includes***, and ***pragmas***.   | ||||||
|  |  | ||||||
| The keywords supported for the preprocessor are: | The keywords supported for the preprocessor are: | ||||||
|  |  | ||||||
| @@ -51,10 +56,17 @@ Any preprocessor definition abuse that changes the syntax of the core language i | |||||||
| Exceptions: | Exceptions: | ||||||
|  |  | ||||||
| * function signatures are allowed for a preprocessed macro: `neverinline MACRO() { ... }` | * function signatures are allowed for a preprocessed macro: `neverinline MACRO() { ... }` | ||||||
|  |   * Disable with: `#define GEN_PARSER_DISABLE_MACRO_FUNCTION_SIGNATURES` | ||||||
| * typedefs allow for a preprocessed macro: `typedef MACRO();` | * typedefs allow for a preprocessed macro: `typedef MACRO();` | ||||||
|  |   * Disable with: `#define GEN_PARSER_DISABLE_MACRO_TYPEDEF` | ||||||
|  |  | ||||||
|  | *(Exceptions are added on an on-demand basis)* | ||||||
| *(See functions `parse_operator_function_or_variable` and `parse_typedef` )* | *(See functions `parse_operator_function_or_variable` and `parse_typedef` )* | ||||||
|  |  | ||||||
|  | Adding your own exceptions is possible by simply modifying the parser to allow for the syntax you need. | ||||||
|  |  | ||||||
|  | *Note: You could interpret this strictness as a feature. This would allow the user to see if their codebase or a third-party's codebase some some egregious preprocessor abuse.* | ||||||
|  |  | ||||||
| The lexing and parsing takes shortcuts from whats expected in the standard. | The lexing and parsing takes shortcuts from whats expected in the standard. | ||||||
|  |  | ||||||
| * Numeric literals are not checked for validity. | * Numeric literals are not checked for validity. | ||||||
| @@ -64,8 +76,6 @@ The lexing and parsing takes shortcuts from whats expected in the standard. | |||||||
|   * Assumed to *come before specifiers* (`const`, `constexpr`, `extern`, `static`, etc) for a function |   * Assumed to *come before specifiers* (`const`, `constexpr`, `extern`, `static`, etc) for a function | ||||||
|   * Or in the usual spot for class, structs, (*right after the declaration keyword*) |   * Or in the usual spot for class, structs, (*right after the declaration keyword*) | ||||||
|   * typedefs have attributes with the type (`parse_type`) |   * typedefs have attributes with the type (`parse_type`) | ||||||
| * As a general rule; if its not available from the upfront constructors, its not available in the parsing constructors. |  | ||||||
|   * *Upfront constructors are not necessarily used in the parsing constructors, this is just a good metric to know what can be parsed.* |  | ||||||
| * Parsing attributes can be extended to support user defined macros by defining `GEN_DEFINE_ATTRIBUTE_TOKENS` (see `gen.hpp` for the formatting) | * Parsing attributes can be extended to support user defined macros by defining `GEN_DEFINE_ATTRIBUTE_TOKENS` (see `gen.hpp` for the formatting) | ||||||
|  |  | ||||||
| Empty lines used throughout the file are preserved for formatting purposes during ast serialization. | Empty lines used throughout the file are preserved for formatting purposes during ast serialization. | ||||||
|   | |||||||
| @@ -32,7 +32,7 @@ Two generic templated containers are used throughout the library: | |||||||
| * `template< class Type> struct Array` | * `template< class Type> struct Array` | ||||||
| * `template< class Type> struct HashTable` | * `template< class Type> struct HashTable` | ||||||
|  |  | ||||||
| Both Code and AST definitions have a `template< class Type> Code/AST cast()`. Its just an alternative way to explicitly cast to each other. | Both Code and AST definitions have a `template< class Type> Code/AST :: cast()`. Its just an alternative way to explicitly cast to each other. | ||||||
|  |  | ||||||
| `template< class Type> swap( Type& a, Type& b)` is used over a macro. | `template< class Type> swap( Type& a, Type& b)` is used over a macro. | ||||||
|  |  | ||||||
| @@ -42,6 +42,7 @@ Otherwise the library is free of any templates. | |||||||
|  |  | ||||||
| **There is no support for validating expressions.**   | **There is no support for validating expressions.**   | ||||||
| Its difficult to parse without enough benefits (At the metaprogramming level).   | Its difficult to parse without enough benefits (At the metaprogramming level).   | ||||||
|  | I plan to add this only at the tail of the project parsing milestone. | ||||||
|  |  | ||||||
| **Only trivial template support is provided.**   | **Only trivial template support is provided.**   | ||||||
| The intention is for only simple, non-recursive substitution.   | The intention is for only simple, non-recursive substitution.   | ||||||
| @@ -70,28 +71,36 @@ Data layout of AST struct: | |||||||
| union { | union { | ||||||
|     struct |     struct | ||||||
|     { |     { | ||||||
|  |         AST*      InlineCmt;       // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable | ||||||
|         AST*      Attributes;      // Class, Enum, Function, Struct, Typedef, Union, Using, Variable |         AST*      Attributes;      // Class, Enum, Function, Struct, Typedef, Union, Using, Variable | ||||||
|         AST*      Specs;           // Function, Operator, Type symbol, Variable |         AST*      Specs;           // Destructor, Function, Operator, Typename, Variable | ||||||
|         union { |         union { | ||||||
|             AST*  InitializerList; // Constructor, Destructor |             AST*  InitializerList; // Constructor | ||||||
|             AST*  ParentType;      // Class, Struct |             AST*  ParentType;      // Class, Struct, ParentType->Next has a possible list of interfaces. | ||||||
|             AST*  ReturnType;      // Function, Operator |             AST*  ReturnType;      // Function, Operator, Typename | ||||||
|             AST*  UnderlyingType;  // Enum, Typedef |             AST*  UnderlyingType;  // Enum, Typedef | ||||||
|             AST*  ValueType;       // Parameter, Variable |             AST*  ValueType;       // Parameter, Variable | ||||||
|         }; |         }; | ||||||
|         union { |         union { | ||||||
|             AST*  BitfieldSize;    // Varaiable (Class/Struct Data Member) |             AST*  BitfieldSize;    // Variable (Class/Struct Data Member) | ||||||
|             AST*  Params;          // Function, Operator, Template |             AST*  Params;          // Constructor, Function, Operator, Template, Typename | ||||||
|         }; |         }; | ||||||
|         union { |         union { | ||||||
|             AST*  ArrExpr;         // Type Symbol |             AST*  ArrExpr;          // Typename | ||||||
|             AST*  Body;             // Class, Constructr, Destructor, Enum, Function, Namespace, Struct, Union |             AST*  Body;             // Class, Constructr, Destructor, Enum, Function, Namespace, Struct, Union | ||||||
|             AST*  Declaration;      // Friend, Template |             AST*  Declaration;      // Friend, Template | ||||||
|             AST*  Value;            // Parameter, Variable |             AST*  Value;            // Parameter, Variable | ||||||
|         }; |         }; | ||||||
|  |         union { | ||||||
|  |             AST*  NextVar;          // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value ) | ||||||
|  |             AST*  SpecsFuncSuffix;  // Only used with typenames, to store the function suffix if typename is function signature. | ||||||
|  |         }; | ||||||
|     }; |     }; | ||||||
|     StringCached  Content;          // Attributes, Comment, Execution, Include |     StringCached  Content;          // Attributes, Comment, Execution, Include | ||||||
|  |     struct { | ||||||
|         SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers |         SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers | ||||||
|  |         AST*       NextSpecs;                   // Specifiers | ||||||
|  |     }; | ||||||
| }; | }; | ||||||
| union { | union { | ||||||
|     AST* Prev; |     AST* Prev; | ||||||
| @@ -108,10 +117,12 @@ CodeT             Type; | |||||||
| ModuleFlag        ModuleFlags; | ModuleFlag        ModuleFlags; | ||||||
| union { | union { | ||||||
|     b32           IsFunction;  // Used by typedef to not serialize the name field. |     b32           IsFunction;  // Used by typedef to not serialize the name field. | ||||||
|  |     b32           IsParamPack; // Used by typename to know if type should be considered a parameter pack. | ||||||
|     OperatorT     Op; |     OperatorT     Op; | ||||||
|     AccessSpec    ParentAccess; |     AccessSpec    ParentAccess; | ||||||
|     s32           NumEntries; |     s32           NumEntries; | ||||||
| }; | }; | ||||||
|  | s32               Token;       // Handle to the token, stored in the CodeFile (Otherwise unretrivable) | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| *`CodeT` is a typedef for `ECode::Type` which has an underlying type of `u32`*   | *`CodeT` is a typedef for `ECode::Type` which has an underlying type of `u32`*   | ||||||
| @@ -142,6 +153,13 @@ Data Notes: | |||||||
|  |  | ||||||
| * The allocator definitions used are exposed to the user incase they want to dictate memory usage | * The allocator definitions used are exposed to the user incase they want to dictate memory usage | ||||||
|   * You'll find the memory handling in `init`, `deinit`, `reset`, `gen_string_allocator`, `get_cached_string`, `make_code`. |   * You'll find the memory handling in `init`, `deinit`, `reset`, `gen_string_allocator`, `get_cached_string`, `make_code`. | ||||||
|  |   * Allocators are defined with the `AllocatorInfo` structure found in `dependencies\memory.hpp` | ||||||
|  |   * Most of the work is just defining the allocation procedure: | ||||||
|  |  | ||||||
|  | ```cpp | ||||||
|  |     void* ( void* allocator_data, AllocType type, sw size, sw alignment, void* old_memory, sw old_size, u64 flags ); | ||||||
|  | ``` | ||||||
|  |  | ||||||
| * ASTs are wrapped for the user in a Code struct which is a wrapper for a AST* type. | * ASTs are wrapped for the user in a Code struct which is a wrapper for a AST* type. | ||||||
| * Both AST and Code have member symbols but their data layout is enforced to be POD types. | * Both AST and Code have member symbols but their data layout is enforced to be POD types. | ||||||
| * This library treats memory failures as fatal. | * This library treats memory failures as fatal. | ||||||
| @@ -233,6 +251,7 @@ Interface :`` | |||||||
| * def_operator_cast | * def_operator_cast | ||||||
| * def_param | * def_param | ||||||
| * def_params | * def_params | ||||||
|  | * def_pragma | ||||||
| * def_preprocess_cond | * def_preprocess_cond | ||||||
| * def_specifier | * def_specifier | ||||||
| * def_specifiers | * def_specifiers | ||||||
| @@ -382,8 +401,8 @@ The following are provided predefined by the library as they are commonly used: | |||||||
| * `module_global_fragment` | * `module_global_fragment` | ||||||
| * `module_private_fragment` | * `module_private_fragment` | ||||||
| * `fmt_newline` | * `fmt_newline` | ||||||
| * `pragma_once` |  | ||||||
| * `param_varaidc` (Used for varadic definitions) | * `param_varaidc` (Used for varadic definitions) | ||||||
|  | * `pragma_once` | ||||||
| * `preprocess_else` | * `preprocess_else` | ||||||
| * `preprocess_endif` | * `preprocess_endif` | ||||||
| * `spec_const` | * `spec_const` | ||||||
| @@ -392,6 +411,7 @@ The following are provided predefined by the library as they are commonly used: | |||||||
| * `spec_constinit` | * `spec_constinit` | ||||||
| * `spec_extern_linkage` (extern) | * `spec_extern_linkage` (extern) | ||||||
| * `spec_final` | * `spec_final` | ||||||
|  | * `spec_forceinline` | ||||||
| * `spec_global` (global macro) | * `spec_global` (global macro) | ||||||
| * `spec_inline` | * `spec_inline` | ||||||
| * `spec_internal_linkage` (internal macro) | * `spec_internal_linkage` (internal macro) | ||||||
| @@ -429,8 +449,8 @@ Optionally the following may be defined if `GEN_DEFINE_LIBRARY_CODE_CONSTANTS` i | |||||||
| * `t_u16` | * `t_u16` | ||||||
| * `t_u32` | * `t_u32` | ||||||
| * `t_u64` | * `t_u64` | ||||||
| * `t_sw` | * `t_sw` (ssize_t) | ||||||
| * `t_uw` | * `t_uw` (size_t) | ||||||
| * `t_f32` | * `t_f32` | ||||||
| * `t_f64` | * `t_f64` | ||||||
|  |  | ||||||
| @@ -458,50 +478,10 @@ Editor and Scanner are disabled by default, use `GEN_FEATURE_EDITOR` and `GEN_FE | |||||||
| ### Builder is a similar object to the jai language's string_builder | ### Builder is a similar object to the jai language's string_builder | ||||||
|  |  | ||||||
| * The purpose of it is to generate a file. | * The purpose of it is to generate a file. | ||||||
| * A file is specified and opened for writing using the open( file_path) ) function. | * A file is specified and opened for writing using the open( file_path) function. | ||||||
| * The code is provided via print( code ) function  will be serialized to its buffer. | * The code is provided via print( code ) function  will be serialized to its buffer. | ||||||
| * When all serialization is finished, use the write() command to write the buffer to the file. | * When all serialization is finished, use the write() command to write the buffer to the file. | ||||||
|  |  | ||||||
| ### Editor is for editing a series of files/asts based on a set of requests provided to it | ### Scanner Auxillary Interface | ||||||
|  |  | ||||||
| **Note: Not implemented yet** | Provides *(eventually)* `scan_file` to automatically populate a CodeFile which contains a parsed AST (`Code`) of the file, with any contextual failures that are reported from the parser. | ||||||
|  |  | ||||||
| * The purpose is to overrite a specific file, it places its contents in a buffer to scan. |  | ||||||
| * If editing an AST it will generate a new ast as a result (ASTs are not edited). |  | ||||||
| * Requests are populated using the following interface: |  | ||||||
|   * add : Add code. |  | ||||||
|   * remove : Remove code. |  | ||||||
|   * replace: Replace code. |  | ||||||
|  |  | ||||||
| All three have the same parameters with exception to remove which only has SymbolInfo and Policy: |  | ||||||
|  |  | ||||||
| * SymbolInfo: |  | ||||||
|   * File      : The file the symbol resides in. Leave null to indicate to search all files. Leave null to indicated all-file search. |  | ||||||
|   * Marker    : #define symbol that indicates a location or following signature is valid to manipulate. Leave null to indicate the signature should only be used. |  | ||||||
|   * Signature : Use a Code symbol to find a valid location to manipulate, can be further filtered with the marker. Leave null to indicate the marker should only be used. |  | ||||||
|  |  | ||||||
| * Policy : Additional policy info for completing the request (empty for now) |  | ||||||
| * Code   : Code to inject if adding, or replace existing code with. |  | ||||||
|  |  | ||||||
| Additionally if `GEN_FEATURE_EDITOR_REFACTOR` is defined, refactor( file_path, specification_path ) wil be made available.   |  | ||||||
| Refactor is based of the refactor library and uses its interface.   |  | ||||||
| It will on call add a request to the queue to run the refactor script on the file. |  | ||||||
|  |  | ||||||
| ### Scanner allows the user to sift through a series of files/asts based on a set of requests provided to it |  | ||||||
|  |  | ||||||
| **Note: Not implemented yet** |  | ||||||
|  |  | ||||||
| * The purpose is to grab definitions to generate metadata or generate new code from these definitions. |  | ||||||
| * Requests are populated using the add( SymbolInfo, Policy ) function. The symbol info is the same as the one used for the editor. So is the case with Policy. |  | ||||||
|  |  | ||||||
| The file will only be read from, no writing supported. |  | ||||||
|  |  | ||||||
| ### Additional Info (Editor and Scanner) |  | ||||||
|  |  | ||||||
| When all requests have been populated, call process_requests().   |  | ||||||
| It will provide an output of receipt data of the results when it completes. |  | ||||||
|  |  | ||||||
| Files may be added to the Editor and Scanner additionally with add_files( num, files ).   |  | ||||||
| This is intended for when you have requests that are for multiple files. |  | ||||||
|  |  | ||||||
| Request queue in both Editor and Scanner are cleared once process_requests completes. |  | ||||||
|   | |||||||
							
								
								
									
										32
									
								
								gencpp.10x
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								gencpp.10x
									
									
									
									
									
								
							| @@ -8,21 +8,22 @@ | |||||||
| 		<ShowEmptyFolders>true</ShowEmptyFolders> | 		<ShowEmptyFolders>true</ShowEmptyFolders> | ||||||
| 		<IsVirtual>false</IsVirtual> | 		<IsVirtual>false</IsVirtual> | ||||||
| 		<IsFolder>false</IsFolder> | 		<IsFolder>false</IsFolder> | ||||||
| 		<BuildCommand>powershell ./scripts/test.gen_run.ps1</BuildCommand> | 		<BuildCommand>pwsh ./scripts/build.ps1 msvc debug bootstrap</BuildCommand> | ||||||
| 		<RebuildCommand></RebuildCommand> | 		<RebuildCommand></RebuildCommand> | ||||||
| 		<BuildFileCommand></BuildFileCommand> | 		<BuildFileCommand></BuildFileCommand> | ||||||
| 		<CleanCommand>powershell ./scripts/clean.ps1</CleanCommand> | 		<CleanCommand>psh ./scripts/clean.ps1</CleanCommand> | ||||||
| 		<BuildWorkingDirectory></BuildWorkingDirectory> | 		<BuildWorkingDirectory></BuildWorkingDirectory> | ||||||
| 		<CancelBuild></CancelBuild> | 		<CancelBuild></CancelBuild> | ||||||
| 		<RunCommand>./test/gen/build/gencpp.exe</RunCommand> | 		<RunCommand>./test/gen/build/gencpp.exe</RunCommand> | ||||||
| 		<RunCommandWorkingDirectory></RunCommandWorkingDirectory> | 		<RunCommandWorkingDirectory></RunCommandWorkingDirectory> | ||||||
| 		<DebugCommand>powershell ./scripts/build.ps1</DebugCommand> | 		<DebugCommand>pwsh ./scripts/build.ps1</DebugCommand> | ||||||
| 		<ExePathCommand>./test/gen/build/gencpp.exe</ExePathCommand> | 		<ExePathCommand>./test/gen/build/gencpp.exe</ExePathCommand> | ||||||
| 		<DebugSln>gencpp.sln</DebugSln> | 		<DebugSln></DebugSln> | ||||||
| 		<UseVisualStudioEnvBat>false</UseVisualStudioEnvBat> | 		<UseVisualStudioEnvBat>true</UseVisualStudioEnvBat> | ||||||
| 		<Configurations> | 		<Configurations> | ||||||
| 			<Configuration>Debug</Configuration> | 			<Configuration>Debug</Configuration> | ||||||
| 			<Configuration>Release</Configuration> | 			<Configuration>Release</Configuration> | ||||||
|  | 			<Configuration>bootstrap debug</Configuration> | ||||||
| 		</Configurations> | 		</Configurations> | ||||||
| 		<Platforms> | 		<Platforms> | ||||||
| 			<Platform>x64</Platform> | 			<Platform>x64</Platform> | ||||||
| @@ -31,15 +32,17 @@ | |||||||
| 			<AdditionalIncludePath>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.36.32532\include</AdditionalIncludePath> | 			<AdditionalIncludePath>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.36.32532\include</AdditionalIncludePath> | ||||||
| 			<AdditionalIncludePath>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.36.32532\ATLMFC\include</AdditionalIncludePath> | 			<AdditionalIncludePath>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.36.32532\ATLMFC\include</AdditionalIncludePath> | ||||||
| 			<AdditionalIncludePath>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\VS\include</AdditionalIncludePath> | 			<AdditionalIncludePath>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\VS\include</AdditionalIncludePath> | ||||||
| 			<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt</AdditionalIncludePath> | 			<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt</AdditionalIncludePath> | ||||||
| 			<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\um</AdditionalIncludePath> | 			<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um</AdditionalIncludePath> | ||||||
| 			<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\shared</AdditionalIncludePath> | 			<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared</AdditionalIncludePath> | ||||||
| 			<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\winrt</AdditionalIncludePath> | 			<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt</AdditionalIncludePath> | ||||||
| 			<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\cppwinrt</AdditionalIncludePath> | 			<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt</AdditionalIncludePath> | ||||||
| 			<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um</AdditionalIncludePath> | 			<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um</AdditionalIncludePath> | ||||||
| 		</AdditionalIncludePaths> | 		</AdditionalIncludePaths> | ||||||
| 		<Defines> | 		<Defines> | ||||||
| 			<Define>GEN_TIME</Define> | 			<Define>GEN_TIME</Define> | ||||||
|  | 			<Define>GEN_SYSTEM_WINDOWS</Define> | ||||||
|  | 			<Define>GEN_INTELLISENSE_DIRECTIVES</Define> | ||||||
| 		</Defines> | 		</Defines> | ||||||
| 		<ConfigProperties> | 		<ConfigProperties> | ||||||
| 			<ConfigAndPlatform> | 			<ConfigAndPlatform> | ||||||
| @@ -47,10 +50,19 @@ | |||||||
| 				<Defines></Defines> | 				<Defines></Defines> | ||||||
| 				<ForceIncludes></ForceIncludes> | 				<ForceIncludes></ForceIncludes> | ||||||
| 			</ConfigAndPlatform> | 			</ConfigAndPlatform> | ||||||
|  | 			<ConfigAndPlatform> | ||||||
|  | 				<Name>bootstrap debug:x64</Name> | ||||||
|  | 				<Defines></Defines> | ||||||
|  | 				<ForceIncludes></ForceIncludes> | ||||||
|  | 			</ConfigAndPlatform> | ||||||
| 			<Config> | 			<Config> | ||||||
| 				<Name>Debug</Name> | 				<Name>Debug</Name> | ||||||
| 				<Defines></Defines> | 				<Defines></Defines> | ||||||
| 			</Config> | 			</Config> | ||||||
|  | 			<Config> | ||||||
|  | 				<Name>bootstrap debug</Name> | ||||||
|  | 				<Defines></Defines> | ||||||
|  | 			</Config> | ||||||
| 			<Platform> | 			<Platform> | ||||||
| 				<Name>x64</Name> | 				<Name>x64</Name> | ||||||
| 				<Defines></Defines> | 				<Defines></Defines> | ||||||
|   | |||||||
							
								
								
									
										41
									
								
								gencpp.sln
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								gencpp.sln
									
									
									
									
									
								
							| @@ -7,20 +7,37 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gencpp", "gencpp.vcxproj", | |||||||
| EndProject | EndProject | ||||||
| Global | Global | ||||||
| 	GlobalSection(SolutionConfigurationPlatforms) = preSolution | 	GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||||||
| 		Debug|x64 = Debug|x64 | 		bootstrap debug|x64 = bootstrap debug|x64 | ||||||
| 		Debug|x86 = Debug|x86 | 		bootstrap debug|x86 = bootstrap debug|x86 | ||||||
| 		Release|x64 = Release|x64 | 		bootstrap release|x64 = bootstrap release|x64 | ||||||
| 		Release|x86 = Release|x86 | 		bootstrap release|x86 = bootstrap release|x86 | ||||||
|  | 		singleheader debug|x64 = singleheader debug|x64 | ||||||
|  | 		singleheader debug|x86 = singleheader debug|x86 | ||||||
|  | 		singleheader release|x64 = singleheader release|x64 | ||||||
|  | 		singleheader release|x86 = singleheader release|x86 | ||||||
|  | 		test debug|x64 = test debug|x64 | ||||||
|  | 		test debug|x86 = test debug|x86 | ||||||
| 	EndGlobalSection | 	EndGlobalSection | ||||||
| 	GlobalSection(ProjectConfigurationPlatforms) = postSolution | 	GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||||||
| 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Debug|x64.ActiveCfg = Debug|x64 | 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap debug|x64.ActiveCfg = bootstrap release|x64 | ||||||
| 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Debug|x64.Build.0 = Debug|x64 | 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap debug|x64.Build.0 = bootstrap release|x64 | ||||||
| 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Debug|x86.ActiveCfg = Debug|Win32 | 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap debug|x86.ActiveCfg = bootstrap debug|Win32 | ||||||
| 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Debug|x86.Build.0 = Debug|Win32 | 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap debug|x86.Build.0 = bootstrap debug|Win32 | ||||||
| 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Release|x64.ActiveCfg = Release|x64 | 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap release|x64.ActiveCfg = bootstrap release|x64 | ||||||
| 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Release|x64.Build.0 = Release|x64 | 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap release|x86.ActiveCfg = bootstrap release|Win32 | ||||||
| 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Release|x86.ActiveCfg = Release|Win32 | 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap release|x86.Build.0 = bootstrap release|Win32 | ||||||
| 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Release|x86.Build.0 = Release|Win32 | 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader debug|x64.ActiveCfg = singleheader debug|x64 | ||||||
|  | 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader debug|x64.Build.0 = singleheader debug|x64 | ||||||
|  | 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader debug|x86.ActiveCfg = singleheader debug|Win32 | ||||||
|  | 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader debug|x86.Build.0 = singleheader debug|Win32 | ||||||
|  | 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader release|x64.ActiveCfg = bootstrap debug|x64 | ||||||
|  | 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader release|x64.Build.0 = bootstrap debug|x64 | ||||||
|  | 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader release|x86.ActiveCfg = singleheader release|Win32 | ||||||
|  | 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader release|x86.Build.0 = singleheader release|Win32 | ||||||
|  | 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.test debug|x64.ActiveCfg = test debug|x64 | ||||||
|  | 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.test debug|x64.Build.0 = test debug|x64 | ||||||
|  | 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.test debug|x86.ActiveCfg = test debug|Win32 | ||||||
|  | 		{53AF600D-C09C-4F39-83E0-E022AA9479F2}.test debug|x86.Build.0 = test debug|Win32 | ||||||
| 	EndGlobalSection | 	EndGlobalSection | ||||||
| 	GlobalSection(SolutionProperties) = preSolution | 	GlobalSection(SolutionProperties) = preSolution | ||||||
| 		HideSolutionNode = FALSE | 		HideSolutionNode = FALSE | ||||||
|   | |||||||
							
								
								
									
										235
									
								
								gencpp.vcxproj
									
									
									
									
									
								
							
							
						
						
									
										235
									
								
								gencpp.vcxproj
									
									
									
									
									
								
							| @@ -1,20 +1,44 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||||
| <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||||||
|   <ItemGroup Label="ProjectConfigurations"> |   <ItemGroup Label="ProjectConfigurations"> | ||||||
|     <ProjectConfiguration Include="Debug|Win32"> |     <ProjectConfiguration Include="bootstrap debug|Win32"> | ||||||
|       <Configuration>Debug</Configuration> |       <Configuration>bootstrap debug</Configuration> | ||||||
|       <Platform>Win32</Platform> |       <Platform>Win32</Platform> | ||||||
|     </ProjectConfiguration> |     </ProjectConfiguration> | ||||||
|     <ProjectConfiguration Include="Release|Win32"> |     <ProjectConfiguration Include="bootstrap debug|x64"> | ||||||
|       <Configuration>Release</Configuration> |       <Configuration>bootstrap debug</Configuration> | ||||||
|       <Platform>Win32</Platform> |  | ||||||
|     </ProjectConfiguration> |  | ||||||
|     <ProjectConfiguration Include="Debug|x64"> |  | ||||||
|       <Configuration>Debug</Configuration> |  | ||||||
|       <Platform>x64</Platform> |       <Platform>x64</Platform> | ||||||
|     </ProjectConfiguration> |     </ProjectConfiguration> | ||||||
|     <ProjectConfiguration Include="Release|x64"> |     <ProjectConfiguration Include="bootstrap release|Win32"> | ||||||
|       <Configuration>Release</Configuration> |       <Configuration>bootstrap release</Configuration> | ||||||
|  |       <Platform>Win32</Platform> | ||||||
|  |     </ProjectConfiguration> | ||||||
|  |     <ProjectConfiguration Include="bootstrap release|x64"> | ||||||
|  |       <Configuration>bootstrap release</Configuration> | ||||||
|  |       <Platform>x64</Platform> | ||||||
|  |     </ProjectConfiguration> | ||||||
|  |     <ProjectConfiguration Include="singleheader debug|Win32"> | ||||||
|  |       <Configuration>singleheader debug</Configuration> | ||||||
|  |       <Platform>Win32</Platform> | ||||||
|  |     </ProjectConfiguration> | ||||||
|  |     <ProjectConfiguration Include="singleheader debug|x64"> | ||||||
|  |       <Configuration>singleheader debug</Configuration> | ||||||
|  |       <Platform>x64</Platform> | ||||||
|  |     </ProjectConfiguration> | ||||||
|  |     <ProjectConfiguration Include="singleheader release|Win32"> | ||||||
|  |       <Configuration>singleheader release</Configuration> | ||||||
|  |       <Platform>Win32</Platform> | ||||||
|  |     </ProjectConfiguration> | ||||||
|  |     <ProjectConfiguration Include="singleheader release|x64"> | ||||||
|  |       <Configuration>singleheader release</Configuration> | ||||||
|  |       <Platform>x64</Platform> | ||||||
|  |     </ProjectConfiguration> | ||||||
|  |     <ProjectConfiguration Include="test debug|Win32"> | ||||||
|  |       <Configuration>test debug</Configuration> | ||||||
|  |       <Platform>Win32</Platform> | ||||||
|  |     </ProjectConfiguration> | ||||||
|  |     <ProjectConfiguration Include="test debug|x64"> | ||||||
|  |       <Configuration>test debug</Configuration> | ||||||
|       <Platform>x64</Platform> |       <Platform>x64</Platform> | ||||||
|     </ProjectConfiguration> |     </ProjectConfiguration> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
| @@ -25,24 +49,54 @@ | |||||||
|     <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> |     <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> |   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|Win32'" Label="Configuration"> | ||||||
|     <ConfigurationType>Makefile</ConfigurationType> |     <ConfigurationType>Makefile</ConfigurationType> | ||||||
|     <UseDebugLibraries>true</UseDebugLibraries> |     <UseDebugLibraries>true</UseDebugLibraries> | ||||||
|     <PlatformToolset>v143</PlatformToolset> |     <PlatformToolset>v143</PlatformToolset> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test debug|Win32'" Label="Configuration"> | ||||||
|     <ConfigurationType>Makefile</ConfigurationType> |  | ||||||
|     <UseDebugLibraries>false</UseDebugLibraries> |  | ||||||
|     <PlatformToolset>v143</PlatformToolset> |  | ||||||
|   </PropertyGroup> |  | ||||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> |  | ||||||
|     <ConfigurationType>Makefile</ConfigurationType> |     <ConfigurationType>Makefile</ConfigurationType> | ||||||
|     <UseDebugLibraries>true</UseDebugLibraries> |     <UseDebugLibraries>true</UseDebugLibraries> | ||||||
|     <PlatformToolset>v143</PlatformToolset> |     <PlatformToolset>v143</PlatformToolset> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|Win32'" Label="Configuration"> | ||||||
|     <ConfigurationType>Makefile</ConfigurationType> |     <ConfigurationType>Makefile</ConfigurationType> | ||||||
|     <UseDebugLibraries>false</UseDebugLibraries> |     <UseDebugLibraries>true</UseDebugLibraries> | ||||||
|  |     <PlatformToolset>v143</PlatformToolset> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|Win32'" Label="Configuration"> | ||||||
|  |     <ConfigurationType>Makefile</ConfigurationType> | ||||||
|  |     <UseDebugLibraries>true</UseDebugLibraries> | ||||||
|  |     <PlatformToolset>v143</PlatformToolset> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|Win32'" Label="Configuration"> | ||||||
|  |     <ConfigurationType>Makefile</ConfigurationType> | ||||||
|  |     <UseDebugLibraries>true</UseDebugLibraries> | ||||||
|  |     <PlatformToolset>v143</PlatformToolset> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|x64'" Label="Configuration"> | ||||||
|  |     <ConfigurationType>Makefile</ConfigurationType> | ||||||
|  |     <UseDebugLibraries>true</UseDebugLibraries> | ||||||
|  |     <PlatformToolset>v143</PlatformToolset> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test debug|x64'" Label="Configuration"> | ||||||
|  |     <ConfigurationType>Makefile</ConfigurationType> | ||||||
|  |     <UseDebugLibraries>true</UseDebugLibraries> | ||||||
|  |     <PlatformToolset>v143</PlatformToolset> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|x64'" Label="Configuration"> | ||||||
|  |     <ConfigurationType>Makefile</ConfigurationType> | ||||||
|  |     <UseDebugLibraries>true</UseDebugLibraries> | ||||||
|  |     <PlatformToolset>v143</PlatformToolset> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|x64'" Label="Configuration"> | ||||||
|  |     <ConfigurationType>Makefile</ConfigurationType> | ||||||
|  |     <UseDebugLibraries>true</UseDebugLibraries> | ||||||
|  |     <PlatformToolset>v143</PlatformToolset> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|x64'" Label="Configuration"> | ||||||
|  |     <ConfigurationType>Makefile</ConfigurationType> | ||||||
|  |     <UseDebugLibraries>true</UseDebugLibraries> | ||||||
|     <PlatformToolset>v143</PlatformToolset> |     <PlatformToolset>v143</PlatformToolset> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> |   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||||||
| @@ -50,61 +104,145 @@ | |||||||
|   </ImportGroup> |   </ImportGroup> | ||||||
|   <ImportGroup Label="Shared"> |   <ImportGroup Label="Shared"> | ||||||
|   </ImportGroup> |   </ImportGroup> | ||||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |   <ImportGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|Win32'" Label="PropertySheets"> | ||||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||||
|   </ImportGroup> |   </ImportGroup> | ||||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |   <ImportGroup Condition="'$(Configuration)|$(Platform)'=='test debug|Win32'" Label="PropertySheets"> | ||||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||||
|   </ImportGroup> |   </ImportGroup> | ||||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |   <ImportGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|Win32'" Label="PropertySheets"> | ||||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||||
|   </ImportGroup> |   </ImportGroup> | ||||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |   <ImportGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|Win32'" Label="PropertySheets"> | ||||||
|  |     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||||
|  |   </ImportGroup> | ||||||
|  |   <ImportGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|Win32'" Label="PropertySheets"> | ||||||
|  |     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||||
|  |   </ImportGroup> | ||||||
|  |   <ImportGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|x64'" Label="PropertySheets"> | ||||||
|  |     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||||
|  |   </ImportGroup> | ||||||
|  |   <ImportGroup Condition="'$(Configuration)|$(Platform)'=='test debug|x64'" Label="PropertySheets"> | ||||||
|  |     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||||
|  |   </ImportGroup> | ||||||
|  |   <ImportGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|x64'" Label="PropertySheets"> | ||||||
|  |     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||||
|  |   </ImportGroup> | ||||||
|  |   <ImportGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|x64'" Label="PropertySheets"> | ||||||
|  |     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||||
|  |   </ImportGroup> | ||||||
|  |   <ImportGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|x64'" Label="PropertySheets"> | ||||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||||
|   </ImportGroup> |   </ImportGroup> | ||||||
|   <PropertyGroup Label="UserMacros" /> |   <PropertyGroup Label="UserMacros" /> | ||||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|Win32'"> | ||||||
|     <NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine> |     <NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine> | ||||||
|     <NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine> |     <NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine> | ||||||
|     <NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine> |     <NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine> | ||||||
|     <NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> |     <NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test debug|Win32'"> | ||||||
|     <NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine> |     <NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine> | ||||||
|     <NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine> |     <NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine> | ||||||
|     <NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine> |     <NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine> | ||||||
|     <NMakePreprocessorDefinitions>WIN32;NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> |     <NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|Win32'"> | ||||||
|     <NMakeBuildCommandLine>powershell.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1"</NMakeBuildCommandLine> |     <NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine> | ||||||
|     <NMakeReBuildCommandLine>powershell.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1"</NMakeReBuildCommandLine> |     <NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine> | ||||||
|     <NMakeCleanCommandLine>powershell.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine> |     <NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine> | ||||||
|     <NMakePreprocessorDefinitions>GEN_TIME;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> |     <NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> | ||||||
|     <IncludePath>$(ProjectDir)thirdparty;$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath> |  | ||||||
|     <SourcePath>$(ProjectDir)project;$(ProjectDir)test;$(SourcePath)</SourcePath> |  | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|Win32'"> | ||||||
|     <NMakeBuildCommandLine>powershell.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1"</NMakeBuildCommandLine> |     <NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine> | ||||||
|     <NMakeReBuildCommandLine>powershell.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1"</NMakeReBuildCommandLine> |     <NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine> | ||||||
|     <NMakeCleanCommandLine>powershell.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine> |     <NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine> | ||||||
|     <NMakePreprocessorDefinitions>GEN_TIME;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> |     <NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> | ||||||
|     <IncludePath>$(ProjectDir)thirdparty;$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath> |  | ||||||
|     <SourcePath>$(ProjectDir)project;$(ProjectDir)test;$(SourcePath)</SourcePath> |  | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|Win32'"> | ||||||
|  |     <NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine> | ||||||
|  |     <NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine> | ||||||
|  |     <NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine> | ||||||
|  |     <NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|x64'"> | ||||||
|  |     <NMakeBuildCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1" msvc debug bootstrap</NMakeBuildCommandLine> | ||||||
|  |     <NMakeReBuildCommandLine> | ||||||
|  |     </NMakeReBuildCommandLine> | ||||||
|  |     <NMakeCleanCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine> | ||||||
|  |     <NMakePreprocessorDefinitions>GEN_INTELLISENSE_DIRECTIVES;GEN_TIME;GEN_BENCHMARK;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> | ||||||
|  |     <IncludePath>$(ProjectDir)project;$(IncludePath)</IncludePath> | ||||||
|  |     <SourcePath>$(ProjectDir)project;$(SourcePath)</SourcePath> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test debug|x64'"> | ||||||
|  |     <NMakeBuildCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1" msvc debug test</NMakeBuildCommandLine> | ||||||
|  |     <NMakeReBuildCommandLine /> | ||||||
|  |     <NMakeCleanCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine> | ||||||
|  |     <NMakePreprocessorDefinitions>GEN_INTELLISENSE_DIRECTIVES;GEN_TIME;GEN_BENCHMARK;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> | ||||||
|  |     <IncludePath>$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath> | ||||||
|  |     <SourcePath>$(ProjectDir)project;$(SourcePath)</SourcePath> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|x64'"> | ||||||
|  |     <NMakeBuildCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1" msvc debug singleheader</NMakeBuildCommandLine> | ||||||
|  |     <NMakeReBuildCommandLine> | ||||||
|  |     </NMakeReBuildCommandLine> | ||||||
|  |     <NMakeCleanCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine> | ||||||
|  |     <NMakePreprocessorDefinitions>GEN_INTELLISENSE_DIRECTIVES;GEN_TIME;GEN_BENCHMARK;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> | ||||||
|  |     <IncludePath>$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath> | ||||||
|  |     <SourcePath>$(ProjectDir)project;$(SourcePath)</SourcePath> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|x64'"> | ||||||
|  |     <NMakeBuildCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1" msvc release singleheader</NMakeBuildCommandLine> | ||||||
|  |     <NMakeReBuildCommandLine> | ||||||
|  |     </NMakeReBuildCommandLine> | ||||||
|  |     <NMakeCleanCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine> | ||||||
|  |     <NMakePreprocessorDefinitions>GEN_INTELLISENSE_DIRECTIVES;GEN_TIME;GEN_BENCHMARK;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> | ||||||
|  |     <IncludePath>$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath> | ||||||
|  |     <SourcePath>$(ProjectDir)project;$(SourcePath)</SourcePath> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|x64'"> | ||||||
|  |     <NMakeBuildCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1" msvc release bootstrap</NMakeBuildCommandLine> | ||||||
|  |     <NMakeReBuildCommandLine> | ||||||
|  |     </NMakeReBuildCommandLine> | ||||||
|  |     <NMakeCleanCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine> | ||||||
|  |     <NMakePreprocessorDefinitions>GEN_INTELLISENSE_DIRECTIVES;GEN_TIME;GEN_BENCHMARK;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> | ||||||
|  |     <IncludePath>$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath> | ||||||
|  |     <SourcePath>$(ProjectDir)project;$(SourcePath)</SourcePath> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|x64'"> | ||||||
|  |     <ClCompile> | ||||||
|  |       <LanguageStandard_C>stdc11</LanguageStandard_C> | ||||||
|  |     </ClCompile> | ||||||
|  |   </ItemDefinitionGroup> | ||||||
|  |   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='test debug|x64'"> | ||||||
|  |     <ClCompile> | ||||||
|  |       <LanguageStandard_C>stdc11</LanguageStandard_C> | ||||||
|  |     </ClCompile> | ||||||
|  |   </ItemDefinitionGroup> | ||||||
|  |   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|x64'"> | ||||||
|  |     <ClCompile> | ||||||
|  |       <LanguageStandard_C>stdc11</LanguageStandard_C> | ||||||
|  |     </ClCompile> | ||||||
|  |   </ItemDefinitionGroup> | ||||||
|  |   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|x64'"> | ||||||
|  |     <ClCompile> | ||||||
|  |       <LanguageStandard_C>stdc11</LanguageStandard_C> | ||||||
|  |     </ClCompile> | ||||||
|  |   </ItemDefinitionGroup> | ||||||
|  |   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|x64'"> | ||||||
|     <ClCompile> |     <ClCompile> | ||||||
|       <LanguageStandard_C>stdc11</LanguageStandard_C> |       <LanguageStandard_C>stdc11</LanguageStandard_C> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|   </ItemDefinitionGroup> |   </ItemDefinitionGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <None Include=".editorconfig" /> |     <None Include=".editorconfig" /> | ||||||
|     <None Include="project\components\temp\Readme.md" /> |  | ||||||
|     <None Include="project\enums\AttributeTokens.csv" /> |     <None Include="project\enums\AttributeTokens.csv" /> | ||||||
|     <None Include="project\enums\ECode.csv" /> |     <None Include="project\enums\ECode.csv" /> | ||||||
|     <None Include="project\enums\EOperator.csv" /> |     <None Include="project\enums\EOperator.csv" /> | ||||||
|     <None Include="project\enums\ESpecifier.csv" /> |     <None Include="project\enums\ESpecifier.csv" /> | ||||||
|     <None Include="project\enums\ETokType.csv" /> |     <None Include="project\enums\ETokType.csv" /> | ||||||
|     <None Include="Readme.md" /> |     <None Include="Readme.md" /> | ||||||
|  |     <None Include="scripts\.clang-format" /> | ||||||
|     <None Include="scripts\build.ci.ps1" /> |     <None Include="scripts\build.ci.ps1" /> | ||||||
|     <None Include="scripts\build.ps1" /> |     <None Include="scripts\build.ps1" /> | ||||||
|     <None Include="scripts\clean.ps1" /> |     <None Include="scripts\clean.ps1" /> | ||||||
| @@ -124,14 +262,14 @@ | |||||||
|     <ClInclude Include="project\auxillary\scanner.hpp" /> |     <ClInclude Include="project\auxillary\scanner.hpp" /> | ||||||
|     <ClInclude Include="project\components\ast.hpp" /> |     <ClInclude Include="project\components\ast.hpp" /> | ||||||
|     <ClInclude Include="project\components\ast_types.hpp" /> |     <ClInclude Include="project\components\ast_types.hpp" /> | ||||||
|  |     <ClInclude Include="project\components\gen\ast_inlines.hpp" /> | ||||||
|  |     <ClInclude Include="project\components\gen\ecode.hpp" /> | ||||||
|  |     <ClInclude Include="project\components\gen\eoperator.hpp" /> | ||||||
|  |     <ClInclude Include="project\components\gen\especifier.hpp" /> | ||||||
|     <ClInclude Include="project\components\header_end.hpp" /> |     <ClInclude Include="project\components\header_end.hpp" /> | ||||||
|     <ClInclude Include="project\components\header_start.hpp" /> |     <ClInclude Include="project\components\header_start.hpp" /> | ||||||
|     <ClInclude Include="project\components\inlines.hpp" /> |     <ClInclude Include="project\components\inlines.hpp" /> | ||||||
|     <ClInclude Include="project\components\interface.hpp" /> |     <ClInclude Include="project\components\interface.hpp" /> | ||||||
|     <ClInclude Include="project\components\temp\ast_inlines.hpp" /> |  | ||||||
|     <ClInclude Include="project\components\temp\ecode.hpp" /> |  | ||||||
|     <ClInclude Include="project\components\temp\eoperator.hpp" /> |  | ||||||
|     <ClInclude Include="project\components\temp\especifier.hpp" /> |  | ||||||
|     <ClInclude Include="project\components\types.hpp" /> |     <ClInclude Include="project\components\types.hpp" /> | ||||||
|     <ClInclude Include="project\dependencies\basic_types.hpp" /> |     <ClInclude Include="project\dependencies\basic_types.hpp" /> | ||||||
|     <ClInclude Include="project\dependencies\containers.hpp" /> |     <ClInclude Include="project\dependencies\containers.hpp" /> | ||||||
| @@ -153,6 +291,7 @@ | |||||||
|     <ClInclude Include="project\helpers\push_ignores.inline.hpp" /> |     <ClInclude Include="project\helpers\push_ignores.inline.hpp" /> | ||||||
|     <ClInclude Include="project\helpers\undef.macros.hpp" /> |     <ClInclude Include="project\helpers\undef.macros.hpp" /> | ||||||
|     <ClInclude Include="singleheader\components\header_start.hpp" /> |     <ClInclude Include="singleheader\components\header_start.hpp" /> | ||||||
|  |     <ClInclude Include="test\CURSED_TYPEDEF.h" /> | ||||||
|     <ClInclude Include="test\DummyInclude.hpp" /> |     <ClInclude Include="test\DummyInclude.hpp" /> | ||||||
|     <ClInclude Include="test\Parsed\Buffer.Parsed.hpp" /> |     <ClInclude Include="test\Parsed\Buffer.Parsed.hpp" /> | ||||||
|     <ClInclude Include="test\Parsed\HashTable.Parsed.hpp" /> |     <ClInclude Include="test\Parsed\HashTable.Parsed.hpp" /> | ||||||
| @@ -174,14 +313,13 @@ | |||||||
|     <ClCompile Include="project\bootstrap.cpp" /> |     <ClCompile Include="project\bootstrap.cpp" /> | ||||||
|     <ClCompile Include="project\components\ast.cpp" /> |     <ClCompile Include="project\components\ast.cpp" /> | ||||||
|     <ClCompile Include="project\components\ast_case_macros.cpp" /> |     <ClCompile Include="project\components\ast_case_macros.cpp" /> | ||||||
|  |     <ClCompile Include="project\components\gen\etoktype.cpp" /> | ||||||
|     <ClCompile Include="project\components\interface.cpp" /> |     <ClCompile Include="project\components\interface.cpp" /> | ||||||
|     <ClCompile Include="project\components\interface.parsing.cpp" /> |     <ClCompile Include="project\components\interface.parsing.cpp" /> | ||||||
|     <ClCompile Include="project\components\interface.untyped.cpp" /> |     <ClCompile Include="project\components\interface.untyped.cpp" /> | ||||||
|     <ClCompile Include="project\components\interface.upfront.cpp" /> |     <ClCompile Include="project\components\interface.upfront.cpp" /> | ||||||
|     <ClCompile Include="project\components\src_start.cpp" /> |     <ClCompile Include="project\components\src_start.cpp" /> | ||||||
|     <ClCompile Include="project\components\static_data.cpp" /> |     <ClCompile Include="project\components\static_data.cpp" /> | ||||||
|     <ClCompile Include="project\components\temp\etoktype.cpp" /> |  | ||||||
|     <ClCompile Include="project\components\untyped.cpp" /> |  | ||||||
|     <ClCompile Include="project\dependencies\debug.cpp" /> |     <ClCompile Include="project\dependencies\debug.cpp" /> | ||||||
|     <ClCompile Include="project\dependencies\filesystem.cpp" /> |     <ClCompile Include="project\dependencies\filesystem.cpp" /> | ||||||
|     <ClCompile Include="project\dependencies\hashing.cpp" /> |     <ClCompile Include="project\dependencies\hashing.cpp" /> | ||||||
| @@ -192,6 +330,7 @@ | |||||||
|     <ClCompile Include="project\dependencies\strings.cpp" /> |     <ClCompile Include="project\dependencies\strings.cpp" /> | ||||||
|     <ClCompile Include="project\dependencies\string_ops.cpp" /> |     <ClCompile Include="project\dependencies\string_ops.cpp" /> | ||||||
|     <ClCompile Include="project\dependencies\timing.cpp" /> |     <ClCompile Include="project\dependencies\timing.cpp" /> | ||||||
|  |     <ClCompile Include="project\Example.cpp" /> | ||||||
|     <ClCompile Include="project\gen.cpp" /> |     <ClCompile Include="project\gen.cpp" /> | ||||||
|     <ClCompile Include="project\gen.dep.cpp" /> |     <ClCompile Include="project\gen.dep.cpp" /> | ||||||
|     <ClCompile Include="singleheader\singleheader.cpp" /> |     <ClCompile Include="singleheader\singleheader.cpp" /> | ||||||
|   | |||||||
| @@ -129,6 +129,9 @@ | |||||||
|     <ClCompile Include="project\components\interface.untyped.cpp"> |     <ClCompile Include="project\components\interface.untyped.cpp"> | ||||||
|       <Filter>Source Files</Filter> |       <Filter>Source Files</Filter> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|  |     <ClCompile Include="project\components\gen\etoktype.cpp"> | ||||||
|  |       <Filter>Source Files</Filter> | ||||||
|  |     </ClCompile> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <ClInclude Include="project\gen.hpp"> |     <ClInclude Include="project\gen.hpp"> | ||||||
| @@ -275,6 +278,21 @@ | |||||||
|     <ClInclude Include="singleheader\components\header_start.hpp"> |     <ClInclude Include="singleheader\components\header_start.hpp"> | ||||||
|       <Filter>Header Files</Filter> |       <Filter>Header Files</Filter> | ||||||
|     </ClInclude> |     </ClInclude> | ||||||
|  |     <ClInclude Include="project\components\gen\ast_inlines.hpp"> | ||||||
|  |       <Filter>Header Files</Filter> | ||||||
|  |     </ClInclude> | ||||||
|  |     <ClInclude Include="project\components\gen\ecode.hpp"> | ||||||
|  |       <Filter>Header Files</Filter> | ||||||
|  |     </ClInclude> | ||||||
|  |     <ClInclude Include="project\components\gen\eoperator.hpp"> | ||||||
|  |       <Filter>Header Files</Filter> | ||||||
|  |     </ClInclude> | ||||||
|  |     <ClInclude Include="project\components\gen\especifier.hpp"> | ||||||
|  |       <Filter>Header Files</Filter> | ||||||
|  |     </ClInclude> | ||||||
|  |     <ClInclude Include="test\CURSED_TYPEDEF.h"> | ||||||
|  |       <Filter>Header Files</Filter> | ||||||
|  |     </ClInclude> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <None Include=".editorconfig" /> |     <None Include=".editorconfig" /> | ||||||
| @@ -297,6 +315,7 @@ | |||||||
|     <None Include="scripts\helpers\target_arch.psm1" /> |     <None Include="scripts\helpers\target_arch.psm1" /> | ||||||
|     <None Include="scripts\package_release.ps1" /> |     <None Include="scripts\package_release.ps1" /> | ||||||
|     <None Include="scripts\refactor.ps1" /> |     <None Include="scripts\refactor.ps1" /> | ||||||
|  |     <None Include="scripts\.clang-format" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <Natvis Include=".vscode\gencpp.natvis" /> |     <Natvis Include=".vscode\gencpp.natvis" /> | ||||||
|   | |||||||
| @@ -3,14 +3,29 @@ | |||||||
|   <PropertyGroup> |   <PropertyGroup> | ||||||
|     <ShowAllFiles>true</ShowAllFiles> |     <ShowAllFiles>true</ShowAllFiles> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|x64'"> | ||||||
|     <LocalDebuggerAttach>false</LocalDebuggerAttach> |     <LocalDebuggerAttach>false</LocalDebuggerAttach> | ||||||
|     <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> |     <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> | ||||||
|     <LocalDebuggerCommand>C:\projects\gencpp\test\gen\build\gencpp.exe</LocalDebuggerCommand> |     <LocalDebuggerCommand>$(ProjectDir)project\build\bootstrap.exe</LocalDebuggerCommand> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test debug|x64'"> | ||||||
|     <LocalDebuggerAttach>false</LocalDebuggerAttach> |     <LocalDebuggerAttach>false</LocalDebuggerAttach> | ||||||
|     <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> |     <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> | ||||||
|     <LocalDebuggerCommand>C:\projects\gencpp\test\gen\build\gencpp.exe</LocalDebuggerCommand> |     <LocalDebuggerCommand>$(ProjectDir)project\build\bootstrap.exe</LocalDebuggerCommand> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|x64'"> | ||||||
|  |     <LocalDebuggerAttach>false</LocalDebuggerAttach> | ||||||
|  |     <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> | ||||||
|  |     <LocalDebuggerCommand>$(ProjectDir)project\build\bootstrap.exe</LocalDebuggerCommand> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|x64'"> | ||||||
|  |     <LocalDebuggerAttach>false</LocalDebuggerAttach> | ||||||
|  |     <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> | ||||||
|  |     <LocalDebuggerCommand>$(ProjectDir)project\build\bootstrap.exe</LocalDebuggerCommand> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|x64'"> | ||||||
|  |     <LocalDebuggerAttach>false</LocalDebuggerAttach> | ||||||
|  |     <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> | ||||||
|  |     <LocalDebuggerCommand>$(ProjectDir)project\build\bootstrap.exe</LocalDebuggerCommand> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
| </Project> | </Project> | ||||||
| @@ -8,8 +8,7 @@ They contain includes for its various components: `components/<component_name>.< | |||||||
| Dependencies are bundled into `gen.dep.<hpp/cpp>`.   | Dependencies are bundled into `gen.dep.<hpp/cpp>`.   | ||||||
| Just like the `gen.<hpp/cpp>` they include their components: `dependencies/<dependency_name>.<hpp/cpp>` | Just like the `gen.<hpp/cpp>` they include their components: `dependencies/<dependency_name>.<hpp/cpp>` | ||||||
|  |  | ||||||
| The fle processors are in their own respective files. (Ex: `file_processors/<file_processor>.<hpp/cpp>` )   | Code not making up the core library is located in `auxiliary/<auxiliary_name>.<hpp/cpp>`. These are optional extensions or tools for the library. | ||||||
| They directly include `depedencies/file_handling.<hpp/cpp>` as the core library does not include file processing by defualt. |  | ||||||
|  |  | ||||||
| **TODO : Right now the library is not finished, as such the first self-hosting iteration is still WIP**   | **TODO : Right now the library is not finished, as such the first self-hosting iteration is still WIP**   | ||||||
| Both libraries use *pre-generated* (self-hosting I guess) version of the library to then generate the latest version of itself.   | Both libraries use *pre-generated* (self-hosting I guess) version of the library to then generate the latest version of itself.   | ||||||
| @@ -30,10 +29,11 @@ Feature Macros: | |||||||
| * `GEN_ENFORCE_STRONG_CODE_TYPES` : Enforces casts to filtered code types. | * `GEN_ENFORCE_STRONG_CODE_TYPES` : Enforces casts to filtered code types. | ||||||
| * `GEN_EXPOSE_BACKEND` : Will expose symbols meant for internal use only. | * `GEN_EXPOSE_BACKEND` : Will expose symbols meant for internal use only. | ||||||
| * `GEN_ROLL_OWN_DEPENDENCIES` : Optional override so that user may define the dependencies themselves. | * `GEN_ROLL_OWN_DEPENDENCIES` : Optional override so that user may define the dependencies themselves. | ||||||
|  | * `GEN_DONT_ALLOW_INVALID_CODE` (Not implemented yet) : Will fail when an invalid code is constructed, parsed, or serialized. | ||||||
|  |  | ||||||
| ## On multi-threading | ## On multi-threading | ||||||
|  |  | ||||||
| Currently unsupported. | Currently unsupported. I want the library to be *stable* and *correct*, with the addition of exhausting all basic single-threaded optimizations before I consider multi-threading. | ||||||
|  |  | ||||||
| ## Extending the library | ## Extending the library | ||||||
|  |  | ||||||
| @@ -51,5 +51,10 @@ Names or Content fields are interned strings and thus showed be cached using `ge | |||||||
| `def_operator` is the most sophisticated constructor as it has multiple permutations of definitions that could be created that are not trivial to determine if valid. | `def_operator` is the most sophisticated constructor as it has multiple permutations of definitions that could be created that are not trivial to determine if valid. | ||||||
|  |  | ||||||
| The library has its code segmented into component files, use it to help create a derived version without needing to have to rewrite a generated file directly or build on top of the header via composition or inheritance. | The library has its code segmented into component files, use it to help create a derived version without needing to have to rewrite a generated file directly or build on top of the header via composition or inheritance. | ||||||
| When the scanner is implemented, this will be even easier to customize. |  | ||||||
|  |  | ||||||
|  | The parser is documented under `docs/Parsing.md` and `docs/Parser_Algo.md`.   | ||||||
|  |  | ||||||
|  | ## A note on compilation and runtime generation speed | ||||||
|  |  | ||||||
|  | The library is designed to be fast to compile and generate code at runtime as fast as resonable possible on a debug build. | ||||||
|  | Its recommended that your metaprogam be compiled using a single translation unit (unity build). | ||||||
|   | |||||||
| @@ -1,4 +1,6 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	include "builder.hpp" | #	include "builder.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| Builder Builder::open( char const* path ) | Builder Builder::open( char const* path ) | ||||||
| { | { | ||||||
| @@ -26,8 +28,7 @@ void Builder::pad_lines( s32 num ) | |||||||
| void Builder::print( Code code ) | void Builder::print( Code code ) | ||||||
| { | { | ||||||
| 	String   str = code->to_string(); | 	String   str = code->to_string(); | ||||||
| 	const sw len = str.length(); | 	// const sw len = str.length(); | ||||||
|  |  | ||||||
| 	// log_fmt( "%s - print: %.*s\n", File.filename, len > 80 ? 80 : len, str.Data ); | 	// log_fmt( "%s - print: %.*s\n", File.filename, len > 80 ? 80 : len, str.Data ); | ||||||
| 	Buffer.append( str ); | 	Buffer.append( str ); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
| #	include "gen.hpp" | #	include "gen.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| struct Builder | struct Builder | ||||||
| { | { | ||||||
|   | |||||||
| @@ -1,67 +0,0 @@ | |||||||
| #pragma once |  | ||||||
| #include "gen.scanner.hpp" |  | ||||||
|  |  | ||||||
| struct Policy |  | ||||||
| { |  | ||||||
| 	// Nothing for now. |  | ||||||
| }; |  | ||||||
|  |  | ||||||
| enum class SymbolType : u32 |  | ||||||
| { |  | ||||||
| 	Code, |  | ||||||
| 	Line, |  | ||||||
| 	Marker |  | ||||||
| }; |  | ||||||
|  |  | ||||||
| struct Editor |  | ||||||
| { |  | ||||||
| 	enum RequestType : u32 |  | ||||||
| 	{ |  | ||||||
| 		Add, |  | ||||||
| 		Replace, |  | ||||||
| 		Remove |  | ||||||
| 	}; |  | ||||||
|  |  | ||||||
| 	struct SymbolData |  | ||||||
| 	{ |  | ||||||
| 		Policy      Policy; |  | ||||||
| 		SymbolInfo  Info; |  | ||||||
| 	}; |  | ||||||
|  |  | ||||||
| 	struct RequestEntry |  | ||||||
| 	{ |  | ||||||
| 		union { |  | ||||||
| 			SymbolData Symbol; |  | ||||||
| 			String     Specification; |  | ||||||
| 		}; |  | ||||||
| 		RequestType    Type; |  | ||||||
| 	}; |  | ||||||
|  |  | ||||||
| 	struct Receipt |  | ||||||
| 	{ |  | ||||||
| 		StringCached File; |  | ||||||
| 		Code         Found; |  | ||||||
| 		Code         Written; |  | ||||||
| 		bool         Result; |  | ||||||
| 	}; |  | ||||||
|  |  | ||||||
| 	static AllocatorInfo Allocator; |  | ||||||
|  |  | ||||||
| 	static void set_allocator( AllocatorInfo  allocator ); |  | ||||||
|  |  | ||||||
| 	Array<FileInfo>     Files; |  | ||||||
| 	String              Buffer; |  | ||||||
| 	Array<RequestEntry> Requests; |  | ||||||
|  |  | ||||||
| 	void add_files( s32 num, char const** files ); |  | ||||||
|  |  | ||||||
| 	void add    ( SymbolInfo definition,  Policy policy, Code to_inject ); |  | ||||||
| 	void remove ( SymbolInfo definition,  Policy policy ); |  | ||||||
| 	void replace( SymbolInfo definition,  Policy policy, Code to_replace); |  | ||||||
|  |  | ||||||
| #	ifdef GEN_FEATURE_EDITOR_REFACTOR |  | ||||||
| 	void refactor( char const* file_path, char const* specification_path ); |  | ||||||
| #	endif |  | ||||||
|  |  | ||||||
| 	bool process_requests( Array<Receipt> out_receipts ); |  | ||||||
| }; |  | ||||||
| @@ -1,10 +1,12 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
| #	include "gen.hpp" | #	include "gen.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| // This is a simple file reader that reads the entire file into memory. | // This is a simple file reader that reads the entire file into memory. | ||||||
| // It has an extra option to skip the first few lines for undesired includes. | // It has an extra option to skip the first few lines for undesired includes. | ||||||
| // This is done so that includes can be kept in dependency and component files so that intellisense works. | // This is done so that includes can be kept in dependency and component files so that intellisense works. | ||||||
| Code scan_file( char const* path, bool skip_initial_directives = true ) | Code scan_file( char const* path ) | ||||||
| { | { | ||||||
| 	FileInfo file; | 	FileInfo file; | ||||||
|  |  | ||||||
| @@ -24,63 +26,92 @@ Code scan_file( char const* path, bool skip_initial_directives = true ) | |||||||
| 		file_read( & file, str, fsize ); | 		file_read( & file, str, fsize ); | ||||||
| 		str.get_header().Length = fsize; | 		str.get_header().Length = fsize; | ||||||
|  |  | ||||||
| 	if ( skip_initial_directives ) | 	// Skip GEN_INTELLISENSE_DIRECTIVES preprocessor blocks | ||||||
|  | 	// Its designed so that the directive should be the first thing in the file. | ||||||
|  | 	// Anything that comes before it will also be omitted. | ||||||
| 	{ | 	{ | ||||||
| 	#define current (*scanner) | 	#define current (*scanner) | ||||||
| 		StrC toks[] { | 	#define matched    0 | ||||||
| 			txt( "pragma once" ), | 	#define move_fwd() do { ++ scanner; -- left; } while (0) | ||||||
| 			txt( "include" ) | 		const StrC directive_start = txt( "ifdef" ); | ||||||
| 		}; | 		const StrC directive_end   = txt( "endif" ); | ||||||
|  | 		const StrC def_intellisense = txt("GEN_INTELLISENSE_DIRECTIVES" ); | ||||||
|  |  | ||||||
| 		char* scanner = str; | 		bool        found_directive = false; | ||||||
| 		while ( current != '\r' && current != '\n' ) | 		char const* scanner         = str.Data; | ||||||
| 		{ | 		s32         left            = fsize; | ||||||
| 			for ( StrC tok : toks ) | 		while ( left ) | ||||||
| 		{ | 		{ | ||||||
|  | 			// Processing directive. | ||||||
| 			if ( current == '#' ) | 			if ( current == '#' ) | ||||||
| 			{ | 			{ | ||||||
| 					++ scanner; | 				move_fwd(); | ||||||
|  | 				while ( left && char_is_space( current ) ) | ||||||
|  | 					move_fwd(); | ||||||
|  |  | ||||||
|  | 				if ( ! found_directive ) | ||||||
|  | 				{ | ||||||
|  | 					if ( left && str_compare( scanner, directive_start.Ptr, directive_start.Len ) == matched ) | ||||||
|  | 					{ | ||||||
|  | 						scanner += directive_start.Len; | ||||||
|  | 						left    -= directive_start.Len; | ||||||
|  |  | ||||||
|  | 						while ( left && char_is_space( current ) ) | ||||||
|  | 							move_fwd(); | ||||||
|  |  | ||||||
|  | 						if ( left && str_compare( scanner, def_intellisense.Ptr, def_intellisense.Len ) == matched ) | ||||||
|  | 						{ | ||||||
|  | 							scanner += def_intellisense.Len; | ||||||
|  | 							left    -= def_intellisense.Len; | ||||||
|  |  | ||||||
|  | 							found_directive = true; | ||||||
|  | 						} | ||||||
| 					} | 					} | ||||||
|  |  | ||||||
| 				if ( strncmp( scanner, tok.Ptr, tok.Len ) == 0 ) | 					// Skip to end of line | ||||||
| 				{ | 					while ( left && current != '\r' && current != '\n' ) | ||||||
| 					scanner += tok.Len; | 						move_fwd(); | ||||||
| 					while ( scanner < ( str.Data + str.length() ) && current != '\r' && current != '\n' ) | 					move_fwd(); | ||||||
| 					{ |  | ||||||
| 						++ scanner; | 					if ( left && current == '\n' ) | ||||||
|  | 						move_fwd(); | ||||||
|  |  | ||||||
|  | 					continue; | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 					// Skip the line | 				if ( left && str_compare( scanner, directive_end.Ptr, directive_end.Len ) == matched ) | ||||||
| 					sptr skip_size = sptr( scanner - str.Data ); |  | ||||||
| 					if ( (scanner + 2) >= ( str.Data + str.length() ) ) |  | ||||||
| 				{ | 				{ | ||||||
| 						sptr new_length = sptr( str.get_header().Length ) - skip_size; | 					scanner += directive_end.Len; | ||||||
| 						mem_move( str, scanner, new_length ); | 					left    -= directive_end.Len; | ||||||
| 						str.get_header().Length = new_length; |  | ||||||
|  | 					// Skip to end of line | ||||||
|  | 					while ( left && current != '\r' && current != '\n' ) | ||||||
|  | 						move_fwd(); | ||||||
|  | 					move_fwd(); | ||||||
|  |  | ||||||
|  | 					if ( left && current == '\n' ) | ||||||
|  | 						move_fwd(); | ||||||
|  |  | ||||||
|  | 					// sptr skip_size = fsize - left; | ||||||
|  | 					if ( (scanner + 2) >= ( str.Data + fsize ) ) | ||||||
|  | 					{ | ||||||
|  | 						mem_move( str, scanner, left ); | ||||||
|  | 						str.get_header().Length = left; | ||||||
| 						break; | 						break; | ||||||
| 					} | 					} | ||||||
|  |  | ||||||
| 					if ( current == '\r' ) | 					mem_move( str, scanner, left ); | ||||||
| 					{ | 					str.get_header().Length = left; | ||||||
| 						skip_size += 2; |  | ||||||
| 						scanner   += 2; | 					break; | ||||||
| 					} |  | ||||||
| 					else |  | ||||||
| 					{ |  | ||||||
| 						skip_size += 1; |  | ||||||
| 						scanner   += 1; |  | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 					sptr new_length = sptr( str.get_header().Length ) - skip_size; |  | ||||||
| 					mem_move( str, scanner, new_length ); |  | ||||||
| 					str.get_header().Length = new_length; |  | ||||||
|  |  | ||||||
| 					scanner = str; |  | ||||||
| 				} |  | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			++ scanner; | 			move_fwd(); | ||||||
| 		} | 		} | ||||||
|  | 	#undef move_fwd | ||||||
|  | 	#undef matched | ||||||
| 	#undef current | 	#undef current | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -89,45 +120,40 @@ Code scan_file( char const* path, bool skip_initial_directives = true ) | |||||||
| } | } | ||||||
|  |  | ||||||
| #if 0 | #if 0 | ||||||
| struct Policy | struct CodeFile | ||||||
| { | { | ||||||
| 	// Nothing for now. | 	using namespace Parser; | ||||||
|  |  | ||||||
|  | 	String              FilePath; | ||||||
|  | 	TokArray            Tokens; | ||||||
|  | 	Array<ParseFailure> ParseFailures; | ||||||
|  | 	Code                CodeRoot; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| struct SymbolInfo | namespace Parser | ||||||
| { | { | ||||||
| 	StringCached File; | 	struct ParseFailure | ||||||
| 	char const*  Marker; |  | ||||||
| 	Code         Signature; |  | ||||||
| }; |  | ||||||
|  |  | ||||||
| struct Scanner |  | ||||||
| 	{ | 	{ | ||||||
| 	struct RequestEntry | 		String Reason; | ||||||
|  | 		Code   Node; | ||||||
|  | 	}; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | CodeFile scan_file( char const* path ) | ||||||
| { | { | ||||||
| 		SymbolInfo Info; | 	using namespace Parser; | ||||||
| 	}; |  | ||||||
|  |  | ||||||
| 	struct Receipt | 	CodeFile | ||||||
| 	{ | 	result = {}; | ||||||
| 		StringCached File; | 	result.FilePath = String::make( GlobalAllocator, path ); | ||||||
| 		Code         Defintion; |  | ||||||
| 		bool         Result; |  | ||||||
| 	}; |  | ||||||
|  |  | ||||||
| 	AllocatorInfo MemAlloc; | 	Code code = scan_file( path ); | ||||||
|  | 	result.CodeRoot = code; | ||||||
|  |  | ||||||
| 	static void set_allocator( AllocatorInfo allocator ); | 	ParseContext context = parser_get_last_context(); | ||||||
|  | 	result.Tokens        = context.Tokens; | ||||||
|  | 	result.ParseFailures = context.Failures; | ||||||
|  |  | ||||||
| 	Array<FileInfo>     Files; | 	return result; | ||||||
| 	String              Buffer; | } | ||||||
| 	Array<RequestEntry> Requests; |  | ||||||
|  |  | ||||||
| 	void add_files( s32 num, char const** files ); |  | ||||||
|  |  | ||||||
| 	void add( SymbolInfo signature, Policy policy ); |  | ||||||
|  |  | ||||||
| 	bool process_requests( Array<Receipt> out_receipts ); |  | ||||||
| }; |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										106
									
								
								project/auxillary/vis_ast/build.ps1
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										106
									
								
								project/auxillary/vis_ast/build.ps1
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,106 @@ | |||||||
|  | Clear-Host | ||||||
|  |  | ||||||
|  | $path_root     = git rev-parse --show-toplevel | ||||||
|  | $path_scripts  = Join-Path $path_root 'scripts' | ||||||
|  |  | ||||||
|  | $target_arch        = Join-Path $path_scripts 'helpers/target_arch.psm1' | ||||||
|  | $devshell           = Join-Path $path_scripts 'helpers/devshell.ps1' | ||||||
|  | $format_cpp	        = Join-Path $path_scripts 'helpers/format_cpp.psm1' | ||||||
|  | $incremental_checks = Join-Path $path_scripts 'helpers/incremental_checks.ps1' | ||||||
|  | $vendor_toolchain   = Join-Path $path_scripts 'helpers/vendor_toolchain.ps1' | ||||||
|  |  | ||||||
|  | $path_project  = Join-Path $path_root     'project' | ||||||
|  | $path_aux      = Join-Path $path_project  'auxillary' | ||||||
|  | $path_vis_root = Join-Path $path_aux      'vis_ast' | ||||||
|  | $path_binaries = Join-Path $path_vis_root 'binaries' | ||||||
|  | $path_build    = Join-Path $path_vis_root 'build' | ||||||
|  | $path_code     = Join-Path $path_vis_root 'code' | ||||||
|  | $path_win32    = Join-Path $path_code     'win32' | ||||||
|  |  | ||||||
|  | Import-Module $target_arch | ||||||
|  | Import-Module $format_cpp | ||||||
|  |  | ||||||
|  | #region Arguments | ||||||
|  | $vendor           = $null | ||||||
|  | $optimize         = $null | ||||||
|  | $debug 	          = $null | ||||||
|  | $analysis	      = $false | ||||||
|  | $dev              = $false | ||||||
|  | $verbose          = $null | ||||||
|  | $platform         = $null | ||||||
|  | $module_specified = $false | ||||||
|  |  | ||||||
|  | [array] $vendors = @( "clang", "msvc" ) | ||||||
|  |  | ||||||
|  | # This is a really lazy way of parsing the args, could use actual params down the line... | ||||||
|  |  | ||||||
|  | if ( $args ) { $args | ForEach-Object { | ||||||
|  | switch ($_){ | ||||||
|  |  { $_ -in $vendors }   { $vendor    = $_; break } | ||||||
|  |  "optimize"            { $optimize  = $true } | ||||||
|  |  "debug"               { $debug     = $true } | ||||||
|  |  "analysis"            { $analysis  = $true } | ||||||
|  |  "dev"                 { $dev       = $true } | ||||||
|  |  "verbose"             { $verbose   = $true } | ||||||
|  |  "platform"            { $platform  = $true; $module_specified = $true } | ||||||
|  | } | ||||||
|  | }} | ||||||
|  | #endregion Argument | ||||||
|  |  | ||||||
|  | if ( -not $module_specified ) | ||||||
|  | { | ||||||
|  | 	$platform = $true | ||||||
|  | } | ||||||
|  |  | ||||||
|  | # Load up toolchain configuraion | ||||||
|  | . $vendor_toolchain | ||||||
|  | . $incremental_checks | ||||||
|  |  | ||||||
|  | write-host "Building Vis AST with $vendor" | ||||||
|  |  | ||||||
|  | if ( (Test-Path $path_build) -eq $false ) { | ||||||
|  | 	New-Item $path_build -ItemType Directory | ||||||
|  | } | ||||||
|  |  | ||||||
|  | if ( (Test-Path $path_binaries) -eq $false ) { | ||||||
|  | 	New-Item $path_binaries -ItemType Directory | ||||||
|  | } | ||||||
|  |  | ||||||
|  | $includes = @( | ||||||
|  | 	$paht_code | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | # Microsoft | ||||||
|  | $lib_gdi32  = 'Gdi32.lib' | ||||||
|  | $lib_xinput = 'Xinput.lib' | ||||||
|  | $lib_user32 = 'User32.lib' | ||||||
|  | $lib_winmm  = 'Winmm.lib' | ||||||
|  |  | ||||||
|  | $stack_size = 1024 * 1024 * 4 | ||||||
|  |  | ||||||
|  | $compiler_args = @( | ||||||
|  | 	($flag_define + 'UNICODE'), | ||||||
|  | 	($flag_define + '_UNICODE') | ||||||
|  | 	( $flag_define + 'INTELLISENSE_DIRECTIVES=0'), | ||||||
|  | 	# ($flag_set_stack_size + $stack_size) | ||||||
|  | 	$flag_wall | ||||||
|  | 	$flag_warnings_as_errors | ||||||
|  | 	$flag_optimize_intrinsics | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | if ( $dev ) { | ||||||
|  | 	$compiler_args += ( $flag_define + 'Build_Development=1' ) | ||||||
|  | } | ||||||
|  | else { | ||||||
|  | 	$compiler_args += ( $flag_define + 'Build_Development=0' ) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | $linker_args = @( | ||||||
|  | 	$flag_link_win_subsystem_windows, | ||||||
|  | 	$flag_link_optiiize_references | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | $unit       = join-path $path_code     'vis_ast_windows.cpp' | ||||||
|  | $executable = join-path $path_binaries 'vis_ast.exe' | ||||||
|  |  | ||||||
|  | $build_result = build-simple $path_build $includes $compiler_args $linker_args $unit $executable | ||||||
							
								
								
									
										0
									
								
								project/auxillary/vis_ast/clean.ps1
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								project/auxillary/vis_ast/clean.ps1
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										24
									
								
								project/auxillary/vis_ast/code/platform/macros.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								project/auxillary/vis_ast/code/platform/macros.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | |||||||
|  | #if INTELLISENSE_DIRECTIVES | ||||||
|  | #include "vendor/compiler.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #define global        static // Global variables | ||||||
|  | #define internal      static // Internal linkage | ||||||
|  | #define local_persist static // Local Persisting variables | ||||||
|  |  | ||||||
|  | #define api_c extern "C" | ||||||
|  |  | ||||||
|  | #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 do_once()   for ( local_persist b32 once = true; once; once = false ) | ||||||
|  | #define stmt( ... ) do { __VA_ARGS__; } while ( 0 ) | ||||||
|  |  | ||||||
|  | #define array_count( array ) ( sizeof( array ) / sizeof( ( array )[0] ) ) | ||||||
|  |  | ||||||
|  | #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 ) ) | ||||||
							
								
								
									
										9
									
								
								project/auxillary/vis_ast/code/platform/vendor/arch.hpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								project/auxillary/vis_ast/code/platform/vendor/arch.hpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | |||||||
|  | // Platform architecture | ||||||
|  |  | ||||||
|  | #if defined( _WIN64 ) || defined( __x86_64__ ) || defined( _M_X64 ) || defined( __64BIT__ ) || defined( __powerpc64__ ) || defined( __ppc64__ ) || defined( __aarch64__ ) | ||||||
|  | #	ifndef ARCH_64_BIT | ||||||
|  | #		define ARCH_64_BIT 1 | ||||||
|  | #	endif | ||||||
|  | #else | ||||||
|  | #	error A 32-bit architecture is not supported | ||||||
|  | #endif | ||||||
							
								
								
									
										21
									
								
								project/auxillary/vis_ast/code/platform/vendor/compiler.hpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								project/auxillary/vis_ast/code/platform/vendor/compiler.hpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | |||||||
|  | // Platform compiler | ||||||
|  |  | ||||||
|  | #if defined( _MSC_VER ) | ||||||
|  | #	define Compiler_MSVC 1 | ||||||
|  | #elif defined( __clang__ ) | ||||||
|  | #	define Compiler_Clang 1 | ||||||
|  | #else | ||||||
|  | #	error "Unknown compiler" | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #if defined( __has_attribute ) | ||||||
|  | #	define HAS_ATTRIBUTE( attribute ) __has_attribute( attribute ) | ||||||
|  | #else | ||||||
|  | #	define HAS_ATTRIBUTE( attribute ) ( 0 ) | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #ifdef Compiler_Clang | ||||||
|  | #	define compiler_decorated_func_name __PRETTY_NAME__ | ||||||
|  | #elif defined(Compiler_MSVC) | ||||||
|  | #	define compiler_decorated_func_name __FUNCDNAME__ | ||||||
|  | #endif | ||||||
							
								
								
									
										34
									
								
								project/auxillary/vis_ast/code/platform/vendor/compiler_ignores.hpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								project/auxillary/vis_ast/code/platform/vendor/compiler_ignores.hpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,34 @@ | |||||||
|  | #pragma once | ||||||
|  | #if INTELLISENSE_DIRECTIVES | ||||||
|  | #include "compiler.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #ifdef Compiler_MSVC | ||||||
|  | #pragma warning( disable: 4201 ) // Support for non-standard nameless struct or union extesnion | ||||||
|  | #pragma warning( disable: 4100 ) // Support for unreferenced formal parameters | ||||||
|  | #pragma warning( disable: 4800 ) // Support implicit conversion to bools | ||||||
|  | #pragma warning( disable: 4365 ) // Support for signed/unsigned mismatch auto-conversion | ||||||
|  | #pragma warning( disable: 4189 ) // Support for unused variables | ||||||
|  | #pragma warning( disable: 4514 ) // Support for unused inline functions | ||||||
|  | #pragma warning( disable: 4505 ) // Support for unused static functions | ||||||
|  | #pragma warning( disable: 5045 ) // Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified | ||||||
|  | #pragma warning( disable: 5264 ) // Support for 'const' variables unused | ||||||
|  | #pragma warning( disable: 4820 ) // Support auto-adding padding to structs | ||||||
|  | #pragma warning( disable: 4711 ) // Support automatic inline expansion | ||||||
|  | #pragma warning( disable: 4710 ) // Support automatic inline expansion | ||||||
|  | #pragma warning( disable: 4805 ) // Support comparisons of s32 to bool. | ||||||
|  | #pragma warning( disable: 5246 ) // Support for initialization of subobject without braces. | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #ifdef Compiler_Clang | ||||||
|  | #pragma clang diagnostic push | ||||||
|  | #pragma clang diagnostic ignored "-Wunused-const-variable" | ||||||
|  | #pragma clang diagnostic ignored "-Wswitch" | ||||||
|  | #pragma clang diagnostic ignored "-Wunused-variable" | ||||||
|  | #pragma clang diagnostic ignored "-Wunused-local-typedef" | ||||||
|  | #pragma clang diagnostic ignored "-Wunknown-pragmas" | ||||||
|  | #pragma clang diagnostic ignored "-Wvarargs" | ||||||
|  | #pragma clang diagnostic ignored "-Wunused-function" | ||||||
|  | #pragma clang diagnostic ignored "-Wunused-but-set-variable" | ||||||
|  | #pragma clang diagnostic ignored "-Wmissing-braces" | ||||||
|  | #endif | ||||||
							
								
								
									
										21
									
								
								project/auxillary/vis_ast/code/platform/vendor/os.hpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								project/auxillary/vis_ast/code/platform/vendor/os.hpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | |||||||
|  | // Platform OS detection | ||||||
|  |  | ||||||
|  | #if defined( _WIN32 ) || defined( _WIN64 ) | ||||||
|  | #	ifndef System_Windows | ||||||
|  | #		define System_Windows 1 | ||||||
|  | #	endif | ||||||
|  | #elif defined( __APPLE__ ) && defined( __MACH__ ) | ||||||
|  | #	ifndef System_MacOS | ||||||
|  | #		define System_MacOS 1 | ||||||
|  | #	endif | ||||||
|  | #elif defined( __unix__ ) | ||||||
|  | #	if defined( __linux__ ) | ||||||
|  | #		ifndef System_Linux | ||||||
|  | #			define System_linux 1 | ||||||
|  | #		endif | ||||||
|  | #	else | ||||||
|  | #		error This UNIX operating system is not supported | ||||||
|  | #	endif | ||||||
|  | #else | ||||||
|  | #	error This operating system is not supported | ||||||
|  | #endif | ||||||
							
								
								
									
										8
									
								
								project/auxillary/vis_ast/code/platform/win32/launch.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								project/auxillary/vis_ast/code/platform/win32/launch.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | |||||||
|  | #if INTELLISENSE_DIRECTIVES | ||||||
|  | #include "win32.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | int __stdcall WinMain( HINSTANCE instance, HINSTANCE prev_instance, char* commandline, int num_cmd_show) | ||||||
|  | { | ||||||
|  | 	return 0; | ||||||
|  | } | ||||||
							
								
								
									
										1
									
								
								project/auxillary/vis_ast/code/platform/win32/types.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								project/auxillary/vis_ast/code/platform/win32/types.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | |||||||
|  | using HINSTANCE = void*; | ||||||
							
								
								
									
										10
									
								
								project/auxillary/vis_ast/code/vis_ast_windows.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								project/auxillary/vis_ast/code/vis_ast_windows.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | |||||||
|  | #include "platform/vendor/arch.hpp" | ||||||
|  | #include "platform/vendor/compiler.hpp" | ||||||
|  | #include "platform/vendor/compiler_ignores.hpp" | ||||||
|  | #include "platform/vendor/os.hpp" | ||||||
|  |  | ||||||
|  | #include "platform/macros.hpp" | ||||||
|  |  | ||||||
|  | #include "platform/win32/types.hpp" | ||||||
|  |  | ||||||
|  | #include "platform/win32/launch.cpp" | ||||||
							
								
								
									
										226
									
								
								project/auxillary/vis_ast/dependencies/raylib/include/config.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										226
									
								
								project/auxillary/vis_ast/dependencies/raylib/include/config.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,226 @@ | |||||||
|  | /********************************************************************************************** | ||||||
|  |  * | ||||||
|  |  *   raylib configuration flags | ||||||
|  |  * | ||||||
|  |  *   This file defines all the configuration flags for the different raylib modules | ||||||
|  |  * | ||||||
|  |  *   LICENSE: zlib/libpng | ||||||
|  |  * | ||||||
|  |  *   Copyright (c) 2018-2023 Ahmad Fatoum & Ramon Santamaria (@raysan5) | ||||||
|  |  * | ||||||
|  |  *   This software is provided "as-is", without any express or implied warranty. In no event | ||||||
|  |  *   will the authors be held liable for any damages arising from the use of this software. | ||||||
|  |  * | ||||||
|  |  *   Permission is granted to anyone to use this software for any purpose, including commercial | ||||||
|  |  *   applications, and to alter it and redistribute it freely, subject to the following restrictions: | ||||||
|  |  * | ||||||
|  |  *     1. The origin of this software must not be misrepresented; you must not claim that you | ||||||
|  |  *     wrote the original software. If you use this software in a product, an acknowledgment | ||||||
|  |  *     in the product documentation would be appreciated but is not required. | ||||||
|  |  * | ||||||
|  |  *     2. Altered source versions must be plainly marked as such, and must not be misrepresented | ||||||
|  |  *     as being the original software. | ||||||
|  |  * | ||||||
|  |  *     3. This notice may not be removed or altered from any source distribution. | ||||||
|  |  * | ||||||
|  |  **********************************************************************************************/ | ||||||
|  |  | ||||||
|  | #ifndef CONFIG_H | ||||||
|  | #define RL_CONFIG_H | ||||||
|  |  | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | // Module selection - Some modules could be avoided | ||||||
|  | // Mandatory modules: rcore, rlgl, utils | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | #define RL_SUPPORT_MODULE_RSHAPES   1 | ||||||
|  | #define RL_SUPPORT_MODULE_RTEXTURES 1 | ||||||
|  | #define RL_SUPPORT_MODULE_RTEXT     1    // WARNING: It requires SUPPORT_MODULE_RTEXTURES to load sprite font textures | ||||||
|  | #define RL_SUPPORT_MODULE_RMODELS   1 | ||||||
|  | #define RL_SUPPORT_MODULE_RAUDIO    1 | ||||||
|  |  | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | // Module: rcore - Configuration Flags | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | // Camera module is included (rcamera.h) and multiple predefined cameras are available: free, 1st/3rd person, orbital | ||||||
|  | #define RL_SUPPORT_CAMERA_SYSTEM 1 | ||||||
|  | // Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag | ||||||
|  | #define RL_SUPPORT_GESTURES_SYSTEM 1 | ||||||
|  | // Mouse gestures are directly mapped like touches and processed by gestures system | ||||||
|  | #define RL_SUPPORT_MOUSE_GESTURES 1 | ||||||
|  | // Reconfigure standard input to receive key inputs, works with SSH connection. | ||||||
|  | #define RL_SUPPORT_SSH_KEYBOARD_RPI 1 | ||||||
|  | // Setting a higher resolution can improve the accuracy of time-out intervals in wait functions. | ||||||
|  | // However, it can also reduce overall system performance, because the thread scheduler switches tasks more often. | ||||||
|  | #define RL_SUPPORT_WINMM_HIGHRES_TIMER 1 | ||||||
|  | // Use busy wait loop for timing sync, if not defined, a high-resolution timer is set up and used | ||||||
|  | // #define SUPPORT_BUSY_WAIT_LOOP          1 | ||||||
|  | // Use a partial-busy wait loop, in this case frame sleeps for most of the time, but then runs a busy loop at the end for accuracy | ||||||
|  | #define RL_SUPPORT_PARTIALBUSY_WAIT_LOOP 1 | ||||||
|  | // Allow automatic screen capture of current screen pressing F12, defined in KeyCallback() | ||||||
|  | #define RL_SUPPORT_SCREEN_CAPTURE 1 | ||||||
|  | // Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback() | ||||||
|  | #define RL_SUPPORT_GIF_RECORDING 1 | ||||||
|  | // Support CompressData() and DecompressData() functions | ||||||
|  | #define RL_SUPPORT_COMPRESSION_API 1 | ||||||
|  | // Support automatic generated events, loading and recording of those events when required | ||||||
|  | // #define SUPPORT_EVENTS_AUTOMATION       1 | ||||||
|  | // Support custom frame control, only for advance users | ||||||
|  | // By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timing + PollInputEvents() | ||||||
|  | // Enabling this flag allows manual control of the frame processes, use at your own risk | ||||||
|  | // #define SUPPORT_CUSTOM_FRAME_CONTROL    1 | ||||||
|  |  | ||||||
|  | // rcore: Configuration values | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | #define RL_MAX_FILEPATH_CAPACITY  8192    // Maximum file paths capacity | ||||||
|  | #define RL_MAX_FILEPATH_LENGTH    4096    // Maximum length for filepaths (Linux PATH_MAX default value) | ||||||
|  |  | ||||||
|  | #define RL_MAX_KEYBOARD_KEYS      512    // Maximum number of keyboard keys supported | ||||||
|  | #define RL_MAX_MOUSE_BUTTONS      8      // Maximum number of mouse buttons supported | ||||||
|  | #define RL_MAX_GAMEPADS           4      // Maximum number of gamepads supported | ||||||
|  | #define RL_MAX_GAMEPAD_AXIS       8      // Maximum number of axis supported (per gamepad) | ||||||
|  | #define RL_MAX_GAMEPAD_BUTTONS    32     // Maximum number of buttons supported (per gamepad) | ||||||
|  | #define RL_MAX_TOUCH_POINTS       8      // Maximum number of touch points supported | ||||||
|  | #define RL_MAX_KEY_PRESSED_QUEUE  16     // Maximum number of keys in the key input queue | ||||||
|  | #define RL_MAX_CHAR_PRESSED_QUEUE 16     // Maximum number of characters in the char input queue | ||||||
|  |  | ||||||
|  | #define RL_MAX_DECOMPRESSION_SIZE 64    // Max size allocated for decompression in MB | ||||||
|  |  | ||||||
|  |  | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | // Module: rlgl - Configuration values | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  |  | ||||||
|  | // Enable OpenGL Debug Context (only available on OpenGL 4.3) | ||||||
|  | // #define RLGL_ENABLE_OPENGL_DEBUG_CONTEXT       1 | ||||||
|  |  | ||||||
|  | // Show OpenGL extensions and capabilities detailed logs on init | ||||||
|  | // #define RLGL_SHOW_GL_DETAILS_INFO              1 | ||||||
|  |  | ||||||
|  | // #define RL_DEFAULT_BATCH_BUFFER_ELEMENTS    4096    // Default internal render batch elements limits | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | // Default shader vertex attribute names to set location points | ||||||
|  | // NOTE: When a new shader is loaded, the following locations are tried to be set for convenience | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | // Module: rshapes - Configuration Flags | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | // Use QUADS instead of TRIANGLES for drawing when possible | ||||||
|  | // Some lines-based shapes could still use lines | ||||||
|  | #define RL_SUPPORT_QUADS_DRAW_MODE 1 | ||||||
|  |  | ||||||
|  |  | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | // Module: rtextures - Configuration Flags | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | // Selecte desired fileformats to be supported for image data loading | ||||||
|  | #define RL_SUPPORT_FILEFORMAT_PNG 1 | ||||||
|  | // #define SUPPORT_FILEFORMAT_BMP      1 | ||||||
|  | // #define SUPPORT_FILEFORMAT_TGA      1 | ||||||
|  | // #define SUPPORT_FILEFORMAT_JPG      1 | ||||||
|  | #define RL_SUPPORT_FILEFORMAT_GIF 1 | ||||||
|  | #define RL_SUPPORT_FILEFORMAT_QOI 1 | ||||||
|  | // #define SUPPORT_FILEFORMAT_PSD      1 | ||||||
|  | #define RL_SUPPORT_FILEFORMAT_DDS 1 | ||||||
|  | // #define SUPPORT_FILEFORMAT_HDR      1 | ||||||
|  | // #define SUPPORT_FILEFORMAT_PIC          1 | ||||||
|  | // #define SUPPORT_FILEFORMAT_KTX      1 | ||||||
|  | // #define SUPPORT_FILEFORMAT_ASTC     1 | ||||||
|  | // #define SUPPORT_FILEFORMAT_PKM      1 | ||||||
|  | // #define SUPPORT_FILEFORMAT_PVR      1 | ||||||
|  | // #define SUPPORT_FILEFORMAT_SVG      1 | ||||||
|  |  | ||||||
|  | // Support image export functionality (.png, .bmp, .tga, .jpg, .qoi) | ||||||
|  | #define RL_SUPPORT_IMAGE_EXPORT 1 | ||||||
|  | // Support procedural image generation functionality (gradient, spot, perlin-noise, cellular) | ||||||
|  | #define RL_SUPPORT_IMAGE_GENERATION 1 | ||||||
|  | // Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop... | ||||||
|  | // If not defined, still some functions are supported: ImageFormat(), ImageCrop(), ImageToPOT() | ||||||
|  | #define RL_SUPPORT_IMAGE_MANIPULATION 1 | ||||||
|  |  | ||||||
|  |  | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | // Module: rtext - Configuration Flags | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | // Default font is loaded on window initialization to be available for the user to render simple text | ||||||
|  | // NOTE: If enabled, uses external module functions to load default raylib font | ||||||
|  | #define RL_SUPPORT_DEFAULT_FONT 1 | ||||||
|  | // Selected desired font fileformats to be supported for loading | ||||||
|  | #define RL_SUPPORT_FILEFORMAT_FNT 1 | ||||||
|  | #define RL_SUPPORT_FILEFORMAT_TTF 1 | ||||||
|  |  | ||||||
|  | // Support text management functions | ||||||
|  | // If not defined, still some functions are supported: TextLength(), TextFormat() | ||||||
|  | #define RL_SUPPORT_TEXT_MANIPULATION 1 | ||||||
|  |  | ||||||
|  | // On font atlas image generation [GenImageFontAtlas()], add a 3x3 pixels white rectangle | ||||||
|  | // at the bottom-right corner of the atlas. It can be useful to for shapes drawing, to allow | ||||||
|  | // drawing text and shapes with a single draw call [SetShapesTexture()]. | ||||||
|  | #define RL_SUPPORT_FONT_ATLAS_WHITE_REC 1 | ||||||
|  |  | ||||||
|  | // rtext: Configuration values | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | #define RL_MAX_TEXT_BUFFER_LENGTH 1024    // Size of internal static buffers used on some functions: | ||||||
|  | // TextFormat(), TextSubtext(), TextToUpper(), TextToLower(), TextToPascal(), TextSplit() | ||||||
|  | #define RL_MAX_TEXTSPLIT_COUNT 128    // Maximum number of substrings to split: TextSplit() | ||||||
|  |  | ||||||
|  |  | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | // Module: rmodels - Configuration Flags | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | // Selected desired model fileformats to be supported for loading | ||||||
|  | #define RL_SUPPORT_FILEFORMAT_OBJ  1 | ||||||
|  | #define RL_SUPPORT_FILEFORMAT_MTL  1 | ||||||
|  | #define RL_SUPPORT_FILEFORMAT_IQM  1 | ||||||
|  | #define RL_SUPPORT_FILEFORMAT_GLTF 1 | ||||||
|  | #define RL_SUPPORT_FILEFORMAT_VOX  1 | ||||||
|  | #define RL_SUPPORT_FILEFORMAT_M3D  1 | ||||||
|  | // Support procedural mesh generation functions, uses external par_shapes.h library | ||||||
|  | // NOTE: Some generated meshes DO NOT include generated texture coordinates | ||||||
|  | #define RL_SUPPORT_MESH_GENERATION 1 | ||||||
|  |  | ||||||
|  | // rmodels: Configuration values | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | #define RL_MAX_MATERIAL_MAPS       12    // Maximum number of shader maps supported | ||||||
|  | #define RL_MAX_MESH_VERTEX_BUFFERS 7     // Maximum vertex buffers (VBO) per mesh | ||||||
|  |  | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | // Module: raudio - Configuration Flags | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | // Desired audio fileformats to be supported for loading | ||||||
|  | #define RL_SUPPORT_FILEFORMAT_WAV 1 | ||||||
|  | #define RL_SUPPORT_FILEFORMAT_OGG 1 | ||||||
|  | #define RL_SUPPORT_FILEFORMAT_MP3 1 | ||||||
|  | #define RL_SUPPORT_FILEFORMAT_QOA 1 | ||||||
|  | // #define SUPPORT_FILEFORMAT_FLAC         1 | ||||||
|  | #define RL_SUPPORT_FILEFORMAT_XM  1 | ||||||
|  | #define RL_SUPPORT_FILEFORMAT_MOD 1 | ||||||
|  |  | ||||||
|  | // raudio: Configuration values | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | #define RL_AUDIO_DEVICE_FORMAT            ma_format_f32    // Device output format (miniaudio: float-32bit) | ||||||
|  | #define RL_AUDIO_DEVICE_CHANNELS          2                // Device output channels: stereo | ||||||
|  | #define RL_AUDIO_DEVICE_SAMPLE_RATE       0                // Device sample rate (device default) | ||||||
|  |  | ||||||
|  | #define RL_MAX_AUDIO_BUFFER_POOL_CHANNELS 16    // Maximum number of audio pool channels | ||||||
|  |  | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | // Module: utils - Configuration Flags | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | // Standard file io library (stdio.h) included | ||||||
|  | #define RL_SUPPORT_STANDARD_FILEIO 1 | ||||||
|  | // Show TRACELOG() output messages | ||||||
|  | // NOTE: By default LOG_DEBUG traces not shown | ||||||
|  | #define RL_SUPPORT_TRACELOG 1 | ||||||
|  | // #define SUPPORT_TRACELOG_DEBUG          1 | ||||||
|  |  | ||||||
|  | // utils: Configuration values | ||||||
|  | //------------------------------------------------------------------------------------ | ||||||
|  | #define RL_MAX_TRACELOG_MSG_LENGTH 256    // Max length of one trace-log message | ||||||
|  |  | ||||||
|  | #endif | ||||||
|  | // CONFIG_H | ||||||
							
								
								
									
										1995
									
								
								project/auxillary/vis_ast/dependencies/raylib/include/raylib.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1995
									
								
								project/auxillary/vis_ast/dependencies/raylib/include/raylib.h
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										2181
									
								
								project/auxillary/vis_ast/dependencies/raylib/include/raymath.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2181
									
								
								project/auxillary/vis_ast/dependencies/raylib/include/raymath.h
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										595
									
								
								project/auxillary/vis_ast/dependencies/raylib/include/rcamera.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										595
									
								
								project/auxillary/vis_ast/dependencies/raylib/include/rcamera.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,595 @@ | |||||||
|  | /******************************************************************************************* | ||||||
|  |  * | ||||||
|  |  *   rcamera - Basic camera system with support for multiple camera modes | ||||||
|  |  * | ||||||
|  |  *   CONFIGURATION: | ||||||
|  |  *       #define RCAMERA_IMPLEMENTATION | ||||||
|  |  *           Generates the implementation of the library into the included file. | ||||||
|  |  *           If not defined, the library is in header only mode and can be included in other headers | ||||||
|  |  *           or source files without problems. But only ONE file should hold the implementation. | ||||||
|  |  * | ||||||
|  |  *       #define RCAMERA_STANDALONE | ||||||
|  |  *           If defined, the library can be used as standalone as a camera system but some | ||||||
|  |  *           functions must be redefined to manage inputs accordingly. | ||||||
|  |  * | ||||||
|  |  *   CONTRIBUTORS: | ||||||
|  |  *       Ramon Santamaria:   Supervision, review, update and maintenance | ||||||
|  |  *       Christoph Wagner:   Complete redesign, using raymath (2022) | ||||||
|  |  *       Marc Palau:         Initial implementation (2014) | ||||||
|  |  * | ||||||
|  |  * | ||||||
|  |  *   LICENSE: zlib/libpng | ||||||
|  |  * | ||||||
|  |  *   Copyright (c) 2022-2023 Christoph Wagner (@Crydsch) & Ramon Santamaria (@raysan5) | ||||||
|  |  * | ||||||
|  |  *   This software is provided "as-is", without any express or implied warranty. In no event | ||||||
|  |  *   will the authors be held liable for any damages arising from the use of this software. | ||||||
|  |  * | ||||||
|  |  *   Permission is granted to anyone to use this software for any purpose, including commercial | ||||||
|  |  *   applications, and to alter it and redistribute it freely, subject to the following restrictions: | ||||||
|  |  * | ||||||
|  |  *     1. The origin of this software must not be misrepresented; you must not claim that you | ||||||
|  |  *     wrote the original software. If you use this software in a product, an acknowledgment | ||||||
|  |  *     in the product documentation would be appreciated but is not required. | ||||||
|  |  * | ||||||
|  |  *     2. Altered source versions must be plainly marked as such, and must not be misrepresented | ||||||
|  |  *     as being the original software. | ||||||
|  |  * | ||||||
|  |  *     3. This notice may not be removed or altered from any source distribution. | ||||||
|  |  * | ||||||
|  |  **********************************************************************************************/ | ||||||
|  |  | ||||||
|  | #ifndef RCAMERA_H | ||||||
|  | #define RL_RCAMERA_H | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Defines and Macros | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Function specifiers definition | ||||||
|  |  | ||||||
|  | // Function specifiers in case library is build/used as a shared library (Windows) | ||||||
|  | // NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll | ||||||
|  | #if defined( _WIN32 ) | ||||||
|  | #if defined( BUILD_LIBTYPE_SHARED ) | ||||||
|  | #if defined( __TINYC__ ) | ||||||
|  | #define RL___declspec( x ) __attribute__( ( x ) ) | ||||||
|  | #endif | ||||||
|  | #elif defined( USE_LIBTYPE_SHARED ) | ||||||
|  | #endif | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #ifndef RLAPI | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #if defined( RCAMERA_STANDALONE ) | ||||||
|  | #define RL_CAMERA_CULL_DISTANCE_NEAR 0.01 | ||||||
|  | #define RL_CAMERA_CULL_DISTANCE_FAR  1000.0 | ||||||
|  | #else | ||||||
|  | #define RL_CAMERA_CULL_DISTANCE_NEAR RL_CULL_DISTANCE_NEAR | ||||||
|  | #define RL_CAMERA_CULL_DISTANCE_FAR  RL_CULL_DISTANCE_FAR | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Types and Structures Definition | ||||||
|  | // NOTE: Below types are required for standalone usage | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | #if defined( RCAMERA_STANDALONE ) | ||||||
|  | // Vector2, 2 components | ||||||
|  | typedef struct Vector2 | ||||||
|  | { | ||||||
|  | 	f32 x;    // Vector x component | ||||||
|  | 	f32 y;    // Vector y component | ||||||
|  |  | ||||||
|  | } Vector2; | ||||||
|  |  | ||||||
|  | // Vector3, 3 components | ||||||
|  | typedef struct Vector3 | ||||||
|  | { | ||||||
|  | 	f32 x;    // Vector x component | ||||||
|  | 	f32 y;    // Vector y component | ||||||
|  | 	f32 z;    // Vector z component | ||||||
|  |  | ||||||
|  | } Vector3; | ||||||
|  |  | ||||||
|  | // Matrix, 4x4 components, column major, OpenGL style, right-handed | ||||||
|  | typedef struct Matrix | ||||||
|  | { | ||||||
|  | 	f32 m0, m4, m8, m12;     // Matrix first row (4 components) | ||||||
|  | 	f32 m1, m5, m9, m13;     // Matrix second row (4 components) | ||||||
|  | 	f32 m2, m6, m10, m14;    // Matrix third row (4 components) | ||||||
|  | 	f32 m3, m7, m11, m15;    // Matrix fourth row (4 components) | ||||||
|  |  | ||||||
|  | } Matrix; | ||||||
|  |  | ||||||
|  | // Camera type, defines a camera position/orientation in 3d space | ||||||
|  | typedef struct Camera3D | ||||||
|  | { | ||||||
|  | 	Vector3 position;      // Camera position | ||||||
|  | 	Vector3 target;        // Camera target it looks-at | ||||||
|  | 	Vector3 up;            // Camera up vector (rotation over its axis) | ||||||
|  | 	f32     fovy;          // Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic | ||||||
|  | 	s32     projection;    // Camera projection type: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC | ||||||
|  |  | ||||||
|  | } Camera3D; | ||||||
|  |  | ||||||
|  | typedef Camera3D Camera;    // Camera type fallback, defaults to Camera3D | ||||||
|  |  | ||||||
|  | // Camera projection | ||||||
|  | typedef enum | ||||||
|  | { | ||||||
|  | 	Camera_Perspective = 0,    // Perspective projection | ||||||
|  | 	Camera_Orthographic        // orthographic projection | ||||||
|  |  | ||||||
|  | } CameraProjection; | ||||||
|  |  | ||||||
|  | // Camera system modes | ||||||
|  | typedef enum | ||||||
|  | { | ||||||
|  | 	Camera_Custom = 0,      // Camera custom, controlled by user (UpdateCamera() does nothing) | ||||||
|  | 	Camera_Free,            // Camera free mode | ||||||
|  | 	Camera_Orbital,         // Camera orbital, around target, zoom supported | ||||||
|  | 	Camera_First_Person,    // Camera first person | ||||||
|  | 	Camera_Third_Person     // camera third person | ||||||
|  |  | ||||||
|  | } CameraMode; | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Global Variables Definition | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | //... | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Module Functions Declaration | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|  | #if defined( __cplusplus ) | ||||||
|  | namespace raylib | ||||||
|  | { | ||||||
|  | 	extern "C" | ||||||
|  | 	{ | ||||||
|  | // Prevents name mangling of functions | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | 		RLAPI Vector3 get_camera_forward( Camera* camera ); | ||||||
|  | 		RLAPI Vector3 get_camera_up( Camera* camera ); | ||||||
|  | 		RLAPI Vector3 get_camera_right( Camera* camera ); | ||||||
|  |  | ||||||
|  | 		// Camera movement | ||||||
|  | 		RLAPI void camera_move_forward( Camera* camera, f32 distance, bool moveInWorldPlane ); | ||||||
|  | 		RLAPI void camera_move_up( Camera* camera, f32 distance ); | ||||||
|  | 		RLAPI void camera_move_right( Camera* camera, f32 distance, bool moveInWorldPlane ); | ||||||
|  | 		RLAPI void camera_move_to_target( Camera* camera, f32 delta ); | ||||||
|  |  | ||||||
|  | 		// Camera rotation | ||||||
|  | 		RLAPI void camera_yaw( Camera* camera, f32 angle, bool rotateAroundTarget ); | ||||||
|  | 		RLAPI void camera_pitch( Camera* camera, f32 angle, bool lockView, bool rotateAroundTarget, bool rotateUp ); | ||||||
|  | 		RLAPI void camera_roll( Camera* camera, f32 angle ); | ||||||
|  |  | ||||||
|  | 		RLAPI Matrix get_camera_view_matrix( Camera* camera ); | ||||||
|  | 		RLAPI Matrix get_camera_projection_matrix( Camera* camera, f32 aspect ); | ||||||
|  |  | ||||||
|  | #if defined( __cplusplus ) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #endif | ||||||
|  | // RCAMERA_H | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /*********************************************************************************** | ||||||
|  |  * | ||||||
|  |  *   CAMERA IMPLEMENTATION | ||||||
|  |  * | ||||||
|  |  ************************************************************************************/ | ||||||
|  |  | ||||||
|  | #if defined( RCAMERA_IMPLEMENTATION ) | ||||||
|  |  | ||||||
|  | #include "raymath.h" | ||||||
|  | // Required for vector maths: | ||||||
|  | // Vector3Add() | ||||||
|  | // Vector3Subtract() | ||||||
|  | // Vector3Scale() | ||||||
|  | // Vector3Normalize() | ||||||
|  | // Vector3Distance() | ||||||
|  | // Vector3CrossProduct() | ||||||
|  | // Vector3RotateByAxisAngle() | ||||||
|  | // Vector3Angle() | ||||||
|  | // Vector3Negate() | ||||||
|  | // MatrixLookAt() | ||||||
|  | // MatrixPerspective() | ||||||
|  | // MatrixOrtho() | ||||||
|  | // MatrixIdentity() | ||||||
|  |  | ||||||
|  | // raylib required functionality: | ||||||
|  | // GetMouseDelta() | ||||||
|  | // GetMouseWheelMove() | ||||||
|  | // IsKeyDown() | ||||||
|  | // IsKeyPressed() | ||||||
|  | // GetFrameTime() | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Defines and Macros | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | #define RL_CAMERA_MOVE_SPEED     0.09f | ||||||
|  | #define RL_CAMERA_ROTATION_SPEED 0.03f | ||||||
|  | #define RL_CAMERA_PAN_SPEED      0.2f | ||||||
|  |  | ||||||
|  | // Camera mouse movement sensitivity | ||||||
|  | #define RL_CAMERA_MOUSE_MOVE_SENSITIVITY                  0.003f    // TODO: it should be independant of framerate | ||||||
|  | #define RL_CAMERA_MOUSE_SCROLL_SENSITIVITY                1.5f | ||||||
|  |  | ||||||
|  | #define RL_CAMERA_ORBITAL_SPEED                           0.5f    // Radians per second | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #define RL_CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER 8.0f | ||||||
|  | #define RL_CAMERA_FIRST_PERSON_STEP_DIVIDER               30.0f | ||||||
|  | #define RL_CAMERA_FIRST_PERSON_WAVING_DIVIDER             200.0f | ||||||
|  |  | ||||||
|  | // PLAYER (used by camera) | ||||||
|  | #define RL_PLAYER_MOVEMENT_SENSITIVITY 20.0f | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Types and Structures Definition | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | //... | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Global Variables Definition | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | //... | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Module specific Functions Declaration | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | //... | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Module Functions Definition | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Returns the cameras forward vector (normalized) | ||||||
|  | Vector3 get_camera_forward( Camera* camera ) | ||||||
|  | { | ||||||
|  | 	return Vector3Normalize( Vector3Subtract( camera->target, camera->position ) ); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Returns the cameras up vector (normalized) | ||||||
|  | // Note: The up vector might not be perpendicular to the forward vector | ||||||
|  | Vector3 get_camera_up( Camera* camera ) | ||||||
|  | { | ||||||
|  | 	return Vector3Normalize( camera->up ); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Returns the cameras right vector (normalized) | ||||||
|  | Vector3 get_camera_right( Camera* camera ) | ||||||
|  | { | ||||||
|  | 	Vector3 forward = GetCameraForward( camera ); | ||||||
|  | 	Vector3 up      = GetCameraUp( camera ); | ||||||
|  |  | ||||||
|  | 	return Vector3CrossProduct( forward, up ); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Moves the camera in its forward direction | ||||||
|  | void camera_move_forward( Camera* camera, f32 distance, bool moveInWorldPlane ) | ||||||
|  | { | ||||||
|  | 	Vector3 forward = GetCameraForward( camera ); | ||||||
|  |  | ||||||
|  | 	if ( moveInWorldPlane ) | ||||||
|  | 	{ | ||||||
|  | 		// Project vector onto world plane | ||||||
|  | 		forward.y = 0; | ||||||
|  | 		forward   = Vector3Normalize( forward ); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Scale by distance | ||||||
|  | 	forward = Vector3Scale( forward, distance ); | ||||||
|  |  | ||||||
|  | 	// Move position and target | ||||||
|  | 	camera->position = Vector3Add( camera->position, forward ); | ||||||
|  | 	camera->target   = Vector3Add( camera->target, forward ); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Moves the camera in its up direction | ||||||
|  | void camera_move_up( Camera* camera, f32 distance ) | ||||||
|  | { | ||||||
|  | 	Vector3 up = GetCameraUp( camera ); | ||||||
|  |  | ||||||
|  | 	// Scale by distance | ||||||
|  | 	up = Vector3Scale( up, distance ); | ||||||
|  |  | ||||||
|  | 	// Move position and target | ||||||
|  | 	camera->position = Vector3Add( camera->position, up ); | ||||||
|  | 	camera->target   = Vector3Add( camera->target, up ); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Moves the camera target in its current right direction | ||||||
|  | void camera_move_right( Camera* camera, f32 distance, bool moveInWorldPlane ) | ||||||
|  | { | ||||||
|  | 	Vector3 right = GetCameraRight( camera ); | ||||||
|  |  | ||||||
|  | 	if ( moveInWorldPlane ) | ||||||
|  | 	{ | ||||||
|  | 		// Project vector onto world plane | ||||||
|  | 		right.y = 0; | ||||||
|  | 		right   = Vector3Normalize( right ); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Scale by distance | ||||||
|  | 	right = Vector3Scale( right, distance ); | ||||||
|  |  | ||||||
|  | 	// Move position and target | ||||||
|  | 	camera->position = Vector3Add( camera->position, right ); | ||||||
|  | 	camera->target   = Vector3Add( camera->target, right ); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Moves the camera position closer/farther to/from the camera target | ||||||
|  | void camera_move_to_target( Camera* camera, f32 delta ) | ||||||
|  | { | ||||||
|  | 	float distance = Vector3Distance( camera->position, camera->target ); | ||||||
|  |  | ||||||
|  | 	// Apply delta | ||||||
|  | 	distance += delta; | ||||||
|  |  | ||||||
|  | 	// Distance must be greater than 0 | ||||||
|  | 	if ( distance <= 0 ) | ||||||
|  | 		distance = 0.001f; | ||||||
|  |  | ||||||
|  | 	// Set new distance by moving the position along the forward vector | ||||||
|  | 	Vector3 forward  = GetCameraForward( camera ); | ||||||
|  | 	camera->position = Vector3Add( camera->target, Vector3Scale( forward, -distance ) ); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Rotates the camera around its up vector | ||||||
|  | // Yaw is "looking left and right" | ||||||
|  | // If rotateAroundTarget is false, the camera rotates around its position | ||||||
|  | // Note: angle must be provided in radians | ||||||
|  | void camera_yaw( Camera* camera, f32 angle, bool rotateAroundTarget ) | ||||||
|  | { | ||||||
|  | 	Vector3 up = GetCameraUp( camera ); | ||||||
|  |  | ||||||
|  | 	// View vector | ||||||
|  | 	Vector3 targetPosition = Vector3Subtract( camera->target, camera->position ); | ||||||
|  |  | ||||||
|  | 	// Rotate view vector around up axis | ||||||
|  | 	targetPosition = Vector3RotateByAxisAngle( targetPosition, up, angle ); | ||||||
|  |  | ||||||
|  | 	if ( rotateAroundTarget ) | ||||||
|  | 	{ | ||||||
|  | 		// Move position relative to target | ||||||
|  | 		camera->position = Vector3Subtract( camera->target, targetPosition ); | ||||||
|  | 	} | ||||||
|  | 	else    // rotate around camera.position | ||||||
|  | 	{ | ||||||
|  | 		// Move target relative to position | ||||||
|  | 		camera->target = Vector3Add( camera->position, targetPosition ); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Rotates the camera around its right vector, pitch is "looking up and down" | ||||||
|  | //  - lockView prevents camera overrotation (aka "somersaults") | ||||||
|  | //  - rotateAroundTarget defines if rotation is around target or around its position | ||||||
|  | //  - rotateUp rotates the up direction as well (typically only usefull in CAMERA_FREE) | ||||||
|  | // NOTE: angle must be provided in radians | ||||||
|  | void camera_pitch( Camera* camera, f32 angle, bool lockView, bool rotateAroundTarget, bool rotateUp ) | ||||||
|  | { | ||||||
|  | 	Vector3 up = GetCameraUp( camera ); | ||||||
|  |  | ||||||
|  | 	// View vector | ||||||
|  | 	Vector3 targetPosition = Vector3Subtract( camera->target, camera->position ); | ||||||
|  |  | ||||||
|  | 	if ( lockView ) | ||||||
|  | 	{ | ||||||
|  | 		// In these camera modes we clamp the Pitch angle | ||||||
|  | 		// to allow only viewing straight up or down. | ||||||
|  |  | ||||||
|  | 		// Clamp view up | ||||||
|  | 		float maxAngleUp  = Vector3Angle( up, targetPosition ); | ||||||
|  | 		maxAngleUp       -= 0.001f;    // avoid numerical errors | ||||||
|  | 		if ( angle > maxAngleUp ) | ||||||
|  | 			angle = maxAngleUp; | ||||||
|  |  | ||||||
|  | 		// Clamp view down | ||||||
|  | 		float maxAngleDown  = Vector3Angle( Vector3Negate( up ), targetPosition ); | ||||||
|  | 		maxAngleDown       *= -1.0f;     // downwards angle is negative | ||||||
|  | 		maxAngleDown       += 0.001f;    // avoid numerical errors | ||||||
|  | 		if ( angle < maxAngleDown ) | ||||||
|  | 			angle = maxAngleDown; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Rotation axis | ||||||
|  | 	Vector3 right = GetCameraRight( camera ); | ||||||
|  |  | ||||||
|  | 	// Rotate view vector around right axis | ||||||
|  | 	targetPosition = Vector3RotateByAxisAngle( targetPosition, right, angle ); | ||||||
|  |  | ||||||
|  | 	if ( rotateAroundTarget ) | ||||||
|  | 	{ | ||||||
|  | 		// Move position relative to target | ||||||
|  | 		camera->position = Vector3Subtract( camera->target, targetPosition ); | ||||||
|  | 	} | ||||||
|  | 	else    // rotate around camera.position | ||||||
|  | 	{ | ||||||
|  | 		// Move target relative to position | ||||||
|  | 		camera->target = Vector3Add( camera->position, targetPosition ); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if ( rotateUp ) | ||||||
|  | 	{ | ||||||
|  | 		// Rotate up direction around right axis | ||||||
|  | 		camera->up = Vector3RotateByAxisAngle( camera->up, right, angle ); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Rotates the camera around its forward vector | ||||||
|  | // Roll is "turning your head sideways to the left or right" | ||||||
|  | // Note: angle must be provided in radians | ||||||
|  | void camera_roll( Camera* camera, f32 angle ) | ||||||
|  | { | ||||||
|  | 	Vector3 forward = GetCameraForward( camera ); | ||||||
|  |  | ||||||
|  | 	// Rotate up direction around forward axis | ||||||
|  | 	camera->up = Vector3RotateByAxisAngle( camera->up, forward, angle ); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Returns the camera view matrix | ||||||
|  | Matrix get_camera_view_matrix( Camera* camera ) | ||||||
|  | { | ||||||
|  | 	return MatrixLookAt( camera->position, camera->target, camera->up ); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Returns the camera projection matrix | ||||||
|  | Matrix get_camera_projection_matrix( Camera* camera, f32 aspect ) | ||||||
|  | { | ||||||
|  | 	if ( camera->projection == CAMERA_PERSPECTIVE ) | ||||||
|  | 	{ | ||||||
|  | 		return MatrixPerspective( camera->fovy * DEG2RAD, aspect, CAMERA_CULL_DISTANCE_NEAR, CAMERA_CULL_DISTANCE_FAR ); | ||||||
|  | 	} | ||||||
|  | 	else if ( camera->projection == CAMERA_ORTHOGRAPHIC ) | ||||||
|  | 	{ | ||||||
|  | 		double top   = camera->fovy / 2.0; | ||||||
|  | 		double right = top * aspect; | ||||||
|  |  | ||||||
|  | 		return MatrixOrtho( -right, right, -top, top, CAMERA_CULL_DISTANCE_NEAR, CAMERA_CULL_DISTANCE_FAR ); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return MatrixIdentity(); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | #if ! defined( RCAMERA_STANDALONE ) | ||||||
|  | // Update camera position for selected mode | ||||||
|  | // Camera mode: CAMERA_FREE, CAMERA_FIRST_PERSON, CAMERA_THIRD_PERSON, CAMERA_ORBITAL or CUSTOM | ||||||
|  | void update_camera( Camera* camera, s32 mode ) | ||||||
|  | { | ||||||
|  | 	Vector2 mousePositionDelta = GetMouseDelta(); | ||||||
|  |  | ||||||
|  | 	bool moveInWorldPlane      = ( ( mode == CAMERA_FIRST_PERSON ) || ( mode == CAMERA_THIRD_PERSON ) ); | ||||||
|  | 	bool rotateAroundTarget    = ( ( mode == CAMERA_THIRD_PERSON ) || ( mode == CAMERA_ORBITAL ) ); | ||||||
|  | 	bool lockView              = ( ( mode == CAMERA_FIRST_PERSON ) || ( mode == CAMERA_THIRD_PERSON ) || ( mode == CAMERA_ORBITAL ) ); | ||||||
|  | 	bool rotateUp              = false; | ||||||
|  |  | ||||||
|  | 	if ( mode == CAMERA_ORBITAL ) | ||||||
|  | 	{ | ||||||
|  | 		// Orbital can just orbit | ||||||
|  | 		Matrix  rotation = MatrixRotate( GetCameraUp( camera ), CAMERA_ORBITAL_SPEED * GetFrameTime() ); | ||||||
|  | 		Vector3 view     = Vector3Subtract( camera->position, camera->target ); | ||||||
|  | 		view             = Vector3Transform( view, rotation ); | ||||||
|  | 		camera->position = Vector3Add( camera->target, view ); | ||||||
|  | 	} | ||||||
|  | 	else | ||||||
|  | 	{ | ||||||
|  | 		// Camera rotation | ||||||
|  | 		if ( IsKeyDown( KEY_DOWN ) ) | ||||||
|  | 			CameraPitch( camera, -CAMERA_ROTATION_SPEED, lockView, rotateAroundTarget, rotateUp ); | ||||||
|  | 		if ( IsKeyDown( KEY_UP ) ) | ||||||
|  | 			CameraPitch( camera, CAMERA_ROTATION_SPEED, lockView, rotateAroundTarget, rotateUp ); | ||||||
|  | 		if ( IsKeyDown( KEY_RIGHT ) ) | ||||||
|  | 			CameraYaw( camera, -CAMERA_ROTATION_SPEED, rotateAroundTarget ); | ||||||
|  | 		if ( IsKeyDown( KEY_LEFT ) ) | ||||||
|  | 			CameraYaw( camera, CAMERA_ROTATION_SPEED, rotateAroundTarget ); | ||||||
|  | 		if ( IsKeyDown( KEY_Q ) ) | ||||||
|  | 			CameraRoll( camera, -CAMERA_ROTATION_SPEED ); | ||||||
|  | 		if ( IsKeyDown( KEY_E ) ) | ||||||
|  | 			CameraRoll( camera, CAMERA_ROTATION_SPEED ); | ||||||
|  |  | ||||||
|  | 		// Camera movement | ||||||
|  | 		if ( ! IsGamepadAvailable( 0 ) ) | ||||||
|  | 		{ | ||||||
|  | 			// Camera pan (for CAMERA_FREE) | ||||||
|  | 			if ( ( mode == CAMERA_FREE ) && ( IsMouseButtonDown( MOUSE_BUTTON_MIDDLE ) ) ) | ||||||
|  | 			{ | ||||||
|  | 				const Vector2 mouseDelta = GetMouseDelta(); | ||||||
|  | 				if ( mouseDelta.x > 0.0f ) | ||||||
|  | 					CameraMoveRight( camera, CAMERA_PAN_SPEED, moveInWorldPlane ); | ||||||
|  | 				if ( mouseDelta.x < 0.0f ) | ||||||
|  | 					CameraMoveRight( camera, -CAMERA_PAN_SPEED, moveInWorldPlane ); | ||||||
|  | 				if ( mouseDelta.y > 0.0f ) | ||||||
|  | 					CameraMoveUp( camera, -CAMERA_PAN_SPEED ); | ||||||
|  | 				if ( mouseDelta.y < 0.0f ) | ||||||
|  | 					CameraMoveUp( camera, CAMERA_PAN_SPEED ); | ||||||
|  | 			} | ||||||
|  | 			else | ||||||
|  | 			{ | ||||||
|  | 				// Mouse support | ||||||
|  | 				CameraYaw( camera, -mousePositionDelta.x * CAMERA_MOUSE_MOVE_SENSITIVITY, rotateAroundTarget ); | ||||||
|  | 				CameraPitch( camera, -mousePositionDelta.y * CAMERA_MOUSE_MOVE_SENSITIVITY, lockView, rotateAroundTarget, rotateUp ); | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			// Keyboard support | ||||||
|  | 			if ( IsKeyDown( KEY_W ) ) | ||||||
|  | 				CameraMoveForward( camera, CAMERA_MOVE_SPEED, moveInWorldPlane ); | ||||||
|  | 			if ( IsKeyDown( KEY_A ) ) | ||||||
|  | 				CameraMoveRight( camera, -CAMERA_MOVE_SPEED, moveInWorldPlane ); | ||||||
|  | 			if ( IsKeyDown( KEY_S ) ) | ||||||
|  | 				CameraMoveForward( camera, -CAMERA_MOVE_SPEED, moveInWorldPlane ); | ||||||
|  | 			if ( IsKeyDown( KEY_D ) ) | ||||||
|  | 				CameraMoveRight( camera, CAMERA_MOVE_SPEED, moveInWorldPlane ); | ||||||
|  | 		} | ||||||
|  | 		else | ||||||
|  | 		{ | ||||||
|  | 			// Gamepad controller support | ||||||
|  | 			CameraYaw( camera, -( GetGamepadAxisMovement( 0, GAMEPAD_AXIS_RIGHT_X ) * 2 ) * CAMERA_MOUSE_MOVE_SENSITIVITY, rotateAroundTarget ); | ||||||
|  | 			CameraPitch( | ||||||
|  | 			    camera, | ||||||
|  | 			    -( GetGamepadAxisMovement( 0, GAMEPAD_AXIS_RIGHT_Y ) * 2 ) * CAMERA_MOUSE_MOVE_SENSITIVITY, | ||||||
|  | 			    lockView, | ||||||
|  | 			    rotateAroundTarget, | ||||||
|  | 			    rotateUp | ||||||
|  | 			); | ||||||
|  |  | ||||||
|  | 			if ( GetGamepadAxisMovement( 0, GAMEPAD_AXIS_LEFT_Y ) <= -0.25f ) | ||||||
|  | 				CameraMoveForward( camera, CAMERA_MOVE_SPEED, moveInWorldPlane ); | ||||||
|  | 			if ( GetGamepadAxisMovement( 0, GAMEPAD_AXIS_LEFT_X ) <= -0.25f ) | ||||||
|  | 				CameraMoveRight( camera, -CAMERA_MOVE_SPEED, moveInWorldPlane ); | ||||||
|  | 			if ( GetGamepadAxisMovement( 0, GAMEPAD_AXIS_LEFT_Y ) >= 0.25f ) | ||||||
|  | 				CameraMoveForward( camera, -CAMERA_MOVE_SPEED, moveInWorldPlane ); | ||||||
|  | 			if ( GetGamepadAxisMovement( 0, GAMEPAD_AXIS_LEFT_X ) >= 0.25f ) | ||||||
|  | 				CameraMoveRight( camera, CAMERA_MOVE_SPEED, moveInWorldPlane ); | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		if ( mode == CAMERA_FREE ) | ||||||
|  | 		{ | ||||||
|  | 			if ( IsKeyDown( KEY_SPACE ) ) | ||||||
|  | 				CameraMoveUp( camera, CAMERA_MOVE_SPEED ); | ||||||
|  | 			if ( IsKeyDown( KEY_LEFT_CONTROL ) ) | ||||||
|  | 				CameraMoveUp( camera, -CAMERA_MOVE_SPEED ); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if ( ( mode == CAMERA_THIRD_PERSON ) || ( mode == CAMERA_ORBITAL ) || ( mode == CAMERA_FREE ) ) | ||||||
|  | 	{ | ||||||
|  | 		// Zoom target distance | ||||||
|  | 		CameraMoveToTarget( camera, -GetMouseWheelMove() ); | ||||||
|  | 		if ( IsKeyPressed( KEY_KP_SUBTRACT ) ) | ||||||
|  | 			CameraMoveToTarget( camera, 2.0f ); | ||||||
|  | 		if ( IsKeyPressed( KEY_KP_ADD ) ) | ||||||
|  | 			CameraMoveToTarget( camera, -2.0f ); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  | // !RCAMERA_STANDALONE | ||||||
|  |  | ||||||
|  | // Update camera movement, movement/rotation values should be provided by user | ||||||
|  | void update_camera_pro( Camera* camera, Vector3 movement, Vector3 rotation, f32 zoom ) | ||||||
|  | { | ||||||
|  | 	bool lockView           = true; | ||||||
|  | 	bool rotateAroundTarget = false; | ||||||
|  | 	bool rotateUp           = false; | ||||||
|  | 	bool moveInWorldPlane   = true; | ||||||
|  |  | ||||||
|  | 	// Camera rotation | ||||||
|  | 	CameraPitch( camera, -rotation.y * DEG2RAD, lockView, rotateAroundTarget, rotateUp ); | ||||||
|  | 	CameraYaw( camera, -rotation.x * DEG2RAD, rotateAroundTarget ); | ||||||
|  | 	CameraRoll( camera, rotation.z * DEG2RAD ); | ||||||
|  |  | ||||||
|  | 	// Camera movement | ||||||
|  | 	CameraMoveForward( camera, movement.x, moveInWorldPlane ); | ||||||
|  | 	CameraMoveRight( camera, movement.y, moveInWorldPlane ); | ||||||
|  | 	CameraMoveUp( camera, movement.z ); | ||||||
|  |  | ||||||
|  | 	// Zoom target distance | ||||||
|  | 	CameraMoveToTarget( camera, zoom ); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | #endif | ||||||
|  | // RCAMERA_IMPLEMENTATION | ||||||
							
								
								
									
										233
									
								
								project/auxillary/vis_ast/dependencies/raylib/include/rcore.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										233
									
								
								project/auxillary/vis_ast/dependencies/raylib/include/rcore.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,233 @@ | |||||||
|  | /********************************************************************************************** | ||||||
|  |  * | ||||||
|  |  *   rcore - Common types and globals (all platforms) | ||||||
|  |  * | ||||||
|  |  *   LIMITATIONS: | ||||||
|  |  *       - Limitation 01 | ||||||
|  |  *       - Limitation 02 | ||||||
|  |  * | ||||||
|  |  *   POSSIBLE IMPROVEMENTS: | ||||||
|  |  *       - Improvement 01 | ||||||
|  |  *       - Improvement 02 | ||||||
|  |  * | ||||||
|  |  * | ||||||
|  |  *   LICENSE: zlib/libpng | ||||||
|  |  * | ||||||
|  |  *   Copyright (c) 2013-2023 Ramon Santamaria (@raysan5) and contributors | ||||||
|  |  * | ||||||
|  |  *   This software is provided "as-is", without any express or implied warranty. In no event | ||||||
|  |  *   will the authors be held liable for any damages arising from the use of this software. | ||||||
|  |  * | ||||||
|  |  *   Permission is granted to anyone to use this software for any purpose, including commercial | ||||||
|  |  *   applications, and to alter it and redistribute it freely, subject to the following restrictions: | ||||||
|  |  * | ||||||
|  |  *     1. The origin of this software must not be misrepresented; you must not claim that you | ||||||
|  |  *     wrote the original software. If you use this software in a product, an acknowledgment | ||||||
|  |  *     in the product documentation would be appreciated but is not required. | ||||||
|  |  * | ||||||
|  |  *     2. Altered source versions must be plainly marked as such, and must not be misrepresented | ||||||
|  |  *     as being the original software. | ||||||
|  |  * | ||||||
|  |  *     3. This notice may not be removed or altered from any source distribution. | ||||||
|  |  * | ||||||
|  |  **********************************************************************************************/ | ||||||
|  |  | ||||||
|  | #ifndef RCORE_H | ||||||
|  | #define RCORE_H | ||||||
|  |  | ||||||
|  | #include "raylib.h" | ||||||
|  |  | ||||||
|  | #include "utils.h"    // Required for: TRACELOG() macros | ||||||
|  |  | ||||||
|  | #include "rlgl.h"    // Required for: graphics layer functionality | ||||||
|  |  | ||||||
|  | #define RAYMATH_IMPLEMENTATION | ||||||
|  | #include "raymath.h"    // Required for: Vector2/Vector3/Matrix functionality | ||||||
|  |  | ||||||
|  | #include <stdlib.h>    // Required for: srand(), rand(), atexit() | ||||||
|  | #include <stdio.h>     // Required for: sprintf() [Used in OpenURL()] | ||||||
|  | #include <string.h>    // Required for: strrchr(), strcmp(), strlen(), memset() | ||||||
|  | #include <time.h>      // Required for: time() [Used in InitTimer()] | ||||||
|  | #include <math.h>      // Required for: tan() [Used in BeginMode3D()], atan2f() [Used in LoadVrStereoConfig()] | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Defines and Macros | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | #ifndef MAX_FILEPATH_CAPACITY | ||||||
|  | #define MAX_FILEPATH_CAPACITY 8192    // Maximum capacity for filepath | ||||||
|  | #endif | ||||||
|  | #ifndef MAX_FILEPATH_LENGTH | ||||||
|  | #define MAX_FILEPATH_LENGTH 4096    // Maximum length for filepaths (Linux PATH_MAX default value) | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #ifndef MAX_KEYBOARD_KEYS | ||||||
|  | #define MAX_KEYBOARD_KEYS 512    // Maximum number of keyboard keys supported | ||||||
|  | #endif | ||||||
|  | #ifndef MAX_MOUSE_BUTTONS | ||||||
|  | #define MAX_MOUSE_BUTTONS 8    // Maximum number of mouse buttons supported | ||||||
|  | #endif | ||||||
|  | #ifndef MAX_GAMEPADS | ||||||
|  | #define MAX_GAMEPADS 4    // Maximum number of gamepads supported | ||||||
|  | #endif | ||||||
|  | #ifndef MAX_GAMEPAD_AXIS | ||||||
|  | #define MAX_GAMEPAD_AXIS 8    // Maximum number of axis supported (per gamepad) | ||||||
|  | #endif | ||||||
|  | #ifndef MAX_GAMEPAD_BUTTONS | ||||||
|  | #define MAX_GAMEPAD_BUTTONS 32    // Maximum number of buttons supported (per gamepad) | ||||||
|  | #endif | ||||||
|  | #ifndef MAX_TOUCH_POINTS | ||||||
|  | #define MAX_TOUCH_POINTS 8    // Maximum number of touch points supported | ||||||
|  | #endif | ||||||
|  | #ifndef MAX_KEY_PRESSED_QUEUE | ||||||
|  | #define MAX_KEY_PRESSED_QUEUE 16    // Maximum number of keys in the key input queue | ||||||
|  | #endif | ||||||
|  | #ifndef MAX_CHAR_PRESSED_QUEUE | ||||||
|  | #define MAX_CHAR_PRESSED_QUEUE 16    // Maximum number of characters in the char input queue | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #ifndef MAX_DECOMPRESSION_SIZE | ||||||
|  | #define MAX_DECOMPRESSION_SIZE 64    // Maximum size allocated for decompression in MB | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | // Flags operation macros | ||||||
|  | #define FLAG_SET( n, f )    ( ( n ) |= ( f ) ) | ||||||
|  | #define FLAG_CLEAR( n, f )  ( ( n ) &= ~( f ) ) | ||||||
|  | #define FLAG_TOGGLE( n, f ) ( ( n ) ^= ( f ) ) | ||||||
|  | #define FLAG_CHECK( n, f )  ( ( n ) & ( f ) ) | ||||||
|  |  | ||||||
|  | #if ( defined( __linux__ ) || defined( PLATFORM_WEB ) ) && ( _POSIX_C_SOURCE < 199309L ) | ||||||
|  | #undef _POSIX_C_SOURCE | ||||||
|  | #define _POSIX_C_SOURCE 199309L    // Required for: CLOCK_MONOTONIC if compiled with c99 without gnu ext. | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Types and Structures Definition | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | typedef struct | ||||||
|  | { | ||||||
|  | 	int x; | ||||||
|  | 	int y; | ||||||
|  | } Point; | ||||||
|  |  | ||||||
|  | typedef struct | ||||||
|  | { | ||||||
|  | 	unsigned int width; | ||||||
|  | 	unsigned int height; | ||||||
|  | } Size; | ||||||
|  |  | ||||||
|  | // Core global state context data | ||||||
|  | typedef struct CoreData | ||||||
|  | { | ||||||
|  | 	struct | ||||||
|  | 	{ | ||||||
|  | 		const char*  title;               // Window text title const pointer | ||||||
|  | 		unsigned int flags;               // Configuration flags (bit based), keeps window state | ||||||
|  | 		bool         ready;               // Check if window has been initialized successfully | ||||||
|  | 		bool         fullscreen;          // Check if fullscreen mode is enabled | ||||||
|  | 		bool         shouldClose;         // Check if window set for closing | ||||||
|  | 		bool         resizedLastFrame;    // Check if window has been resized last frame | ||||||
|  | 		bool         eventWaiting;        // Wait for events before ending frame | ||||||
|  |  | ||||||
|  | 		Point  position;            // Window position (required on fullscreen toggle) | ||||||
|  | 		Point  previousPosition;    // Window previous position (required on borderless windowed toggle) | ||||||
|  | 		Size   display;             // Display width and height (monitor, device-screen, LCD, ...) | ||||||
|  | 		Size   screen;              // Screen width and height (used render area) | ||||||
|  | 		Size   previousScreen;      // Screen previous width and height (required on borderless windowed toggle) | ||||||
|  | 		Size   currentFbo;          // Current render width and height (depends on active fbo) | ||||||
|  | 		Size   render;              // Framebuffer width and height (render area, including black bars if required) | ||||||
|  | 		Point  renderOffset;        // Offset from render area (must be divided by 2) | ||||||
|  | 		Size   screenMin;           // Screen minimum width and height (for resizable window) | ||||||
|  | 		Size   screenMax;           // Screen maximum width and height (for resizable window) | ||||||
|  | 		Matrix screenScale;         // Matrix to scale screen (framebuffer rendering) | ||||||
|  |  | ||||||
|  | 		char**       dropFilepaths;    // Store dropped files paths pointers (provided by GLFW) | ||||||
|  | 		unsigned int dropFileCount;    // Count dropped files strings | ||||||
|  |  | ||||||
|  | 	} Window; | ||||||
|  |  | ||||||
|  | 	struct | ||||||
|  | 	{ | ||||||
|  | 		const char* basePath;    // Base path for data storage | ||||||
|  |  | ||||||
|  | 	} Storage; | ||||||
|  |  | ||||||
|  | 	struct | ||||||
|  | 	{ | ||||||
|  | 		struct | ||||||
|  | 		{ | ||||||
|  | 			int  exitKey;                                  // Default exit key | ||||||
|  | 			char currentKeyState[ MAX_KEYBOARD_KEYS ];     // Registers current frame key state | ||||||
|  | 			char previousKeyState[ MAX_KEYBOARD_KEYS ];    // Registers previous frame key state | ||||||
|  |  | ||||||
|  | 			// NOTE: Since key press logic involves comparing prev vs cur key state, we need to handle key repeats specially | ||||||
|  | 			char keyRepeatInFrame[ MAX_KEYBOARD_KEYS ];    // Registers key repeats for current frame. | ||||||
|  |  | ||||||
|  | 			int keyPressedQueue[ MAX_KEY_PRESSED_QUEUE ];    // Input keys queue | ||||||
|  | 			int keyPressedQueueCount;                        // Input keys queue count | ||||||
|  |  | ||||||
|  | 			int charPressedQueue[ MAX_CHAR_PRESSED_QUEUE ];    // Input characters queue (unicode) | ||||||
|  | 			int charPressedQueueCount;                         // Input characters queue count | ||||||
|  |  | ||||||
|  | 		} Keyboard; | ||||||
|  |  | ||||||
|  | 		struct | ||||||
|  | 		{ | ||||||
|  | 			Vector2 offset;              // Mouse offset | ||||||
|  | 			Vector2 scale;               // Mouse scaling | ||||||
|  | 			Vector2 currentPosition;     // Mouse position on screen | ||||||
|  | 			Vector2 previousPosition;    // Previous mouse position | ||||||
|  |  | ||||||
|  | 			int  cursor;            // Tracks current mouse cursor | ||||||
|  | 			bool cursorHidden;      // Track if cursor is hidden | ||||||
|  | 			bool cursorOnScreen;    // Tracks if cursor is inside client area | ||||||
|  |  | ||||||
|  | 			char    currentButtonState[ MAX_MOUSE_BUTTONS ];     // Registers current mouse button state | ||||||
|  | 			char    previousButtonState[ MAX_MOUSE_BUTTONS ];    // Registers previous mouse button state | ||||||
|  | 			Vector2 currentWheelMove;                            // Registers current mouse wheel variation | ||||||
|  | 			Vector2 previousWheelMove;                           // Registers previous mouse wheel variation | ||||||
|  |  | ||||||
|  | 		} Mouse; | ||||||
|  |  | ||||||
|  | 		struct | ||||||
|  | 		{ | ||||||
|  | 			int     pointCount;                                // Number of touch points active | ||||||
|  | 			int     pointId[ MAX_TOUCH_POINTS ];               // Point identifiers | ||||||
|  | 			Vector2 position[ MAX_TOUCH_POINTS ];              // Touch position on screen | ||||||
|  | 			char    currentTouchState[ MAX_TOUCH_POINTS ];     // Registers current touch state | ||||||
|  | 			char    previousTouchState[ MAX_TOUCH_POINTS ];    // Registers previous touch state | ||||||
|  |  | ||||||
|  | 		} Touch; | ||||||
|  |  | ||||||
|  | 		struct | ||||||
|  | 		{ | ||||||
|  | 			int   lastButtonPressed;                                             // Register last gamepad button pressed | ||||||
|  | 			int   axisCount[ MAX_GAMEPADS ];                                     // Register number of available gamepad axis | ||||||
|  | 			bool  ready[ MAX_GAMEPADS ];                                         // Flag to know if gamepad is ready | ||||||
|  | 			char  name[ MAX_GAMEPADS ][ 64 ];                                    // Gamepad name holder | ||||||
|  | 			char  currentButtonState[ MAX_GAMEPADS ][ MAX_GAMEPAD_BUTTONS ];     // Current gamepad buttons state | ||||||
|  | 			char  previousButtonState[ MAX_GAMEPADS ][ MAX_GAMEPAD_BUTTONS ];    // Previous gamepad buttons state | ||||||
|  | 			float axisState[ MAX_GAMEPADS ][ MAX_GAMEPAD_AXIS ];                 // Gamepad axis state | ||||||
|  |  | ||||||
|  | 		} Gamepad; | ||||||
|  | 	} Input; | ||||||
|  |  | ||||||
|  | 	struct | ||||||
|  | 	{ | ||||||
|  | 		double                 current;         // Current time measure | ||||||
|  | 		double                 previous;        // Previous time measure | ||||||
|  | 		double                 update;          // Time measure for frame update | ||||||
|  | 		double                 draw;            // Time measure for frame draw | ||||||
|  | 		double                 frame;           // Time measure for one frame | ||||||
|  | 		double                 target;          // Desired time for one frame, if 0 not applied | ||||||
|  | 		unsigned long long int base;            // Base time measure for hi-res timer (PLATFORM_ANDROID, PLATFORM_DRM) | ||||||
|  | 		unsigned int           frameCounter;    // Frame counter | ||||||
|  |  | ||||||
|  | 	} Time; | ||||||
|  | } CoreData; | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Global Variables Definition | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | extern CoreData CORE; | ||||||
|  |  | ||||||
|  | #endif | ||||||
| @@ -0,0 +1,594 @@ | |||||||
|  | /********************************************************************************************** | ||||||
|  |  * | ||||||
|  |  *   rgestures - Gestures system, gestures processing based on input events (touch/mouse) | ||||||
|  |  * | ||||||
|  |  *   CONFIGURATION: | ||||||
|  |  *       #define RGESTURES_IMPLEMENTATION | ||||||
|  |  *           Generates the implementation of the library into the included file. | ||||||
|  |  *           If not defined, the library is in header only mode and can be included in other headers | ||||||
|  |  *           or source files without problems. But only ONE file should hold the implementation. | ||||||
|  |  * | ||||||
|  |  *       #define RGESTURES_STANDALONE | ||||||
|  |  *           If defined, the library can be used as standalone to process gesture events with | ||||||
|  |  *           no external dependencies. | ||||||
|  |  * | ||||||
|  |  *   CONTRIBUTORS: | ||||||
|  |  *       Marc Palau:         Initial implementation (2014) | ||||||
|  |  *       Albert Martos:      Complete redesign and testing (2015) | ||||||
|  |  *       Ian Eito:           Complete redesign and testing (2015) | ||||||
|  |  *       Ramon Santamaria:   Supervision, review, update and maintenance | ||||||
|  |  * | ||||||
|  |  * | ||||||
|  |  *   LICENSE: zlib/libpng | ||||||
|  |  * | ||||||
|  |  *   Copyright (c) 2014-2023 Ramon Santamaria (@raysan5) | ||||||
|  |  * | ||||||
|  |  *   This software is provided "as-is", without any express or implied warranty. In no event | ||||||
|  |  *   will the authors be held liable for any damages arising from the use of this software. | ||||||
|  |  * | ||||||
|  |  *   Permission is granted to anyone to use this software for any purpose, including commercial | ||||||
|  |  *   applications, and to alter it and redistribute it freely, subject to the following restrictions: | ||||||
|  |  * | ||||||
|  |  *     1. The origin of this software must not be misrepresented; you must not claim that you | ||||||
|  |  *     wrote the original software. If you use this software in a product, an acknowledgment | ||||||
|  |  *     in the product documentation would be appreciated but is not required. | ||||||
|  |  * | ||||||
|  |  *     2. Altered source versions must be plainly marked as such, and must not be misrepresented | ||||||
|  |  *     as being the original software. | ||||||
|  |  * | ||||||
|  |  *     3. This notice may not be removed or altered from any source distribution. | ||||||
|  |  * | ||||||
|  |  **********************************************************************************************/ | ||||||
|  |  | ||||||
|  | #ifndef RGESTURES_H | ||||||
|  | #define RGESTURES_H | ||||||
|  |  | ||||||
|  | #ifndef PI | ||||||
|  | #define PI 3.14159265358979323846 | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Defines and Macros | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | #ifndef MAX_TOUCH_POINTS | ||||||
|  | #define MAX_TOUCH_POINTS 8    // Maximum number of touch points supported | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Types and Structures Definition | ||||||
|  | // NOTE: Below types are required for standalone usage | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Boolean type | ||||||
|  | #if ( defined( __STDC__ ) && __STDC_VERSION__ >= 199901L ) || ( defined( _MSC_VER ) && _MSC_VER >= 1800 ) | ||||||
|  | #include <stdbool.h> | ||||||
|  | #elif ! defined( __cplusplus ) && ! defined( bool ) && ! defined( RL_BOOL_TYPE ) | ||||||
|  | typedef enum bool | ||||||
|  | { | ||||||
|  | 	false = 0, | ||||||
|  | 	true  = ! false | ||||||
|  | } bool; | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #if ! defined( RL_VECTOR2_TYPE ) | ||||||
|  | // Vector2 type | ||||||
|  | typedef struct Vector2 | ||||||
|  | { | ||||||
|  | 	float x; | ||||||
|  | 	float y; | ||||||
|  | } Vector2; | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #if defined( RGESTURES_STANDALONE ) | ||||||
|  | // Gestures type | ||||||
|  | // NOTE: It could be used as flags to enable only some gestures | ||||||
|  | typedef enum | ||||||
|  | { | ||||||
|  | 	GESTURE_NONE        = 0, | ||||||
|  | 	GESTURE_TAP         = 1, | ||||||
|  | 	GESTURE_DOUBLETAP   = 2, | ||||||
|  | 	GESTURE_HOLD        = 4, | ||||||
|  | 	GESTURE_DRAG        = 8, | ||||||
|  | 	GESTURE_SWIPE_RIGHT = 16, | ||||||
|  | 	GESTURE_SWIPE_LEFT  = 32, | ||||||
|  | 	GESTURE_SWIPE_UP    = 64, | ||||||
|  | 	GESTURE_SWIPE_DOWN  = 128, | ||||||
|  | 	GESTURE_PINCH_IN    = 256, | ||||||
|  | 	GESTURE_PINCH_OUT   = 512 | ||||||
|  | } Gesture; | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | typedef enum | ||||||
|  | { | ||||||
|  | 	TOUCH_ACTION_UP = 0, | ||||||
|  | 	TOUCH_ACTION_DOWN, | ||||||
|  | 	TOUCH_ACTION_MOVE, | ||||||
|  | 	TOUCH_ACTION_CANCEL | ||||||
|  | } TouchAction; | ||||||
|  |  | ||||||
|  | // Gesture event | ||||||
|  | typedef struct | ||||||
|  | { | ||||||
|  | 	int     touchAction; | ||||||
|  | 	int     pointCount; | ||||||
|  | 	int     pointId[ MAX_TOUCH_POINTS ]; | ||||||
|  | 	Vector2 position[ MAX_TOUCH_POINTS ]; | ||||||
|  | } GestureEvent; | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Global Variables Definition | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | //... | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Module Functions Declaration | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|  | #if defined( __cplusplus ) | ||||||
|  | extern "C" | ||||||
|  | {    // Prevents name mangling of functions | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | 	void ProcessGestureEvent( GestureEvent event );    // Process gesture event and translate it into gestures | ||||||
|  | 	void UpdateGestures( void );                       // Update gestures detected (must be called every frame) | ||||||
|  |  | ||||||
|  | #if defined( RGESTURES_STANDALONE ) | ||||||
|  | 	void SetGesturesEnabled( unsigned int flags );    // Enable a set of gestures using flags | ||||||
|  | 	bool IsGestureDetected( int gesture );            // Check if a gesture have been detected | ||||||
|  | 	int  GetGestureDetected( void );                  // Get latest detected gesture | ||||||
|  |  | ||||||
|  | 	float   GetGestureHoldDuration( void );    // Get gesture hold time in seconds | ||||||
|  | 	Vector2 GetGestureDragVector( void );      // Get gesture drag vector | ||||||
|  | 	float   GetGestureDragAngle( void );       // Get gesture drag angle | ||||||
|  | 	Vector2 GetGesturePinchVector( void );     // Get gesture pinch delta | ||||||
|  | 	float   GetGesturePinchAngle( void );      // Get gesture pinch angle | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #if defined( __cplusplus ) | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #endif    // RGESTURES_H | ||||||
|  |  | ||||||
|  | /*********************************************************************************** | ||||||
|  |  * | ||||||
|  |  *   RGESTURES IMPLEMENTATION | ||||||
|  |  * | ||||||
|  |  ************************************************************************************/ | ||||||
|  |  | ||||||
|  | #if defined( RGESTURES_IMPLEMENTATION ) | ||||||
|  |  | ||||||
|  | #if defined( RGESTURES_STANDALONE ) | ||||||
|  | #if defined( _WIN32 ) | ||||||
|  | #if defined( __cplusplus ) | ||||||
|  | extern "C" | ||||||
|  | {    // Prevents name mangling of functions | ||||||
|  | #endif | ||||||
|  | 	// Functions required to query time on Windows | ||||||
|  | 	int __stdcall QueryPerformanceCounter( unsigned long long int* lpPerformanceCount ); | ||||||
|  | 	int __stdcall QueryPerformanceFrequency( unsigned long long int* lpFrequency ); | ||||||
|  | #if defined( __cplusplus ) | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  | #elif defined( __linux__ ) | ||||||
|  | #if _POSIX_C_SOURCE < 199309L | ||||||
|  | #undef _POSIX_C_SOURCE | ||||||
|  | #define _POSIX_C_SOURCE 199309L    // Required for CLOCK_MONOTONIC if compiled with c99 without gnu ext. | ||||||
|  | #endif | ||||||
|  | #include <sys/time.h>    // Required for: timespec | ||||||
|  | #include <time.h>        // Required for: clock_gettime() | ||||||
|  |  | ||||||
|  | #include <math.h>    // Required for: sqrtf(), atan2f() | ||||||
|  | #endif | ||||||
|  | #if defined( __APPLE__ )    // macOS also defines __MACH__ | ||||||
|  | #include <mach/clock.h>     // Required for: clock_get_time() | ||||||
|  | #include <mach/mach.h>      // Required for: mach_timespec_t | ||||||
|  | #endif | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Defines and Macros | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | #define FORCE_TO_SWIPE  0.2f      // Swipe force, measured in normalized screen units/time | ||||||
|  | #define MINIMUM_DRAG    0.015f    // Drag minimum force, measured in normalized screen units (0.0f to 1.0f) | ||||||
|  | #define DRAG_TIMEOUT    0.3f      // Drag minimum time for web, measured in seconds | ||||||
|  | #define MINIMUM_PINCH   0.005f    // Pinch minimum force, measured in normalized screen units (0.0f to 1.0f) | ||||||
|  | #define TAP_TIMEOUT     0.3f      // Tap minimum time, measured in seconds | ||||||
|  | #define PINCH_TIMEOUT   0.3f      // Pinch minimum time, measured in seconds | ||||||
|  | #define DOUBLETAP_RANGE 0.03f     // DoubleTap range, measured in normalized screen units (0.0f to 1.0f) | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Types and Structures Definition | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|  | // Gestures module state context [136 bytes] | ||||||
|  | typedef struct | ||||||
|  | { | ||||||
|  | 	unsigned int current;         // Current detected gesture | ||||||
|  | 	unsigned int enabledFlags;    // Enabled gestures flags | ||||||
|  |  | ||||||
|  | 	struct | ||||||
|  | 	{ | ||||||
|  | 		int     firstId;              // Touch id for first touch point | ||||||
|  | 		int     pointCount;           // Touch points counter | ||||||
|  | 		double  eventTime;            // Time stamp when an event happened | ||||||
|  | 		Vector2 upPosition;           // Touch up position | ||||||
|  | 		Vector2 downPositionA;        // First touch down position | ||||||
|  | 		Vector2 downPositionB;        // Second touch down position | ||||||
|  | 		Vector2 downDragPosition;     // Touch drag position | ||||||
|  | 		Vector2 moveDownPositionA;    // First touch down position on move | ||||||
|  | 		Vector2 moveDownPositionB;    // Second touch down position on move | ||||||
|  | 		Vector2 previousPositionA;    // Previous position A to compare for pinch gestures | ||||||
|  | 		Vector2 previousPositionB;    // Previous position B to compare for pinch gestures | ||||||
|  | 		int     tapCounter;           // TAP counter (one tap implies TOUCH_ACTION_DOWN and TOUCH_ACTION_UP actions) | ||||||
|  | 	} Touch; | ||||||
|  |  | ||||||
|  | 	struct | ||||||
|  | 	{ | ||||||
|  | 		bool   resetRequired;    // HOLD reset to get first touch point again | ||||||
|  | 		double timeDuration;     // HOLD duration in seconds | ||||||
|  | 	} Hold; | ||||||
|  |  | ||||||
|  | 	struct | ||||||
|  | 	{ | ||||||
|  | 		Vector2 vector;       // DRAG vector (between initial and current position) | ||||||
|  | 		float   angle;        // DRAG angle (relative to x-axis) | ||||||
|  | 		float   distance;     // DRAG distance (from initial touch point to final) (normalized [0..1]) | ||||||
|  | 		float   intensity;    // DRAG intensity, how far why did the DRAG (pixels per frame) | ||||||
|  | 	} Drag; | ||||||
|  |  | ||||||
|  | 	struct | ||||||
|  | 	{ | ||||||
|  | 		double startTime;    // SWIPE start time to calculate drag intensity | ||||||
|  | 	} Swipe; | ||||||
|  |  | ||||||
|  | 	struct | ||||||
|  | 	{ | ||||||
|  | 		Vector2 vector;      // PINCH vector (between first and second touch points) | ||||||
|  | 		float   angle;       // PINCH angle (relative to x-axis) | ||||||
|  | 		float   distance;    // PINCH displacement distance (normalized [0..1]) | ||||||
|  | 	} Pinch; | ||||||
|  | } GesturesData; | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Global Variables Definition | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | static GesturesData GESTURES = { | ||||||
|  | 	.Touch.firstId = -1, | ||||||
|  | 	.current       = GESTURE_NONE,         // No current gesture detected | ||||||
|  | 	.enabledFlags  = 0b0000001111111111    // All gestures supported by default | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Module specific Functions Declaration | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | static float  rgVector2Angle( Vector2 initialPosition, Vector2 finalPosition ); | ||||||
|  | static float  rgVector2Distance( Vector2 v1, Vector2 v2 ); | ||||||
|  | static double rgGetCurrentTime( void ); | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Module Functions Definition | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|  | // Enable only desired gestures to be detected | ||||||
|  | void SetGesturesEnabled( unsigned int flags ) | ||||||
|  | { | ||||||
|  | 	GESTURES.enabledFlags = flags; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Check if a gesture have been detected | ||||||
|  | bool IsGestureDetected( unsigned int gesture ) | ||||||
|  | { | ||||||
|  | 	if ( ( GESTURES.enabledFlags & GESTURES.current ) == gesture ) | ||||||
|  | 		return true; | ||||||
|  | 	else | ||||||
|  | 		return false; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Process gesture event and translate it into gestures | ||||||
|  | void ProcessGestureEvent( GestureEvent event ) | ||||||
|  | { | ||||||
|  | 	// Reset required variables | ||||||
|  | 	GESTURES.Touch.pointCount = event.pointCount;    // Required on UpdateGestures() | ||||||
|  |  | ||||||
|  | 	if ( GESTURES.Touch.pointCount == 1 )    // One touch point | ||||||
|  | 	{ | ||||||
|  | 		if ( event.touchAction == TOUCH_ACTION_DOWN ) | ||||||
|  | 		{ | ||||||
|  | 			GESTURES.Touch.tapCounter++;    // Tap counter | ||||||
|  |  | ||||||
|  | 			// Detect GESTURE_DOUBLE_TAP | ||||||
|  | 			if ( ( GESTURES.current == GESTURE_NONE ) && ( GESTURES.Touch.tapCounter >= 2 ) | ||||||
|  | 			     && ( ( rgGetCurrentTime() - GESTURES.Touch.eventTime ) < TAP_TIMEOUT ) | ||||||
|  | 			     && ( rgVector2Distance( GESTURES.Touch.downPositionA, event.position[ 0 ] ) < DOUBLETAP_RANGE ) ) | ||||||
|  | 			{ | ||||||
|  | 				GESTURES.current          = GESTURE_DOUBLETAP; | ||||||
|  | 				GESTURES.Touch.tapCounter = 0; | ||||||
|  | 			} | ||||||
|  | 			else    // Detect GESTURE_TAP | ||||||
|  | 			{ | ||||||
|  | 				GESTURES.Touch.tapCounter = 1; | ||||||
|  | 				GESTURES.current          = GESTURE_TAP; | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			GESTURES.Touch.downPositionA    = event.position[ 0 ]; | ||||||
|  | 			GESTURES.Touch.downDragPosition = event.position[ 0 ]; | ||||||
|  |  | ||||||
|  | 			GESTURES.Touch.upPosition       = GESTURES.Touch.downPositionA; | ||||||
|  | 			GESTURES.Touch.eventTime        = rgGetCurrentTime(); | ||||||
|  |  | ||||||
|  | 			GESTURES.Swipe.startTime        = rgGetCurrentTime(); | ||||||
|  |  | ||||||
|  | 			GESTURES.Drag.vector            = ( Vector2 ) { 0.0f, 0.0f }; | ||||||
|  | 		} | ||||||
|  | 		else if ( event.touchAction == TOUCH_ACTION_UP ) | ||||||
|  | 		{ | ||||||
|  | 			// A swipe can happen while the current gesture is drag, but (specially for web) also hold, so set upPosition for both cases | ||||||
|  | 			if ( GESTURES.current == GESTURE_DRAG || GESTURES.current == GESTURE_HOLD ) | ||||||
|  | 				GESTURES.Touch.upPosition = event.position[ 0 ]; | ||||||
|  |  | ||||||
|  | 			// NOTE: GESTURES.Drag.intensity dependent on the resolution of the screen | ||||||
|  | 			GESTURES.Drag.distance  = rgVector2Distance( GESTURES.Touch.downPositionA, GESTURES.Touch.upPosition ); | ||||||
|  | 			GESTURES.Drag.intensity = GESTURES.Drag.distance / ( float )( ( rgGetCurrentTime() - GESTURES.Swipe.startTime ) ); | ||||||
|  |  | ||||||
|  | 			// Detect GESTURE_SWIPE | ||||||
|  | 			if ( ( GESTURES.Drag.intensity > FORCE_TO_SWIPE ) && ( GESTURES.current != GESTURE_DRAG ) ) | ||||||
|  | 			{ | ||||||
|  | 				// NOTE: Angle should be inverted in Y | ||||||
|  | 				GESTURES.Drag.angle = 360.0f - rgVector2Angle( GESTURES.Touch.downPositionA, GESTURES.Touch.upPosition ); | ||||||
|  |  | ||||||
|  | 				if ( ( GESTURES.Drag.angle < 30 ) || ( GESTURES.Drag.angle > 330 ) ) | ||||||
|  | 					GESTURES.current = GESTURE_SWIPE_RIGHT;    // Right | ||||||
|  | 				else if ( ( GESTURES.Drag.angle >= 30 ) && ( GESTURES.Drag.angle <= 150 ) ) | ||||||
|  | 					GESTURES.current = GESTURE_SWIPE_UP;    // Up | ||||||
|  | 				else if ( ( GESTURES.Drag.angle > 150 ) && ( GESTURES.Drag.angle < 210 ) ) | ||||||
|  | 					GESTURES.current = GESTURE_SWIPE_LEFT;    // Left | ||||||
|  | 				else if ( ( GESTURES.Drag.angle >= 210 ) && ( GESTURES.Drag.angle <= 330 ) ) | ||||||
|  | 					GESTURES.current = GESTURE_SWIPE_DOWN;    // Down | ||||||
|  | 				else | ||||||
|  | 					GESTURES.current = GESTURE_NONE; | ||||||
|  | 			} | ||||||
|  | 			else | ||||||
|  | 			{ | ||||||
|  | 				GESTURES.Drag.distance  = 0.0f; | ||||||
|  | 				GESTURES.Drag.intensity = 0.0f; | ||||||
|  | 				GESTURES.Drag.angle     = 0.0f; | ||||||
|  |  | ||||||
|  | 				GESTURES.current        = GESTURE_NONE; | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			GESTURES.Touch.downDragPosition = ( Vector2 ) { 0.0f, 0.0f }; | ||||||
|  | 			GESTURES.Touch.pointCount       = 0; | ||||||
|  | 		} | ||||||
|  | 		else if ( event.touchAction == TOUCH_ACTION_MOVE ) | ||||||
|  | 		{ | ||||||
|  | 			GESTURES.Touch.moveDownPositionA = event.position[ 0 ]; | ||||||
|  |  | ||||||
|  | 			if ( GESTURES.current == GESTURE_HOLD ) | ||||||
|  | 			{ | ||||||
|  | 				if ( GESTURES.Hold.resetRequired ) | ||||||
|  | 					GESTURES.Touch.downPositionA = event.position[ 0 ]; | ||||||
|  |  | ||||||
|  | 				GESTURES.Hold.resetRequired = false; | ||||||
|  |  | ||||||
|  | 				// Detect GESTURE_DRAG | ||||||
|  | 				if ( ( rgGetCurrentTime() - GESTURES.Touch.eventTime ) > DRAG_TIMEOUT ) | ||||||
|  | 				{ | ||||||
|  | 					GESTURES.Touch.eventTime = rgGetCurrentTime(); | ||||||
|  | 					GESTURES.current         = GESTURE_DRAG; | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			GESTURES.Drag.vector.x = GESTURES.Touch.moveDownPositionA.x - GESTURES.Touch.downDragPosition.x; | ||||||
|  | 			GESTURES.Drag.vector.y = GESTURES.Touch.moveDownPositionA.y - GESTURES.Touch.downDragPosition.y; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	else if ( GESTURES.Touch.pointCount == 2 )    // Two touch points | ||||||
|  | 	{ | ||||||
|  | 		if ( event.touchAction == TOUCH_ACTION_DOWN ) | ||||||
|  | 		{ | ||||||
|  | 			GESTURES.Touch.downPositionA     = event.position[ 0 ]; | ||||||
|  | 			GESTURES.Touch.downPositionB     = event.position[ 1 ]; | ||||||
|  |  | ||||||
|  | 			GESTURES.Touch.previousPositionA = GESTURES.Touch.downPositionA; | ||||||
|  | 			GESTURES.Touch.previousPositionB = GESTURES.Touch.downPositionB; | ||||||
|  |  | ||||||
|  | 			// GESTURES.Pinch.distance = rgVector2Distance(GESTURES.Touch.downPositionA, GESTURES.Touch.downPositionB); | ||||||
|  |  | ||||||
|  | 			GESTURES.Pinch.vector.x    = GESTURES.Touch.downPositionB.x - GESTURES.Touch.downPositionA.x; | ||||||
|  | 			GESTURES.Pinch.vector.y    = GESTURES.Touch.downPositionB.y - GESTURES.Touch.downPositionA.y; | ||||||
|  |  | ||||||
|  | 			GESTURES.current           = GESTURE_HOLD; | ||||||
|  | 			GESTURES.Hold.timeDuration = rgGetCurrentTime(); | ||||||
|  | 		} | ||||||
|  | 		else if ( event.touchAction == TOUCH_ACTION_MOVE ) | ||||||
|  | 		{ | ||||||
|  | 			GESTURES.Pinch.distance          = rgVector2Distance( GESTURES.Touch.moveDownPositionA, GESTURES.Touch.moveDownPositionB ); | ||||||
|  |  | ||||||
|  | 			GESTURES.Touch.moveDownPositionA = event.position[ 0 ]; | ||||||
|  | 			GESTURES.Touch.moveDownPositionB = event.position[ 1 ]; | ||||||
|  |  | ||||||
|  | 			GESTURES.Pinch.vector.x          = GESTURES.Touch.moveDownPositionB.x - GESTURES.Touch.moveDownPositionA.x; | ||||||
|  | 			GESTURES.Pinch.vector.y          = GESTURES.Touch.moveDownPositionB.y - GESTURES.Touch.moveDownPositionA.y; | ||||||
|  |  | ||||||
|  | 			if ( ( rgVector2Distance( GESTURES.Touch.previousPositionA, GESTURES.Touch.moveDownPositionA ) >= MINIMUM_PINCH ) | ||||||
|  | 			     || ( rgVector2Distance( GESTURES.Touch.previousPositionB, GESTURES.Touch.moveDownPositionB ) >= MINIMUM_PINCH ) ) | ||||||
|  | 			{ | ||||||
|  | 				if ( rgVector2Distance( GESTURES.Touch.previousPositionA, GESTURES.Touch.previousPositionB ) | ||||||
|  | 				     > rgVector2Distance( GESTURES.Touch.moveDownPositionA, GESTURES.Touch.moveDownPositionB ) ) | ||||||
|  | 					GESTURES.current = GESTURE_PINCH_IN; | ||||||
|  | 				else | ||||||
|  | 					GESTURES.current = GESTURE_PINCH_OUT; | ||||||
|  | 			} | ||||||
|  | 			else | ||||||
|  | 			{ | ||||||
|  | 				GESTURES.current           = GESTURE_HOLD; | ||||||
|  | 				GESTURES.Hold.timeDuration = rgGetCurrentTime(); | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			// NOTE: Angle should be inverted in Y | ||||||
|  | 			GESTURES.Pinch.angle = 360.0f - rgVector2Angle( GESTURES.Touch.moveDownPositionA, GESTURES.Touch.moveDownPositionB ); | ||||||
|  | 		} | ||||||
|  | 		else if ( event.touchAction == TOUCH_ACTION_UP ) | ||||||
|  | 		{ | ||||||
|  | 			GESTURES.Pinch.distance   = 0.0f; | ||||||
|  | 			GESTURES.Pinch.angle      = 0.0f; | ||||||
|  | 			GESTURES.Pinch.vector     = ( Vector2 ) { 0.0f, 0.0f }; | ||||||
|  | 			GESTURES.Touch.pointCount = 0; | ||||||
|  |  | ||||||
|  | 			GESTURES.current          = GESTURE_NONE; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	else if ( GESTURES.Touch.pointCount > 2 )    // More than two touch points | ||||||
|  | 	{ | ||||||
|  | 		// TODO: Process gesture events for more than two points | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Update gestures detected (must be called every frame) | ||||||
|  | void UpdateGestures( void ) | ||||||
|  | { | ||||||
|  | 	// NOTE: Gestures are processed through system callbacks on touch events | ||||||
|  |  | ||||||
|  | 	// Detect GESTURE_HOLD | ||||||
|  | 	if ( ( ( GESTURES.current == GESTURE_TAP ) || ( GESTURES.current == GESTURE_DOUBLETAP ) ) && ( GESTURES.Touch.pointCount < 2 ) ) | ||||||
|  | 	{ | ||||||
|  | 		GESTURES.current           = GESTURE_HOLD; | ||||||
|  | 		GESTURES.Hold.timeDuration = rgGetCurrentTime(); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Detect GESTURE_NONE | ||||||
|  | 	if ( ( GESTURES.current == GESTURE_SWIPE_RIGHT ) || ( GESTURES.current == GESTURE_SWIPE_UP ) || ( GESTURES.current == GESTURE_SWIPE_LEFT ) | ||||||
|  | 	     || ( GESTURES.current == GESTURE_SWIPE_DOWN ) ) | ||||||
|  | 	{ | ||||||
|  | 		GESTURES.current = GESTURE_NONE; | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get latest detected gesture | ||||||
|  | int GetGestureDetected( void ) | ||||||
|  | { | ||||||
|  | 	// Get current gesture only if enabled | ||||||
|  | 	return ( GESTURES.enabledFlags & GESTURES.current ); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Hold time measured in ms | ||||||
|  | float GetGestureHoldDuration( void ) | ||||||
|  | { | ||||||
|  | 	// NOTE: time is calculated on current gesture HOLD | ||||||
|  |  | ||||||
|  | 	double time = 0.0; | ||||||
|  |  | ||||||
|  | 	if ( GESTURES.current == GESTURE_HOLD ) | ||||||
|  | 		time = rgGetCurrentTime() - GESTURES.Hold.timeDuration; | ||||||
|  |  | ||||||
|  | 	return ( float )time; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get drag vector (between initial touch point to current) | ||||||
|  | Vector2 GetGestureDragVector( void ) | ||||||
|  | { | ||||||
|  | 	// NOTE: drag vector is calculated on one touch points TOUCH_ACTION_MOVE | ||||||
|  |  | ||||||
|  | 	return GESTURES.Drag.vector; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get drag angle | ||||||
|  | // NOTE: Angle in degrees, horizontal-right is 0, counterclockwise | ||||||
|  | float GetGestureDragAngle( void ) | ||||||
|  | { | ||||||
|  | 	// NOTE: drag angle is calculated on one touch points TOUCH_ACTION_UP | ||||||
|  |  | ||||||
|  | 	return GESTURES.Drag.angle; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get distance between two pinch points | ||||||
|  | Vector2 GetGesturePinchVector( void ) | ||||||
|  | { | ||||||
|  | 	// NOTE: Pinch distance is calculated on two touch points TOUCH_ACTION_MOVE | ||||||
|  |  | ||||||
|  | 	return GESTURES.Pinch.vector; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Get angle between two pinch points | ||||||
|  | // NOTE: Angle in degrees, horizontal-right is 0, counterclockwise | ||||||
|  | float GetGesturePinchAngle( void ) | ||||||
|  | { | ||||||
|  | 	// NOTE: pinch angle is calculated on two touch points TOUCH_ACTION_MOVE | ||||||
|  |  | ||||||
|  | 	return GESTURES.Pinch.angle; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Module specific Functions Definition | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Get angle from two-points vector with X-axis | ||||||
|  | static float rgVector2Angle( Vector2 v1, Vector2 v2 ) | ||||||
|  | { | ||||||
|  | 	float angle = atan2f( v2.y - v1.y, v2.x - v1.x ) * ( 180.0f / PI ); | ||||||
|  |  | ||||||
|  | 	if ( angle < 0 ) | ||||||
|  | 		angle += 360.0f; | ||||||
|  |  | ||||||
|  | 	return angle; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Calculate distance between two Vector2 | ||||||
|  | static float rgVector2Distance( Vector2 v1, Vector2 v2 ) | ||||||
|  | { | ||||||
|  | 	float result; | ||||||
|  |  | ||||||
|  | 	float dx = v2.x - v1.x; | ||||||
|  | 	float dy = v2.y - v1.y; | ||||||
|  |  | ||||||
|  | 	result   = ( float )sqrt( dx * dx + dy * dy ); | ||||||
|  |  | ||||||
|  | 	return result; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Time measure returned are seconds | ||||||
|  | static double rgGetCurrentTime( void ) | ||||||
|  | { | ||||||
|  | 	double time = 0; | ||||||
|  |  | ||||||
|  | #if ! defined( RGESTURES_STANDALONE ) | ||||||
|  | 	time = GetTime(); | ||||||
|  | #else | ||||||
|  | #if defined( _WIN32 ) | ||||||
|  | 	unsigned long long int clockFrequency, currentTime; | ||||||
|  |  | ||||||
|  | 	QueryPerformanceFrequency( &clockFrequency );    // BE CAREFUL: Costly operation! | ||||||
|  | 	QueryPerformanceCounter( ¤tTime ); | ||||||
|  |  | ||||||
|  | 	time = ( double )currentTime / clockFrequency;    // Time in seconds | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #if defined( __linux__ ) | ||||||
|  | 	// NOTE: Only for Linux-based systems | ||||||
|  | 	struct timespec now; | ||||||
|  | 	clock_gettime( CLOCK_MONOTONIC, &now ); | ||||||
|  | 	unsigned long long int nowTime = ( unsigned long long int )now.tv_sec * 1000000000LLU + ( unsigned long long int )now.tv_nsec;    // Time in nanoseconds | ||||||
|  |  | ||||||
|  | 	time                           = ( ( double )nowTime * 1e-9 );    // Time in seconds | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #if defined( __APPLE__ ) | ||||||
|  | 	// #define CLOCK_REALTIME  CALENDAR_CLOCK    // returns UTC time since 1970-01-01 | ||||||
|  | 	// #define CLOCK_MONOTONIC SYSTEM_CLOCK      // returns the time since boot time | ||||||
|  |  | ||||||
|  | 	clock_serv_t    cclock; | ||||||
|  | 	mach_timespec_t now; | ||||||
|  | 	host_get_clock_service( mach_host_self(), SYSTEM_CLOCK, &cclock ); | ||||||
|  |  | ||||||
|  | 	// NOTE: OS X does not have clock_gettime(), using clock_get_time() | ||||||
|  | 	clock_get_time( cclock, &now ); | ||||||
|  | 	mach_port_deallocate( mach_task_self(), cclock ); | ||||||
|  | 	unsigned long long int nowTime = ( unsigned long long int )now.tv_sec * 1000000000LLU + ( unsigned long long int )now.tv_nsec;    // Time in nanoseconds | ||||||
|  |  | ||||||
|  | 	time                           = ( ( double )nowTime * 1e-9 );    // Time in seconds | ||||||
|  | #endif | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | 	return time; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | #endif    // RGESTURES_IMPLEMENTATION | ||||||
							
								
								
									
										5679
									
								
								project/auxillary/vis_ast/dependencies/raylib/include/rlgl.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5679
									
								
								project/auxillary/vis_ast/dependencies/raylib/include/rlgl.h
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -0,0 +1,82 @@ | |||||||
|  | /********************************************************************************************** | ||||||
|  |  * | ||||||
|  |  *   raylib.utils - Some common utility functions | ||||||
|  |  * | ||||||
|  |  * | ||||||
|  |  *   LICENSE: zlib/libpng | ||||||
|  |  * | ||||||
|  |  *   Copyright (c) 2014-2023 Ramon Santamaria (@raysan5) | ||||||
|  |  * | ||||||
|  |  *   This software is provided "as-is", without any express or implied warranty. In no event | ||||||
|  |  *   will the authors be held liable for any damages arising from the use of this software. | ||||||
|  |  * | ||||||
|  |  *   Permission is granted to anyone to use this software for any purpose, including commercial | ||||||
|  |  *   applications, and to alter it and redistribute it freely, subject to the following restrictions: | ||||||
|  |  * | ||||||
|  |  *     1. The origin of this software must not be misrepresented; you must not claim that you | ||||||
|  |  *     wrote the original software. If you use this software in a product, an acknowledgment | ||||||
|  |  *     in the product documentation would be appreciated but is not required. | ||||||
|  |  * | ||||||
|  |  *     2. Altered source versions must be plainly marked as such, and must not be misrepresented | ||||||
|  |  *     as being the original software. | ||||||
|  |  * | ||||||
|  |  *     3. This notice may not be removed or altered from any source distribution. | ||||||
|  |  * | ||||||
|  |  **********************************************************************************************/ | ||||||
|  |  | ||||||
|  | #ifndef UTILS_H | ||||||
|  | #define UTILS_H | ||||||
|  |  | ||||||
|  | #if defined( PLATFORM_ANDROID ) | ||||||
|  | #include <stdio.h>                    // Required for: FILE | ||||||
|  | #include <android/asset_manager.h>    // Required for: AAssetManager | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #if defined( SUPPORT_TRACELOG ) | ||||||
|  | #define TRACELOG( level, ... ) TraceLog( level, __VA_ARGS__ ) | ||||||
|  |  | ||||||
|  | #if defined( SUPPORT_TRACELOG_DEBUG ) | ||||||
|  | #define TRACELOGD( ... ) TraceLog( LOG_DEBUG, __VA_ARGS__ ) | ||||||
|  | #else | ||||||
|  | #define TRACELOGD( ... ) ( void )0 | ||||||
|  | #endif | ||||||
|  | #else | ||||||
|  | #define TRACELOG( level, ... ) ( void )0 | ||||||
|  | #define TRACELOGD( ... )       ( void )0 | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Some basic Defines | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | #if defined( PLATFORM_ANDROID ) | ||||||
|  | #define fopen( name, mode ) android_fopen( name, mode ) | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Types and Structures Definition | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | //... | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Global Variables Definition | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Nop... | ||||||
|  |  | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | // Module Functions Declaration | ||||||
|  | //---------------------------------------------------------------------------------- | ||||||
|  | #if defined( __cplusplus ) | ||||||
|  | extern "C" | ||||||
|  | {    // Prevents name mangling of functions | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #if defined( PLATFORM_ANDROID ) | ||||||
|  | 	void  InitAssetManager( AAssetManager* manager, const char* dataPath );    // Initialize asset manager from android app | ||||||
|  | 	FILE* android_fopen( const char* fileName, const char* mode );             // Replacement for fopen() -> Read-only! | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #if defined( __cplusplus ) | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #endif    // UTILS_H | ||||||
							
								
								
									
										8
									
								
								project/auxillary/vis_ast/dependencies/raylib/raylib.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								project/auxillary/vis_ast/dependencies/raylib/raylib.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | |||||||
|  | #include "raudio.c" | ||||||
|  | #include "rcore.c" | ||||||
|  | #include "rglfw.c" | ||||||
|  | #include "rmodels.c" | ||||||
|  | #include "rshapes.c" | ||||||
|  | #include "rtext.c" | ||||||
|  | #include "rtextures.c" | ||||||
|  | #include "rutils.c" | ||||||
| @@ -0,0 +1,9 @@ | |||||||
|  |  __VERSION 1 | ||||||
|  |  | ||||||
|  |  | ||||||
|  | word SUPPORT_MODULE_RSHAPES,   RL_SUPPORT_MODULE_RSHAPES | ||||||
|  | word SUPPORT_MODULE_RTEXTURES, RL_SUPPORT_MODULE_RTEXTURES | ||||||
|  | word SUPPORT_MODULE_RTEXT,     RL_SUPPORT_MODULE_RTEXT | ||||||
|  | word SUPPORT_MODULE_RMODELS,   RL_SUPPORT_MODULE_RMODELS | ||||||
|  | word SUPPORT_MODULE_RAUDIO,    RL_SUPPORT_MODULE_RAUDIO | ||||||
|  |  | ||||||
| @@ -0,0 +1,290 @@ | |||||||
|  | #define GEN_DEFINE_LIBRARY_CODE_CONSTANTS | ||||||
|  | #define GEN_BENCHMARK | ||||||
|  | #define GEN_ENFORCE_STRONG_CODE_TYPES | ||||||
|  | // #define GEN_IMPLEMENTATION | ||||||
|  | #include "gen.cpp" | ||||||
|  | #include "gen.builder.cpp" | ||||||
|  |  | ||||||
|  |  | ||||||
|  | constexpr char const* path_config    = "config.h"; | ||||||
|  | constexpr char const* path_raylib    = "raylib.h"; | ||||||
|  | constexpr char const* path_raymath   = "raymath.h"; | ||||||
|  | constexpr char const* path_rcamera   = "rcamera.h"; | ||||||
|  | constexpr char const* path_rcore     = "rcore.h"; | ||||||
|  | constexpr char const* path_rgestures = "rgestures.h"; | ||||||
|  | constexpr char const* path_rgl       = "rgl.h"; | ||||||
|  | constexpr char const* path_rtext     = "rtext.h"; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | using namespace gen; | ||||||
|  |  | ||||||
|  | StringCached upper_snake_to_mixed_snake(StringCached str) | ||||||
|  | { | ||||||
|  |     local_persist String scratch = String::make_reserve(GlobalAllocator, kilobytes(1)); | ||||||
|  |     scratch.clear(); | ||||||
|  |  | ||||||
|  |     bool capitalizeNext = true; | ||||||
|  |  | ||||||
|  |     for (s32 index = 0; index < str.length(); ++index) | ||||||
|  |     { | ||||||
|  |         char c = str[index]; | ||||||
|  |  | ||||||
|  |         if (c == '_') | ||||||
|  |         { | ||||||
|  |             scratch.append(c); | ||||||
|  |             capitalizeNext = true; | ||||||
|  |         } | ||||||
|  |         else if (capitalizeNext) | ||||||
|  |         { | ||||||
|  |             if (c >= 'a' && c <= 'z') | ||||||
|  |             { | ||||||
|  |                 scratch.append(c - 32); // Convert to uppercase | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 scratch.append(c); | ||||||
|  |             } | ||||||
|  |             capitalizeNext = false; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             if (c >= 'A' && c <= 'Z') | ||||||
|  |             { | ||||||
|  |                 scratch.append(c + 32); // Convert to lowercase | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 scratch.append(c); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     StringCached result = get_cached_string(scratch); | ||||||
|  |     return result; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | StringCached pascal_to_lower_snake(StringCached str) | ||||||
|  | { | ||||||
|  |     local_persist String scratch = String::make_reserve(GlobalAllocator, kilobytes(1)); | ||||||
|  |     scratch.clear(); | ||||||
|  |  | ||||||
|  |     for (s32 index = 0; index < str.length(); ++index) | ||||||
|  |     { | ||||||
|  |         char c = str[index]; | ||||||
|  |         char next = (index + 1 < str.length()) ? str[index + 1] : '\0'; // Ensure we don't go out of bounds | ||||||
|  |  | ||||||
|  |         // Whitelist check for "2D" and "3D" | ||||||
|  |         if ((c == '2' || c == '3' | c == '4') && (next == 'D' || next == 'd')) | ||||||
|  |         { | ||||||
|  |             if (index > 0) // If it's not the start of the string, append an underscore | ||||||
|  |             { | ||||||
|  |                 char* prev = str.Data + index - 1; | ||||||
|  |                 if (*prev != '_') // Avoid double underscores | ||||||
|  |                 { | ||||||
|  |                     scratch.append('_'); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             scratch.append(c); | ||||||
|  |             scratch.append('d'); // Convert to lowercase | ||||||
|  |             index++; // Skip the next character since we've already processed it | ||||||
|  |             continue; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if (c >= 'A' && c <= 'Z') | ||||||
|  |         { | ||||||
|  |             char* prev = (index > 0) ? str.Data + index - 1 : nullptr; | ||||||
|  |  | ||||||
|  |             if ((index > 0 && prev && *prev >= 'a' && *prev <= 'z') ||  | ||||||
|  |                 (prev && char_is_digit(*prev) && (next >= 'A' && next <= 'Z'))) | ||||||
|  |             { | ||||||
|  |                 scratch.append('_'); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             scratch.append(c + 32); | ||||||
|  |         } | ||||||
|  |         else if (char_is_digit(c) && (next >= 'A' && next <= 'Z')) // Check for a number followed by an uppercase letter | ||||||
|  |         { | ||||||
|  |             scratch.append(c); | ||||||
|  |             scratch.append('_'); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             scratch.append(c); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     StringCached result = get_cached_string(scratch); | ||||||
|  |     return result; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void refactor_enum( CodeEnum& code ) | ||||||
|  | { | ||||||
|  | 	for ( Code elem : code->Body ) | ||||||
|  | 	{ | ||||||
|  | 		if ( elem->Type == ECode::Untyped ) | ||||||
|  | 		{ | ||||||
|  | 			elem->Content = upper_snake_to_mixed_snake( elem->Content ); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void refactor_typename( CodeType& type ) | ||||||
|  | { | ||||||
|  | 	local_persist CodeType t_unsigned_char      = parse_type( code(unsigned char) ); | ||||||
|  | 	local_persist CodeType t_unsigned_char_ptr  = parse_type( code(unsigned char*) ); | ||||||
|  | 	local_persist CodeType t_unsigned_short_ptr	= parse_type( code(unsigned short*) ); | ||||||
|  | 	local_persist CodeType t_int                = parse_type( code(int) ); | ||||||
|  | 	local_persist CodeType t_int_ptr 		    = parse_type( code(int*) ); | ||||||
|  | 	local_persist CodeType t_unsigned_int       = parse_type( code(unsigned int) ); | ||||||
|  | 	local_persist CodeType t_float 	            = parse_type( code(float) ); | ||||||
|  | 	local_persist CodeType t_float_ptr          = parse_type( code(float*) ); | ||||||
|  |  | ||||||
|  | 	local_persist CodeType t_f32_ptr = parse_type( code(f32*) ); | ||||||
|  | 	local_persist CodeType t_u8_ptr  = parse_type( code(u8*) ); | ||||||
|  | 	local_persist CodeType t_s32_ptr = parse_type( code(s32*) ); | ||||||
|  |  | ||||||
|  | 	String type_str = type.to_string(); | ||||||
|  |  | ||||||
|  | 	if ( str_compare( type_str, t_unsigned_char.to_string() ) == 0 ) | ||||||
|  | 	{ | ||||||
|  | 		type.ast = t_u8.ast; | ||||||
|  | 	} | ||||||
|  | 	if ( str_compare( type_str, t_unsigned_char_ptr.to_string() ) == 0 ) | ||||||
|  | 	{ | ||||||
|  | 		type.ast = t_u8_ptr.ast; | ||||||
|  | 	} | ||||||
|  | 	if ( str_compare( type_str, t_unsigned_short_ptr.to_string() ) == 0 ) | ||||||
|  | 	{ | ||||||
|  | 		type.ast = t_u8_ptr.ast; | ||||||
|  | 	} | ||||||
|  | 	if ( str_compare( type_str, t_int.to_string() ) == 0 ) | ||||||
|  | 	{ | ||||||
|  | 		type.ast = t_s32.ast; | ||||||
|  | 	} | ||||||
|  | 	if ( str_compare( type_str, t_int_ptr.to_string() ) == 0 ) | ||||||
|  | 	{ | ||||||
|  | 		type.ast = t_s32_ptr.ast; | ||||||
|  | 	} | ||||||
|  | 	if ( str_compare( type_str, t_unsigned_int.to_string() ) == 0 ) | ||||||
|  | 	{ | ||||||
|  | 		type.ast = t_u32.ast; | ||||||
|  | 	} | ||||||
|  | 	if ( str_compare( type_str, t_float.to_string() ) == 0 ) | ||||||
|  | 	{ | ||||||
|  | 		type.ast = t_f32.ast; | ||||||
|  | 	} | ||||||
|  | 	if ( str_compare( type_str, t_float_ptr.to_string() ) == 0 ) | ||||||
|  | 	{ | ||||||
|  | 		type.ast = t_f32_ptr.ast; | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void refactor_fn( CodeFn& fn ) | ||||||
|  | { | ||||||
|  | 	fn->Name = pascal_to_lower_snake( fn->Name ); | ||||||
|  |  | ||||||
|  | 	for ( CodeParam param : fn->Params ) | ||||||
|  | 	{ | ||||||
|  | 		refactor_typename( param->ValueType ); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void refactor_struct( CodeStruct& code ) | ||||||
|  | { | ||||||
|  | 	for ( Code field : code->Body ) | ||||||
|  | 	{ | ||||||
|  | 		if ( field->Type == ECode::Variable ) | ||||||
|  | 		{ | ||||||
|  | 			CodeVar var = field.cast<CodeVar>(); | ||||||
|  | 			refactor_typename( var->ValueType ); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void refactor_file( char const* path ) | ||||||
|  | { | ||||||
|  | 	FileContents contents = file_read_contents( GlobalAllocator, true, path ); | ||||||
|  | 	CodeBody     code     = parse_global_body( { contents.size, rcast(char const*, contents.data) } ); | ||||||
|  |  | ||||||
|  | 	String name_scratch = String::make_reserve( GlobalAllocator, kilobytes(1) ); | ||||||
|  |  | ||||||
|  | 	// CodeBody includes  | ||||||
|  | 	// CodeBody nspace_body = def_body( ECode::Namespace ); | ||||||
|  | 	CodeBody new_code = def_body( ECode::Global_Body ); | ||||||
|  |  | ||||||
|  | 	for ( Code elem : code ) | ||||||
|  | 	{ | ||||||
|  | 		if ( elem->Type == ECode::Preprocess_Define ) | ||||||
|  | 		{ | ||||||
|  | 			if ( str_compare( elem->Name, txt("RL"), 2 ) == 0 || str_compare( elem->Name, txt("RAYLIB"), 6 ) == 0 ) | ||||||
|  | 				continue; | ||||||
|  |  | ||||||
|  | 			name_scratch.append_fmt( "%RL_%S", elem->Name ); | ||||||
|  | 			elem->Name = get_cached_string( name_scratch ); | ||||||
|  | 			name_scratch.clear(); | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		if ( elem->Type == ECode::Enum ) | ||||||
|  | 		{ | ||||||
|  | 			refactor_enum( elem.cast<CodeEnum>() ); | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		if ( elem->Type == ECode::Typedef ) | ||||||
|  | 		{ | ||||||
|  | 			CodeTypedef td = elem.cast<CodeTypedef>(); | ||||||
|  | 			if ( td->UnderlyingType->Type == ECode::Enum ) | ||||||
|  | 			{ | ||||||
|  | 				CodeEnum code = td->UnderlyingType.cast<CodeEnum>(); | ||||||
|  | 				refactor_enum( code ); | ||||||
|  | 			} | ||||||
|  | 			if ( td->UnderlyingType->Type == ECode::Struct ) | ||||||
|  | 			{ | ||||||
|  | 				CodeStruct code = td->UnderlyingType.cast<CodeStruct>(); | ||||||
|  | 				refactor_struct( code ); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		if ( elem->Type == ECode::Struct ) | ||||||
|  | 		{ | ||||||
|  | 			refactor_struct( elem.cast<CodeStruct>() ); | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		if ( elem->Type == ECode::Function || elem->Type == ECode::Function_Fwd ) | ||||||
|  | 		{ | ||||||
|  | 			refactor_fn( elem.cast<CodeFn>() ); | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		if ( elem->Type == ECode::Extern_Linkage ) | ||||||
|  | 		{ | ||||||
|  | 			CodeBody body = elem.cast<CodeExtern>()->Body; | ||||||
|  | 			for ( Code elem : body ) | ||||||
|  | 			{ | ||||||
|  | 				if ( elem->Type == ECode::Function || elem->Type == ECode::Function_Fwd ) | ||||||
|  | 				{ | ||||||
|  | 					refactor_fn( elem.cast<CodeFn>() ); | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			Code nspace = def_namespace( txt("raylib"), def_namespace_body( args(elem) ) ); | ||||||
|  | 			elem = nspace; | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		new_code.append( elem ); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	Builder builder = Builder::open( path ); | ||||||
|  | 	builder.print( new_code ); | ||||||
|  | 	builder.write(); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | int gen_main() | ||||||
|  | { | ||||||
|  | 	gen::init(); | ||||||
|  |  | ||||||
|  | 	refactor_file( path_config ); | ||||||
|  | 	refactor_file( path_raylib ); | ||||||
|  | 	refactor_file( path_raymath ); | ||||||
|  | 	refactor_file( path_rcamera ); | ||||||
|  |  | ||||||
|  | 	return 0; | ||||||
|  | } | ||||||
							
								
								
									
										10
									
								
								project/auxillary/vis_ast/readme.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								project/auxillary/vis_ast/readme.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | |||||||
|  | # Vis AST | ||||||
|  |  | ||||||
|  | AST visualizer for gencpp | ||||||
|  |  | ||||||
|  | This is a early start to creating frontend tooling for c/c++ using gencpp as a core component.   | ||||||
|  | I'll be exploring creating an AST explorer for this library with raylib as the graphical & general platform vendor for dependencies that go beyond the scope of gencpp. | ||||||
|  |  | ||||||
|  | For now I'll have its build script in this file, however it will heavily rely on gencpp's helper scripts. | ||||||
|  |  | ||||||
|  | Whatever sort of UX tooling I setup for this will be reused for the other tools I'll be creating for gencpp. | ||||||
							
								
								
									
										0
									
								
								project/auxillary/vis_ast/rebuild.ps1
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								project/auxillary/vis_ast/rebuild.ps1
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										178
									
								
								project/auxillary/vis_ast/update_deps.ps1
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										178
									
								
								project/auxillary/vis_ast/update_deps.ps1
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,178 @@ | |||||||
|  | Clear-Host | ||||||
|  |  | ||||||
|  | $path_root     = git rev-parse --show-toplevel | ||||||
|  | $path_scripts  = Join-Path $path_root 'scripts' | ||||||
|  |  | ||||||
|  | $target_arch        = Join-Path $path_scripts 'helpers/target_arch.psm1' | ||||||
|  | $devshell           = Join-Path $path_scripts 'helpers/devshell.ps1' | ||||||
|  | $format_cpp	        = Join-Path $path_scripts 'helpers/format_cpp.psm1' | ||||||
|  | $incremental_checks = Join-Path $path_scripts 'helpers/incremental_checks.ps1' | ||||||
|  | $vendor_toolchain   = Join-Path $path_scripts 'helpers/vendor_toolchain.ps1' | ||||||
|  |  | ||||||
|  | $path_project  = Join-Path $path_root     'project' | ||||||
|  | $path_aux      = Join-Path $path_project  'auxillary' | ||||||
|  | $path_vis_root = Join-Path $path_aux      'vis_ast' | ||||||
|  | $path_binaries = Join-Path $path_vis_root 'binaries' | ||||||
|  |  | ||||||
|  | $path_deps = Join-Path $path_vis_root 'dependencies' | ||||||
|  | $path_temp = Join-Path $path_deps     'temp' | ||||||
|  |  | ||||||
|  | Import-Module $target_arch | ||||||
|  | Import-Module $format_cpp | ||||||
|  |  | ||||||
|  | #region Arguments | ||||||
|  | $vendor           = $null | ||||||
|  | $optimize         = $null | ||||||
|  | $debug 	          = $null | ||||||
|  | $analysis	      = $false | ||||||
|  | $dev              = $false | ||||||
|  | $verbose          = $null | ||||||
|  |  | ||||||
|  | [array] $vendors = @( "clang", "msvc" ) | ||||||
|  |  | ||||||
|  | # This is a really lazy way of parsing the args, could use actual params down the line... | ||||||
|  |  | ||||||
|  | if ( $args ) { $args | ForEach-Object { | ||||||
|  | switch ($_){ | ||||||
|  |  { $_ -in $vendors }   { $vendor    = $_; break } | ||||||
|  |  "optimize"            { $optimize  = $true } | ||||||
|  |  "debug"               { $debug     = $true } | ||||||
|  |  "analysis"            { $analysis  = $true } | ||||||
|  |  "dev"                 { $dev       = $true } | ||||||
|  |  "verbose"             { $verbose   = $true } | ||||||
|  | } | ||||||
|  | }} | ||||||
|  | #endregion Argument | ||||||
|  |  | ||||||
|  | # Load up toolchain configuraion | ||||||
|  | . $vendor_toolchain | ||||||
|  | . $incremental_checks | ||||||
|  |  | ||||||
|  | # Clear out the current content first | ||||||
|  | # remove-item $path_temp -Recurse | ||||||
|  | # New-Item -ItemType Directory -Path $path_temp | ||||||
|  |  | ||||||
|  | if ( -not (Test-Path $path_binaries) ) { | ||||||
|  | 	New-Item -ItemType Directory -Path $path_binaries | ||||||
|  | } | ||||||
|  |  | ||||||
|  | function setup-raylib { | ||||||
|  | 	$path_raylib     = join-path $path_deps   'raylib' | ||||||
|  | 	$path_raylib_inc = join-path $path_raylib 'include' | ||||||
|  | 	$path_raylib_lib = join-path $path_raylib 'lib' | ||||||
|  | 	if ( test-path $path_raylib_inc ) { | ||||||
|  | 		remove-item $path_raylib_inc -recurse | ||||||
|  | 		remove-item $path_raylib_lib -recurse | ||||||
|  | 	} | ||||||
|  | 	new-item -path $path_raylib_inc -ItemType Directory | ||||||
|  | 	new-item -path $path_raylib_lib -ItemType Directory | ||||||
|  |  | ||||||
|  | 	$url_raylib_zip  = 'https://github.com/raysan5/raylib/archive/refs/heads/master.zip' | ||||||
|  | 	$path_raylib_zip = join-path $path_temp 'raylib.zip' | ||||||
|  |  | ||||||
|  | 	$path_raylib_master      = join-path $path_temp          'raylib-master' | ||||||
|  | 	$path_raylib_src         = join-path $path_raylib_master 'src' | ||||||
|  | 	$path_raylib_glfw_inc    = join-path $path_raylib_src    'external/glfw/include' | ||||||
|  |  | ||||||
|  | 	remove-item $path_raylib_master -Recurse | ||||||
|  | 	# invoke-webrequest -uri $url_raylib_zip   -outfile $path_raylib_zip | ||||||
|  | 	expand-archive    -path $path_raylib_zip -destinationpath $path_temp | ||||||
|  |  | ||||||
|  | 	write-host "Building raylib with $vendor" | ||||||
|  |  | ||||||
|  | 	$path_build = Join-Path $path_raylib 'build' | ||||||
|  | 	if ( (Test-Path $path_build) -eq $false ) { | ||||||
|  | 		New-Item $path_build -ItemType Directory | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	$raylib_headers = Get-ChildItem -Path $path_raylib_src -Filter "*.h" -File | ||||||
|  | 	$raylib_modules = get-childitem -path $path_raylib_src -filter "*.c" -file | ||||||
|  |  | ||||||
|  | 	# Refactor raylib | ||||||
|  | 	if ( $true ) { | ||||||
|  | 	# if ( $false ) { | ||||||
|  | 		$path_gencpp = join-path $path_root 'project/gen' | ||||||
|  |  | ||||||
|  | 		$includes = @( | ||||||
|  | 			$path_gencpp | ||||||
|  | 		) | ||||||
|  |  | ||||||
|  | 		$compiler_args = @( | ||||||
|  | 			($flag_define + 'GEN_TIME') | ||||||
|  | 		) | ||||||
|  |  | ||||||
|  | 		$linker_args = @( | ||||||
|  |  | ||||||
|  | 		) | ||||||
|  |  | ||||||
|  | 		$unit       = join-path $path_raylib 'raylib_refactor.cpp' | ||||||
|  | 		$executable = join-path $path_build  'raylib_refactor.exe' | ||||||
|  |  | ||||||
|  | 		$build_result = build-simple $path_build $includes $compiler_args $linker_args $unit $executable | ||||||
|  | 		Push-Location $path_raylib_src | ||||||
|  | 			if ( Test-Path( $executable ) ) { | ||||||
|  | 				Measure-Command { & $executable | ||||||
|  | 						| ForEach-Object { | ||||||
|  | 							write-host `t $_ -ForegroundColor Green | ||||||
|  | 						} | ||||||
|  | 					} | ||||||
|  | 			} | ||||||
|  | 		Pop-Location | ||||||
|  |  | ||||||
|  | 		push-location $path_scripts | ||||||
|  | 		# Time to format | ||||||
|  | 		$fmt_includes = @() | ||||||
|  | 		foreach ( $header in $raylib_headers ) { | ||||||
|  | 			$fmt_includes +=  split-path $header -leaf | ||||||
|  | 		} | ||||||
|  | 		foreach ( $module in $raylib_modules ) { | ||||||
|  | 			$fmt_includes +=  split-path $module -leaf | ||||||
|  | 		} | ||||||
|  | 		format-cpp $path_raylib_src $fmt_includes $null | ||||||
|  | 		pop-location | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	# Build raylib | ||||||
|  | 	if ( $false ) { | ||||||
|  | 		# Microsoft | ||||||
|  | 		$lib_gdi32   = 'Gdi32.lib' | ||||||
|  | 		$lib_shell32 = 'Shell32.lib' | ||||||
|  | 		$lib_xinput  = 'Xinput.lib' | ||||||
|  | 		$lib_user32  = 'User32.lib' | ||||||
|  | 		$lib_winmm   = 'Winmm.lib' | ||||||
|  |  | ||||||
|  | 		$includes = @( | ||||||
|  | 			$path_raylib_src, | ||||||
|  | 			$path_raylib_glfw_inc | ||||||
|  | 		) | ||||||
|  | 		foreach ($include in $includes) { | ||||||
|  | 			write-host $include | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		$compiler_args = @( | ||||||
|  | 			($flag_define + 'PLATFORM_DESKTOP'), | ||||||
|  | 			($flag_define + 'BUILD_LIBTYPE_SHARED') | ||||||
|  | 		) | ||||||
|  | 		$linker_args   = @( | ||||||
|  | 			$flag_link_dll, | ||||||
|  |  | ||||||
|  | 			# $lib_xinput, | ||||||
|  | 			$lib_gdi32, | ||||||
|  | 			$lib_shell32, | ||||||
|  | 			$lib_user32, | ||||||
|  | 			$lib_winmm | ||||||
|  | 		) | ||||||
|  |  | ||||||
|  | 		# $unit = join-path $path_raylib     'raylib.c' | ||||||
|  | 		$dll  = join-path $path_raylib_lib 'raylib.dll' | ||||||
|  | 		# $build_result = build-simple $path_build $includes $compiler_args $linker_args $unit $dll | ||||||
|  |  | ||||||
|  | 		$build_result = build $path_build $includes $compiler_args $linker_args $raylib_modules $dll | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	# Move headers to used include | ||||||
|  | 	foreach ($header in $raylib_headers) { | ||||||
|  | 		Copy-Item -Path $header -Destination (join-path $path_raylib_inc (split-path $header -Leaf)) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | setup-raylib | ||||||
| @@ -17,21 +17,19 @@ GEN_NS_END | |||||||
| using namespace gen; | using namespace gen; | ||||||
|  |  | ||||||
| constexpr char const* generation_notice = | constexpr char const* generation_notice = | ||||||
| "// This file was generated automatially by gen.bootstrap.cpp " | "// This file was generated automatially by gencpp's bootstrap.cpp " | ||||||
| "(See: https://github.com/Ed94/gencpp)\n\n"; | "(See: https://github.com/Ed94/gencpp)\n\n"; | ||||||
|  |  | ||||||
| constexpr bool DontSkipInitialDirectives = false; |  | ||||||
|  |  | ||||||
| int gen_main() | int gen_main() | ||||||
| { | { | ||||||
| 	gen::init(); | 	gen::init(); | ||||||
|  |  | ||||||
| 	Code push_ignores = scan_file( "helpers/push_ignores.inline.hpp", DontSkipInitialDirectives ); | 	Code push_ignores = scan_file( "helpers/push_ignores.inline.hpp" ); | ||||||
| 	Code pop_ignores  = scan_file( "helpers/pop_ignores.inline.hpp", DontSkipInitialDirectives ); | 	Code pop_ignores  = scan_file( "helpers/pop_ignores.inline.hpp" ); | ||||||
|  |  | ||||||
| 	// gen_dep.hpp | 	// gen_dep.hpp | ||||||
| 	{ | 	{ | ||||||
| 		Code header_start = scan_file( "dependencies/header_start.hpp", DontSkipInitialDirectives ); | 		Code header_start = scan_file( "dependencies/header_start.hpp" ); | ||||||
| 		Code macros 	  = scan_file( "dependencies/macros.hpp" ); | 		Code macros 	  = scan_file( "dependencies/macros.hpp" ); | ||||||
| 		Code basic_types  = scan_file( "dependencies/basic_types.hpp" ); | 		Code basic_types  = scan_file( "dependencies/basic_types.hpp" ); | ||||||
| 		Code debug        = scan_file( "dependencies/debug.hpp" ); | 		Code debug        = scan_file( "dependencies/debug.hpp" ); | ||||||
| @@ -99,6 +97,15 @@ int gen_main() | |||||||
| 		src.write(); | 		src.write(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	CodeBody gen_component_header = def_global_body( args( | ||||||
|  | 		def_preprocess_cond( PreprocessCond_IfDef, txt("GEN_INTELLISENSE_DIRECTIVES") ), | ||||||
|  | 		pragma_once, | ||||||
|  | 		def_include(txt("components/types.hpp")), | ||||||
|  | 		preprocess_endif, | ||||||
|  | 		fmt_newline, | ||||||
|  | 		untyped_str( to_str(generation_notice) ) | ||||||
|  | 	)); | ||||||
|  |  | ||||||
| 	// gen.hpp | 	// gen.hpp | ||||||
| 	{ | 	{ | ||||||
| 		Code header_start = scan_file( "components/header_start.hpp" ); | 		Code header_start = scan_file( "components/header_start.hpp" ); | ||||||
| @@ -149,29 +156,25 @@ int gen_main() | |||||||
|  |  | ||||||
| 		Builder | 		Builder | ||||||
| 		header_ecode = Builder::open( "components/gen/ecode.hpp" ); | 		header_ecode = Builder::open( "components/gen/ecode.hpp" ); | ||||||
| 		header_ecode.print( pragma_once ); | 		header_ecode.print( gen_component_header ); | ||||||
| 		header_ecode.print_fmt( generation_notice ); |  | ||||||
| 		header_ecode.print( ecode ); | 		header_ecode.print( ecode ); | ||||||
| 		header_ecode.write(); | 		header_ecode.write(); | ||||||
|  |  | ||||||
| 		Builder | 		Builder | ||||||
| 		header_eoperator = Builder::open( "components/gen/eoperator.hpp" ); | 		header_eoperator = Builder::open( "components/gen/eoperator.hpp" ); | ||||||
| 		header_eoperator.print( pragma_once ); | 		header_eoperator.print( gen_component_header ); | ||||||
| 		header_eoperator.print_fmt( generation_notice ); |  | ||||||
| 		header_eoperator.print( eoperator ); | 		header_eoperator.print( eoperator ); | ||||||
| 		header_eoperator.write(); | 		header_eoperator.write(); | ||||||
|  |  | ||||||
| 		Builder | 		Builder | ||||||
| 		header_especifier = Builder::open( "components/gen/especifier.hpp" ); | 		header_especifier = Builder::open( "components/gen/especifier.hpp" ); | ||||||
| 		header_especifier.print( pragma_once ); | 		header_especifier.print( gen_component_header ); | ||||||
| 		header_especifier.print_fmt( generation_notice ); |  | ||||||
| 		header_especifier.print( especifier ); | 		header_especifier.print( especifier ); | ||||||
| 		header_especifier.write(); | 		header_especifier.write(); | ||||||
|  |  | ||||||
| 		Builder | 		Builder | ||||||
| 		header_ast_inlines = Builder::open( "components/gen/ast_inlines.hpp" ); | 		header_ast_inlines = Builder::open( "components/gen/ast_inlines.hpp" ); | ||||||
| 		header_ast_inlines.print( pragma_once ); | 		header_ast_inlines.print( gen_component_header ); | ||||||
| 		header_ast_inlines.print_fmt( generation_notice ); |  | ||||||
| 		header_ast_inlines.print( ast_inlines ); | 		header_ast_inlines.print( ast_inlines ); | ||||||
| 		header_ast_inlines.write(); | 		header_ast_inlines.write(); | ||||||
| 	} | 	} | ||||||
| @@ -220,8 +223,7 @@ int gen_main() | |||||||
|  |  | ||||||
| 		Builder | 		Builder | ||||||
| 		src_etoktype = Builder::open( "components/gen/etoktype.cpp" ); | 		src_etoktype = Builder::open( "components/gen/etoktype.cpp" ); | ||||||
| 		src_etoktype.print_fmt( generation_notice ); | 		src_etoktype.print( gen_component_header ); | ||||||
| 		src_etoktype.print( pragma_once ); |  | ||||||
| 		src_etoktype.print( nspaced_etoktype ); | 		src_etoktype.print( nspaced_etoktype ); | ||||||
| 		src_etoktype.write(); | 		src_etoktype.write(); | ||||||
| 	} | 	} | ||||||
|   | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,8 +1,10 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #pragma once | #pragma once | ||||||
| #include "types.hpp" | #include "types.hpp" | ||||||
| #include "gen/ecode.hpp" | #include "gen/ecode.hpp" | ||||||
| #include "gen/eoperator.hpp" | #include "gen/eoperator.hpp" | ||||||
| #include "gen/especifier.hpp" | #include "gen/especifier.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| struct AST; | struct AST; | ||||||
| struct AST_Body; | struct AST_Body; | ||||||
| @@ -39,10 +41,10 @@ struct CodeBody; | |||||||
| // These are to offer ease of use and optionally strong type safety for the AST. | // These are to offer ease of use and optionally strong type safety for the AST. | ||||||
| struct CodeAttributes; | struct CodeAttributes; | ||||||
| struct CodeComment; | struct CodeComment; | ||||||
| struct CodeConstructor; |  | ||||||
| struct CodeDestructor; |  | ||||||
| struct CodeClass; | struct CodeClass; | ||||||
|  | struct CodeConstructor; | ||||||
| struct CodeDefine; | struct CodeDefine; | ||||||
|  | struct CodeDestructor; | ||||||
| struct CodeEnum; | struct CodeEnum; | ||||||
| struct CodeExec; | struct CodeExec; | ||||||
| struct CodeExtern; | struct CodeExtern; | ||||||
| @@ -65,6 +67,11 @@ struct CodeUnion; | |||||||
| struct CodeUsing; | struct CodeUsing; | ||||||
| struct CodeVar; | struct CodeVar; | ||||||
|  |  | ||||||
|  | namespace Parser | ||||||
|  | { | ||||||
|  | 	struct Token; | ||||||
|  | } | ||||||
|  |  | ||||||
| /* | /* | ||||||
| 	AST* wrapper | 	AST* wrapper | ||||||
| 	- Not constantly have to append the '*' as this is written often.. | 	- Not constantly have to append the '*' as this is written often.. | ||||||
| @@ -106,7 +113,7 @@ struct Code | |||||||
| 		return ast; | 		return ast; | ||||||
| 	} | 	} | ||||||
| 	Code& operator ++(); | 	Code& operator ++(); | ||||||
| 	Code& operator*() | 	auto& operator*() | ||||||
| 	{ | 	{ | ||||||
| 		return *this; | 		return *this; | ||||||
| 	} | 	} | ||||||
| @@ -155,7 +162,7 @@ struct Code_POD | |||||||
| static_assert( sizeof(Code) == sizeof(Code_POD), "ERROR: Code is not POD" ); | static_assert( sizeof(Code) == sizeof(Code_POD), "ERROR: Code is not POD" ); | ||||||
|  |  | ||||||
| // Desired width of the AST data structure. | // Desired width of the AST data structure. | ||||||
| constexpr u32 AST_POD_Size = 128; | constexpr int const AST_POD_Size = 128; | ||||||
|  |  | ||||||
| /* | /* | ||||||
| 	Simple AST POD with functionality to seralize into C++ syntax. | 	Simple AST POD with functionality to seralize into C++ syntax. | ||||||
| @@ -212,42 +219,52 @@ struct AST | |||||||
| #	pragma endregion Member Functions | #	pragma endregion Member Functions | ||||||
|  |  | ||||||
| 	constexpr static | 	constexpr static | ||||||
| 	uw ArrSpecs_Cap = | 	int ArrSpecs_Cap = | ||||||
| 	( | 	( | ||||||
| 			AST_POD_Size | 			AST_POD_Size | ||||||
| 			- sizeof(AST*) * 3 | 			- sizeof(AST*) * 3 | ||||||
|  | 			- sizeof(Parser::Token*) | ||||||
|  | 			- sizeof(AST*) | ||||||
| 			- sizeof(StringCached) | 			- sizeof(StringCached) | ||||||
| 			- sizeof(CodeT) | 			- sizeof(CodeT) | ||||||
| 			- sizeof(ModuleFlag) | 			- sizeof(ModuleFlag) | ||||||
| 			- sizeof(u32) | 			- sizeof(int) | ||||||
| 	) | 	) | ||||||
| 	/ sizeof(SpecifierT) - 1; // -1 for 4 extra bytes | 	/ sizeof(int) - 1; // -1 for 4 extra bytes | ||||||
|  |  | ||||||
| 	union { | 	union { | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
|  | 			AST*      InlineCmt;       // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable | ||||||
| 			AST*      Attributes;      // Class, Enum, Function, Struct, Typedef, Union, Using, Variable | 			AST*      Attributes;      // Class, Enum, Function, Struct, Typedef, Union, Using, Variable | ||||||
| 			AST*      Specs;          // Function, Operator, Type symbol, Variable | 			AST*      Specs;           // Destructor, Function, Operator, Typename, Variable | ||||||
| 			union { | 			union { | ||||||
| 				AST*  InitializerList; // Constructor, Destructor | 				AST*  InitializerList; // Constructor | ||||||
| 				AST*  ParentType;      // Class, Struct | 				AST*  ParentType;      // Class, Struct, ParentType->Next has a possible list of interfaces. | ||||||
| 				AST*  ReturnType;      // Function, Operator | 				AST*  ReturnType;      // Function, Operator, Typename | ||||||
| 				AST*  UnderlyingType;  // Enum, Typedef | 				AST*  UnderlyingType;  // Enum, Typedef | ||||||
| 				AST*  ValueType;       // Parameter, Variable | 				AST*  ValueType;       // Parameter, Variable | ||||||
| 			}; | 			}; | ||||||
| 			union { | 			union { | ||||||
| 				AST*  BitfieldSize;    // Varaiable (Class/Struct Data Member) | 				AST*  BitfieldSize;    // Variable (Class/Struct Data Member) | ||||||
| 				AST*  Params;          // Function, Operator, Template | 				AST*  Params;          // Constructor, Function, Operator, Template, Typename | ||||||
| 			}; | 			}; | ||||||
| 			union { | 			union { | ||||||
| 				AST*  ArrExpr;        // Type Symbol | 				AST*  ArrExpr;          // Typename | ||||||
| 				AST*  Body;             // Class, Constructr, Destructor, Enum, Function, Namespace, Struct, Union | 				AST*  Body;             // Class, Constructr, Destructor, Enum, Function, Namespace, Struct, Union | ||||||
| 				AST*  Declaration;      // Friend, Template | 				AST*  Declaration;      // Friend, Template | ||||||
| 				AST*  Value;            // Parameter, Variable | 				AST*  Value;            // Parameter, Variable | ||||||
| 			}; | 			}; | ||||||
|  | 			union { | ||||||
|  | 				AST*  NextVar;          // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value ) | ||||||
|  | 				AST*  SuffixSpecs;      // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed ) | ||||||
|  | 			}; | ||||||
| 		}; | 		}; | ||||||
| 		StringCached  Content;          // Attributes, Comment, Execution, Include | 		StringCached  Content;          // Attributes, Comment, Execution, Include | ||||||
| 		SpecifierT    ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers | 		struct { | ||||||
|  | 			SpecifierT ArrSpecs[ArrSpecs_Cap]; // Specifiers | ||||||
|  | 			AST*       NextSpecs;                   // Specifiers; If ArrSpecs is full, then NextSpecs is used. | ||||||
|  | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	union { | 	union { | ||||||
| 		AST* Prev; | 		AST* Prev; | ||||||
| @@ -258,12 +275,14 @@ struct AST | |||||||
| 		AST* Next; | 		AST* Next; | ||||||
| 		AST* Back; | 		AST* Back; | ||||||
| 	}; | 	}; | ||||||
|  | 	Parser::Token*    Token; // Reference to starting token, only avaialble if it was derived from parsing. | ||||||
| 	AST*              Parent; | 	AST*              Parent; | ||||||
| 	StringCached      Name; | 	StringCached      Name; | ||||||
| 	CodeT             Type; | 	CodeT             Type; | ||||||
| 	ModuleFlag        ModuleFlags; | 	ModuleFlag        ModuleFlags; | ||||||
| 	union { | 	union { | ||||||
| 		b32           IsFunction;  // Used by typedef to not serialize the name field. | 		b32           IsFunction;  // Used by typedef to not serialize the name field. | ||||||
|  | 		b32           IsParamPack; // Used by typename to know if type should be considered a parameter pack. | ||||||
| 		OperatorT     Op; | 		OperatorT     Op; | ||||||
| 		AccessSpec    ParentAccess; | 		AccessSpec    ParentAccess; | ||||||
| 		s32           NumEntries; | 		s32           NumEntries; | ||||||
| @@ -275,28 +294,36 @@ struct AST_POD | |||||||
| 	union { | 	union { | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
| 			AST*      Attributes;     // Class, Enum, Function, Struct, Typename, Union, Using, Variable | 			AST*      InlineCmt;       // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable | ||||||
| 			AST*      Specs;          // Function, Operator, Type symbol, Variable | 			AST*      Attributes;      // Class, Enum, Function, Struct, Typedef, Union, Using, Variable | ||||||
|  | 			AST*      Specs;           // Destructor, Function, Operator, Typename, Variable | ||||||
| 			union { | 			union { | ||||||
| 				AST*  InitializerList; // Constructor, Destructor | 				AST*  InitializerList; // Constructor | ||||||
| 				AST*  ParentType;      // Class, Struct | 				AST*  ParentType;      // Class, Struct, ParentType->Next has a possible list of interfaces. | ||||||
| 				AST*  ReturnType;      // Function, Operator | 				AST*  ReturnType;      // Function, Operator, Typename | ||||||
| 				AST*  UnderlyingType;  // Enum, Typedef | 				AST*  UnderlyingType;  // Enum, Typedef | ||||||
| 				AST*  ValueType;       // Parameter, Variable | 				AST*  ValueType;       // Parameter, Variable | ||||||
| 			}; | 			}; | ||||||
| 			union { | 			union { | ||||||
| 				AST*  BitfieldSize;    // Varaiable (Class/Struct Data Member) | 				AST*  BitfieldSize;    // Variable (Class/Struct Data Member) | ||||||
| 				AST*  Params;          // Function, Operator, Template | 				AST*  Params;          // Constructor, Function, Operator, Template, Typename | ||||||
| 			}; | 			}; | ||||||
| 			union { | 			union { | ||||||
| 				AST*  ArrExpr;        // Type Symbol | 				AST*  ArrExpr;          // Typename | ||||||
| 				AST*  Body;             // Class, Constructr, Destructor, Enum, Function, Namespace, Struct, Union | 				AST*  Body;             // Class, Constructr, Destructor, Enum, Function, Namespace, Struct, Union | ||||||
| 				AST*  Declaration;      // Friend, Template | 				AST*  Declaration;      // Friend, Template | ||||||
| 				AST*  Value;            // Parameter, Variable | 				AST*  Value;            // Parameter, Variable | ||||||
| 			}; | 			}; | ||||||
|  | 			union { | ||||||
|  | 				AST*  NextVar;          // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value ) | ||||||
|  | 				AST*  SuffixSpecs;      // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed ) | ||||||
|  | 			}; | ||||||
| 		}; | 		}; | ||||||
| 		StringCached  Content;          // Attributes, Comment, Execution, Include | 		StringCached  Content;          // Attributes, Comment, Execution, Include | ||||||
|  | 		struct { | ||||||
| 			SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers | 			SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers | ||||||
|  | 			AST*       NextSpecs;                   // Specifiers; If ArrSpecs is full, then NextSpecs is used. | ||||||
|  | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	union { | 	union { | ||||||
| 		AST* Prev; | 		AST* Prev; | ||||||
| @@ -307,18 +334,27 @@ struct AST_POD | |||||||
| 		AST* Next; | 		AST* Next; | ||||||
| 		AST* Back; | 		AST* Back; | ||||||
| 	}; | 	}; | ||||||
|  | 	Parser::Token*    Token; // Reference to starting token, only avaialble if it was derived from parsing. | ||||||
| 	AST*              Parent; | 	AST*              Parent; | ||||||
| 	StringCached      Name; | 	StringCached      Name; | ||||||
| 	CodeT             Type; | 	CodeT             Type; | ||||||
| 	ModuleFlag        ModuleFlags; | 	ModuleFlag        ModuleFlags; | ||||||
| 	union { | 	union { | ||||||
| 		b32           IsFunction;  // Used by typedef to not serialize the name field. | 		b32           IsFunction;  // Used by typedef to not serialize the name field. | ||||||
|  | 		b32           IsParamPack; // Used by typename to know if type should be considered a parameter pack. | ||||||
| 		OperatorT     Op; | 		OperatorT     Op; | ||||||
| 		AccessSpec    ParentAccess; | 		AccessSpec    ParentAccess; | ||||||
| 		s32           NumEntries; | 		s32           NumEntries; | ||||||
| 	}; | 	}; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | struct test { | ||||||
|  | 	SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers | ||||||
|  | 	AST* NextSpecs;                   // Specifiers; If ArrSpecs is full, then NextSpecs is used. | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | constexpr int pls = sizeof(test); | ||||||
|  |  | ||||||
| // Its intended for the AST to have equivalent size to its POD. | // Its intended for the AST to have equivalent size to its POD. | ||||||
| // All extra functionality within the AST namespace should just be syntatic sugar. | // All extra functionality within the AST namespace should just be syntatic sugar. | ||||||
| static_assert( sizeof(AST)     == sizeof(AST_POD), "ERROR: AST IS NOT POD" ); | static_assert( sizeof(AST)     == sizeof(AST_POD), "ERROR: AST IS NOT POD" ); | ||||||
| @@ -439,7 +475,8 @@ struct CodeParam | |||||||
| 	} | 	} | ||||||
| 	CodeParam end() | 	CodeParam end() | ||||||
| 	{ | 	{ | ||||||
| 		return { (AST_Param*) rcast( AST*, ast)->Last }; | 		// return { (AST_Param*) rcast( AST*, ast)->Last }; | ||||||
|  | 		return { nullptr }; | ||||||
| 	} | 	} | ||||||
| 	CodeParam& operator++(); | 	CodeParam& operator++(); | ||||||
| 	CodeParam operator*() | 	CodeParam operator*() | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
| #	include "ast.hpp" | #	include "ast.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region AST Types | #pragma region AST Types | ||||||
| /* | /* | ||||||
| @@ -10,25 +12,27 @@ | |||||||
|  |  | ||||||
| struct AST_Body | struct AST_Body | ||||||
| { | { | ||||||
| 	char              _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 	char              _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 	Code              Front; | 	Code              Front; | ||||||
| 	Code              Back; | 	Code              Back; | ||||||
|  | 	Parser::Token*    Token; | ||||||
| 	Code              Parent; | 	Code              Parent; | ||||||
| 	StringCached      Name; | 	StringCached      Name; | ||||||
| 	CodeT             Type; | 	CodeT             Type; | ||||||
| 	char              _PAD_UNUSED_[ sizeof(ModuleFlag) ]; | 	char              _PAD_UNUSED_[ sizeof(ModuleFlag) ]; | ||||||
| 	s32 			  NumEntries; | 	s32 			  NumEntries; | ||||||
| }; | }; | ||||||
| static_assert( sizeof(AST_Body) == sizeof(AST), "ERROR: AST_Filtered is not the same size as AST"); | static_assert( sizeof(AST_Body) == sizeof(AST), "ERROR: AST_Body is not the same size as AST"); | ||||||
|  |  | ||||||
| struct AST_Attributes | struct AST_Attributes | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char          _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char          _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		StringCached  Content; | 		StringCached  Content; | ||||||
| 	}; | 	}; | ||||||
| 	Code              Prev; | 	Code              Prev; | ||||||
| 	Code              Next; | 	Code              Next; | ||||||
|  | 	Parser::Token*    Token; | ||||||
| 	Code              Parent; | 	Code              Parent; | ||||||
| 	StringCached      Name; | 	StringCached      Name; | ||||||
| 	CodeT             Type; | 	CodeT             Type; | ||||||
| @@ -39,11 +43,12 @@ static_assert( sizeof(AST_Attributes) == sizeof(AST), "ERROR: AST_Attributes is | |||||||
| struct AST_Comment | struct AST_Comment | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char          _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char          _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		StringCached  Content; | 		StringCached  Content; | ||||||
| 	}; | 	}; | ||||||
| 	Code              Prev; | 	Code              Prev; | ||||||
| 	Code              Next; | 	Code              Next; | ||||||
|  | 	Parser::Token*    Token; | ||||||
| 	Code              Parent; | 	Code              Parent; | ||||||
| 	StringCached      Name; | 	StringCached      Name; | ||||||
| 	CodeT             Type; | 	CodeT             Type; | ||||||
| @@ -54,18 +59,21 @@ static_assert( sizeof(AST_Comment) == sizeof(AST), "ERROR: AST_Comment is not th | |||||||
| struct AST_Class | struct AST_Class | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char                _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char                _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
|  | 			CodeComment     InlineCmt; // Only supported by forward declarations | ||||||
| 			CodeAttributes  Attributes; | 			CodeAttributes  Attributes; | ||||||
| 			char 	        _PAD_SPECS_ [ sizeof(AST*) ]; | 			char 	        _PAD_SPECS_ [ sizeof(AST*) ]; | ||||||
| 			CodeType        ParentType; | 			CodeType        ParentType; | ||||||
| 			char 	        _PAD_PARAMS_[ sizeof(AST*) ]; | 			char 	        _PAD_PARAMS_[ sizeof(AST*) ]; | ||||||
| 			CodeBody        Body; | 			CodeBody        Body; | ||||||
|  | 			char 	        _PAD_PROPERTIES_2_[ sizeof(AST*) ]; | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	CodeType                Last; | 	CodeType                Prev; | ||||||
| 	CodeType                Next; | 	CodeType                Next; | ||||||
|  | 	Parser::Token*          Token; | ||||||
| 	Code                    Parent; | 	Code                    Parent; | ||||||
| 	StringCached            Name; | 	StringCached            Name; | ||||||
| 	CodeT                   Type; | 	CodeT                   Type; | ||||||
| @@ -77,19 +85,23 @@ static_assert( sizeof(AST_Class) == sizeof(AST), "ERROR: AST_Class is not the sa | |||||||
| struct AST_Constructor | struct AST_Constructor | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char          _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char               _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
| 			char      _PAD_PROPERTIES_ [ sizeof(AST*) * 3 ]; | 			CodeComment    InlineCmt; // Only supported by forward declarations | ||||||
|  | 			char           _PAD_PROPERTIES_ [ sizeof(AST*) * 1 ]; | ||||||
|  | 			CodeSpecifiers Specs; | ||||||
| 			Code           InitializerList; | 			Code           InitializerList; | ||||||
| 			CodeParam      Params; | 			CodeParam      Params; | ||||||
| 			Code           Body; | 			Code           Body; | ||||||
|  | 			char 		   _PAD_PROPERTIES_2_ [ sizeof(AST*) * 2 ]; | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	Code              Prev; | 	Code              Prev; | ||||||
| 	Code              Next; | 	Code              Next; | ||||||
|  | 	Parser::Token*    Token; | ||||||
| 	Code              Parent; | 	Code              Parent; | ||||||
| 	StringCached      Name; | 	char              _PAD_NAME_[ sizeof(StringCached) ]; | ||||||
| 	CodeT             Type; | 	CodeT             Type; | ||||||
| 	char              _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; | 	char              _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; | ||||||
| }; | }; | ||||||
| @@ -98,11 +110,12 @@ static_assert( sizeof(AST_Constructor) == sizeof(AST), "ERROR: AST_Constructor i | |||||||
| struct AST_Define | struct AST_Define | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char 		  _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char          _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		StringCached  Content; | 		StringCached  Content; | ||||||
| 	}; | 	}; | ||||||
| 	Code              Prev; | 	Code              Prev; | ||||||
| 	Code              Next; | 	Code              Next; | ||||||
|  | 	Parser::Token*    Token; | ||||||
| 	Code              Parent; | 	Code              Parent; | ||||||
| 	StringCached      Name; | 	StringCached      Name; | ||||||
| 	CodeT             Type; | 	CodeT             Type; | ||||||
| @@ -113,19 +126,22 @@ static_assert( sizeof(AST_Define) == sizeof(AST), "ERROR: AST_Define is not the | |||||||
| struct AST_Destructor | struct AST_Destructor | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char               _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char               _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
|  | 			CodeComment    InlineCmt; | ||||||
| 			char           _PAD_PROPERTIES_ [ sizeof(AST*) * 1 ]; | 			char           _PAD_PROPERTIES_ [ sizeof(AST*) * 1 ]; | ||||||
| 			CodeSpecifiers Specs; | 			CodeSpecifiers Specs; | ||||||
| 			char           _PAD_PROPERTIES_2_ [ sizeof(AST*) * 2 ]; | 			char           _PAD_PROPERTIES_2_ [ sizeof(AST*) * 2 ]; | ||||||
| 			Code           Body; | 			Code           Body; | ||||||
|  | 			char 		   _PAD_PROPERTIES_3_ [ sizeof(AST*) ]; | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	Code                   Prev; | 	Code                   Prev; | ||||||
| 	Code                   Next; | 	Code                   Next; | ||||||
|  | 	Parser::Token*         Token; | ||||||
| 	Code                   Parent; | 	Code                   Parent; | ||||||
| 	StringCached           Name; | 	char                   _PAD_NAME_[ sizeof(StringCached) ]; | ||||||
| 	CodeT                  Type; | 	CodeT                  Type; | ||||||
| 	char                   _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; | 	char                   _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; | ||||||
| }; | }; | ||||||
| @@ -134,18 +150,21 @@ static_assert( sizeof(AST_Destructor) == sizeof(AST), "ERROR: AST_Destructor is | |||||||
| struct AST_Enum | struct AST_Enum | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char                _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char               _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
|  | 			CodeComment    InlineCmt; | ||||||
| 			CodeAttributes Attributes; | 			CodeAttributes Attributes; | ||||||
| 			char           _PAD_SPEC_  [ sizeof(AST*) ]; | 			char           _PAD_SPEC_  [ sizeof(AST*) ]; | ||||||
| 			CodeType       UnderlyingType; | 			CodeType       UnderlyingType; | ||||||
| 			char	       _PAD_PARAMS_[ sizeof(AST*) ]; | 			char	       _PAD_PARAMS_[ sizeof(AST*) ]; | ||||||
| 			CodeBody       Body; | 			CodeBody       Body; | ||||||
|  | 			char 	       _PAD_PROPERTIES_2_[ sizeof(AST*) ]; | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	Code                   Prev; | 	Code                   Prev; | ||||||
| 	Code                   Next; | 	Code                   Next; | ||||||
|  | 	Parser::Token*         Token; | ||||||
| 	Code                   Parent; | 	Code                   Parent; | ||||||
| 	StringCached           Name; | 	StringCached           Name; | ||||||
| 	CodeT                  Type; | 	CodeT                  Type; | ||||||
| @@ -157,14 +176,12 @@ static_assert( sizeof(AST_Enum) == sizeof(AST), "ERROR: AST_Enum is not the same | |||||||
| struct AST_Exec | struct AST_Exec | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char          _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char          _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		struct | 		StringCached  Content; | ||||||
| 		{ |  | ||||||
| 			char      _PAD_PROPERTIES_[ sizeof(AST*) * 5 ]; |  | ||||||
| 		}; |  | ||||||
| 	}; | 	}; | ||||||
| 	Code              Prev; | 	Code              Prev; | ||||||
| 	Code              Next; | 	Code              Next; | ||||||
|  | 	Parser::Token*    Token; | ||||||
| 	Code              Parent; | 	Code              Parent; | ||||||
| 	StringCached      Name; | 	StringCached      Name; | ||||||
| 	CodeT             Type; | 	CodeT             Type; | ||||||
| @@ -175,15 +192,17 @@ static_assert( sizeof(AST_Exec) == sizeof(AST), "ERROR: AST_Exec is not the same | |||||||
| struct AST_Extern | struct AST_Extern | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char          _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char          _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
| 			char      _PAD_PROPERTIES_[ sizeof(AST*) * 4 ]; | 			char      _PAD_PROPERTIES_[ sizeof(AST*) * 5 ]; | ||||||
| 			CodeBody  Body; | 			CodeBody  Body; | ||||||
|  | 			char      _PAD_PROPERTIES_2_[ sizeof(AST*) ]; | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	Code              Prev; | 	Code              Prev; | ||||||
| 	Code              Next; | 	Code              Next; | ||||||
|  | 	Parser::Token*    Token; | ||||||
| 	Code              Parent; | 	Code              Parent; | ||||||
| 	StringCached      Name; | 	StringCached      Name; | ||||||
| 	CodeT             Type; | 	CodeT             Type; | ||||||
| @@ -194,11 +213,12 @@ static_assert( sizeof(AST_Extern) == sizeof(AST), "ERROR: AST_Extern is not the | |||||||
| struct AST_Include | struct AST_Include | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char          _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char          _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		StringCached  Content; | 		StringCached  Content; | ||||||
| 	}; | 	}; | ||||||
| 	Code              Prev; | 	Code              Prev; | ||||||
| 	Code              Next; | 	Code              Next; | ||||||
|  | 	Parser::Token*    Token; | ||||||
| 	Code              Parent; | 	Code              Parent; | ||||||
| 	StringCached      Name; | 	StringCached      Name; | ||||||
| 	CodeT             Type; | 	CodeT             Type; | ||||||
| @@ -209,15 +229,18 @@ static_assert( sizeof(AST_Include) == sizeof(AST), "ERROR: AST_Include is not th | |||||||
| struct AST_Friend | struct AST_Friend | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char          _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char            _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
|  | 			CodeComment InlineCmt; | ||||||
| 			char        _PAD_PROPERTIES_[ sizeof(AST*) * 4 ]; | 			char        _PAD_PROPERTIES_[ sizeof(AST*) * 4 ]; | ||||||
| 			Code        Declaration; | 			Code        Declaration; | ||||||
|  | 			char 	    _PAD_PROPERTIES_2_[ sizeof(AST*) ]; | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	Code              Prev; | 	Code              Prev; | ||||||
| 	Code              Next; | 	Code              Next; | ||||||
|  | 	Parser::Token*    Token; | ||||||
| 	Code              Parent; | 	Code              Parent; | ||||||
| 	StringCached      Name; | 	StringCached      Name; | ||||||
| 	CodeT             Type; | 	CodeT             Type; | ||||||
| @@ -228,19 +251,22 @@ static_assert( sizeof(AST_Friend) == sizeof(AST), "ERROR: AST_Friend is not the | |||||||
| struct AST_Fn | struct AST_Fn | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char                _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char               _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
|  | 			CodeComment     InlineCmt; | ||||||
| 			CodeAttributes  Attributes; | 			CodeAttributes  Attributes; | ||||||
| 			CodeSpecifiers  Specs; | 			CodeSpecifiers  Specs; | ||||||
| 			CodeType        ReturnType; | 			CodeType        ReturnType; | ||||||
| 			CodeParam 	    Params; | 			CodeParam 	    Params; | ||||||
| 			CodeBody        Body; | 			CodeBody        Body; | ||||||
|  | 			char 	        _PAD_PROPERTIES_ [ sizeof(AST*) ]; | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	Code                    Prev; | 	Code                    Prev; | ||||||
| 	Code                    Parent; |  | ||||||
| 	Code                    Next; | 	Code                    Next; | ||||||
|  | 	Parser::Token*          Token; | ||||||
|  | 	Code                    Parent; | ||||||
| 	StringCached            Name; | 	StringCached            Name; | ||||||
| 	CodeT                   Type; | 	CodeT                   Type; | ||||||
| 	ModuleFlag              ModuleFlags; | 	ModuleFlag              ModuleFlags; | ||||||
| @@ -250,9 +276,10 @@ static_assert( sizeof(AST_Fn) == sizeof(AST), "ERROR: AST_Fn is not the same siz | |||||||
|  |  | ||||||
| struct AST_Module | struct AST_Module | ||||||
| { | { | ||||||
| 	char              _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 	char              _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 	Code              Prev; | 	Code              Prev; | ||||||
| 	Code              Next; | 	Code              Next; | ||||||
|  | 	Parser::Token*    Token; | ||||||
| 	Code              Parent; | 	Code              Parent; | ||||||
| 	StringCached      Name; | 	StringCached      Name; | ||||||
| 	CodeT             Type; | 	CodeT             Type; | ||||||
| @@ -264,14 +291,16 @@ static_assert( sizeof(AST_Module) == sizeof(AST), "ERROR: AST_Module is not the | |||||||
| struct AST_NS | struct AST_NS | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char          _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char          _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		struct { | 		struct { | ||||||
| 			char 	  _PAD_PROPERTIES_[ sizeof(AST*) * 4 ]; | 			char 	  _PAD_PROPERTIES_[ sizeof(AST*) * 5 ]; | ||||||
| 			CodeBody  Body; | 			CodeBody  Body; | ||||||
|  | 			char 	  _PAD_PROPERTIES_2_[ sizeof(AST*) ]; | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	Code              Prev; | 	Code              Prev; | ||||||
| 	Code              Next; | 	Code              Next; | ||||||
|  | 	Parser::Token*    Token; | ||||||
| 	Code              Parent; | 	Code              Parent; | ||||||
| 	StringCached      Name; | 	StringCached      Name; | ||||||
| 	CodeT             Type; | 	CodeT             Type; | ||||||
| @@ -283,18 +312,21 @@ static_assert( sizeof(AST_NS) == sizeof(AST), "ERROR: AST_NS is not the same siz | |||||||
| struct AST_Operator | struct AST_Operator | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char                _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char                _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
|  | 			CodeComment     InlineCmt; | ||||||
| 			CodeAttributes  Attributes; | 			CodeAttributes  Attributes; | ||||||
| 			CodeSpecifiers  Specs; | 			CodeSpecifiers  Specs; | ||||||
| 			CodeType        ReturnType; | 			CodeType        ReturnType; | ||||||
| 			CodeParam 	    Params; | 			CodeParam 	    Params; | ||||||
| 			CodeBody        Body; | 			CodeBody        Body; | ||||||
|  | 			char 	        _PAD_PROPERTIES_ [ sizeof(AST*) ]; | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	Code           Prev; | 	Code           Prev; | ||||||
| 	Code           Next; | 	Code           Next; | ||||||
|  | 	Parser::Token* Token; | ||||||
| 	Code           Parent; | 	Code           Parent; | ||||||
| 	StringCached   Name; | 	StringCached   Name; | ||||||
| 	CodeT          Type; | 	CodeT          Type; | ||||||
| @@ -306,18 +338,21 @@ static_assert( sizeof(AST_Operator) == sizeof(AST), "ERROR: AST_Operator is not | |||||||
| struct AST_OpCast | struct AST_OpCast | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char          _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char               _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
|  | 			CodeComment    InlineCmt; | ||||||
| 			char 	       _PAD_PROPERTIES_[ sizeof(AST*)  ]; | 			char 	       _PAD_PROPERTIES_[ sizeof(AST*)  ]; | ||||||
| 			CodeSpecifiers Specs; | 			CodeSpecifiers Specs; | ||||||
| 			CodeType       ValueType; | 			CodeType       ValueType; | ||||||
| 			char 	       _PAD_PROPERTIES_2_[ sizeof(AST*) ]; | 			char 	       _PAD_PROPERTIES_2_[ sizeof(AST*) ]; | ||||||
| 			CodeBody       Body; | 			CodeBody       Body; | ||||||
|  | 			char 	       _PAD_PROPERTIES_3_[ sizeof(AST*) ]; | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	Code              Prev; | 	Code              Prev; | ||||||
| 	Code              Next; | 	Code              Next; | ||||||
|  | 	Parser::Token*    Token; | ||||||
| 	Code              Parent; | 	Code              Parent; | ||||||
| 	StringCached      Name; | 	StringCached      Name; | ||||||
| 	CodeT             Type; | 	CodeT             Type; | ||||||
| @@ -328,17 +363,19 @@ static_assert( sizeof(AST_OpCast) == sizeof(AST), "ERROR: AST_OpCast is not the | |||||||
| struct AST_Param | struct AST_Param | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char 		  _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char          _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
| 			char 	  _PAD_PROPERTIES_2_[ sizeof(AST*) * 2 ]; | 			char 	  _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ]; | ||||||
| 			CodeType  ValueType; | 			CodeType  ValueType; | ||||||
| 			char 	  _PAD_PROPERTIES_[ sizeof(AST*) ]; | 			char 	  _PAD_PROPERTIES_[ sizeof(AST*) ]; | ||||||
| 			Code      Value; | 			Code      Value; | ||||||
|  | 			char 	  _PAD_PROPERTIES_3_[ sizeof(AST*) ]; | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	CodeParam         Last; | 	CodeParam         Last; | ||||||
| 	CodeParam         Next; | 	CodeParam         Next; | ||||||
|  | 	Parser::Token*    Token; | ||||||
| 	Code              Parent; | 	Code              Parent; | ||||||
| 	StringCached      Name; | 	StringCached      Name; | ||||||
| 	CodeT             Type; | 	CodeT             Type; | ||||||
| @@ -350,11 +387,12 @@ static_assert( sizeof(AST_Param) == sizeof(AST), "ERROR: AST_Param is not the sa | |||||||
| struct AST_Pragma | struct AST_Pragma | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char 		  _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char          _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		StringCached  Content; | 		StringCached  Content; | ||||||
| 	}; | 	}; | ||||||
| 	Code              Prev; | 	Code              Prev; | ||||||
| 	Code              Next; | 	Code              Next; | ||||||
|  | 	Parser::Token*    Token; | ||||||
| 	Code              Parent; | 	Code              Parent; | ||||||
| 	StringCached      Name; | 	StringCached      Name; | ||||||
| 	CodeT             Type; | 	CodeT             Type; | ||||||
| @@ -365,11 +403,12 @@ static_assert( sizeof(AST_Pragma) == sizeof(AST), "ERROR: AST_Pragma is not the | |||||||
| struct AST_PreprocessCond | struct AST_PreprocessCond | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char 		  _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char          _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		StringCached  Content; | 		StringCached  Content; | ||||||
| 	}; | 	}; | ||||||
| 	Code              Prev; | 	Code              Prev; | ||||||
| 	Code              Next; | 	Code              Next; | ||||||
|  | 	Parser::Token*    Token; | ||||||
| 	Code              Parent; | 	Code              Parent; | ||||||
| 	StringCached      Name; | 	StringCached      Name; | ||||||
| 	CodeT             Type; | 	CodeT             Type; | ||||||
| @@ -380,8 +419,10 @@ static_assert( sizeof(AST_PreprocessCond) == sizeof(AST), "ERROR: AST_Preprocess | |||||||
| struct AST_Specifiers | struct AST_Specifiers | ||||||
| { | { | ||||||
| 	SpecifierT        ArrSpecs[ AST::ArrSpecs_Cap ]; | 	SpecifierT        ArrSpecs[ AST::ArrSpecs_Cap ]; | ||||||
|  | 	CodeSpecifiers    NextSpecs; | ||||||
| 	Code              Prev; | 	Code              Prev; | ||||||
| 	Code              Next; | 	Code              Next; | ||||||
|  | 	Parser::Token*    Token; | ||||||
| 	Code              Parent; | 	Code              Parent; | ||||||
| 	StringCached      Name; | 	StringCached      Name; | ||||||
| 	CodeT             Type; | 	CodeT             Type; | ||||||
| @@ -393,18 +434,21 @@ struct AST_Specifiers | |||||||
| struct AST_Struct | struct AST_Struct | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char               _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char               _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
|  | 			CodeComment    InlineCmt; | ||||||
| 			CodeAttributes Attributes; | 			CodeAttributes Attributes; | ||||||
| 			char 	       _PAD_SPECS_ [ sizeof(AST*) ]; | 			char 	       _PAD_SPECS_ [ sizeof(AST*) ]; | ||||||
| 			CodeType       ParentType; | 			CodeType       ParentType; | ||||||
| 			char 	       _PAD_PARAMS_[ sizeof(AST*) ]; | 			char 	       _PAD_PARAMS_[ sizeof(AST*) ]; | ||||||
| 			CodeBody       Body; | 			CodeBody       Body; | ||||||
|  | 			char 	       _PAD_PROPERTIES_2_[ sizeof(AST*) ]; | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	CodeType               Last; | 	CodeType               Prev; | ||||||
| 	CodeType               Next; | 	CodeType               Next; | ||||||
|  | 	Parser::Token*         Token; | ||||||
| 	Code                   Parent; | 	Code                   Parent; | ||||||
| 	StringCached           Name; | 	StringCached           Name; | ||||||
| 	CodeT                  Type; | 	CodeT                  Type; | ||||||
| @@ -416,16 +460,18 @@ static_assert( sizeof(AST_Struct) == sizeof(AST), "ERROR: AST_Struct is not the | |||||||
| struct AST_Template | struct AST_Template | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char 		       _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char               _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
| 			char 	       _PAD_PROPERTIES_[ sizeof(AST*) * 3 ]; | 			char 	       _PAD_PROPERTIES_[ sizeof(AST*) * 4 ]; | ||||||
| 			CodeParam 	   Params; | 			CodeParam 	   Params; | ||||||
| 			Code           Declaration; | 			Code           Declaration; | ||||||
|  | 			char 	       _PAD_PROPERTIES_2_[ sizeof(AST*) ]; | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	Code                   Prev; | 	Code                   Prev; | ||||||
| 	Code                   Next; | 	Code                   Next; | ||||||
|  | 	Parser::Token*         Token; | ||||||
| 	Code                   Parent; | 	Code                   Parent; | ||||||
| 	StringCached           Name; | 	StringCached           Name; | ||||||
| 	CodeT                  Type; | 	CodeT                  Type; | ||||||
| @@ -437,37 +483,44 @@ static_assert( sizeof(AST_Template) == sizeof(AST), "ERROR: AST_Template is not | |||||||
| struct AST_Type | struct AST_Type | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char 		       _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char               _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
|  | 			char           _PAD_INLINE_CMT_[ sizeof(AST*) ]; | ||||||
| 			CodeAttributes Attributes; | 			CodeAttributes Attributes; | ||||||
| 			CodeSpecifiers Specs; | 			CodeSpecifiers Specs; | ||||||
| 			char 	       _PAD_PROPERTIES_[ sizeof(AST*) * 2 ]; | 			CodeType       ReturnType;      // Only used for function signatures | ||||||
|  | 			CodeParam      Params;          // Only used for function signatures | ||||||
| 			Code           ArrExpr; | 			Code           ArrExpr; | ||||||
|  | 			CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	Code                   Prev; | 	Code                   Prev; | ||||||
| 	Code                   Next; | 	Code                   Next; | ||||||
|  | 	Parser::Token*         Token; | ||||||
| 	Code                   Parent; | 	Code                   Parent; | ||||||
| 	StringCached           Name; | 	StringCached           Name; | ||||||
| 	CodeT                  Type; | 	CodeT                  Type; | ||||||
| 	char 			       _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; | 	char 			       _PAD_UNUSED_[ sizeof(ModuleFlag) ]; | ||||||
|  | 	b32                    IsParamPack; | ||||||
| }; | }; | ||||||
| static_assert( sizeof(AST_Type) == sizeof(AST), "ERROR: AST_Type is not the same size as AST"); | static_assert( sizeof(AST_Type) == sizeof(AST), "ERROR: AST_Type is not the same size as AST"); | ||||||
|  |  | ||||||
| struct AST_Typedef | struct AST_Typedef | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char 		       _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char               _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
|  | 			CodeComment    InlineCmt; | ||||||
| 			char 	       _PAD_PROPERTIES_[ sizeof(AST*) * 2 ]; | 			char 	       _PAD_PROPERTIES_[ sizeof(AST*) * 2 ]; | ||||||
| 			Code           UnderlyingType; | 			Code           UnderlyingType; | ||||||
| 			char 	       _PAD_PROPERTIES_2_[ sizeof(AST*) * 2 ]; | 			char 	       _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ]; | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	Code                   Prev; | 	Code                   Prev; | ||||||
| 	Code                   Next; | 	Code                   Next; | ||||||
|  | 	Parser::Token*         Token; | ||||||
| 	Code                   Parent; | 	Code                   Parent; | ||||||
| 	StringCached           Name; | 	StringCached           Name; | ||||||
| 	CodeT                  Type; | 	CodeT                  Type; | ||||||
| @@ -479,16 +532,19 @@ static_assert( sizeof(AST_Typedef) == sizeof(AST), "ERROR: AST_Typedef is not th | |||||||
| struct AST_Union | struct AST_Union | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char 		       _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char               _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
|  | 			char           _PAD_INLINE_CMT_[ sizeof(AST*) ]; | ||||||
| 			CodeAttributes Attributes; | 			CodeAttributes Attributes; | ||||||
| 			char 	       _PAD_PROPERTIES_[ sizeof(AST*) * 3 ]; | 			char 	       _PAD_PROPERTIES_[ sizeof(AST*) * 3 ]; | ||||||
| 			CodeBody       Body; | 			CodeBody       Body; | ||||||
|  | 			char 	       _PAD_PROPERTIES_2_[ sizeof(AST*) ]; | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	Code                   Prev; | 	Code                   Prev; | ||||||
| 	Code                   Next; | 	Code                   Next; | ||||||
|  | 	Parser::Token*         Token; | ||||||
| 	Code                   Parent; | 	Code                   Parent; | ||||||
| 	StringCached           Name; | 	StringCached           Name; | ||||||
| 	CodeT                  Type; | 	CodeT                  Type; | ||||||
| @@ -500,17 +556,19 @@ static_assert( sizeof(AST_Union) == sizeof(AST), "ERROR: AST_Union is not the sa | |||||||
| struct AST_Using | struct AST_Using | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char 		        _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char                _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
|  | 			CodeComment     InlineCmt; | ||||||
| 			CodeAttributes  Attributes; | 			CodeAttributes  Attributes; | ||||||
| 			char 	        _PAD_SPECS_     [ sizeof(AST*) ]; | 			char 	        _PAD_SPECS_     [ sizeof(AST*) ]; | ||||||
| 			CodeType        UnderlyingType; | 			CodeType        UnderlyingType; | ||||||
| 			char 	        _PAD_PROPERTIES_[ sizeof(AST*) * 2 ]; | 			char 	        _PAD_PROPERTIES_[ sizeof(AST*) * 3 ]; | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	Code                    Prev; | 	Code                    Prev; | ||||||
| 	Code                    Next; | 	Code                    Next; | ||||||
|  | 	Parser::Token*          Token; | ||||||
| 	Code                    Parent; | 	Code                    Parent; | ||||||
| 	StringCached            Name; | 	StringCached            Name; | ||||||
| 	CodeT                   Type; | 	CodeT                   Type; | ||||||
| @@ -522,18 +580,21 @@ static_assert( sizeof(AST_Using) == sizeof(AST), "ERROR: AST_Using is not the sa | |||||||
| struct AST_Var | struct AST_Var | ||||||
| { | { | ||||||
| 	union { | 	union { | ||||||
| 		char               _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; | 		char               _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ]; | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
|  | 			CodeComment    InlineCmt; | ||||||
| 			CodeAttributes Attributes; | 			CodeAttributes Attributes; | ||||||
| 			CodeSpecifiers Specs; | 			CodeSpecifiers Specs; | ||||||
| 			CodeType       ValueType; | 			CodeType       ValueType; | ||||||
| 			Code           BitfieldSize; | 			Code           BitfieldSize; | ||||||
| 			Code           Value; | 			Code           Value; | ||||||
|  | 			CodeVar		   NextVar; | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	Code                   Prev; | 	Code                   Prev; | ||||||
| 	Code                   Next; | 	Code                   Next; | ||||||
|  | 	Parser::Token*         Token; | ||||||
| 	Code                   Parent; | 	Code                   Parent; | ||||||
| 	StringCached           Name; | 	StringCached           Name; | ||||||
| 	CodeT                  Type; | 	CodeT                  Type; | ||||||
|   | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,6 +1,9 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #pragma once | #pragma once | ||||||
|  | #include "components/types.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| // This file was generated automatially by gen.bootstrap.cpp (See: https://github.com/Ed94/gencpp) | // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) | ||||||
|  |  | ||||||
| namespace ECode | namespace ECode | ||||||
| { | { | ||||||
|   | |||||||
| @@ -1,6 +1,9 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #pragma once | #pragma once | ||||||
|  | #include "components/types.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| // This file was generated automatially by gen.bootstrap.cpp (See: https://github.com/Ed94/gencpp) | // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) | ||||||
|  |  | ||||||
| namespace EOperator | namespace EOperator | ||||||
| { | { | ||||||
|   | |||||||
| @@ -1,6 +1,9 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #pragma once | #pragma once | ||||||
|  | #include "components/types.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| // This file was generated automatially by gen.bootstrap.cpp (See: https://github.com/Ed94/gencpp) | // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) | ||||||
|  |  | ||||||
| namespace ESpecifier | namespace ESpecifier | ||||||
| { | { | ||||||
| @@ -29,6 +32,7 @@ namespace ESpecifier | |||||||
| 		Virtual, | 		Virtual, | ||||||
| 		Const, | 		Const, | ||||||
| 		Final, | 		Final, | ||||||
|  | 		NoExceptions, | ||||||
| 		Override, | 		Override, | ||||||
| 		Pure, | 		Pure, | ||||||
| 		NumSpecifiers | 		NumSpecifiers | ||||||
| @@ -65,6 +69,7 @@ namespace ESpecifier | |||||||
| 			{ sizeof( "virtual" ),       "virtual"      }, | 			{ sizeof( "virtual" ),       "virtual"      }, | ||||||
| 			{ sizeof( "const" ),         "const"        }, | 			{ sizeof( "const" ),         "const"        }, | ||||||
| 			{ sizeof( "final" ),         "final"        }, | 			{ sizeof( "final" ),         "final"        }, | ||||||
|  | 			{ sizeof( "noexcept" ),      "noexcept"     }, | ||||||
| 			{ sizeof( "override" ),      "override"     }, | 			{ sizeof( "override" ),      "override"     }, | ||||||
| 			{ sizeof( "= 0" ),           "= 0"          }, | 			{ sizeof( "= 0" ),           "= 0"          }, | ||||||
| 		}; | 		}; | ||||||
|   | |||||||
| @@ -1,6 +1,9 @@ | |||||||
| // This file was generated automatially by gen.bootstrap.cpp (See: https://github.com/Ed94/gencpp) | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
|  |  | ||||||
| #pragma once | #pragma once | ||||||
|  | #include "components/types.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) | ||||||
|  |  | ||||||
| namespace Parser | namespace Parser | ||||||
| { | { | ||||||
| @@ -128,7 +131,7 @@ namespace Parser | |||||||
| 				{ sizeof( "]" ),                   "]"                  }, | 				{ sizeof( "]" ),                   "]"                  }, | ||||||
| 				{ sizeof( "(" ),                   "("                  }, | 				{ sizeof( "(" ),                   "("                  }, | ||||||
| 				{ sizeof( ")" ),                   ")"                  }, | 				{ sizeof( ")" ),                   ")"                  }, | ||||||
| 				{ sizeof( "__comemnt__" ),         "__comemnt__"        }, | 				{ sizeof( "__comment__" ),         "__comment__"        }, | ||||||
| 				{ sizeof( "__comment_end__" ),     "__comment_end__"    }, | 				{ sizeof( "__comment_end__" ),     "__comment_end__"    }, | ||||||
| 				{ sizeof( "__comment_start__" ),   "__comment_start__"  }, | 				{ sizeof( "__comment_start__" ),   "__comment_start__"  }, | ||||||
| 				{ sizeof( "__character__" ),       "__character__"      }, | 				{ sizeof( "__character__" ),       "__character__"      }, | ||||||
|   | |||||||
| @@ -1,11 +1,13 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #pragma once | #pragma once | ||||||
| #include "inlines.hpp" | #include "inlines.hpp" | ||||||
| #include "gen/ast_inlines.hpp" | #include "gen/ast_inlines.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region Constants | #pragma region Constants | ||||||
|  |  | ||||||
| #ifndef GEN_GLOBAL_BUCKET_SIZE | #ifndef GEN_GLOBAL_BUCKET_SIZE | ||||||
| #	define GEN_GLOBAL_BUCKET_SIZE megabytes(4) | #	define GEN_GLOBAL_BUCKET_SIZE megabytes(8) | ||||||
| #endif | #endif | ||||||
| #ifndef GEN_CODEPOOL_NUM_BLOCKS | #ifndef GEN_CODEPOOL_NUM_BLOCKS | ||||||
| #	define GEN_CODEPOOL_NUM_BLOCKS kilobytes(16) | #	define GEN_CODEPOOL_NUM_BLOCKS kilobytes(16) | ||||||
| @@ -29,7 +31,7 @@ | |||||||
| #	define GEN_LEX_ALLOCATOR_SIZE megabytes(4) | #	define GEN_LEX_ALLOCATOR_SIZE megabytes(4) | ||||||
| #endif | #endif | ||||||
| #ifndef GEN_BUILDER_STR_BUFFER_RESERVE | #ifndef GEN_BUILDER_STR_BUFFER_RESERVE | ||||||
| #	define GEN_BUILDER_STR_BUFFER_RESERVE megabytes(1) | #	define GEN_BUILDER_STR_BUFFER_RESERVE megabytes(2) | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| // These constexprs are used for allocation behavior of data structures | // These constexprs are used for allocation behavior of data structures | ||||||
| @@ -84,6 +86,7 @@ extern CodeSpecifiers spec_internal_linkage; | |||||||
| extern CodeSpecifiers spec_local_persist; | extern CodeSpecifiers spec_local_persist; | ||||||
| extern CodeSpecifiers spec_mutable; | extern CodeSpecifiers spec_mutable; | ||||||
| extern CodeSpecifiers spec_neverinline; | extern CodeSpecifiers spec_neverinline; | ||||||
|  | extern CodeSpecifiers spec_noexcept; | ||||||
| extern CodeSpecifiers spec_override; | extern CodeSpecifiers spec_override; | ||||||
| extern CodeSpecifiers spec_ptr; | extern CodeSpecifiers spec_ptr; | ||||||
| extern CodeSpecifiers spec_pure; | extern CodeSpecifiers spec_pure; | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #pragma once | #pragma once | ||||||
| #include "interface.hpp" | #include "interface.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| void AST::append( AST* other ) | void AST::append( AST* other ) | ||||||
| { | { | ||||||
| @@ -25,43 +27,6 @@ void AST::append( AST* other ) | |||||||
| 	NumEntries++; | 	NumEntries++; | ||||||
| } | } | ||||||
|  |  | ||||||
| char const* AST::debug_str() |  | ||||||
| { |  | ||||||
| 	if ( Parent ) |  | ||||||
| 	{ |  | ||||||
| 		char const* fmt = stringize( |  | ||||||
| 			\nType    : %s |  | ||||||
| 			\nParent  : %s %s |  | ||||||
| 			\nName    : %s |  | ||||||
| 		); |  | ||||||
|  |  | ||||||
| 		// These should be used immediately in a log. |  | ||||||
| 		// Thus if its desired to keep the debug str |  | ||||||
| 		// for multiple calls to bprintf, |  | ||||||
| 		// allocate this to proper string. |  | ||||||
| 		return str_fmt_buf( fmt |  | ||||||
| 			,	type_str() |  | ||||||
| 			,	Parent->Name |  | ||||||
| 			,   Parent->type_str() |  | ||||||
| 			,	Name     ? Name         : "" |  | ||||||
| 		); |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	char const* fmt = stringize( |  | ||||||
| 		\nType    : %s |  | ||||||
| 		\nName    : %s |  | ||||||
| 	); |  | ||||||
|  |  | ||||||
| 	// These should be used immediately in a log. |  | ||||||
| 	// Thus if its desired to keep the debug str |  | ||||||
| 	// for multiple calls to bprintf, |  | ||||||
| 	// allocate this to proper string. |  | ||||||
| 	return str_fmt_buf( fmt |  | ||||||
| 		,	type_str() |  | ||||||
| 		,	Name     ? Name         : "" |  | ||||||
| 	); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| Code& AST::entry( u32 idx ) | Code& AST::entry( u32 idx ) | ||||||
| { | { | ||||||
| 	AST** current = & Front; | 	AST** current = & Front; | ||||||
| @@ -102,15 +67,21 @@ Code& Code::operator ++() | |||||||
|  |  | ||||||
| void CodeClass::add_interface( CodeType type ) | void CodeClass::add_interface( CodeType type ) | ||||||
| { | { | ||||||
| 	if ( ! ast->Next ) | 	CodeType possible_slot = ast->ParentType; | ||||||
|  | 	if ( possible_slot.ast ) | ||||||
| 	{ | 	{ | ||||||
| 		ast->Next = type; | 		// Were adding an interface to parent type, so we need to make sure the parent type is public. | ||||||
| 		ast->Last = ast->Next; | 		ast->ParentAccess = AccessSpec::Public; | ||||||
| 		return; | 		// If your planning on adding a proper parent, | ||||||
|  | 		// then you'll need to move this over to ParentType->next and update ParentAccess accordingly. | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	ast->Next->Next = type; | 	while ( possible_slot.ast != nullptr ) | ||||||
| 	ast->Last       = ast->Next->Next; | 	{ | ||||||
|  | 		possible_slot.ast = (AST_Type*) possible_slot->Next.ast; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	possible_slot.ast = type.ast; | ||||||
| } | } | ||||||
|  |  | ||||||
| void CodeParam::append( CodeParam other ) | void CodeParam::append( CodeParam other ) | ||||||
| @@ -164,14 +135,21 @@ CodeParam& CodeParam::operator ++() | |||||||
|  |  | ||||||
| void CodeStruct::add_interface( CodeType type ) | void CodeStruct::add_interface( CodeType type ) | ||||||
| { | { | ||||||
| 	if ( ! ast->Next ) | 	CodeType possible_slot = ast->ParentType; | ||||||
|  | 	if ( possible_slot.ast ) | ||||||
| 	{ | 	{ | ||||||
| 		ast->Next = type; | 		// Were adding an interface to parent type, so we need to make sure the parent type is public. | ||||||
| 		ast->Last = ast->Next; | 		ast->ParentAccess = AccessSpec::Public; | ||||||
|  | 		// If your planning on adding a proper parent, | ||||||
|  | 		// then you'll need to move this over to ParentType->next and update ParentAccess accordingly. | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	ast->Next->Next = type; | 	while ( possible_slot.ast != nullptr ) | ||||||
| 	ast->Last       = ast->Next->Next; | 	{ | ||||||
|  | 		possible_slot.ast = (AST_Type*) possible_slot->Next.ast; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	possible_slot.ast = type.ast; | ||||||
| } | } | ||||||
|  |  | ||||||
| CodeBody def_body( CodeT type ) | CodeBody def_body( CodeT type ) | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #pragma once | #pragma once | ||||||
| #include "ast.cpp" | #include "ast.cpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| internal void init_parser(); | internal void init_parser(); | ||||||
| internal void deinit_parser(); | internal void deinit_parser(); | ||||||
| @@ -173,6 +175,11 @@ void define_constants() | |||||||
| #endif | #endif | ||||||
| #	undef def_constant_code_type | #	undef def_constant_code_type | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #	define def_constant_spec( Type_, ... )                                  \ | ||||||
|  | 		spec_##Type_ = def_specifiers( num_args(__VA_ARGS__), __VA_ARGS__); \ | ||||||
|  | 		spec_##Type_.set_global(); | ||||||
|  |  | ||||||
| #	pragma push_macro("forceinline") | #	pragma push_macro("forceinline") | ||||||
| #	pragma push_macro("global") | #	pragma push_macro("global") | ||||||
| #	pragma push_macro("internal") | #	pragma push_macro("internal") | ||||||
| @@ -183,11 +190,6 @@ void define_constants() | |||||||
| #	undef internal | #	undef internal | ||||||
| #	undef local_persist | #	undef local_persist | ||||||
| #	undef neverinline | #	undef neverinline | ||||||
|  |  | ||||||
| #	define def_constant_spec( Type_, ... )                                  \ |  | ||||||
| 		spec_##Type_ = def_specifiers( num_args(__VA_ARGS__), __VA_ARGS__); \ |  | ||||||
| 		spec_##Type_.set_global(); |  | ||||||
|  |  | ||||||
| 	def_constant_spec( const,            ESpecifier::Const ); | 	def_constant_spec( const,            ESpecifier::Const ); | ||||||
| 	def_constant_spec( consteval,        ESpecifier::Consteval ); | 	def_constant_spec( consteval,        ESpecifier::Consteval ); | ||||||
| 	def_constant_spec( constexpr,        ESpecifier::Constexpr ); | 	def_constant_spec( constexpr,        ESpecifier::Constexpr ); | ||||||
| @@ -201,6 +203,7 @@ void define_constants() | |||||||
| 	def_constant_spec( local_persist,    ESpecifier::Local_Persist ); | 	def_constant_spec( local_persist,    ESpecifier::Local_Persist ); | ||||||
| 	def_constant_spec( mutable,          ESpecifier::Mutable ); | 	def_constant_spec( mutable,          ESpecifier::Mutable ); | ||||||
| 	def_constant_spec( neverinline,      ESpecifier::NeverInline ); | 	def_constant_spec( neverinline,      ESpecifier::NeverInline ); | ||||||
|  | 	def_constant_spec( noexcept,         ESpecifier::NoExceptions ); | ||||||
| 	def_constant_spec( override,         ESpecifier::Override ); | 	def_constant_spec( override,         ESpecifier::Override ); | ||||||
| 	def_constant_spec( ptr,              ESpecifier::Ptr ); | 	def_constant_spec( ptr,              ESpecifier::Ptr ); | ||||||
| 	def_constant_spec( pure,             ESpecifier::Pure ) | 	def_constant_spec( pure,             ESpecifier::Pure ) | ||||||
| @@ -413,10 +416,13 @@ Code make_code() | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	Code result { rcast( AST*, alloc( * allocator, sizeof(AST) )) }; | 	Code result { rcast( AST*, alloc( * allocator, sizeof(AST) )) }; | ||||||
|  | 	// mem_set( result.ast, 0, sizeof(AST) ); | ||||||
|  | 	result->Type = ECode::Invalid; | ||||||
|  |  | ||||||
| 	result->Content     = { nullptr }; | 	result->Content     = { nullptr }; | ||||||
| 	result->Prev        = { nullptr }; | 	result->Prev        = { nullptr }; | ||||||
| 	result->Next        = { nullptr }; | 	result->Next        = { nullptr }; | ||||||
|  | 	result->Token		= nullptr; | ||||||
| 	result->Parent      = { nullptr }; | 	result->Parent      = { nullptr }; | ||||||
| 	result->Name        = { nullptr }; | 	result->Name        = { nullptr }; | ||||||
| 	result->Type        = ECode::Invalid; | 	result->Type        = ECode::Invalid; | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #pragma once | #pragma once | ||||||
| #include "ast_types.hpp" | #include "ast_types.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region Gen Interface | #pragma region Gen Interface | ||||||
|  |  | ||||||
| @@ -68,7 +70,7 @@ CodeFn def_function( StrC name | |||||||
| 	, CodeSpecifiers specifiers = NoCode, CodeAttributes attributes = NoCode | 	, CodeSpecifiers specifiers = NoCode, CodeAttributes attributes = NoCode | ||||||
| 	, ModuleFlag mflags     = ModuleFlag::None ); | 	, ModuleFlag mflags     = ModuleFlag::None ); | ||||||
|  |  | ||||||
| CodeInclude   def_include  ( StrC content ); | CodeInclude   def_include  ( StrC content, bool foreign = false ); | ||||||
| CodeModule    def_module   ( StrC name,            ModuleFlag mflags = ModuleFlag::None ); | CodeModule    def_module   ( StrC name,            ModuleFlag mflags = ModuleFlag::None ); | ||||||
| CodeNS        def_namespace( StrC name, Code body, ModuleFlag mflags = ModuleFlag::None ); | CodeNS        def_namespace( StrC name, Code body, ModuleFlag mflags = ModuleFlag::None ); | ||||||
|  |  | ||||||
|   | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #pragma once | #pragma once | ||||||
| #include "interface.parsing.cpp" | #include "interface.parsing.cpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| sw token_fmt_va( char* buf, uw buf_size, s32 num_tokens, va_list va ) | sw token_fmt_va( char* buf, uw buf_size, s32 num_tokens, va_list va ) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #pragma once | #pragma once | ||||||
| #include "interface.cpp" | #include "interface.cpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region Upfront | #pragma region Upfront | ||||||
|  |  | ||||||
| @@ -34,12 +36,12 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| #	define check_param_eq_ret()                                                                     \ | #	define check_param_eq_ret()                                                                     \ | ||||||
| 	if ( ! is_member_symbol && params_code->ValueType != ret_type )                                \ | 	if ( ! is_member_symbol && ! params_code->ValueType.is_equal( ret_type) )                       \ | ||||||
| 	{                                                                                               \ | 	{                                                                                               \ | ||||||
| 		log_failure("gen_def_operator: operator%s requires first parameter to equal return type\n" \ | 		log_failure("gen::def_operator: operator%s requires first parameter to equal return type\n" \ | ||||||
| 			"param types: %s\n"                                                                     \ | 			"param types: %s\n"                                                                     \ | ||||||
| 			"return type: %s",                                                                      \ | 			"return type: %s",                                                                      \ | ||||||
| 			to_str(op),                                                                            \ | 			to_str(op).Ptr,                                                                         \ | ||||||
| 			params_code.debug_str(),                                                                \ | 			params_code.debug_str(),                                                                \ | ||||||
| 			ret_type.debug_str()                                                                    \ | 			ret_type.debug_str()                                                                    \ | ||||||
| 		);                                                                                          \ | 		);                                                                                          \ | ||||||
| @@ -415,12 +417,42 @@ CodeComment def_comment( StrC content ) | |||||||
| 		return CodeInvalid; | 		return CodeInvalid; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	static char line[ MaxCommentLineLength ]; | ||||||
|  |  | ||||||
|  | 	String      cmt_formatted = String::make_reserve( GlobalAllocator, kilobytes(1) ); | ||||||
|  | 	char const* end           = content.Ptr + content.Len; | ||||||
|  | 	char const* scanner       = content.Ptr; | ||||||
|  | 	s32         curr          = 0; | ||||||
|  | 	do | ||||||
|  | 	{ | ||||||
|  | 		char const* next   = scanner; | ||||||
|  | 		s32         length = 0; | ||||||
|  | 		while ( next != end && scanner[ length ] != '\n' ) | ||||||
|  | 		{ | ||||||
|  | 			next = scanner + length; | ||||||
|  | 			length++; | ||||||
|  | 		} | ||||||
|  | 		length++; | ||||||
|  |  | ||||||
|  | 		str_copy( line, scanner, length ); | ||||||
|  | 		cmt_formatted.append_fmt( "//%.*s", length, line ); | ||||||
|  | 		mem_set( line, 0, MaxCommentLineLength ); | ||||||
|  |  | ||||||
|  | 		scanner += length; | ||||||
|  | 	} | ||||||
|  | 	while ( scanner <= end ); | ||||||
|  |  | ||||||
|  | 	if ( cmt_formatted.back() != '\n' ) | ||||||
|  | 		cmt_formatted.append( "\n" ); | ||||||
|  |  | ||||||
| 	Code | 	Code | ||||||
| 	result          = make_code(); | 	result          = make_code(); | ||||||
| 	result->Type    = ECode::Comment; | 	result->Type    = ECode::Comment; | ||||||
| 	result->Name    = get_cached_string( content ); | 	result->Name    = get_cached_string( cmt_formatted ); | ||||||
| 	result->Content = result->Name; | 	result->Content = result->Name; | ||||||
|  |  | ||||||
|  | 	cmt_formatted.free(); | ||||||
|  |  | ||||||
| 	return (CodeComment) result; | 	return (CodeComment) result; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -820,7 +852,7 @@ CodeFn def_function( StrC name | |||||||
| 	return result; | 	return result; | ||||||
| } | } | ||||||
|  |  | ||||||
| CodeInclude def_include ( StrC path ) | CodeInclude def_include( StrC path, bool foreign ) | ||||||
| { | { | ||||||
| 	if ( path.Len <= 0 || path.Ptr == nullptr ) | 	if ( path.Len <= 0 || path.Ptr == nullptr ) | ||||||
| 	{ | 	{ | ||||||
| @@ -828,10 +860,14 @@ CodeInclude def_include ( StrC path ) | |||||||
| 		return CodeInvalid; | 		return CodeInvalid; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	StrC content = foreign ? | ||||||
|  | 			to_str( str_fmt_buf( "<%.*s>", path.Len, path.Ptr )) | ||||||
|  | 		:	to_str( str_fmt_buf( "\"%.*s\"", path.Len, path.Ptr )); | ||||||
|  |  | ||||||
| 	Code | 	Code | ||||||
| 	result          = make_code(); | 	result          = make_code(); | ||||||
| 	result->Type    = ECode::Preprocess_Include; | 	result->Type    = ECode::Preprocess_Include; | ||||||
| 	result->Name    = get_cached_string( path ); | 	result->Name    = get_cached_string( content ); | ||||||
| 	result->Content = result->Name; | 	result->Content = result->Name; | ||||||
|  |  | ||||||
| 	return (CodeInclude) result; | 	return (CodeInclude) result; | ||||||
| @@ -911,6 +947,7 @@ CodeOperator def_operator( OperatorT op, StrC nspace | |||||||
| 	result              = (CodeOperator) make_code(); | 	result              = (CodeOperator) make_code(); | ||||||
| 	result->Name        = get_cached_string( { str_len(name), name } ); | 	result->Name        = get_cached_string( { str_len(name), name } ); | ||||||
| 	result->ModuleFlags = mflags; | 	result->ModuleFlags = mflags; | ||||||
|  | 	result->Op          = op; | ||||||
|  |  | ||||||
| 	if ( body ) | 	if ( body ) | ||||||
| 	{ | 	{ | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #pragma once | #pragma once | ||||||
| #include "gen.hpp" | #include "gen.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region StaticData | #pragma region StaticData | ||||||
|  |  | ||||||
| @@ -56,6 +58,7 @@ global CodeSpecifiers spec_inline; | |||||||
| global CodeSpecifiers spec_internal_linkage; | global CodeSpecifiers spec_internal_linkage; | ||||||
| global CodeSpecifiers spec_local_persist; | global CodeSpecifiers spec_local_persist; | ||||||
| global CodeSpecifiers spec_mutable; | global CodeSpecifiers spec_mutable; | ||||||
|  | global CodeSpecifiers spec_noexcept; | ||||||
| global CodeSpecifiers spec_neverinline; | global CodeSpecifiers spec_neverinline; | ||||||
| global CodeSpecifiers spec_override; | global CodeSpecifiers spec_override; | ||||||
| global CodeSpecifiers spec_ptr; | global CodeSpecifiers spec_ptr; | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #pragma once | #pragma once | ||||||
| #include "header_start.hpp" | #include "header_start.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| using LogFailType = sw(*)(char const*, ...); | using LogFailType = sw(*)(char const*, ...); | ||||||
|  |  | ||||||
| @@ -39,6 +41,15 @@ char const* to_str( AccessSpec type ) | |||||||
| 	return lookup[ (u32)type ]; | 	return lookup[ (u32)type ]; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | enum CodeFlag : u32 | ||||||
|  | { | ||||||
|  | 	FunctionType  = bit(0), | ||||||
|  | 	ParamPack     = bit(1), | ||||||
|  | 	Module_Export = bit(2), | ||||||
|  | 	Module_Import = bit(3), | ||||||
|  | }; | ||||||
|  |  | ||||||
| // Used to indicate if enum definitoin is an enum class or regular enum. | // Used to indicate if enum definitoin is an enum class or regular enum. | ||||||
| enum class EnumT : u8 | enum class EnumT : u8 | ||||||
| { | { | ||||||
| @@ -54,12 +65,26 @@ enum class ModuleFlag : u32 | |||||||
| 	None    = 0, | 	None    = 0, | ||||||
| 	Export  = bit(0), | 	Export  = bit(0), | ||||||
| 	Import  = bit(1), | 	Import  = bit(1), | ||||||
| 	// Private = bit(2), |  | ||||||
|  |  | ||||||
| 	Num_ModuleFlags, | 	Num_ModuleFlags, | ||||||
| 	Invalid, | 	Invalid, | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | StrC to_str( ModuleFlag flag ) | ||||||
|  | { | ||||||
|  | 	local_persist | ||||||
|  | 	StrC lookup[ (u32)ModuleFlag::Num_ModuleFlags ] = { | ||||||
|  | 		{ sizeof("__none__"), "__none__" }, | ||||||
|  | 		{ sizeof("export"), "export" }, | ||||||
|  | 		{ sizeof("import"), "import" }, | ||||||
|  | 	}; | ||||||
|  |  | ||||||
|  | 	if ( flag > ModuleFlag::Import ) | ||||||
|  | 		return { sizeof("invalid"), "invalid" }; | ||||||
|  |  | ||||||
|  | 	return lookup[ (u32)flag ]; | ||||||
|  | } | ||||||
|  |  | ||||||
| ModuleFlag operator|( ModuleFlag A, ModuleFlag B) | ModuleFlag operator|( ModuleFlag A, ModuleFlag B) | ||||||
| { | { | ||||||
| 	return (ModuleFlag)( (u32)A | (u32)B ); | 	return (ModuleFlag)( (u32)A | (u32)B ); | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
| #	include "macros.hpp" | #	include "macros.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region Basic Types | #pragma region Basic Types | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
| #	include "printing.hpp" | #	include "printing.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region Containers | #pragma region Containers | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,4 +1,9 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
|  | #	include "debug.hpp" | ||||||
|  | #	include "basic_types.hpp" | ||||||
|  | #   include "src_start.cpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region Debug | #pragma region Debug | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
| #	include "basic_types.hpp" | #	include "basic_types.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region Debug | #pragma region Debug | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
| #	include "strings.cpp" | #	include "strings.cpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region File Handling | #pragma region File Handling | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
| #	include "strings.hpp" | #	include "strings.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region File Handling | #pragma region File Handling | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
| #	include "memory.cpp" | #	include "memory.cpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region Hashing | #pragma region Hashing | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #pragma once | #pragma once | ||||||
| #include "containers.hpp" | #include "containers.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region Hashing | #pragma region Hashing | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
| #	include "header_start.hpp" | #	include "header_start.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region Macros | #pragma region Macros | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
| #	include "printing.cpp" | #	include "printing.cpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region Memory | #pragma region Memory | ||||||
|  |  | ||||||
| @@ -206,6 +208,132 @@ void* heap_allocator_proc( void* allocator_data, AllocType type, sw size, sw ali | |||||||
| 	return ptr; | 	return ptr; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #pragma region VirtualMemory | ||||||
|  | VirtualMemory vm_from_memory( void* data, sw size ) | ||||||
|  | { | ||||||
|  | 	VirtualMemory vm; | ||||||
|  | 	vm.data = data; | ||||||
|  | 	vm.size = size; | ||||||
|  | 	return vm; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | #if defined( GEN_SYSTEM_WINDOWS ) | ||||||
|  | VirtualMemory vm_alloc( void* addr, sw size ) | ||||||
|  | { | ||||||
|  | 	VirtualMemory vm; | ||||||
|  | 	GEN_ASSERT( size > 0 ); | ||||||
|  | 	vm.data = VirtualAlloc( addr, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE ); | ||||||
|  | 	vm.size = size; | ||||||
|  | 	return vm; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | b32 vm_free( VirtualMemory vm ) | ||||||
|  | { | ||||||
|  | 	MEMORY_BASIC_INFORMATION info; | ||||||
|  | 	while ( vm.size > 0 ) | ||||||
|  | 	{ | ||||||
|  | 		if ( VirtualQuery( vm.data, &info, size_of( info ) ) == 0 ) | ||||||
|  | 			return false; | ||||||
|  | 		if ( info.BaseAddress != vm.data || info.AllocationBase != vm.data || info.State != MEM_COMMIT || info.RegionSize > zpl_cast( uw ) vm.size ) | ||||||
|  | 		{ | ||||||
|  | 			return false; | ||||||
|  | 		} | ||||||
|  | 		if ( VirtualFree( vm.data, 0, MEM_RELEASE ) == 0 ) | ||||||
|  | 			return false; | ||||||
|  | 		vm.data  = pointer_add( vm.data, info.RegionSize ); | ||||||
|  | 		vm.size -= info.RegionSize; | ||||||
|  | 	} | ||||||
|  | 	return true; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | VirtualMemory vm_trim( VirtualMemory vm, sw lead_size, sw size ) | ||||||
|  | { | ||||||
|  | 	VirtualMemory new_vm = { 0 }; | ||||||
|  | 	void*             ptr; | ||||||
|  | 	GEN_ASSERT( vm.size >= lead_size + size ); | ||||||
|  |  | ||||||
|  | 	ptr = pointer_add( vm.data, lead_size ); | ||||||
|  |  | ||||||
|  | 	vm_free( vm ); | ||||||
|  | 	new_vm = vm_alloc( ptr, size ); | ||||||
|  | 	if ( new_vm.data == ptr ) | ||||||
|  | 		return new_vm; | ||||||
|  | 	if ( new_vm.data ) | ||||||
|  | 		vm_free( new_vm ); | ||||||
|  | 	return new_vm; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | b32 vm_purge( VirtualMemory vm ) | ||||||
|  | { | ||||||
|  | 	VirtualAlloc( vm.data, vm.size, MEM_RESET, PAGE_READWRITE ); | ||||||
|  | 	// NOTE: Can this really fail? | ||||||
|  | 	return true; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | sw virtual_memory_page_size( sw* alignment_out ) | ||||||
|  | { | ||||||
|  | 	SYSTEM_INFO info; | ||||||
|  | 	GetSystemInfo( &info ); | ||||||
|  | 	if ( alignment_out ) | ||||||
|  | 		*alignment_out = info.dwAllocationGranularity; | ||||||
|  | 	return info.dwPageSize; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | #else | ||||||
|  | #	include <sys/mman.h> | ||||||
|  |  | ||||||
|  | #	ifndef MAP_ANONYMOUS | ||||||
|  | #		define MAP_ANONYMOUS MAP_ANON | ||||||
|  | #	endif | ||||||
|  | VirtualMemory vm_alloc( void* addr, sw size ) | ||||||
|  | { | ||||||
|  | 	VirtualMemory vm; | ||||||
|  | 	GEN_ASSERT( size > 0 ); | ||||||
|  | 	vm.data = mmap( addr, size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0 ); | ||||||
|  | 	vm.size = size; | ||||||
|  | 	return vm; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | b32 vm_free( VirtualMemory vm ) | ||||||
|  | { | ||||||
|  | 	munmap( vm.data, vm.size ); | ||||||
|  | 	return true; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | VirtualMemory vm_trim( VirtualMemory vm, sw lead_size, sw size ) | ||||||
|  | { | ||||||
|  | 	void*  ptr; | ||||||
|  | 	sw trail_size; | ||||||
|  | 	GEN_ASSERT( vm.size >= lead_size + size ); | ||||||
|  |  | ||||||
|  | 	ptr        = pointer_add( vm.data, lead_size ); | ||||||
|  | 	trail_size = vm.size - lead_size - size; | ||||||
|  |  | ||||||
|  | 	if ( lead_size != 0 ) | ||||||
|  | 		vm_free( vm_from_memory(( vm.data, lead_size ) ); | ||||||
|  | 	if ( trail_size != 0 ) | ||||||
|  | 		vm_free( vm_from_memory( ptr, trail_size ) ); | ||||||
|  | 	return vm_from_memory( ptr, size ); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | b32 vm_purge( VirtualMemory vm ) | ||||||
|  | { | ||||||
|  | 	int err = madvise( vm.data, vm.size, MADV_DONTNEED ); | ||||||
|  | 	return err != 0; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | sw virtual_memory_page_size( sw* alignment_out ) | ||||||
|  | { | ||||||
|  | 	// TODO: Is this always true? | ||||||
|  | 	sw result = zpl_cast( sw ) sysconf( _SC_PAGE_SIZE ); | ||||||
|  | 	if ( alignment_out ) | ||||||
|  | 		*alignment_out = result; | ||||||
|  | 	return result; | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #pragma endregion VirtualMemory | ||||||
|  |  | ||||||
| void* Arena::allocator_proc( void* allocator_data, AllocType type, sw size, sw alignment, void* old_memory, sw old_size, u64 flags ) | void* Arena::allocator_proc( void* allocator_data, AllocType type, sw size, sw alignment, void* old_memory, sw old_size, u64 flags ) | ||||||
| { | { | ||||||
| 	Arena* arena = rcast(Arena*, allocator_data); | 	Arena* arena = rcast(Arena*, allocator_data); | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
| #	include "debug.hpp" | #	include "debug.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region Memory | #pragma region Memory | ||||||
|  |  | ||||||
| @@ -363,6 +365,33 @@ GEN_IMPL_INLINE void zero_size( void* ptr, sw size ) | |||||||
| 	mem_set( ptr, 0, size ); | 	mem_set( ptr, 0, size ); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | struct VirtualMemory | ||||||
|  | { | ||||||
|  | 	void*  data; | ||||||
|  | 	sw size; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | //! Initialize virtual memory from existing data. | ||||||
|  | VirtualMemory vm_from_memory( void* data, sw size ); | ||||||
|  |  | ||||||
|  | //! Allocate virtual memory at address with size. | ||||||
|  |  | ||||||
|  | //! @param addr The starting address of the region to reserve. If NULL, it lets operating system to decide where to allocate it. | ||||||
|  | //! @param size The size to serve. | ||||||
|  | VirtualMemory vm_alloc( void* addr, sw size ); | ||||||
|  |  | ||||||
|  | //! Release the virtual memory. | ||||||
|  | b32 vm_free( VirtualMemory vm ); | ||||||
|  |  | ||||||
|  | //! Trim virtual memory. | ||||||
|  | VirtualMemory vm_trim( VirtualMemory vm, sw lead_size, sw size ); | ||||||
|  |  | ||||||
|  | //! Purge virtual memory. | ||||||
|  | b32 gen_vm_purge( VirtualMemory vm ); | ||||||
|  |  | ||||||
|  | //! Retrieve VM's page size and alignment. | ||||||
|  | sw gen_virtual_memory_page_size( sw* alignment_out ); | ||||||
|  |  | ||||||
| struct Arena | struct Arena | ||||||
| { | { | ||||||
| 	static | 	static | ||||||
| @@ -448,6 +477,45 @@ 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 > | ||||||
|  | struct FixedArena | ||||||
|  | { | ||||||
|  | 	static | ||||||
|  | 	FixedArena init() | ||||||
|  | 	{ | ||||||
|  | 		FixedArena result = { Arena::init_from_memory( result.memory, Size ), {0} }; | ||||||
|  | 		return result; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	sw size_remaining( sw alignment ) | ||||||
|  | 	{ | ||||||
|  | 		return arena.size_remaining( alignment ); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	operator AllocatorInfo() | ||||||
|  | 	{ | ||||||
|  | 		return { Arena::allocator_proc, &arena }; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	Arena arena; | ||||||
|  | 	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 ) >; | ||||||
|  |  | ||||||
| struct Pool | struct Pool | ||||||
| { | { | ||||||
| 	static | 	static | ||||||
|   | |||||||
| @@ -1,4 +1,6 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region ADT | #pragma region ADT | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,4 +1,6 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region ADT | #pragma region ADT | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,9 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
|  | #	include "filesystem.hpp" | ||||||
|  | #	include "strings.hpp" | ||||||
| #	include "string_ops.cpp" | #	include "string_ops.cpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region Printing | #pragma region Printing | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
| #	include "string_ops.hpp" | #	include "string_ops.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region Printing | #pragma region Printing | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,3 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
|  | #	include "header_start.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region Macros and Includes | #pragma region Macros and Includes | ||||||
|  |  | ||||||
| #	include <stdio.h> | #	include <stdio.h> | ||||||
|   | |||||||
| @@ -1,5 +1,8 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
|  | #	include "string_ops.hpp" | ||||||
| #	include "debug.cpp" | #	include "debug.cpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region String Ops | #pragma region String Ops | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
| #	include "memory.hpp" | #	include "memory.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region String Ops | #pragma region String Ops | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
| #	include "hashing.cpp" | #	include "hashing.cpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region String | #pragma region String | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
| #	include "hashing.hpp" | #	include "hashing.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region Strings | #pragma region Strings | ||||||
|  |  | ||||||
| @@ -99,6 +101,11 @@ struct String | |||||||
|  |  | ||||||
| 	bool make_space_for( char const* str, sw add_len ); | 	bool make_space_for( char const* str, sw add_len ); | ||||||
|  |  | ||||||
|  | 	bool append( char c ) | ||||||
|  | 	{ | ||||||
|  | 		return append( & c, 1 ); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	bool append( char const* str ) | 	bool append( char const* str ) | ||||||
| 	{ | 	{ | ||||||
| 		return append( str, str_len( str ) ); | 		return append( str, str_len( str ) ); | ||||||
| @@ -213,6 +220,27 @@ struct String | |||||||
| 	#undef current | 	#undef current | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	void strip_space() | ||||||
|  | 	{ | ||||||
|  | 		char* write_pos = Data; | ||||||
|  | 		char* read_pos  = Data; | ||||||
|  |  | ||||||
|  | 		while ( * read_pos) | ||||||
|  | 		{ | ||||||
|  | 			if ( ! char_is_space( *read_pos )) | ||||||
|  | 			{ | ||||||
|  | 				*write_pos = *read_pos; | ||||||
|  | 				write_pos++; | ||||||
|  | 			} | ||||||
|  | 			read_pos++; | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		write_pos[0] = '\0';  // Null-terminate the modified string | ||||||
|  |  | ||||||
|  | 		// Update the length if needed | ||||||
|  | 		get_header().Length = write_pos - Data; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	void trim( char const* cut_set ) | 	void trim( char const* cut_set ) | ||||||
| 	{ | 	{ | ||||||
| 		sw len = 0; | 		sw len = 0; | ||||||
| @@ -241,14 +269,52 @@ struct String | |||||||
| 		return trim( " \t\r\n\v\f" ); | 		return trim( " \t\r\n\v\f" ); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	// Debug function that provides a copy of the string with whitespace characters visualized. | ||||||
|  | 	String visualize_whitespace() const | ||||||
|  | 	{ | ||||||
|  | 		Header* header = (Header*)(Data - sizeof(Header)); | ||||||
|  |  | ||||||
|  | 		String result = make_reserve(header->Allocator, length() * 2); // Assume worst case for space requirements. | ||||||
|  |  | ||||||
|  | 		for ( char c : *this ) | ||||||
|  | 		{ | ||||||
|  | 			switch ( c ) | ||||||
|  | 			{ | ||||||
|  | 				case ' ': | ||||||
|  | 					result.append( txt("·") ); | ||||||
|  | 				break; | ||||||
|  | 				case '\t': | ||||||
|  | 					result.append( txt("→") ); | ||||||
|  | 				break; | ||||||
|  | 				case '\n': | ||||||
|  | 					result.append( txt("↵") ); | ||||||
|  | 				break; | ||||||
|  | 				case '\r': | ||||||
|  | 					result.append( txt("⏎") ); | ||||||
|  | 				break; | ||||||
|  | 				case '\v': | ||||||
|  | 					result.append( txt("⇕") ); | ||||||
|  | 				break; | ||||||
|  | 				case '\f': | ||||||
|  | 					result.append( txt("⌂") ); | ||||||
|  | 				break; | ||||||
|  | 				default: | ||||||
|  | 					result.append(c); | ||||||
|  | 				break; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		return result; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	// For-range support | 	// For-range support | ||||||
|  |  | ||||||
| 	char* begin() | 	char* begin() const | ||||||
| 	{ | 	{ | ||||||
| 		return Data; | 		return Data; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	char* end() | 	char* end() const | ||||||
| 	{ | 	{ | ||||||
| 		Header const& | 		Header const& | ||||||
| 		header = * rcast( Header const*, Data - sizeof( Header )); | 		header = * rcast( Header const*, Data - sizeof( Header )); | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
| #	include "filesystem.cpp" | #	include "filesystem.cpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region Timing | #pragma region Timing | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
|  | #ifdef GEN_INTELLISENSE_DIRECTIVES | ||||||
| #	pragma once | #	pragma once | ||||||
| #	include "filesystem.hpp" | #	include "filesystem.hpp" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #pragma region Timing | #pragma region Timing | ||||||
|  |  | ||||||
|   | |||||||
| @@ -21,5 +21,6 @@ Volatile,         volatile | |||||||
| Virtual,          virtual | Virtual,          virtual | ||||||
| Const,            const | Const,            const | ||||||
| Final,            final | Final,            final | ||||||
|  | NoExceptions,     noexcept | ||||||
| Override,         override | Override,         override | ||||||
| Pure,             = 0 | Pure,             = 0 | ||||||
|   | |||||||
| 
 | 
| @@ -15,7 +15,7 @@ BraceSquare_Open,       "[" | |||||||
| BraceSquare_Close,      "]" | BraceSquare_Close,      "]" | ||||||
| Capture_Start,          "(" | Capture_Start,          "(" | ||||||
| Capture_End,            ")" | Capture_End,            ")" | ||||||
| Comment,                "__comemnt__" | Comment,                "__comment__" | ||||||
| Comment_End,            "__comment_end__" | Comment_End,            "__comment_end__" | ||||||
| Comment_Start,          "__comment_start__" | Comment_Start,          "__comment_start__" | ||||||
| Char,                   "__character__" | Char,                   "__character__" | ||||||
|   | |||||||
| 
 | 
| @@ -86,7 +86,7 @@ CompactNamespaces: true | |||||||
| ConstructorInitializerAllOnOneLineOrOnePerLine: true | ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||||||
| ConstructorInitializerIndentWidth : 4 | ConstructorInitializerIndentWidth : 4 | ||||||
|  |  | ||||||
| ContinuationIndentWidth: 0 | ContinuationIndentWidth: 4 | ||||||
|  |  | ||||||
| Cpp11BracedListStyle: false | Cpp11BracedListStyle: false | ||||||
|  |  | ||||||
|   | |||||||
| @@ -3,14 +3,23 @@ | |||||||
| # That or just rewrite it in an sh script and call it a day. | # That or just rewrite it in an sh script and call it a day. | ||||||
|  |  | ||||||
| Import-Module ./helpers/target_arch.psm1 | Import-Module ./helpers/target_arch.psm1 | ||||||
|  | $target_arch        = Join-Path $PSScriptRoot 'helpers/target_arch.psm1' | ||||||
| $devshell           = Join-Path $PSScriptRoot 'helpers/devshell.ps1' | $devshell           = Join-Path $PSScriptRoot 'helpers/devshell.ps1' | ||||||
|  | $format_cpp	        = Join-Path $PSScriptRoot 'helpers/format_cpp.psm1' | ||||||
|  | $incremental_checks = Join-Path $PSScriptRoot 'helpers/incremental_checks.ps1' | ||||||
|  | $vendor_toolchain   = Join-Path $PSScriptRoot 'helpers/vendor_toolchain.ps1' | ||||||
|  |  | ||||||
| $path_root = git rev-parse --show-toplevel | $path_root = git rev-parse --show-toplevel | ||||||
|  |  | ||||||
|  | Import-Module $target_arch | ||||||
|  | Import-Module $format_cpp | ||||||
|  |  | ||||||
| Push-Location $path_root | Push-Location $path_root | ||||||
|  |  | ||||||
| #region Arguments | #region Arguments | ||||||
|        $vendor       = $null |        $vendor       = $null | ||||||
|        $release      = $null |        $release      = $null | ||||||
|  | 	   $verbose      = $false | ||||||
| [bool] $bootstrap    = $false | [bool] $bootstrap    = $false | ||||||
| [bool] $singleheader = $false | [bool] $singleheader = $false | ||||||
| [bool] $test         = $false | [bool] $test         = $false | ||||||
| @@ -22,6 +31,7 @@ Push-Location $path_root | |||||||
| if ( $args ) { $args | ForEach-Object { | if ( $args ) { $args | ForEach-Object { | ||||||
| 	switch ($_){ | 	switch ($_){ | ||||||
| 		{ $_ -in $vendors }   { $vendor       = $_; break } | 		{ $_ -in $vendors }   { $vendor       = $_; break } | ||||||
|  | 		"verbose"			  { $verbose      = $true } | ||||||
| 		"release"             { $release      = $true } | 		"release"             { $release      = $true } | ||||||
| 		"debug"               { $release      = $false } | 		"debug"               { $release      = $false } | ||||||
| 		"bootstrap"           { $bootstrap    = $true } | 		"bootstrap"           { $bootstrap    = $true } | ||||||
| @@ -47,257 +57,24 @@ if ( $release -eq $null ) { | |||||||
| 	write-host "No build type specified, assuming debug" | 	write-host "No build type specified, assuming debug" | ||||||
| 	$release = $false | 	$release = $false | ||||||
| } | } | ||||||
|  | elseif ( $release -eq $false ) { | ||||||
|  | 	$debug = $true | ||||||
|  | } | ||||||
|  | else { | ||||||
|  | 	$optimize = treu | ||||||
|  | } | ||||||
|  |  | ||||||
| if ( $bootstrap -eq $false -and $singleheader -eq $false -and $test -eq $false ) { | if ( $bootstrap -eq $false -and $singleheader -eq $false -and $test -eq $false ) { | ||||||
| 	throw "No build target specified. One must be specified, this script will not assume one" | 	throw "No build target specified. One must be specified, this script will not assume one" | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | . $vendor_toolchain | ||||||
|  | . $incremental_checks | ||||||
|  |  | ||||||
| write-host "Building gencpp with $vendor" | write-host "Building gencpp with $vendor" | ||||||
| write-host "Build Type: $(if ($release) {"Release"} else {"Debug"} )" | write-host "Build Type: $(if ($release) {"Release"} else {"Debug"} )" | ||||||
|  |  | ||||||
| function run-compiler |  | ||||||
| { |  | ||||||
| 	param( $compiler, $unit, $compiler_args ) |  | ||||||
|  |  | ||||||
| 	write-host "`Compiling $unit" |  | ||||||
| 	write-host "Compiler config:" |  | ||||||
| 	$compiler_args | ForEach-Object { |  | ||||||
| 		write-host $_ -ForegroundColor Cyan |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	$time_taken = Measure-Command { |  | ||||||
| 		& $compiler $compiler_args 2>&1 | ForEach-Object { |  | ||||||
| 			$color = 'White' |  | ||||||
| 			switch ($_){ |  | ||||||
| 				{ $_ -match "error"   } { $color = 'Red'   ; break } |  | ||||||
| 				{ $_ -match "warning" } { $color = 'Yellow'; break } |  | ||||||
| 			} |  | ||||||
| 			write-host `t $_ -ForegroundColor $color |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	if ( Test-Path($unit) ) { |  | ||||||
| 		write-host "$unit compile finished in $($time_taken.TotalMilliseconds) ms" |  | ||||||
| 	} |  | ||||||
| 	else { |  | ||||||
| 		write-host "Compile failed for $unit" -ForegroundColor Red |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function run-linker |  | ||||||
| { |  | ||||||
| 	param( $linker, $binary, $linker_args ) |  | ||||||
|  |  | ||||||
| 	write-host "`Linking $binary" |  | ||||||
| 	write-host "Linker config:" |  | ||||||
| 	$linker_args | ForEach-Object { |  | ||||||
| 		write-host $_ -ForegroundColor Cyan |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	$time_taken = Measure-Command { |  | ||||||
| 		& $linker $linker_args 2>&1 | ForEach-Object { |  | ||||||
| 			$color = 'White' |  | ||||||
| 			switch ($_){ |  | ||||||
| 				{ $_ -match "error"   } { $color = 'Red'   ; break } |  | ||||||
| 				{ $_ -match "warning" } { $color = 'Yellow'; break } |  | ||||||
| 			} |  | ||||||
| 			write-host `t $_ -ForegroundColor $color |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	if ( Test-Path($binary) ) { |  | ||||||
| 		write-host "$binary linking finished in $($time_taken.TotalMilliseconds) ms" |  | ||||||
| 	} |  | ||||||
| 	else { |  | ||||||
| 		write-host "Linking failed for $binary" -ForegroundColor Red |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  |  | ||||||
| if ( $vendor -match "clang" ) |  | ||||||
| { |  | ||||||
| 	# https://clang.llvm.org/docs/ClangCommandLineReference.html |  | ||||||
| 	$flag_compile                    = '-c' |  | ||||||
| 	$flag_color_diagnostics          = '-fcolor-diagnostics' |  | ||||||
| 	$flag_no_color_diagnostics       = '-fno-color-diagnostics' |  | ||||||
| 	$flag_debug                      = '-g' |  | ||||||
| 	$flag_debug_codeview             = '-gcodeview' |  | ||||||
| 	$flag_define                     = '-D' |  | ||||||
| 	$flag_preprocess 			     = '-E' |  | ||||||
| 	$flag_include                    = '-I' |  | ||||||
| 	$flag_library					 = '-l' |  | ||||||
| 	$flag_library_path				 = '-L' |  | ||||||
| 	$flag_link_win                   = '-Wl,' |  | ||||||
| 	$flag_link_win_subsystem_console = '/SUBSYSTEM:CONSOLE' |  | ||||||
| 	$flag_link_win_machine_32        = '/MACHINE:X86' |  | ||||||
| 	$flag_link_win_machine_64        = '/MACHINE:X64' |  | ||||||
| 	$flag_link_win_debug             = '/DEBUG' |  | ||||||
| 	$flag_link_win_pdb 			     = '/PDB:' |  | ||||||
| 	$flag_link_win_path_output       = '/OUT:' |  | ||||||
| 	$flag_no_optimization 		     = '-O0' |  | ||||||
| 	$flag_path_output                = '-o' |  | ||||||
| 	$flag_preprocess_non_intergrated = '-no-integrated-cpp' |  | ||||||
| 	$flag_profiling_debug            = '-fdebug-info-for-profiling' |  | ||||||
| 	$flag_target_arch				 = '-target' |  | ||||||
| 	$flag_wall 					     = '-Wall' |  | ||||||
| 	$flag_warning 					 = '-W' |  | ||||||
| 	$flag_warning_as_error 		     = '-Werror' |  | ||||||
| 	$flag_win_nologo 			     = '/nologo' |  | ||||||
|  |  | ||||||
| 	$ignore_warning_ms_include = 'no-microsoft-include' |  | ||||||
|  |  | ||||||
| 	$target_arch = Get-TargetArchClang |  | ||||||
|  |  | ||||||
| 	$warning_ignores = @( |  | ||||||
| 		$ignore_warning_ms_include |  | ||||||
| 	) |  | ||||||
|  |  | ||||||
| 	# https://learn.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=msvc-170 |  | ||||||
| 	$libraries = @( |  | ||||||
| 		'Kernel32' # For Windows API |  | ||||||
| 		# 'msvcrt', # For the C Runtime (Dynamically Linked) |  | ||||||
| 		# 'libucrt', |  | ||||||
| 		'libcmt'    # For the C Runtime (Static Linkage) |  | ||||||
| 	) |  | ||||||
|  |  | ||||||
| 	function build-simple |  | ||||||
| 	{ |  | ||||||
| 		param( $includes, $unit, $executable ) |  | ||||||
| 		Write-Host "build-simple: clang" |  | ||||||
|  |  | ||||||
| 		$object = $executable -replace '\.exe', '.obj' |  | ||||||
| 		$pdb    = $executable -replace '\.exe', '.pdb' |  | ||||||
|  |  | ||||||
| 		$compiler_args = @( |  | ||||||
| 			$flag_no_color_diagnostics, |  | ||||||
| 			$flag_target_arch, $target_arch, |  | ||||||
| 			$flag_wall, |  | ||||||
| 			$flag_preprocess_non_intergrated, |  | ||||||
| 			( $flag_define + 'GEN_TIME' ), |  | ||||||
| 			( $flag_path_output + $object ), |  | ||||||
| 			( $flag_include + $includes ) |  | ||||||
| 		) |  | ||||||
| 		if ( $release -eq $false ) { |  | ||||||
| 			$compiler_args += ( $flag_define + 'Build_Debug' ) |  | ||||||
| 			$compiler_args += $flag_debug, $flag_debug_codeview, $flag_profiling_debug |  | ||||||
| 			$compiler_args += $flag_no_optimization |  | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		$warning_ignores | ForEach-Object { |  | ||||||
| 			$compiler_args += $flag_warning + $_ |  | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		# $compiler_args += $flag_preprocess |  | ||||||
|  |  | ||||||
| 		$compiler_args += $flag_compile, $unit |  | ||||||
| 		run-compiler $compiler $unit $compiler_args |  | ||||||
|  |  | ||||||
| 		$linker_args = @( |  | ||||||
| 			$flag_link_win_subsystem_console, |  | ||||||
| 			$flag_link_win_machine_64, |  | ||||||
| 			$( $flag_link_win_path_output + $executable ) |  | ||||||
| 		) |  | ||||||
| 		if ( $release -eq $false ) { |  | ||||||
| 			$linker_args += $flag_link_win_debug |  | ||||||
| 			$linker_args += $flag_link_win_pdb + $pdb |  | ||||||
| 		} |  | ||||||
| 		else { |  | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		$libraries | ForEach-Object { |  | ||||||
| 			$linker_args += $_ + '.lib' |  | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		$linker_args += $object |  | ||||||
| 		run-linker $linker $executable $linker_args |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	$compiler = 'clang++' |  | ||||||
| 	$linker   = 'lld-link' |  | ||||||
| } |  | ||||||
|  |  | ||||||
| if ( $vendor -match "msvc" ) |  | ||||||
| { |  | ||||||
| 	# https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-by-category?view=msvc-170 |  | ||||||
| 	$flag_compile			      = '/c' |  | ||||||
| 	$flag_debug                   = '/Zi' |  | ||||||
| 	$flag_define		          = '/D' |  | ||||||
| 	$flag_include                 = '/I' |  | ||||||
| 	$flag_full_src_path           = '/FC' |  | ||||||
| 	$flag_nologo                  = '/nologo' |  | ||||||
| 	$flag_dll 				      = '/LD' |  | ||||||
| 	$flag_dll_debug 			  = '/LDd' |  | ||||||
| 	$flag_linker 		          = '/link' |  | ||||||
| 	$flag_link_debug 			  = '/DEBUG' |  | ||||||
| 	$flag_link_pdb 				  = '/PDB:' |  | ||||||
| 	$flag_link_machine_32         = '/MACHINE:X86' |  | ||||||
| 	$flag_link_machine_64         = '/MACHINE:X64' |  | ||||||
| 	$flag_link_path_output 	      = '/OUT:' |  | ||||||
| 	$flag_link_rt_dll             = '/MD' |  | ||||||
| 	$flag_link_rt_dll_debug       = '/MDd' |  | ||||||
| 	$flag_link_rt_static          = '/MT' |  | ||||||
| 	$flag_link_rt_static_debug    = '/MTd' |  | ||||||
| 	$flag_link_subsystem_console  = '/SUBSYSTEM:CONSOLE' |  | ||||||
| 	$flag_link_subsystem_windows  = '/SUBSYSTEM:WINDOWS' |  | ||||||
| 	$flag_no_optimization		  = '/Od' |  | ||||||
| 	$flag_out_name                = '/OUT:' |  | ||||||
| 	$flag_path_interm             = '/Fo' |  | ||||||
| 	$flag_path_debug              = '/Fd' |  | ||||||
| 	$flag_path_output             = '/Fe' |  | ||||||
| 	$flag_preprocess_conform      = '/Zc:preprocessor' |  | ||||||
|  |  | ||||||
| 	# This works because this project uses a single unit to build |  | ||||||
| 	function build-simple |  | ||||||
| 	{ |  | ||||||
| 		param( $includes, $unit, $executable ) |  | ||||||
| 		Write-Host "build-simple: msvc" |  | ||||||
|  |  | ||||||
| 		$object = $executable -replace '\.exe', '.obj' |  | ||||||
| 		$pdb    = $executable -replace '\.exe', '.pdb' |  | ||||||
|  |  | ||||||
| 		$compiler_args = @( |  | ||||||
| 			$flag_nologo, |  | ||||||
| 			$flag_preprocess_conform, |  | ||||||
| 			$flag_debug, |  | ||||||
| 			( $flag_define + 'GEN_TIME' ), |  | ||||||
| 			$flag_full_src_path, |  | ||||||
| 			( $flag_path_interm + $path_build + '\' ), |  | ||||||
| 			( $flag_path_output + $path_build + '\' ) |  | ||||||
| 		) |  | ||||||
| 		if ( $release -eq $false ) { |  | ||||||
| 			$compiler_args += ( $flag_define + 'Build_Debug' ) |  | ||||||
| 			$compiler_args += ( $flag_path_debug + $path_build + '\' ) |  | ||||||
| 			$compiler_args += $flag_link_rt_static_debug |  | ||||||
| 			$compiler_args += $flag_no_optimization |  | ||||||
| 		} |  | ||||||
| 		else { |  | ||||||
| 			$compiler_args += $flag_link_rt_static |  | ||||||
| 		} |  | ||||||
| 		$compiler_args += $includes | ForEach-Object { $flag_include + $_ } |  | ||||||
| 		$compiler_args += $flag_compile, $unit |  | ||||||
| 		run-compiler $compiler $unit $compiler_args |  | ||||||
|  |  | ||||||
| 		$linker_args = @( |  | ||||||
| 			$flag_nologo, |  | ||||||
| 			$flag_link_machine_64, |  | ||||||
| 			$flag_link_subsystem_console, |  | ||||||
| 			( $flag_link_path_output + $executable ) |  | ||||||
| 		) |  | ||||||
| 		if ( $release -eq $false ) { |  | ||||||
| 			$linker_args += $flag_link_debug |  | ||||||
| 			$linker_args += $flag_link_pdb + $pdb |  | ||||||
| 		} |  | ||||||
| 		else { |  | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		$linker_args += $object |  | ||||||
| 		run-linker $linker $executable $linker_args |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	$compiler = 'cl' |  | ||||||
| 	$linker   = 'link' |  | ||||||
| } |  | ||||||
| #endregion Configuration |  | ||||||
|  |  | ||||||
| #region Building | #region Building | ||||||
| $path_build        = Join-Path $path_root build | $path_build        = Join-Path $path_root build | ||||||
| $path_project      = Join-Path $path_root project | $path_project      = Join-Path $path_root project | ||||||
| @@ -321,11 +98,18 @@ if ( $bootstrap ) | |||||||
| 		New-Item -ItemType Directory -Path $path_comp_gen | 		New-Item -ItemType Directory -Path $path_comp_gen | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	$compiler_args = @() | ||||||
|  | 	$compiler_args += ( $flag_define + 'GEN_TIME' ) | ||||||
|  |  | ||||||
|  | 	$linker_args   = @( | ||||||
|  | 		$flag_link_win_subsystem_console | ||||||
|  | 	) | ||||||
|  |  | ||||||
| 	$includes   = @( $path_project) | 	$includes   = @( $path_project) | ||||||
| 	$unit       = join-path $path_project "bootstrap.cpp" | 	$unit       = join-path $path_project "bootstrap.cpp" | ||||||
| 	$executable = join-path $path_build   "bootstrap.exe" | 	$executable = join-path $path_build   "bootstrap.exe" | ||||||
|  |  | ||||||
| 	build-simple $includes $unit $executable | 	build-simple $path_build $includes $compiler_args $linker_args $unit $executable | ||||||
|  |  | ||||||
| 	Push-Location $path_project | 	Push-Location $path_project | ||||||
| 		if ( Test-Path( $executable ) ) { | 		if ( Test-Path( $executable ) ) { | ||||||
| @@ -356,7 +140,14 @@ if ( $singleheader ) | |||||||
| 	$unit       = join-path $path_singleheader "singleheader.cpp" | 	$unit       = join-path $path_singleheader "singleheader.cpp" | ||||||
| 	$executable = join-path $path_build        "singleheader.exe" | 	$executable = join-path $path_build        "singleheader.exe" | ||||||
|  |  | ||||||
| 	build-simple $includes $unit $executable | 	$compiler_args = @() | ||||||
|  | 	$compiler_args += ( $flag_define + 'GEN_TIME' ) | ||||||
|  |  | ||||||
|  | 	$linker_args   = @( | ||||||
|  | 		$flag_link_win_subsystem_console | ||||||
|  | 	) | ||||||
|  |  | ||||||
|  | 	build-simple $path_build $includes $compiler_args $linker_args $unit $executable | ||||||
|  |  | ||||||
| 	Push-Location $path_singleheader | 	Push-Location $path_singleheader | ||||||
| 		if ( Test-Path( $executable ) ) { | 		if ( Test-Path( $executable ) ) { | ||||||
| @@ -393,9 +184,17 @@ if ( $test ) | |||||||
| 	$unit       = join-path $path_test  "test.cpp" | 	$unit       = join-path $path_test  "test.cpp" | ||||||
| 	$executable = join-path $path_build "test.exe" | 	$executable = join-path $path_build "test.exe" | ||||||
|  |  | ||||||
| 	build-simple $includes $unit $executable | 	$compiler_args = @() | ||||||
|  | 	$compiler_args += ( $flag_define + 'GEN_TIME' ) | ||||||
|  |  | ||||||
|  | 	$linker_args   = @( | ||||||
|  | 		$flag_link_win_subsystem_console | ||||||
|  | 	) | ||||||
|  |  | ||||||
|  | 	build-simple $path_build $includes $compiler_args $linker_args $unit $executable | ||||||
|  |  | ||||||
| 	Push-Location $path_test | 	Push-Location $path_test | ||||||
|  | 		Write-Host $path_test | ||||||
| 		if ( Test-Path( $executable ) ) { | 		if ( Test-Path( $executable ) ) { | ||||||
| 			write-host "`nRunning test generator" | 			write-host "`nRunning test generator" | ||||||
| 			$time_taken = Measure-Command { & $executable | 			$time_taken = Measure-Command { & $executable | ||||||
| @@ -410,29 +209,7 @@ if ( $test ) | |||||||
| #endregion Building | #endregion Building | ||||||
|  |  | ||||||
| #region Formatting | #region Formatting | ||||||
| function format-cpp | push-location $path_scripts | ||||||
| { |  | ||||||
| 	param( $path, $include, $exclude ) |  | ||||||
|  |  | ||||||
| 	# Format generated gencpp |  | ||||||
| 	Write-Host "`nBeginning format" |  | ||||||
| 	$formatParams = @( |  | ||||||
| 		'-i'          # In-place |  | ||||||
| 		'-style=file:./scripts/.clang-format' |  | ||||||
| 		'-verbose' |  | ||||||
| 	) |  | ||||||
|  |  | ||||||
| 	$targetFiles = @( |  | ||||||
| 		Get-ChildItem -Recurse -Path $path -Include $include -Exclude $exclude |  | ||||||
| 			| Select-Object -ExpandProperty FullName |  | ||||||
| 	) |  | ||||||
|  |  | ||||||
| 	$time_taken = Measure-Command { |  | ||||||
| 		clang-format $formatParams $targetFiles |  | ||||||
| 	} |  | ||||||
| 	Write-Host "`nFormatting complete in $($time_taken.TotalMilliseconds) ms" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| if ( $bootstrap -and (Test-Path (Join-Path $path_project "gen/gen.hpp")) ) | if ( $bootstrap -and (Test-Path (Join-Path $path_project "gen/gen.hpp")) ) | ||||||
| { | { | ||||||
| 	$path_gen      = join-path $path_project gen | 	$path_gen      = join-path $path_project gen | ||||||
| @@ -446,6 +223,7 @@ if ( $bootstrap -and (Test-Path (Join-Path $path_project "gen/gen.hpp")) ) | |||||||
| 	$exclude  = $null | 	$exclude  = $null | ||||||
| 	format-cpp $path_gen $include $exclude | 	format-cpp $path_gen $include $exclude | ||||||
| 	format-cpp $path_comp_gen @( 'ast_inlines.hpp', 'ecode.hpp', 'especifier.hpp', 'eoperator.hpp', 'etoktype.cpp' ) $null | 	format-cpp $path_comp_gen @( 'ast_inlines.hpp', 'ecode.hpp', 'especifier.hpp', 'eoperator.hpp', 'etoktype.cpp' ) $null | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| if ( $singleheader -and (Test-Path (Join-Path $path_singleheader "gen/gen.hpp")) ) | if ( $singleheader -and (Test-Path (Join-Path $path_singleheader "gen/gen.hpp")) ) | ||||||
| @@ -458,7 +236,7 @@ if ( $singleheader -and (Test-Path (Join-Path $path_singleheader "gen/gen.hpp")) | |||||||
| 	format-cpp $path_gen $include $exclude | 	format-cpp $path_gen $include $exclude | ||||||
| } | } | ||||||
|  |  | ||||||
| if ( $test ) | if ( $test -and $false ) | ||||||
| { | { | ||||||
| 	$path_gen = join-path $path_test gen | 	$path_gen = join-path $path_test gen | ||||||
| 	$include  = @( | 	$include  = @( | ||||||
| @@ -467,6 +245,7 @@ if ( $test ) | |||||||
| 	$exclude  = $null | 	$exclude  = $null | ||||||
| 	format-cpp $path_gen $include $exclude | 	format-cpp $path_gen $include $exclude | ||||||
| } | } | ||||||
|  | pop-location | ||||||
| #endregion Formatting | #endregion Formatting | ||||||
|  |  | ||||||
| Pop-Location # $path_root | Pop-Location # $path_root | ||||||
|   | |||||||
| @@ -23,5 +23,6 @@ if ( -not (Test-Path $vs_devshell) ) { | |||||||
|  |  | ||||||
| # Launch the Visual Studio Developer Shell | # Launch the Visual Studio Developer Shell | ||||||
| Push-Location | Push-Location | ||||||
|  | write-host @args | ||||||
| & $vs_devshell @args | & $vs_devshell @args | ||||||
| Pop-Location | Pop-Location | ||||||
|   | |||||||
							
								
								
									
										26
									
								
								scripts/helpers/format_cpp.psm1
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								scripts/helpers/format_cpp.psm1
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,26 @@ | |||||||
|  | # format_cpp.psm1 | ||||||
|  |  | ||||||
|  | function format-cpp | ||||||
|  | { | ||||||
|  | 	param( $path, $include, $exclude ) | ||||||
|  |  | ||||||
|  | 	# Format generated gencpp | ||||||
|  | 	Write-Host "Beginning format" | ||||||
|  | 	$formatParams = @( | ||||||
|  | 		'-i'          # In-place | ||||||
|  | 		'-style=file:.clang-format' | ||||||
|  | 		'-verbose' | ||||||
|  | 	) | ||||||
|  |  | ||||||
|  | 	$targetFiles = @( | ||||||
|  | 		Get-ChildItem -Recurse -Path $path -Include $include -Exclude $exclude | ||||||
|  | 			| Select-Object -ExpandProperty FullName | ||||||
|  | 	) | ||||||
|  |  | ||||||
|  | 	$time_taken = Measure-Command { | ||||||
|  | 		clang-format $formatParams $targetFiles | ||||||
|  | 	} | ||||||
|  | 	Write-Host "Formatting complete in $($time_taken.TotalMilliseconds) ms`n" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | Export-ModuleMember -Function format-cpp | ||||||
							
								
								
									
										73
									
								
								scripts/helpers/incremental_checks.ps1
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								scripts/helpers/incremental_checks.ps1
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,73 @@ | |||||||
|  | # This is meant to be used with build.ps1, and is not a standalone script. | ||||||
|  |  | ||||||
|  | function check-FileForChanges | ||||||
|  | { | ||||||
|  |     param( | ||||||
|  |         [Parameter(Mandatory=$true)] | ||||||
|  |         [string]$path_file | ||||||
|  |     ) | ||||||
|  |  | ||||||
|  |     if (-not (Test-Path $path_file -PathType Leaf)) { | ||||||
|  |         Write-Error "The provided path is not a valid file: $path_file" | ||||||
|  |         return $false | ||||||
|  |     } | ||||||
|  |     $file_name = Split-Path $path_file -Leaf | ||||||
|  |     $path_csv  = Join-Path $path_build ($file_name + "_file_hash.csv") | ||||||
|  |  | ||||||
|  |     $csv_file_hash = $null | ||||||
|  |     if (Test-Path $path_csv) { | ||||||
|  |         $csv_file_hash = Import-Csv $path_csv | Select-Object -ExpandProperty value | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     $current_hash_info = Get-FileHash -Path $path_file -Algorithm MD5 | ||||||
|  |     $current_file_hash = $current_hash_info.Hash | ||||||
|  |  | ||||||
|  |     # Save the current hash to the CSV | ||||||
|  |     [PSCustomObject]@{ | ||||||
|  |         name  = $path_file | ||||||
|  |         value = $current_file_hash | ||||||
|  |     } | Export-Csv $path_csv -NoTypeInformation | ||||||
|  |  | ||||||
|  |     if ($csv_file_hash -and $csv_file_hash -eq $current_file_hash) { | ||||||
|  |         return $false | ||||||
|  |     } else { | ||||||
|  |         return $true | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | # Check to see if the module has changed files since the last build | ||||||
|  | function check-ModuleForChanges | ||||||
|  | { | ||||||
|  | 	param( [string]$path_module, [array]$excludes ) | ||||||
|  |  | ||||||
|  | 	$module_name = split-path $path_module -leaf | ||||||
|  | 	$path_csv    = Join-Path $path_build ($module_name + "_module_hashes.csv") | ||||||
|  |  | ||||||
|  | 	$csv_file_hashes = $null | ||||||
|  | 	if ( test-path $path_csv ) { | ||||||
|  | 		$csv_file_hashes = @{} | ||||||
|  | 		import-csv $path_csv | foreach-object { | ||||||
|  | 			$csv_file_hashes[ $_.name ] = $_.value | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	$file_hashes = @{} | ||||||
|  | 	get-childitem -path $path_module -recurse -file -Exclude $excludes | foreach-object { | ||||||
|  | 		$id                 = $_.fullname | ||||||
|  | 		$hash_info          = get-filehash -path $id -Algorithm MD5 | ||||||
|  | 		$file_hashes[ $id ] = $hash_info.Hash | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	$file_hashes.GetEnumerator() | foreach-object { [PSCustomObject]$_ } | | ||||||
|  | 		export-csv $path_csv -NoTypeInformation | ||||||
|  |  | ||||||
|  | 	if ( -not $csv_file_hashes )                         { return $true } | ||||||
|  | 	if ( $csv_file_hashes.Count -ne $file_hashes.Count ) { return $true } | ||||||
|  |  | ||||||
|  | 	foreach ( $key in $csv_file_hashes.Keys ) { | ||||||
|  | 		if ( $csv_file_hashes[ $key ] -ne $file_hashes[ $key ] ) { | ||||||
|  | 			return $true | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	return $false | ||||||
|  | } | ||||||
							
								
								
									
										525
									
								
								scripts/helpers/vendor_toolchain.ps1
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										525
									
								
								scripts/helpers/vendor_toolchain.ps1
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,525 @@ | |||||||
|  | # This is meant to be used with build.ps1, and is not a standalone script. | ||||||
|  |  | ||||||
|  | if ($IsWindows) { | ||||||
|  | 	# This HandmadeHero implementation is only designed for 64-bit systems | ||||||
|  |     & $devshell -arch amd64 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | if ( $vendor -eq $null ) { | ||||||
|  | 	write-host "No vendor specified, assuming clang available" | ||||||
|  | 	$vendor = "clang" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | if ( $dev ) { | ||||||
|  | 	if ( $debug -eq $null ) { | ||||||
|  | 		$debug = $true | ||||||
|  | 	} | ||||||
|  | 	if ( $optimize -eq $null ) { | ||||||
|  | 		$optimize = $false | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | function run-compiler | ||||||
|  | { | ||||||
|  | 	param( $compiler, $unit, $compiler_args ) | ||||||
|  |  | ||||||
|  | 	if ( $analysis ) { | ||||||
|  | 		$compiler_args += $flag_syntax_only | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	write-host "`Compiling $unit" | ||||||
|  | 	if ( $verbose ) { | ||||||
|  | 		write-host "Compiler config:" | ||||||
|  | 		$compiler_args | ForEach-Object { | ||||||
|  | 			write-host $_ -ForegroundColor Cyan | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	$time_taken = Measure-Command { | ||||||
|  | 		& $compiler $compiler_args 2>&1 | ForEach-Object { | ||||||
|  | 			$color = 'White' | ||||||
|  | 			switch ($_){ | ||||||
|  | 				{ $_ -match "error"   } { $color = 'Red'   ; break } | ||||||
|  | 				{ $_ -match "warning" } { $color = 'Yellow'; break } | ||||||
|  | 			} | ||||||
|  | 			write-host `t $_ -ForegroundColor $color | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if ( $LASTEXITCODE -eq 0 ) { | ||||||
|  | 		write-host "$unit compile finished in $($time_taken.TotalMilliseconds) ms`n" | ||||||
|  | 		return $true | ||||||
|  | 	} | ||||||
|  | 	else { | ||||||
|  | 		write-host "Compile failed for $unit`n" -ForegroundColor Red | ||||||
|  | 		return $false | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | function run-linker | ||||||
|  | { | ||||||
|  | 	param( $linker, $binary, $linker_args ) | ||||||
|  |  | ||||||
|  | 	write-host "`Linking $binary" | ||||||
|  | 	if ( $verbose ) { | ||||||
|  | 		write-host "Linker config:" | ||||||
|  | 		$linker_args | ForEach-Object { | ||||||
|  | 			write-host $_ -ForegroundColor Cyan | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	$time_taken = Measure-Command { | ||||||
|  | 		& $linker $linker_args 2>&1 | ForEach-Object { | ||||||
|  | 			$color = 'White' | ||||||
|  | 			switch ($_){ | ||||||
|  | 				{ $_ -match "error"   } { $color = 'Red'   ; break } | ||||||
|  | 				{ $_ -match "warning" } { $color = 'Yellow'; break } | ||||||
|  | 			} | ||||||
|  | 			write-host `t $_ -ForegroundColor $color | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if ( $LASTEXITCODE -eq 0 ) { | ||||||
|  | 		write-host "$binary linking finished in $($time_taken.TotalMilliseconds) ms`n" | ||||||
|  | 		return $true | ||||||
|  | 	} | ||||||
|  | 	else { | ||||||
|  | 		write-host "Linking failed for $binary`n" -ForegroundColor Red | ||||||
|  | 		return $false | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | if ( $vendor -match "clang" ) | ||||||
|  | { | ||||||
|  | 	# https://clang.llvm.org/docs/ClangCommandLineReference.html | ||||||
|  | 	$flag_all_c 					   = '/TC' | ||||||
|  | 	$flag_all_cpp                      = '/TP' | ||||||
|  | 	$flag_compile                      = '-c' | ||||||
|  | 	$flag_color_diagnostics            = '-fcolor-diagnostics' | ||||||
|  | 	$flag_no_color_diagnostics         = '-fno-color-diagnostics' | ||||||
|  | 	$flag_debug                        = '-g' | ||||||
|  | 	$flag_debug_codeview               = '-gcodeview' | ||||||
|  | 	$flag_define                       = '-D' | ||||||
|  | 	$flag_exceptions_disabled		   = '-fno-exceptions' | ||||||
|  | 	$flag_preprocess 			       = '-E' | ||||||
|  | 	$flag_include                      = '-I' | ||||||
|  | 	$flag_section_data                 = '-fdata-sections' | ||||||
|  | 	$flag_section_functions            = '-ffunction-sections' | ||||||
|  | 	$flag_library					   = '-l' | ||||||
|  | 	$flag_library_path				   = '-L' | ||||||
|  | 	$flag_linker                       = '-Wl,' | ||||||
|  | 	if ( $IsWindows ) { | ||||||
|  | 		$flag_link_dll                 = '/DLL' | ||||||
|  | 		$flag_link_mapfile 		       = '/MAP:' | ||||||
|  | 		$flag_link_optimize_references = '/OPT:REF' | ||||||
|  | 	} | ||||||
|  | 	if ( $IsLinux ) { | ||||||
|  | 		$flag_link_mapfile              = '--Map=' | ||||||
|  | 		$flag_link_optimize_references  = '--gc-sections' | ||||||
|  | 	} | ||||||
|  | 	$flag_link_win_subsystem_console    = '/SUBSYSTEM:CONSOLE' | ||||||
|  | 	$flag_link_win_subsystem_windows    = '/SUBSYSTEM:WINDOWS' | ||||||
|  | 	$flag_link_win_machine_32           = '/MACHINE:X86' | ||||||
|  | 	$flag_link_win_machine_64           = '/MACHINE:X64' | ||||||
|  | 	$flag_link_win_debug                = '/DEBUG' | ||||||
|  | 	$flag_link_win_pdb 			        = '/PDB:' | ||||||
|  | 	$flag_link_win_path_output          = '/OUT:' | ||||||
|  | 	$flag_no_optimization 		        = '-O0' | ||||||
|  | 	$flag_optimize_fast 		        = '-O2' | ||||||
|  | 	$flag_optimize_size 		        = '-O1' | ||||||
|  | 	$flag_optimize_intrinsics		    = '-Oi' | ||||||
|  | 	$flag_path_output                   = '-o' | ||||||
|  | 	$flag_preprocess_non_intergrated    = '-no-integrated-cpp' | ||||||
|  | 	$flag_profiling_debug               = '-fdebug-info-for-profiling' | ||||||
|  | 	$flag_set_stack_size			    = '-stack=' | ||||||
|  | 	$flag_syntax_only				    = '-fsyntax-only' | ||||||
|  | 	$flag_target_arch				    = '-target' | ||||||
|  | 	$flag_time_trace					= '-ftime-trace' | ||||||
|  | 	$flag_verbose 					    = '-v' | ||||||
|  | 	$flag_wall 					        = '-Wall' | ||||||
|  | 	$flag_warning 					    = '-W' | ||||||
|  | 	$flag_warnings_as_errors            = '-Werror' | ||||||
|  | 	$flag_win_nologo 			        = '/nologo' | ||||||
|  |  | ||||||
|  | 	$ignore_warning_ms_include            = 'no-microsoft-include' | ||||||
|  | 	$ignore_warning_return_type_c_linkage = 'no-return-type-c-linkage' | ||||||
|  |  | ||||||
|  | 	$target_arch = Get-TargetArchClang | ||||||
|  |  | ||||||
|  | 	$warning_ignores = @( | ||||||
|  | 		$ignore_warning_ms_include, | ||||||
|  | 		$ignore_warning_return_type_c_linkage | ||||||
|  | 	) | ||||||
|  |  | ||||||
|  | 	# https://learn.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=msvc-170 | ||||||
|  | 	if ( $IsWindows ) { | ||||||
|  | 		$libraries = @( | ||||||
|  | 			'Kernel32' # For Windows API | ||||||
|  | 			# 'msvcrt', # For the C Runtime (Dynamically Linked) | ||||||
|  | 			# 'libucrt', | ||||||
|  | 			'libcmt'    # For the C Runtime (Static Linkage) | ||||||
|  | 		) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	function build | ||||||
|  | 	{ | ||||||
|  | 		param( [string]$path_output, [array]$includes, [array]$compiler_args, [array]$linker_args, [array]$units, [string]$binary ) | ||||||
|  | 		$result = $false | ||||||
|  | 		#Write-Host "build: clang" | ||||||
|  |  | ||||||
|  | 		$map    = $binary -replace '\.(exe|dll)$', '.map' | ||||||
|  | 		$map    = join-path $path_output (split-path $map    -Leaf) | ||||||
|  |  | ||||||
|  | 		# This allows dll reloads at runtime to work (jankily, use below if not interested) | ||||||
|  | 		$pdb    = $binary -replace '\.(exe|dll)$', "_$(get-random).pdb" | ||||||
|  | 		# $pdb    = $binary -replace '\.(exe|dll)$', ".pdb" | ||||||
|  |  | ||||||
|  | 		$compiler_args += @( | ||||||
|  | 			$flag_no_color_diagnostics, | ||||||
|  | 			$flag_exceptions_disabled, | ||||||
|  | 			$flag_target_arch, $target_arch, | ||||||
|  | 			$flag_wall, | ||||||
|  | 			$flag_preprocess_non_intergrated | ||||||
|  | 			# $flag_section_data, | ||||||
|  | 			# $flag_section_functions, | ||||||
|  | 		) | ||||||
|  | 		if ( $verbose ) { | ||||||
|  | 			# $compiler_args += $flag_verbose | ||||||
|  | 			# $compiler_args += $flag_time_trace | ||||||
|  | 		} | ||||||
|  | 		if ( $optimize ) { | ||||||
|  | 			$compiler_args += $flag_optimize_fast | ||||||
|  | 		} | ||||||
|  | 		else { | ||||||
|  | 			$compiler_args += $flag_no_optimization | ||||||
|  | 		} | ||||||
|  | 		if ( $debug ) { | ||||||
|  | 			$compiler_args += ( $flag_define + 'Build_Debug=1' ) | ||||||
|  | 			$compiler_args += $flag_debug, $flag_debug_codeview, $flag_profiling_debug | ||||||
|  | 		} | ||||||
|  | 		else { | ||||||
|  | 			$compiler_args += ( $flag_define + 'Build_Debug=0' ) | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		$warning_ignores | ForEach-Object { | ||||||
|  | 			$compiler_args += $flag_warning + $_ | ||||||
|  | 		} | ||||||
|  | 		$compiler_args += $includes | ForEach-Object { $flag_include + $_ } | ||||||
|  |  | ||||||
|  | 		$objects = @() | ||||||
|  | 		foreach ( $unit in $units ) | ||||||
|  | 		{ | ||||||
|  | 			$object = $unit -replace '\.(cpp|c)$', '.obj' | ||||||
|  | 			$object = join-path $path_output (split-path $object -Leaf) | ||||||
|  | 			$objects += $object | ||||||
|  |  | ||||||
|  | 			$unit_compiler_args  = $compiler_args | ||||||
|  | 			$unit_compiler_args += ( $flag_path_output + $object ) | ||||||
|  |  | ||||||
|  | 			$unit_compiler_args += $flag_compile, $unit | ||||||
|  | 			run-compiler $compiler $unit $unit_compiler_args | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		$linker_args += @( | ||||||
|  | 			$flag_link_win_machine_64, | ||||||
|  | 			$( $flag_link_win_path_output + $binary ) | ||||||
|  | 		) | ||||||
|  | 		if ( $debug ) { | ||||||
|  | 			$linker_args += $flag_link_win_debug | ||||||
|  | 			$linker_args += $flag_link_win_pdb + $pdb | ||||||
|  | 			$linker_args += $flag_link_mapfile + $map | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		$libraries | ForEach-Object { | ||||||
|  | 			$linker_args += $_ + '.lib' | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		$linker_args += $objects | ||||||
|  | 		return run-linker $linker $binary $linker_args | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	function build-simple | ||||||
|  | 	{ | ||||||
|  | 		param( [string]$path_output, [array]$includes, [array]$compiler_args, [array]$linker_args, [string]$unit, [string]$binary ) | ||||||
|  | 		$result = $false | ||||||
|  | 		#Write-Host "build-simple: clang" | ||||||
|  |  | ||||||
|  | 		$object = $unit -replace '\.(cpp|c)$', '.obj' | ||||||
|  | 		$map    = $unit -replace '\.(cpp|c)$', '.map' | ||||||
|  | 		$object = join-path $path_output (split-path $object -Leaf) | ||||||
|  | 		$map    = join-path $path_output (split-path $map    -Leaf) | ||||||
|  |  | ||||||
|  | 		# This allows dll reloads at runtime to work (jankily, use below if not interested) | ||||||
|  | 		$pdb    = $binary -replace '\.(exe|dll)$', "_$(get-random).pdb" | ||||||
|  | 		# $pdb    = $binary -replace '\.(exe|dll)$', ".pdb" | ||||||
|  |  | ||||||
|  | 		$compiler_args += @( | ||||||
|  | 			$flag_no_color_diagnostics, | ||||||
|  | 			$flag_exceptions_disabled, | ||||||
|  | 			$flag_target_arch, $target_arch, | ||||||
|  | 			$flag_wall, | ||||||
|  | 			$flag_preprocess_non_intergrated, | ||||||
|  | 			# $flag_section_data, | ||||||
|  | 			# $flag_section_functions, | ||||||
|  | 			( $flag_path_output + $object ) | ||||||
|  | 		) | ||||||
|  | 		if ( $verbose ) { | ||||||
|  | 			# $compiler_args += $flag_verbose | ||||||
|  | 			# $compiler_args += $flag_time_trace | ||||||
|  | 		} | ||||||
|  | 		if ( $optimize ) { | ||||||
|  | 			$compiler_args += $flag_optimize_fast | ||||||
|  | 		} | ||||||
|  | 		else { | ||||||
|  | 			$compiler_args += $flag_no_optimization | ||||||
|  | 		} | ||||||
|  | 		if ( $debug ) { | ||||||
|  | 			$compiler_args += ( $flag_define + 'Build_Debug=1' ) | ||||||
|  | 			$compiler_args += $flag_debug, $flag_debug_codeview, $flag_profiling_debug | ||||||
|  | 		} | ||||||
|  | 		else { | ||||||
|  | 			$compiler_args += ( $flag_define + 'Build_Debug=0' ) | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		$warning_ignores | ForEach-Object { | ||||||
|  | 			$compiler_args += $flag_warning + $_ | ||||||
|  | 		} | ||||||
|  | 		$compiler_args += $includes | ForEach-Object { $flag_include + $_ } | ||||||
|  |  | ||||||
|  | 		$compiler_args += $flag_compile, $unit | ||||||
|  | 		if ( (run-compiler $compiler $unit $compiler_args) -eq $false ) { | ||||||
|  | 			return $false | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		$linker_args += @( | ||||||
|  | 			$flag_link_win_machine_64, | ||||||
|  | 			$( $flag_link_win_path_output + $binary ) | ||||||
|  | 		) | ||||||
|  | 		if ( $debug ) { | ||||||
|  | 			$linker_args += $flag_link_win_debug | ||||||
|  | 			$linker_args += $flag_link_win_pdb + $pdb | ||||||
|  | 			$linker_args += $flag_link_mapfile + $map | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		$libraries | ForEach-Object { | ||||||
|  | 			$linker_args += $_ + '.lib' | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		$linker_args += $object | ||||||
|  | 		return run-linker $linker $binary $linker_args | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	$compiler = 'clang++' | ||||||
|  | 	$linker   = 'lld-link' | ||||||
|  | } | ||||||
|  |  | ||||||
|  | if ( $vendor -match "msvc" ) | ||||||
|  | { | ||||||
|  | 	# https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-by-category?view=msvc-170 | ||||||
|  | 	$flag_all_c 					 = '/TC' | ||||||
|  | 	$flag_all_cpp                    = '/TP' | ||||||
|  | 	$flag_compile			         = '/c' | ||||||
|  | 	$flag_debug                      = '/Zi' | ||||||
|  | 	$flag_define		             = '/D' | ||||||
|  | 	$flag_exceptions_disabled		 = '/EHsc-' | ||||||
|  | 	$flag_RTTI_disabled				 = '/GR-' | ||||||
|  | 	$flag_include                    = '/I' | ||||||
|  | 	$flag_full_src_path              = '/FC' | ||||||
|  | 	$flag_nologo                     = '/nologo' | ||||||
|  | 	$flag_dll 				         = '/LD' | ||||||
|  | 	$flag_dll_debug 			     = '/LDd' | ||||||
|  | 	$flag_linker 		             = '/link' | ||||||
|  | 	$flag_link_dll                   = '/DLL' | ||||||
|  | 	$flag_link_no_incremental 	     = '/INCREMENTAL:NO' | ||||||
|  | 	$flag_link_mapfile 				 = '/MAP:' | ||||||
|  | 	$flag_link_optimize_references   = '/OPT:REF' | ||||||
|  | 	$flag_link_win_debug 	         = '/DEBUG' | ||||||
|  | 	$flag_link_win_pdb 		         = '/PDB:' | ||||||
|  | 	$flag_link_win_machine_32        = '/MACHINE:X86' | ||||||
|  | 	$flag_link_win_machine_64        = '/MACHINE:X64' | ||||||
|  | 	$flag_link_win_path_output       = '/OUT:' | ||||||
|  | 	$flag_link_win_rt_dll            = '/MD' | ||||||
|  | 	$flag_link_win_rt_dll_debug      = '/MDd' | ||||||
|  | 	$flag_link_win_rt_static         = '/MT' | ||||||
|  | 	$flag_link_win_rt_static_debug   = '/MTd' | ||||||
|  | 	$flag_link_win_subsystem_console = '/SUBSYSTEM:CONSOLE' | ||||||
|  | 	$flag_link_win_subsystem_windows = '/SUBSYSTEM:WINDOWS' | ||||||
|  | 	$flag_no_optimization		     = '/Od' | ||||||
|  | 	$flag_optimize_fast 		     = '/O2' | ||||||
|  | 	$flag_optimize_size 		     = '/O1' | ||||||
|  | 	$flag_optimize_intrinsics		 = '/Oi' | ||||||
|  | 	$flag_optimized_debug			 = '/Zo' | ||||||
|  | 	$flag_out_name                   = '/OUT:' | ||||||
|  | 	$flag_path_interm                = '/Fo' | ||||||
|  | 	$flag_path_debug                 = '/Fd' | ||||||
|  | 	$flag_path_output                = '/Fe' | ||||||
|  | 	$flag_preprocess_conform         = '/Zc:preprocessor' | ||||||
|  | 	$flag_set_stack_size			 = '/F' | ||||||
|  | 	$flag_syntax_only				 = '/Zs' | ||||||
|  | 	$flag_wall 					     = '/Wall' | ||||||
|  | 	$flag_warnings_as_errors 		 = '/WX' | ||||||
|  |  | ||||||
|  | 	function build | ||||||
|  | 	{ | ||||||
|  | 		param( [string]$path_output, [array]$includes, [array]$compiler_args, [array]$linker_args, [array]$units, [string]$binary ) | ||||||
|  | 		$result = $false | ||||||
|  | 		#Write-Host "build-simple: msvc" | ||||||
|  |  | ||||||
|  | 		$map    = $binary -replace '\.(exe|dll)$', '.map' | ||||||
|  | 		$map    = join-path $path_output (split-path $map    -Leaf) | ||||||
|  |  | ||||||
|  | 		# This allows dll reloads at runtime to work (jankily, use below if not interested) | ||||||
|  | 		$pdb    = $binary -replace '\.(exe|dll)$', "_$(get-random).pdb" | ||||||
|  | 		# $pdb    = $binary -replace '\.(exe|dll)$', ".pdb" | ||||||
|  |  | ||||||
|  | 		$compiler_args += @( | ||||||
|  | 			$flag_nologo, | ||||||
|  | 			# $flag_all_cpp, | ||||||
|  | 			$flag_exceptions_disabled, | ||||||
|  | 			( $flag_define + '_HAS_EXCEPTIONS=0' ), | ||||||
|  | 			$flag_RTTI_disabled, | ||||||
|  | 			$flag_preprocess_conform, | ||||||
|  | 			$flag_full_src_path, | ||||||
|  | 			( $flag_path_interm + $path_output + '\' ), | ||||||
|  | 			( $flag_path_output + $path_output + '\' ) | ||||||
|  | 		) | ||||||
|  |  | ||||||
|  | 		if ( $verbose ) { | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		if ( $optimize ) { | ||||||
|  | 			$compiler_args += $flag_optimize_fast | ||||||
|  | 		} | ||||||
|  | 		else { | ||||||
|  | 			$compiler_args += $flag_no_optimization | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		if ( $debug ) | ||||||
|  | 		{ | ||||||
|  | 			$compiler_args += $flag_debug | ||||||
|  | 			$compiler_args += ( $flag_define + 'Build_Debug=1' ) | ||||||
|  | 			$compiler_args += ( $flag_path_debug + $path_output + '\' ) | ||||||
|  | 			$compiler_args += $flag_link_win_rt_static_debug | ||||||
|  |  | ||||||
|  | 			if ( $optimize ) { | ||||||
|  | 				$compiler_args += $flag_optimized_debug | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		else { | ||||||
|  | 			$compiler_args += ( $flag_define + 'Build_Debug=0' ) | ||||||
|  | 			$compiler_args += $flag_link_win_rt_static | ||||||
|  | 		} | ||||||
|  | 		$compiler_args += $includes | ForEach-Object { $flag_include + $_ } | ||||||
|  |  | ||||||
|  | 		$objects = @() | ||||||
|  | 		foreach ( $unit in $units ) | ||||||
|  | 		{ | ||||||
|  | 			$object   = $unit -replace '\.(cpp|c)$', '.obj' | ||||||
|  | 			$object   = join-path $path_output (split-path $object -Leaf) | ||||||
|  | 			$objects += $object | ||||||
|  |  | ||||||
|  | 			$unit_compiler_args  = $compiler_args | ||||||
|  | 			# $unit_compiler_args += ( $flag_path_output + $object ) | ||||||
|  |  | ||||||
|  | 			$unit_compiler_args += $flag_compile, $unit | ||||||
|  | 			run-compiler $compiler $unit $unit_compiler_args | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		$linker_args += @( | ||||||
|  | 			$flag_nologo, | ||||||
|  | 			$flag_link_win_machine_64, | ||||||
|  | 			$flag_link_no_incremental, | ||||||
|  | 			( $flag_link_win_path_output + $binary ) | ||||||
|  | 		) | ||||||
|  | 		if ( $debug ) { | ||||||
|  | 			$linker_args += $flag_link_win_debug | ||||||
|  | 			$linker_args += $flag_link_win_pdb + $pdb | ||||||
|  | 			$linker_args += $flag_link_mapfile + $map | ||||||
|  | 		} | ||||||
|  | 		else { | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		$linker_args += $objects | ||||||
|  | 		return run-linker $linker $binary $linker_args | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	function build-simple | ||||||
|  | 	{ | ||||||
|  | 		param( [string]$path_output, [array]$includes, [array]$compiler_args, [array]$linker_args, [string]$unit, [string]$binary ) | ||||||
|  | 		$result = $false | ||||||
|  | 		#Write-Host "build-simple: msvc" | ||||||
|  |  | ||||||
|  | 		$object = $unit -replace '\.(cpp|c)$', '.obj' | ||||||
|  | 		$map    = $unit -replace '\.(cpp|c)$', '.map' | ||||||
|  | 		$object = join-path $path_output (split-path $object -Leaf) | ||||||
|  | 		$map    = join-path $path_output (split-path $map    -Leaf) | ||||||
|  |  | ||||||
|  | 		# This allows dll reloads at runtime to work (jankily, use below if not interested) | ||||||
|  | 		$pdb    = $binary -replace '\.(exe|dll)$', "_$(get-random).pdb" | ||||||
|  | 		# $pdb    = $binary -replace '\.(exe|dll)$', ".pdb" | ||||||
|  |  | ||||||
|  | 		$compiler_args += @( | ||||||
|  | 			$flag_nologo, | ||||||
|  | 			# $flag_all_cpp, | ||||||
|  | 			$flag_exceptions_disabled, | ||||||
|  | 			( $flag_define + '_HAS_EXCEPTIONS=0' ), | ||||||
|  | 			$flag_RTTI_disabled, | ||||||
|  | 			$flag_preprocess_conform, | ||||||
|  | 			$flag_full_src_path, | ||||||
|  | 			( $flag_path_interm + $path_output + '\' ), | ||||||
|  | 			( $flag_path_output + $path_output + '\' ) | ||||||
|  | 		) | ||||||
|  |  | ||||||
|  | 		if ( $verbose ) { | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		if ( $optimize ) { | ||||||
|  | 			$compiler_args += $flag_optimize_fast | ||||||
|  | 		} | ||||||
|  | 		else { | ||||||
|  | 			$compiler_args += $flag_no_optimization | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		if ( $debug ) | ||||||
|  | 		{ | ||||||
|  | 			$compiler_args += $flag_debug | ||||||
|  | 			$compiler_args += ( $flag_define + 'Build_Debug=1' ) | ||||||
|  | 			$compiler_args += ( $flag_path_debug + $path_output + '\' ) | ||||||
|  | 			$compiler_args += $flag_link_win_rt_static_debug | ||||||
|  |  | ||||||
|  | 			if ( $optimize ) { | ||||||
|  | 				$compiler_args += $flag_optimized_debug | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		else { | ||||||
|  | 			$compiler_args += ( $flag_define + 'Build_Debug=0' ) | ||||||
|  | 			$compiler_args += $flag_link_win_rt_static | ||||||
|  | 		} | ||||||
|  | 		$compiler_args += $includes | ForEach-Object { $flag_include + $_ } | ||||||
|  |  | ||||||
|  | 		$compiler_args += $flag_compile, $unit | ||||||
|  | 		if ( (run-compiler $compiler $unit $compiler_args) -eq $false ) { | ||||||
|  | 			return $false; | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		$linker_args += @( | ||||||
|  | 			$flag_nologo, | ||||||
|  | 			$flag_link_win_machine_64, | ||||||
|  | 			$flag_link_no_incremental, | ||||||
|  | 			( $flag_link_win_path_output + $binary ) | ||||||
|  | 		) | ||||||
|  | 		if ( $debug ) { | ||||||
|  | 			$linker_args += $flag_link_win_debug | ||||||
|  | 			$linker_args += $flag_link_win_pdb + $pdb | ||||||
|  | 			$linker_args += $flag_link_mapfile + $map | ||||||
|  | 		} | ||||||
|  | 		else { | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		$linker_args += $object | ||||||
|  | 		return run-linker $linker $binary $linker_args | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	$compiler = 'cl' | ||||||
|  | 	$linker   = 'link' | ||||||
|  | } | ||||||
| @@ -1,6 +1,4 @@ | |||||||
| # Singleheader | # Singleheader | ||||||
|  |  | ||||||
| `gen.singleheader.cpp` with its own `meson.build` generates the library as a single header `gen.hpp`. | Creates a single header file version of the library using `gen.singleheader.cpp`. | ||||||
| Following the same convention seen in the gb, stb, and zpl libraries. | Follows the same convention seen in the gb, stb, and zpl libraries. | ||||||
|  |  | ||||||
| ( Currently WIP ) |  | ||||||
|   | |||||||
| @@ -17,7 +17,7 @@ GEN_NS_END | |||||||
| using namespace gen; | using namespace gen; | ||||||
|  |  | ||||||
| constexpr char const* generation_notice = | constexpr char const* generation_notice = | ||||||
| "// This file was generated automatially by gen.bootstrap.cpp " | "// This file was generated automatially by gencpp's singleheader.cpp" | ||||||
| "(See: https://github.com/Ed94/gencpp)\n\n"; | "(See: https://github.com/Ed94/gencpp)\n\n"; | ||||||
|  |  | ||||||
| constexpr StrC implementation_guard_start = txt(R"( | constexpr StrC implementation_guard_start = txt(R"( | ||||||
| @@ -48,8 +48,6 @@ global bool generate_builder = true; | |||||||
| global bool generate_editor  = true; | global bool generate_editor  = true; | ||||||
| global bool generate_scanner = true; | global bool generate_scanner = true; | ||||||
|  |  | ||||||
| constexpr bool DontSkipInitialDirectives = false; |  | ||||||
|  |  | ||||||
| int gen_main() | int gen_main() | ||||||
| { | { | ||||||
| #define project_dir "../project/" | #define project_dir "../project/" | ||||||
| @@ -57,7 +55,7 @@ int gen_main() | |||||||
|  |  | ||||||
| 	Code push_ignores        = scan_file( project_dir "helpers/push_ignores.inline.hpp" ); | 	Code push_ignores        = scan_file( project_dir "helpers/push_ignores.inline.hpp" ); | ||||||
| 	Code pop_ignores         = scan_file( project_dir "helpers/pop_ignores.inline.hpp" ); | 	Code pop_ignores         = scan_file( project_dir "helpers/pop_ignores.inline.hpp" ); | ||||||
| 	Code single_header_start = scan_file( "components/header_start.hpp", DontSkipInitialDirectives ); | 	Code single_header_start = scan_file( "components/header_start.hpp" ); | ||||||
|  |  | ||||||
| 	Builder | 	Builder | ||||||
| 	header = Builder::open( "gen/gen.hpp" ); | 	header = Builder::open( "gen/gen.hpp" ); | ||||||
| @@ -71,7 +69,7 @@ int gen_main() | |||||||
|  |  | ||||||
| 		if ( generate_gen_dep ) | 		if ( generate_gen_dep ) | ||||||
| 		{ | 		{ | ||||||
| 			Code header_start = scan_file( project_dir "dependencies/header_start.hpp", DontSkipInitialDirectives ); | 			Code header_start = scan_file( project_dir "dependencies/header_start.hpp" ); | ||||||
| 			Code macros       = scan_file( project_dir "dependencies/macros.hpp" ); | 			Code macros       = scan_file( project_dir "dependencies/macros.hpp" ); | ||||||
| 			Code basic_types  = scan_file( project_dir "dependencies/basic_types.hpp" ); | 			Code basic_types  = scan_file( project_dir "dependencies/basic_types.hpp" ); | ||||||
| 			Code debug        = scan_file( project_dir "dependencies/debug.hpp" ); | 			Code debug        = scan_file( project_dir "dependencies/debug.hpp" ); | ||||||
| @@ -154,13 +152,6 @@ int gen_main() | |||||||
| 			header.print_fmt( "#pragma endregion Builder\n" ); | 			header.print_fmt( "#pragma endregion Builder\n" ); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if ( generate_scanner ) |  | ||||||
| 		{ |  | ||||||
| 			header.print_fmt( "\n#pragma region Scanner\n" ); |  | ||||||
| 			header.print( scan_file( project_dir "auxillary/scanner.hpp" ) ); |  | ||||||
| 			header.print_fmt( "#pragma endregion Scanner\n\n" ); |  | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		header.print_fmt( "GEN_NS_END\n" ); | 		header.print_fmt( "GEN_NS_END\n" ); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -240,6 +231,14 @@ int gen_main() | |||||||
| 			header.print_fmt( "\n#pragma endregion Builder\n\n" ); | 			header.print_fmt( "\n#pragma endregion Builder\n\n" ); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		// Scanner header depends on implementation | ||||||
|  | 		if ( generate_scanner ) | ||||||
|  | 		{ | ||||||
|  | 			header.print_fmt( "\n#pragma region Scanner\n" ); | ||||||
|  | 			header.print( scan_file( project_dir "auxillary/scanner.hpp" ) ); | ||||||
|  | 			header.print_fmt( "#pragma endregion Scanner\n\n" ); | ||||||
|  | 		} | ||||||
|  |  | ||||||
| #if 0 | #if 0 | ||||||
| 		if ( generate_scanner ) | 		if ( generate_scanner ) | ||||||
| 		{ | 		{ | ||||||
|   | |||||||
							
								
								
									
										35
									
								
								test/CURSED_TYPEDEF.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								test/CURSED_TYPEDEF.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | |||||||
|  | #include <functional> | ||||||
|  |  | ||||||
|  | class MyClass; | ||||||
|  |  | ||||||
|  | enum class MyEnum : short { VAL1, VAL2 }; | ||||||
|  |  | ||||||
|  | struct OuterStruct { | ||||||
|  |     union NamedUnion { | ||||||
|  |         struct InnerStruct { | ||||||
|  |             double d; | ||||||
|  |             char c; | ||||||
|  |         } inner; | ||||||
|  |         int i; | ||||||
|  |     } unionInstance; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | template<typename T, int N = alignof(double)> | ||||||
|  | struct TemplateStruct { | ||||||
|  |     T member[N]; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | template<> | ||||||
|  | struct TemplateStruct<int, 10> { | ||||||
|  |     int specialMember[10]; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | typedef decltype(nullptr) (MyClass::*InsaneComplexTypeDef)( | ||||||
|  |     decltype((MyEnum::VAL1 == MyEnum::VAL2) ? 1 : 2.0) | ||||||
|  |         (TemplateStruct<decltype(OuterStruct().unionInstance.inner), 5>::*ptr)[5][alignof(double)], | ||||||
|  |     std::function<void *(TemplateStruct<int, 10>&&, | ||||||
|  |         void (MyClass::*memFnPtr)(TemplateStruct<decltype(OuterStruct().unionInstance.inner)>))>, | ||||||
|  |     int (MyClass::*&refToMemFnPtr)(TemplateStruct<int, 10>), | ||||||
|  |     int (TemplateStruct<int, 10>::*memberPointer)[10], | ||||||
|  |     char&&... | ||||||
|  | ) volatile const && noexcept; | ||||||
							
								
								
									
										13
									
								
								test/GamePipeline/Readme.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								test/GamePipeline/Readme.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | |||||||
|  | # Test : Eskil Steenberg's Game Pipeline | ||||||
|  |  | ||||||
|  | ***Note: This validation test has not been implemented yet.*** | ||||||
|  |  | ||||||
|  | Repo : https://github.com/valiet/quel_solaar | ||||||
|  |  | ||||||
|  | This is a AST reconstruction test of the gamepipeline library. | ||||||
|  |  | ||||||
|  | 1. Download the library | ||||||
|  | 2. Grab all header and source file paths | ||||||
|  | 3. Generate an ast for each file and serialize it to a file called <name of file>.gen.<h/c> | ||||||
|  | 4. Reconstruct the ast from the generated file | ||||||
|  | 5. Compare the original ast to the reconstructed ast | ||||||
							
								
								
									
										0
									
								
								test/GamePipeline/validate.gamepipeline.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								test/GamePipeline/validate.gamepipeline.cpp
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										0
									
								
								test/GamePipeline/validate.ps1
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								test/GamePipeline/validate.ps1
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										15
									
								
								test/Godot/Readme.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								test/Godot/Readme.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | |||||||
|  | # Test : Godot full AST reconstruction and compile validation | ||||||
|  |  | ||||||
|  | ***Note: This validation test has not been implemented yet.*** | ||||||
|  |  | ||||||
|  | Repo : https://github.com/godotengine/godot | ||||||
|  |  | ||||||
|  | * Download the Unreal source code | ||||||
|  | * Find paths of every header and source file | ||||||
|  | * Generate an ast for each file and serialize it to a file called `<name of file>.gen.<h/c>` | ||||||
|  | * Reconstruct the ast from the generated file | ||||||
|  | * Compare the original ast to the reconstructed ast | ||||||
|  | * If all ASTs are considered valid, overwrite the original files with the generated files | ||||||
|  | * Compile the engine. | ||||||
|  |  | ||||||
|  | Currently the most involved test planned for the library. | ||||||
							
								
								
									
										0
									
								
								test/Godot/validate.godot.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								test/Godot/validate.godot.cpp
									
									
									
									
									
										Normal file
									
								
							Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user