Update std.mem.split usage to new API

This commit is contained in:
Robin Voetter
2021-08-14 01:07:08 +02:00
parent 89e16f69a8
commit 07e530719b
2 changed files with 6 additions and 6 deletions

View File

@@ -209,7 +209,7 @@ fn parseContainer(allocator: *Allocator, ty: *xml.Element, is_union: bool) !regi
if (ty.getAttribute("structextends")) |extends| { if (ty.getAttribute("structextends")) |extends| {
const n_structs = std.mem.count(u8, extends, ",") + 1; const n_structs = std.mem.count(u8, extends, ",") + 1;
maybe_extends = try allocator.alloc([]const u8, n_structs); maybe_extends = try allocator.alloc([]const u8, n_structs);
var struct_extends = std.mem.split(extends, ","); var struct_extends = std.mem.split(u8, extends, ",");
var j: usize = 0; var j: usize = 0;
while (struct_extends.next()) |struct_extend| { while (struct_extends.next()) |struct_extend| {
maybe_extends.?[j] = struct_extend; maybe_extends.?[j] = struct_extend;
@@ -278,7 +278,7 @@ fn lenToPointerSize(fields: Fields, len: []const u8) registry.Pointer.PointerSiz
fn parsePointerMeta(fields: Fields, type_info: *registry.TypeInfo, elem: *xml.Element) !void { fn parsePointerMeta(fields: Fields, type_info: *registry.TypeInfo, elem: *xml.Element) !void {
if (elem.getAttribute("len")) |lens| { if (elem.getAttribute("len")) |lens| {
var it = mem.split(lens, ","); var it = mem.split(u8, lens, ",");
var current_type_info = type_info; var current_type_info = type_info;
while (current_type_info.* == .pointer) { while (current_type_info.* == .pointer) {
// TODO: Check altlen // TODO: Check altlen
@@ -295,7 +295,7 @@ fn parsePointerMeta(fields: Fields, type_info: *registry.TypeInfo, elem: *xml.El
} }
if (elem.getAttribute("optional")) |optionals| { if (elem.getAttribute("optional")) |optionals| {
var it = mem.split(optionals, ","); var it = mem.split(u8, optionals, ",");
var current_type_info = type_info; var current_type_info = type_info;
while (current_type_info.* == .pointer) { while (current_type_info.* == .pointer) {
if (it.next()) |current_optional| { if (it.next()) |current_optional| {
@@ -428,7 +428,7 @@ fn splitCommaAlloc(allocator: *Allocator, text: []const u8) ![][]const u8 {
} }
const codes = try allocator.alloc([]const u8, n_codes); const codes = try allocator.alloc([]const u8, n_codes);
var it = mem.split(text, ","); var it = mem.split(u8, text, ",");
for (codes) |*code| { for (codes) |*code| {
code.* = it.next().?; code.* = it.next().?;
} }
@@ -845,7 +845,7 @@ fn parseExtension(allocator: *Allocator, extension: *xml.Element) !registry.Exte
} }
fn splitFeatureLevel(ver: []const u8, split: []const u8) !registry.FeatureLevel { fn splitFeatureLevel(ver: []const u8, split: []const u8) !registry.FeatureLevel {
var it = mem.split(ver, split); var it = mem.split(u8, ver, split);
const major = it.next() orelse return error.InvalidFeatureLevel; const major = it.next() orelse return error.InvalidFeatureLevel;
const minor = it.next() orelse return error.InvalidFeatureLevel; const minor = it.next() orelse return error.InvalidFeatureLevel;

View File

@@ -456,7 +456,7 @@ fn Renderer(comptime WriterType: type) type {
} }
fn renderCopyright(self: *Self) !void { fn renderCopyright(self: *Self) !void {
var it = mem.split(self.registry.copyright, "\n"); var it = mem.split(u8, self.registry.copyright, "\n");
while (it.next()) |line| { while (it.next()) |line| {
try self.writer.print("// {s}\n", .{line}); try self.writer.print("// {s}\n", .{line});
} }