all: use explicit backing integers for packed structs

This commit is contained in:
Ali Chraghi 2023-03-28 15:11:13 +03:30 committed by Stephen Gutekanst
parent 4ebf238c5e
commit 266b651b34
9 changed files with 18 additions and 18 deletions

View file

@ -203,7 +203,7 @@ pub const Image = struct {
}
};
pub const PackUASTCFlags = packed struct {
pub const PackUASTCFlags = packed struct(u32) {
fastest: bool = false,
faster: bool = false,
default: bool = false,

View file

@ -117,7 +117,7 @@ pub const Transcoder = struct {
block_count: u32,
};
pub const DecodeFlags = packed struct {
pub const DecodeFlags = packed struct(u32) {
_padding: u1 = 0,
pvrtc_decode_to_next_pow_2: bool = false,
transcode_alpha_data_to_opaque_formats: bool = false,

View file

@ -362,14 +362,14 @@ pub const Key = enum {
unknown,
};
pub const KeyMods = packed struct {
pub const KeyMods = packed struct(u8) {
shift: bool,
control: bool,
alt: bool,
super: bool,
caps_lock: bool,
num_lock: bool,
_reserved: u2 = 0,
_padding: u2 = 0,
};
pub const DisplayMode = enum {

View file

@ -4,12 +4,12 @@ const c = @import("c.zig").c;
/// A bitmask of all Joystick hat states
///
/// See glfw.Joystick.getHats for how these are used.
pub const Hat = packed struct {
pub const Hat = packed struct(u8) {
up: bool = false,
right: bool = false,
down: bool = false,
left: bool = false,
_reserved: u4 = 0,
_padding: u4 = 0,
pub inline fn centered(self: Hat) bool {
return self.up == false and self.right == false and self.down == false and self.left == false;
@ -57,7 +57,7 @@ test "from int, single" {
.right = false,
.down = false,
.left = false,
._reserved = 0,
._padding = 0,
}, Hat.fromInt(RawHat.up));
}
@ -69,7 +69,7 @@ test "from int, multi" {
.right = false,
.down = true,
.left = true,
._reserved = 0,
._padding = 0,
}, Hat.fromInt(RawHat.up | RawHat.down | RawHat.left));
}
@ -81,7 +81,7 @@ test "to int, single" {
.right = false,
.down = false,
.left = false,
._reserved = 0,
._padding = 0,
};
try std.testing.expectEqual(v.toInt(c_int), RawHat.up);
}
@ -94,7 +94,7 @@ test "to int, multi" {
.right = false,
.down = true,
.left = true,
._reserved = 0,
._padding = 0,
};
try std.testing.expectEqual(v.toInt(c_int), RawHat.up | RawHat.down | RawHat.left);
}

View file

@ -6,14 +6,14 @@ const c = @import("c.zig").c;
// must be in sync with GLFW C constants in modifier group, search for "@defgroup mods Modifier key flags"
/// A bitmask of all key modifiers
pub const Mods = packed struct {
pub const Mods = packed struct(u8) {
shift: bool = false,
control: bool = false,
alt: bool = false,
super: bool = false,
caps_lock: bool = false,
num_lock: bool = false,
_reserved: u2 = 0,
_padding: u2 = 0,
inline fn verifyIntType(comptime IntType: type) void {
comptime {

View file

@ -29,7 +29,7 @@ pub const Buffer = opaque {
unmapped_before_callback = 0x00000005,
};
pub const UsageFlags = packed struct {
pub const UsageFlags = packed struct(u32) {
map_read: bool = false,
map_write: bool = false,
copy_src: bool = false,

View file

@ -136,7 +136,7 @@ pub const Texture = opaque {
uint = 0x00000005,
};
pub const UsageFlags = packed struct {
pub const UsageFlags = packed struct(u32) {
copy_src: bool = false,
copy_dst: bool = false,
texture_binding: bool = false,

View file

@ -410,7 +410,7 @@ pub const VertexStepMode = enum(u32) {
vertex_buffer_not_used = 0x00000002,
};
pub const ColorWriteMaskFlags = packed struct {
pub const ColorWriteMaskFlags = packed struct(u32) {
red: bool = false,
green: bool = false,
blue: bool = false,
@ -437,7 +437,7 @@ pub const ColorWriteMaskFlags = packed struct {
}
};
pub const MapModeFlags = packed struct {
pub const MapModeFlags = packed struct(u32) {
read: bool = false,
write: bool = false,
@ -457,7 +457,7 @@ pub const MapModeFlags = packed struct {
}
};
pub const ShaderStageFlags = packed struct {
pub const ShaderStageFlags = packed struct(u32) {
vertex: bool = false,
fragment: bool = false,
compute: bool = false,

View file

@ -154,7 +154,7 @@ pub const Quality = enum(u2) {
double = c.M3D_EXP_DOUBLE,
};
pub const Flags = packed struct {
pub const Flags = packed struct(u32) {
// don't export color map
nocmap: bool = false,
// don't export materials