mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
gtk: correct comptime adwaita.versionAtLeast() comparison (#4084)
Companion to #3977
This commit is contained in:
@ -25,7 +25,10 @@ pub inline fn enabled(config: *const Config) bool {
|
|||||||
/// in the headers. If it is run in a runtime context, it will
|
/// in the headers. If it is run in a runtime context, it will
|
||||||
/// check the actual version of the library we are linked against.
|
/// check the actual version of the library we are linked against.
|
||||||
/// So generally you probably want to do both checks!
|
/// So generally you probably want to do both checks!
|
||||||
pub fn versionAtLeast(
|
///
|
||||||
|
/// This is inlined so that the comptime checks will disable the
|
||||||
|
/// runtime checks if the comptime checks fail.
|
||||||
|
pub inline fn versionAtLeast(
|
||||||
comptime major: u16,
|
comptime major: u16,
|
||||||
comptime minor: u16,
|
comptime minor: u16,
|
||||||
comptime micro: u16,
|
comptime micro: u16,
|
||||||
@ -37,8 +40,9 @@ pub fn versionAtLeast(
|
|||||||
// compiling against unknown symbols and makes runtime checks
|
// compiling against unknown symbols and makes runtime checks
|
||||||
// very slightly faster.
|
// very slightly faster.
|
||||||
if (comptime c.ADW_MAJOR_VERSION < major or
|
if (comptime c.ADW_MAJOR_VERSION < major or
|
||||||
c.ADW_MINOR_VERSION < minor or
|
(c.ADW_MAJOR_VERSION == major and c.ADW_MINOR_VERSION < minor) or
|
||||||
c.ADW_MICRO_VERSION < micro) return false;
|
(c.ADW_MAJOR_VERSION == major and c.ADW_MINOR_VERSION == minor and c.ADW_MICRO_VERSION < micro))
|
||||||
|
return false;
|
||||||
|
|
||||||
// If we're in comptime then we can't check the runtime version.
|
// If we're in comptime then we can't check the runtime version.
|
||||||
if (@inComptime()) return true;
|
if (@inComptime()) return true;
|
||||||
@ -56,3 +60,16 @@ pub fn versionAtLeast(
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "versionAtLeast" {
|
||||||
|
const testing = std.testing;
|
||||||
|
|
||||||
|
try testing.expect(versionAtLeast(c.ADW_MAJOR_VERSION, c.ADW_MINOR_VERSION, c.ADW_MICRO_VERSION));
|
||||||
|
try testing.expect(!versionAtLeast(c.ADW_MAJOR_VERSION, c.ADW_MINOR_VERSION, c.ADW_MICRO_VERSION + 1));
|
||||||
|
try testing.expect(!versionAtLeast(c.ADW_MAJOR_VERSION, c.ADW_MINOR_VERSION + 1, c.ADW_MICRO_VERSION));
|
||||||
|
try testing.expect(!versionAtLeast(c.ADW_MAJOR_VERSION + 1, c.ADW_MINOR_VERSION, c.ADW_MICRO_VERSION));
|
||||||
|
try testing.expect(versionAtLeast(c.ADW_MAJOR_VERSION - 1, c.ADW_MINOR_VERSION, c.ADW_MICRO_VERSION));
|
||||||
|
try testing.expect(versionAtLeast(c.ADW_MAJOR_VERSION - 1, c.ADW_MINOR_VERSION + 1, c.ADW_MICRO_VERSION));
|
||||||
|
try testing.expect(versionAtLeast(c.ADW_MAJOR_VERSION - 1, c.ADW_MINOR_VERSION, c.ADW_MICRO_VERSION + 1));
|
||||||
|
try testing.expect(versionAtLeast(c.ADW_MAJOR_VERSION, c.ADW_MINOR_VERSION - 1, c.ADW_MICRO_VERSION + 1));
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user