Implemented two critical parser enhancements that unlock 3 more perfect APIs and fix issues across multiple headers. ## Features Added ### 1. Array Field Parsing Support for C array fields in structs: ```c Uint8 padding[2]; // C → padding: [2]u8, // Zig ``` **Implementation (patterns.zig)**: - Detect array syntax with `[` bracket - Parse pattern: `Type name[size]` - Extract base type, field name, and array notation - Reconstruct as Zig array type: `Type[size]` **Type Conversion (types.zig)**: - Handle array types in `convertType()` - Pattern: `Uint8[2]` → `[2]u8` - Recursively convert base type - Reorder to Zig syntax: `[size]BaseType` ### 2. Multi-Line Comment Handling Fixed enum parsing to skip multi-line `/* ... */` comments: - Previously only handled `/** ... */` documentation comments - SDL uses `/* ... */` for macro expansion examples - Comments were leaking into enum values causing syntax errors **Before**: ```zig chromaLocationNone), // Stray ) from comment! ``` **After**: ```zig chromaLocationNone, // Clean! ``` **Implementation**: - Changed comment detection from `/**` to `/*` - Tracks `in_multiline_comment` state - Skips ALL lines within comment blocks ## Results ### Before - 19/43 APIs perfect (44%) - Array fields: NOT SUPPORTED - Multi-line comments: BROKEN ### After - **22/43 APIs perfect (51%)** ✅ - Array fields: FULLY SUPPORTED - Multi-line comments: FIXED **Progress: +7% (+3 APIs)** ### New Perfect APIs ✅ **SDL_pixels.h** (288 lines) - Pixel format definitions - Color management (palettes, colorspaces) - Had 4 errors: array fields + multi-line comments - Now perfect! ✅ **SDL_surface.h** (495 lines) - Surface creation and manipulation - Largest perfect API so far! - Had 2 errors: array fields + multi-line comments - Now perfect! ✅ **SDL_guid.h** (13 lines) - GUID utilities - Was 1 error, now perfect! ## Technical Details ### Array Field Parsing Algorithm 1. Detect `[` in field declaration 2. Split at bracket: `Uint8 padding[2]` → before: `Uint8 padding`, array: `[2]` 3. Tokenize before bracket by spaces 4. Last token is field name, rest is type 5. Combine type + array notation: `Uint8[2]` 6. Generate Zig: `padding: [2]u8,` ### Multi-Line Comment Fix Changed detection in enum scanning from: ```zig if (std.mem.indexOf(u8, trimmed, "/**")) |_| { ``` To: ```zig if (std.mem.indexOf(u8, trimmed, "/*")) |_| { ``` This catches ALL multi-line comments, not just doc comments. ## Impact **Immediate**: +3 perfect APIs (7% improvement) **Unlocked**: Array fields now work everywhere **Fixed**: Enum parsing more robust ## Code Changes ### src/patterns.zig (+40 lines) - `parseStructField()`: Array field detection and parsing - `scanEnum()`: Fixed multi-line comment detection - Uses fixed buffers (no allocations) for performance ### src/types.zig (+15 lines) - `convertType()`: Array type conversion - Recursive base type conversion - Reorders to Zig syntax: `[size]Type` ## Testing Tested against all 43 SDL3 headers: - 22 compile perfectly (0 errors) ✅ - 21 have 1-13 errors (edge cases) - 0 complete failures **Cumulative Progress**: - Session start: 15 APIs (35%) - After function pointers: 19 APIs (44%) - After arrays & comments: **22 APIs (51%)** 🎉 **More than half of SDL3 APIs now generate perfectly!** ## Example Output **Input** (SDL_pixels.h): ```c typedef struct SDL_PixelFormatDetails { SDL_PixelFormat format; Uint8 bits_per_pixel; Uint8 bytes_per_pixel; Uint8 padding[2]; Uint32 Rmask; ... } SDL_PixelFormatDetails; ``` **Output** (pixels.zig): ```zig pub const PixelFormatDetails = extern struct { format: PixelFormat, bits_per_pixel: u8, bytes_per_pixel: u8, padding: [2]u8, Rmask: u32, ... }; ``` --- Arrays are now fully supported - critical for many SDL structs! |
||
|---|---|---|
| .github/workflows | ||
| archive | ||
| build | ||
| buildgen | ||
| depot | ||
| docs | ||
| engine | ||
| extras | ||
| lib | ||
| projects | ||
| testing | ||
| tools | ||
| .gitattributes | ||
| .gitignore | ||
| CLAUDE.md | ||
| LICENSE | ||
| README.md | ||
| build.archive.zig | ||
| build.zig | ||
| build.zig.zon | ||
| content.txt | ||
| todo.txt | ||
README.md
Backlog
zig version: 0.15.1
Backlog Labs Game Engine.
Getting Started
run tools/scripts/first-time-setup.py
ffmpeg -i INPUT.mp4 -c:v libtheora -q:v 7 -c:a libvorbis -q:a 4 OUTPUT.ogv
git-bug Cheat Sheet
This project uses git-bug for distributed issue tracking. Issues are stored directly in the repository.
Common Commands
Listing Issues
git bug bug # List all issues
git bug bug status:open # List only open issues
git bug bug status:closed # List only closed issues
Creating Issues
git bug bug new -t "title" -m "message" # Create new issue
git bug bug new -t "Add feature X" -m "Description" # Example
Viewing & Managing Issues
git bug bug show <id> # Show issue details
git bug bug comment <id> # Add a comment to an issue
git bug bug close <id> # Close an issue
git bug bug open <id> # Reopen an issue
git bug bug status <id> # Show issue status
Labels
git bug bug label <id> # Show labels for an issue
git bug bug label new <id> <label> # Add a label
git bug bug label rm <id> <label> # Remove a label
Syncing
git bug pull # Pull issue updates from remote
git bug push # Push issue updates to remote
Standard Labels
Component Labels: core, rendering, physics, build-system, platform, assets, audio, ui, documentation
Type Labels:
bug- Defects or incorrect behaviorfeature- New functionalityenhancement- Improvements to existing featurestask- General development workdocumentation- Documentation improvementsquestion- Design decisions or discussionsrefactoring- Code cleanup
Problem Type Labels (for bugs):
memory- Memory issuesthreading- Concurrency issuescrash- Application crashesbuild- Build system issues
Quick Examples
# Create a bug report
git bug bug new -t "Memory leak in asset loader" -m "Assets not freed when unloading scenes"
git bug bug label new <id> bug assets memory
# Create a feature request
git bug bug new -t "Add terrain generation" -m "Implement heightmap-based terrain"
git bug bug label new <id> feature rendering
# Create a task
git bug bug new -t "Update to Zig 0.15" -m "Migrate to latest Zig version"
git bug bug label new <id> task build-system
# View and comment on an issue
git bug bug show abc123
git bug bug comment abc123
Tips
- Issue IDs can be abbreviated (first few characters)
- Use
--non-interactiveflag for scripting - Issues sync with
git bug pull/push - Keep descriptions factual and clear