From a95cead8e7dfb747cc5afa58dc8f1a76966d035b Mon Sep 17 00:00:00 2001 From: blob1807 <12388588+blob1807@users.noreply.github.com> Date: Wed, 21 Feb 2024 14:05:50 +1000 Subject: [PATCH] add all inter types to switch --- core/encoding/json/marshal.odin | 30 +++++++++++++++++++++++++++--- 1 file 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 {