Commit b66b22cd authored by Russ Cox's avatar Russ Cox

fmt: remove uintptrGetter type checks

This will make the fmt code easier to gofix
when the new reflect interface is ready.

R=r
CC=golang-dev
https://golang.org/cl/4324043
parent 7a5bbfd4
...@@ -520,12 +520,14 @@ func (p *pp) fmtBytes(v []byte, verb int, goSyntax bool, depth int, value interf ...@@ -520,12 +520,14 @@ func (p *pp) fmtBytes(v []byte, verb int, goSyntax bool, depth int, value interf
} }
func (p *pp) fmtPointer(field interface{}, value reflect.Value, verb int, goSyntax bool) { func (p *pp) fmtPointer(field interface{}, value reflect.Value, verb int, goSyntax bool) {
v, ok := value.(uintptrGetter) var u uintptr
if !ok { // reflect.PtrValue is a uintptrGetter, so failure means it's not a pointer at all. switch value.(type) {
case *reflect.ChanValue, *reflect.FuncValue, *reflect.MapValue, *reflect.PtrValue, *reflect.SliceValue, *reflect.UnsafePointerValue:
u = value.(uintptrGetter).Get()
default:
p.badVerb(verb, field) p.badVerb(verb, field)
return return
} }
u := v.Get()
if goSyntax { if goSyntax {
p.add('(') p.add('(')
p.buf.WriteString(reflect.Typeof(field).String()) p.buf.WriteString(reflect.Typeof(field).String())
...@@ -534,7 +536,7 @@ func (p *pp) fmtPointer(field interface{}, value reflect.Value, verb int, goSynt ...@@ -534,7 +536,7 @@ func (p *pp) fmtPointer(field interface{}, value reflect.Value, verb int, goSynt
if u == 0 { if u == 0 {
p.buf.Write(nilBytes) p.buf.Write(nilBytes)
} else { } else {
p.fmt0x64(uint64(v.Get()), true) p.fmt0x64(uint64(u), true)
} }
p.add(')') p.add(')')
} else { } else {
...@@ -811,7 +813,7 @@ BigSwitch: ...@@ -811,7 +813,7 @@ BigSwitch:
break break
} }
p.fmt0x64(uint64(v), true) p.fmt0x64(uint64(v), true)
case uintptrGetter: case *reflect.ChanValue, *reflect.FuncValue, *reflect.UnsafePointerValue:
p.fmtPointer(field, value, verb, goSyntax) p.fmtPointer(field, value, verb, goSyntax)
default: default:
p.unknownType(f) p.unknownType(f)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment