diff options
| author | Alexandros Naskos <alex_naskos@hotmail.com> | 2020-10-02 02:56:18 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-02 02:56:18 +0300 |
| commit | 0228887b943dd7e70f7c5cc56e3993769342abf2 (patch) | |
| tree | 9290c5cdca1974f095efd8ee5dfa9c7ced56689b /lib/std | |
| parent | a4fe438d3940d0beff16c939e991fdff24eb6ba2 (diff) | |
| parent | 362c87f1aab1db7f0019130115f7cadfef782a56 (diff) | |
| download | zig-0228887b943dd7e70f7c5cc56e3993769342abf2.tar.gz zig-0228887b943dd7e70f7c5cc56e3993769342abf2.zip | |
Merge pull request #6428 from tadeokondrak/alignment-typeinfo-struct-union
Add alignment field to TypeInfo.UnionField and TypeInfo.StructField
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/builtin.zig | 2 | ||||
| -rw-r--r-- | lib/std/meta.zig | 2 | ||||
| -rw-r--r-- | lib/std/meta/trailer_flags.zig | 1 |
3 files changed, 5 insertions, 0 deletions
diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index 52b8f641cd..d80d0e88fe 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -262,6 +262,7 @@ pub const TypeInfo = union(enum) { field_type: type, default_value: anytype, is_comptime: bool, + alignment: comptime_int, }; /// This data structure is used by the Zig language code generation and @@ -318,6 +319,7 @@ pub const TypeInfo = union(enum) { pub const UnionField = struct { name: []const u8, field_type: type, + alignment: comptime_int, }; /// This data structure is used by the Zig language code generation and diff --git a/lib/std/meta.zig b/lib/std/meta.zig index 492e497ff4..79b0424e96 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -854,6 +854,7 @@ pub fn ArgsTuple(comptime Function: type) type { .field_type = arg.arg_type.?, .default_value = @as(?(arg.arg_type.?), null), .is_comptime = false, + .alignment = @alignOf(arg.arg_type.?), }; } @@ -884,6 +885,7 @@ pub fn Tuple(comptime types: []const type) type { .field_type = T, .default_value = @as(?T, null), .is_comptime = false, + .alignment = @alignOf(T), }; } diff --git a/lib/std/meta/trailer_flags.zig b/lib/std/meta/trailer_flags.zig index c8c1323686..6cd8dc9357 100644 --- a/lib/std/meta/trailer_flags.zig +++ b/lib/std/meta/trailer_flags.zig @@ -47,6 +47,7 @@ pub fn TrailerFlags(comptime Fields: type) type { @as(?struct_field.field_type, null), ), .is_comptime = false, + .alignment = @alignOf(?struct_field.field_type), }; } break :blk @Type(.{ |
