forked from mirror/vulkan-zig
Add Khronos license information to generated bindings
This commit is contained in:
@@ -24,6 +24,7 @@ pub fn parseXml(backing_allocator: *Allocator, root: *xml.Element) !ParseResult
|
||||
const allocator = &arena.allocator;
|
||||
|
||||
var reg = registry.Registry{
|
||||
.copyright = root.getCharData("comment") orelse return error.InvalidRegistry,
|
||||
.decls = try parseDeclarations(allocator, root),
|
||||
.api_constants = try parseApiConstants(allocator, root),
|
||||
.tags = try parseTags(allocator, root),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
pub const Registry = struct {
|
||||
copyright: []const u8,
|
||||
decls: []Declaration,
|
||||
api_constants: []ApiConstant,
|
||||
tags: []Tag,
|
||||
|
||||
@@ -6,6 +6,9 @@ const mem = std.mem;
|
||||
const Allocator = mem.Allocator;
|
||||
|
||||
const preamble =
|
||||
\\
|
||||
\\// This file is generated from the Khronos Vulkan XML API Registry
|
||||
\\
|
||||
\\const std = @import("std");
|
||||
\\const builtin = @import("builtin");
|
||||
\\const root = @import("root");
|
||||
@@ -294,6 +297,7 @@ fn Renderer(comptime WriterType: type) type {
|
||||
}
|
||||
|
||||
fn render(self: *Self) !void {
|
||||
try self.renderCopyright();
|
||||
try self.writer.writeAll(preamble);
|
||||
|
||||
for (self.registry.api_constants) |api_constant| {
|
||||
@@ -309,6 +313,13 @@ fn Renderer(comptime WriterType: type) type {
|
||||
try self.renderWrappers();
|
||||
}
|
||||
|
||||
fn renderCopyright(self: *Self) !void {
|
||||
var it = mem.split(self.registry.copyright, "\n");
|
||||
while (it.next()) |line| {
|
||||
try self.writer.print("// {}\n", .{line});
|
||||
}
|
||||
}
|
||||
|
||||
fn renderApiConstant(self: *Self, api_constant: reg.ApiConstant) !void {
|
||||
try self.writer.writeAll("pub const ");
|
||||
try self.renderName(api_constant.name);
|
||||
|
||||
Reference in New Issue
Block a user