Skip to content

Commit ee197af

Browse files
committed
Prevent symbol collisions, update dishwasher
1 parent 3cbef1e commit ee197af

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

build.zig.zon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
.version = "0.0.0",
44
.dependencies = .{
55
.dishwasher = .{
6-
.url = "https://github.com/edqx/dishwasher/archive/refs/tags/1.0.4.zip",
7-
.hash = "12209f29d4963ec005990c46310ce63d883b2c02d1e79906ec60ec1b4f40466d34a0",
6+
.url = "https://github.com/edqx/dishwasher/archive/refs/tags/1.0.5.zip",
7+
.hash = "12209904f622e4ffb9aa8d6fef6bc6e2eeb6536e057b6c8b8c65a6287dbdd9ec536a",
88
},
99
.@"OpenGL-Registry" = .{
1010
.url = "https://github.com/KhronosGroup/OpenGL-Registry/archive/5466009a38991f5ea5c2009105bd83f19fe49979.zip",

src/main.zig

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -378,11 +378,11 @@ const GLSpec = struct {
378378
try writer.print("{s}", .{zigTypeDefs});
379379
try writer.print("\n\n", .{});
380380

381-
var enums = std.ArrayList([]const u8).init(self.allocator);
382-
defer enums.deinit();
381+
var enumNames = std.StringHashMap(void).init(self.allocator);
382+
defer enumNames.deinit();
383383

384-
var commands = std.ArrayList([]const u8).init(self.allocator);
385-
defer commands.deinit();
384+
var commandNames = std.StringHashMap(void).init(self.allocator);
385+
defer commandNames.deinit();
386386

387387
// try commands.append("glGetShaderSource");
388388

@@ -396,23 +396,30 @@ const GLSpec = struct {
396396
}
397397

398398
for (featureSet.enums) |enumSet| {
399-
try enums.appendSlice(enumSet);
399+
for (enumSet) |enumName| {
400+
try enumNames.put(enumName, {});
401+
}
400402
}
401403

402404
for (featureSet.commands) |commandSet| {
403-
try commands.appendSlice(commandSet);
405+
for (commandSet) |commandName| {
406+
try commandNames.put(commandName, {});
407+
}
404408
}
405409
}
406410

407-
for (enums.items) |enumName| {
408-
const @"enum" = enumQuickSet.get(enumName) orelse unreachable;
411+
var enumIter = enumNames.keyIterator();
412+
var commandIter = commandNames.keyIterator();
413+
414+
while (enumIter.next()) |enumName| {
415+
const @"enum" = enumQuickSet.get(enumName.*) orelse unreachable;
409416
try writer.print("{}\n", .{@"enum"});
410417
}
411418

412419
try writer.print("\n", .{});
413420

414-
for (commands.items) |commandName| {
415-
const command = commandQuickSet.get(commandName) orelse unreachable;
421+
while (commandIter.next()) |commandName| {
422+
const command = commandQuickSet.get(commandName.*) orelse unreachable;
416423
try writer.print("{}\n", .{Command.Formatter{ .allocator = self.allocator, .command = command, .static = self.static }});
417424
}
418425

@@ -446,9 +453,10 @@ const GLSpec = struct {
446453
try writer.print(
447454
\\pub fn init() void {{
448455
, .{});
449-
for (commands.items) |commandName| {
456+
var commandIter2 = commandNames.keyIterator();
457+
while (commandIter2.next()) |commandName| {
450458
try writer.print("\n", .{});
451-
const command = commandQuickSet.get(commandName) orelse unreachable;
459+
const command = commandQuickSet.get(commandName.*) orelse unreachable;
452460
try writer.print(
453461
\\ {} = @ptrCast(loadFn("{s}") orelse @panic("Cannot find proc \"{s}\""));
454462
, .{ formatSymbol(command.prototype.name), command.prototype.name, command.prototype.name });
@@ -496,10 +504,13 @@ pub fn main() !void {
496504
};
497505

498506
var isWasm = false;
507+
var time = false;
499508
while (args.next()) |arg| {
500509
if (std.mem.eql(u8, arg, "--static")) isWasm = true;
510+
if (std.mem.eql(u8, arg, "--time")) time = true;
501511
}
502512

513+
const us1 = std.time.microTimestamp();
503514
var document = try xml.parseXmlFull(gpa.allocator(), @embedFile("gl.xml"));
504515
defer document.deinit();
505516

@@ -538,4 +549,8 @@ pub fn main() !void {
538549
\\//
539550
, .{ "2024", api, version, isWasm });
540551
try outFile.writer().print("\n{}", .{formatter});
552+
const us2 = std.time.microTimestamp();
553+
const ms: usize = @intCast(@divFloor(us2 - us1, 1000));
554+
555+
if (time) try std.io.getStdOut().writer().print("took {}ms", .{ms});
541556
}

0 commit comments

Comments
 (0)