|
|
@ -173,6 +173,8 @@ var ( |
|
|
|
func makeDecoder(typ reflect.Type, tags tags) (dec decoder, err error) { |
|
|
|
func makeDecoder(typ reflect.Type, tags tags) (dec decoder, err error) { |
|
|
|
kind := typ.Kind() |
|
|
|
kind := typ.Kind() |
|
|
|
switch { |
|
|
|
switch { |
|
|
|
|
|
|
|
case typ == rawValueType: |
|
|
|
|
|
|
|
return decodeRawValue, nil |
|
|
|
case typ.Implements(decoderInterface): |
|
|
|
case typ.Implements(decoderInterface): |
|
|
|
return decodeDecoder, nil |
|
|
|
return decodeDecoder, nil |
|
|
|
case kind != reflect.Ptr && reflect.PtrTo(typ).Implements(decoderInterface): |
|
|
|
case kind != reflect.Ptr && reflect.PtrTo(typ).Implements(decoderInterface): |
|
|
@ -203,6 +205,15 @@ func makeDecoder(typ reflect.Type, tags tags) (dec decoder, err error) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func decodeRawValue(s *Stream, val reflect.Value) error { |
|
|
|
|
|
|
|
r, err := s.Raw() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
val.SetBytes(r) |
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func decodeUint(s *Stream, val reflect.Value) error { |
|
|
|
func decodeUint(s *Stream, val reflect.Value) error { |
|
|
|
typ := val.Type() |
|
|
|
typ := val.Type() |
|
|
|
num, err := s.uint(typ.Bits()) |
|
|
|
num, err := s.uint(typ.Bits()) |
|
|
|