From e9fcd25c51228fb0b5edcb0066dd348f267d2933 Mon Sep 17 00:00:00 2001 From: Peterino2 Date: Thu, 22 Jan 2026 18:55:36 -0800 Subject: [PATCH] Fix parser issues: remove trailing comma syntax, add SDL_ACQUIRE/RELEASE macro stripping, add Uint16/Uint8 pointer type conversions --- lib/sdl3/parser/src/codegen.zig | 14 ++------------ lib/sdl3/parser/src/patterns.zig | 2 ++ lib/sdl3/parser/src/types.zig | 4 ++++ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/sdl3/parser/src/codegen.zig b/lib/sdl3/parser/src/codegen.zig index 5681282..b49d027 100644 --- a/lib/sdl3/parser/src/codegen.zig +++ b/lib/sdl3/parser/src/codegen.zig @@ -430,12 +430,7 @@ pub const CodeGen = struct { } // ) *GPUDevice { - // Add trailing comma for functions with more than 3 parameters (triggers multi-line formatting) - if (func.params.len > 3) { - try self.output.writer(self.allocator).print(",) {s} {{\n", .{zig_return_type}); - } else { - try self.output.writer(self.allocator).print(") {s} {{\n", .{zig_return_type}); - } + try self.output.writer(self.allocator).print(") {s} {{\n", .{zig_return_type}); // Function body - call C API with appropriate casts try self.output.appendSlice(self.allocator, " return "); @@ -523,12 +518,7 @@ pub const CodeGen = struct { } // ) *GPUDevice { - // Add trailing comma for functions with more than 3 parameters (triggers multi-line formatting) - if (func.params.len > 3) { - try self.output.writer(self.allocator).print(",) {s} {{\n", .{zig_return_type}); - } else { - try self.output.writer(self.allocator).print(") {s} {{\n", .{zig_return_type}); - } + try self.output.writer(self.allocator).print(") {s} {{\n", .{zig_return_type}); // Function body - call C API with appropriate casts try self.output.appendSlice(self.allocator, " return "); diff --git a/lib/sdl3/parser/src/patterns.zig b/lib/sdl3/parser/src/patterns.zig index fbb9467..140ae6a 100644 --- a/lib/sdl3/parser/src/patterns.zig +++ b/lib/sdl3/parser/src/patterns.zig @@ -1060,6 +1060,8 @@ pub const Scanner = struct { "SDL_PRINTF_VARARG_FUNCV", "SDL_WPRINTF_VARARG_FUNC", "SDL_SCANF_VARARG_FUNC", + "SDL_ACQUIRE", + "SDL_RELEASE", }; for (vararg_macros) |macro| { if (std.mem.indexOf(u8, text, macro)) |pos| { diff --git a/lib/sdl3/parser/src/types.zig b/lib/sdl3/parser/src/types.zig index 5f91d4a..99a3652 100644 --- a/lib/sdl3/parser/src/types.zig +++ b/lib/sdl3/parser/src/types.zig @@ -78,9 +78,13 @@ pub fn convertType(c_type: []const u8, allocator: Allocator) ![]const u8 { if (std.mem.eql(u8, trimmed, "bool *")) return try allocator.dupe(u8, "*bool"); if (std.mem.eql(u8, trimmed, "size_t *")) return try allocator.dupe(u8, "*usize"); if (std.mem.eql(u8, trimmed, "float *")) return try allocator.dupe(u8, "*f32"); + if (std.mem.eql(u8, trimmed, "const float *")) return try allocator.dupe(u8, "*const f32"); if (std.mem.eql(u8, trimmed, "double *")) return try allocator.dupe(u8, "*f64"); + if (std.mem.eql(u8, trimmed, "Uint8 *")) return try allocator.dupe(u8, "*u8"); + if (std.mem.eql(u8, trimmed, "Uint16 *")) return try allocator.dupe(u8, "*u16"); if (std.mem.eql(u8, trimmed, "Uint32 *")) return try allocator.dupe(u8, "*u32"); if (std.mem.eql(u8, trimmed, "Uint64 *")) return try allocator.dupe(u8, "*u64"); + if (std.mem.eql(u8, trimmed, "Sint16 *")) return try allocator.dupe(u8, "*i16"); if (std.mem.eql(u8, trimmed, "Sint32 *")) return try allocator.dupe(u8, "*i32"); if (std.mem.eql(u8, trimmed, "const bool *")) return try allocator.dupe(u8, "*const bool");