@@ -31,6 +31,10 @@ type intCodec struct {
3131}
3232
3333func (codec * intCodec ) Decode (ptr unsafe.Pointer , iter * Iterator ) {
34+ if iter .ReadNil () {
35+ * ((* int )(ptr )) = 0
36+ return
37+ }
3438 * ((* int )(ptr )) = iter .ReadInt ()
3539}
3640
@@ -50,6 +54,10 @@ type uintptrCodec struct {
5054}
5155
5256func (codec * uintptrCodec ) Decode (ptr unsafe.Pointer , iter * Iterator ) {
57+ if iter .ReadNil () {
58+ * ((* uintptr )(ptr )) = 0
59+ return
60+ }
5361 * ((* uintptr )(ptr )) = uintptr (iter .ReadUint64 ())
5462}
5563
@@ -69,6 +77,10 @@ type int8Codec struct {
6977}
7078
7179func (codec * int8Codec ) Decode (ptr unsafe.Pointer , iter * Iterator ) {
80+ if iter .ReadNil () {
81+ * ((* uint8 )(ptr )) = 0
82+ return
83+ }
7284 * ((* int8 )(ptr )) = iter .ReadInt8 ()
7385}
7486
@@ -88,6 +100,10 @@ type int16Codec struct {
88100}
89101
90102func (codec * int16Codec ) Decode (ptr unsafe.Pointer , iter * Iterator ) {
103+ if iter .ReadNil () {
104+ * ((* int16 )(ptr )) = 0
105+ return
106+ }
91107 * ((* int16 )(ptr )) = iter .ReadInt16 ()
92108}
93109
@@ -107,6 +123,10 @@ type int32Codec struct {
107123}
108124
109125func (codec * int32Codec ) Decode (ptr unsafe.Pointer , iter * Iterator ) {
126+ if iter .ReadNil () {
127+ * ((* int32 )(ptr )) = 0
128+ return
129+ }
110130 * ((* int32 )(ptr )) = iter .ReadInt32 ()
111131}
112132
@@ -126,6 +146,10 @@ type int64Codec struct {
126146}
127147
128148func (codec * int64Codec ) Decode (ptr unsafe.Pointer , iter * Iterator ) {
149+ if iter .ReadNil () {
150+ * ((* int64 )(ptr )) = 0
151+ return
152+ }
129153 * ((* int64 )(ptr )) = iter .ReadInt64 ()
130154}
131155
@@ -145,6 +169,10 @@ type uintCodec struct {
145169}
146170
147171func (codec * uintCodec ) Decode (ptr unsafe.Pointer , iter * Iterator ) {
172+ if iter .ReadNil () {
173+ * ((* uint )(ptr )) = 0
174+ return
175+ }
148176 * ((* uint )(ptr )) = iter .ReadUint ()
149177}
150178
@@ -164,6 +192,10 @@ type uint8Codec struct {
164192}
165193
166194func (codec * uint8Codec ) Decode (ptr unsafe.Pointer , iter * Iterator ) {
195+ if iter .ReadNil () {
196+ * ((* uint8 )(ptr )) = 0
197+ return
198+ }
167199 * ((* uint8 )(ptr )) = iter .ReadUint8 ()
168200}
169201
@@ -183,6 +215,10 @@ type uint16Codec struct {
183215}
184216
185217func (codec * uint16Codec ) Decode (ptr unsafe.Pointer , iter * Iterator ) {
218+ if iter .ReadNil () {
219+ * ((* uint16 )(ptr )) = 0
220+ return
221+ }
186222 * ((* uint16 )(ptr )) = iter .ReadUint16 ()
187223}
188224
@@ -202,6 +238,10 @@ type uint32Codec struct {
202238}
203239
204240func (codec * uint32Codec ) Decode (ptr unsafe.Pointer , iter * Iterator ) {
241+ if iter .ReadNil () {
242+ * ((* uint32 )(ptr )) = 0
243+ return
244+ }
205245 * ((* uint32 )(ptr )) = iter .ReadUint32 ()
206246}
207247
@@ -221,6 +261,10 @@ type uint64Codec struct {
221261}
222262
223263func (codec * uint64Codec ) Decode (ptr unsafe.Pointer , iter * Iterator ) {
264+ if iter .ReadNil () {
265+ * ((* uint64 )(ptr )) = 0
266+ return
267+ }
224268 * ((* uint64 )(ptr )) = iter .ReadUint64 ()
225269}
226270
@@ -240,6 +284,10 @@ type float32Codec struct {
240284}
241285
242286func (codec * float32Codec ) Decode (ptr unsafe.Pointer , iter * Iterator ) {
287+ if iter .ReadNil () {
288+ * ((* float32 )(ptr )) = 0
289+ return
290+ }
243291 * ((* float32 )(ptr )) = iter .ReadFloat32 ()
244292}
245293
@@ -259,6 +307,10 @@ type float64Codec struct {
259307}
260308
261309func (codec * float64Codec ) Decode (ptr unsafe.Pointer , iter * Iterator ) {
310+ if iter .ReadNil () {
311+ * ((* float64 )(ptr )) = 0
312+ return
313+ }
262314 * ((* float64 )(ptr )) = iter .ReadFloat64 ()
263315}
264316
0 commit comments