diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-01-08 20:24:12 +0000 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-01-08 20:24:12 +0000 |
| commit | ff473e83425c74bae2cee4c9d68435c7b346533e (patch) | |
| tree | 746fbe47711e1d00ef09214136e53f2a140b9241 /code | |
| parent | 659e5359b2399927ffdd44d441d41a8a6e96228a (diff) | |
"Old style" enums
name and value information
`count`, `min_value`, `max_value` constants
Diffstat (limited to 'code')
| -rw-r--r-- | code/demo.odin | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/code/demo.odin b/code/demo.odin index 1fe4c564d..285abe14d 100644 --- a/code/demo.odin +++ b/code/demo.odin @@ -1,21 +1,31 @@ #import "fmt.odin"; main :: proc() { - fmt.printf("%f", 123); -} - -/* -Standard Library Development: -* Formatted printf -* The Variable -* math - - Trig - - Random - - atoi -* Memory allocation -* File IO -* Timing - - Regular and OS + using Type_Info; + is_type_integer :: proc(info: ^Type_Info) -> bool { + if info == nil { + return false; + } + match type i : type_info_base(info) { + case Integer: + return true; + } + return false; + } -*/ + ti := type_info_base(type_info(Allocator_Mode)); + match type e : ti { + case Enum: + is_int := is_type_integer(e.base); + for i : 0..<e.names.count { + name := e.names[i]; + value := e.values[i]; + if is_int { + fmt.printf("%s - %d\n", name, value.i); + } else { + fmt.printf("%s - %f\n", name, value.f); + } + } + } +} |