diff options
| author | blob1807 <12388588+blob1807@users.noreply.github.com> | 2024-02-21 14:05:50 +1000 |
|---|---|---|
| committer | blob1807 <12388588+blob1807@users.noreply.github.com> | 2024-02-21 14:05:50 +1000 |
| commit | a95cead8e7dfb747cc5afa58dc8f1a76966d035b (patch) | |
| tree | cccc29f41278debb779188c4685d31561023a5c2 /core/encoding/json | |
| parent | c276b1c0bc50e3f66a8003ade48a79c669122dc7 (diff) | |
add all inter types to switch
Diffstat (limited to 'core/encoding/json')
| -rw-r--r-- | core/encoding/json/marshal.odin | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/core/encoding/json/marshal.odin b/core/encoding/json/marshal.odin index f544070b2..78ba4bea4 100644 --- a/core/encoding/json/marshal.odin +++ b/core/encoding/json/marshal.odin @@ -411,11 +411,35 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err: u: runtime.Type_Info_Enum_Value switch i in enum_a { - case int: u = runtime.Type_Info_Enum_Value(i) - case: panic("Invalid enum base type") + case i8: u = runtime.Type_Info_Enum_Value(i) + case i16: u = runtime.Type_Info_Enum_Value(i) + case i32: u = runtime.Type_Info_Enum_Value(i) + case i64: u = runtime.Type_Info_Enum_Value(i) + case int: u = runtime.Type_Info_Enum_Value(i) + case u8: u = runtime.Type_Info_Enum_Value(i) + case u16: u = runtime.Type_Info_Enum_Value(i) + case u32: u = runtime.Type_Info_Enum_Value(i) + case u64: u = runtime.Type_Info_Enum_Value(i) + case uint: u = runtime.Type_Info_Enum_Value(i) + case uintptr: u = runtime.Type_Info_Enum_Value(i) + + case i16le: u = runtime.Type_Info_Enum_Value(i) + case i32le: u = runtime.Type_Info_Enum_Value(i) + case i64le: u = runtime.Type_Info_Enum_Value(i) + case u16le: u = runtime.Type_Info_Enum_Value(i) + case u32le: u = runtime.Type_Info_Enum_Value(i) + case u64le: u = runtime.Type_Info_Enum_Value(i) + + case i16be: u = runtime.Type_Info_Enum_Value(i) + case i32be: u = runtime.Type_Info_Enum_Value(i) + case i64be: u = runtime.Type_Info_Enum_Value(i) + case u16be: u = runtime.Type_Info_Enum_Value(i) + case u32be: u = runtime.Type_Info_Enum_Value(i) + case u64be: u = runtime.Type_Info_Enum_Value(i) + case: panic("Invalid enum base type") } - pos, found := slice.binary_search(info.values, u) + pos, found := slice.linear_search(info.values, u) if found { return marshal_to_writer(w, any(info.names[pos]), opt) } else { |