Codebase list golang-github-mailru-easyjson / 9825584
Merge pull request #174 from IncSW/master fix marshaling for uint8 custom types Vasily Romanov authored 5 years ago GitHub committed 5 years ago
5 changed file(s) with 24 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
55
66 .root/src/$(PKG):
77 mkdir -p $@
8 for i in $$PWD/* ; do ln -s $$i $@/`basename $$i` ; done
8 for i in $$PWD/* ; do ln -s $$i $@/`basename $$i` ; done
99
1010 root: .root/src/$(PKG)
1111
2626 .root/src/$(PKG)/tests/custom_map_key_type.go \
2727 .root/src/$(PKG)/tests/embedded_type.go
2828
29 .root/bin/easyjson -all .root/src/$(PKG)/tests/data.go
29 .root/bin/easyjson -all .root/src/$(PKG)/tests/data.go
3030 .root/bin/easyjson -all .root/src/$(PKG)/tests/nothing.go
3131 .root/bin/easyjson -all .root/src/$(PKG)/tests/errors.go
3232 .root/bin/easyjson -snake_case .root/src/$(PKG)/tests/snake.go
113113 tmpVar := g.uniqueVarName()
114114 elem := t.Elem()
115115
116 if elem.Kind() == reflect.Uint8 {
116 if elem.Kind() == reflect.Uint8 && elem.Name() == "uint8" {
117117 fmt.Fprintln(g.out, ws+"if in.IsNull() {")
118118 fmt.Fprintln(g.out, ws+" in.Skip()")
119119 fmt.Fprintln(g.out, ws+" "+out+" = nil")
160160 iterVar := g.uniqueVarName()
161161 elem := t.Elem()
162162
163 if elem.Kind() == reflect.Uint8 {
163 if elem.Kind() == reflect.Uint8 && elem.Name() == "uint8" {
164164 fmt.Fprintln(g.out, ws+"if in.IsNull() {")
165165 fmt.Fprintln(g.out, ws+" in.Skip()")
166166 fmt.Fprintln(g.out, ws+"} else {")
136136 iVar := g.uniqueVarName()
137137 vVar := g.uniqueVarName()
138138
139 if t.Elem().Kind() == reflect.Uint8 {
139 if t.Elem().Kind() == reflect.Uint8 && elem.Name() == "uint8" {
140140 fmt.Fprintln(g.out, ws+"out.Base64Bytes("+in+")")
141141 } else {
142142 if !assumeNonEmpty {
165165 elem := t.Elem()
166166 iVar := g.uniqueVarName()
167167
168 if t.Elem().Kind() == reflect.Uint8 {
168 if t.Elem().Kind() == reflect.Uint8 && elem.Name() == "uint8" {
169169 fmt.Fprintln(g.out, ws+"out.Base64Bytes("+in+"[:])")
170170 } else {
171171 fmt.Fprintln(g.out, ws+"out.RawByte('[')")
4949 {&mapUintptrStringValue, mapUintptrStringValueString},
5050 {&intKeyedMapStructValue, intKeyedMapStructValueString},
5151 {&intArrayStructValue, intArrayStructValueString},
52 {&myUInt8SliceValue, myUInt8SliceString},
53 {&myUInt8ArrayValue, myUInt8ArrayString},
5254 }
5355
5456 func TestMarshal(t *testing.T) {
783783 `"pointer":[1,2],` +
784784 `"value":[1,2]` +
785785 `}`
786
787 type MyUInt8 uint8
788
789 //easyjson:json
790 type MyUInt8Slice []MyUInt8
791
792 var myUInt8SliceValue = MyUInt8Slice{1, 2, 3, 4, 5}
793
794 var myUInt8SliceString = `[1,2,3,4,5]`
795
796 //easyjson:json
797 type MyUInt8Array [2]MyUInt8
798
799 var myUInt8ArrayValue = MyUInt8Array{1, 2}
800
801 var myUInt8ArrayString = `[1,2]`