mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-10 23:13:15 +00:00
Fix fmt.odin printing enums
This commit is contained in:
@@ -45,6 +45,7 @@ del *.ilk > NUL 2> NUL
|
||||
cl %compiler_settings% "src\main.c" ^
|
||||
/link %linker_settings% -OUT:%exe_name% ^
|
||||
&& odin run code/demo.odin
|
||||
rem && odin run code/Jaze/src/main.odin
|
||||
rem && odin build_dll code/example.odin ^
|
||||
rem odin run code/demo.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;
|
||||
|
||||
Reference in New Issue
Block a user