Commit 0e1305ab authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

cmd/api: normalize byte to uint8 and rune to int32

R=golang-dev, adg, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7195049
parent 91e99c13
This diff is collapsed.
This diff is collapsed.
......@@ -1140,10 +1140,21 @@ func (w *Walker) namelessField(f *ast.Field) *ast.Field {
}
}
var (
byteRx = regexp.MustCompile(`\bbyte\b`)
runeRx = regexp.MustCompile(`\brune\b`)
)
func (w *Walker) emitFeature(feature string) {
if !w.wantedPkg[w.curPackageName] {
return
}
if strings.Contains(feature, "byte") {
feature = byteRx.ReplaceAllString(feature, "uint8")
}
if strings.Contains(feature, "rune") {
feature = runeRx.ReplaceAllString(feature, "int32")
}
f := strings.Join(w.scope, ", ") + ", " + feature
if _, dup := w.features[f]; dup {
panic("duplicate feature inserted: " + f)
......@@ -1159,6 +1170,7 @@ func (w *Walker) emitFeature(feature string) {
}
panic("feature contains newlines: " + f)
}
w.features[f] = true
if *verbose {
log.Printf("feature: %s", f)
......
......@@ -28,6 +28,9 @@ pkg p1, method (TPtrExported) OnEmbedded()
pkg p1, method (TPtrUnexported) OnBothTandBPtr()
pkg p1, method (TPtrUnexported) OnBothTandBVal()
pkg p1, type B struct
pkg p1, type ByteStruct struct
pkg p1, type ByteStruct struct, B uint8
pkg p1, type ByteStruct struct, R int32
pkg p1, type Codec struct
pkg p1, type Codec struct, Func func(int, int) int
pkg p1, type EmbedSelector struct
......@@ -65,7 +68,9 @@ pkg p1, type T struct
pkg p1, type TPtrExported struct
pkg p1, type TPtrExported struct, embedded *Embedded
pkg p1, type TPtrUnexported struct
pkg p1, var ByteConv []byte
pkg p1, var Byte uint8
pkg p1, var ByteConv []uint8
pkg p1, var ByteFunc func(uint8) int32
pkg p1, var ChecksumError error
pkg p1, var SIPtr *SI
pkg p1, var SIPtr2 *SI
......
......@@ -193,3 +193,11 @@ var ifaceVar interface{} = 5
var assertVar = ifaceVar.(int)
var indexVar = m["foo"]
var Byte byte
var ByteFunc func(byte) rune
type ByteStruct struct {
B byte
R rune
}
pkg p3, method (*ThirdBase) GoodPlayer() (int, int, int)
pkg p3, func BadHop(int, int, int) (bool, bool, *ThirdBase, *ThirdBase, error)
pkg p3, method (*ThirdBase) GoodPlayer() (int, int, int)
pkg p3, type ThirdBase struct
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