File tree 2 files changed +17
-16
lines changed
2 files changed +17
-16
lines changed Original file line number Diff line number Diff line change @@ -2,14 +2,14 @@ package server
2
2
3
3
import " base:runtime"
4
4
5
- import " core:mem"
5
+ import " core:encoding/json"
6
+ import " core:io"
7
+ import " core:log"
6
8
import " core:math/bits"
9
+ import " core:mem"
10
+ import " core:reflect"
7
11
import " core:strconv"
8
12
import " core:strings"
9
- import " core:reflect"
10
- import " core:io"
11
- import " core:encoding/json"
12
- import " core:log"
13
13
14
14
Marshal_Data_Error :: enum {
15
15
None,
@@ -419,7 +419,7 @@ marshal_to_writer :: proc(
419
419
case runtime.Type_Info_Struct:
420
420
opt_write_start (w, opt, ' {' ) or_return
421
421
422
- for name, i in info.names {
422
+ for name, i in info.names[ 0 :info.field_count] {
423
423
id := info.types[i].id
424
424
data := rawptr (uintptr (v.data) + info.offsets[i])
425
425
Original file line number Diff line number Diff line change @@ -3,9 +3,9 @@ package server
3
3
import " base:runtime"
4
4
5
5
import " core:encoding/json"
6
- import " core:strings"
7
- import " core:mem"
8
6
import " core:fmt"
7
+ import " core:mem"
8
+ import " core:strings"
9
9
10
10
/*
11
11
Right now union handling is type specific so you can only have one struct type, int type, etc.
@@ -33,8 +33,8 @@ unmarshal :: proc(
33
33
case json.Object:
34
34
#partial switch variant in type_info.variant {
35
35
case Type_Info_Struct:
36
- for field, i in variant.names {
37
- a := any {
36
+ for field, i in variant.names[ 0 :variant.field_count] {
37
+ a := any {
38
38
rawptr (uintptr (v.data) + uintptr (variant.offsets[i])),
39
39
variant.types[i].id,
40
40
}
@@ -78,11 +78,12 @@ unmarshal :: proc(
78
78
case Type_Info_Dynamic_Array:
79
79
array := (^mem.Raw_Dynamic_Array)(v.data)
80
80
if array.data == nil {
81
- array.data = mem.alloc (
82
- len (j) * variant.elem_size,
83
- variant.elem.align,
84
- allocator,
85
- ) or_else panic (" OOM" )
81
+ array.data =
82
+ mem.alloc (
83
+ len (j) * variant.elem_size,
84
+ variant.elem.align,
85
+ allocator,
86
+ ) or_else panic (" OOM" )
86
87
array.len = len (j)
87
88
array.cap = len (j)
88
89
array.allocator = allocator
@@ -91,7 +92,7 @@ unmarshal :: proc(
91
92
}
92
93
93
94
for i in 0 ..< array.len {
94
- a := any {
95
+ a := any {
95
96
rawptr (
96
97
uintptr (array.data) + uintptr (variant.elem_size * i),
97
98
),
You can’t perform that action at this time.
0 commit comments