Merge pull request #179 from rpkak/allow-custom-dispatch-types

Allow custom Dispatch structs
This commit is contained in:
Robin Voetter
2025-03-31 21:27:53 +02:00
committed by GitHub

View File

@@ -1440,13 +1440,14 @@ fn Renderer(comptime WriterType: type) type {
const name = dispatch_type.name();
try self.writer.print(
\\pub const {0s}Wrapper = struct {{
\\pub const {0s}Wrapper = {0s}WrapperWithCustomDispatch({0s}Dispatch);
\\pub fn {0s}WrapperWithCustomDispatch(DispatchType: type) type {{
\\ return struct {{
\\ const Self = @This();
\\ pub const Dispatch = {0s}Dispatch;
\\ pub const Dispatch = DispatchType;
\\
\\ dispatch: Dispatch,
\\
\\
, .{name});
try self.renderWrapperLoader(dispatch_type);
@@ -1473,7 +1474,7 @@ fn Renderer(comptime WriterType: type) type {
}
}
try self.writer.writeAll("};\n");
try self.writer.writeAll("};}\n");
}
fn renderWrapperLoader(self: *Self, dispatch_type: CommandDispatchType) !void {
@@ -1520,9 +1521,11 @@ fn Renderer(comptime WriterType: type) type {
const loader_name = dispatch_type.name();
try self.writer.print(
\\pub const {0s}Proxy = struct {{
\\pub const {0s}Proxy = {0s}ProxyWithCustomDispatch({1s}Dispatch);
\\pub fn {0s}ProxyWithCustomDispatch(DispatchType: type) type {{
\\ return struct {{
\\ const Self = @This();
\\ pub const Wrapper = {1s}Wrapper;
\\ pub const Wrapper = {1s}WrapperWithCustomDispatch(DispatchType);
\\
\\ handle: {0s},
// Note: This is a pointer because in the past there were some performance
@@ -1572,7 +1575,7 @@ fn Renderer(comptime WriterType: type) type {
try self.writer.writeAll(
\\ };
\\
\\}
);
}