in codec.go [344:414]
func SetValueToPtrDest(dest reflect.Value, v reflect.Value) {
// for number, the type of value may be different with the dest,
// must convert it to the correct type of value then set.
switch dest.Type() {
case _typeOfIntPtr:
vv := v.Int()
dest.Set(reflect.ValueOf(&vv))
return
case _typeOfInt8Ptr:
vv := int8(v.Int())
dest.Set(reflect.ValueOf(&vv))
return
case _typeOfInt16Ptr:
vv := int16(v.Int())
dest.Set(reflect.ValueOf(&vv))
return
case _typeOfInt32Ptr:
if v.Kind() == reflect.String {
vv := rune(v.String()[0])
dest.Set(reflect.ValueOf(&vv))
return
}
vv := int32(v.Int())
dest.Set(reflect.ValueOf(&vv))
return
case _typeOfInt64Ptr:
vv := v.Int()
dest.Set(reflect.ValueOf(&vv))
return
case _typeOfUintPtr:
vv := uint(v.Uint())
dest.Set(reflect.ValueOf(&vv))
return
case _typeOfUint8Ptr:
// v is a int32 here.
vv := uint8(v.Int())
dest.Set(reflect.ValueOf(&vv))
return
case _typeOfUint16Ptr:
vv := uint16(v.Uint())
dest.Set(reflect.ValueOf(&vv))
return
case _typeOfUint32Ptr:
vv := uint32(v.Uint())
dest.Set(reflect.ValueOf(&vv))
return
case _typeOfUint64Ptr:
vv := v.Uint()
dest.Set(reflect.ValueOf(&vv))
return
case _typeOfFloat32Ptr:
vv := float32(v.Float())
dest.Set(reflect.ValueOf(&vv))
case _typeOfFloat64Ptr:
vv := v.Float()
dest.Set(reflect.ValueOf(&vv))
return
case _typeOfRunePtr:
if v.Kind() == reflect.String {
vv := Rune(v.String()[0])
dest.Set(reflect.ValueOf(&vv))
return
}
vv := Rune(v.Int())
dest.Set(reflect.ValueOf(&vv))
return
default:
dest.Set(v)
}
}