goprotobuf: Rename some fields for clarity.
R=r
CC=golang-dev
http://codereview.appspot.com/6576047
diff --git a/proto/decode.go b/proto/decode.go
index a581917..4571d74 100644
--- a/proto/decode.go
+++ b/proto/decode.go
@@ -364,7 +364,7 @@
if tag <= 0 {
return fmt.Errorf("proto: illegal tag %d", tag)
}
- fieldnum, ok := prop.tags.get(tag)
+ fieldnum, ok := prop.decoderTags.get(tag)
if !ok {
// Maybe it's an extension?
if prop.extendable {
diff --git a/proto/lib.go b/proto/lib.go
index 28f9fff..4b3f48e 100644
--- a/proto/lib.go
+++ b/proto/lib.go
@@ -697,7 +697,7 @@
func buildDefaultMessage(t reflect.Type) (dm defaultMessage) {
sprop := GetProperties(t)
for _, prop := range sprop.Prop {
- fi, ok := sprop.tags.get(prop.Tag)
+ fi, ok := sprop.decoderTags.get(prop.Tag)
if !ok {
// XXX_unrecognized
continue
diff --git a/proto/properties.go b/proto/properties.go
index 9bad381..ce6b0d8 100644
--- a/proto/properties.go
+++ b/proto/properties.go
@@ -114,14 +114,15 @@
}
// StructProperties represents properties for all the fields of a struct.
+// decoderTags and decoderOrigNames should only be used by the decoder.
type StructProperties struct {
- Prop []*Properties // properties for each field
- reqCount int // required count
- tags tagMap // map from proto tag to struct field number
- origNames map[string]int // map from original name to struct field number
- order []int // list of struct field numbers in tag order
- unrecField field // field id of the XXX_unrecognized []byte field
- extendable bool // is this an extendable proto
+ Prop []*Properties // properties for each field
+ reqCount int // required count
+ decoderTags tagMap // map from proto tag to struct field number
+ decoderOrigNames map[string]int // map from original name to struct field number
+ order []int // list of struct field numbers in tag order
+ unrecField field // field id of the XXX_unrecognized []byte field
+ extendable bool // is this an extendable proto
}
// Implement the sorting interface so we can sort the fields in tag order, as recommended by the spec.
@@ -545,7 +546,7 @@
// build required counts
// build tags
reqCount := 0
- prop.origNames = make(map[string]int)
+ prop.decoderOrigNames = make(map[string]int)
for i, p := range prop.Prop {
if strings.HasPrefix(p.Name, "XXX_") {
// Internal fields should not appear in tags/origNames maps.
@@ -555,8 +556,8 @@
if p.Required {
reqCount++
}
- prop.tags.put(p.Tag, i)
- prop.origNames[p.OrigName] = i
+ prop.decoderTags.put(p.Tag, i)
+ prop.decoderOrigNames[p.OrigName] = i
}
prop.reqCount = reqCount
diff --git a/proto/text_parser.go b/proto/text_parser.go
index 1dff7cb..1f170bf 100644
--- a/proto/text_parser.go
+++ b/proto/text_parser.go
@@ -374,7 +374,7 @@
// Returns the index in the struct for the named field, as well as the parsed tag properties.
func structFieldByName(st reflect.Type, name string) (int, *Properties, bool) {
sprops := GetProperties(st)
- i, ok := sprops.origNames[name]
+ i, ok := sprops.decoderOrigNames[name]
if ok {
return i, sprops.Prop[i], true
}