Tweak generate.Tuple and generate.Union

Leverage comptime fields to give generated Tuple a default value, allowing
TupleT and Tuple to be merged.

Only call generate.Tuple on the final output. This eliminates redundant
deduplication, and results in a simpler API (nested types just need to expose
a natural Zig tuple).

generate.Union leverages the new Tuple and removes unused features.
This commit is contained in:
Karl Seguin
2025-02-01 14:31:16 +08:00
parent 00d332cd16
commit fc0ec860b0
17 changed files with 203 additions and 450 deletions

View File

@@ -99,9 +99,8 @@ pub const Interfaces = .{
HTMLVideoElement,
CSSProperties,
};
const Generated = generate.Union.compile(Interfaces);
pub const Union = Generated._union;
pub const Tags = Generated._enum;
pub const Union = generate.Union(Interfaces);
// Abstract class
// --------------

View File

@@ -25,7 +25,7 @@ const Navigator = @import("navigator.zig").Navigator;
const History = @import("history.zig").History;
const Location = @import("location.zig").Location;
pub const Interfaces = generate.Tuple(.{
pub const Interfaces = .{
HTMLDocument,
HTMLElem.HTMLElement,
HTMLElem.HTMLMediaElement,
@@ -34,4 +34,4 @@ pub const Interfaces = generate.Tuple(.{
Navigator,
History,
Location,
});
};