diff --git a/src/platform/common.zig b/src/platform/common.zig index 4964678b..116b4ff8 100644 --- a/src/platform/common.zig +++ b/src/platform/common.zig @@ -8,39 +8,24 @@ pub fn checkApplication(comptime app_pkg: type) void { if (@hasDecl(App, "init")) { const InitFn = @TypeOf(@field(App, "init")); - if (@import("builtin").zig_backend == .stage1) { - if (InitFn != fn (app: *App, core: *Core) @typeInfo(@typeInfo(InitFn).Fn.return_type.?).ErrorUnion.error_set!void) - @compileError("expected 'pub fn init(app: *App, core: *mach.Core) !void' found '" ++ @typeName(InitFn) ++ "'"); - } else { - if (InitFn != *const fn (app: *App, core: *Core) @typeInfo(@typeInfo(InitFn).Fn.return_type.?).ErrorUnion.error_set!void) - @compileError("expected 'pub fn init(app: *App, core: *mach.Core) !void' found '" ++ @typeName(InitFn) ++ "'"); - } + if (InitFn != fn (app: *App, core: *Core) @typeInfo(@typeInfo(InitFn).Fn.return_type.?).ErrorUnion.error_set!void) + @compileError("expected 'pub fn init(app: *App, core: *mach.Core) !void' found '" ++ @typeName(InitFn) ++ "'"); } else { @compileError("App must export 'pub fn init(app: *App, core: *mach.Core) !void'"); } if (@hasDecl(App, "update")) { const UpdateFn = @TypeOf(@field(App, "update")); - if (@import("builtin").zig_backend == .stage1) { - if (UpdateFn != fn (app: *App, core: *Core) @typeInfo(@typeInfo(UpdateFn).Fn.return_type.?).ErrorUnion.error_set!void) - @compileError("expected 'pub fn update(app: *App, core: *mach.Core) !void' found '" ++ @typeName(UpdateFn) ++ "'"); - } else { - if (UpdateFn != *const fn (app: *App, core: *Core) @typeInfo(@typeInfo(UpdateFn).Fn.return_type.?).ErrorUnion.error_set!void) - @compileError("expected 'pub fn update(app: *App, core: *mach.Core) !void' found '" ++ @typeName(UpdateFn) ++ "'"); - } + if (UpdateFn != fn (app: *App, core: *Core) @typeInfo(@typeInfo(UpdateFn).Fn.return_type.?).ErrorUnion.error_set!void) + @compileError("expected 'pub fn update(app: *App, core: *mach.Core) !void' found '" ++ @typeName(UpdateFn) ++ "'"); } else { @compileError("App must export 'pub fn update(app: *App, core: *mach.Core) !void'"); } if (@hasDecl(App, "deinit")) { const DeinitFn = @TypeOf(@field(App, "deinit")); - if (@import("builtin").zig_backend == .stage1) { - if (DeinitFn != fn (app: *App, core: *Core) void) - @compileError("expected 'pub fn deinit(app: *App, core: *mach.Core) void' found '" ++ @typeName(DeinitFn) ++ "'"); - } else { - if (DeinitFn != *const fn (app: *App, core: *Core) void) - @compileError("expected 'pub fn deinit(app: *App, core: *mach.Core) void' found '" ++ @typeName(DeinitFn) ++ "'"); - } + if (DeinitFn != fn (app: *App, core: *Core) void) + @compileError("expected 'pub fn deinit(app: *App, core: *mach.Core) void' found '" ++ @typeName(DeinitFn) ++ "'"); } else { @compileError("App must export 'pub fn deinit(app: *App, core: *mach.Core) void'"); } diff --git a/src/platform/native.zig b/src/platform/native.zig index 2c3c71ed..fff4d56c 100644 --- a/src/platform/native.zig +++ b/src/platform/native.zig @@ -341,8 +341,8 @@ pub const Platform = struct { try platform.window.setSize(.{ .width = options.width, .height = options.height }); try platform.window.setTitle(options.title); try platform.window.setSizeLimits( - @bitCast(glfw.Window.SizeOptional, options.size_min), - @bitCast(glfw.Window.SizeOptional, options.size_max), + glfwSizeOptional(options.size_min), + glfwSizeOptional(options.size_max), ); platform.core.target_desc.present_mode = switch (options.vsync) { .none => .immediate, @@ -669,3 +669,10 @@ pub fn coreUpdate(core: *Core, resize: ?CoreResizeCallback) !void { core.current_desc = core.target_desc; } } + +fn glfwSizeOptional(size: structs.SizeOptional) glfw.Window.SizeOptional { + return .{ + .width = size.width, + .height = size.height, + }; +}