authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-01-09 13:04:08-08:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2021-01-09 13:04:08-08:00
log29928af6005997d2b02b4c3a3576a696a02fa269
tree9852e606adc5bc065e758482445bb6d1c5ead99c
parenta0ad2dee6a0b3bb7fd04032f6113206f7b4e73eb
parente72472d953f5e91d37bc5f1bf1ec7b6fb5b1afe2
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #7729 from jayschwa/remove-deprecated-stream

Remove deprecated stream aliases

32 files changed, 98 insertions(+), 324 deletions(-)

CMakeLists.txt+1-1
......@@ -377,7 +377,7 @@ set(ZIG_STAGE2_SOURCES
377377 "${CMAKE_SOURCE_DIR}/lib/std/io/change_detection_stream.zig"
378378 "${CMAKE_SOURCE_DIR}/lib/std/io/counting_writer.zig"
379379 "${CMAKE_SOURCE_DIR}/lib/std/io/counting_reader.zig"
380 "${CMAKE_SOURCE_DIR}/lib/std/io/find_byte_out_stream.zig"
380 "${CMAKE_SOURCE_DIR}/lib/std/io/find_byte_writer.zig"
381381 "${CMAKE_SOURCE_DIR}/lib/std/io/fixed_buffer_stream.zig"
382382 "${CMAKE_SOURCE_DIR}/lib/std/io/reader.zig"
383383 "${CMAKE_SOURCE_DIR}/lib/std/io/seekable_stream.zig"
doc/langref.html.in+3-3
......@@ -6120,7 +6120,7 @@ pub fn main() void {
61206120
61216121 {#code_begin|syntax#}
61226122/// Calls print and then flushes the buffer.
6123pub fn printf(self: *OutStream, comptime format: []const u8, args: anytype) anyerror!void {
6123pub fn printf(self: *Writer, comptime format: []const u8, args: anytype) anyerror!void {
61246124 const State = enum {
61256125 start,
61266126 open_brace,
......@@ -6192,7 +6192,7 @@ pub fn printf(self: *OutStream, comptime format: []const u8, args: anytype) anye
61926192 and emits a function that actually looks like this:
61936193 </p>
61946194 {#code_begin|syntax#}
6195pub fn printf(self: *OutStream, arg0: i32, arg1: []const u8) !void {
6195pub fn printf(self: *Writer, arg0: i32, arg1: []const u8) !void {
61966196 try self.write("here is a string: '");
61976197 try self.printValue(arg0);
61986198 try self.write("' here is a number: ");
......@@ -6206,7 +6206,7 @@ pub fn printf(self: *OutStream, arg0: i32, arg1: []const u8) !void {
62066206 on the type:
62076207 </p>
62086208 {#code_begin|syntax#}
6209pub fn printValue(self: *OutStream, value: anytype) !void {
6209pub fn printValue(self: *Writer, value: anytype) !void {
62106210 switch (@typeInfo(@TypeOf(value))) {
62116211 .Int => {
62126212 return self.printInt(T, value);
lib/std/array_list.zig-3
......@@ -242,9 +242,6 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
242242 return .{ .context = self };
243243 }
244244
245 /// Deprecated: use `writer`
246 pub const outStream = writer;
247
248245 /// Same as `append` except it returns the number of bytes written, which is always the same
249246 /// as `m.len`. The purpose of this function existing is to match `std.io.Writer` API.
250247 fn appendWrite(self: *Self, m: []const u8) !usize {
lib/std/fifo.zig+1-11
......@@ -232,11 +232,6 @@ pub fn LinearFifo(
232232 return .{ .context = self };
233233 }
234234
235 /// Deprecated: `use reader`
236 pub fn inStream(self: *Self) std.io.InStream(*Self, error{}, readFn) {
237 return .{ .context = self };
238 }
239
240235 /// Returns number of items available in fifo
241236 pub fn writableLength(self: Self) usize {
242237 return self.buf.len - self.count;
......@@ -317,7 +312,7 @@ pub fn LinearFifo(
317312 }
318313
319314 /// Same as `write` except it returns the number of bytes written, which is always the same
320 /// as `bytes.len`. The purpose of this function existing is to match `std.io.OutStream` API.
315 /// as `bytes.len`. The purpose of this function existing is to match `std.io.Writer` API.
321316 fn appendWrite(self: *Self, bytes: []const u8) error{OutOfMemory}!usize {
322317 try self.write(bytes);
323318 return bytes.len;
......@@ -327,11 +322,6 @@ pub fn LinearFifo(
327322 return .{ .context = self };
328323 }
329324
330 /// Deprecated: `use writer`
331 pub fn outStream(self: *Self) std.io.OutStream(*Self, error{OutOfMemory}, appendWrite) {
332 return .{ .context = self };
333 }
334
335325 /// Make `count` items available before the current read location
336326 fn rewind(self: *Self, count: usize) void {
337327 assert(self.writableLength() >= count);
lib/std/fs/file.zig-16
......@@ -813,32 +813,16 @@ pub const File = struct {
813813
814814 pub const Reader = io.Reader(File, ReadError, read);
815815
816 /// Deprecated: use `Reader`
817 pub const InStream = Reader;
818
819816 pub fn reader(file: File) Reader {
820817 return .{ .context = file };
821818 }
822819
823 /// Deprecated: use `reader`
824 pub fn inStream(file: File) Reader {
825 return .{ .context = file };
826 }
827
828820 pub const Writer = io.Writer(File, WriteError, write);
829821
830 /// Deprecated: use `Writer`
831 pub const OutStream = Writer;
832
833822 pub fn writer(file: File) Writer {
834823 return .{ .context = file };
835824 }
836825
837 /// Deprecated: use `writer`
838 pub fn outStream(file: File) Writer {
839 return .{ .context = file };
840 }
841
842826 pub const SeekableStream = io.SeekableStream(
843827 File,
844828 SeekError,
lib/std/heap/logging_allocator.zig+15-15
......@@ -9,22 +9,22 @@ const Allocator = std.mem.Allocator;
99/// This allocator is used in front of another allocator and logs to the provided stream
1010/// on every call to the allocator. Stream errors are ignored.
1111/// If https://github.com/ziglang/zig/issues/2586 is implemented, this API can be improved.
12pub fn LoggingAllocator(comptime OutStreamType: type) type {
12pub fn LoggingAllocator(comptime Writer: type) type {
1313 return struct {
1414 allocator: Allocator,
1515 parent_allocator: *Allocator,
16 out_stream: OutStreamType,
16 writer: Writer,
1717
1818 const Self = @This();
1919
20 pub fn init(parent_allocator: *Allocator, out_stream: OutStreamType) Self {
20 pub fn init(parent_allocator: *Allocator, writer: Writer) Self {
2121 return Self{
2222 .allocator = Allocator{
2323 .allocFn = alloc,
2424 .resizeFn = resize,
2525 },
2626 .parent_allocator = parent_allocator,
27 .out_stream = out_stream,
27 .writer = writer,
2828 };
2929 }
3030
......@@ -36,12 +36,12 @@ pub fn LoggingAllocator(comptime OutStreamType: type) type {
3636 ra: usize,
3737 ) error{OutOfMemory}![]u8 {
3838 const self = @fieldParentPtr(Self, "allocator", allocator);
39 self.out_stream.print("alloc : {}", .{len}) catch {};
39 self.writer.print("alloc : {}", .{len}) catch {};
4040 const result = self.parent_allocator.allocFn(self.parent_allocator, len, ptr_align, len_align, ra);
4141 if (result) |buff| {
42 self.out_stream.print(" success!\n", .{}) catch {};
42 self.writer.print(" success!\n", .{}) catch {};
4343 } else |err| {
44 self.out_stream.print(" failure!\n", .{}) catch {};
44 self.writer.print(" failure!\n", .{}) catch {};
4545 }
4646 return result;
4747 }
......@@ -56,20 +56,20 @@ pub fn LoggingAllocator(comptime OutStreamType: type) type {
5656 ) error{OutOfMemory}!usize {
5757 const self = @fieldParentPtr(Self, "allocator", allocator);
5858 if (new_len == 0) {
59 self.out_stream.print("free : {}\n", .{buf.len}) catch {};
59 self.writer.print("free : {}\n", .{buf.len}) catch {};
6060 } else if (new_len <= buf.len) {
61 self.out_stream.print("shrink: {} to {}\n", .{ buf.len, new_len }) catch {};
61 self.writer.print("shrink: {} to {}\n", .{ buf.len, new_len }) catch {};
6262 } else {
63 self.out_stream.print("expand: {} to {}", .{ buf.len, new_len }) catch {};
63 self.writer.print("expand: {} to {}", .{ buf.len, new_len }) catch {};
6464 }
6565 if (self.parent_allocator.resizeFn(self.parent_allocator, buf, buf_align, new_len, len_align, ra)) |resized_len| {
6666 if (new_len > buf.len) {
67 self.out_stream.print(" success!\n", .{}) catch {};
67 self.writer.print(" success!\n", .{}) catch {};
6868 }
6969 return resized_len;
7070 } else |e| {
7171 std.debug.assert(new_len > buf.len);
72 self.out_stream.print(" failure!\n", .{}) catch {};
72 self.writer.print(" failure!\n", .{}) catch {};
7373 return e;
7474 }
7575 }
......@@ -78,9 +78,9 @@ pub fn LoggingAllocator(comptime OutStreamType: type) type {
7878
7979pub fn loggingAllocator(
8080 parent_allocator: *Allocator,
81 out_stream: anytype,
82) LoggingAllocator(@TypeOf(out_stream)) {
83 return LoggingAllocator(@TypeOf(out_stream)).init(parent_allocator, out_stream);
81 writer: anytype,
82) LoggingAllocator(@TypeOf(writer)) {
83 return LoggingAllocator(@TypeOf(writer)).init(parent_allocator, writer);
8484}
8585
8686test "LoggingAllocator" {
lib/std/io.zig+6-39
......@@ -107,26 +107,14 @@ pub fn getStdIn() File {
107107}
108108
109109pub const Reader = @import("io/reader.zig").Reader;
110/// Deprecated: use `Reader`
111pub const InStream = Reader;
112110pub const Writer = @import("io/writer.zig").Writer;
113/// Deprecated: use `Writer`
114pub const OutStream = Writer;
115111pub const SeekableStream = @import("io/seekable_stream.zig").SeekableStream;
116112
117113pub const BufferedWriter = @import("io/buffered_writer.zig").BufferedWriter;
118114pub const bufferedWriter = @import("io/buffered_writer.zig").bufferedWriter;
119/// Deprecated: use `BufferedWriter`
120pub const BufferedOutStream = BufferedWriter;
121/// Deprecated: use `bufferedWriter`
122pub const bufferedOutStream = bufferedWriter;
123115
124116pub const BufferedReader = @import("io/buffered_reader.zig").BufferedReader;
125117pub const bufferedReader = @import("io/buffered_reader.zig").bufferedReader;
126/// Deprecated: use `BufferedReader`
127pub const BufferedInStream = BufferedReader;
128/// Deprecated: use `bufferedReader`
129pub const bufferedInStream = bufferedReader;
130118
131119pub const PeekStream = @import("io/peek_stream.zig").PeekStream;
132120pub const peekStream = @import("io/peek_stream.zig").peekStream;
......@@ -136,40 +124,20 @@ pub const fixedBufferStream = @import("io/fixed_buffer_stream.zig").fixedBufferS
136124
137125pub const CWriter = @import("io/c_writer.zig").CWriter;
138126pub const cWriter = @import("io/c_writer.zig").cWriter;
139/// Deprecated: use `CWriter`
140pub const COutStream = CWriter;
141/// Deprecated: use `cWriter`
142pub const cOutStream = cWriter;
143127
144128pub const CountingWriter = @import("io/counting_writer.zig").CountingWriter;
145129pub const countingWriter = @import("io/counting_writer.zig").countingWriter;
146130pub const CountingReader = @import("io/counting_reader.zig").CountingReader;
147131pub const countingReader = @import("io/counting_reader.zig").countingReader;
148/// Deprecated: use `CountingWriter`
149pub const CountingOutStream = CountingWriter;
150/// Deprecated: use `countingWriter`
151pub const countingOutStream = countingWriter;
152132
153133pub const MultiWriter = @import("io/multi_writer.zig").MultiWriter;
154134pub const multiWriter = @import("io/multi_writer.zig").multiWriter;
155/// Deprecated: use `MultiWriter`
156pub const MultiOutStream = MultiWriter;
157/// Deprecated: use `multiWriter`
158pub const multiOutStream = multiWriter;
159135
160136pub const BitReader = @import("io/bit_reader.zig").BitReader;
161137pub const bitReader = @import("io/bit_reader.zig").bitReader;
162/// Deprecated: use `BitReader`
163pub const BitInStream = BitReader;
164/// Deprecated: use `bitReader`
165pub const bitInStream = bitReader;
166138
167139pub const BitWriter = @import("io/bit_writer.zig").BitWriter;
168140pub const bitWriter = @import("io/bit_writer.zig").bitWriter;
169/// Deprecated: use `BitWriter`
170pub const BitOutStream = BitWriter;
171/// Deprecated: use `bitWriter`
172pub const bitOutStream = bitWriter;
173141
174142pub const AutoIndentingStream = @import("io/auto_indenting_stream.zig").AutoIndentingStream;
175143pub const autoIndentingStream = @import("io/auto_indenting_stream.zig").autoIndentingStream;
......@@ -177,8 +145,12 @@ pub const autoIndentingStream = @import("io/auto_indenting_stream.zig").autoInde
177145pub const ChangeDetectionStream = @import("io/change_detection_stream.zig").ChangeDetectionStream;
178146pub const changeDetectionStream = @import("io/change_detection_stream.zig").changeDetectionStream;
179147
180pub const FindByteOutStream = @import("io/find_byte_out_stream.zig").FindByteOutStream;
181pub const findByteOutStream = @import("io/find_byte_out_stream.zig").findByteOutStream;
148pub const FindByteWriter = @import("io/find_byte_writer.zig").FindByteWriter;
149pub const findByteWriter = @import("io/find_byte_writer.zig").findByteWriter;
150/// Deprecated: use `FindByteWriter`.
151pub const FindByteOutStream = FindByteWriter;
152/// Deprecated: use `findByteWriter`.
153pub const findByteOutStream = findByteWriter;
182154
183155pub const BufferedAtomicFile = @import("io/buffered_atomic_file.zig").BufferedAtomicFile;
184156
......@@ -187,12 +159,7 @@ pub const StreamSource = @import("io/stream_source.zig").StreamSource;
187159/// A Writer that doesn't write to anything.
188160pub const null_writer = @as(NullWriter, .{ .context = {} });
189161
190/// Deprecated: use `null_writer`
191pub const null_out_stream = null_writer;
192
193162const NullWriter = Writer(void, error{}, dummyWrite);
194/// Deprecated: use NullWriter
195const NullOutStream = NullWriter;
196163fn dummyWrite(context: void, data: []const u8) error{}!usize {
197164 return data.len;
198165}
lib/std/io/bit_in_stream.zig deleted-10
......@@ -1,10 +0,0 @@
1// SPDX-License-Identifier: MIT
2// Copyright (c) 2015-2021 Zig Contributors
3// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
4// The MIT license requires this copyright notice to be included in all copies
5// and substantial portions of the software.
6/// Deprecated: use `std.io.bit_reader.BitReader`
7pub const BitInStream = @import("./bit_reader.zig").BitReader;
8
9/// Deprecated: use `std.io.bit_reader.bitReader`
10pub const bitInStream = @import("./bit_reader.zig").bitReader;
lib/std/io/bit_out_stream.zig deleted-10
......@@ -1,10 +0,0 @@
1// SPDX-License-Identifier: MIT
2// Copyright (c) 2015-2021 Zig Contributors
3// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
4// The MIT license requires this copyright notice to be included in all copies
5// and substantial portions of the software.
6/// Deprecated: use `std.io.bit_writer.BitWriter`
7pub const BitOutStream = @import("./bit_writer.zig").BitWriter;
8
9/// Deprecated: use `std.io.bit_writer.bitWriter`
10pub const bitOutStream = @import("./bit_writer.zig").bitWriter;
lib/std/io/bit_reader.zig-7
......@@ -21,8 +21,6 @@ pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type {
2121
2222 pub const Error = ReaderType.Error;
2323 pub const Reader = io.Reader(*Self, Error, read);
24 /// Deprecated: use `Reader`
25 pub const InStream = io.InStream(*Self, Error, read);
2624
2725 const Self = @This();
2826 const u8_bit_count = comptime meta.bitCount(u8);
......@@ -165,11 +163,6 @@ pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type {
165163 pub fn reader(self: *Self) Reader {
166164 return .{ .context = self };
167165 }
168
169 /// Deprecated: use `reader`
170 pub fn inStream(self: *Self) InStream {
171 return .{ .context = self };
172 }
173166 };
174167}
175168
lib/std/io/bit_writer.zig-6
......@@ -21,8 +21,6 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type {
2121
2222 pub const Error = WriterType.Error;
2323 pub const Writer = io.Writer(*Self, Error, write);
24 /// Deprecated: use `Writer`
25 pub const OutStream = io.OutStream(*Self, Error, write);
2624
2725 const Self = @This();
2826 const u8_bit_count = comptime meta.bitCount(u8);
......@@ -141,10 +139,6 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type {
141139 pub fn writer(self: *Self) Writer {
142140 return .{ .context = self };
143141 }
144 /// Deprecated: use `writer`
145 pub fn outStream(self: *Self) OutStream {
146 return .{ .context = self };
147 }
148142 };
149143}
150144
lib/std/io/buffered_atomic_file.zig+11-11
......@@ -10,13 +10,13 @@ const File = std.fs.File;
1010
1111pub const BufferedAtomicFile = struct {
1212 atomic_file: fs.AtomicFile,
13 file_stream: File.OutStream,
14 buffered_stream: BufferedOutStream,
13 file_writer: File.Writer,
14 buffered_writer: BufferedWriter,
1515 allocator: *mem.Allocator,
1616
1717 pub const buffer_size = 4096;
18 pub const BufferedOutStream = std.io.BufferedOutStream(buffer_size, File.OutStream);
19 pub const OutStream = std.io.OutStream(*BufferedOutStream, BufferedOutStream.Error, BufferedOutStream.write);
18 pub const BufferedWriter = std.io.BufferedWriter(buffer_size, File.Writer);
19 pub const Writer = std.io.Writer(*BufferedWriter, BufferedWriter.Error, BufferedWriter.write);
2020
2121 /// TODO when https://github.com/ziglang/zig/issues/2761 is solved
2222 /// this API will not need an allocator
......@@ -29,8 +29,8 @@ pub const BufferedAtomicFile = struct {
2929 var self = try allocator.create(BufferedAtomicFile);
3030 self.* = BufferedAtomicFile{
3131 .atomic_file = undefined,
32 .file_stream = undefined,
33 .buffered_stream = undefined,
32 .file_writer = undefined,
33 .buffered_writer = undefined,
3434 .allocator = allocator,
3535 };
3636 errdefer allocator.destroy(self);
......@@ -38,8 +38,8 @@ pub const BufferedAtomicFile = struct {
3838 self.atomic_file = try dir.atomicFile(dest_path, atomic_file_options);
3939 errdefer self.atomic_file.deinit();
4040
41 self.file_stream = self.atomic_file.file.writer();
42 self.buffered_stream = .{ .unbuffered_writer = self.file_stream };
41 self.file_writer = self.atomic_file.file.writer();
42 self.buffered_writer = .{ .unbuffered_writer = self.file_writer };
4343 return self;
4444 }
4545
......@@ -50,11 +50,11 @@ pub const BufferedAtomicFile = struct {
5050 }
5151
5252 pub fn finish(self: *BufferedAtomicFile) !void {
53 try self.buffered_stream.flush();
53 try self.buffered_writer.flush();
5454 try self.atomic_file.finish();
5555 }
5656
57 pub fn stream(self: *BufferedAtomicFile) OutStream {
58 return .{ .context = &self.buffered_stream };
57 pub fn writer(self: *BufferedAtomicFile) Writer {
58 return .{ .context = &self.buffered_writer };
5959 }
6060};
lib/std/io/buffered_in_stream.zig deleted-10
......@@ -1,10 +0,0 @@
1// SPDX-License-Identifier: MIT
2// Copyright (c) 2015-2021 Zig Contributors
3// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
4// The MIT license requires this copyright notice to be included in all copies
5// and substantial portions of the software.
6/// Deprecated: use `std.io.buffered_reader.BufferedReader`
7pub const BufferedInStream = @import("./buffered_reader.zig").BufferedReader;
8
9/// Deprecated: use `std.io.buffered_reader.bufferedReader`
10pub const bufferedInStream = @import("./buffered_reader.zig").bufferedReader;
lib/std/io/buffered_out_stream.zig deleted-10
......@@ -1,10 +0,0 @@
1// SPDX-License-Identifier: MIT
2// Copyright (c) 2015-2021 Zig Contributors
3// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
4// The MIT license requires this copyright notice to be included in all copies
5// and substantial portions of the software.
6/// Deprecated: use `std.io.buffered_writer.BufferedWriter`
7pub const BufferedOutStream = @import("./buffered_writer.zig").BufferedWriter;
8
9/// Deprecated: use `std.io.buffered_writer.bufferedWriter`
10pub const bufferedOutStream = @import("./buffered_writer.zig").bufferedWriter;
lib/std/io/buffered_reader.zig-7
......@@ -15,8 +15,6 @@ pub fn BufferedReader(comptime buffer_size: usize, comptime ReaderType: type) ty
1515
1616 pub const Error = ReaderType.Error;
1717 pub const Reader = io.Reader(*Self, Error, read);
18 /// Deprecated: use `Reader`
19 pub const InStream = Reader;
2018
2119 const Self = @This();
2220 const FifoType = std.fifo.LinearFifo(u8, std.fifo.LinearFifoBufferType{ .Static = buffer_size });
......@@ -45,11 +43,6 @@ pub fn BufferedReader(comptime buffer_size: usize, comptime ReaderType: type) ty
4543 pub fn reader(self: *Self) Reader {
4644 return .{ .context = self };
4745 }
48
49 /// Deprecated: use `reader`
50 pub fn inStream(self: *Self) InStream {
51 return .{ .context = self };
52 }
5346 };
5447}
5548
lib/std/io/buffered_writer.zig-7
......@@ -13,8 +13,6 @@ pub fn BufferedWriter(comptime buffer_size: usize, comptime WriterType: type) ty
1313
1414 pub const Error = WriterType.Error;
1515 pub const Writer = io.Writer(*Self, Error, write);
16 /// Deprecated: use `Writer`
17 pub const OutStream = Writer;
1816
1917 const Self = @This();
2018 const FifoType = std.fifo.LinearFifo(u8, std.fifo.LinearFifoBufferType{ .Static = buffer_size });
......@@ -32,11 +30,6 @@ pub fn BufferedWriter(comptime buffer_size: usize, comptime WriterType: type) ty
3230 return .{ .context = self };
3331 }
3432
35 /// Deprecated: use writer
36 pub fn outStream(self: *Self) Writer {
37 return .{ .context = self };
38 }
39
4033 pub fn write(self: *Self, bytes: []const u8) Error!usize {
4134 if (bytes.len >= self.fifo.writableLength()) {
4235 try self.flush();
lib/std/io/c_out_stream.zig deleted-10
......@@ -1,10 +0,0 @@
1// SPDX-License-Identifier: MIT
2// Copyright (c) 2015-2021 Zig Contributors
3// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
4// The MIT license requires this copyright notice to be included in all copies
5// and substantial portions of the software.
6/// Deprecated: use `std.io.c_writer.CWriter`
7pub const COutStream = @import("./c_writer.zig").CWriter;
8
9/// Deprecated: use `std.io.c_writer.cWriter`
10pub const cOutStream = @import("./c_writer.zig").cWriter;
lib/std/io/counting_out_stream.zig deleted-10
......@@ -1,10 +0,0 @@
1// SPDX-License-Identifier: MIT
2// Copyright (c) 2015-2021 Zig Contributors
3// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
4// The MIT license requires this copyright notice to be included in all copies
5// and substantial portions of the software.
6/// Deprecated: use `std.io.counting_writer.CountingWriter`
7pub const CountingOutStream = @import("./counting_writer.zig").CountingWriter;
8
9/// Deprecated: use `std.io.counting_writer.countingWriter`
10pub const countingOutStream = @import("./counting_writer.zig").countingWriter;
lib/std/io/counting_writer.zig-7
......@@ -15,8 +15,6 @@ pub fn CountingWriter(comptime WriterType: type) type {
1515
1616 pub const Error = WriterType.Error;
1717 pub const Writer = io.Writer(*Self, Error, write);
18 /// Deprecated: use `Writer`
19 pub const OutStream = Writer;
2018
2119 const Self = @This();
2220
......@@ -29,11 +27,6 @@ pub fn CountingWriter(comptime WriterType: type) type {
2927 pub fn writer(self: *Self) Writer {
3028 return .{ .context = self };
3129 }
32
33 /// Deprecated: use `writer`
34 pub fn outStream(self: *Self) OutStream {
35 return .{ .context = self };
36 }
3730 };
3831}
3932
lib/std/io/find_byte_out_stream.zig deleted-46
......@@ -1,46 +0,0 @@
1// SPDX-License-Identifier: MIT
2// Copyright (c) 2015-2021 Zig Contributors
3// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
4// The MIT license requires this copyright notice to be included in all copies
5// and substantial portions of the software.
6
7const std = @import("../std.zig");
8const io = std.io;
9const assert = std.debug.assert;
10
11/// An OutStream that returns whether the given character has been written to it.
12/// The contents are not written to anything.
13pub fn FindByteOutStream(comptime UnderlyingWriter: type) type {
14 return struct {
15 const Self = @This();
16 pub const Error = UnderlyingWriter.Error;
17 pub const Writer = io.Writer(*Self, Error, write);
18
19 underlying_writer: UnderlyingWriter,
20 byte_found: bool,
21 byte: u8,
22
23 pub fn writer(self: *Self) Writer {
24 return .{ .context = self };
25 }
26
27 fn write(self: *Self, bytes: []const u8) Error!usize {
28 if (!self.byte_found) {
29 self.byte_found = blk: {
30 for (bytes) |b|
31 if (b == self.byte) break :blk true;
32 break :blk false;
33 };
34 }
35 return self.underlying_writer.write(bytes);
36 }
37 };
38}
39
40pub fn findByteOutStream(byte: u8, underlying_writer: anytype) FindByteOutStream(@TypeOf(underlying_writer)) {
41 return FindByteOutStream(@TypeOf(underlying_writer)){
42 .underlying_writer = underlying_writer,
43 .byte = byte,
44 .byte_found = false,
45 };
46}
lib/std/io/find_byte_writer.zig created+46
......@@ -0,0 +1,46 @@
1// SPDX-License-Identifier: MIT
2// Copyright (c) 2015-2021 Zig Contributors
3// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
4// The MIT license requires this copyright notice to be included in all copies
5// and substantial portions of the software.
6
7const std = @import("../std.zig");
8const io = std.io;
9const assert = std.debug.assert;
10
11/// A Writer that returns whether the given character has been written to it.
12/// The contents are not written to anything.
13pub fn FindByteWriter(comptime UnderlyingWriter: type) type {
14 return struct {
15 const Self = @This();
16 pub const Error = UnderlyingWriter.Error;
17 pub const Writer = io.Writer(*Self, Error, write);
18
19 underlying_writer: UnderlyingWriter,
20 byte_found: bool,
21 byte: u8,
22
23 pub fn writer(self: *Self) Writer {
24 return .{ .context = self };
25 }
26
27 fn write(self: *Self, bytes: []const u8) Error!usize {
28 if (!self.byte_found) {
29 self.byte_found = blk: {
30 for (bytes) |b|
31 if (b == self.byte) break :blk true;
32 break :blk false;
33 };
34 }
35 return self.underlying_writer.write(bytes);
36 }
37 };
38}
39
40pub fn findByteWriter(byte: u8, underlying_writer: anytype) FindByteWriter(@TypeOf(underlying_writer)) {
41 return FindByteWriter(@TypeOf(underlying_writer)){
42 .underlying_writer = underlying_writer,
43 .byte = byte,
44 .byte_found = false,
45 };
46}
lib/std/io/fixed_buffer_stream.zig-14
......@@ -23,11 +23,7 @@ pub fn FixedBufferStream(comptime Buffer: type) type {
2323 pub const GetSeekPosError = error{};
2424
2525 pub const Reader = io.Reader(*Self, ReadError, read);
26 /// Deprecated: use `Reader`
27 pub const InStream = io.InStream(*Self, ReadError, read);
2826 pub const Writer = io.Writer(*Self, WriteError, write);
29 /// Deprecated: use `Writer`
30 pub const OutStream = Writer;
3127
3228 pub const SeekableStream = io.SeekableStream(
3329 *Self,
......@@ -45,20 +41,10 @@ pub fn FixedBufferStream(comptime Buffer: type) type {
4541 return .{ .context = self };
4642 }
4743
48 /// Deprecated: use `reader`
49 pub fn inStream(self: *Self) InStream {
50 return .{ .context = self };
51 }
52
5344 pub fn writer(self: *Self) Writer {
5445 return .{ .context = self };
5546 }
5647
57 /// Deprecated: use `writer`
58 pub fn outStream(self: *Self) OutStream {
59 return .{ .context = self };
60 }
61
6248 pub fn seekableStream(self: *Self) SeekableStream {
6349 return .{ .context = self };
6450 }
lib/std/io/in_stream.zig deleted-7
......@@ -1,7 +0,0 @@
1// SPDX-License-Identifier: MIT
2// Copyright (c) 2015-2021 Zig Contributors
3// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
4// The MIT license requires this copyright notice to be included in all copies
5// and substantial portions of the software.
6/// Deprecated: use `std.io.reader.Reader`
7pub const InStream = @import("./reader.zig").Reader;
lib/std/io/multi_out_stream.zig deleted-10
......@@ -1,10 +0,0 @@
1// SPDX-License-Identifier: MIT
2// Copyright (c) 2015-2021 Zig Contributors
3// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
4// The MIT license requires this copyright notice to be included in all copies
5// and substantial portions of the software.
6/// Deprecated: use `std.io.multi_writer.MultiWriter`
7pub const MultiOutStream = @import("./multi_writer.zig").MultiWriter;
8
9/// Deprecated: use `std.io.multi_writer.multiWriter`
10pub const multiOutStream = @import("./multi_writer.zig").multiWriter;
lib/std/io/multi_writer.zig-7
......@@ -22,18 +22,11 @@ pub fn MultiWriter(comptime Writers: type) type {
2222
2323 pub const Error = ErrSet;
2424 pub const Writer = io.Writer(*Self, Error, write);
25 /// Deprecated: use `Writer`
26 pub const OutStream = Writer;
2725
2826 pub fn writer(self: *Self) Writer {
2927 return .{ .context = self };
3028 }
3129
32 /// Deprecated: use `writer`
33 pub fn outStream(self: *Self) OutStream {
34 return .{ .context = self };
35 }
36
3730 pub fn write(self: *Self, bytes: []const u8) Error!usize {
3831 var batch = std.event.Batch(Error!void, self.streams.len, .auto_async).init();
3932 comptime var i = 0;
lib/std/io/out_stream.zig deleted-7
......@@ -1,7 +0,0 @@
1// SPDX-License-Identifier: MIT
2// Copyright (c) 2015-2021 Zig Contributors
3// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
4// The MIT license requires this copyright notice to be included in all copies
5// and substantial portions of the software.
6/// Deprecated: use `std.io.writer.Writer`
7pub const OutStream = @import("./writer.zig").Writer;
lib/std/io/peek_stream.zig+5-12
......@@ -16,13 +16,11 @@ pub fn PeekStream(
1616 comptime ReaderType: type,
1717) type {
1818 return struct {
19 unbuffered_in_stream: ReaderType,
19 unbuffered_reader: ReaderType,
2020 fifo: FifoType,
2121
2222 pub const Error = ReaderType.Error;
2323 pub const Reader = io.Reader(*Self, Error, read);
24 /// Deprecated: use `Reader`
25 pub const InStream = Reader;
2624
2725 const Self = @This();
2826 const FifoType = std.fifo.LinearFifo(u8, buffer_type);
......@@ -31,7 +29,7 @@ pub fn PeekStream(
3129 .Static => struct {
3230 pub fn init(base: ReaderType) Self {
3331 return .{
34 .unbuffered_in_stream = base,
32 .unbuffered_reader = base,
3533 .fifo = FifoType.init(),
3634 };
3735 }
......@@ -39,7 +37,7 @@ pub fn PeekStream(
3937 .Slice => struct {
4038 pub fn init(base: ReaderType, buf: []u8) Self {
4139 return .{
42 .unbuffered_in_stream = base,
40 .unbuffered_reader = base,
4341 .fifo = FifoType.init(buf),
4442 };
4543 }
......@@ -47,7 +45,7 @@ pub fn PeekStream(
4745 .Dynamic => struct {
4846 pub fn init(base: ReaderType, allocator: *mem.Allocator) Self {
4947 return .{
50 .unbuffered_in_stream = base,
48 .unbuffered_reader = base,
5149 .fifo = FifoType.init(allocator),
5250 };
5351 }
......@@ -68,18 +66,13 @@ pub fn PeekStream(
6866 if (dest_index == dest.len) return dest_index;
6967
7068 // ask the backing stream for more
71 dest_index += try self.unbuffered_in_stream.read(dest[dest_index..]);
69 dest_index += try self.unbuffered_reader.read(dest[dest_index..]);
7270 return dest_index;
7371 }
7472
7573 pub fn reader(self: *Self) Reader {
7674 return .{ .context = self };
7775 }
78
79 /// Deprecated: use `reader`
80 pub fn inStream(self: *Self) InStream {
81 return .{ .context = self };
82 }
8376 };
8477}
8578
lib/std/io/stream_source.zig+1-15
......@@ -9,7 +9,7 @@ const testing = std.testing;
99
1010/// Provides `io.Reader`, `io.Writer`, and `io.SeekableStream` for in-memory buffers as
1111/// well as files.
12/// For memory sources, if the supplied byte buffer is const, then `io.OutStream` is not available.
12/// For memory sources, if the supplied byte buffer is const, then `io.Writer` is not available.
1313/// The error set of the stream functions is the error set of the corresponding file functions.
1414pub const StreamSource = union(enum) {
1515 buffer: io.FixedBufferStream([]u8),
......@@ -22,11 +22,7 @@ pub const StreamSource = union(enum) {
2222 pub const GetSeekPosError = std.fs.File.GetPosError;
2323
2424 pub const Reader = io.Reader(*StreamSource, ReadError, read);
25 /// Deprecated: use `Reader`
26 pub const InStream = Reader;
2725 pub const Writer = io.Writer(*StreamSource, WriteError, write);
28 /// Deprecated: use `Writer`
29 pub const OutStream = Writer;
3026 pub const SeekableStream = io.SeekableStream(
3127 *StreamSource,
3228 SeekError,
......@@ -89,20 +85,10 @@ pub const StreamSource = union(enum) {
8985 return .{ .context = self };
9086 }
9187
92 /// Deprecated: use `reader`
93 pub fn inStream(self: *StreamSource) InStream {
94 return .{ .context = self };
95 }
96
9788 pub fn writer(self: *StreamSource) Writer {
9889 return .{ .context = self };
9990 }
10091
101 /// Deprecated: use `writer`
102 pub fn outStream(self: *StreamSource) OutStream {
103 return .{ .context = self };
104 }
105
10692 pub fn seekableStream(self: *StreamSource) SeekableStream {
10793 return .{ .context = self };
10894 }
lib/std/json.zig+5-5
......@@ -2620,9 +2620,9 @@ pub fn stringify(
26202620}
26212621
26222622fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions) !void {
2623 const ValidationOutStream = struct {
2623 const ValidationWriter = struct {
26242624 const Self = @This();
2625 pub const OutStream = std.io.OutStream(*Self, Error, write);
2625 pub const Writer = std.io.Writer(*Self, Error, write);
26262626 pub const Error = error{
26272627 TooMuchData,
26282628 DifferentData,
......@@ -2634,7 +2634,7 @@ fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions
26342634 return .{ .expected_remaining = exp };
26352635 }
26362636
2637 pub fn outStream(self: *Self) OutStream {
2637 pub fn writer(self: *Self) Writer {
26382638 return .{ .context = self };
26392639 }
26402640
......@@ -2670,8 +2670,8 @@ fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions
26702670 }
26712671 };
26722672
2673 var vos = ValidationOutStream.init(expected);
2674 try stringify(value, options, vos.outStream());
2673 var vos = ValidationWriter.init(expected);
2674 try stringify(value, options, vos.writer());
26752675 if (vos.expected_remaining.len > 0) return error.NotEnoughData;
26762676}
26772677
lib/std/pdb.zig-4
......@@ -716,8 +716,4 @@ const MsfStream = struct {
716716 pub fn reader(self: *MsfStream) std.io.Reader(*MsfStream, Error, read) {
717717 return .{ .context = self };
718718 }
719 /// Deprecated: use `reader`
720 pub fn inStream(self: *MsfStream) std.io.InStream(*MsfStream, Error, read) {
721 return .{ .context = self };
722 }
723719};
lib/std/zig/render.zig+3-3
......@@ -790,8 +790,8 @@ fn renderExpression(
790790 const section_exprs = row_exprs[0..section_end];
791791
792792 // Null stream for counting the printed length of each expression
793 var line_find_stream = std.io.findByteOutStream('\n', std.io.null_writer);
794 var counting_stream = std.io.countingOutStream(line_find_stream.writer());
793 var line_find_stream = std.io.findByteWriter('\n', std.io.null_writer);
794 var counting_stream = std.io.countingWriter(line_find_stream.writer());
795795 var auto_indenting_stream = std.io.autoIndentingStream(indent_delta, counting_stream.writer());
796796
797797 // Calculate size of columns in current section
......@@ -954,7 +954,7 @@ fn renderExpression(
954954 const expr_outputs_one_line = blk: {
955955 // render field expressions until a LF is found
956956 for (field_inits) |field_init| {
957 var find_stream = std.io.findByteOutStream('\n', std.io.null_writer);
957 var find_stream = std.io.findByteWriter('\n', std.io.null_writer);
958958 var auto_indenting_stream = std.io.autoIndentingStream(indent_delta, find_stream.writer());
959959
960960 try renderExpression(allocator, &auto_indenting_stream, tree, field_init, Space.None);
src/main.zig+1-1
......@@ -2024,7 +2024,7 @@ fn updateModule(gpa: *Allocator, comp: *Compilation, zir_out_path: ?[]const u8,
20242024 const baf = try io.BufferedAtomicFile.create(gpa, fs.cwd(), zop, .{});
20252025 defer baf.destroy();
20262026
2027 try new_zir_module.writeToStream(gpa, baf.stream());
2027 try new_zir_module.writeToStream(gpa, baf.writer());
20282028
20292029 try baf.finish();
20302030 }