diff options
| author | Veikka Tuominen <git@vexu.eu> | 2020-09-05 13:58:02 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-05 13:58:02 +0300 |
| commit | 41bbadbb9a27107da539e27e175f5bdb52656bd5 (patch) | |
| tree | 48a89b9ef19eedded7d5b8f3ab9e5e40efacf528 /lib/std/io | |
| parent | cff14dc2c67d9a35ae2c3e07bd6d2c5594d8a0a1 (diff) | |
| parent | 09c861b829480be525a787e54117c108705256e6 (diff) | |
| download | zig-41bbadbb9a27107da539e27e175f5bdb52656bd5.tar.gz zig-41bbadbb9a27107da539e27e175f5bdb52656bd5.zip | |
Merge pull request #6246 from Vexu/field
Remove deprecated fields on `type`
Diffstat (limited to 'lib/std/io')
| -rw-r--r-- | lib/std/io/reader.zig | 10 | ||||
| -rw-r--r-- | lib/std/io/serialization.zig | 6 | ||||
| -rw-r--r-- | lib/std/io/writer.zig | 10 |
3 files changed, 13 insertions, 13 deletions
diff --git a/lib/std/io/reader.zig b/lib/std/io/reader.zig index 2ab799046a..4090f5a476 100644 --- a/lib/std/io/reader.zig +++ b/lib/std/io/reader.zig @@ -198,28 +198,28 @@ pub fn Reader( /// Reads a native-endian integer pub fn readIntNative(self: Self, comptime T: type) !T { - const bytes = try self.readBytesNoEof((T.bit_count + 7) / 8); + const bytes = try self.readBytesNoEof((@typeInfo(T).Int.bits + 7) / 8); return mem.readIntNative(T, &bytes); } /// Reads a foreign-endian integer pub fn readIntForeign(self: Self, comptime T: type) !T { - const bytes = try self.readBytesNoEof((T.bit_count + 7) / 8); + const bytes = try self.readBytesNoEof((@typeInfo(T).Int.bits + 7) / 8); return mem.readIntForeign(T, &bytes); } pub fn readIntLittle(self: Self, comptime T: type) !T { - const bytes = try self.readBytesNoEof((T.bit_count + 7) / 8); + const bytes = try self.readBytesNoEof((@typeInfo(T).Int.bits + 7) / 8); return mem.readIntLittle(T, &bytes); } pub fn readIntBig(self: Self, comptime T: type) !T { - const bytes = try self.readBytesNoEof((T.bit_count + 7) / 8); + const bytes = try self.readBytesNoEof((@typeInfo(T).Int.bits + 7) / 8); return mem.readIntBig(T, &bytes); } pub fn readInt(self: Self, comptime T: type, endian: builtin.Endian) !T { - const bytes = try self.readBytesNoEof((T.bit_count + 7) / 8); + const bytes = try self.readBytesNoEof((@typeInfo(T).Int.bits + 7) / 8); return mem.readInt(T, &bytes, endian); } diff --git a/lib/std/io/serialization.zig b/lib/std/io/serialization.zig index 4f8c149b47..925c929cee 100644 --- a/lib/std/io/serialization.zig +++ b/lib/std/io/serialization.zig @@ -60,7 +60,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing, const U = std.meta.Int(false, t_bit_count); const Log2U = math.Log2Int(U); - const int_size = (U.bit_count + 7) / 8; + const int_size = (t_bit_count + 7) / 8; if (packing == .Bit) { const result = try self.in_stream.readBitsNoEof(U, t_bit_count); @@ -73,7 +73,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing, if (int_size == 1) { if (t_bit_count == 8) return @bitCast(T, buffer[0]); - const PossiblySignedByte = std.meta.Int(T.is_signed, 8); + const PossiblySignedByte = std.meta.Int(@typeInfo(T).Int.is_signed, 8); return @truncate(T, @bitCast(PossiblySignedByte, buffer[0])); } @@ -247,7 +247,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co const U = std.meta.Int(false, t_bit_count); const Log2U = math.Log2Int(U); - const int_size = (U.bit_count + 7) / 8; + const int_size = (t_bit_count + 7) / 8; const u_value = @bitCast(U, value); diff --git a/lib/std/io/writer.zig b/lib/std/io/writer.zig index 39729ef0a2..770cd5f0fa 100644 --- a/lib/std/io/writer.zig +++ b/lib/std/io/writer.zig @@ -53,7 +53,7 @@ pub fn Writer( /// Write a native-endian integer. /// TODO audit non-power-of-two int sizes pub fn writeIntNative(self: Self, comptime T: type, value: T) Error!void { - var bytes: [(T.bit_count + 7) / 8]u8 = undefined; + var bytes: [(@typeInfo(T).Int.bits + 7) / 8]u8 = undefined; mem.writeIntNative(T, &bytes, value); return self.writeAll(&bytes); } @@ -61,28 +61,28 @@ pub fn Writer( /// Write a foreign-endian integer. /// TODO audit non-power-of-two int sizes pub fn writeIntForeign(self: Self, comptime T: type, value: T) Error!void { - var bytes: [(T.bit_count + 7) / 8]u8 = undefined; + var bytes: [(@typeInfo(T).Int.bits + 7) / 8]u8 = undefined; mem.writeIntForeign(T, &bytes, value); return self.writeAll(&bytes); } /// TODO audit non-power-of-two int sizes pub fn writeIntLittle(self: Self, comptime T: type, value: T) Error!void { - var bytes: [(T.bit_count + 7) / 8]u8 = undefined; + var bytes: [(@typeInfo(T).Int.bits + 7) / 8]u8 = undefined; mem.writeIntLittle(T, &bytes, value); return self.writeAll(&bytes); } /// TODO audit non-power-of-two int sizes pub fn writeIntBig(self: Self, comptime T: type, value: T) Error!void { - var bytes: [(T.bit_count + 7) / 8]u8 = undefined; + var bytes: [(@typeInfo(T).Int.bits + 7) / 8]u8 = undefined; mem.writeIntBig(T, &bytes, value); return self.writeAll(&bytes); } /// TODO audit non-power-of-two int sizes pub fn writeInt(self: Self, comptime T: type, value: T, endian: builtin.Endian) Error!void { - var bytes: [(T.bit_count + 7) / 8]u8 = undefined; + var bytes: [(@typeInfo(T).Int.bits + 7) / 8]u8 = undefined; mem.writeInt(T, &bytes, value, endian); return self.writeAll(&bytes); } |
