diff --git a/generator/main.zig b/generator/main.zig index 24f7342..7ca9df0 100644 --- a/generator/main.zig +++ b/generator/main.zig @@ -1,6 +1,6 @@ const std = @import("std"); const xml = @import("xml.zig"); -const reg = @import("registry.zig"); +const Registry = @import("registry.zig").Registry; pub fn main() !void { if (std.os.argv.len <= 1) { @@ -20,7 +20,7 @@ pub fn main() !void { const spec = try xml.parse(std.heap.page_allocator, source); 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(); registry.dump(); @@ -28,5 +28,4 @@ pub fn main() !void { test "main" { _ = @import("xml.zig"); - _ = @import("registry.zig"); } diff --git a/generator/registry.zig b/generator/registry.zig index 8087f98..aebd713 100644 --- a/generator/registry.zig +++ b/generator/registry.zig @@ -38,6 +38,20 @@ pub const Registry = struct { 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 { 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 { var types = root.findChildByTag("types").?; var it = types.findChildrenByTag("type");