mod(event): merge the declarations of the tagged unions alongside the fields
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 55s
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 55s
This commit is contained in:
@@ -54,6 +54,19 @@ pub fn mergeTaggedUnions(comptime A: type, comptime B: type) type {
|
||||
i += 1;
|
||||
}
|
||||
|
||||
const a_enum_decls = @typeInfo(A).@"union".decls;
|
||||
const b_enum_decls = @typeInfo(B).@"union".decls;
|
||||
var decls: [a_enum_decls.len + b_enum_decls.len]std.builtin.Type.Declaration = undefined;
|
||||
var j: usize = 0;
|
||||
for (a_enum_decls) |decl| {
|
||||
decls[j] = decl;
|
||||
j += 1;
|
||||
}
|
||||
for (b_enum_decls) |decl| {
|
||||
decls[j] = decl;
|
||||
j += 1;
|
||||
}
|
||||
|
||||
const log2_i = @bitSizeOf(@TypeOf(i)) - @clz(i);
|
||||
|
||||
const EventType = @Type(.{ .int = .{
|
||||
@@ -72,7 +85,7 @@ pub fn mergeTaggedUnions(comptime A: type, comptime B: type) type {
|
||||
.layout = .auto,
|
||||
.tag_type = Event,
|
||||
.fields = fields[0..],
|
||||
.decls = &.{},
|
||||
.decls = if (decls.len != 0) decls[0..] else &.{},
|
||||
} });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user