adjustments

This commit is contained in:
2026-02-20 21:03:37 -05:00
parent 3c99f3f950
commit e630590065
3 changed files with 51 additions and 19 deletions

View File

@@ -32,7 +32,29 @@ This document outlines the strict C style and architectural conventions expected
## 4. Formatting & Layout ## 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. * **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. * Example Struct:
```c
typedef struct MS_WNDCLASSA {
U4 style;
S8 (*lpfnWndProc)(void*, U4, U8, S8);
S4 cbClsExtra;
// ...
char const* lpszClassName;
} MS_WNDCLASSA;
```
* **Multi-line Argument Alignment:** For long function signatures, place one argument per line with a single 4-space indent.
* Example:
```c
WinAPI B4 ms_read_console(
MS_Handle handle,
UTF8*r buffer,
U4 to_read,
U4*r num_read,
U8 reserved_input_control
) asm("ReadConsoleA");
```
* **WinAPI Grouping:** Group foreign procedure declarations by their originating OS library (e.g., Kernel32, User32, GDI32) using comment headers.
* **Brace Style:** Use Allman style (braces on a new line) for function bodies or control blocks (`if`, `for`, `switch`, etc.) that are large or complex. Smaller blocks may use K&R style.
* **Conditionals:** Always place `else if` and `else` statements on a new line, un-nested from the previous closing brace. * **Conditionals:** Always place `else if` and `else` statements on a new line, un-nested from the previous closing brace.
## 5. Memory Management ## 5. Memory Management
@@ -45,3 +67,13 @@ This document outlines the strict C style and architectural conventions expected
* **Correct:** `char const* my_ptr;` (Pointer to a constant character) * **Correct:** `char const* my_ptr;` (Pointer to a constant character)
* **Correct:** `U4 const* const my_ptr;` (Constant pointer to a constant U4) * **Correct:** `U4 const* const my_ptr;` (Constant pointer to a constant U4)
* **Incorrect:** `const char* my_ptr;` * **Incorrect:** `const char* my_ptr;`
## 7. Metadata Coupling (X-Macros)
* **Metadata Enums:** Use X-Macros to define Enums that are tightly coupled with static metadata (colors, prefixes, names).
* Example:
```c
#define Tag_Entries() \
X(Define, "Define", 0x0018AEFF, ":") \
X(Call, "Call", 0x00D6A454, "~")
```
* **Naming Conventions:** When using X-Macros for Tags, entry names should be PascalCase, and the Enum symbols should be prefixed with the Enum type name (e.g., `tmpl(STag, Define)` -> `STag_Define`).

View File

@@ -696,4 +696,15 @@ WinAPI S4 ms_delete_object(void* ho) asm("
#define MS_VK_DOWN 0x28 #define MS_VK_DOWN 0x28
#define MS_PAGE_EXECUTE_READWRITE 0x40 #define MS_PAGE_EXECUTE_READWRITE 0x40
#define MS_WM_CHAR 0x0102
#define MS_VK_RETURN 0x0D
#define MS_VK_BACK 0x08
#define MS_VK_TAB 0x09
#define MS_VK_SPACE 0x20
#define MS_VK_F5 0x74
#define MS_VK_PRIOR 0x21
#define MS_VK_NEXT 0x22
#define MS_VK_SHIFT 0x10
#pragma endregion OS_GDI_And_Minimal #pragma endregion OS_GDI_And_Minimal

View File

@@ -216,11 +216,11 @@ IA_ void compile_and_run_tape(void)
in_def = false; in_def = false;
} }
} }
else if (tag == tmpl(STag, Data)) { else if (tag == STag_Data) {
emit8(0x48); emit8(0x89); emit8(0xC2); // mov rdx, rax emit8(0x48); emit8(0x89); emit8(0xC2); // mov rdx, rax
emit8(0x48); emit8(0xC7); emit8(0xC0); emit32(val); // mov rax, imm32 emit8(0x48); emit8(0xC7); emit8(0xC0); emit32(val); // mov rax, imm32
} }
else if (tag == tmpl(STag, Imm)) else if (tag == STag_Imm)
{ {
if (in_def) { if (in_def) {
// If we execute something, we jump out of def block first // If we execute something, we jump out of def block first
@@ -253,17 +253,6 @@ IA_ void compile_and_run_tape(void)
vm_rdx = vm_globals[15]; vm_rdx = vm_globals[15];
} }
#define MS_WM_CHAR 0x0102
#define MS_VK_RETURN 0x0D
#define MS_VK_BACK 0x08
#define MS_VK_TAB 0x09
#define MS_VK_SPACE 0x20
#define MS_VK_F5 0x74
#define MS_VK_PRIOR 0x21
#define MS_VK_NEXT 0x22
#define MS_VK_SHIFT 0x10
// --- Window Procedure --- // --- Window Procedure ---
S8 win_proc(void* hwnd, U4 msg, U8 wparam, S8 lparam) S8 win_proc(void* hwnd, U4 msg, U8 wparam, S8 lparam)
{ {