glfw: Fixed all uses of the alignCast builtin

This commit is contained in:
thedoctorquantum 2023-06-29 20:37:25 +01:00 committed by Stephen Gutekanst
parent 79cafc0456
commit 70ff87ba8a
4 changed files with 6 additions and 6 deletions

View file

@ -296,7 +296,7 @@ pub inline fn setUserPointer(self: Joystick, comptime T: type, pointer: *T) void
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(@intFromEnum(self.jid)); const ptr = c.glfwGetJoystickUserPointer(@intFromEnum(self.jid));
if (ptr) |p| return @as(PointerType, @ptrCast(@alignCast(@alignOf(std.meta.Child(PointerType)), p))); if (ptr) |p| return @as(PointerType, @ptrCast(@alignCast(p)));
return null; return null;
} }

View file

@ -176,7 +176,7 @@ pub inline fn getUserPointer(self: Monitor, comptime T: type) ?*T {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
const ptr = c.glfwGetMonitorUserPointer(self.handle); const ptr = c.glfwGetMonitorUserPointer(self.handle);
if (ptr == null) return null; if (ptr == null) return null;
return @as(*T, @ptrCast(@alignCast(@alignOf(T), ptr.?))); return @as(*T, @ptrCast(@alignCast(ptr.?)));
} }
/// Returns the available video modes for the specified monitor. /// Returns the available video modes for the specified monitor.

View file

@ -22,7 +22,7 @@ handle: *c.GLFWwindow,
/// Returns a Zig GLFW window from an underlying C GLFW window handle. /// Returns a Zig GLFW window from an underlying C GLFW window handle.
pub inline fn from(handle: *anyopaque) Window { pub inline fn from(handle: *anyopaque) Window {
return Window{ .handle = @as(*c.GLFWwindow, @ptrCast(@alignCast(@alignOf(*c.GLFWwindow), handle))) }; return Window{ .handle = @as(*c.GLFWwindow, @ptrCast(@alignCast(handle))) };
} }
/// Resets all window hints to their default values. /// Resets all window hints to their default values.
@ -1174,7 +1174,7 @@ pub inline fn setUserPointer(self: Window, pointer: ?*anyopaque) void {
/// see also: window_userptr, glfw.Window.setUserPointer /// see also: window_userptr, glfw.Window.setUserPointer
pub inline fn getUserPointer(self: Window, comptime T: type) ?*T { pub inline fn getUserPointer(self: Window, comptime T: type) ?*T {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
if (c.glfwGetWindowUserPointer(self.handle)) |user_pointer| return @as(?*T, @ptrCast(@alignCast(@alignOf(T), user_pointer))); if (c.glfwGetWindowUserPointer(self.handle)) |user_pointer| return @as(?*T, @ptrCast(@alignCast(user_pointer)));
return null; return null;
} }

View file

@ -238,8 +238,8 @@ pub inline fn createWindowSurface(vk_instance: anytype, window: Window, vk_alloc
return c.glfwCreateWindowSurface( return c.glfwCreateWindowSurface(
instance, instance,
window.handle, window.handle,
if (vk_allocation_callbacks == null) null else @as(*const c.VkAllocationCallbacks, @ptrCast(@alignCast(@alignOf(c.VkAllocationCallbacks), vk_allocation_callbacks))), if (vk_allocation_callbacks == null) null else @as(*const c.VkAllocationCallbacks, @ptrCast(@alignCast(vk_allocation_callbacks))),
@as(*c.VkSurfaceKHR, @ptrCast(@alignCast(@alignOf(c.VkSurfaceKHR), vk_surface_khr))), @as(*c.VkSurfaceKHR, @ptrCast(@alignCast(vk_surface_khr))),
); );
} }