forked from mirror/vulkan-zig
Make registry generation a member function
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const xml = @import("xml.zig");
|
const xml = @import("xml.zig");
|
||||||
const reg = @import("registry.zig");
|
const Registry = @import("registry.zig").Registry;
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
if (std.os.argv.len <= 1) {
|
if (std.os.argv.len <= 1) {
|
||||||
@@ -20,7 +20,7 @@ pub fn main() !void {
|
|||||||
const spec = try xml.parse(std.heap.page_allocator, source);
|
const spec = try xml.parse(std.heap.page_allocator, source);
|
||||||
defer spec.deinit();
|
defer spec.deinit();
|
||||||
|
|
||||||
const registry = reg.generate(std.heap.page_allocator, spec.root);
|
const registry = Registry.fromXml(std.heap.page_allocator, spec.root);
|
||||||
defer registry.deinit();
|
defer registry.deinit();
|
||||||
|
|
||||||
registry.dump();
|
registry.dump();
|
||||||
@@ -28,5 +28,4 @@ pub fn main() !void {
|
|||||||
|
|
||||||
test "main" {
|
test "main" {
|
||||||
_ = @import("xml.zig");
|
_ = @import("xml.zig");
|
||||||
_ = @import("registry.zig");
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,20 @@ pub const Registry = struct {
|
|||||||
return registry;
|
return registry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn fromXml(allocator: *Allocator, root: *xml.Element) *Registry {
|
||||||
|
std.debug.assert(mem.eql(u8, root.tag, "registry"));
|
||||||
|
|
||||||
|
var registry = Registry.init(allocator) catch unreachable;
|
||||||
|
|
||||||
|
processTypes(registry, root);
|
||||||
|
processEnums(registry, root);
|
||||||
|
processCommands(registry, root);
|
||||||
|
processFeatures(registry, root);
|
||||||
|
processExtensions(registry, root);
|
||||||
|
|
||||||
|
return registry;
|
||||||
|
}
|
||||||
|
|
||||||
fn deinit(self: Registry) void {
|
fn deinit(self: Registry) void {
|
||||||
self.declarations_by_name.deinit();
|
self.declarations_by_name.deinit();
|
||||||
|
|
||||||
@@ -517,20 +531,6 @@ const EnumInfo = struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn generate(backing_allocator: *Allocator, root: *xml.Element) *Registry {
|
|
||||||
std.debug.assert(mem.eql(u8, root.tag, "registry"));
|
|
||||||
|
|
||||||
var registry = Registry.init(backing_allocator) catch unreachable;
|
|
||||||
|
|
||||||
processTypes(registry, root);
|
|
||||||
processEnums(registry, root);
|
|
||||||
processCommands(registry, root);
|
|
||||||
processFeatures(registry, root);
|
|
||||||
processExtensions(registry, root);
|
|
||||||
|
|
||||||
return registry;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn processTypes(registry: *Registry, root: *xml.Element) void {
|
fn processTypes(registry: *Registry, root: *xml.Element) void {
|
||||||
var types = root.findChildByTag("types").?;
|
var types = root.findChildByTag("types").?;
|
||||||
var it = types.findChildrenByTag("type");
|
var it = types.findChildrenByTag("type");
|
||||||
|
|||||||
Reference in New Issue
Block a user