@zigc/lib 0.16.0-dev.3128 → 0.16.0-dev.3132
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/aro/backend/Ir/x86/Renderer.zig +3 -3
- package/compiler/resinator/compile.zig +2 -2
- package/package.json +1 -1
- package/std/Io/File/Reader.zig +3 -1
- package/std/Io/Kqueue.zig +2 -2
- package/std/Io.zig +2 -2
- package/std/bit_set.zig +22 -6
- package/std/crypto/codecs/base64_hex_ct.zig +2 -2
- package/std/enums.zig +19 -25
- package/std/http/Client.zig +10 -6
|
@@ -21,17 +21,17 @@ const RegisterManager = zig.RegisterManager(Renderer, Register, Ir.Ref, abi.allo
|
|
|
21
21
|
const RegisterBitSet = RegisterManager.RegisterBitSet;
|
|
22
22
|
const RegisterClass = struct {
|
|
23
23
|
const gp: RegisterBitSet = blk: {
|
|
24
|
-
var set = RegisterBitSet.
|
|
24
|
+
var set = RegisterBitSet.empty;
|
|
25
25
|
for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .general_purpose) set.set(index);
|
|
26
26
|
break :blk set;
|
|
27
27
|
};
|
|
28
28
|
const x87: RegisterBitSet = blk: {
|
|
29
|
-
var set = RegisterBitSet.
|
|
29
|
+
var set = RegisterBitSet.empty;
|
|
30
30
|
for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .x87) set.set(index);
|
|
31
31
|
break :blk set;
|
|
32
32
|
};
|
|
33
33
|
const sse: RegisterBitSet = blk: {
|
|
34
|
-
var set = RegisterBitSet.
|
|
34
|
+
var set = RegisterBitSet.empty;
|
|
35
35
|
for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .sse) set.set(index);
|
|
36
36
|
break :blk set;
|
|
37
37
|
};
|
|
@@ -2746,7 +2746,7 @@ pub const Compiler = struct {
|
|
|
2746
2746
|
// 1. Any permutation that does not have PRELOAD in it just uses the
|
|
2747
2747
|
// default flags.
|
|
2748
2748
|
const initial_flags = flags.*;
|
|
2749
|
-
var flags_set = std.enums.EnumSet(rc.CommonResourceAttributes).
|
|
2749
|
+
var flags_set = std.enums.EnumSet(rc.CommonResourceAttributes).empty;
|
|
2750
2750
|
for (tokens) |token| {
|
|
2751
2751
|
const attribute = rc.CommonResourceAttributes.map.get(token.slice(source)).?;
|
|
2752
2752
|
flags_set.insert(attribute);
|
|
@@ -2769,7 +2769,7 @@ pub const Compiler = struct {
|
|
|
2769
2769
|
// 3. If none of DISCARDABLE, SHARED, or PURE is specified, then PRELOAD
|
|
2770
2770
|
// implies `flags &= ~SHARED` and LOADONCALL implies `flags |= SHARED`
|
|
2771
2771
|
const shared_set = comptime blk: {
|
|
2772
|
-
var set = std.enums.EnumSet(rc.CommonResourceAttributes).
|
|
2772
|
+
var set = std.enums.EnumSet(rc.CommonResourceAttributes).empty;
|
|
2773
2773
|
set.insert(.discardable);
|
|
2774
2774
|
set.insert(.shared);
|
|
2775
2775
|
set.insert(.pure);
|
package/package.json
CHANGED
package/std/Io/File/Reader.zig
CHANGED
|
@@ -309,7 +309,9 @@ fn discard(io_reader: *Io.Reader, limit: Io.Limit) Io.Reader.Error!usize {
|
|
|
309
309
|
return 0;
|
|
310
310
|
};
|
|
311
311
|
const logical_pos = logicalPos(r);
|
|
312
|
-
const
|
|
312
|
+
const bytes_remaining = size - logical_pos;
|
|
313
|
+
if (bytes_remaining == 0) return error.EndOfStream;
|
|
314
|
+
const delta = @min(@intFromEnum(limit), bytes_remaining);
|
|
313
315
|
setLogicalPos(r, logical_pos + delta);
|
|
314
316
|
return delta;
|
|
315
317
|
},
|
package/std/Io/Kqueue.zig
CHANGED
|
@@ -186,7 +186,7 @@ pub fn init(k: *Kqueue, gpa: Allocator, options: InitOptions) !void {
|
|
|
186
186
|
.awaiter = null,
|
|
187
187
|
.queue_next = null,
|
|
188
188
|
.cancel_thread = null,
|
|
189
|
-
.awaiting_completions = .
|
|
189
|
+
.awaiting_completions = .empty,
|
|
190
190
|
};
|
|
191
191
|
const main_thread = &k.threads.allocated[0];
|
|
192
192
|
Thread.self = main_thread;
|
|
@@ -713,7 +713,7 @@ fn concurrent(
|
|
|
713
713
|
.awaiter = null,
|
|
714
714
|
.queue_next = null,
|
|
715
715
|
.cancel_thread = null,
|
|
716
|
-
.awaiting_completions = .
|
|
716
|
+
.awaiting_completions = .empty,
|
|
717
717
|
};
|
|
718
718
|
closure.* = .{
|
|
719
719
|
.kqueue = k,
|
package/std/Io.zig
CHANGED
|
@@ -500,8 +500,8 @@ pub const Batch = struct {
|
|
|
500
500
|
/// Returns the index that will be returned by `next` after the operation completes.
|
|
501
501
|
/// Asserts that no more than `storage.len` operations are active at a time.
|
|
502
502
|
pub fn add(batch: *Batch, operation: Operation) u32 {
|
|
503
|
-
const index = batch.unused.
|
|
504
|
-
batch.addAt(index
|
|
503
|
+
const index = batch.unused.head.toIndex();
|
|
504
|
+
batch.addAt(index, operation);
|
|
505
505
|
return index;
|
|
506
506
|
}
|
|
507
507
|
|
package/std/bit_set.zig
CHANGED
|
@@ -68,16 +68,24 @@ pub fn IntegerBitSet(comptime size: u16) type {
|
|
|
68
68
|
/// The bit mask, as a single integer
|
|
69
69
|
mask: MaskInt,
|
|
70
70
|
|
|
71
|
+
/// Deprecated: use `.empty`.
|
|
71
72
|
/// Creates a bit set with no elements present.
|
|
72
73
|
pub fn initEmpty() Self {
|
|
73
74
|
return .{ .mask = 0 };
|
|
74
75
|
}
|
|
75
76
|
|
|
77
|
+
/// Deprecated: use `.full`.
|
|
76
78
|
/// Creates a bit set with all elements present.
|
|
77
79
|
pub fn initFull() Self {
|
|
78
80
|
return .{ .mask = ~@as(MaskInt, 0) };
|
|
79
81
|
}
|
|
80
82
|
|
|
83
|
+
/// A bit set with no elements present.
|
|
84
|
+
pub const empty: Self = .{ .mask = 0 };
|
|
85
|
+
|
|
86
|
+
/// A bit set with all elements present.
|
|
87
|
+
pub const full: Self = .{ .mask = ~@as(MaskInt, 0) };
|
|
88
|
+
|
|
81
89
|
/// Returns the number of bits in this bit set
|
|
82
90
|
pub inline fn capacity(self: Self) usize {
|
|
83
91
|
_ = self;
|
|
@@ -387,11 +395,13 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
|
|
|
387
395
|
/// Padding bits at the end are undefined.
|
|
388
396
|
masks: [num_masks]MaskInt,
|
|
389
397
|
|
|
398
|
+
/// Deprecated: use `.empty`.
|
|
390
399
|
/// Creates a bit set with no elements present.
|
|
391
400
|
pub fn initEmpty() Self {
|
|
392
401
|
return .{ .masks = [_]MaskInt{0} ** num_masks };
|
|
393
402
|
}
|
|
394
403
|
|
|
404
|
+
/// Deprecated: use `.full`.
|
|
395
405
|
/// Creates a bit set with all elements present.
|
|
396
406
|
pub fn initFull() Self {
|
|
397
407
|
if (num_masks == 0) {
|
|
@@ -401,6 +411,12 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
|
|
|
401
411
|
}
|
|
402
412
|
}
|
|
403
413
|
|
|
414
|
+
/// A bit set with no elements present.
|
|
415
|
+
pub const empty: Self = .{ .masks = @splat(0) };
|
|
416
|
+
|
|
417
|
+
/// A bit set with all elements present.
|
|
418
|
+
pub const full: Self = .{ .masks = if (num_masks == 0) .{} else ([_]MaskInt{~@as(MaskInt, 0)} ** (num_masks - 1) ++ [_]MaskInt{last_item_mask}) };
|
|
419
|
+
|
|
404
420
|
/// Returns the number of bits in this bit set
|
|
405
421
|
pub inline fn capacity(self: Self) usize {
|
|
406
422
|
_ = self;
|
|
@@ -1633,17 +1649,17 @@ fn fillOdd(set: anytype, len: usize) void {
|
|
|
1633
1649
|
}
|
|
1634
1650
|
|
|
1635
1651
|
fn testPureBitSet(comptime Set: type) !void {
|
|
1636
|
-
const empty = Set.
|
|
1637
|
-
const full = Set.
|
|
1652
|
+
const empty = Set.empty;
|
|
1653
|
+
const full = Set.full;
|
|
1638
1654
|
|
|
1639
1655
|
const even = even: {
|
|
1640
|
-
var bit_set = Set.
|
|
1656
|
+
var bit_set = Set.empty;
|
|
1641
1657
|
fillEven(&bit_set, Set.bit_length);
|
|
1642
1658
|
break :even bit_set;
|
|
1643
1659
|
};
|
|
1644
1660
|
|
|
1645
1661
|
const odd = odd: {
|
|
1646
|
-
var bit_set = Set.
|
|
1662
|
+
var bit_set = Set.empty;
|
|
1647
1663
|
fillOdd(&bit_set, Set.bit_length);
|
|
1648
1664
|
break :odd bit_set;
|
|
1649
1665
|
};
|
|
@@ -1686,8 +1702,8 @@ fn testPureBitSet(comptime Set: type) !void {
|
|
|
1686
1702
|
}
|
|
1687
1703
|
|
|
1688
1704
|
fn testStaticBitSet(comptime Set: type) !void {
|
|
1689
|
-
var a = Set.
|
|
1690
|
-
var b = Set.
|
|
1705
|
+
var a = Set.empty;
|
|
1706
|
+
var b = Set.full;
|
|
1691
1707
|
try testing.expectEqual(@as(usize, 0), a.count());
|
|
1692
1708
|
try testing.expectEqual(@as(usize, Set.bit_length), b.count());
|
|
1693
1709
|
|
|
@@ -93,7 +93,7 @@ pub const hex = struct {
|
|
|
93
93
|
/// The decoder will skip any characters that are in the ignore list.
|
|
94
94
|
/// The ignore list must not contain any valid hexadecimal characters.
|
|
95
95
|
pub fn decoderWithIgnore(ignore_chars: []const u8) error{InvalidCharacter}!DecoderWithIgnore {
|
|
96
|
-
var ignored_chars = StaticBitSet(256).
|
|
96
|
+
var ignored_chars = StaticBitSet(256).empty;
|
|
97
97
|
for (ignore_chars) |c| {
|
|
98
98
|
switch (c) {
|
|
99
99
|
'0'...'9', 'a'...'f', 'A'...'F' => return error.InvalidCharacter,
|
|
@@ -269,7 +269,7 @@ pub const base64 = struct {
|
|
|
269
269
|
|
|
270
270
|
/// Creates a new decoder that ignores certain characters.
|
|
271
271
|
pub fn decoderWithIgnore(ignore_chars: []const u8) error{InvalidCharacter}!DecoderWithIgnore {
|
|
272
|
-
var ignored_chars = StaticBitSet(256).
|
|
272
|
+
var ignored_chars = StaticBitSet(256).empty;
|
|
273
273
|
for (ignore_chars) |c| {
|
|
274
274
|
switch (c) {
|
|
275
275
|
'A'...'Z', 'a'...'z', '0'...'9' => return error.InvalidCharacter,
|
package/std/enums.zig
CHANGED
|
@@ -252,7 +252,7 @@ pub fn EnumSet(comptime E: type) type {
|
|
|
252
252
|
/// The maximum number of items in this set.
|
|
253
253
|
pub const len = Indexer.count;
|
|
254
254
|
|
|
255
|
-
bits: BitSet =
|
|
255
|
+
bits: BitSet = .empty,
|
|
256
256
|
|
|
257
257
|
/// Initializes the set using a struct of bools
|
|
258
258
|
pub fn init(init_values: EnumFieldStruct(E, bool, false)) Self {
|
|
@@ -278,19 +278,15 @@ pub fn EnumSet(comptime E: type) type {
|
|
|
278
278
|
return result;
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
///
|
|
282
|
-
pub
|
|
283
|
-
return .{ .bits = BitSet.initEmpty() };
|
|
284
|
-
}
|
|
281
|
+
/// A set containing no keys.
|
|
282
|
+
pub const empty: Self = .{ .bits = .empty };
|
|
285
283
|
|
|
286
|
-
///
|
|
287
|
-
pub
|
|
288
|
-
return .{ .bits = BitSet.initFull() };
|
|
289
|
-
}
|
|
284
|
+
/// A set containing all possible keys.
|
|
285
|
+
pub const full: Self = .{ .bits = .full };
|
|
290
286
|
|
|
291
287
|
/// Returns a set containing multiple keys.
|
|
292
288
|
pub fn initMany(keys: []const Key) Self {
|
|
293
|
-
var set =
|
|
289
|
+
var set: Self = .empty;
|
|
294
290
|
for (keys) |key| set.insert(key);
|
|
295
291
|
return set;
|
|
296
292
|
}
|
|
@@ -440,7 +436,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
|
|
|
440
436
|
const BitSet = std.StaticBitSet(Indexer.count);
|
|
441
437
|
|
|
442
438
|
/// Bits determining whether items are in the map
|
|
443
|
-
bits: BitSet =
|
|
439
|
+
bits: BitSet = .empty,
|
|
444
440
|
/// Values of items in the map. If the associated
|
|
445
441
|
/// bit is zero, the value is undefined.
|
|
446
442
|
values: [Indexer.count]Value = undefined,
|
|
@@ -475,7 +471,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
|
|
|
475
471
|
/// Consider using EnumArray instead if the map will remain full.
|
|
476
472
|
pub fn initFull(value: Value) Self {
|
|
477
473
|
var result: Self = .{
|
|
478
|
-
.bits =
|
|
474
|
+
.bits = .full,
|
|
479
475
|
.values = undefined,
|
|
480
476
|
};
|
|
481
477
|
@memset(&result.values, value);
|
|
@@ -493,7 +489,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
|
|
|
493
489
|
pub fn initFullWithDefault(comptime default: ?Value, init_values: EnumFieldStruct(E, Value, default)) Self {
|
|
494
490
|
@setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len);
|
|
495
491
|
var result: Self = .{
|
|
496
|
-
.bits =
|
|
492
|
+
.bits = .full,
|
|
497
493
|
.values = undefined,
|
|
498
494
|
};
|
|
499
495
|
inline for (0..Self.len) |i| {
|
|
@@ -687,16 +683,14 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
|
|
|
687
683
|
return self;
|
|
688
684
|
}
|
|
689
685
|
|
|
690
|
-
///
|
|
691
|
-
pub
|
|
692
|
-
return initWithCount(0);
|
|
693
|
-
}
|
|
686
|
+
/// A multiset with a count of zero.
|
|
687
|
+
pub const empty: Self = .initWithCount(0);
|
|
694
688
|
|
|
695
689
|
/// Initializes the multiset with all keys at the
|
|
696
690
|
/// same count.
|
|
697
691
|
pub fn initWithCount(comptime c: CountSize) Self {
|
|
698
692
|
return .{
|
|
699
|
-
.counts =
|
|
693
|
+
.counts = .initDefault(c, .{}),
|
|
700
694
|
};
|
|
701
695
|
}
|
|
702
696
|
|
|
@@ -855,7 +849,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
|
|
|
855
849
|
test EnumMultiset {
|
|
856
850
|
const Ball = enum { red, green, blue };
|
|
857
851
|
|
|
858
|
-
const empty = EnumMultiset(Ball).
|
|
852
|
+
const empty = EnumMultiset(Ball).empty;
|
|
859
853
|
const r0_g1_b2 = EnumMultiset(Ball).init(.{
|
|
860
854
|
.red = 0,
|
|
861
855
|
.green = 1,
|
|
@@ -1162,8 +1156,8 @@ pub fn EnumArray(comptime E: type, comptime V: type) type {
|
|
|
1162
1156
|
test "pure EnumSet fns" {
|
|
1163
1157
|
const Suit = enum { spades, hearts, clubs, diamonds };
|
|
1164
1158
|
|
|
1165
|
-
const empty = EnumSet(Suit).
|
|
1166
|
-
const full = EnumSet(Suit).
|
|
1159
|
+
const empty = EnumSet(Suit).empty;
|
|
1160
|
+
const full = EnumSet(Suit).full;
|
|
1167
1161
|
const black = EnumSet(Suit).initMany(&[_]Suit{ .spades, .clubs });
|
|
1168
1162
|
const red = EnumSet(Suit).initMany(&[_]Suit{ .hearts, .diamonds });
|
|
1169
1163
|
|
|
@@ -1224,8 +1218,8 @@ test "pure EnumSet fns" {
|
|
|
1224
1218
|
|
|
1225
1219
|
test "EnumSet empty" {
|
|
1226
1220
|
const E = enum {};
|
|
1227
|
-
const empty = EnumSet(E).
|
|
1228
|
-
const full = EnumSet(E).
|
|
1221
|
+
const empty = EnumSet(E).empty;
|
|
1222
|
+
const full = EnumSet(E).full;
|
|
1229
1223
|
|
|
1230
1224
|
try std.testing.expect(empty.eql(full));
|
|
1231
1225
|
try std.testing.expect(empty.complement().eql(full));
|
|
@@ -1236,13 +1230,13 @@ test "EnumSet empty" {
|
|
|
1236
1230
|
test "EnumSet const iterator" {
|
|
1237
1231
|
const Direction = enum { up, down, left, right };
|
|
1238
1232
|
const diag_move = init: {
|
|
1239
|
-
var move = EnumSet(Direction).
|
|
1233
|
+
var move = EnumSet(Direction).empty;
|
|
1240
1234
|
move.insert(.right);
|
|
1241
1235
|
move.insert(.up);
|
|
1242
1236
|
break :init move;
|
|
1243
1237
|
};
|
|
1244
1238
|
|
|
1245
|
-
var result = EnumSet(Direction).
|
|
1239
|
+
var result = EnumSet(Direction).empty;
|
|
1246
1240
|
var it = diag_move.iterator();
|
|
1247
1241
|
while (it.next()) |dir| {
|
|
1248
1242
|
result.insert(dir);
|
package/std/http/Client.zig
CHANGED
|
@@ -1133,7 +1133,16 @@ pub const Request = struct {
|
|
|
1133
1133
|
pub fn receiveHead(r: *Request, redirect_buffer: []u8) ReceiveHeadError!Response {
|
|
1134
1134
|
var aux_buf = redirect_buffer;
|
|
1135
1135
|
while (true) {
|
|
1136
|
-
|
|
1136
|
+
// This while loop is for handling redirects, which means the request's
|
|
1137
|
+
// connection may be different than the previous iteration. However, it
|
|
1138
|
+
// is still guaranteed to be non-null with each iteration of this loop.
|
|
1139
|
+
const connection = r.connection.?;
|
|
1140
|
+
|
|
1141
|
+
const head_buffer = r.reader.receiveHead() catch |err| {
|
|
1142
|
+
// Failure here means the connection can no longer be reused.
|
|
1143
|
+
connection.closing = true;
|
|
1144
|
+
return err;
|
|
1145
|
+
};
|
|
1137
1146
|
const response: Response = .{
|
|
1138
1147
|
.request = r,
|
|
1139
1148
|
.head = Response.Head.parse(head_buffer) catch return error.HttpHeadersInvalid,
|
|
@@ -1147,11 +1156,6 @@ pub const Request = struct {
|
|
|
1147
1156
|
return response; // we're not handling the 100-continue
|
|
1148
1157
|
}
|
|
1149
1158
|
|
|
1150
|
-
// This while loop is for handling redirects, which means the request's
|
|
1151
|
-
// connection may be different than the previous iteration. However, it
|
|
1152
|
-
// is still guaranteed to be non-null with each iteration of this loop.
|
|
1153
|
-
const connection = r.connection.?;
|
|
1154
|
-
|
|
1155
1159
|
if (r.method == .CONNECT and head.status.class() == .success) {
|
|
1156
1160
|
// This connection is no longer doing HTTP.
|
|
1157
1161
|
connection.closing = false;
|