diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-02-24 20:55:35 +0000 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-02-24 20:55:35 +0000 |
| commit | eec709c545cb2f2c754db83e374d66f83c432ae9 (patch) | |
| tree | 67d0eb6f4058cddba54978cd4a54673c58836681 /core | |
| parent | 9b2f5c359a6bc1ab1c8d6a27ebf859c4ed512980 (diff) | |
Fix fmt.odin printing enums
Diffstat (limited to 'core')
| -rw-r--r-- | core/fmt.odin | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/core/fmt.odin b/core/fmt.odin index e623f533b..80517ee95 100644 --- a/core/fmt.odin +++ b/core/fmt.odin @@ -268,7 +268,12 @@ buffer_write_type :: proc(buf: ^Buffer, ti: ^Type_Info) { buffer_write_string(buf, "enum "); buffer_write_type(buf, info.base); buffer_write_string(buf, " {"); - + for name, i in info.names { + if i > 0 { + buffer_write_string(buf, ", "); + } + buffer_write_string(buf, name); + } buffer_write_string(buf, "}"); } } @@ -708,13 +713,13 @@ fmt_enum :: proc(fi: ^Fmt_Info, v: any, verb: rune) { case u32: i = cast(i64)v; case u64: i = cast(i64)v; case uint: i = cast(i64)v; - case f32: f = cast(f64)v; - case f64: f = cast(f64)v; + case f32: f = cast(f64)v; i = transmute(i64)f; + case f64: f = cast(f64)v; i = transmute(i64)f; } if types.is_string(e.base) { - for it, idx in e.values { - if it.i == i { + for val, idx in e.values { + if val.i == i { buffer_write_string(fi.buf, e.names[idx]); ok = true; break; @@ -724,8 +729,8 @@ fmt_enum :: proc(fi: ^Fmt_Info, v: any, verb: rune) { buffer_write_string(fi.buf, ""); ok = true; } else { - for it, idx in e.values { - if it.f == f { + for val, idx in e.values { + if val.i == i { buffer_write_string(fi.buf, e.names[idx]); ok = true; break; |