fix #soa '%#v' formatting

This commit is contained in:
Matias Fernandez
2024-04-17 22:54:30 -04:00
parent 9bbe26f80f
commit e296b050ee
+19 -2
View File
@@ -1900,7 +1900,7 @@ fmt_struct :: proc(fi: ^Info, v: any, the_verb: rune, info: runtime.Type_Info_St
// fi.hash = false; // fi.hash = false;
fi.indent += 1 fi.indent += 1
if hash { if !is_soa && hash {
io.write_byte(fi.writer, '\n', &fi.n) io.write_byte(fi.writer, '\n', &fi.n)
} }
defer { defer {
@@ -1934,6 +1934,9 @@ fmt_struct :: proc(fi: ^Info, v: any, the_verb: rune, info: runtime.Type_Info_St
n = uintptr((^int)(uintptr(v.data) + info.offsets[actual_field_count])^) n = uintptr((^int)(uintptr(v.data) + info.offsets[actual_field_count])^)
} }
if hash && n > 0 {
io.write_byte(fi.writer, '\n', &fi.n)
}
for index in 0..<n { for index in 0..<n {
if !hash && index > 0 { io.write_string(fi.writer, ", ", &fi.n) } if !hash && index > 0 { io.write_string(fi.writer, ", ", &fi.n) }
@@ -1942,9 +1945,23 @@ fmt_struct :: proc(fi: ^Info, v: any, the_verb: rune, info: runtime.Type_Info_St
if !hash && field_count > 0 { io.write_string(fi.writer, ", ", &fi.n) } if !hash && field_count > 0 { io.write_string(fi.writer, ", ", &fi.n) }
if hash {
fi.indent -= 1
fmt_write_indent(fi)
fi.indent += 1
}
io.write_string(fi.writer, base_type_name, &fi.n) io.write_string(fi.writer, base_type_name, &fi.n)
io.write_byte(fi.writer, '{', &fi.n) io.write_byte(fi.writer, '{', &fi.n)
defer io.write_byte(fi.writer, '}', &fi.n) if hash { io.write_byte(fi.writer, '\n', &fi.n) }
defer {
if hash {
fi.indent -= 1
fmt_write_indent(fi)
fi.indent += 1
}
io.write_byte(fi.writer, '}', &fi.n)
if hash { io.write_string(fi.writer, ",\n", &fi.n) }
}
fi.record_level += 1 fi.record_level += 1
defer fi.record_level -= 1 defer fi.record_level -= 1