1
0
mirror of https://github.com/golang/go synced 2024-11-25 04:37:56 -07:00

fmt: rename internal interfaces

readRuner -> runeReader
unreadRuner -> runeUnreader

R=r, rsc
CC=golang-dev
https://golang.org/cl/4000054
This commit is contained in:
Robert Griesemer 2011-02-02 15:00:14 -08:00
parent b287d7cbe1
commit c5fc3b6972

View File

@ -16,18 +16,11 @@ import (
"utf8" "utf8"
) )
// readRuner is the interface to something that can read runes. If // runeUnreader is the interface to something that can unread runes.
// the object provided to Scan does not satisfy this interface, the
// object will be wrapped by a readRune object.
type readRuner interface {
ReadRune() (rune int, size int, err os.Error)
}
// unreadRuner is the interface to something that can unread runes.
// If the object provided to Scan does not satisfy this interface, // If the object provided to Scan does not satisfy this interface,
// a local buffer will be used to back up the input, but its contents // a local buffer will be used to back up the input, but its contents
// will be lost when Scan returns. // will be lost when Scan returns.
type unreadRuner interface { type runeUnreader interface {
UnreadRune() os.Error UnreadRune() os.Error
} }
@ -138,7 +131,7 @@ const EOF = -1
// ss is the internal implementation of ScanState. // ss is the internal implementation of ScanState.
type ss struct { type ss struct {
rr readRuner // where to read input rr io.RuneReader // where to read input
buf bytes.Buffer // token accumulator buf bytes.Buffer // token accumulator
nlIsSpace bool // whether newline counts as white space nlIsSpace bool // whether newline counts as white space
peekRune int // one-rune lookahead peekRune int // one-rune lookahead
@ -216,7 +209,7 @@ func (s *ss) mustGetRune() (rune int) {
func (s *ss) UngetRune() { func (s *ss) UngetRune() {
if u, ok := s.rr.(unreadRuner); ok { if u, ok := s.rr.(runeUnreader); ok {
u.UnreadRune() u.UnreadRune()
} else { } else {
s.peekRune = s.prevRune s.peekRune = s.prevRune
@ -247,7 +240,7 @@ func (s *ss) Token() (tok string, err os.Error) {
// readRune is a structure to enable reading UTF-8 encoded code points // readRune is a structure to enable reading UTF-8 encoded code points
// from an io.Reader. It is used if the Reader given to the scanner does // from an io.Reader. It is used if the Reader given to the scanner does
// not already implement ReadRuner. // not already implement io.RuneReader.
type readRune struct { type readRune struct {
reader io.Reader reader io.Reader
buf [utf8.UTFMax]byte // used only inside ReadRune buf [utf8.UTFMax]byte // used only inside ReadRune
@ -309,7 +302,7 @@ var ssFree = newCache(func() interface{} { return new(ss) })
// Allocate a new ss struct or grab a cached one. // Allocate a new ss struct or grab a cached one.
func newScanState(r io.Reader, nlIsSpace bool) *ss { func newScanState(r io.Reader, nlIsSpace bool) *ss {
s := ssFree.get().(*ss) s := ssFree.get().(*ss)
if rr, ok := r.(readRuner); ok { if rr, ok := r.(io.RuneReader); ok {
s.rr = rr s.rr = rr
} else { } else {
s.rr = &readRune{reader: r} s.rr = &readRune{reader: r}