glfw: enum-ify 'Joystick.jid', set 'InvalidEnum' as unreachable, and run zig fmt

This commit is contained in:
InKryption 2021-11-22 19:54:36 +01:00 committed by Stephen Gutekanst
parent aae3ea8577
commit 88e0d37325
4 changed files with 68 additions and 79 deletions

View file

@ -61,7 +61,7 @@ pub inline fn init(hints: InitHints) Error!void {
internal_debug.toggleInitialized();
internal_debug.assertInitialized();
errdefer internal_debug.toggleInitialized();
inline for (comptime std.meta.fieldNames(InitHints)) |field_name| {
const init_hint = @field(InitHint, field_name);
const init_value = @field(hints, field_name);
@ -70,7 +70,7 @@ pub inline fn init(hints: InitHints) Error!void {
else => unreachable,
};
}
_ = c.glfwInit();
getError() catch |err| return switch (err) {
Error.PlatformError => err,
@ -318,7 +318,7 @@ pub inline fn waitEventsTimeout(timeout: f64) Error!void {
getError() catch |err| return switch (err) {
// TODO: Consider whether to catch 'GLFW_INVALID_VALUE' from GLFW, or assert that 'timeout' is positive here, in the same manner as GLFW,
// and make its branch unreachable.
Error.InvalidValue,
Error.InvalidValue,
Error.PlatformError,
=> err,
else => unreachable,