update to latest Zig (zig fmt)

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2023-06-25 00:01:55 -07:00
parent 83beff8e67
commit 08611c2c9f
7 changed files with 52 additions and 52 deletions

View file

@ -153,7 +153,7 @@ pub inline fn create(image: Image, xhot: i32, yhot: i32) ?Cursor {
/// see also: cursor_object, glfwCreateCursor /// see also: cursor_object, glfwCreateCursor
pub inline fn createStandard(shape: Shape) ?Cursor { pub inline fn createStandard(shape: Shape) ?Cursor {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
if (c.glfwCreateStandardCursor(@intCast(c_int, @enumToInt(shape)))) |cursor| return Cursor{ .ptr = cursor }; if (c.glfwCreateStandardCursor(@intCast(c_int, @intFromEnum(shape)))) |cursor| return Cursor{ .ptr = cursor };
return null; return null;
} }

View file

@ -39,7 +39,7 @@ pub const Id = enum(c_int) {
fourteen = c.GLFW_JOYSTICK_14, fourteen = c.GLFW_JOYSTICK_14,
fifteen = c.GLFW_JOYSTICK_15, fifteen = c.GLFW_JOYSTICK_15,
sixteen = c.GLFW_JOYSTICK_16, sixteen = c.GLFW_JOYSTICK_16,
pub const last = @intToEnum(@This(), c.GLFW_JOYSTICK_LAST); pub const last = @enumFromInt(@This(), c.GLFW_JOYSTICK_LAST);
}; };
/// Gamepad input state /// Gamepad input state
@ -60,12 +60,12 @@ const GamepadState = extern struct {
/// Returns the state of the specified gamepad button. /// Returns the state of the specified gamepad button.
pub fn getButton(self: @This(), which: GamepadButton) Action { pub fn getButton(self: @This(), which: GamepadButton) Action {
return @intToEnum(Action, self.buttons[@intCast(u32, @enumToInt(which))]); return @enumFromInt(Action, self.buttons[@intCast(u32, @intFromEnum(which))]);
} }
/// Returns the status of the specified gamepad axis, in the range -1.0 to 1.0 inclusive. /// Returns the status of the specified gamepad axis, in the range -1.0 to 1.0 inclusive.
pub fn getAxis(self: @This(), which: GamepadAxis) f32 { pub fn getAxis(self: @This(), which: GamepadAxis) f32 {
return self.axes[@intCast(u32, @enumToInt(which))]; return self.axes[@intCast(u32, @intFromEnum(which))];
} }
}; };
@ -85,7 +85,7 @@ const GamepadState = extern struct {
/// see also: joystick /// see also: joystick
pub inline fn present(self: Joystick) bool { pub inline fn present(self: Joystick) bool {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
const is_present = c.glfwJoystickPresent(@enumToInt(self.jid)); const is_present = c.glfwJoystickPresent(@intFromEnum(self.jid));
return is_present == c.GLFW_TRUE; return is_present == c.GLFW_TRUE;
} }
@ -113,7 +113,7 @@ pub inline fn present(self: Joystick) bool {
pub inline fn getAxes(self: Joystick) ?[]const f32 { pub inline fn getAxes(self: Joystick) ?[]const f32 {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
var count: c_int = undefined; var count: c_int = undefined;
const axes = c.glfwGetJoystickAxes(@enumToInt(self.jid), &count); const axes = c.glfwGetJoystickAxes(@intFromEnum(self.jid), &count);
if (axes == null) return null; if (axes == null) return null;
return axes[0..@intCast(u32, count)]; return axes[0..@intCast(u32, count)];
} }
@ -146,7 +146,7 @@ pub inline fn getAxes(self: Joystick) ?[]const f32 {
pub inline fn getButtons(self: Joystick) ?[]const u8 { pub inline fn getButtons(self: Joystick) ?[]const u8 {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
var count: c_int = undefined; var count: c_int = undefined;
const buttons = c.glfwGetJoystickButtons(@enumToInt(self.jid), &count); const buttons = c.glfwGetJoystickButtons(@intFromEnum(self.jid), &count);
if (buttons == null) return null; if (buttons == null) return null;
return buttons[0..@intCast(u32, count)]; return buttons[0..@intCast(u32, count)];
} }
@ -195,7 +195,7 @@ pub inline fn getButtons(self: Joystick) ?[]const u8 {
pub inline fn getHats(self: Joystick) ?[]const Hat { pub inline fn getHats(self: Joystick) ?[]const Hat {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
var count: c_int = undefined; var count: c_int = undefined;
const hats = c.glfwGetJoystickHats(@enumToInt(self.jid), &count); const hats = c.glfwGetJoystickHats(@intFromEnum(self.jid), &count);
if (hats == null) return null; if (hats == null) return null;
const slice = hats[0..@intCast(u32, count)]; const slice = hats[0..@intCast(u32, count)];
return @ptrCast(*const []const Hat, &slice).*; return @ptrCast(*const []const Hat, &slice).*;
@ -223,7 +223,7 @@ pub inline fn getHats(self: Joystick) ?[]const Hat {
/// see also: joystick_name /// see also: joystick_name
pub inline fn getName(self: Joystick) ?[:0]const u8 { pub inline fn getName(self: Joystick) ?[:0]const u8 {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
const name_opt = c.glfwGetJoystickName(@enumToInt(self.jid)); const name_opt = c.glfwGetJoystickName(@intFromEnum(self.jid));
return if (name_opt) |name| return if (name_opt) |name|
std.mem.span(@ptrCast([*:0]const u8, name)) std.mem.span(@ptrCast([*:0]const u8, name))
else else
@ -260,7 +260,7 @@ pub inline fn getName(self: Joystick) ?[:0]const u8 {
/// see also: gamepad /// see also: gamepad
pub inline fn getGUID(self: Joystick) ?[:0]const u8 { pub inline fn getGUID(self: Joystick) ?[:0]const u8 {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
const guid_opt = c.glfwGetJoystickGUID(@enumToInt(self.jid)); const guid_opt = c.glfwGetJoystickGUID(@intFromEnum(self.jid));
return if (guid_opt) |guid| return if (guid_opt) |guid|
std.mem.span(@ptrCast([*:0]const u8, guid)) std.mem.span(@ptrCast([*:0]const u8, guid))
else else
@ -279,7 +279,7 @@ pub inline fn getGUID(self: Joystick) ?[:0]const u8 {
/// see also: joystick_userptr, glfw.Joystick.getUserPointer /// see also: joystick_userptr, glfw.Joystick.getUserPointer
pub inline fn setUserPointer(self: Joystick, comptime T: type, pointer: *T) void { pub inline fn setUserPointer(self: Joystick, comptime T: type, pointer: *T) void {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
c.glfwSetJoystickUserPointer(@enumToInt(self.jid), @ptrCast(*anyopaque, pointer)); c.glfwSetJoystickUserPointer(@intFromEnum(self.jid), @ptrCast(*anyopaque, pointer));
} }
/// Returns the user pointer of the specified joystick. /// Returns the user pointer of the specified joystick.
@ -295,7 +295,7 @@ pub inline fn setUserPointer(self: Joystick, comptime T: type, pointer: *T) void
/// see also: joystick_userptr, glfw.Joystick.setUserPointer /// see also: joystick_userptr, glfw.Joystick.setUserPointer
pub inline fn getUserPointer(self: Joystick, comptime PointerType: type) ?PointerType { pub inline fn getUserPointer(self: Joystick, comptime PointerType: type) ?PointerType {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
const ptr = c.glfwGetJoystickUserPointer(@enumToInt(self.jid)); const ptr = c.glfwGetJoystickUserPointer(@intFromEnum(self.jid));
if (ptr) |p| return @ptrCast(PointerType, @alignCast(@alignOf(std.meta.Child(PointerType)), p)); if (ptr) |p| return @ptrCast(PointerType, @alignCast(@alignOf(std.meta.Child(PointerType)), p));
return null; return null;
} }
@ -335,8 +335,8 @@ pub inline fn setCallback(comptime callback: ?fn (joystick: Joystick, event: Eve
const CWrapper = struct { const CWrapper = struct {
pub fn joystickCallbackWrapper(jid: c_int, event: c_int) callconv(.C) void { pub fn joystickCallbackWrapper(jid: c_int, event: c_int) callconv(.C) void {
@call(.always_inline, user_callback, .{ @call(.always_inline, user_callback, .{
Joystick{ .jid = @intToEnum(Joystick.Id, jid) }, Joystick{ .jid = @enumFromInt(Joystick.Id, jid) },
@intToEnum(Event, event), @enumFromInt(Event, event),
}); });
} }
}; };
@ -394,7 +394,7 @@ pub inline fn updateGamepadMappings(gamepad_mappings: [*:0]const u8) bool {
/// see also: gamepad, glfw.Joystick.getGamepadState /// see also: gamepad, glfw.Joystick.getGamepadState
pub inline fn isGamepad(self: Joystick) bool { pub inline fn isGamepad(self: Joystick) bool {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
const is_gamepad = c.glfwJoystickIsGamepad(@enumToInt(self.jid)); const is_gamepad = c.glfwJoystickIsGamepad(@intFromEnum(self.jid));
return is_gamepad == c.GLFW_TRUE; return is_gamepad == c.GLFW_TRUE;
} }
@ -422,7 +422,7 @@ pub inline fn isGamepad(self: Joystick) bool {
/// see also: gamepad, glfw.Joystick.isGamepad /// see also: gamepad, glfw.Joystick.isGamepad
pub inline fn getGamepadName(self: Joystick) ?[:0]const u8 { pub inline fn getGamepadName(self: Joystick) ?[:0]const u8 {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
const name_opt = c.glfwGetGamepadName(@enumToInt(self.jid)); const name_opt = c.glfwGetGamepadName(@intFromEnum(self.jid));
return if (name_opt) |name| return if (name_opt) |name|
std.mem.span(@ptrCast([*:0]const u8, name)) std.mem.span(@ptrCast([*:0]const u8, name))
else else
@ -457,7 +457,7 @@ pub inline fn getGamepadName(self: Joystick) ?[:0]const u8 {
pub inline fn getGamepadState(self: Joystick) ?GamepadState { pub inline fn getGamepadState(self: Joystick) ?GamepadState {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
var state: GamepadState = undefined; var state: GamepadState = undefined;
const success = c.glfwGetGamepadState(@enumToInt(self.jid), @ptrCast(*c.GLFWgamepadstate, &state)); const success = c.glfwGetGamepadState(@intFromEnum(self.jid), @ptrCast(*c.GLFWgamepadstate, &state));
return if (success == c.GLFW_TRUE) state else null; return if (success == c.GLFW_TRUE) state else null;
} }

View file

@ -387,7 +387,7 @@ pub inline fn setCallback(comptime callback: ?fn (monitor: Monitor, event: Event
pub fn monitorCallbackWrapper(monitor: ?*c.GLFWmonitor, event: c_int) callconv(.C) void { pub fn monitorCallbackWrapper(monitor: ?*c.GLFWmonitor, event: c_int) callconv(.C) void {
@call(.always_inline, user_callback, .{ @call(.always_inline, user_callback, .{
Monitor{ .handle = monitor.? }, Monitor{ .handle = monitor.? },
@intToEnum(Event, event), @enumFromInt(Event, event),
}); });
} }
}; };

View file

@ -229,10 +229,10 @@ pub const Hints = struct {
fn set(hints: Hints) void { fn set(hints: Hints) void {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
inline for (comptime std.meta.fieldNames(Hint)) |field_name| { inline for (comptime std.meta.fieldNames(Hint)) |field_name| {
const hint_tag = @enumToInt(@field(Hint, field_name)); const hint_tag = @intFromEnum(@field(Hint, field_name));
const hint_value = @field(hints, field_name); const hint_value = @field(hints, field_name);
switch (@TypeOf(hint_value)) { switch (@TypeOf(hint_value)) {
bool => c.glfwWindowHint(hint_tag, @boolToInt(hint_value)), bool => c.glfwWindowHint(hint_tag, @intFromBool(hint_value)),
?PositiveCInt => c.glfwWindowHint(hint_tag, if (hint_value) |unwrapped| unwrapped else glfw.dont_care), ?PositiveCInt => c.glfwWindowHint(hint_tag, if (hint_value) |unwrapped| unwrapped else glfw.dont_care),
c_int => c.glfwWindowHint(hint_tag, hint_value), c_int => c.glfwWindowHint(hint_tag, hint_value),
@ -241,7 +241,7 @@ pub const Hints = struct {
ContextRobustness, ContextRobustness,
ContextReleaseBehavior, ContextReleaseBehavior,
OpenGLProfile, OpenGLProfile,
=> c.glfwWindowHint(hint_tag, @enumToInt(hint_value)), => c.glfwWindowHint(hint_tag, @intFromEnum(hint_value)),
[:0]const u8 => c.glfwWindowHintString(hint_tag, hint_value.ptr), [:0]const u8 => c.glfwWindowHintString(hint_tag, hint_value.ptr),
@ -1107,7 +1107,7 @@ pub const Attrib = enum(c_int) {
/// see also: window_attribs, glfw.Window.setAttrib /// see also: window_attribs, glfw.Window.setAttrib
pub inline fn getAttrib(self: Window, attrib: Attrib) i32 { pub inline fn getAttrib(self: Window, attrib: Attrib) i32 {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
return c.glfwGetWindowAttrib(self.handle, @enumToInt(attrib)); return c.glfwGetWindowAttrib(self.handle, @intFromEnum(attrib));
} }
/// Sets an attribute of the specified window. /// Sets an attribute of the specified window.
@ -1148,7 +1148,7 @@ pub inline fn setAttrib(self: Window, attrib: Attrib, value: bool) void {
=> true, => true,
else => false, else => false,
}); });
c.glfwSetWindowAttrib(self.handle, @enumToInt(attrib), if (value) c.GLFW_TRUE else c.GLFW_FALSE); c.glfwSetWindowAttrib(self.handle, @intFromEnum(attrib), if (value) c.GLFW_TRUE else c.GLFW_FALSE);
} }
/// Sets the user pointer of the specified window. /// Sets the user pointer of the specified window.
@ -1541,7 +1541,7 @@ pub inline fn setInputModeCursor(self: Window, value: InputModeCursor) void {
/// Gets the current input mode of the cursor. /// Gets the current input mode of the cursor.
pub inline fn getInputModeCursor(self: Window) InputModeCursor { pub inline fn getInputModeCursor(self: Window) InputModeCursor {
return @intToEnum(InputModeCursor, self.getInputMode(InputMode.cursor)); return @enumFromInt(InputModeCursor, self.getInputMode(InputMode.cursor));
} }
/// Sets the input mode of sticky keys, if enabled a key press will ensure that `glfw.Window.getKey` /// Sets the input mode of sticky keys, if enabled a key press will ensure that `glfw.Window.getKey`
@ -1622,7 +1622,7 @@ pub inline fn getInputModeRawMouseMotion(self: Window) bool {
/// see also: glfw.Window.setInputMode /// see also: glfw.Window.setInputMode
pub inline fn getInputMode(self: Window, mode: InputMode) i32 { pub inline fn getInputMode(self: Window, mode: InputMode) i32 {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
const value = c.glfwGetInputMode(self.handle, @enumToInt(mode)); const value = c.glfwGetInputMode(self.handle, @intFromEnum(mode));
return @intCast(i32, value); return @intCast(i32, value);
} }
@ -1660,10 +1660,10 @@ pub inline fn setInputMode(self: Window, mode: InputMode, value: anytype) void {
const int_value: c_int = switch (@typeInfo(T)) { const int_value: c_int = switch (@typeInfo(T)) {
.Enum, .Enum,
.EnumLiteral, .EnumLiteral,
=> @enumToInt(@as(InputModeCursor, value)), => @intFromEnum(@as(InputModeCursor, value)),
else => @boolToInt(value), else => @intFromBool(value),
}; };
c.glfwSetInputMode(self.handle, @enumToInt(mode), int_value); c.glfwSetInputMode(self.handle, @intFromEnum(mode), int_value);
} }
/// Returns the last reported press state of a keyboard key for the specified window. /// Returns the last reported press state of a keyboard key for the specified window.
@ -1692,8 +1692,8 @@ pub inline fn setInputMode(self: Window, mode: InputMode, value: anytype) void {
/// see also: input_key /// see also: input_key
pub inline fn getKey(self: Window, key: Key) Action { pub inline fn getKey(self: Window, key: Key) Action {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
const state = c.glfwGetKey(self.handle, @enumToInt(key)); const state = c.glfwGetKey(self.handle, @intFromEnum(key));
return @intToEnum(Action, state); return @enumFromInt(Action, state);
} }
/// Returns the last reported state of a mouse button for the specified window. /// Returns the last reported state of a mouse button for the specified window.
@ -1714,8 +1714,8 @@ pub inline fn getKey(self: Window, key: Key) Action {
/// see also: input_mouse_button /// see also: input_mouse_button
pub inline fn getMouseButton(self: Window, button: MouseButton) Action { pub inline fn getMouseButton(self: Window, button: MouseButton) Action {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
const state = c.glfwGetMouseButton(self.handle, @enumToInt(button)); const state = c.glfwGetMouseButton(self.handle, @intFromEnum(button));
return @intToEnum(Action, state); return @enumFromInt(Action, state);
} }
pub const CursorPos = struct { pub const CursorPos = struct {
@ -1848,9 +1848,9 @@ pub inline fn setKeyCallback(self: Window, comptime callback: ?fn (window: Windo
pub fn keyCallbackWrapper(handle: ?*c.GLFWwindow, key: c_int, scancode: c_int, action: c_int, mods: c_int) callconv(.C) void { pub fn keyCallbackWrapper(handle: ?*c.GLFWwindow, key: c_int, scancode: c_int, action: c_int, mods: c_int) callconv(.C) void {
@call(.always_inline, user_callback, .{ @call(.always_inline, user_callback, .{
from(handle.?), from(handle.?),
@intToEnum(Key, key), @enumFromInt(Key, key),
@intCast(i32, scancode), @intCast(i32, scancode),
@intToEnum(Action, action), @enumFromInt(Action, action),
Mods.fromInt(mods), Mods.fromInt(mods),
}); });
} }
@ -1935,8 +1935,8 @@ pub inline fn setMouseButtonCallback(self: Window, comptime callback: ?fn (windo
pub fn mouseButtonCallbackWrapper(handle: ?*c.GLFWwindow, button: c_int, action: c_int, mods: c_int) callconv(.C) void { pub fn mouseButtonCallbackWrapper(handle: ?*c.GLFWwindow, button: c_int, action: c_int, mods: c_int) callconv(.C) void {
@call(.always_inline, user_callback, .{ @call(.always_inline, user_callback, .{
from(handle.?), from(handle.?),
@intToEnum(MouseButton, button), @enumFromInt(MouseButton, button),
@intToEnum(Action, action), @enumFromInt(Action, action),
Mods.fromInt(mods), Mods.fromInt(mods),
}); });
} }
@ -2125,21 +2125,21 @@ inline fn hint(h: Hint, value: anytype) void {
switch (value_type_info) { switch (value_type_info) {
.Int, .ComptimeInt => { .Int, .ComptimeInt => {
c.glfwWindowHint(@enumToInt(h), @intCast(c_int, value)); c.glfwWindowHint(@intFromEnum(h), @intCast(c_int, value));
}, },
.Bool => { .Bool => {
const int_value = @boolToInt(value); const int_value = @intFromBool(value);
c.glfwWindowHint(@enumToInt(h), @intCast(c_int, int_value)); c.glfwWindowHint(@intFromEnum(h), @intCast(c_int, int_value));
}, },
.Enum => { .Enum => {
const int_value = @enumToInt(value); const int_value = @intFromEnum(value);
c.glfwWindowHint(@enumToInt(h), @intCast(c_int, int_value)); c.glfwWindowHint(@intFromEnum(h), @intCast(c_int, int_value));
}, },
.Array => |arr_type| { .Array => |arr_type| {
if (arr_type.child != u8) { if (arr_type.child != u8) {
@compileError("expected array of u8, got " ++ @typeName(arr_type)); @compileError("expected array of u8, got " ++ @typeName(arr_type));
} }
c.glfwWindowHintString(@enumToInt(h), &value[0]); c.glfwWindowHintString(@intFromEnum(h), &value[0]);
}, },
.Pointer => |pointer_info| { .Pointer => |pointer_info| {
const pointed_type = @typeInfo(pointer_info.child); const pointed_type = @typeInfo(pointer_info.child);
@ -2152,7 +2152,7 @@ inline fn hint(h: Hint, value: anytype) void {
else => @compileError("expected pointer to array, got " ++ @typeName(pointed_type)), else => @compileError("expected pointer to array, got " ++ @typeName(pointed_type)),
} }
c.glfwWindowHintString(@enumToInt(h), &value[0]); c.glfwWindowHintString(@intFromEnum(h), &value[0]);
}, },
else => { else => {
@compileError("expected a int, bool, enum, array, or pointer, got " ++ @typeName(value_type)); @compileError("expected a int, bool, enum, array, or pointer, got " ++ @typeName(value_type));

View file

@ -150,7 +150,7 @@ pub const Key = enum(c_int) {
menu = cc.GLFW_KEY_MENU, menu = cc.GLFW_KEY_MENU,
pub inline fn last() Key { pub inline fn last() Key {
return @intToEnum(Key, cc.GLFW_KEY_LAST); return @enumFromInt(Key, cc.GLFW_KEY_LAST);
} }
/// Returns the layout-specific name of the specified printable key. /// Returns the layout-specific name of the specified printable key.
@ -215,7 +215,7 @@ pub const Key = enum(c_int) {
/// see also: input_key_name /// see also: input_key_name
pub inline fn getName(self: Key, scancode: i32) ?[:0]const u8 { pub inline fn getName(self: Key, scancode: i32) ?[:0]const u8 {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
const name_opt = cc.glfwGetKeyName(@enumToInt(self), @intCast(c_int, scancode)); const name_opt = cc.glfwGetKeyName(@intFromEnum(self), @intCast(c_int, scancode));
return if (name_opt) |name| return if (name_opt) |name|
std.mem.span(@ptrCast([*:0]const u8, name)) std.mem.span(@ptrCast([*:0]const u8, name))
else else
@ -237,7 +237,7 @@ pub const Key = enum(c_int) {
/// @thread_safety This function may be called from any thread. /// @thread_safety This function may be called from any thread.
pub inline fn getScancode(self: Key) i32 { pub inline fn getScancode(self: Key) i32 {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
return cc.glfwGetKeyScancode(@enumToInt(self)); return cc.glfwGetKeyScancode(@intFromEnum(self));
} }
}; };

View file

@ -101,7 +101,7 @@ pub inline fn init(hints: InitHints) bool {
const init_hint = @field(InitHint, field_name); const init_hint = @field(InitHint, field_name);
const init_value = @field(hints, field_name); const init_value = @field(hints, field_name);
if (@TypeOf(init_value) == PlatformType) { if (@TypeOf(init_value) == PlatformType) {
initHint(init_hint, @enumToInt(init_value)); initHint(init_hint, @intFromEnum(init_value));
} else { } else {
initHint(init_hint, init_value); initHint(init_hint, init_value);
} }
@ -273,9 +273,9 @@ pub const PlatformType = enum(c_int) {
fn initHint(hint: InitHint, value: anytype) void { fn initHint(hint: InitHint, value: anytype) void {
switch (@typeInfo(@TypeOf(value))) { switch (@typeInfo(@TypeOf(value))) {
.Int, .ComptimeInt => { .Int, .ComptimeInt => {
c.glfwInitHint(@enumToInt(hint), @intCast(c_int, value)); c.glfwInitHint(@intFromEnum(hint), @intCast(c_int, value));
}, },
.Bool => c.glfwInitHint(@enumToInt(hint), @intCast(c_int, @boolToInt(value))), .Bool => c.glfwInitHint(@intFromEnum(hint), @intCast(c_int, @intFromBool(value))),
else => @compileError("expected a int or bool, got " ++ @typeName(@TypeOf(value))), else => @compileError("expected a int or bool, got " ++ @typeName(@TypeOf(value))),
} }
} }
@ -313,7 +313,7 @@ pub inline fn getVersionString() [:0]const u8 {
/// thread_safety: This function may be called from any thread. /// thread_safety: This function may be called from any thread.
pub fn getPlatform() PlatformType { pub fn getPlatform() PlatformType {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
return @intToEnum(PlatformType, c.glfwGetPlatform()); return @enumFromInt(PlatformType, c.glfwGetPlatform());
} }
/// Returns whether the library includes support for the specified platform. /// Returns whether the library includes support for the specified platform.
@ -327,7 +327,7 @@ pub fn getPlatform() PlatformType {
/// thread_safety: This function may be called from any thread. /// thread_safety: This function may be called from any thread.
pub fn platformSupported(platform: PlatformType) bool { pub fn platformSupported(platform: PlatformType) bool {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
return c.glfwPlatformSupported(@enumToInt(platform)) == c.GLFW_TRUE; return c.glfwPlatformSupported(@intFromEnum(platform)) == c.GLFW_TRUE;
} }
/// Processes all pending events. /// Processes all pending events.

View file

@ -231,7 +231,7 @@ pub inline fn createWindowSurface(vk_instance: anytype, window: Window, vk_alloc
// zig-vulkan uses enums to represent opaque pointers: // zig-vulkan uses enums to represent opaque pointers:
// pub const Instance = enum(usize) { null_handle = 0, _ }; // pub const Instance = enum(usize) { null_handle = 0, _ };
const instance: c.VkInstance = switch (@typeInfo(@TypeOf(vk_instance))) { const instance: c.VkInstance = switch (@typeInfo(@TypeOf(vk_instance))) {
.Enum => @intToPtr(c.VkInstance, @enumToInt(vk_instance)), .Enum => @ptrFromInt(c.VkInstance, @intFromEnum(vk_instance)),
else => @ptrCast(c.VkInstance, vk_instance), else => @ptrCast(c.VkInstance, vk_instance),
}; };