diff options
author | Rob Pike <r@golang.org> | 2008-12-11 14:41:12 -0800 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2008-12-11 14:41:12 -0800 |
commit | 2b25e4b01751f52a781768dfe697cfcab451cf04 (patch) | |
tree | 0924c6e7bb54e0b9cb4552aefb797f9c2459287f /src/lib/fmt/print.go | |
parent | fcd88948faa3e92ceabe3d5d8e0ea855f1d00e1e (diff) | |
download | golang-2b25e4b01751f52a781768dfe697cfcab451cf04.tar.gz |
add uintptr to reflect and print
R=rsc
DELTA=70 (35 added, 4 deleted, 31 changed)
OCL=20993
CL=20998
Diffstat (limited to 'src/lib/fmt/print.go')
-rw-r--r-- | src/lib/fmt/print.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/fmt/print.go b/src/lib/fmt/print.go index 9c1b0ddfc..0ce27cefb 100644 --- a/src/lib/fmt/print.go +++ b/src/lib/fmt/print.go @@ -231,6 +231,8 @@ func getInt(v reflect.Value) (val int64, signed, ok bool) { return int64(v.(reflect.Uint32Value).Get()), false, true; case reflect.Uint64Kind: return int64(v.(reflect.Uint64Value).Get()), false, true; + case reflect.UintptrKind: + return int64(v.(reflect.UintptrValue).Get()), false, true; } return 0, false, false; } @@ -324,6 +326,10 @@ func (p *P) printField(field reflect.Value) (was_string bool) { case reflect.UintKind, reflect.Uint8Kind, reflect.Uint16Kind, reflect.Uint32Kind, reflect.Uint64Kind: v, signed, ok := getInt(field); s = p.fmt.ud64(uint64(v)).str(); + case reflect.UintptrKind: + v, signed, ok := getInt(field); + p.fmt.sharp = !p.fmt.sharp; // turn 0x on by default + s = p.fmt.ux64(uint64(v)).str(); case reflect.Float32Kind: v, ok := getFloat32(field); s = p.fmt.g32(v).str(); @@ -357,8 +363,7 @@ func (p *P) printField(field reflect.Value) (was_string bool) { } p.addstr("]"); } else { - p.add('0'); - p.add('x'); + p.fmt.sharp = !p.fmt.sharp; // turn 0x on by default s = p.fmt.uX64(uint64(v)).str(); } } |