Skip to content

Commit c6a75ec

Browse files
pascaldekloealecthomas
authored andcommitted
Consistency (alecthomas#83)
* Rename Xdr to XDR. * Use 32-bit siblings with gencode, just like the rest. * Sync ProtoBuf and GoGo Protobuf with go modules version. * Use testing Helper declaration instead of stringer. * Error handling for all. * Some debug information on error.
1 parent f3feb07 commit c6a75ec

7 files changed

+287
-297
lines changed

gencode-unsafe.schema

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ struct GencodeUnsafeA {
22
Name string
33
BirthDay int64
44
Phone string
5-
Siblings vint64
5+
Siblings vint32
66
Spouse bool
77
Money float64
8-
}
8+
}

gencode-unsafe.schema.gen.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type GencodeUnsafeA struct {
1616
Name string
1717
BirthDay int64
1818
Phone string
19-
Siblings int64
19+
Siblings int32
2020
Spouse bool
2121
Money float64
2222
}
@@ -55,7 +55,7 @@ func (d *GencodeUnsafeA) Size() (s uint64) {
5555
}
5656
{
5757

58-
t := uint64(d.Siblings)
58+
t := uint32(d.Siblings)
5959
t <<= 1
6060
if d.Siblings < 0 {
6161
t = ^t
@@ -126,7 +126,7 @@ func (d *GencodeUnsafeA) Marshal(buf []byte) ([]byte, error) {
126126
}
127127
{
128128

129-
t := uint64(d.Siblings)
129+
t := uint32(d.Siblings)
130130

131131
t <<= 1
132132
if d.Siblings < 0 {
@@ -208,15 +208,15 @@ func (d *GencodeUnsafeA) Unmarshal(buf []byte) (uint64, error) {
208208
{
209209

210210
bs := uint8(7)
211-
t := uint64(buf[i+8] & 0x7F)
211+
t := uint32(buf[i+8] & 0x7F)
212212
for buf[i+8]&0x80 == 0x80 {
213213
i++
214-
t |= uint64(buf[i+8]&0x7F) << bs
214+
t |= uint32(buf[i+8]&0x7F) << bs
215215
bs += 7
216216
}
217217
i++
218218

219-
d.Siblings = int64(t >> 1)
219+
d.Siblings = int32(t >> 1)
220220
if t&1 != 0 {
221221
d.Siblings = ^d.Siblings
222222
}

gencode.schema

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ struct GencodeA {
22
Name string
33
BirthDay time
44
Phone string
5-
Siblings vint64
5+
Siblings vint32
66
Spouse bool
77
Money float64
8-
}
8+
}

gencode.schema.gen.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type GencodeA struct {
1616
Name string
1717
BirthDay time.Time
1818
Phone string
19-
Siblings int64
19+
Siblings int32
2020
Spouse bool
2121
Money float64
2222
}
@@ -55,7 +55,7 @@ func (d *GencodeA) Size() (s uint64) {
5555
}
5656
{
5757

58-
t := uint64(d.Siblings)
58+
t := uint32(d.Siblings)
5959
t <<= 1
6060
if d.Siblings < 0 {
6161
t = ^t
@@ -128,7 +128,7 @@ func (d *GencodeA) Marshal(buf []byte) ([]byte, error) {
128128
}
129129
{
130130

131-
t := uint64(d.Siblings)
131+
t := uint32(d.Siblings)
132132

133133
t <<= 1
134134
if d.Siblings < 0 {
@@ -224,15 +224,15 @@ func (d *GencodeA) Unmarshal(buf []byte) (uint64, error) {
224224
{
225225

226226
bs := uint8(7)
227-
t := uint64(buf[i+15] & 0x7F)
227+
t := uint32(buf[i+15] & 0x7F)
228228
for buf[i+15]&0x80 == 0x80 {
229229
i++
230-
t |= uint64(buf[i+15]&0x7F) << bs
230+
t |= uint32(buf[i+15]&0x7F) << bs
231231
bs += 7
232232
}
233233
i++
234234

235-
d.Siblings = int64(t >> 1)
235+
d.Siblings = int32(t >> 1)
236236
if t&1 != 0 {
237237
d.Siblings = ^d.Siblings
238238
}

0 commit comments

Comments
 (0)