forked from mirror/vulkan-zig
Make SPIR-V registry parse-able by std.json.parse
This commit is contained in:
14
generator/spirv/generator.zig
Normal file
14
generator/spirv/generator.zig
Normal file
@@ -0,0 +1,14 @@
|
||||
const std = @import("std");
|
||||
const reg = @import("registry.zig");
|
||||
const Allocator = std.mem.Allocator;
|
||||
|
||||
pub fn generate(allocator: *Allocator, spec_jsons: []const []const u8, writer: anytype) !void {
|
||||
var arena = std.heap.ArenaAllocator.init(allocator);
|
||||
defer arena.deinit();
|
||||
|
||||
const registries = try arena.allocator.alloc(reg.Registry, spec_jsons.len);
|
||||
for (registries) |*registry, i| {
|
||||
var tokens = std.json.TokenStream.init(spec_jsons[i]);
|
||||
registry.* = try std.json.parse(reg.Registry, &tokens, .{.allocator = &arena.allocator});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user