doc: Began documenting the code style
This commit is contained in:
		
							parent
							
								
									5709cc98a5
								
							
						
					
					
						commit
						3059fce861
					
				
							
								
								
									
										33
									
								
								docs/CODE_STYLE.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								docs/CODE_STYLE.md
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					# Naming
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Functions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Functions (and methods) use `PascalCase`.
 | 
				
			||||||
 | 
					Functions (but not methods) exposed in headers additionally use the prefix  `rt`: `rtLoadResource`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Types
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Types (including C++ clases) use `snake_case`.
 | 
				
			||||||
 | 
					Types exposed in header files use the prefix `rt_`: `rt_aio_handle`.
 | 
				
			||||||
 | 
					This is often also done for "private" types in C/C++ files, but there it is not mandatory.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Variables
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Variables use `snake_case`.
 | 
				
			||||||
 | 
					Global variables use the prefix `g_`, while file-scope global variables use a single underscore as their prefix `_`.
 | 
				
			||||||
 | 
					Member variables of C++ classes (but not plain-old data C structs) use the prefix `m_`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Macros
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Macros use `ALL_UPPER_CASE` with the `RT_` prefix.
 | 
				
			||||||
 | 
					This is also used for enum options.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## API and Interface Structs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					API structs (like `rt_render_backend_api`) are collections of function pointers,
 | 
				
			||||||
 | 
					without any "object pointer" containing wrapped state.
 | 
				
			||||||
 | 
					They use the suffix `_api`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Interface structs (like `rt_render_device_i`) also contain function pointers,
 | 
				
			||||||
 | 
					and additionally an "object pointer", usually called `o`, that points to some
 | 
				
			||||||
 | 
					stateful object. The function pointers in the interface usually take this object as their first parameter.
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user