mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
std.io.Writer.Allocating: rename getWritten() to written()
This "get" is useless noise and was copied from FixedBufferWriter. Since this API has not yet landed in a release, now is a good time to make the breaking change to fix this.
This commit is contained in:
parent
7abd62800c
commit
b8124d9c0b
25 changed files with 202 additions and 202 deletions
|
|
@ -443,7 +443,7 @@ fn parse(file_name: []const u8, source: []u8) Oom!Ast {
|
||||||
error.WriteFailed => return error.OutOfMemory,
|
error.WriteFailed => return error.OutOfMemory,
|
||||||
};
|
};
|
||||||
log.err("{s}:{d}:{d}: {s}", .{
|
log.err("{s}:{d}:{d}: {s}", .{
|
||||||
file_name, err_loc.line + 1, err_loc.column + 1, rendered_err.getWritten(),
|
file_name, err_loc.line + 1, err_loc.column + 1, rendered_err.written(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return Ast.parse(gpa, "", .zig);
|
return Ast.parse(gpa, "", .zig);
|
||||||
|
|
|
||||||
|
|
@ -239,7 +239,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const output = aw.getWritten();
|
const output = aw.written();
|
||||||
man.hash.addBytes(output);
|
man.hash.addBytes(output);
|
||||||
|
|
||||||
if (try step.cacheHit(&man)) {
|
if (try step.cacheHit(&man)) {
|
||||||
|
|
@ -347,10 +347,10 @@ fn render_autoconf_at(
|
||||||
while (line_it.next()) |line| : (line_index += 1) {
|
while (line_it.next()) |line| : (line_index += 1) {
|
||||||
const last_line = line_it.index == line_it.buffer.len;
|
const last_line = line_it.index == line_it.buffer.len;
|
||||||
|
|
||||||
const old_len = aw.getWritten().len;
|
const old_len = aw.written().len;
|
||||||
expand_variables_autoconf_at(bw, line, values, used) catch |err| switch (err) {
|
expand_variables_autoconf_at(bw, line, values, used) catch |err| switch (err) {
|
||||||
error.MissingValue => {
|
error.MissingValue => {
|
||||||
const name = aw.getWritten()[old_len..];
|
const name = aw.written()[old_len..];
|
||||||
defer aw.shrinkRetainingCapacity(old_len);
|
defer aw.shrinkRetainingCapacity(old_len);
|
||||||
try step.addError("{s}:{d}: error: unspecified config header value: '{s}'", .{
|
try step.addError("{s}:{d}: error: unspecified config header value: '{s}'", .{
|
||||||
src_path, line_index + 1, name,
|
src_path, line_index + 1, name,
|
||||||
|
|
@ -763,7 +763,7 @@ fn testReplaceVariablesAutoconfAt(
|
||||||
try expand_variables_autoconf_at(&aw.writer, contents, values, used);
|
try expand_variables_autoconf_at(&aw.writer, contents, values, used);
|
||||||
|
|
||||||
for (used) |u| if (!u) return error.UnusedValue;
|
for (used) |u| if (!u) return error.UnusedValue;
|
||||||
try std.testing.expectEqualStrings(expected, aw.getWritten());
|
try std.testing.expectEqualStrings(expected, aw.written());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn testReplaceVariablesCMake(
|
fn testReplaceVariablesCMake(
|
||||||
|
|
|
||||||
|
|
@ -2557,7 +2557,7 @@ pub const Allocating = struct {
|
||||||
return list.toOwnedSliceSentinel(gpa, sentinel);
|
return list.toOwnedSliceSentinel(gpa, sentinel);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getWritten(a: *Allocating) []u8 {
|
pub fn written(a: *Allocating) []u8 {
|
||||||
return a.writer.buffered();
|
return a.writer.buffered();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2624,7 +2624,7 @@ pub const Allocating = struct {
|
||||||
const y: i32 = 1234;
|
const y: i32 = 1234;
|
||||||
try w.print("x: {}\ny: {}\n", .{ x, y });
|
try w.print("x: {}\ny: {}\n", .{ x, y });
|
||||||
|
|
||||||
try testing.expectEqualSlices(u8, "x: 42\ny: 1234\n", a.getWritten());
|
try testing.expectEqualSlices(u8, "x: 42\ny: 1234\n", a.written());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1272,5 +1272,5 @@ fn testDecompress(container: Container, compressed: []const u8, expected_plain:
|
||||||
var decompress: Decompress = .init(&in, container, &.{});
|
var decompress: Decompress = .init(&in, container, &.{});
|
||||||
const decompressed_len = try decompress.reader.streamRemaining(&aw.writer);
|
const decompressed_len = try decompress.reader.streamRemaining(&aw.writer);
|
||||||
try testing.expectEqual(expected_plain.len, decompressed_len);
|
try testing.expectEqual(expected_plain.len, decompressed_len);
|
||||||
try testing.expectEqualSlices(u8, expected_plain, aw.getWritten());
|
try testing.expectEqualSlices(u8, expected_plain, aw.written());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -318,7 +318,7 @@ test dumpHexFallible {
|
||||||
@sizeOf(usize) * 2,
|
@sizeOf(usize) * 2,
|
||||||
});
|
});
|
||||||
defer std.testing.allocator.free(expected);
|
defer std.testing.allocator.free(expected);
|
||||||
try std.testing.expectEqualStrings(expected, aw.getWritten());
|
try std.testing.expectEqualStrings(expected, aw.written());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tries to print the current stack trace to stderr, unbuffered, and ignores any error returned.
|
/// Tries to print the current stack trace to stderr, unbuffered, and ignores any error returned.
|
||||||
|
|
@ -1258,7 +1258,7 @@ test printLineFromFileAnyOs {
|
||||||
try expectError(error.EndOfFile, printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 2, .column = 0 }));
|
try expectError(error.EndOfFile, printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 2, .column = 0 }));
|
||||||
|
|
||||||
try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 1, .column = 0 });
|
try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 1, .column = 0 });
|
||||||
try expectEqualStrings("no new lines in this file, but one is printed anyway\n", aw.getWritten());
|
try expectEqualStrings("no new lines in this file, but one is printed anyway\n", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
@ -1274,11 +1274,11 @@ test printLineFromFileAnyOs {
|
||||||
});
|
});
|
||||||
|
|
||||||
try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 1, .column = 0 });
|
try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 1, .column = 0 });
|
||||||
try expectEqualStrings("1\n", aw.getWritten());
|
try expectEqualStrings("1\n", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 3, .column = 0 });
|
try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 3, .column = 0 });
|
||||||
try expectEqualStrings("3\n", aw.getWritten());
|
try expectEqualStrings("3\n", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
@ -1297,7 +1297,7 @@ test printLineFromFileAnyOs {
|
||||||
try writer.flush();
|
try writer.flush();
|
||||||
|
|
||||||
try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 2, .column = 0 });
|
try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 2, .column = 0 });
|
||||||
try expectEqualStrings(("a" ** overlap) ++ "\n", aw.getWritten());
|
try expectEqualStrings(("a" ** overlap) ++ "\n", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
@ -1311,7 +1311,7 @@ test printLineFromFileAnyOs {
|
||||||
try writer.splatByteAll('a', std.heap.page_size_max);
|
try writer.splatByteAll('a', std.heap.page_size_max);
|
||||||
|
|
||||||
try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 1, .column = 0 });
|
try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 1, .column = 0 });
|
||||||
try expectEqualStrings(("a" ** std.heap.page_size_max) ++ "\n", aw.getWritten());
|
try expectEqualStrings(("a" ** std.heap.page_size_max) ++ "\n", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
@ -1327,17 +1327,17 @@ test printLineFromFileAnyOs {
|
||||||
try expectError(error.EndOfFile, printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 2, .column = 0 }));
|
try expectError(error.EndOfFile, printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 2, .column = 0 }));
|
||||||
|
|
||||||
try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 1, .column = 0 });
|
try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 1, .column = 0 });
|
||||||
try expectEqualStrings(("a" ** (3 * std.heap.page_size_max)) ++ "\n", aw.getWritten());
|
try expectEqualStrings(("a" ** (3 * std.heap.page_size_max)) ++ "\n", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try writer.writeAll("a\na");
|
try writer.writeAll("a\na");
|
||||||
|
|
||||||
try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 1, .column = 0 });
|
try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 1, .column = 0 });
|
||||||
try expectEqualStrings(("a" ** (3 * std.heap.page_size_max)) ++ "a\n", aw.getWritten());
|
try expectEqualStrings(("a" ** (3 * std.heap.page_size_max)) ++ "a\n", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 2, .column = 0 });
|
try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 2, .column = 0 });
|
||||||
try expectEqualStrings("a\n", aw.getWritten());
|
try expectEqualStrings("a\n", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
@ -1353,11 +1353,11 @@ test printLineFromFileAnyOs {
|
||||||
try writer.writeAll("abc\ndef");
|
try writer.writeAll("abc\ndef");
|
||||||
|
|
||||||
try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = real_file_start + 1, .column = 0 });
|
try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = real_file_start + 1, .column = 0 });
|
||||||
try expectEqualStrings("abc\n", aw.getWritten());
|
try expectEqualStrings("abc\n", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = real_file_start + 2, .column = 0 });
|
try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = real_file_start + 2, .column = 0 });
|
||||||
try expectEqualStrings("def\n", aw.getWritten());
|
try expectEqualStrings("def\n", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1020,7 +1020,7 @@ fn echoTests(client: *http.Client, port: u16) !void {
|
||||||
.response_writer = &body.writer,
|
.response_writer = &body.writer,
|
||||||
});
|
});
|
||||||
try expectEqual(.ok, res.status);
|
try expectEqual(.ok, res.status);
|
||||||
try expectEqualStrings("Hello, World!\n", body.getWritten());
|
try expectEqualStrings("Hello, World!\n", body.written());
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // expect: 100-continue
|
{ // expect: 100-continue
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ test Stringify {
|
||||||
\\ "foo": 123
|
\\ "foo": 123
|
||||||
\\}
|
\\}
|
||||||
;
|
;
|
||||||
try testing.expectEqualSlices(u8, expected, out.getWritten());
|
try testing.expectEqualSlices(u8, expected, out.written());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const ObjectMap = @import("json/dynamic.zig").ObjectMap;
|
pub const ObjectMap = @import("json/dynamic.zig").ObjectMap;
|
||||||
|
|
|
||||||
|
|
@ -582,7 +582,7 @@ test value {
|
||||||
|
|
||||||
const T = struct { a: i32, b: []const u8 };
|
const T = struct { a: i32, b: []const u8 };
|
||||||
try value(T{ .a = 123, .b = "xy" }, .{}, writer);
|
try value(T{ .a = 123, .b = "xy" }, .{}, writer);
|
||||||
try std.testing.expectEqualSlices(u8, "{\"a\":123,\"b\":\"xy\"}", out.getWritten());
|
try std.testing.expectEqualSlices(u8, "{\"a\":123,\"b\":\"xy\"}", out.written());
|
||||||
|
|
||||||
try testStringify("9999999999999999", 9999999999999999, .{});
|
try testStringify("9999999999999999", 9999999999999999, .{});
|
||||||
try testStringify("\"9999999999999999\"", 9999999999999999, .{ .emit_nonportable_numbers_as_strings = true });
|
try testStringify("\"9999999999999999\"", 9999999999999999, .{ .emit_nonportable_numbers_as_strings = true });
|
||||||
|
|
|
||||||
|
|
@ -403,7 +403,7 @@ test "write files" {
|
||||||
for (files) |file|
|
for (files) |file|
|
||||||
try w.writeFileBytes(file.path, file.content, .{});
|
try w.writeFileBytes(file.path, file.content, .{});
|
||||||
|
|
||||||
var input: std.Io.Reader = .fixed(output.getWritten());
|
var input: std.Io.Reader = .fixed(output.written());
|
||||||
var it: std.tar.Iterator = .init(&input, .{
|
var it: std.tar.Iterator = .init(&input, .{
|
||||||
.file_name_buffer = &file_name_buffer,
|
.file_name_buffer = &file_name_buffer,
|
||||||
.link_name_buffer = &link_name_buffer,
|
.link_name_buffer = &link_name_buffer,
|
||||||
|
|
@ -427,7 +427,7 @@ test "write files" {
|
||||||
var content: std.Io.Writer.Allocating = .init(testing.allocator);
|
var content: std.Io.Writer.Allocating = .init(testing.allocator);
|
||||||
defer content.deinit();
|
defer content.deinit();
|
||||||
try it.streamRemaining(actual, &content.writer);
|
try it.streamRemaining(actual, &content.writer);
|
||||||
try testing.expectEqualSlices(u8, expected.content, content.getWritten());
|
try testing.expectEqualSlices(u8, expected.content, content.written());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// without root
|
// without root
|
||||||
|
|
@ -440,7 +440,7 @@ test "write files" {
|
||||||
try w.writeFileStream(file.path, file.content.len, &content, .{});
|
try w.writeFileStream(file.path, file.content.len, &content, .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
var input: std.Io.Reader = .fixed(output.getWritten());
|
var input: std.Io.Reader = .fixed(output.written());
|
||||||
var it: std.tar.Iterator = .init(&input, .{
|
var it: std.tar.Iterator = .init(&input, .{
|
||||||
.file_name_buffer = &file_name_buffer,
|
.file_name_buffer = &file_name_buffer,
|
||||||
.link_name_buffer = &link_name_buffer,
|
.link_name_buffer = &link_name_buffer,
|
||||||
|
|
@ -455,7 +455,7 @@ test "write files" {
|
||||||
var content: std.Io.Writer.Allocating = .init(testing.allocator);
|
var content: std.Io.Writer.Allocating = .init(testing.allocator);
|
||||||
defer content.deinit();
|
defer content.deinit();
|
||||||
try it.streamRemaining(actual, &content.writer);
|
try it.streamRemaining(actual, &content.writer);
|
||||||
try testing.expectEqualSlices(u8, expected.content, content.getWritten());
|
try testing.expectEqualSlices(u8, expected.content, content.written());
|
||||||
}
|
}
|
||||||
try w.finishPedantically();
|
try w.finishPedantically();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -361,7 +361,7 @@ fn testCase(case: Case) !void {
|
||||||
var aw: std.Io.Writer.Allocating = .init(std.testing.allocator);
|
var aw: std.Io.Writer.Allocating = .init(std.testing.allocator);
|
||||||
defer aw.deinit();
|
defer aw.deinit();
|
||||||
try it.streamRemaining(actual, &aw.writer);
|
try it.streamRemaining(actual, &aw.writer);
|
||||||
const chksum = std.fmt.bytesToHex(std.crypto.hash.Md5.hashResult(aw.getWritten()), .lower);
|
const chksum = std.fmt.bytesToHex(std.crypto.hash.Md5.hashResult(aw.written()), .lower);
|
||||||
try testing.expectEqualStrings(case.chksums[i], &chksum);
|
try testing.expectEqualStrings(case.chksums[i], &chksum);
|
||||||
} else {
|
} else {
|
||||||
if (expected.truncated) {
|
if (expected.truncated) {
|
||||||
|
|
|
||||||
|
|
@ -2189,12 +2189,12 @@ fn renderArrayInit(
|
||||||
var single_line = true;
|
var single_line = true;
|
||||||
var contains_newline = false;
|
var contains_newline = false;
|
||||||
for (section_exprs, 0..) |expr, i| {
|
for (section_exprs, 0..) |expr, i| {
|
||||||
const start = sub_expr_buffer.getWritten().len;
|
const start = sub_expr_buffer.written().len;
|
||||||
sub_expr_buffer_starts[i] = start;
|
sub_expr_buffer_starts[i] = start;
|
||||||
|
|
||||||
if (i + 1 < section_exprs.len) {
|
if (i + 1 < section_exprs.len) {
|
||||||
try renderExpression(&sub_render, expr, .none);
|
try renderExpression(&sub_render, expr, .none);
|
||||||
const written = sub_expr_buffer.getWritten();
|
const written = sub_expr_buffer.written();
|
||||||
const width = written.len - start;
|
const width = written.len - start;
|
||||||
const this_contains_newline = mem.indexOfScalar(u8, written[start..], '\n') != null;
|
const this_contains_newline = mem.indexOfScalar(u8, written[start..], '\n') != null;
|
||||||
contains_newline = contains_newline or this_contains_newline;
|
contains_newline = contains_newline or this_contains_newline;
|
||||||
|
|
@ -2218,7 +2218,7 @@ fn renderArrayInit(
|
||||||
try renderExpression(&sub_render, expr, .comma);
|
try renderExpression(&sub_render, expr, .comma);
|
||||||
ais.popSpace();
|
ais.popSpace();
|
||||||
|
|
||||||
const written = sub_expr_buffer.getWritten();
|
const written = sub_expr_buffer.written();
|
||||||
const width = written.len - start - 2;
|
const width = written.len - start - 2;
|
||||||
const this_contains_newline = mem.indexOfScalar(u8, written[start .. written.len - 1], '\n') != null;
|
const this_contains_newline = mem.indexOfScalar(u8, written[start .. written.len - 1], '\n') != null;
|
||||||
contains_newline = contains_newline or this_contains_newline;
|
contains_newline = contains_newline or this_contains_newline;
|
||||||
|
|
@ -2231,14 +2231,14 @@ fn renderArrayInit(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sub_expr_buffer_starts[section_exprs.len] = sub_expr_buffer.getWritten().len;
|
sub_expr_buffer_starts[section_exprs.len] = sub_expr_buffer.written().len;
|
||||||
|
|
||||||
// Render exprs in current section.
|
// Render exprs in current section.
|
||||||
column_counter = 0;
|
column_counter = 0;
|
||||||
for (section_exprs, 0..) |expr, i| {
|
for (section_exprs, 0..) |expr, i| {
|
||||||
const start = sub_expr_buffer_starts[i];
|
const start = sub_expr_buffer_starts[i];
|
||||||
const end = sub_expr_buffer_starts[i + 1];
|
const end = sub_expr_buffer_starts[i + 1];
|
||||||
const expr_text = sub_expr_buffer.getWritten()[start..end];
|
const expr_text = sub_expr_buffer.written()[start..end];
|
||||||
if (!expr_newlines[i]) {
|
if (!expr_newlines[i]) {
|
||||||
try ais.writeAll(expr_text);
|
try ais.writeAll(expr_text);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -13765,19 +13765,19 @@ fn lowerAstErrors(astgen: *AstGen) error{OutOfMemory}!void {
|
||||||
};
|
};
|
||||||
msg.clearRetainingCapacity();
|
msg.clearRetainingCapacity();
|
||||||
tree.renderError(ast_err, msg_w) catch return error.OutOfMemory;
|
tree.renderError(ast_err, msg_w) catch return error.OutOfMemory;
|
||||||
return try astgen.appendErrorTokNotesOff(tok, bad_off, "{s}", .{msg.getWritten()}, notes.items);
|
return try astgen.appendErrorTokNotesOff(tok, bad_off, "{s}", .{msg.written()}, notes.items);
|
||||||
}
|
}
|
||||||
|
|
||||||
var cur_err = tree.errors[0];
|
var cur_err = tree.errors[0];
|
||||||
for (tree.errors[1..]) |err| {
|
for (tree.errors[1..]) |err| {
|
||||||
if (err.is_note) {
|
if (err.is_note) {
|
||||||
tree.renderError(err, msg_w) catch return error.OutOfMemory;
|
tree.renderError(err, msg_w) catch return error.OutOfMemory;
|
||||||
try notes.append(gpa, try astgen.errNoteTok(err.token, "{s}", .{msg.getWritten()}));
|
try notes.append(gpa, try astgen.errNoteTok(err.token, "{s}", .{msg.written()}));
|
||||||
} else {
|
} else {
|
||||||
// Flush error
|
// Flush error
|
||||||
const extra_offset = tree.errorOffset(cur_err);
|
const extra_offset = tree.errorOffset(cur_err);
|
||||||
tree.renderError(cur_err, msg_w) catch return error.OutOfMemory;
|
tree.renderError(cur_err, msg_w) catch return error.OutOfMemory;
|
||||||
try astgen.appendErrorTokNotesOff(cur_err.token, extra_offset, "{s}", .{msg.getWritten()}, notes.items);
|
try astgen.appendErrorTokNotesOff(cur_err.token, extra_offset, "{s}", .{msg.written()}, notes.items);
|
||||||
notes.clearRetainingCapacity();
|
notes.clearRetainingCapacity();
|
||||||
cur_err = err;
|
cur_err = err;
|
||||||
|
|
||||||
|
|
@ -13791,7 +13791,7 @@ fn lowerAstErrors(astgen: *AstGen) error{OutOfMemory}!void {
|
||||||
// Flush error
|
// Flush error
|
||||||
const extra_offset = tree.errorOffset(cur_err);
|
const extra_offset = tree.errorOffset(cur_err);
|
||||||
tree.renderError(cur_err, msg_w) catch return error.OutOfMemory;
|
tree.renderError(cur_err, msg_w) catch return error.OutOfMemory;
|
||||||
try astgen.appendErrorTokNotesOff(cur_err.token, extra_offset, "{s}", .{msg.getWritten()}, notes.items);
|
try astgen.appendErrorTokNotesOff(cur_err.token, extra_offset, "{s}", .{msg.written()}, notes.items);
|
||||||
}
|
}
|
||||||
|
|
||||||
const DeclarationName = union(enum) {
|
const DeclarationName = union(enum) {
|
||||||
|
|
|
||||||
|
|
@ -817,6 +817,6 @@ pub const Wip = struct {
|
||||||
defer copy_buf.deinit();
|
defer copy_buf.deinit();
|
||||||
try copy.renderToWriter(.{ .ttyconf = ttyconf }, copy_bw);
|
try copy.renderToWriter(.{ .ttyconf = ttyconf }, copy_bw);
|
||||||
|
|
||||||
try std.testing.expectEqualStrings(bundle_bw.getWritten(), copy_bw.getWritten());
|
try std.testing.expectEqualStrings(bundle_bw.written(), copy_bw.written());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -896,12 +896,12 @@ fn lowerAstErrors(zg: *ZonGen) Allocator.Error!void {
|
||||||
for (tree.errors[1..]) |err| {
|
for (tree.errors[1..]) |err| {
|
||||||
if (err.is_note) {
|
if (err.is_note) {
|
||||||
tree.renderError(err, msg_bw) catch return error.OutOfMemory;
|
tree.renderError(err, msg_bw) catch return error.OutOfMemory;
|
||||||
try notes.append(gpa, try zg.errNoteTok(err.token, "{s}", .{msg.getWritten()}));
|
try notes.append(gpa, try zg.errNoteTok(err.token, "{s}", .{msg.written()}));
|
||||||
} else {
|
} else {
|
||||||
// Flush error
|
// Flush error
|
||||||
tree.renderError(cur_err, msg_bw) catch return error.OutOfMemory;
|
tree.renderError(cur_err, msg_bw) catch return error.OutOfMemory;
|
||||||
const extra_offset = tree.errorOffset(cur_err);
|
const extra_offset = tree.errorOffset(cur_err);
|
||||||
try zg.addErrorTokNotesOff(cur_err.token, extra_offset, "{s}", .{msg.getWritten()}, notes.items);
|
try zg.addErrorTokNotesOff(cur_err.token, extra_offset, "{s}", .{msg.written()}, notes.items);
|
||||||
notes.clearRetainingCapacity();
|
notes.clearRetainingCapacity();
|
||||||
cur_err = err;
|
cur_err = err;
|
||||||
|
|
||||||
|
|
@ -917,5 +917,5 @@ fn lowerAstErrors(zg: *ZonGen) Allocator.Error!void {
|
||||||
// Flush error
|
// Flush error
|
||||||
const extra_offset = tree.errorOffset(cur_err);
|
const extra_offset = tree.errorOffset(cur_err);
|
||||||
tree.renderError(cur_err, msg_bw) catch return error.OutOfMemory;
|
tree.renderError(cur_err, msg_bw) catch return error.OutOfMemory;
|
||||||
try zg.addErrorTokNotesOff(cur_err.token, extra_offset, "{s}", .{msg.getWritten()}, notes.items);
|
try zg.addErrorTokNotesOff(cur_err.token, extra_offset, "{s}", .{msg.written()}, notes.items);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ fn expectSerializeEqual(
|
||||||
defer aw.deinit();
|
defer aw.deinit();
|
||||||
|
|
||||||
try serialize(value, options, bw);
|
try serialize(value, options, bw);
|
||||||
try std.testing.expectEqualStrings(expected, aw.getWritten());
|
try std.testing.expectEqualStrings(expected, aw.written());
|
||||||
}
|
}
|
||||||
|
|
||||||
test "std.zon stringify whitespace, high level API" {
|
test "std.zon stringify whitespace, high level API" {
|
||||||
|
|
@ -233,42 +233,42 @@ test "std.zon stringify whitespace, low level API" {
|
||||||
{
|
{
|
||||||
var container = try s.beginStruct(.{});
|
var container = try s.beginStruct(.{});
|
||||||
try container.end();
|
try container.end();
|
||||||
try std.testing.expectEqualStrings(".{}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{}", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var container = try s.beginTuple(.{});
|
var container = try s.beginTuple(.{});
|
||||||
try container.end();
|
try container.end();
|
||||||
try std.testing.expectEqualStrings(".{}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{}", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var container = try s.beginStruct(.{ .whitespace_style = .{ .wrap = false } });
|
var container = try s.beginStruct(.{ .whitespace_style = .{ .wrap = false } });
|
||||||
try container.end();
|
try container.end();
|
||||||
try std.testing.expectEqualStrings(".{}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{}", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var container = try s.beginTuple(.{ .whitespace_style = .{ .wrap = false } });
|
var container = try s.beginTuple(.{ .whitespace_style = .{ .wrap = false } });
|
||||||
try container.end();
|
try container.end();
|
||||||
try std.testing.expectEqualStrings(".{}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{}", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var container = try s.beginStruct(.{ .whitespace_style = .{ .fields = 0 } });
|
var container = try s.beginStruct(.{ .whitespace_style = .{ .fields = 0 } });
|
||||||
try container.end();
|
try container.end();
|
||||||
try std.testing.expectEqualStrings(".{}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{}", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var container = try s.beginTuple(.{ .whitespace_style = .{ .fields = 0 } });
|
var container = try s.beginTuple(.{ .whitespace_style = .{ .fields = 0 } });
|
||||||
try container.end();
|
try container.end();
|
||||||
try std.testing.expectEqualStrings(".{}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{}", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -282,9 +282,9 @@ test "std.zon stringify whitespace, low level API" {
|
||||||
\\.{
|
\\.{
|
||||||
\\ .a = 1,
|
\\ .a = 1,
|
||||||
\\}
|
\\}
|
||||||
, aw.getWritten());
|
, aw.written());
|
||||||
} else {
|
} else {
|
||||||
try std.testing.expectEqualStrings(".{.a=1}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{.a=1}", aw.written());
|
||||||
}
|
}
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
@ -298,9 +298,9 @@ test "std.zon stringify whitespace, low level API" {
|
||||||
\\.{
|
\\.{
|
||||||
\\ 1,
|
\\ 1,
|
||||||
\\}
|
\\}
|
||||||
, aw.getWritten());
|
, aw.written());
|
||||||
} else {
|
} else {
|
||||||
try std.testing.expectEqualStrings(".{1}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{1}", aw.written());
|
||||||
}
|
}
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
@ -310,9 +310,9 @@ test "std.zon stringify whitespace, low level API" {
|
||||||
try container.field("a", 1, .{});
|
try container.field("a", 1, .{});
|
||||||
try container.end();
|
try container.end();
|
||||||
if (whitespace) {
|
if (whitespace) {
|
||||||
try std.testing.expectEqualStrings(".{ .a = 1 }", aw.getWritten());
|
try std.testing.expectEqualStrings(".{ .a = 1 }", aw.written());
|
||||||
} else {
|
} else {
|
||||||
try std.testing.expectEqualStrings(".{.a=1}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{.a=1}", aw.written());
|
||||||
}
|
}
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
@ -324,9 +324,9 @@ test "std.zon stringify whitespace, low level API" {
|
||||||
try container.field(1, .{});
|
try container.field(1, .{});
|
||||||
try container.end();
|
try container.end();
|
||||||
if (whitespace) {
|
if (whitespace) {
|
||||||
try std.testing.expectEqualStrings(".{ 1 }", aw.getWritten());
|
try std.testing.expectEqualStrings(".{ 1 }", aw.written());
|
||||||
} else {
|
} else {
|
||||||
try std.testing.expectEqualStrings(".{1}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{1}", aw.written());
|
||||||
}
|
}
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
@ -336,9 +336,9 @@ test "std.zon stringify whitespace, low level API" {
|
||||||
try container.field("a", 1, .{});
|
try container.field("a", 1, .{});
|
||||||
try container.end();
|
try container.end();
|
||||||
if (whitespace) {
|
if (whitespace) {
|
||||||
try std.testing.expectEqualStrings(".{ .a = 1 }", aw.getWritten());
|
try std.testing.expectEqualStrings(".{ .a = 1 }", aw.written());
|
||||||
} else {
|
} else {
|
||||||
try std.testing.expectEqualStrings(".{.a=1}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{.a=1}", aw.written());
|
||||||
}
|
}
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
@ -347,7 +347,7 @@ test "std.zon stringify whitespace, low level API" {
|
||||||
var container = try s.beginTuple(.{ .whitespace_style = .{ .fields = 1 } });
|
var container = try s.beginTuple(.{ .whitespace_style = .{ .fields = 1 } });
|
||||||
try container.field(1, .{});
|
try container.field(1, .{});
|
||||||
try container.end();
|
try container.end();
|
||||||
try std.testing.expectEqualStrings(".{1}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{1}", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -363,9 +363,9 @@ test "std.zon stringify whitespace, low level API" {
|
||||||
\\ .a = 1,
|
\\ .a = 1,
|
||||||
\\ .b = 2,
|
\\ .b = 2,
|
||||||
\\}
|
\\}
|
||||||
, aw.getWritten());
|
, aw.written());
|
||||||
} else {
|
} else {
|
||||||
try std.testing.expectEqualStrings(".{.a=1,.b=2}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{.a=1,.b=2}", aw.written());
|
||||||
}
|
}
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
@ -381,9 +381,9 @@ test "std.zon stringify whitespace, low level API" {
|
||||||
\\ 1,
|
\\ 1,
|
||||||
\\ 2,
|
\\ 2,
|
||||||
\\}
|
\\}
|
||||||
, aw.getWritten());
|
, aw.written());
|
||||||
} else {
|
} else {
|
||||||
try std.testing.expectEqualStrings(".{1,2}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{1,2}", aw.written());
|
||||||
}
|
}
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
@ -394,9 +394,9 @@ test "std.zon stringify whitespace, low level API" {
|
||||||
try container.field("b", 2, .{});
|
try container.field("b", 2, .{});
|
||||||
try container.end();
|
try container.end();
|
||||||
if (whitespace) {
|
if (whitespace) {
|
||||||
try std.testing.expectEqualStrings(".{ .a = 1, .b = 2 }", aw.getWritten());
|
try std.testing.expectEqualStrings(".{ .a = 1, .b = 2 }", aw.written());
|
||||||
} else {
|
} else {
|
||||||
try std.testing.expectEqualStrings(".{.a=1,.b=2}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{.a=1,.b=2}", aw.written());
|
||||||
}
|
}
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
@ -407,9 +407,9 @@ test "std.zon stringify whitespace, low level API" {
|
||||||
try container.field(2, .{});
|
try container.field(2, .{});
|
||||||
try container.end();
|
try container.end();
|
||||||
if (whitespace) {
|
if (whitespace) {
|
||||||
try std.testing.expectEqualStrings(".{ 1, 2 }", aw.getWritten());
|
try std.testing.expectEqualStrings(".{ 1, 2 }", aw.written());
|
||||||
} else {
|
} else {
|
||||||
try std.testing.expectEqualStrings(".{1,2}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{1,2}", aw.written());
|
||||||
}
|
}
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
@ -420,9 +420,9 @@ test "std.zon stringify whitespace, low level API" {
|
||||||
try container.field("b", 2, .{});
|
try container.field("b", 2, .{});
|
||||||
try container.end();
|
try container.end();
|
||||||
if (whitespace) {
|
if (whitespace) {
|
||||||
try std.testing.expectEqualStrings(".{ .a = 1, .b = 2 }", aw.getWritten());
|
try std.testing.expectEqualStrings(".{ .a = 1, .b = 2 }", aw.written());
|
||||||
} else {
|
} else {
|
||||||
try std.testing.expectEqualStrings(".{.a=1,.b=2}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{.a=1,.b=2}", aw.written());
|
||||||
}
|
}
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
@ -433,9 +433,9 @@ test "std.zon stringify whitespace, low level API" {
|
||||||
try container.field(2, .{});
|
try container.field(2, .{});
|
||||||
try container.end();
|
try container.end();
|
||||||
if (whitespace) {
|
if (whitespace) {
|
||||||
try std.testing.expectEqualStrings(".{ 1, 2 }", aw.getWritten());
|
try std.testing.expectEqualStrings(".{ 1, 2 }", aw.written());
|
||||||
} else {
|
} else {
|
||||||
try std.testing.expectEqualStrings(".{1,2}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{1,2}", aw.written());
|
||||||
}
|
}
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
@ -454,9 +454,9 @@ test "std.zon stringify whitespace, low level API" {
|
||||||
\\ .b = 2,
|
\\ .b = 2,
|
||||||
\\ .c = 3,
|
\\ .c = 3,
|
||||||
\\}
|
\\}
|
||||||
, aw.getWritten());
|
, aw.written());
|
||||||
} else {
|
} else {
|
||||||
try std.testing.expectEqualStrings(".{.a=1,.b=2,.c=3}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{.a=1,.b=2,.c=3}", aw.written());
|
||||||
}
|
}
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
@ -474,9 +474,9 @@ test "std.zon stringify whitespace, low level API" {
|
||||||
\\ 2,
|
\\ 2,
|
||||||
\\ 3,
|
\\ 3,
|
||||||
\\}
|
\\}
|
||||||
, aw.getWritten());
|
, aw.written());
|
||||||
} else {
|
} else {
|
||||||
try std.testing.expectEqualStrings(".{1,2,3}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{1,2,3}", aw.written());
|
||||||
}
|
}
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
@ -488,9 +488,9 @@ test "std.zon stringify whitespace, low level API" {
|
||||||
try container.field("c", 3, .{});
|
try container.field("c", 3, .{});
|
||||||
try container.end();
|
try container.end();
|
||||||
if (whitespace) {
|
if (whitespace) {
|
||||||
try std.testing.expectEqualStrings(".{ .a = 1, .b = 2, .c = 3 }", aw.getWritten());
|
try std.testing.expectEqualStrings(".{ .a = 1, .b = 2, .c = 3 }", aw.written());
|
||||||
} else {
|
} else {
|
||||||
try std.testing.expectEqualStrings(".{.a=1,.b=2,.c=3}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{.a=1,.b=2,.c=3}", aw.written());
|
||||||
}
|
}
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
@ -502,9 +502,9 @@ test "std.zon stringify whitespace, low level API" {
|
||||||
try container.field(3, .{});
|
try container.field(3, .{});
|
||||||
try container.end();
|
try container.end();
|
||||||
if (whitespace) {
|
if (whitespace) {
|
||||||
try std.testing.expectEqualStrings(".{ 1, 2, 3 }", aw.getWritten());
|
try std.testing.expectEqualStrings(".{ 1, 2, 3 }", aw.written());
|
||||||
} else {
|
} else {
|
||||||
try std.testing.expectEqualStrings(".{1,2,3}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{1,2,3}", aw.written());
|
||||||
}
|
}
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
@ -522,9 +522,9 @@ test "std.zon stringify whitespace, low level API" {
|
||||||
\\ .b = 2,
|
\\ .b = 2,
|
||||||
\\ .c = 3,
|
\\ .c = 3,
|
||||||
\\}
|
\\}
|
||||||
, aw.getWritten());
|
, aw.written());
|
||||||
} else {
|
} else {
|
||||||
try std.testing.expectEqualStrings(".{.a=1,.b=2,.c=3}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{.a=1,.b=2,.c=3}", aw.written());
|
||||||
}
|
}
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
@ -542,9 +542,9 @@ test "std.zon stringify whitespace, low level API" {
|
||||||
\\ 2,
|
\\ 2,
|
||||||
\\ 3,
|
\\ 3,
|
||||||
\\}
|
\\}
|
||||||
, aw.getWritten());
|
, aw.written());
|
||||||
} else {
|
} else {
|
||||||
try std.testing.expectEqualStrings(".{1,2,3}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{1,2,3}", aw.written());
|
||||||
}
|
}
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
@ -566,11 +566,11 @@ test "std.zon stringify whitespace, low level API" {
|
||||||
\\ 5,
|
\\ 5,
|
||||||
\\ 6,
|
\\ 6,
|
||||||
\\} }
|
\\} }
|
||||||
, aw.getWritten());
|
, aw.written());
|
||||||
} else {
|
} else {
|
||||||
try std.testing.expectEqualStrings(
|
try std.testing.expectEqualStrings(
|
||||||
".{.first=.{1,2,3},.second=.{4,5,6}}",
|
".{.first=.{1,2,3},.second=.{4,5,6}}",
|
||||||
aw.getWritten(),
|
aw.written(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
@ -585,108 +585,108 @@ test "std.zon stringify utf8 codepoints" {
|
||||||
|
|
||||||
// Printable ASCII
|
// Printable ASCII
|
||||||
try s.int('a');
|
try s.int('a');
|
||||||
try std.testing.expectEqualStrings("97", aw.getWritten());
|
try std.testing.expectEqualStrings("97", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.codePoint('a');
|
try s.codePoint('a');
|
||||||
try std.testing.expectEqualStrings("'a'", aw.getWritten());
|
try std.testing.expectEqualStrings("'a'", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.value('a', .{ .emit_codepoint_literals = .always });
|
try s.value('a', .{ .emit_codepoint_literals = .always });
|
||||||
try std.testing.expectEqualStrings("'a'", aw.getWritten());
|
try std.testing.expectEqualStrings("'a'", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.value('a', .{ .emit_codepoint_literals = .printable_ascii });
|
try s.value('a', .{ .emit_codepoint_literals = .printable_ascii });
|
||||||
try std.testing.expectEqualStrings("'a'", aw.getWritten());
|
try std.testing.expectEqualStrings("'a'", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.value('a', .{ .emit_codepoint_literals = .never });
|
try s.value('a', .{ .emit_codepoint_literals = .never });
|
||||||
try std.testing.expectEqualStrings("97", aw.getWritten());
|
try std.testing.expectEqualStrings("97", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
// Short escaped codepoint
|
// Short escaped codepoint
|
||||||
try s.int('\n');
|
try s.int('\n');
|
||||||
try std.testing.expectEqualStrings("10", aw.getWritten());
|
try std.testing.expectEqualStrings("10", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.codePoint('\n');
|
try s.codePoint('\n');
|
||||||
try std.testing.expectEqualStrings("'\\n'", aw.getWritten());
|
try std.testing.expectEqualStrings("'\\n'", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.value('\n', .{ .emit_codepoint_literals = .always });
|
try s.value('\n', .{ .emit_codepoint_literals = .always });
|
||||||
try std.testing.expectEqualStrings("'\\n'", aw.getWritten());
|
try std.testing.expectEqualStrings("'\\n'", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.value('\n', .{ .emit_codepoint_literals = .printable_ascii });
|
try s.value('\n', .{ .emit_codepoint_literals = .printable_ascii });
|
||||||
try std.testing.expectEqualStrings("10", aw.getWritten());
|
try std.testing.expectEqualStrings("10", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.value('\n', .{ .emit_codepoint_literals = .never });
|
try s.value('\n', .{ .emit_codepoint_literals = .never });
|
||||||
try std.testing.expectEqualStrings("10", aw.getWritten());
|
try std.testing.expectEqualStrings("10", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
// Large codepoint
|
// Large codepoint
|
||||||
try s.int('⚡');
|
try s.int('⚡');
|
||||||
try std.testing.expectEqualStrings("9889", aw.getWritten());
|
try std.testing.expectEqualStrings("9889", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.codePoint('⚡');
|
try s.codePoint('⚡');
|
||||||
try std.testing.expectEqualStrings("'\\u{26a1}'", aw.getWritten());
|
try std.testing.expectEqualStrings("'\\u{26a1}'", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.value('⚡', .{ .emit_codepoint_literals = .always });
|
try s.value('⚡', .{ .emit_codepoint_literals = .always });
|
||||||
try std.testing.expectEqualStrings("'\\u{26a1}'", aw.getWritten());
|
try std.testing.expectEqualStrings("'\\u{26a1}'", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.value('⚡', .{ .emit_codepoint_literals = .printable_ascii });
|
try s.value('⚡', .{ .emit_codepoint_literals = .printable_ascii });
|
||||||
try std.testing.expectEqualStrings("9889", aw.getWritten());
|
try std.testing.expectEqualStrings("9889", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.value('⚡', .{ .emit_codepoint_literals = .never });
|
try s.value('⚡', .{ .emit_codepoint_literals = .never });
|
||||||
try std.testing.expectEqualStrings("9889", aw.getWritten());
|
try std.testing.expectEqualStrings("9889", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
// Invalid codepoint
|
// Invalid codepoint
|
||||||
try s.codePoint(0x110000 + 1);
|
try s.codePoint(0x110000 + 1);
|
||||||
try std.testing.expectEqualStrings("'\\u{110001}'", aw.getWritten());
|
try std.testing.expectEqualStrings("'\\u{110001}'", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.int(0x110000 + 1);
|
try s.int(0x110000 + 1);
|
||||||
try std.testing.expectEqualStrings("1114113", aw.getWritten());
|
try std.testing.expectEqualStrings("1114113", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.value(0x110000 + 1, .{ .emit_codepoint_literals = .always });
|
try s.value(0x110000 + 1, .{ .emit_codepoint_literals = .always });
|
||||||
try std.testing.expectEqualStrings("1114113", aw.getWritten());
|
try std.testing.expectEqualStrings("1114113", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.value(0x110000 + 1, .{ .emit_codepoint_literals = .printable_ascii });
|
try s.value(0x110000 + 1, .{ .emit_codepoint_literals = .printable_ascii });
|
||||||
try std.testing.expectEqualStrings("1114113", aw.getWritten());
|
try std.testing.expectEqualStrings("1114113", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.value(0x110000 + 1, .{ .emit_codepoint_literals = .never });
|
try s.value(0x110000 + 1, .{ .emit_codepoint_literals = .never });
|
||||||
try std.testing.expectEqualStrings("1114113", aw.getWritten());
|
try std.testing.expectEqualStrings("1114113", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
// Valid codepoint, not a codepoint type
|
// Valid codepoint, not a codepoint type
|
||||||
try s.value(@as(u22, 'a'), .{ .emit_codepoint_literals = .always });
|
try s.value(@as(u22, 'a'), .{ .emit_codepoint_literals = .always });
|
||||||
try std.testing.expectEqualStrings("97", aw.getWritten());
|
try std.testing.expectEqualStrings("97", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.value(@as(u22, 'a'), .{ .emit_codepoint_literals = .printable_ascii });
|
try s.value(@as(u22, 'a'), .{ .emit_codepoint_literals = .printable_ascii });
|
||||||
try std.testing.expectEqualStrings("97", aw.getWritten());
|
try std.testing.expectEqualStrings("97", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.value(@as(i32, 'a'), .{ .emit_codepoint_literals = .never });
|
try s.value(@as(i32, 'a'), .{ .emit_codepoint_literals = .never });
|
||||||
try std.testing.expectEqualStrings("97", aw.getWritten());
|
try std.testing.expectEqualStrings("97", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
// Make sure value options are passed to children
|
// Make sure value options are passed to children
|
||||||
try s.value(.{ .c = '⚡' }, .{ .emit_codepoint_literals = .always });
|
try s.value(.{ .c = '⚡' }, .{ .emit_codepoint_literals = .always });
|
||||||
try std.testing.expectEqualStrings(".{ .c = '\\u{26a1}' }", aw.getWritten());
|
try std.testing.expectEqualStrings(".{ .c = '\\u{26a1}' }", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.value(.{ .c = '⚡' }, .{ .emit_codepoint_literals = .never });
|
try s.value(.{ .c = '⚡' }, .{ .emit_codepoint_literals = .never });
|
||||||
try std.testing.expectEqualStrings(".{ .c = 9889 }", aw.getWritten());
|
try std.testing.expectEqualStrings(".{ .c = 9889 }", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -697,7 +697,7 @@ test "std.zon stringify strings" {
|
||||||
|
|
||||||
// Minimal case
|
// Minimal case
|
||||||
try s.string("abc⚡\n");
|
try s.string("abc⚡\n");
|
||||||
try std.testing.expectEqualStrings("\"abc\\xe2\\x9a\\xa1\\n\"", aw.getWritten());
|
try std.testing.expectEqualStrings("\"abc\\xe2\\x9a\\xa1\\n\"", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.tuple("abc⚡\n", .{});
|
try s.tuple("abc⚡\n", .{});
|
||||||
|
|
@ -711,11 +711,11 @@ test "std.zon stringify strings" {
|
||||||
\\ 161,
|
\\ 161,
|
||||||
\\ 10,
|
\\ 10,
|
||||||
\\}
|
\\}
|
||||||
, aw.getWritten());
|
, aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.value("abc⚡\n", .{});
|
try s.value("abc⚡\n", .{});
|
||||||
try std.testing.expectEqualStrings("\"abc\\xe2\\x9a\\xa1\\n\"", aw.getWritten());
|
try std.testing.expectEqualStrings("\"abc\\xe2\\x9a\\xa1\\n\"", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.value("abc⚡\n", .{ .emit_strings_as_containers = true });
|
try s.value("abc⚡\n", .{ .emit_strings_as_containers = true });
|
||||||
|
|
@ -729,12 +729,12 @@ test "std.zon stringify strings" {
|
||||||
\\ 161,
|
\\ 161,
|
||||||
\\ 10,
|
\\ 10,
|
||||||
\\}
|
\\}
|
||||||
, aw.getWritten());
|
, aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
// Value options are inherited by children
|
// Value options are inherited by children
|
||||||
try s.value(.{ .str = "abc" }, .{});
|
try s.value(.{ .str = "abc" }, .{});
|
||||||
try std.testing.expectEqualStrings(".{ .str = \"abc\" }", aw.getWritten());
|
try std.testing.expectEqualStrings(".{ .str = \"abc\" }", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.value(.{ .str = "abc" }, .{ .emit_strings_as_containers = true });
|
try s.value(.{ .str = "abc" }, .{ .emit_strings_as_containers = true });
|
||||||
|
|
@ -744,7 +744,7 @@ test "std.zon stringify strings" {
|
||||||
\\ 98,
|
\\ 98,
|
||||||
\\ 99,
|
\\ 99,
|
||||||
\\} }
|
\\} }
|
||||||
, aw.getWritten());
|
, aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
// Arrays (rather than pointers to arrays) of u8s are not considered strings, so that data can
|
// Arrays (rather than pointers to arrays) of u8s are not considered strings, so that data can
|
||||||
|
|
@ -756,7 +756,7 @@ test "std.zon stringify strings" {
|
||||||
\\ 98,
|
\\ 98,
|
||||||
\\ 99,
|
\\ 99,
|
||||||
\\}
|
\\}
|
||||||
, aw.getWritten());
|
, aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -770,46 +770,46 @@ test "std.zon stringify multiline strings" {
|
||||||
|
|
||||||
{
|
{
|
||||||
try s.multilineString("", .{ .top_level = true });
|
try s.multilineString("", .{ .top_level = true });
|
||||||
try std.testing.expectEqualStrings("\\\\", aw.getWritten());
|
try std.testing.expectEqualStrings("\\\\", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
try s.multilineString("abc⚡", .{ .top_level = true });
|
try s.multilineString("abc⚡", .{ .top_level = true });
|
||||||
try std.testing.expectEqualStrings("\\\\abc⚡", aw.getWritten());
|
try std.testing.expectEqualStrings("\\\\abc⚡", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
try s.multilineString("abc⚡\ndef", .{ .top_level = true });
|
try s.multilineString("abc⚡\ndef", .{ .top_level = true });
|
||||||
try std.testing.expectEqualStrings("\\\\abc⚡\n\\\\def", aw.getWritten());
|
try std.testing.expectEqualStrings("\\\\abc⚡\n\\\\def", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
try s.multilineString("abc⚡\r\ndef", .{ .top_level = true });
|
try s.multilineString("abc⚡\r\ndef", .{ .top_level = true });
|
||||||
try std.testing.expectEqualStrings("\\\\abc⚡\n\\\\def", aw.getWritten());
|
try std.testing.expectEqualStrings("\\\\abc⚡\n\\\\def", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
try s.multilineString("\nabc⚡", .{ .top_level = true });
|
try s.multilineString("\nabc⚡", .{ .top_level = true });
|
||||||
try std.testing.expectEqualStrings("\\\\\n\\\\abc⚡", aw.getWritten());
|
try std.testing.expectEqualStrings("\\\\\n\\\\abc⚡", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
try s.multilineString("\r\nabc⚡", .{ .top_level = true });
|
try s.multilineString("\r\nabc⚡", .{ .top_level = true });
|
||||||
try std.testing.expectEqualStrings("\\\\\n\\\\abc⚡", aw.getWritten());
|
try std.testing.expectEqualStrings("\\\\\n\\\\abc⚡", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
try s.multilineString("abc\ndef", .{});
|
try s.multilineString("abc\ndef", .{});
|
||||||
if (whitespace) {
|
if (whitespace) {
|
||||||
try std.testing.expectEqualStrings("\n\\\\abc\n\\\\def\n", aw.getWritten());
|
try std.testing.expectEqualStrings("\n\\\\abc\n\\\\def\n", aw.written());
|
||||||
} else {
|
} else {
|
||||||
try std.testing.expectEqualStrings("\\\\abc\n\\\\def\n", aw.getWritten());
|
try std.testing.expectEqualStrings("\\\\abc\n\\\\def\n", aw.written());
|
||||||
}
|
}
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
@ -817,7 +817,7 @@ test "std.zon stringify multiline strings" {
|
||||||
{
|
{
|
||||||
const str: []const u8 = &.{ 'a', '\r', 'c' };
|
const str: []const u8 = &.{ 'a', '\r', 'c' };
|
||||||
try s.string(str);
|
try s.string(str);
|
||||||
try std.testing.expectEqualStrings("\"a\\rc\"", aw.getWritten());
|
try std.testing.expectEqualStrings("\"a\\rc\"", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -834,7 +834,7 @@ test "std.zon stringify multiline strings" {
|
||||||
error.InnerCarriageReturn,
|
error.InnerCarriageReturn,
|
||||||
s.multilineString(@as([]const u8, &.{ 'a', '\r', 'c', '\r', '\n' }), .{}),
|
s.multilineString(@as([]const u8, &.{ 'a', '\r', 'c', '\r', '\n' }), .{}),
|
||||||
);
|
);
|
||||||
try std.testing.expectEqualStrings("", aw.getWritten());
|
try std.testing.expectEqualStrings("", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -989,11 +989,11 @@ test "std.zon depth limits" {
|
||||||
|
|
||||||
// Normal operation
|
// Normal operation
|
||||||
try serializeMaxDepth(.{ 1, .{ 2, 3 } }, .{}, bw, 16);
|
try serializeMaxDepth(.{ 1, .{ 2, 3 } }, .{}, bw, 16);
|
||||||
try std.testing.expectEqualStrings(".{ 1, .{ 2, 3 } }", aw.getWritten());
|
try std.testing.expectEqualStrings(".{ 1, .{ 2, 3 } }", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try serializeArbitraryDepth(.{ 1, .{ 2, 3 } }, .{}, bw);
|
try serializeArbitraryDepth(.{ 1, .{ 2, 3 } }, .{}, bw);
|
||||||
try std.testing.expectEqualStrings(".{ 1, .{ 2, 3 } }", aw.getWritten());
|
try std.testing.expectEqualStrings(".{ 1, .{ 2, 3 } }", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
// Max depth failing on non recursive type
|
// Max depth failing on non recursive type
|
||||||
|
|
@ -1001,14 +1001,14 @@ test "std.zon depth limits" {
|
||||||
error.ExceededMaxDepth,
|
error.ExceededMaxDepth,
|
||||||
serializeMaxDepth(.{ 1, .{ 2, .{ 3, 4 } } }, .{}, bw, 3),
|
serializeMaxDepth(.{ 1, .{ 2, .{ 3, 4 } } }, .{}, bw, 3),
|
||||||
);
|
);
|
||||||
try std.testing.expectEqualStrings("", aw.getWritten());
|
try std.testing.expectEqualStrings("", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
// Max depth passing on recursive type
|
// Max depth passing on recursive type
|
||||||
{
|
{
|
||||||
const maybe_recurse = Recurse{ .r = &.{} };
|
const maybe_recurse = Recurse{ .r = &.{} };
|
||||||
try serializeMaxDepth(maybe_recurse, .{}, bw, 2);
|
try serializeMaxDepth(maybe_recurse, .{}, bw, 2);
|
||||||
try std.testing.expectEqualStrings(".{ .r = .{} }", aw.getWritten());
|
try std.testing.expectEqualStrings(".{ .r = .{} }", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1016,7 +1016,7 @@ test "std.zon depth limits" {
|
||||||
{
|
{
|
||||||
const maybe_recurse = Recurse{ .r = &.{} };
|
const maybe_recurse = Recurse{ .r = &.{} };
|
||||||
try serializeArbitraryDepth(maybe_recurse, .{}, bw);
|
try serializeArbitraryDepth(maybe_recurse, .{}, bw);
|
||||||
try std.testing.expectEqualStrings(".{ .r = .{} }", aw.getWritten());
|
try std.testing.expectEqualStrings(".{ .r = .{} }", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1028,7 +1028,7 @@ test "std.zon depth limits" {
|
||||||
error.ExceededMaxDepth,
|
error.ExceededMaxDepth,
|
||||||
serializeMaxDepth(maybe_recurse, .{}, bw, 2),
|
serializeMaxDepth(maybe_recurse, .{}, bw, 2),
|
||||||
);
|
);
|
||||||
try std.testing.expectEqualStrings("", aw.getWritten());
|
try std.testing.expectEqualStrings("", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1041,7 +1041,7 @@ test "std.zon depth limits" {
|
||||||
error.ExceededMaxDepth,
|
error.ExceededMaxDepth,
|
||||||
serializeMaxDepth(maybe_recurse, .{}, bw, 2),
|
serializeMaxDepth(maybe_recurse, .{}, bw, 2),
|
||||||
);
|
);
|
||||||
try std.testing.expectEqualStrings("", aw.getWritten());
|
try std.testing.expectEqualStrings("", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
var s: Serializer = .{ .writer = bw };
|
var s: Serializer = .{ .writer = bw };
|
||||||
|
|
@ -1050,11 +1050,11 @@ test "std.zon depth limits" {
|
||||||
error.ExceededMaxDepth,
|
error.ExceededMaxDepth,
|
||||||
s.tupleMaxDepth(maybe_recurse, .{}, 2),
|
s.tupleMaxDepth(maybe_recurse, .{}, 2),
|
||||||
);
|
);
|
||||||
try std.testing.expectEqualStrings("", aw.getWritten());
|
try std.testing.expectEqualStrings("", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.tupleArbitraryDepth(maybe_recurse, .{});
|
try s.tupleArbitraryDepth(maybe_recurse, .{});
|
||||||
try std.testing.expectEqualStrings(".{.{ .r = .{} }}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{.{ .r = .{} }}", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1064,17 +1064,17 @@ test "std.zon depth limits" {
|
||||||
const maybe_recurse: []const Recurse = &temp;
|
const maybe_recurse: []const Recurse = &temp;
|
||||||
|
|
||||||
try serializeMaxDepth(maybe_recurse, .{}, bw, 3);
|
try serializeMaxDepth(maybe_recurse, .{}, bw, 3);
|
||||||
try std.testing.expectEqualStrings(".{.{ .r = .{} }}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{.{ .r = .{} }}", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
var s: Serializer = .{ .writer = bw };
|
var s: Serializer = .{ .writer = bw };
|
||||||
|
|
||||||
try s.tupleMaxDepth(maybe_recurse, .{}, 3);
|
try s.tupleMaxDepth(maybe_recurse, .{}, 3);
|
||||||
try std.testing.expectEqualStrings(".{.{ .r = .{} }}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{.{ .r = .{} }}", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.tupleArbitraryDepth(maybe_recurse, .{});
|
try s.tupleArbitraryDepth(maybe_recurse, .{});
|
||||||
try std.testing.expectEqualStrings(".{.{ .r = .{} }}", aw.getWritten());
|
try std.testing.expectEqualStrings(".{.{ .r = .{} }}", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1088,7 +1088,7 @@ test "std.zon depth limits" {
|
||||||
error.ExceededMaxDepth,
|
error.ExceededMaxDepth,
|
||||||
serializeMaxDepth(maybe_recurse, .{}, bw, 128),
|
serializeMaxDepth(maybe_recurse, .{}, bw, 128),
|
||||||
);
|
);
|
||||||
try std.testing.expectEqualStrings("", aw.getWritten());
|
try std.testing.expectEqualStrings("", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
var s: Serializer = .{ .writer = bw };
|
var s: Serializer = .{ .writer = bw };
|
||||||
|
|
@ -1096,7 +1096,7 @@ test "std.zon depth limits" {
|
||||||
error.ExceededMaxDepth,
|
error.ExceededMaxDepth,
|
||||||
s.tupleMaxDepth(maybe_recurse, .{}, 128),
|
s.tupleMaxDepth(maybe_recurse, .{}, 128),
|
||||||
);
|
);
|
||||||
try std.testing.expectEqualStrings("", aw.getWritten());
|
try std.testing.expectEqualStrings("", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1146,7 +1146,7 @@ test "std.zon depth limits" {
|
||||||
\\ 9,
|
\\ 9,
|
||||||
\\ .{},
|
\\ .{},
|
||||||
\\}
|
\\}
|
||||||
, aw.getWritten());
|
, aw.written());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1248,35 +1248,35 @@ test "std.zon stringify ident" {
|
||||||
|
|
||||||
try expectSerializeEqual(".{ .a = 0 }", .{ .a = 0 }, .{});
|
try expectSerializeEqual(".{ .a = 0 }", .{ .a = 0 }, .{});
|
||||||
try s.ident("a");
|
try s.ident("a");
|
||||||
try std.testing.expectEqualStrings(".a", aw.getWritten());
|
try std.testing.expectEqualStrings(".a", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.ident("foo_1");
|
try s.ident("foo_1");
|
||||||
try std.testing.expectEqualStrings(".foo_1", aw.getWritten());
|
try std.testing.expectEqualStrings(".foo_1", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.ident("_foo_1");
|
try s.ident("_foo_1");
|
||||||
try std.testing.expectEqualStrings("._foo_1", aw.getWritten());
|
try std.testing.expectEqualStrings("._foo_1", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.ident("foo bar");
|
try s.ident("foo bar");
|
||||||
try std.testing.expectEqualStrings(".@\"foo bar\"", aw.getWritten());
|
try std.testing.expectEqualStrings(".@\"foo bar\"", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.ident("1foo");
|
try s.ident("1foo");
|
||||||
try std.testing.expectEqualStrings(".@\"1foo\"", aw.getWritten());
|
try std.testing.expectEqualStrings(".@\"1foo\"", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.ident("var");
|
try s.ident("var");
|
||||||
try std.testing.expectEqualStrings(".@\"var\"", aw.getWritten());
|
try std.testing.expectEqualStrings(".@\"var\"", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.ident("true");
|
try s.ident("true");
|
||||||
try std.testing.expectEqualStrings(".true", aw.getWritten());
|
try std.testing.expectEqualStrings(".true", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
try s.ident("_");
|
try s.ident("_");
|
||||||
try std.testing.expectEqualStrings("._", aw.getWritten());
|
try std.testing.expectEqualStrings("._", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
const Enum = enum {
|
const Enum = enum {
|
||||||
|
|
@ -1295,17 +1295,17 @@ test "std.zon stringify as tuple" {
|
||||||
|
|
||||||
// Tuples
|
// Tuples
|
||||||
try s.tuple(.{ 1, 2 }, .{});
|
try s.tuple(.{ 1, 2 }, .{});
|
||||||
try std.testing.expectEqualStrings(".{ 1, 2 }", aw.getWritten());
|
try std.testing.expectEqualStrings(".{ 1, 2 }", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
// Slice
|
// Slice
|
||||||
try s.tuple(@as([]const u8, &.{ 1, 2 }), .{});
|
try s.tuple(@as([]const u8, &.{ 1, 2 }), .{});
|
||||||
try std.testing.expectEqualStrings(".{ 1, 2 }", aw.getWritten());
|
try std.testing.expectEqualStrings(".{ 1, 2 }", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
// Array
|
// Array
|
||||||
try s.tuple([2]u8{ 1, 2 }, .{});
|
try s.tuple([2]u8{ 1, 2 }, .{});
|
||||||
try std.testing.expectEqualStrings(".{ 1, 2 }", aw.getWritten());
|
try std.testing.expectEqualStrings(".{ 1, 2 }", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1316,12 +1316,12 @@ test "std.zon stringify as float" {
|
||||||
|
|
||||||
// Comptime float
|
// Comptime float
|
||||||
try s.float(2.5);
|
try s.float(2.5);
|
||||||
try std.testing.expectEqualStrings("2.5", aw.getWritten());
|
try std.testing.expectEqualStrings("2.5", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
|
|
||||||
// Sized float
|
// Sized float
|
||||||
try s.float(@as(f32, 2.5));
|
try s.float(@as(f32, 2.5));
|
||||||
try std.testing.expectEqualStrings("2.5", aw.getWritten());
|
try std.testing.expectEqualStrings("2.5", aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1446,7 +1446,7 @@ test "std.zon tuple/struct field" {
|
||||||
\\ .b = 1,
|
\\ .b = 1,
|
||||||
\\ },
|
\\ },
|
||||||
\\}
|
\\}
|
||||||
, aw.getWritten());
|
, aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1478,7 +1478,7 @@ test "std.zon tuple/struct field" {
|
||||||
\\ .b = 1,
|
\\ .b = 1,
|
||||||
\\ },
|
\\ },
|
||||||
\\}
|
\\}
|
||||||
, aw.getWritten());
|
, aw.written());
|
||||||
aw.clearRetainingCapacity();
|
aw.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1123,7 +1123,7 @@ pub const CObject = struct {
|
||||||
var aw: Writer.Allocating = .init(eb.gpa);
|
var aw: Writer.Allocating = .init(eb.gpa);
|
||||||
defer aw.deinit();
|
defer aw.deinit();
|
||||||
_ = file_reader.interface.streamDelimiterEnding(&aw.writer, '\n') catch break :source_line 0;
|
_ = file_reader.interface.streamDelimiterEnding(&aw.writer, '\n') catch break :source_line 0;
|
||||||
break :source_line try eb.addString(aw.getWritten());
|
break :source_line try eb.addString(aw.written());
|
||||||
};
|
};
|
||||||
|
|
||||||
return .{
|
return .{
|
||||||
|
|
|
||||||
|
|
@ -2029,7 +2029,7 @@ const UnpackResult = struct {
|
||||||
\\ note: unable to create symlink from 'dir2/file2' to 'filename': SymlinkError
|
\\ note: unable to create symlink from 'dir2/file2' to 'filename': SymlinkError
|
||||||
\\ note: file 'dir2/file4' has unsupported type 'x'
|
\\ note: file 'dir2/file4' has unsupported type 'x'
|
||||||
\\
|
\\
|
||||||
, aw.getWritten());
|
, aw.written());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -2333,7 +2333,7 @@ const TestFetchBuilder = struct {
|
||||||
var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
|
var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
|
||||||
defer aw.deinit();
|
defer aw.deinit();
|
||||||
try errors.renderToWriter(.{ .ttyconf = .no_color }, &aw.writer);
|
try errors.renderToWriter(.{ .ttyconf = .no_color }, &aw.writer);
|
||||||
try std.testing.expectEqualStrings(msg, aw.getWritten());
|
try std.testing.expectEqualStrings(msg, aw.written());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
10
src/Sema.zig
10
src/Sema.zig
|
|
@ -3071,7 +3071,7 @@ pub fn createTypeName(
|
||||||
|
|
||||||
w.writeByte(')') catch return error.OutOfMemory;
|
w.writeByte(')') catch return error.OutOfMemory;
|
||||||
return .{
|
return .{
|
||||||
.name = try ip.getOrPutString(gpa, pt.tid, aw.getWritten(), .no_embedded_nulls),
|
.name = try ip.getOrPutString(gpa, pt.tid, aw.written(), .no_embedded_nulls),
|
||||||
.nav = .none,
|
.nav = .none,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
@ -5484,7 +5484,7 @@ fn zirCompileLog(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const line_data = try zcu.intern_pool.getOrPutString(gpa, pt.tid, aw.getWritten(), .no_embedded_nulls);
|
const line_data = try zcu.intern_pool.getOrPutString(gpa, pt.tid, aw.written(), .no_embedded_nulls);
|
||||||
|
|
||||||
const line_idx: Zcu.CompileLogLine.Index = if (zcu.free_compile_log_lines.pop()) |idx| idx: {
|
const line_idx: Zcu.CompileLogLine.Index = if (zcu.free_compile_log_lines.pop()) |idx| idx: {
|
||||||
zcu.compile_log_lines.items[@intFromEnum(idx)] = .{
|
zcu.compile_log_lines.items[@intFromEnum(idx)] = .{
|
||||||
|
|
@ -36892,11 +36892,11 @@ fn notePathToComptimeAllocPtr(
|
||||||
switch (deriv_start) {
|
switch (deriv_start) {
|
||||||
.int, .nav_ptr => unreachable,
|
.int, .nav_ptr => unreachable,
|
||||||
.uav_ptr => |uav| {
|
.uav_ptr => |uav| {
|
||||||
try sema.errNote(src, msg, "'{s}' points to '{s}', where", .{ first_path.items, second_path_aw.getWritten() });
|
try sema.errNote(src, msg, "'{s}' points to '{s}', where", .{ first_path.items, second_path_aw.written() });
|
||||||
return .{ .new_val = .fromInterned(uav.val) };
|
return .{ .new_val = .fromInterned(uav.val) };
|
||||||
},
|
},
|
||||||
.comptime_alloc_ptr => |cta_info| {
|
.comptime_alloc_ptr => |cta_info| {
|
||||||
try sema.errNote(src, msg, "'{s}' points to '{s}', where", .{ first_path.items, second_path_aw.getWritten() });
|
try sema.errNote(src, msg, "'{s}' points to '{s}', where", .{ first_path.items, second_path_aw.written() });
|
||||||
const cta = sema.getComptimeAlloc(cta_info.idx);
|
const cta = sema.getComptimeAlloc(cta_info.idx);
|
||||||
if (cta.is_const) {
|
if (cta.is_const) {
|
||||||
return .{ .new_val = cta_info.val };
|
return .{ .new_val = cta_info.val };
|
||||||
|
|
@ -36906,7 +36906,7 @@ fn notePathToComptimeAllocPtr(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.comptime_field_ptr => {
|
.comptime_field_ptr => {
|
||||||
try sema.errNote(src, msg, "'{s}' points to '{s}', where", .{ first_path.items, second_path_aw.getWritten() });
|
try sema.errNote(src, msg, "'{s}' points to '{s}', where", .{ first_path.items, second_path_aw.written() });
|
||||||
try sema.errNote(src, msg, "'{s}' is a comptime field", .{inter_name});
|
try sema.errNote(src, msg, "'{s}' is a comptime field", .{inter_name});
|
||||||
return .done;
|
return .done;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -728,7 +728,7 @@ pub const Object = struct {
|
||||||
}
|
}
|
||||||
fn outdent(o: *Object) !void {
|
fn outdent(o: *Object) !void {
|
||||||
o.indent_counter -= indent_width;
|
o.indent_counter -= indent_width;
|
||||||
const written = o.code.getWritten();
|
const written = o.code.written();
|
||||||
switch (written[written.len - 1]) {
|
switch (written[written.len - 1]) {
|
||||||
indent_char => o.code.shrinkRetainingCapacity(written.len - indent_width),
|
indent_char => o.code.shrinkRetainingCapacity(written.len - indent_width),
|
||||||
'\n' => try o.code.writer.splatByteAll(indent_char, o.indent_counter),
|
'\n' => try o.code.writer.splatByteAll(indent_char, o.indent_counter),
|
||||||
|
|
|
||||||
|
|
@ -341,7 +341,7 @@ fn fmtPathFile(
|
||||||
tree.render(gpa, &fmt.out_buffer.writer, .{}) catch |err| switch (err) {
|
tree.render(gpa, &fmt.out_buffer.writer, .{}) catch |err| switch (err) {
|
||||||
error.WriteFailed, error.OutOfMemory => return error.OutOfMemory,
|
error.WriteFailed, error.OutOfMemory => return error.OutOfMemory,
|
||||||
};
|
};
|
||||||
if (mem.eql(u8, fmt.out_buffer.getWritten(), source_code))
|
if (mem.eql(u8, fmt.out_buffer.written(), source_code))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (check_mode) {
|
if (check_mode) {
|
||||||
|
|
@ -351,7 +351,7 @@ fn fmtPathFile(
|
||||||
var af = try dir.atomicFile(sub_path, .{ .mode = stat.mode, .write_buffer = &.{} });
|
var af = try dir.atomicFile(sub_path, .{ .mode = stat.mode, .write_buffer = &.{} });
|
||||||
defer af.deinit();
|
defer af.deinit();
|
||||||
|
|
||||||
try af.file_writer.interface.writeAll(fmt.out_buffer.getWritten());
|
try af.file_writer.interface.writeAll(fmt.out_buffer.written());
|
||||||
try af.finish();
|
try af.finish();
|
||||||
try fmt.stdout_writer.interface.print("{s}\n", .{file_path});
|
try fmt.stdout_writer.interface.print("{s}\n", .{file_path});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -268,8 +268,8 @@ fn updateUav(self: *C, pt: Zcu.PerThread, i: usize) link.File.FlushError!void {
|
||||||
|
|
||||||
object.dg.ctype_pool.freeUnusedCapacity(gpa);
|
object.dg.ctype_pool.freeUnusedCapacity(gpa);
|
||||||
self.uavs.values()[i] = .{
|
self.uavs.values()[i] = .{
|
||||||
.fwd_decl = try self.addString(object.dg.fwd_decl.getWritten()),
|
.fwd_decl = try self.addString(object.dg.fwd_decl.written()),
|
||||||
.code = try self.addString(object.code.getWritten()),
|
.code = try self.addString(object.code.written()),
|
||||||
.ctype_pool = object.dg.ctype_pool.move(),
|
.ctype_pool = object.dg.ctype_pool.move(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -335,8 +335,8 @@ pub fn updateNav(self: *C, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) l
|
||||||
},
|
},
|
||||||
error.WriteFailed, error.OutOfMemory => return error.OutOfMemory,
|
error.WriteFailed, error.OutOfMemory => return error.OutOfMemory,
|
||||||
};
|
};
|
||||||
gop.value_ptr.fwd_decl = try self.addString(object.dg.fwd_decl.getWritten());
|
gop.value_ptr.fwd_decl = try self.addString(object.dg.fwd_decl.written());
|
||||||
gop.value_ptr.code = try self.addString(object.code.getWritten());
|
gop.value_ptr.code = try self.addString(object.code.written());
|
||||||
try self.addUavsFromCodegen(&object.dg.uavs);
|
try self.addUavsFromCodegen(&object.dg.uavs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -409,7 +409,7 @@ pub fn flush(self: *C, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: std.P
|
||||||
// Covers defines, zig.h, ctypes, asm, lazy fwd.
|
// Covers defines, zig.h, ctypes, asm, lazy fwd.
|
||||||
try f.all_buffers.ensureUnusedCapacity(gpa, 5);
|
try f.all_buffers.ensureUnusedCapacity(gpa, 5);
|
||||||
|
|
||||||
f.appendBufAssumeCapacity(abi_defines_aw.getWritten());
|
f.appendBufAssumeCapacity(abi_defines_aw.written());
|
||||||
f.appendBufAssumeCapacity(zig_h);
|
f.appendBufAssumeCapacity(zig_h);
|
||||||
|
|
||||||
const ctypes_index = f.all_buffers.items.len;
|
const ctypes_index = f.all_buffers.items.len;
|
||||||
|
|
@ -420,7 +420,7 @@ pub fn flush(self: *C, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: std.P
|
||||||
codegen.genGlobalAsm(zcu, &asm_aw.writer) catch |err| switch (err) {
|
codegen.genGlobalAsm(zcu, &asm_aw.writer) catch |err| switch (err) {
|
||||||
error.WriteFailed => return error.OutOfMemory,
|
error.WriteFailed => return error.OutOfMemory,
|
||||||
};
|
};
|
||||||
f.appendBufAssumeCapacity(asm_aw.getWritten());
|
f.appendBufAssumeCapacity(asm_aw.written());
|
||||||
|
|
||||||
const lazy_index = f.all_buffers.items.len;
|
const lazy_index = f.all_buffers.items.len;
|
||||||
f.all_buffers.items.len += 1;
|
f.all_buffers.items.len += 1;
|
||||||
|
|
@ -849,7 +849,7 @@ pub fn updateExports(
|
||||||
codegen.genExports(&dg, exported, export_indices) catch |err| switch (err) {
|
codegen.genExports(&dg, exported, export_indices) catch |err| switch (err) {
|
||||||
error.WriteFailed, error.OutOfMemory => return error.OutOfMemory,
|
error.WriteFailed, error.OutOfMemory => return error.OutOfMemory,
|
||||||
};
|
};
|
||||||
exported_block.* = .{ .fwd_decl = try self.addString(dg.fwd_decl.getWritten()) };
|
exported_block.* = .{ .fwd_decl = try self.addString(dg.fwd_decl.written()) };
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deleteExport(
|
pub fn deleteExport(
|
||||||
|
|
|
||||||
|
|
@ -748,7 +748,7 @@ const Unit = struct {
|
||||||
assert(tw.end == unit.trailer_len);
|
assert(tw.end == unit.trailer_len);
|
||||||
tw.splatByteAll(fill_byte, len - unit.trailer_len) catch unreachable;
|
tw.splatByteAll(fill_byte, len - unit.trailer_len) catch unreachable;
|
||||||
assert(tw.end == len);
|
assert(tw.end == len);
|
||||||
try dwarf.getFile().?.pwriteAll(trailer_aw.getWritten(), sec.off(dwarf) + start);
|
try dwarf.getFile().?.pwriteAll(trailer_aw.written(), sec.off(dwarf) + start);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolveRelocs(unit: *Unit, sec: *Section, dwarf: *Dwarf) RelocError!void {
|
fn resolveRelocs(unit: *Unit, sec: *Section, dwarf: *Dwarf) RelocError!void {
|
||||||
|
|
@ -1719,10 +1719,10 @@ pub const WipNav = struct {
|
||||||
else
|
else
|
||||||
std.leb.writeUnsignedFixed(
|
std.leb.writeUnsignedFixed(
|
||||||
block_bytes,
|
block_bytes,
|
||||||
wip_nav.debug_info.getWritten()[block.abbrev_code..][0..block_bytes],
|
wip_nav.debug_info.written()[block.abbrev_code..][0..block_bytes],
|
||||||
try wip_nav.dwarf.refAbbrevCode(.empty_block),
|
try wip_nav.dwarf.refAbbrevCode(.empty_block),
|
||||||
);
|
);
|
||||||
std.mem.writeInt(u32, wip_nav.debug_info.getWritten()[block.high_pc..][0..4], @intCast(code_off - block.low_pc_off), wip_nav.dwarf.endian);
|
std.mem.writeInt(u32, wip_nav.debug_info.written()[block.high_pc..][0..4], @intCast(code_off - block.low_pc_off), wip_nav.dwarf.endian);
|
||||||
wip_nav.any_children = true;
|
wip_nav.any_children = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1781,10 +1781,10 @@ pub const WipNav = struct {
|
||||||
else
|
else
|
||||||
std.leb.writeUnsignedFixed(
|
std.leb.writeUnsignedFixed(
|
||||||
inlined_func_bytes,
|
inlined_func_bytes,
|
||||||
wip_nav.debug_info.getWritten()[block.abbrev_code..][0..inlined_func_bytes],
|
wip_nav.debug_info.written()[block.abbrev_code..][0..inlined_func_bytes],
|
||||||
try wip_nav.dwarf.refAbbrevCode(.empty_inlined_func),
|
try wip_nav.dwarf.refAbbrevCode(.empty_inlined_func),
|
||||||
);
|
);
|
||||||
std.mem.writeInt(u32, wip_nav.debug_info.getWritten()[block.high_pc..][0..4], @intCast(code_off - block.low_pc_off), wip_nav.dwarf.endian);
|
std.mem.writeInt(u32, wip_nav.debug_info.written()[block.high_pc..][0..4], @intCast(code_off - block.low_pc_off), wip_nav.dwarf.endian);
|
||||||
try wip_nav.setInlineFunc(func);
|
try wip_nav.setInlineFunc(func);
|
||||||
wip_nav.any_children = true;
|
wip_nav.any_children = true;
|
||||||
}
|
}
|
||||||
|
|
@ -2282,7 +2282,7 @@ pub const WipNav = struct {
|
||||||
|
|
||||||
if (!is_generic_decl) return;
|
if (!is_generic_decl) return;
|
||||||
const generic_decl_entry = wip_nav.entry;
|
const generic_decl_entry = wip_nav.entry;
|
||||||
try dwarf.debug_info.section.replaceEntry(wip_nav.unit, generic_decl_entry, dwarf, wip_nav.debug_info.getWritten());
|
try dwarf.debug_info.section.replaceEntry(wip_nav.unit, generic_decl_entry, dwarf, wip_nav.debug_info.written());
|
||||||
wip_nav.debug_info.clearRetainingCapacity();
|
wip_nav.debug_info.clearRetainingCapacity();
|
||||||
wip_nav.entry = orig_entry;
|
wip_nav.entry = orig_entry;
|
||||||
try wip_nav.abbrevCode(abbrev_code.decl_instance);
|
try wip_nav.abbrevCode(abbrev_code.decl_instance);
|
||||||
|
|
@ -2851,7 +2851,7 @@ fn finishWipNavFuncWriterError(
|
||||||
DW.CFA.nop,
|
DW.CFA.nop,
|
||||||
@intCast(dwarf.debug_frame.section.alignment.forward(dfw.end) - dfw.end),
|
@intCast(dwarf.debug_frame.section.alignment.forward(dfw.end) - dfw.end),
|
||||||
);
|
);
|
||||||
const contents = wip_nav.debug_frame.getWritten();
|
const contents = wip_nav.debug_frame.written();
|
||||||
try dwarf.debug_frame.section.resizeEntry(wip_nav.unit, wip_nav.entry, dwarf, @intCast(contents.len));
|
try dwarf.debug_frame.section.resizeEntry(wip_nav.unit, wip_nav.entry, dwarf, @intCast(contents.len));
|
||||||
const unit = dwarf.debug_frame.section.getUnit(wip_nav.unit);
|
const unit = dwarf.debug_frame.section.getUnit(wip_nav.unit);
|
||||||
const entry = unit.getEntry(wip_nav.entry);
|
const entry = unit.getEntry(wip_nav.entry);
|
||||||
|
|
@ -2878,12 +2878,12 @@ fn finishWipNavFuncWriterError(
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std.mem.writeInt(u32, wip_nav.debug_info.getWritten()[wip_nav.func_high_pc..][0..4], @intCast(code_size), dwarf.endian);
|
std.mem.writeInt(u32, wip_nav.debug_info.written()[wip_nav.func_high_pc..][0..4], @intCast(code_size), dwarf.endian);
|
||||||
if (wip_nav.any_children) {
|
if (wip_nav.any_children) {
|
||||||
const diw = &wip_nav.debug_info.writer;
|
const diw = &wip_nav.debug_info.writer;
|
||||||
try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
|
try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
|
||||||
} else {
|
} else {
|
||||||
const abbrev_code_buf = wip_nav.debug_info.getWritten()[0..AbbrevCode.decl_bytes];
|
const abbrev_code_buf = wip_nav.debug_info.written()[0..AbbrevCode.decl_bytes];
|
||||||
var abbrev_code_fr: std.Io.Reader = .fixed(abbrev_code_buf);
|
var abbrev_code_fr: std.Io.Reader = .fixed(abbrev_code_buf);
|
||||||
const abbrev_code: AbbrevCode = @enumFromInt(
|
const abbrev_code: AbbrevCode = @enumFromInt(
|
||||||
abbrev_code_fr.takeLeb128(@typeInfo(AbbrevCode).@"enum".tag_type) catch unreachable,
|
abbrev_code_fr.takeLeb128(@typeInfo(AbbrevCode).@"enum".tag_type) catch unreachable,
|
||||||
|
|
@ -2944,15 +2944,15 @@ fn finishWipNavWriterError(
|
||||||
const nav = ip.getNav(nav_index);
|
const nav = ip.getNav(nav_index);
|
||||||
log.debug("finishWipNav({f})", .{nav.fqn.fmt(ip)});
|
log.debug("finishWipNav({f})", .{nav.fqn.fmt(ip)});
|
||||||
|
|
||||||
try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.getWritten());
|
try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.written());
|
||||||
const dlw = &wip_nav.debug_line.writer;
|
const dlw = &wip_nav.debug_line.writer;
|
||||||
if (dlw.end > 0) {
|
if (dlw.end > 0) {
|
||||||
try dlw.writeByte(DW.LNS.extended_op);
|
try dlw.writeByte(DW.LNS.extended_op);
|
||||||
try dlw.writeUleb128(1);
|
try dlw.writeUleb128(1);
|
||||||
try dlw.writeByte(DW.LNE.end_sequence);
|
try dlw.writeByte(DW.LNE.end_sequence);
|
||||||
try dwarf.debug_line.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_line.getWritten());
|
try dwarf.debug_line.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_line.written());
|
||||||
}
|
}
|
||||||
try dwarf.debug_loclists.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_loclists.getWritten());
|
try dwarf.debug_loclists.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_loclists.written());
|
||||||
|
|
||||||
try wip_nav.updateLazy(zcu.navSrcLoc(nav_index));
|
try wip_nav.updateLazy(zcu.navSrcLoc(nav_index));
|
||||||
}
|
}
|
||||||
|
|
@ -3407,7 +3407,7 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo
|
||||||
try wip_nav.refNav(owner_nav);
|
try wip_nav.refNav(owner_nav);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.getWritten());
|
try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.written());
|
||||||
try wip_nav.updateLazy(nav_src_loc);
|
try wip_nav.updateLazy(nav_src_loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3914,7 +3914,7 @@ fn updateLazyType(
|
||||||
.memoized_call,
|
.memoized_call,
|
||||||
=> unreachable,
|
=> unreachable,
|
||||||
}
|
}
|
||||||
try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.getWritten());
|
try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.written());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn updateLazyValue(
|
fn updateLazyValue(
|
||||||
|
|
@ -4288,7 +4288,7 @@ fn updateLazyValue(
|
||||||
},
|
},
|
||||||
.memoized_call => unreachable, // not a value
|
.memoized_call => unreachable, // not a value
|
||||||
}
|
}
|
||||||
try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.getWritten());
|
try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.written());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn optRepr(opt_child_type: Type, zcu: *const Zcu) enum {
|
fn optRepr(opt_child_type: Type, zcu: *const Zcu) enum {
|
||||||
|
|
@ -4411,7 +4411,7 @@ fn updateContainerTypeWriterError(
|
||||||
try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
|
try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
|
||||||
}
|
}
|
||||||
|
|
||||||
try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.getWritten());
|
try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.written());
|
||||||
try wip_nav.updateLazy(ty_src_loc);
|
try wip_nav.updateLazy(ty_src_loc);
|
||||||
} else {
|
} else {
|
||||||
{
|
{
|
||||||
|
|
@ -4611,8 +4611,8 @@ fn updateContainerTypeWriterError(
|
||||||
},
|
},
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
}
|
}
|
||||||
try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.getWritten());
|
try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.written());
|
||||||
try dwarf.debug_loclists.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_loclists.getWritten());
|
try dwarf.debug_loclists.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_loclists.written());
|
||||||
try wip_nav.updateLazy(ty_src_loc);
|
try wip_nav.updateLazy(ty_src_loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4661,7 +4661,7 @@ fn refAbbrevCode(
|
||||||
try daw.writeByte(if (abbrev.children) DW.CHILDREN.yes else DW.CHILDREN.no);
|
try daw.writeByte(if (abbrev.children) DW.CHILDREN.yes else DW.CHILDREN.no);
|
||||||
for (abbrev.attrs) |*attr| inline for (attr) |info| try daw.writeUleb128(@intFromEnum(info));
|
for (abbrev.attrs) |*attr| inline for (attr) |info| try daw.writeUleb128(@intFromEnum(info));
|
||||||
for (0..2) |_| try daw.writeUleb128(0);
|
for (0..2) |_| try daw.writeUleb128(0);
|
||||||
try dwarf.debug_abbrev.section.replaceEntry(DebugAbbrev.unit, entry, dwarf, debug_abbrev_aw.getWritten());
|
try dwarf.debug_abbrev.section.replaceEntry(DebugAbbrev.unit, entry, dwarf, debug_abbrev_aw.written());
|
||||||
return @intFromEnum(abbrev_code);
|
return @intFromEnum(abbrev_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4710,7 +4710,7 @@ fn flushWriterError(dwarf: *Dwarf, pt: Zcu.PerThread) (FlushError || Writer.Erro
|
||||||
try wip_nav.strp(name.toSlice(ip));
|
try wip_nav.strp(name.toSlice(ip));
|
||||||
}
|
}
|
||||||
if (global_error_set_names.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
|
if (global_error_set_names.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
|
||||||
try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.getWritten());
|
try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.written());
|
||||||
try wip_nav.updateLazy(.unneeded);
|
try wip_nav.updateLazy(.unneeded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4751,7 +4751,7 @@ fn flushWriterError(dwarf: *Dwarf, pt: Zcu.PerThread) (FlushError || Writer.Erro
|
||||||
hw.writeByte(@intFromEnum(dwarf.address_size)) catch unreachable;
|
hw.writeByte(@intFromEnum(dwarf.address_size)) catch unreachable;
|
||||||
hw.writeByte(0) catch unreachable;
|
hw.writeByte(0) catch unreachable;
|
||||||
hw.splatByteAll(0, unit_ptr.header_len - hw.end) catch unreachable;
|
hw.splatByteAll(0, unit_ptr.header_len - hw.end) catch unreachable;
|
||||||
try unit_ptr.replaceHeader(&dwarf.debug_aranges.section, dwarf, header_aw.getWritten());
|
try unit_ptr.replaceHeader(&dwarf.debug_aranges.section, dwarf, header_aw.written());
|
||||||
try unit_ptr.writeTrailer(&dwarf.debug_aranges.section, dwarf);
|
try unit_ptr.writeTrailer(&dwarf.debug_aranges.section, dwarf);
|
||||||
}
|
}
|
||||||
dwarf.debug_aranges.section.dirty = false;
|
dwarf.debug_aranges.section.dirty = false;
|
||||||
|
|
@ -4790,7 +4790,7 @@ fn flushWriterError(dwarf: *Dwarf, pt: Zcu.PerThread) (FlushError || Writer.Erro
|
||||||
hw.writeByte(@as(u8, DW.CFA.offset) + Register.rip.dwarfNum()) catch unreachable;
|
hw.writeByte(@as(u8, DW.CFA.offset) + Register.rip.dwarfNum()) catch unreachable;
|
||||||
hw.writeUleb128(1) catch unreachable;
|
hw.writeUleb128(1) catch unreachable;
|
||||||
hw.splatByteAll(DW.CFA.nop, unit.header_len - hw.end) catch unreachable;
|
hw.splatByteAll(DW.CFA.nop, unit.header_len - hw.end) catch unreachable;
|
||||||
try unit.replaceHeader(&dwarf.debug_frame.section, dwarf, header_aw.getWritten());
|
try unit.replaceHeader(&dwarf.debug_frame.section, dwarf, header_aw.written());
|
||||||
try unit.writeTrailer(&dwarf.debug_frame.section, dwarf);
|
try unit.writeTrailer(&dwarf.debug_frame.section, dwarf);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -4880,7 +4880,7 @@ fn flushWriterError(dwarf: *Dwarf, pt: Zcu.PerThread) (FlushError || Writer.Erro
|
||||||
});
|
});
|
||||||
hw.splatByteAll(0, dwarf.sectionOffsetBytes()) catch unreachable;
|
hw.splatByteAll(0, dwarf.sectionOffsetBytes()) catch unreachable;
|
||||||
hw.writeUleb128(0) catch unreachable;
|
hw.writeUleb128(0) catch unreachable;
|
||||||
try unit_ptr.replaceHeader(&dwarf.debug_info.section, dwarf, header_aw.getWritten());
|
try unit_ptr.replaceHeader(&dwarf.debug_info.section, dwarf, header_aw.written());
|
||||||
try unit_ptr.writeTrailer(&dwarf.debug_info.section, dwarf);
|
try unit_ptr.writeTrailer(&dwarf.debug_info.section, dwarf);
|
||||||
}
|
}
|
||||||
dwarf.debug_info.section.dirty = false;
|
dwarf.debug_info.section.dirty = false;
|
||||||
|
|
@ -4997,7 +4997,7 @@ fn flushWriterError(dwarf: *Dwarf, pt: Zcu.PerThread) (FlushError || Writer.Erro
|
||||||
});
|
});
|
||||||
hw.splatByteAll(0, dwarf.sectionOffsetBytes()) catch unreachable;
|
hw.splatByteAll(0, dwarf.sectionOffsetBytes()) catch unreachable;
|
||||||
}
|
}
|
||||||
try unit.replaceHeader(&dwarf.debug_line.section, dwarf, header_aw.getWritten());
|
try unit.replaceHeader(&dwarf.debug_line.section, dwarf, header_aw.written());
|
||||||
try unit.writeTrailer(&dwarf.debug_line.section, dwarf);
|
try unit.writeTrailer(&dwarf.debug_line.section, dwarf);
|
||||||
}
|
}
|
||||||
dwarf.debug_line.section.dirty = false;
|
dwarf.debug_line.section.dirty = false;
|
||||||
|
|
@ -5034,7 +5034,7 @@ fn flushWriterError(dwarf: *Dwarf, pt: Zcu.PerThread) (FlushError || Writer.Erro
|
||||||
.@"32" => hw.writeInt(u32, dwarf.sectionOffsetBytes() * 1, dwarf.endian) catch unreachable,
|
.@"32" => hw.writeInt(u32, dwarf.sectionOffsetBytes() * 1, dwarf.endian) catch unreachable,
|
||||||
.@"64" => hw.writeInt(u64, dwarf.sectionOffsetBytes() * 1, dwarf.endian) catch unreachable,
|
.@"64" => hw.writeInt(u64, dwarf.sectionOffsetBytes() * 1, dwarf.endian) catch unreachable,
|
||||||
}
|
}
|
||||||
try unit.replaceHeader(&dwarf.debug_rnglists.section, dwarf, header_aw.getWritten());
|
try unit.replaceHeader(&dwarf.debug_rnglists.section, dwarf, header_aw.written());
|
||||||
try unit.writeTrailer(&dwarf.debug_rnglists.section, dwarf);
|
try unit.writeTrailer(&dwarf.debug_rnglists.section, dwarf);
|
||||||
}
|
}
|
||||||
dwarf.debug_rnglists.section.dirty = false;
|
dwarf.debug_rnglists.section.dirty = false;
|
||||||
|
|
|
||||||
|
|
@ -3156,7 +3156,7 @@ fn writeSyntheticSections(self: *Elf) !void {
|
||||||
try aw.ensureUnusedCapacity(self.gnu_hash.size());
|
try aw.ensureUnusedCapacity(self.gnu_hash.size());
|
||||||
defer aw.deinit();
|
defer aw.deinit();
|
||||||
try self.gnu_hash.write(self, &aw.writer);
|
try self.gnu_hash.write(self, &aw.writer);
|
||||||
try self.pwriteAll(aw.getWritten(), shdr.sh_offset);
|
try self.pwriteAll(aw.written(), shdr.sh_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.section_indexes.versym) |shndx| {
|
if (self.section_indexes.versym) |shndx| {
|
||||||
|
|
|
||||||
|
|
@ -274,7 +274,7 @@ pub fn flush(
|
||||||
) catch return error.OutOfMemory;
|
) catch return error.OutOfMemory;
|
||||||
}
|
}
|
||||||
try linker.module.sections.debug_strings.emit(gpa, .OpSourceExtension, .{
|
try linker.module.sections.debug_strings.emit(gpa, .OpSourceExtension, .{
|
||||||
.extension = error_info.getWritten(),
|
.extension = error_info.written(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const module = try linker.module.finalize(arena);
|
const module = try linker.module.finalize(arena);
|
||||||
|
|
|
||||||
|
|
@ -7198,7 +7198,7 @@ fn cmdFetch(
|
||||||
var aw: std.Io.Writer.Allocating = .init(gpa);
|
var aw: std.Io.Writer.Allocating = .init(gpa);
|
||||||
defer aw.deinit();
|
defer aw.deinit();
|
||||||
try ast.render(gpa, &aw.writer, fixups);
|
try ast.render(gpa, &aw.writer, fixups);
|
||||||
const rendered = aw.getWritten();
|
const rendered = aw.written();
|
||||||
|
|
||||||
build_root.directory.handle.writeFile(.{ .sub_path = Package.Manifest.basename, .data = rendered }) catch |err| {
|
build_root.directory.handle.writeFile(.{ .sub_path = Package.Manifest.basename, .data = rendered }) catch |err| {
|
||||||
fatal("unable to write {s} file: {t}", .{ Package.Manifest.basename, err });
|
fatal("unable to write {s} file: {t}", .{ Package.Manifest.basename, err });
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue