Skip to content

Commit

Permalink
debug: println tENUM
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaost committed Oct 21, 2024
1 parent 4378967 commit e7d8a4e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions internal/reflect/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,25 @@ func (d *tDecoder) mallocIfPointer(t *tType, p unsafe.Pointer) (ret unsafe.Point
return p
}

var hextable = "0123456789abcdef"

func dump4bytes(b []byte) string {
_ = b[3]
return "{" + string([]byte{
hextable[(b[0]>>4)&0xf],
hextable[b[0]&0xf],
' ',
hextable[(b[1]>>4)&0xf],
hextable[b[1]&0xf],
' ',
hextable[(b[2]>>4)&0xf],
hextable[b[2]&0xf],
' ',
hextable[(b[3]>>4)&0xf],
hextable[b[3]&0xf],
}) + "}"
}

func (d *tDecoder) Decode(b []byte, base unsafe.Pointer, sd *structDesc, maxdepth int) (int, error) {
if maxdepth == 0 {
return 0, errDepthLimitExceeded
Expand Down Expand Up @@ -124,6 +143,14 @@ func (d *tDecoder) Decode(b []byte, base unsafe.Pointer, sd *structDesc, maxdept
p = d.mallocIfPointer(t, p)
if t.FixedSize > 0 {
i += decodeFixedSizeTypes(t.T, b[i:], p)
if t.T == tENUM {
println("DEBUG tENUM",
lookupFieldName(sd.rt, f.Offset),
dump4bytes(b[i-4:]),
p,
*(*int64)(p),
)
}
} else {
n, err := d.decodeType(t, b[i:], p, maxdepth-1)
if err != nil {
Expand Down

0 comments on commit e7d8a4e

Please sign in to comment.