@ enum type

This commit is contained in:
agra
2026-02-14 14:52:39 +02:00
parent fe7efeadb0
commit d61c6488f3
12 changed files with 164 additions and 41 deletions

View File

@@ -7,13 +7,16 @@ Perms :: enum flags {
execute;
}
// Explicit values (e.g. for C interop)
WindowFlags :: enum flags {
// Explicit values with u32 backing type (e.g. for C interop)
WindowFlags :: enum flags u32 {
vsync :: 64;
resizable :: 4;
hidden :: 128;
}
// Backing type on plain enums too
Color :: enum u8 { red; green; blue; }
check_perms :: (p: Perms) {
print(" checking: {}\n", p);
if p & .read { print(" - can read\n"); }
@@ -53,6 +56,11 @@ main :: () {
print("\nwindow: {}\n", w);
print("raw value: {}\n", cast(s64) w);
// Backing type on plain enums
c :Color = .blue;
print("\ncolor: {}\n", c);
print("raw: {}\n", cast(s64) c);
// Bitwise ops work on plain integers too
x := 0xFF & 0x0F;
y := 1 | 2 | 4;