Fix parser issues: remove trailing comma syntax, add SDL_ACQUIRE/RELEASE macro stripping, add Uint16/Uint8 pointer type conversions

This commit is contained in:
Peterino2 2026-01-22 18:55:36 -08:00
parent d03338034e
commit e9fcd25c51
3 changed files with 8 additions and 12 deletions

View File

@ -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 ");

View File

@ -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| {

View File

@ -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");