diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-02-28 01:25:05 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-28 01:25:05 -0500 |
| commit | 98508a12cfae15a895d3e829539f907e9d88d0b6 (patch) | |
| tree | 64667cc40b95097f2d834fad1f0971ac8f9f9971 /lib/std/multi_array_list.zig | |
| parent | f6c934677315665c140151b8dd28a56f948205e2 (diff) | |
| parent | 6bed45b87358975da97fec45fd30eb095ad1dfc9 (diff) | |
| download | zig-98508a12cfae15a895d3e829539f907e9d88d0b6.tar.gz zig-98508a12cfae15a895d3e829539f907e9d88d0b6.zip | |
Merge pull request #14741 from jacobly0/lldb
Diffstat (limited to 'lib/std/multi_array_list.zig')
| -rw-r--r-- | lib/std/multi_array_list.zig | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/lib/std/multi_array_list.zig b/lib/std/multi_array_list.zig index 56b36aaa81..6965205b1e 100644 --- a/lib/std/multi_array_list.zig +++ b/lib/std/multi_array_list.zig @@ -131,8 +131,8 @@ pub fn MultiArrayList(comptime S: type) type { .capacity = self.capacity, }; var ptr: [*]u8 = self.bytes; - for (sizes.bytes, 0..) |field_size, i| { - result.ptrs[sizes.fields[i]] = ptr; + for (sizes.bytes, sizes.fields) |field_size, i| { + result.ptrs[i] = ptr; ptr += field_size * self.capacity; } return result; @@ -446,16 +446,33 @@ pub fn MultiArrayList(comptime S: type) type { return meta.fieldInfo(S, field).type; } - /// This function is used in tools/zig-gdb.py to fetch the child type to facilitate - /// fancy debug printing for this type. - fn gdbHelper(self: *Self, child: *S) void { + const Entry = entry: { + var entry_fields: [fields.len]std.builtin.Type.StructField = undefined; + for (&entry_fields, sizes.fields) |*entry_field, i| entry_field.* = .{ + .name = fields[i].name ++ "_ptr", + .type = *fields[i].type, + .default_value = null, + .is_comptime = fields[i].is_comptime, + .alignment = fields[i].alignment, + }; + break :entry @Type(.{ .Struct = .{ + .layout = .Extern, + .fields = &entry_fields, + .decls = &.{}, + .is_tuple = false, + } }); + }; + /// This function is used in the debugger pretty formatters in tools/ to fetch the + /// child type to facilitate fancy debug printing for this type. + fn dbHelper(self: *Self, child: *S, entry: *Entry) void { _ = self; _ = child; + _ = entry; } comptime { if (builtin.mode == .Debug) { - _ = gdbHelper; + _ = dbHelper; } } }; |
