Przeglądaj źródła

goprotobuf: Switch to using protobuf-2.5.0 as the baseline.

Regenerating descriptor.pb.go also lays the path for using SourceCodeInfo in the code generator.

R=r
CC=golang-dev
https://codereview.appspot.com/11893043
David Symonds 12 lat temu
rodzic
commit
5bbe4ae0ac

+ 2 - 2
protoc-gen-go/descriptor/Makefile

@@ -30,10 +30,10 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 # Not stored here, but descriptor.proto is in http://code.google.com/p/protobuf
-# at protobuf-2.3.0/src/google/protobuf/descriptor.proto
+# at protobuf-2.5.0/src/google/protobuf/descriptor.proto
 regenerate:
 	echo WARNING! THIS RULE IS PROBABLY NOT RIGHT FOR YOUR INSTALLATION
-	cd $(HOME)/src/protobuf-2.3.0/src && \
+	cd $(HOME)/src/protobuf-2.5.0/src && \
 	protoc --go_out=. ./google/protobuf/descriptor.proto && \
 	cp ./google/protobuf/descriptor.pb.go $(GOPATH)/src/code.google.com/p/goprotobuf/protoc-gen-go/descriptor/descriptor.pb.go
 

+ 130 - 13
protoc-gen-go/descriptor/descriptor.pb.go

@@ -241,6 +241,7 @@ type FileDescriptorProto struct {
 	Service          []*ServiceDescriptorProto `protobuf:"bytes,6,rep,name=service" json:"service,omitempty"`
 	Extension        []*FieldDescriptorProto   `protobuf:"bytes,7,rep,name=extension" json:"extension,omitempty"`
 	Options          *FileOptions              `protobuf:"bytes,8,opt,name=options" json:"options,omitempty"`
+	SourceCodeInfo   *SourceCodeInfo           `protobuf:"bytes,9,opt,name=source_code_info" json:"source_code_info,omitempty"`
 	XXX_unrecognized []byte                    `json:"-"`
 }
 
@@ -318,6 +319,13 @@ func (m *FileDescriptorProto) GetOptions() *FileOptions {
 	return nil
 }
 
+func (m *FileDescriptorProto) GetSourceCodeInfo() *SourceCodeInfo {
+	if m != nil {
+		return m.SourceCodeInfo
+	}
+	return nil
+}
+
 type DescriptorProto struct {
 	Name             *string                           `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
 	Field            []*FieldDescriptorProto           `protobuf:"bytes,2,rep,name=field" json:"field,omitempty"`
@@ -615,16 +623,18 @@ func (m *MethodDescriptorProto) GetOptions() *MethodOptions {
 }
 
 type FileOptions struct {
-	JavaPackage         *string                   `protobuf:"bytes,1,opt,name=java_package" json:"java_package,omitempty"`
-	JavaOuterClassname  *string                   `protobuf:"bytes,8,opt,name=java_outer_classname" json:"java_outer_classname,omitempty"`
-	JavaMultipleFiles   *bool                     `protobuf:"varint,10,opt,name=java_multiple_files,def=0" json:"java_multiple_files,omitempty"`
-	OptimizeFor         *FileOptions_OptimizeMode `protobuf:"varint,9,opt,name=optimize_for,enum=google.protobuf.FileOptions_OptimizeMode,def=1" json:"optimize_for,omitempty"`
-	CcGenericServices   *bool                     `protobuf:"varint,16,opt,name=cc_generic_services,def=1" json:"cc_generic_services,omitempty"`
-	JavaGenericServices *bool                     `protobuf:"varint,17,opt,name=java_generic_services,def=1" json:"java_generic_services,omitempty"`
-	PyGenericServices   *bool                     `protobuf:"varint,18,opt,name=py_generic_services,def=1" json:"py_generic_services,omitempty"`
-	UninterpretedOption []*UninterpretedOption    `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"`
-	XXX_extensions      map[int32]proto.Extension `json:"-"`
-	XXX_unrecognized    []byte                    `json:"-"`
+	JavaPackage               *string                   `protobuf:"bytes,1,opt,name=java_package" json:"java_package,omitempty"`
+	JavaOuterClassname        *string                   `protobuf:"bytes,8,opt,name=java_outer_classname" json:"java_outer_classname,omitempty"`
+	JavaMultipleFiles         *bool                     `protobuf:"varint,10,opt,name=java_multiple_files,def=0" json:"java_multiple_files,omitempty"`
+	JavaGenerateEqualsAndHash *bool                     `protobuf:"varint,20,opt,name=java_generate_equals_and_hash,def=0" json:"java_generate_equals_and_hash,omitempty"`
+	OptimizeFor               *FileOptions_OptimizeMode `protobuf:"varint,9,opt,name=optimize_for,enum=google.protobuf.FileOptions_OptimizeMode,def=1" json:"optimize_for,omitempty"`
+	GoPackage                 *string                   `protobuf:"bytes,11,opt,name=go_package" json:"go_package,omitempty"`
+	CcGenericServices         *bool                     `protobuf:"varint,16,opt,name=cc_generic_services,def=0" json:"cc_generic_services,omitempty"`
+	JavaGenericServices       *bool                     `protobuf:"varint,17,opt,name=java_generic_services,def=0" json:"java_generic_services,omitempty"`
+	PyGenericServices         *bool                     `protobuf:"varint,18,opt,name=py_generic_services,def=0" json:"py_generic_services,omitempty"`
+	UninterpretedOption       []*UninterpretedOption    `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"`
+	XXX_extensions            map[int32]proto.Extension `json:"-"`
+	XXX_unrecognized          []byte                    `json:"-"`
 }
 
 func (m *FileOptions) Reset()         { *m = FileOptions{} }
@@ -646,10 +656,11 @@ func (m *FileOptions) ExtensionMap() map[int32]proto.Extension {
 }
 
 const Default_FileOptions_JavaMultipleFiles bool = false
+const Default_FileOptions_JavaGenerateEqualsAndHash bool = false
 const Default_FileOptions_OptimizeFor FileOptions_OptimizeMode = FileOptions_SPEED
-const Default_FileOptions_CcGenericServices bool = true
-const Default_FileOptions_JavaGenericServices bool = true
-const Default_FileOptions_PyGenericServices bool = true
+const Default_FileOptions_CcGenericServices bool = false
+const Default_FileOptions_JavaGenericServices bool = false
+const Default_FileOptions_PyGenericServices bool = false
 
 func (m *FileOptions) GetJavaPackage() string {
 	if m != nil && m.JavaPackage != nil {
@@ -672,6 +683,13 @@ func (m *FileOptions) GetJavaMultipleFiles() bool {
 	return Default_FileOptions_JavaMultipleFiles
 }
 
+func (m *FileOptions) GetJavaGenerateEqualsAndHash() bool {
+	if m != nil && m.JavaGenerateEqualsAndHash != nil {
+		return *m.JavaGenerateEqualsAndHash
+	}
+	return Default_FileOptions_JavaGenerateEqualsAndHash
+}
+
 func (m *FileOptions) GetOptimizeFor() FileOptions_OptimizeMode {
 	if m != nil && m.OptimizeFor != nil {
 		return *m.OptimizeFor
@@ -679,6 +697,13 @@ func (m *FileOptions) GetOptimizeFor() FileOptions_OptimizeMode {
 	return Default_FileOptions_OptimizeFor
 }
 
+func (m *FileOptions) GetGoPackage() string {
+	if m != nil && m.GoPackage != nil {
+		return *m.GoPackage
+	}
+	return ""
+}
+
 func (m *FileOptions) GetCcGenericServices() bool {
 	if m != nil && m.CcGenericServices != nil {
 		return *m.CcGenericServices
@@ -760,8 +785,10 @@ func (m *MessageOptions) GetUninterpretedOption() []*UninterpretedOption {
 type FieldOptions struct {
 	Ctype               *FieldOptions_CType       `protobuf:"varint,1,opt,name=ctype,enum=google.protobuf.FieldOptions_CType,def=0" json:"ctype,omitempty"`
 	Packed              *bool                     `protobuf:"varint,2,opt,name=packed" json:"packed,omitempty"`
+	Lazy                *bool                     `protobuf:"varint,5,opt,name=lazy,def=0" json:"lazy,omitempty"`
 	Deprecated          *bool                     `protobuf:"varint,3,opt,name=deprecated,def=0" json:"deprecated,omitempty"`
 	ExperimentalMapKey  *string                   `protobuf:"bytes,9,opt,name=experimental_map_key" json:"experimental_map_key,omitempty"`
+	Weak                *bool                     `protobuf:"varint,10,opt,name=weak,def=0" json:"weak,omitempty"`
 	UninterpretedOption []*UninterpretedOption    `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"`
 	XXX_extensions      map[int32]proto.Extension `json:"-"`
 	XXX_unrecognized    []byte                    `json:"-"`
@@ -786,7 +813,9 @@ func (m *FieldOptions) ExtensionMap() map[int32]proto.Extension {
 }
 
 const Default_FieldOptions_Ctype FieldOptions_CType = FieldOptions_STRING
+const Default_FieldOptions_Lazy bool = false
 const Default_FieldOptions_Deprecated bool = false
+const Default_FieldOptions_Weak bool = false
 
 func (m *FieldOptions) GetCtype() FieldOptions_CType {
 	if m != nil && m.Ctype != nil {
@@ -802,6 +831,13 @@ func (m *FieldOptions) GetPacked() bool {
 	return false
 }
 
+func (m *FieldOptions) GetLazy() bool {
+	if m != nil && m.Lazy != nil {
+		return *m.Lazy
+	}
+	return Default_FieldOptions_Lazy
+}
+
 func (m *FieldOptions) GetDeprecated() bool {
 	if m != nil && m.Deprecated != nil {
 		return *m.Deprecated
@@ -816,6 +852,13 @@ func (m *FieldOptions) GetExperimentalMapKey() string {
 	return ""
 }
 
+func (m *FieldOptions) GetWeak() bool {
+	if m != nil && m.Weak != nil {
+		return *m.Weak
+	}
+	return Default_FieldOptions_Weak
+}
+
 func (m *FieldOptions) GetUninterpretedOption() []*UninterpretedOption {
 	if m != nil {
 		return m.UninterpretedOption
@@ -824,6 +867,7 @@ func (m *FieldOptions) GetUninterpretedOption() []*UninterpretedOption {
 }
 
 type EnumOptions struct {
+	AllowAlias          *bool                     `protobuf:"varint,2,opt,name=allow_alias,def=1" json:"allow_alias,omitempty"`
 	UninterpretedOption []*UninterpretedOption    `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"`
 	XXX_extensions      map[int32]proto.Extension `json:"-"`
 	XXX_unrecognized    []byte                    `json:"-"`
@@ -847,6 +891,15 @@ func (m *EnumOptions) ExtensionMap() map[int32]proto.Extension {
 	return m.XXX_extensions
 }
 
+const Default_EnumOptions_AllowAlias bool = true
+
+func (m *EnumOptions) GetAllowAlias() bool {
+	if m != nil && m.AllowAlias != nil {
+		return *m.AllowAlias
+	}
+	return Default_EnumOptions_AllowAlias
+}
+
 func (m *EnumOptions) GetUninterpretedOption() []*UninterpretedOption {
 	if m != nil {
 		return m.UninterpretedOption
@@ -954,6 +1007,7 @@ type UninterpretedOption struct {
 	NegativeIntValue *int64                          `protobuf:"varint,5,opt,name=negative_int_value" json:"negative_int_value,omitempty"`
 	DoubleValue      *float64                        `protobuf:"fixed64,6,opt,name=double_value" json:"double_value,omitempty"`
 	StringValue      []byte                          `protobuf:"bytes,7,opt,name=string_value" json:"string_value,omitempty"`
+	AggregateValue   *string                         `protobuf:"bytes,8,opt,name=aggregate_value" json:"aggregate_value,omitempty"`
 	XXX_unrecognized []byte                          `json:"-"`
 }
 
@@ -1003,6 +1057,13 @@ func (m *UninterpretedOption) GetStringValue() []byte {
 	return nil
 }
 
+func (m *UninterpretedOption) GetAggregateValue() string {
+	if m != nil && m.AggregateValue != nil {
+		return *m.AggregateValue
+	}
+	return ""
+}
+
 type UninterpretedOption_NamePart struct {
 	NamePart         *string `protobuf:"bytes,1,req,name=name_part" json:"name_part,omitempty"`
 	IsExtension      *bool   `protobuf:"varint,2,req,name=is_extension" json:"is_extension,omitempty"`
@@ -1027,6 +1088,62 @@ func (m *UninterpretedOption_NamePart) GetIsExtension() bool {
 	return false
 }
 
+type SourceCodeInfo struct {
+	Location         []*SourceCodeInfo_Location `protobuf:"bytes,1,rep,name=location" json:"location,omitempty"`
+	XXX_unrecognized []byte                     `json:"-"`
+}
+
+func (m *SourceCodeInfo) Reset()         { *m = SourceCodeInfo{} }
+func (m *SourceCodeInfo) String() string { return proto.CompactTextString(m) }
+func (*SourceCodeInfo) ProtoMessage()    {}
+
+func (m *SourceCodeInfo) GetLocation() []*SourceCodeInfo_Location {
+	if m != nil {
+		return m.Location
+	}
+	return nil
+}
+
+type SourceCodeInfo_Location struct {
+	Path             []int32 `protobuf:"varint,1,rep,packed,name=path" json:"path,omitempty"`
+	Span             []int32 `protobuf:"varint,2,rep,packed,name=span" json:"span,omitempty"`
+	LeadingComments  *string `protobuf:"bytes,3,opt,name=leading_comments" json:"leading_comments,omitempty"`
+	TrailingComments *string `protobuf:"bytes,4,opt,name=trailing_comments" json:"trailing_comments,omitempty"`
+	XXX_unrecognized []byte  `json:"-"`
+}
+
+func (m *SourceCodeInfo_Location) Reset()         { *m = SourceCodeInfo_Location{} }
+func (m *SourceCodeInfo_Location) String() string { return proto.CompactTextString(m) }
+func (*SourceCodeInfo_Location) ProtoMessage()    {}
+
+func (m *SourceCodeInfo_Location) GetPath() []int32 {
+	if m != nil {
+		return m.Path
+	}
+	return nil
+}
+
+func (m *SourceCodeInfo_Location) GetSpan() []int32 {
+	if m != nil {
+		return m.Span
+	}
+	return nil
+}
+
+func (m *SourceCodeInfo_Location) GetLeadingComments() string {
+	if m != nil && m.LeadingComments != nil {
+		return *m.LeadingComments
+	}
+	return ""
+}
+
+func (m *SourceCodeInfo_Location) GetTrailingComments() string {
+	if m != nil && m.TrailingComments != nil {
+		return *m.TrailingComments
+	}
+	return ""
+}
+
 func init() {
 	proto.RegisterEnum("google.protobuf.FieldDescriptorProto_Type", FieldDescriptorProto_Type_name, FieldDescriptorProto_Type_value)
 	proto.RegisterEnum("google.protobuf.FieldDescriptorProto_Label", FieldDescriptorProto_Label_name, FieldDescriptorProto_Label_value)

+ 2 - 2
protoc-gen-go/plugin/Makefile

@@ -30,11 +30,11 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 # Not stored here, but plugin.proto is in http://code.google.com/p/protobuf
-# at protobuf-2.3.0/src/google/protobuf/compiler/plugin.proto
+# at protobuf-2.5.0/src/google/protobuf/compiler/plugin.proto
 # Also we need to fix an import.
 regenerate:
 	echo WARNING! THIS RULE IS PROBABLY NOT RIGHT FOR YOUR INSTALLATION
-	cd $(HOME)/src/protobuf-2.3.0/src && \
+	cd $(HOME)/src/protobuf-2.5.0/src && \
 	protoc --go_out=. ./google/protobuf/compiler/plugin.proto && \
 	cat ./google/protobuf/compiler/plugin.pb.go | \
 		sed '/^import/s;google/protobuf/descriptor.pb;code.google.com/p/goprotobuf/protoc-gen-go/descriptor;' > $(GOPATH)/src/code.google.com/p/goprotobuf/protoc-gen-go/plugin/plugin.pb.go

+ 1 - 1
protoc-gen-go/testdata/my_test/test.pb.go

@@ -351,7 +351,7 @@ var _ proto.Marshaler = (*OldReply)(nil)
 var _ proto.Unmarshaler = (*OldReply)(nil)
 
 var extRange_OldReply = []proto.ExtensionRange{
-	{100, 536870911},
+	{100, 2147483646},
 }
 
 func (*OldReply) ExtensionRangeArray() []proto.ExtensionRange {

+ 1 - 1
protoc-gen-go/testdata/my_test/test.pb.go.golden

@@ -351,7 +351,7 @@ var _ proto.Marshaler = (*OldReply)(nil)
 var _ proto.Unmarshaler = (*OldReply)(nil)
 
 var extRange_OldReply = []proto.ExtensionRange{
-	{100, 536870911},
+	{100, 2147483646},
 }
 
 func (*OldReply) ExtensionRangeArray() []proto.ExtensionRange {

+ 1 - 0
protoc-gen-go/testdata/my_test/test.proto

@@ -41,6 +41,7 @@ enum HatType {
 }
 
 enum Days {
+  option allow_alias = true;
 
   MONDAY = 1;
   TUESDAY = 2;