add skill and some adjustments
This commit is contained in:
@@ -27,17 +27,15 @@ This document outlines the strict C style and architectural conventions expected
|
||||
* **Case:** Strictly use `lower_snake_case` for all functions and variables.
|
||||
* **Types:** Use `PascalCase` for type names (`FArena`, `SWord_Tag`).
|
||||
* **WinAPI Symbols:** When declaring foreign Win32 symbols, prefix the C function name with `ms_` (using `lower_snake_case`) and use the `asm("SymbolName")` attribute to link it to the actual DLL export.
|
||||
* *Correct:* `WinAPI U2 ms_register_class(const MS_WNDCLASSA* lpWndClass) asm("RegisterClassA");`
|
||||
* *Correct:* `WinAPI U2 ms_register_class_a(const MS_WNDCLASSA* lpWndClass) asm("RegisterClassA");`
|
||||
* *Incorrect:* `WinAPI U2 RegisterClassA(...);`
|
||||
|
||||
## 4. Memory Management
|
||||
## 4. Formatting & Layout
|
||||
* **Vertical Alignment:** Align related variable declarations, struct fields, and function prototypes into columns to create a "sheet-like" layout. This improves visual parsing.
|
||||
* **Brace Style:** Use Allman style (braces on a new line) for function bodies control block (`if`, `for`, `switch`, etc.) that spans more than 50 lines or contains nested logic.
|
||||
* **Conditionals:** Always place `else if` and `else` statements on a new line, un-nested from the previous closing brace.
|
||||
|
||||
## 5. Memory Management
|
||||
* **No Standard Library:** The environment is built with `-nostdlib` and `-ffreestanding`. Never include `<stdlib.h>`, `<string.h>`, etc.
|
||||
* **Arenas over Malloc:** Use `FArena` and its associated macros (`farena_push`, `farena_push_type`, `farena_reset`) for all dynamic memory allocations. Do not use raw pointers with manual arithmetic when an arena can handle it.
|
||||
* **Memory Ops:** Use `mem_fill` and `mem_copy` instead of standard `memset`/`memcpy` within the application logic. (A minimal `memset`/`memcpy` shim is only provided to satisfy compiler intrinsic struct zeroing under `-nostdlib`).
|
||||
|
||||
## 5. Modifiers
|
||||
* `internal`: Static functions.
|
||||
* `global`: Global state variables.
|
||||
* `IA_`: Internal Always Inline.
|
||||
* `I_`: Internal Inline.
|
||||
* Pointers use `*r` (restrict) or `*v` (volatile) macros where applicable.
|
||||
* **Memory Ops:** Use `mem_fill` and `mem_copy` instead of standard `memset`/`memcpy` within the application logic.
|
||||
|
||||
Reference in New Issue
Block a user