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 | 5 |
|
6 | 6 |
.root/src/$(PKG):
|
7 | 7 |
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
|
9 | 9 |
|
10 | 10 |
root: .root/src/$(PKG)
|
11 | 11 |
|
|
26 | 26 |
.root/src/$(PKG)/tests/custom_map_key_type.go \
|
27 | 27 |
.root/src/$(PKG)/tests/embedded_type.go
|
28 | 28 |
|
29 | |
.root/bin/easyjson -all .root/src/$(PKG)/tests/data.go
|
|
29 |
.root/bin/easyjson -all .root/src/$(PKG)/tests/data.go
|
30 | 30 |
.root/bin/easyjson -all .root/src/$(PKG)/tests/nothing.go
|
31 | 31 |
.root/bin/easyjson -all .root/src/$(PKG)/tests/errors.go
|
32 | 32 |
.root/bin/easyjson -snake_case .root/src/$(PKG)/tests/snake.go
|
113 | 113 |
tmpVar := g.uniqueVarName()
|
114 | 114 |
elem := t.Elem()
|
115 | 115 |
|
116 | |
if elem.Kind() == reflect.Uint8 {
|
|
116 |
if elem.Kind() == reflect.Uint8 && elem.Name() == "uint8" {
|
117 | 117 |
fmt.Fprintln(g.out, ws+"if in.IsNull() {")
|
118 | 118 |
fmt.Fprintln(g.out, ws+" in.Skip()")
|
119 | 119 |
fmt.Fprintln(g.out, ws+" "+out+" = nil")
|
|
160 | 160 |
iterVar := g.uniqueVarName()
|
161 | 161 |
elem := t.Elem()
|
162 | 162 |
|
163 | |
if elem.Kind() == reflect.Uint8 {
|
|
163 |
if elem.Kind() == reflect.Uint8 && elem.Name() == "uint8" {
|
164 | 164 |
fmt.Fprintln(g.out, ws+"if in.IsNull() {")
|
165 | 165 |
fmt.Fprintln(g.out, ws+" in.Skip()")
|
166 | 166 |
fmt.Fprintln(g.out, ws+"} else {")
|
136 | 136 |
iVar := g.uniqueVarName()
|
137 | 137 |
vVar := g.uniqueVarName()
|
138 | 138 |
|
139 | |
if t.Elem().Kind() == reflect.Uint8 {
|
|
139 |
if t.Elem().Kind() == reflect.Uint8 && elem.Name() == "uint8" {
|
140 | 140 |
fmt.Fprintln(g.out, ws+"out.Base64Bytes("+in+")")
|
141 | 141 |
} else {
|
142 | 142 |
if !assumeNonEmpty {
|
|
165 | 165 |
elem := t.Elem()
|
166 | 166 |
iVar := g.uniqueVarName()
|
167 | 167 |
|
168 | |
if t.Elem().Kind() == reflect.Uint8 {
|
|
168 |
if t.Elem().Kind() == reflect.Uint8 && elem.Name() == "uint8" {
|
169 | 169 |
fmt.Fprintln(g.out, ws+"out.Base64Bytes("+in+"[:])")
|
170 | 170 |
} else {
|
171 | 171 |
fmt.Fprintln(g.out, ws+"out.RawByte('[')")
|
49 | 49 |
{&mapUintptrStringValue, mapUintptrStringValueString},
|
50 | 50 |
{&intKeyedMapStructValue, intKeyedMapStructValueString},
|
51 | 51 |
{&intArrayStructValue, intArrayStructValueString},
|
|
52 |
{&myUInt8SliceValue, myUInt8SliceString},
|
|
53 |
{&myUInt8ArrayValue, myUInt8ArrayString},
|
52 | 54 |
}
|
53 | 55 |
|
54 | 56 |
func TestMarshal(t *testing.T) {
|
783 | 783 |
`"pointer":[1,2],` +
|
784 | 784 |
`"value":[1,2]` +
|
785 | 785 |
`}`
|
|
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]`
|