Replace deprecated ArrayListUnmanaged with ArrayList
std.ArrayListUnmanaged is now std.ArrayList in Zig 0.15. The old managed ArrayList is deprecated as std.array_list.Managed.
This commit is contained in:
@@ -65,7 +65,7 @@ const TemplateGenStep = struct {
|
||||
const b = step.owner;
|
||||
const allocator = b.allocator;
|
||||
|
||||
var templates = std.ArrayListUnmanaged(TemplateInfo){};
|
||||
var templates = std.ArrayList(TemplateInfo){};
|
||||
defer templates.deinit(allocator);
|
||||
try findTemplates(allocator, self.options.source_dir, "", self.options.extension, &templates);
|
||||
|
||||
@@ -86,7 +86,7 @@ fn findTemplates(
|
||||
base_dir: []const u8,
|
||||
sub_path: []const u8,
|
||||
extension: []const u8,
|
||||
templates: *std.ArrayListUnmanaged(TemplateInfo),
|
||||
templates: *std.ArrayList(TemplateInfo),
|
||||
) !void {
|
||||
const full_path = if (sub_path.len > 0)
|
||||
try std.fs.path.join(allocator, &.{ base_dir, sub_path })
|
||||
@@ -144,7 +144,7 @@ fn generateSingleFile(
|
||||
out_path: []const u8,
|
||||
templates: []const TemplateInfo,
|
||||
) !void {
|
||||
var out = std.ArrayListUnmanaged(u8){};
|
||||
var out = std.ArrayList(u8){};
|
||||
defer out.deinit(allocator);
|
||||
|
||||
const w = out.writer(allocator);
|
||||
@@ -255,7 +255,7 @@ fn generateSingleFile(
|
||||
|
||||
fn compileTemplate(
|
||||
allocator: std.mem.Allocator,
|
||||
w: std.ArrayListUnmanaged(u8).Writer,
|
||||
w: std.ArrayList(u8).Writer,
|
||||
name: []const u8,
|
||||
source: []const u8,
|
||||
) !void {
|
||||
@@ -381,12 +381,12 @@ fn nodeHasDynamic(node: ast.Node) bool {
|
||||
|
||||
const Compiler = struct {
|
||||
allocator: std.mem.Allocator,
|
||||
writer: std.ArrayListUnmanaged(u8).Writer,
|
||||
buf: std.ArrayListUnmanaged(u8), // Buffer for merging static strings
|
||||
writer: std.ArrayList(u8).Writer,
|
||||
buf: std.ArrayList(u8), // Buffer for merging static strings
|
||||
depth: usize,
|
||||
loop_vars: std.ArrayListUnmanaged([]const u8), // Track loop variable names
|
||||
loop_vars: std.ArrayList([]const u8), // Track loop variable names
|
||||
|
||||
fn init(allocator: std.mem.Allocator, writer: std.ArrayListUnmanaged(u8).Writer) Compiler {
|
||||
fn init(allocator: std.mem.Allocator, writer: std.ArrayList(u8).Writer) Compiler {
|
||||
return .{
|
||||
.allocator = allocator,
|
||||
.writer = writer,
|
||||
|
||||
@@ -55,7 +55,7 @@ const whitespace_sensitive = std.StaticStringMap(void).initComptime(.{
|
||||
pub const CodeGen = struct {
|
||||
allocator: std.mem.Allocator,
|
||||
options: Options,
|
||||
output: std.ArrayListUnmanaged(u8),
|
||||
output: std.ArrayList(u8),
|
||||
depth: usize,
|
||||
/// Track if we're inside a whitespace-sensitive element.
|
||||
preserve_whitespace: bool,
|
||||
|
||||
@@ -29,7 +29,7 @@ pub fn compileDoc(allocator: std.mem.Allocator, name: []const u8, doc: ast.Docum
|
||||
|
||||
const Compiler = struct {
|
||||
alloc: std.mem.Allocator,
|
||||
out: std.ArrayListUnmanaged(u8),
|
||||
out: std.ArrayList(u8),
|
||||
depth: u8,
|
||||
|
||||
fn init(allocator: std.mem.Allocator) Compiler {
|
||||
|
||||
@@ -128,8 +128,8 @@ pub const Lexer = struct {
|
||||
pos: usize,
|
||||
line: usize,
|
||||
column: usize,
|
||||
indent_stack: std.ArrayListUnmanaged(usize),
|
||||
tokens: std.ArrayListUnmanaged(Token),
|
||||
indent_stack: std.ArrayList(usize),
|
||||
tokens: std.ArrayList(Token),
|
||||
allocator: std.mem.Allocator,
|
||||
at_line_start: bool,
|
||||
current_indent: usize,
|
||||
|
||||
@@ -54,7 +54,7 @@ pub const Parser = struct {
|
||||
|
||||
/// Parses all tokens and returns the document AST.
|
||||
pub fn parse(self: *Parser) Error!ast.Document {
|
||||
var nodes = std.ArrayListUnmanaged(Node).empty;
|
||||
var nodes = std.ArrayList(Node).empty;
|
||||
errdefer nodes.deinit(self.allocator);
|
||||
|
||||
var extends_path: ?[]const u8 = null;
|
||||
@@ -122,9 +122,9 @@ pub const Parser = struct {
|
||||
/// Parses an HTML element with optional tag, classes, id, attributes, and children.
|
||||
fn parseElement(self: *Parser) Error!Node {
|
||||
var tag: []const u8 = "div"; // default tag
|
||||
var classes = std.ArrayListUnmanaged([]const u8).empty;
|
||||
var classes = std.ArrayList([]const u8).empty;
|
||||
var id: ?[]const u8 = null;
|
||||
var attributes = std.ArrayListUnmanaged(Attribute).empty;
|
||||
var attributes = std.ArrayList(Attribute).empty;
|
||||
var spread_attributes: ?[]const u8 = null;
|
||||
var self_closing = false;
|
||||
|
||||
@@ -174,7 +174,7 @@ pub const Parser = struct {
|
||||
self.skipWhitespace();
|
||||
|
||||
// Parse the inline nested element
|
||||
var children = std.ArrayListUnmanaged(Node).empty;
|
||||
var children = std.ArrayList(Node).empty;
|
||||
errdefer children.deinit(self.allocator);
|
||||
|
||||
if (try self.parseNode()) |child| {
|
||||
@@ -223,7 +223,7 @@ pub const Parser = struct {
|
||||
_ = self.advance();
|
||||
const raw_content = try self.parseRawTextBlock();
|
||||
|
||||
var children = std.ArrayListUnmanaged(Node).empty;
|
||||
var children = std.ArrayList(Node).empty;
|
||||
errdefer children.deinit(self.allocator);
|
||||
try children.append(self.allocator, .{ .raw_text = .{ .content = raw_content } });
|
||||
|
||||
@@ -245,7 +245,7 @@ pub const Parser = struct {
|
||||
self.skipNewlines();
|
||||
|
||||
// Parse children if indented
|
||||
var children = std.ArrayListUnmanaged(Node).empty;
|
||||
var children = std.ArrayList(Node).empty;
|
||||
errdefer children.deinit(self.allocator);
|
||||
|
||||
if (self.check(.indent)) {
|
||||
@@ -267,7 +267,7 @@ pub const Parser = struct {
|
||||
}
|
||||
|
||||
/// Parses attributes within parentheses.
|
||||
fn parseAttributes(self: *Parser, attributes: *std.ArrayListUnmanaged(Attribute)) Error!void {
|
||||
fn parseAttributes(self: *Parser, attributes: *std.ArrayList(Attribute)) Error!void {
|
||||
while (!self.check(.rparen) and !self.isAtEnd()) {
|
||||
// Skip commas
|
||||
if (self.check(.comma)) {
|
||||
@@ -302,7 +302,7 @@ pub const Parser = struct {
|
||||
|
||||
/// Parses text segments (literals and interpolations).
|
||||
fn parseTextSegments(self: *Parser) Error![]TextSegment {
|
||||
var segments = std.ArrayListUnmanaged(TextSegment).empty;
|
||||
var segments = std.ArrayList(TextSegment).empty;
|
||||
errdefer segments.deinit(self.allocator);
|
||||
|
||||
while (self.check(.text) or self.check(.interp_start) or self.check(.interp_start_unesc) or self.check(.tag_interp_start)) {
|
||||
@@ -338,9 +338,9 @@ pub const Parser = struct {
|
||||
_ = self.advance(); // skip #[
|
||||
|
||||
var tag: []const u8 = "span"; // default tag
|
||||
var classes = std.ArrayListUnmanaged([]const u8).empty;
|
||||
var classes = std.ArrayList([]const u8).empty;
|
||||
var id: ?[]const u8 = null;
|
||||
var attributes = std.ArrayListUnmanaged(Attribute).empty;
|
||||
var attributes = std.ArrayList(Attribute).empty;
|
||||
|
||||
errdefer classes.deinit(self.allocator);
|
||||
errdefer attributes.deinit(self.allocator);
|
||||
@@ -369,7 +369,7 @@ pub const Parser = struct {
|
||||
}
|
||||
|
||||
// Parse inner text segments (may contain nested interpolations)
|
||||
var text_segments = std.ArrayListUnmanaged(TextSegment).empty;
|
||||
var text_segments = std.ArrayList(TextSegment).empty;
|
||||
errdefer text_segments.deinit(self.allocator);
|
||||
|
||||
while (!self.check(.tag_interp_end) and !self.check(.newline) and !self.isAtEnd()) {
|
||||
@@ -415,7 +415,7 @@ pub const Parser = struct {
|
||||
}
|
||||
|
||||
/// Parses children within an indented block.
|
||||
fn parseChildren(self: *Parser, children: *std.ArrayListUnmanaged(Node)) Error!void {
|
||||
fn parseChildren(self: *Parser, children: *std.ArrayList(Node)) Error!void {
|
||||
while (!self.check(.dedent) and !self.isAtEnd()) {
|
||||
self.skipNewlines();
|
||||
if (self.check(.dedent) or self.isAtEnd()) break;
|
||||
@@ -433,7 +433,7 @@ pub const Parser = struct {
|
||||
|
||||
/// Parses a raw text block (after `.`).
|
||||
fn parseRawTextBlock(self: *Parser) Error![]const u8 {
|
||||
var lines = std.ArrayListUnmanaged(u8).empty;
|
||||
var lines = std.ArrayList(u8).empty;
|
||||
errdefer lines.deinit(self.allocator);
|
||||
|
||||
while (!self.check(.dedent) and !self.isAtEnd()) {
|
||||
@@ -470,7 +470,7 @@ pub const Parser = struct {
|
||||
|
||||
/// Parses conditional (if/else if/else/unless).
|
||||
fn parseConditional(self: *Parser) Error!Node {
|
||||
var branches = std.ArrayListUnmanaged(ast.Conditional.Branch).empty;
|
||||
var branches = std.ArrayList(ast.Conditional.Branch).empty;
|
||||
errdefer branches.deinit(self.allocator);
|
||||
|
||||
// Parse initial if/unless
|
||||
@@ -483,7 +483,7 @@ pub const Parser = struct {
|
||||
self.skipNewlines();
|
||||
|
||||
// Parse body
|
||||
var body = std.ArrayListUnmanaged(Node).empty;
|
||||
var body = std.ArrayList(Node).empty;
|
||||
errdefer body.deinit(self.allocator);
|
||||
|
||||
if (self.check(.indent)) {
|
||||
@@ -512,7 +512,7 @@ pub const Parser = struct {
|
||||
|
||||
self.skipNewlines();
|
||||
|
||||
var else_body = std.ArrayListUnmanaged(Node).empty;
|
||||
var else_body = std.ArrayList(Node).empty;
|
||||
errdefer else_body.deinit(self.allocator);
|
||||
|
||||
if (self.check(.indent)) {
|
||||
@@ -590,7 +590,7 @@ pub const Parser = struct {
|
||||
self.skipNewlines();
|
||||
|
||||
// Parse body
|
||||
var body = std.ArrayListUnmanaged(Node).empty;
|
||||
var body = std.ArrayList(Node).empty;
|
||||
errdefer body.deinit(self.allocator);
|
||||
|
||||
if (self.check(.indent)) {
|
||||
@@ -599,7 +599,7 @@ pub const Parser = struct {
|
||||
}
|
||||
|
||||
// Check for else branch
|
||||
var else_children = std.ArrayListUnmanaged(Node).empty;
|
||||
var else_children = std.ArrayList(Node).empty;
|
||||
errdefer else_children.deinit(self.allocator);
|
||||
|
||||
if (self.check(.kw_else)) {
|
||||
@@ -629,7 +629,7 @@ pub const Parser = struct {
|
||||
|
||||
self.skipNewlines();
|
||||
|
||||
var body = std.ArrayListUnmanaged(Node).empty;
|
||||
var body = std.ArrayList(Node).empty;
|
||||
errdefer body.deinit(self.allocator);
|
||||
|
||||
if (self.check(.indent)) {
|
||||
@@ -651,10 +651,10 @@ pub const Parser = struct {
|
||||
|
||||
self.skipNewlines();
|
||||
|
||||
var whens = std.ArrayListUnmanaged(ast.Case.When).empty;
|
||||
var whens = std.ArrayList(ast.Case.When).empty;
|
||||
errdefer whens.deinit(self.allocator);
|
||||
|
||||
var default_children = std.ArrayListUnmanaged(Node).empty;
|
||||
var default_children = std.ArrayList(Node).empty;
|
||||
errdefer default_children.deinit(self.allocator);
|
||||
|
||||
// Parse indented when/default clauses
|
||||
@@ -675,7 +675,7 @@ pub const Parser = struct {
|
||||
value = try self.parseRestOfLine();
|
||||
}
|
||||
|
||||
var when_children = std.ArrayListUnmanaged(Node).empty;
|
||||
var when_children = std.ArrayList(Node).empty;
|
||||
errdefer when_children.deinit(self.allocator);
|
||||
var has_break = false;
|
||||
|
||||
@@ -778,8 +778,8 @@ pub const Parser = struct {
|
||||
}
|
||||
|
||||
// Parse parameters if present
|
||||
var params = std.ArrayListUnmanaged([]const u8).empty;
|
||||
var defaults = std.ArrayListUnmanaged(?[]const u8).empty;
|
||||
var params = std.ArrayList([]const u8).empty;
|
||||
var defaults = std.ArrayList(?[]const u8).empty;
|
||||
errdefer params.deinit(self.allocator);
|
||||
errdefer defaults.deinit(self.allocator);
|
||||
|
||||
@@ -830,7 +830,7 @@ pub const Parser = struct {
|
||||
self.skipNewlines();
|
||||
|
||||
// Parse body
|
||||
var body = std.ArrayListUnmanaged(Node).empty;
|
||||
var body = std.ArrayList(Node).empty;
|
||||
errdefer body.deinit(self.allocator);
|
||||
|
||||
if (self.check(.indent)) {
|
||||
@@ -851,8 +851,8 @@ pub const Parser = struct {
|
||||
fn parseMixinCall(self: *Parser) Error!Node {
|
||||
const name = self.advance().value; // +name
|
||||
|
||||
var args = std.ArrayListUnmanaged([]const u8).empty;
|
||||
var attributes = std.ArrayListUnmanaged(Attribute).empty;
|
||||
var args = std.ArrayList([]const u8).empty;
|
||||
var attributes = std.ArrayList(Attribute).empty;
|
||||
errdefer args.deinit(self.allocator);
|
||||
errdefer attributes.deinit(self.allocator);
|
||||
|
||||
@@ -894,7 +894,7 @@ pub const Parser = struct {
|
||||
self.skipNewlines();
|
||||
|
||||
// Parse block content
|
||||
var block_children = std.ArrayListUnmanaged(Node).empty;
|
||||
var block_children = std.ArrayList(Node).empty;
|
||||
errdefer block_children.deinit(self.allocator);
|
||||
|
||||
if (self.check(.indent)) {
|
||||
@@ -979,7 +979,7 @@ pub const Parser = struct {
|
||||
self.skipNewlines();
|
||||
|
||||
// Parse body
|
||||
var body = std.ArrayListUnmanaged(Node).empty;
|
||||
var body = std.ArrayList(Node).empty;
|
||||
errdefer body.deinit(self.allocator);
|
||||
|
||||
if (self.check(.indent)) {
|
||||
@@ -1011,7 +1011,7 @@ pub const Parser = struct {
|
||||
self.skipNewlines();
|
||||
|
||||
// Parse body
|
||||
var body = std.ArrayListUnmanaged(Node).empty;
|
||||
var body = std.ArrayList(Node).empty;
|
||||
errdefer body.deinit(self.allocator);
|
||||
|
||||
if (self.check(.indent)) {
|
||||
@@ -1052,7 +1052,7 @@ pub const Parser = struct {
|
||||
self.skipNewlines();
|
||||
|
||||
// Parse nested comment content
|
||||
var children = std.ArrayListUnmanaged(Node).empty;
|
||||
var children = std.ArrayList(Node).empty;
|
||||
errdefer children.deinit(self.allocator);
|
||||
|
||||
if (self.check(.indent)) {
|
||||
@@ -1091,7 +1091,7 @@ pub const Parser = struct {
|
||||
|
||||
/// Parses rest of line as text.
|
||||
fn parseRestOfLine(self: *Parser) Error![]const u8 {
|
||||
var result = std.ArrayListUnmanaged(u8).empty;
|
||||
var result = std.ArrayList(u8).empty;
|
||||
errdefer result.deinit(self.allocator);
|
||||
|
||||
while (!self.check(.newline) and !self.check(.indent) and !self.check(.dedent) and !self.isAtEnd()) {
|
||||
|
||||
@@ -128,7 +128,7 @@ pub const Context = struct {
|
||||
allocator: std.mem.Allocator,
|
||||
/// Stack of variable scopes (innermost last).
|
||||
/// We keep all scopes allocated and track active depth with scope_depth.
|
||||
scopes: std.ArrayListUnmanaged(std.StringHashMapUnmanaged(Value)),
|
||||
scopes: std.ArrayList(std.StringHashMapUnmanaged(Value)),
|
||||
/// Current active scope depth (scopes[0..scope_depth] are active).
|
||||
scope_depth: usize,
|
||||
/// Mixin definitions available in this context.
|
||||
@@ -242,7 +242,7 @@ const BlockDef = struct {
|
||||
pub const Runtime = struct {
|
||||
allocator: std.mem.Allocator,
|
||||
context: *Context,
|
||||
output: std.ArrayListUnmanaged(u8),
|
||||
output: std.ArrayList(u8),
|
||||
depth: usize,
|
||||
options: Options,
|
||||
/// File resolver for loading external templates.
|
||||
@@ -431,7 +431,7 @@ pub const Runtime = struct {
|
||||
}
|
||||
|
||||
// Collect all classes: shorthand classes + class attributes (may be arrays)
|
||||
var all_classes = std.ArrayListUnmanaged(u8).empty;
|
||||
var all_classes = std.ArrayList(u8).empty;
|
||||
defer all_classes.deinit(self.allocator);
|
||||
|
||||
// Add shorthand classes first (e.g., .bang)
|
||||
@@ -1580,7 +1580,7 @@ fn parseArrayToSpaceSeparated(allocator: std.mem.Allocator, input: []const u8) !
|
||||
const content = std.mem.trim(u8, trimmed[1 .. trimmed.len - 1], " \t\n\r");
|
||||
if (content.len == 0) return "";
|
||||
|
||||
var result = std.ArrayListUnmanaged(u8).empty;
|
||||
var result = std.ArrayList(u8).empty;
|
||||
errdefer result.deinit(allocator);
|
||||
|
||||
var pos: usize = 0;
|
||||
@@ -1643,7 +1643,7 @@ fn parseObjectToCSS(allocator: std.mem.Allocator, input: []const u8) ![]const u8
|
||||
const content = std.mem.trim(u8, trimmed[1 .. trimmed.len - 1], " \t\n\r");
|
||||
if (content.len == 0) return "";
|
||||
|
||||
var result = std.ArrayListUnmanaged(u8).empty;
|
||||
var result = std.ArrayList(u8).empty;
|
||||
errdefer result.deinit(allocator);
|
||||
|
||||
var pos: usize = 0;
|
||||
|
||||
Reference in New Issue
Block a user