mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-18 16:51:31 -07:00
Change is_utf16 field to encoding and use an enum
This commit is contained in:
@@ -298,7 +298,7 @@ tag_base64_unmarshal :: proc(_: ^Tag_Implementation, d: Decoder, _: Tag_Number,
|
||||
|
||||
#partial switch t in ti.variant {
|
||||
case reflect.Type_Info_String:
|
||||
assert(!t.is_utf16)
|
||||
assert(t.encoding == .UTF_8)
|
||||
if t.is_cstring {
|
||||
length := base64.decoded_len(bytes)
|
||||
builder := strings.builder_make(0, length+1)
|
||||
|
||||
@@ -335,7 +335,7 @@ _unmarshal_value :: proc(d: Decoder, v: any, hdr: Header, allocator := context.a
|
||||
_unmarshal_bytes :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Header, add: Add, allocator := context.allocator, loc := #caller_location) -> (err: Unmarshal_Error) {
|
||||
#partial switch t in ti.variant {
|
||||
case reflect.Type_Info_String:
|
||||
assert(!t.is_utf16)
|
||||
assert(t.encoding == .UTF_8)
|
||||
|
||||
bytes := err_conv(_decode_bytes(d, add, allocator=allocator, loc=loc)) or_return
|
||||
|
||||
|
||||
@@ -571,7 +571,7 @@ unmarshal_object :: proc(p: ^Parser, v: any, end_token: Token_Kind) -> (err: Unm
|
||||
|
||||
#partial switch tk in t.key.variant {
|
||||
case runtime.Type_Info_String:
|
||||
assert(!tk.is_utf16)
|
||||
assert(tk.encoding == .UTF_8)
|
||||
|
||||
key_ptr = rawptr(&key)
|
||||
key_cstr: cstring
|
||||
|
||||
@@ -127,7 +127,7 @@ parse_and_set_pointer_by_base_type :: proc(ptr: rawptr, str: string, type_info:
|
||||
}
|
||||
|
||||
case runtime.Type_Info_String:
|
||||
assert(!specific_type_info.is_utf16)
|
||||
assert(specific_type_info.encoding == .UTF_8)
|
||||
|
||||
if specific_type_info.is_cstring {
|
||||
cstr_ptr := (^cstring)(ptr)
|
||||
|
||||
@@ -514,8 +514,9 @@ write_type_writer :: #force_no_inline proc(w: io.Writer, ti: ^Type_Info, n_writt
|
||||
io.write_byte(w, 'c', &n) or_return
|
||||
}
|
||||
io.write_string(w, "string", &n) or_return
|
||||
if info.is_utf16 {
|
||||
io.write_string(w, "16", &n) or_return
|
||||
switch info.encoding {
|
||||
case .UTF_8: /**/
|
||||
case .UTF_16: io.write_string(w, "16", &n) or_return
|
||||
}
|
||||
case Type_Info_Boolean:
|
||||
switch ti.id {
|
||||
|
||||
Reference in New Issue
Block a user