diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2025-12-08 14:03:13 +0000 |
|---|---|---|
| committer | gingerBill <gingerBill@users.noreply.github.com> | 2025-12-08 14:03:13 +0000 |
| commit | 3a3239294c9e4a7504bfb60e3cb5f8229fe6a326 (patch) | |
| tree | 7065908e8ba0833cebf67e5b54d4f83dd9a287a2 /core/fmt | |
| parent | f9f4dcd207fb58a791a23ed4b08afe380e9fc17c (diff) | |
`raw_union_tag` allow for comma separation for multiple mappings
Diffstat (limited to 'core/fmt')
| -rw-r--r-- | core/fmt/fmt.odin | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index fd0af7559..c05b8eb62 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -2112,21 +2112,26 @@ __handle_raw_union_tag :: proc(fi: ^Info, v: any, the_verb: rune, info: runtime. tag_string := reflect.enum_string(tag) for tag, index in info.tags[:info.field_count] { - rut := reflect.struct_tag_lookup(reflect.Struct_Tag(tag), "raw_union_tag") or_continue - head_tag, match, tail_name := strings.partition(string(rut), "=") - if head_tag != tag_name || match != "=" { - continue - } + rut_list := reflect.struct_tag_lookup(reflect.Struct_Tag(tag), "raw_union_tag") or_continue - // just ignore the `A.` prefix for `A.B` stuff entirely - if _, _, try_tail_name := strings.partition(string(rut), "."); try_tail_name != "" { - tail_name = try_tail_name - } + for rut in strings.split_iterator(&rut_list, ",") { + head_tag, match, tail_name := strings.partition(string(rut), "=") + if head_tag != tag_name || match != "=" { + continue + } + + // just ignore the `A.` prefix for `A.B` stuff entirely + if _, _, try_tail_name := strings.partition(string(rut), "."); try_tail_name != "" { + tail_name = try_tail_name + } - if tail_name == tag_string { - io.write_string(fi.writer, "#raw_union ", &fi.n) - fmt_arg(fi, any{v.data, info.types[index].id}, the_verb) - return true + if tail_name == tag_string { + io.write_string(fi.writer, "#raw_union(.", &fi.n) + io.write_string(fi.writer, tag_string, &fi.n) + io.write_string(fi.writer, ") ", &fi.n) + fmt_arg(fi, any{v.data, info.types[index].id}, the_verb) + return true + } } } } |