@ enum type
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user