aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Symonds <dsymonds@golang.org>2014-10-28 11:00:50 +1100
committerDavid Symonds <dsymonds@golang.org>2014-10-28 11:00:50 +1100
commit50386d247745d79b9936c1fe6241315c9e21a296 (patch)
tree7f2e99533b9f1fb737412645ac24a0afd414eb4f
parent30f7034a3e41d02df3e786a9df0a2a5f7a0dfe8a (diff)
downloadprotobuf-50386d247745d79b9936c1fe6241315c9e21a296.tar.gz
goprotobuf: Miscellaneous cleanups.
No significant changes except for debuggers. LGTM=nigeltao R=nigeltao CC=golang-codereviews https://codereview.appspot.com/166720043
-rw-r--r--proto/decode.go2
-rw-r--r--proto/equal.go2
-rw-r--r--proto/properties.go2
-rw-r--r--protoc-gen-go/generator/generator.go10
4 files changed, 9 insertions, 7 deletions
diff --git a/proto/decode.go b/proto/decode.go
index 49a487a..cadee03 100644
--- a/proto/decode.go
+++ b/proto/decode.go
@@ -362,7 +362,7 @@ func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group
}
tag := int(u >> 3)
if tag <= 0 {
- return fmt.Errorf("proto: %s: illegal tag %d", st, tag)
+ return fmt.Errorf("proto: %s: illegal tag %d (wire type %d)", st, tag, wire)
}
fieldnum, ok := prop.decoderTags.get(tag)
if !ok {
diff --git a/proto/equal.go b/proto/equal.go
index 42542e6..60dda9f 100644
--- a/proto/equal.go
+++ b/proto/equal.go
@@ -57,7 +57,7 @@ Equality is defined in this way:
although represented by []byte, is not a repeated field)
- Two unset fields are equal.
- Two unknown field sets are equal if their current
- encoded state is equal. (TODO)
+ encoded state is equal.
- Two extension sets are equal iff they have corresponding
elements that are pairwise equal.
- Every other combination of things are not equal.
diff --git a/proto/properties.go b/proto/properties.go
index ee65ff5..0ed1497 100644
--- a/proto/properties.go
+++ b/proto/properties.go
@@ -300,7 +300,7 @@ func (p *Properties) setEncAndDec(typ reflect.Type, lockGetProp bool) {
switch t1 := typ; t1.Kind() {
default:
- fmt.Fprintf(os.Stderr, "proto: no coders for %T\n", t1)
+ fmt.Fprintf(os.Stderr, "proto: no coders for %v\n", t1)
case reflect.Ptr:
switch t2 := t1.Elem(); t2.Kind() {
diff --git a/protoc-gen-go/generator/generator.go b/protoc-gen-go/generator/generator.go
index f4902c6..6d281b4 100644
--- a/protoc-gen-go/generator/generator.go
+++ b/protoc-gen-go/generator/generator.go
@@ -242,6 +242,7 @@ type FileDescriptor struct {
exported map[Object][]symbol
index int // The index of this file in the list of files to generate code for
+
}
// PackageName is the package name we'll use in the generated code to refer to this file.
@@ -1268,7 +1269,7 @@ func (g *Generator) generateEnum(enum *EnumDescriptor) {
// def= string representation of the default value, if any.
// The default value must be in a representation that can be used at run-time
// to generate the default value. Thus bools become 0 and 1, for instance.
-func (g *Generator) goTag(field *descriptor.FieldDescriptorProto, wiretype string) string {
+func (g *Generator) goTag(message *Descriptor, field *descriptor.FieldDescriptorProto, wiretype string) string {
optrepreq := ""
switch {
case isOptional(field):
@@ -1488,7 +1489,7 @@ func (g *Generator) generateMessage(message *Descriptor) {
usedNames[fieldName] = true
typename, wiretype := g.GoType(message, field)
jsonName := *field.Name
- tag := fmt.Sprintf("protobuf:%s json:%q", g.goTag(field, wiretype), jsonName+",omitempty")
+ tag := fmt.Sprintf("protobuf:%s json:%q", g.goTag(message, field, wiretype), jsonName+",omitempty")
fieldNames[field] = fieldName
fieldGetterNames[field] = fieldGetterName
g.P(fieldName, "\t", typename, "\t`", tag, "`")
@@ -1753,10 +1754,11 @@ func (g *Generator) generateMessage(message *Descriptor) {
func (g *Generator) generateExtension(ext *ExtensionDescriptor) {
ccTypeName := ext.DescName()
- extendedType := "*" + g.TypeName(g.ObjectNamed(*ext.Extendee))
+ extDesc := g.ObjectNamed(*ext.Extendee).(*Descriptor)
+ extendedType := "*" + g.TypeName(extDesc)
field := ext.FieldDescriptorProto
fieldType, wireType := g.GoType(ext.parent, field)
- tag := g.goTag(field, wireType)
+ tag := g.goTag(extDesc, field, wireType)
g.RecordTypeUse(*ext.Extendee)
if n := ext.FieldDescriptorProto.TypeName; n != nil {
// foreign extension type