From 0e1305abc2e1e7dad8af5a319779b393114931de Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 28 Jan 2013 16:45:45 -0800 Subject: cmd/api: normalize byte to uint8 and rune to int32 R=golang-dev, adg, mikioh.mikioh CC=golang-dev https://golang.org/cl/7195049 --- src/cmd/api/goapi.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/cmd/api/goapi.go') diff --git a/src/cmd/api/goapi.go b/src/cmd/api/goapi.go index 1ee852ea79..906cd3a68d 100644 --- a/src/cmd/api/goapi.go +++ b/src/cmd/api/goapi.go @@ -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) -- cgit v1.2.1