glfw: Eliminate Error.InvalidValue

This commit is contained in:
InKryption 2021-11-27 00:51:52 +01:00 committed by Stephen Gutekanst
parent 683c60bdfe
commit 1d648c2256
7 changed files with 79 additions and 33 deletions

View file

@ -131,13 +131,16 @@ pub inline fn swapInterval(interval: isize) Error!void {
/// @thread_safety This function may be called from any thread.
///
/// see also: context_glext, glfw.getProcAddress
pub inline fn extensionSupported(extension: [*:0]const u8) Error!bool {
pub inline fn extensionSupported(extension: [:0]const u8) Error!bool {
internal_debug.assertInitialized();
std.debug.assert(extension.len != 0);
std.debug.assert(extension[0] != 0);
const supported = c.glfwExtensionSupported(extension);
getError() catch |err| return switch (err) {
Error.NoCurrentContext,
Error.InvalidValue,
=> err,
Error.NoCurrentContext => err,
Error.InvalidValue => unreachable, // we assert that 'extension' is a minimally valid value, so this should be impossible
else => unreachable,
};
return supported == c.GLFW_TRUE;