Commit 28ba9777 authored by Rob Pike's avatar Rob Pike

rename Formatter to State and Format to Formatter, for nomenclatural consistency

R=rsc
DELTA=9  (0 added, 0 deleted, 9 changed)
OCL=30658
CL=30658
parent be639b9a
...@@ -722,7 +722,7 @@ func fmtbase(c int) uint { ...@@ -722,7 +722,7 @@ func fmtbase(c int) uint {
// Format is a support routine for fmt.Formatter. It accepts // Format is a support routine for fmt.Formatter. It accepts
// the formats 'b' (binary), 'o' (octal), and 'x' (hexadecimal). // the formats 'b' (binary), 'o' (octal), and 'x' (hexadecimal).
// //
func (x Natural) Format(h fmt.Formatter, c int) { func (x Natural) Format(h fmt.State, c int) {
fmt.Fprintf(h, "%s", x.ToString(fmtbase(c))); fmt.Fprintf(h, "%s", x.ToString(fmtbase(c)));
} }
...@@ -1252,7 +1252,7 @@ func (x *Integer) String() string { ...@@ -1252,7 +1252,7 @@ func (x *Integer) String() string {
// Format is a support routine for fmt.Formatter. It accepts // Format is a support routine for fmt.Formatter. It accepts
// the formats 'b' (binary), 'o' (octal), and 'x' (hexadecimal). // the formats 'b' (binary), 'o' (octal), and 'x' (hexadecimal).
// //
func (x *Integer) Format(h fmt.Formatter, c int) { func (x *Integer) Format(h fmt.State, c int) {
fmt.Fprintf(h, "%s", x.ToString(fmtbase(c))); fmt.Fprintf(h, "%s", x.ToString(fmtbase(c)));
} }
...@@ -1424,7 +1424,7 @@ func (x *Rational) String() string { ...@@ -1424,7 +1424,7 @@ func (x *Rational) String() string {
// Format is a support routine for fmt.Formatter. It accepts // Format is a support routine for fmt.Formatter. It accepts
// the formats 'b' (binary), 'o' (octal), and 'x' (hexadecimal). // the formats 'b' (binary), 'o' (octal), and 'x' (hexadecimal).
// //
func (x *Rational) Format(h fmt.Formatter, c int) { func (x *Rational) Format(h fmt.State, c int) {
fmt.Fprintf(h, "%s", x.ToString(fmtbase(c))); fmt.Fprintf(h, "%s", x.ToString(fmtbase(c)));
} }
......
...@@ -172,7 +172,7 @@ func TestSprintf(t *testing.T) { ...@@ -172,7 +172,7 @@ func TestSprintf(t *testing.T) {
} }
type flagPrinter struct { } type flagPrinter struct { }
func (*flagPrinter) Format(f fmt.Formatter, c int) { func (*flagPrinter) Format(f fmt.State, c int) {
s := "%"; s := "%";
for i := 0; i < 128; i++ { for i := 0; i < 128; i++ {
if f.Flag(i) { if f.Flag(i) {
......
...@@ -74,10 +74,10 @@ import ( ...@@ -74,10 +74,10 @@ import (
"utf8"; "utf8";
) )
// Formatter represents the printer state passed to custom formatters. // State represents the printer state passed to custom formatters.
// It provides access to the io.Writer interface plus information about // It provides access to the io.Writer interface plus information about
// the flags and options for the operand's format specifier. // the flags and options for the operand's format specifier.
type Formatter interface { type State interface {
// Write is the function to call to emit formatted output to be printed. // Write is the function to call to emit formatted output to be printed.
Write(b []byte) (ret int, err os.Error); Write(b []byte) (ret int, err os.Error);
// Width returns the value of the width option and whether it has been set. // Width returns the value of the width option and whether it has been set.
...@@ -92,8 +92,8 @@ type Formatter interface { ...@@ -92,8 +92,8 @@ type Formatter interface {
// Format is the interface implemented by objects with a custom formatter. // Format is the interface implemented by objects with a custom formatter.
// The implementation of Format may call Sprintf or Fprintf(f) etc. // The implementation of Format may call Sprintf or Fprintf(f) etc.
// to generate its output. // to generate its output.
type Format interface { type Formatter interface {
Format(f Formatter, c int); Format(f State, c int);
} }
// String represents any object being printed that has a String() method that // String represents any object being printed that has a String() method that
...@@ -565,7 +565,7 @@ func (p *pp) doprintf(format string, v reflect.StructValue) { ...@@ -565,7 +565,7 @@ func (p *pp) doprintf(format string, v reflect.StructValue) {
fieldnum++; fieldnum++;
inter := field.Interface(); inter := field.Interface();
if inter != nil && c != 'T' { // don't want thing to describe itself if we're asking for its type if inter != nil && c != 'T' { // don't want thing to describe itself if we're asking for its type
if formatter, ok := inter.(Format); ok { if formatter, ok := inter.(Formatter); ok {
formatter.Format(p, c); formatter.Format(p, c);
continue; continue;
} }
......
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