forked from mirror/vulkan-zig
allocgate 2.0
This commit is contained in:
@@ -466,7 +466,7 @@ fn parseFnPtrSuffix(allocator: Allocator, xctok: *XmlCTokenizer, return_type: Ty
|
|||||||
}
|
}
|
||||||
|
|
||||||
_ = try xctok.nextNoEof();
|
_ = try xctok.nextNoEof();
|
||||||
command_ptr.decl_type.command_ptr.params = params.toOwnedSlice();
|
command_ptr.decl_type.command_ptr.params = try params.toOwnedSlice();
|
||||||
return command_ptr;
|
return command_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ const EnumFieldMerger = struct {
|
|||||||
|
|
||||||
// Existing base_enum.fields was allocated by `self.arena`, so
|
// Existing base_enum.fields was allocated by `self.arena`, so
|
||||||
// it gets cleaned up whenever that is deinited.
|
// it gets cleaned up whenever that is deinited.
|
||||||
base_enum.fields = self.arena.shrink(new_fields, i);
|
base_enum.fields = new_fields[0..i];
|
||||||
}
|
}
|
||||||
|
|
||||||
fn merge(self: *EnumFieldMerger) !void {
|
fn merge(self: *EnumFieldMerger) !void {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ fn parseDeclarations(allocator: Allocator, root: *xml.Element) ![]registry.Decla
|
|||||||
count += try parseTypes(allocator, decls, types_elem);
|
count += try parseTypes(allocator, decls, types_elem);
|
||||||
count += try parseEnums(allocator, decls[count..], root);
|
count += try parseEnums(allocator, decls[count..], root);
|
||||||
count += try parseCommands(allocator, decls[count..], commands_elem);
|
count += try parseCommands(allocator, decls[count..], commands_elem);
|
||||||
return allocator.shrink(decls, count);
|
return decls[0..count];
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parseTypes(allocator: Allocator, out: []registry.Declaration, types_elem: *xml.Element) !usize {
|
fn parseTypes(allocator: Allocator, out: []registry.Declaration, types_elem: *xml.Element) !usize {
|
||||||
@@ -202,7 +202,7 @@ fn parseContainer(allocator: Allocator, ty: *xml.Element, is_union: bool) !regis
|
|||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
members = allocator.shrink(members, i);
|
members = members[0..i];
|
||||||
|
|
||||||
var maybe_extends: ?[][]const u8 = null;
|
var maybe_extends: ?[][]const u8 = null;
|
||||||
if (ty.getAttribute("structextends")) |extends| {
|
if (ty.getAttribute("structextends")) |extends| {
|
||||||
@@ -370,7 +370,7 @@ fn parseEnumFields(allocator: Allocator, elem: *xml.Element) !registry.Enum {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return registry.Enum{
|
return registry.Enum{
|
||||||
.fields = allocator.shrink(fields, i),
|
.fields = fields[0..i],
|
||||||
.bitwidth = bitwidth,
|
.bitwidth = bitwidth,
|
||||||
.is_bitmask = is_bitmask,
|
.is_bitmask = is_bitmask,
|
||||||
};
|
};
|
||||||
@@ -483,7 +483,7 @@ fn parseCommand(allocator: Allocator, elem: *xml.Element) !registry.Declaration
|
|||||||
else
|
else
|
||||||
&[_][]const u8{};
|
&[_][]const u8{};
|
||||||
|
|
||||||
params = allocator.shrink(params, i);
|
params = params[0..i];
|
||||||
|
|
||||||
it = elem.findChildrenByTag("param");
|
it = elem.findChildrenByTag("param");
|
||||||
for (params) |*param| {
|
for (params) |*param| {
|
||||||
@@ -552,7 +552,7 @@ fn parseApiConstants(allocator: Allocator, root: *xml.Element) ![]registry.ApiCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
i += try parseDefines(types, constants[i..]);
|
i += try parseDefines(types, constants[i..]);
|
||||||
return allocator.shrink(constants, i);
|
return constants[0..i];
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parseDefines(types: *xml.Element, out: []registry.ApiConstant) !usize {
|
fn parseDefines(types: *xml.Element, out: []registry.ApiConstant) !usize {
|
||||||
@@ -598,7 +598,7 @@ fn parseTags(allocator: Allocator, root: *xml.Element) ![]registry.Tag {
|
|||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return allocator.shrink(tags, i);
|
return tags[0..i];
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parseFeatures(allocator: Allocator, root: *xml.Element) ![]registry.Feature {
|
fn parseFeatures(allocator: Allocator, root: *xml.Element) ![]registry.Feature {
|
||||||
@@ -635,7 +635,7 @@ fn parseFeature(allocator: Allocator, feature: *xml.Element) !registry.Feature {
|
|||||||
return registry.Feature{
|
return registry.Feature{
|
||||||
.name = name,
|
.name = name,
|
||||||
.level = feature_level,
|
.level = feature_level,
|
||||||
.requires = allocator.shrink(requires, i),
|
.requires = requires[0..i],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -738,7 +738,7 @@ fn parseRequire(allocator: Allocator, require: *xml.Element, extnumber: ?u31) !r
|
|||||||
};
|
};
|
||||||
|
|
||||||
return registry.Require{
|
return registry.Require{
|
||||||
.extends = allocator.shrink(extends, i_extends),
|
.extends = extends[0..i_extends],
|
||||||
.types = types,
|
.types = types,
|
||||||
.commands = commands,
|
.commands = commands,
|
||||||
.required_feature_level = required_feature_level,
|
.required_feature_level = required_feature_level,
|
||||||
@@ -764,7 +764,7 @@ fn parseExtensions(allocator: Allocator, root: *xml.Element) ![]registry.Extensi
|
|||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return allocator.shrink(extensions, i);
|
return extensions[0..i];
|
||||||
}
|
}
|
||||||
|
|
||||||
fn findExtVersion(extension: *xml.Element) !u32 {
|
fn findExtVersion(extension: *xml.Element) !u32 {
|
||||||
@@ -844,7 +844,7 @@ fn parseExtension(allocator: Allocator, extension: *xml.Element) !registry.Exten
|
|||||||
.promoted_to = promoted_to,
|
.promoted_to = promoted_to,
|
||||||
.platform = platform,
|
.platform = platform,
|
||||||
.required_feature_level = requires_core,
|
.required_feature_level = requires_core,
|
||||||
.requires = allocator.shrink(requires, i),
|
.requires = requires[0..i],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1305,7 +1305,7 @@ fn Renderer(comptime WriterType: type) type {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return returns.toOwnedSlice();
|
return try returns.toOwnedSlice();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn renderReturnStructName(self: *Self, command_name: []const u8) !void {
|
fn renderReturnStructName(self: *Self, command_name: []const u8) !void {
|
||||||
|
|||||||
@@ -481,8 +481,8 @@ fn parseElement(parser: *Parser, alloc: Allocator, comptime kind: ElementKind) !
|
|||||||
const element = try alloc.create(Element);
|
const element = try alloc.create(Element);
|
||||||
element.* = .{
|
element.* = .{
|
||||||
.tag = try alloc.dupe(u8, tag),
|
.tag = try alloc.dupe(u8, tag),
|
||||||
.attributes = attributes.toOwnedSlice(),
|
.attributes = try attributes.toOwnedSlice(),
|
||||||
.children = children.toOwnedSlice(),
|
.children = try children.toOwnedSlice(),
|
||||||
};
|
};
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user