mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-01-30 21:32:43 +00:00
b6405bd782
Implement support in protoc-gen-go for generating messages and enums that satisfy the v2 protobuf reflection interfaces. Specifically, the following are added: * top-level variable representing the file descriptor * ProtoReflect method on enums (to implement protoV2.Enum) * ProtoReflect method on messages (to implement protoV2.Message) The following are not supported yet: * resolving transitive dependencies for file imports * Extension descriptors * Service descriptors The implementation approach creates a single array for all the message and enum declarations and references sections of that array to complete dependencies. Since protobuf declarations can form a graph (a message may depend on itself), it is difficult to construct a graph as a single literal. One way is to use placeholder descriptors, but that is not efficient as it requires encoding the full name of each dependent enum and message and then later resolving it; thus, both expanding the binary size and also increasing initialization cost. Instead, we add a prototype.{Enum,Message}.Reference method to obtain a descriptor reference for the purposes for satisfying dependencies. As such, nested declarations and dependencies are populated in an init function. Other changes to support the implementation: * Added a protoimpl package to expose the MessageType type and also the MessageTypeOf and EnumTypeOf helper functions. * Added a protogen.File.GoIdent field to provide a suggested variable name for the file descriptor. * Added prototype.{Enum,Message}.Reference that provides a descriptor reference for the purposes for satisfying cyclic dependencies. * Added protoreflect.{Syntax,Cardinality,Kind}.GoString to obtain a Go source identifier that represents the given constant. Change-Id: I9455764882dee6ad10f251901e7d419091e8bf1d Reviewed-on: https://go-review.googlesource.com/c/150074 Reviewed-by: Damien Neil <dneil@google.com>
64 lines
2.6 KiB
Go
64 lines
2.6 KiB
Go
// Code generated by protoc-gen-go. DO NOT EDIT.
|
|
// source: grpc/deprecation.proto
|
|
|
|
package grpc
|
|
|
|
import (
|
|
fmt "fmt"
|
|
proto "github.com/golang/protobuf/proto"
|
|
protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
|
|
prototype "github.com/golang/protobuf/v2/reflect/prototype"
|
|
protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
|
|
math "math"
|
|
)
|
|
|
|
// Reference imports to suppress errors if they are not otherwise used.
|
|
var _ = proto.Marshal
|
|
var _ = fmt.Errorf
|
|
var _ = math.Inf
|
|
|
|
// This is a compile-time assertion to ensure that this generated file
|
|
// is compatible with the proto package it is being compiled against.
|
|
// A compilation error at this line likely means your copy of the
|
|
// proto package needs to be updated.
|
|
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
|
|
|
func init() { proto.RegisterFile("grpc/deprecation.proto", fileDescriptor_1e7146702b7fe8c5) }
|
|
|
|
var fileDescriptor_1e7146702b7fe8c5 = []byte{
|
|
// 184 bytes of a gzipped FileDescriptorProto
|
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4b, 0x2f, 0x2a, 0x48,
|
|
0xd6, 0x4f, 0x49, 0x2d, 0x28, 0x4a, 0x4d, 0x4e, 0x2c, 0xc9, 0xcc, 0xcf, 0xd3, 0x2b, 0x28, 0xca,
|
|
0x2f, 0xc9, 0x17, 0x12, 0x4e, 0xcf, 0x07, 0x33, 0x20, 0xdc, 0x64, 0x3d, 0x90, 0x32, 0x29, 0x7e,
|
|
0xb0, 0x62, 0x10, 0x01, 0x11, 0x36, 0xca, 0xe1, 0x12, 0x74, 0x81, 0x6a, 0x4d, 0x4d, 0x09, 0x4e,
|
|
0x2d, 0x2a, 0xcb, 0x4c, 0x4e, 0x15, 0x0a, 0xe2, 0xe2, 0x43, 0x08, 0x3a, 0x27, 0xe6, 0xe4, 0x08,
|
|
0xc9, 0xe8, 0x61, 0x31, 0x4d, 0x2f, 0x28, 0xb5, 0xb0, 0x34, 0xb5, 0xb8, 0x44, 0x4a, 0x16, 0x87,
|
|
0x6c, 0x71, 0x41, 0x7e, 0x5e, 0x71, 0xaa, 0x12, 0x73, 0x07, 0x13, 0xa3, 0x14, 0x88, 0x70, 0xb2,
|
|
0x8f, 0xb2, 0x4d, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0xcf,
|
|
0x49, 0xcc, 0x4b, 0xd7, 0x07, 0xeb, 0x49, 0x2a, 0x4d, 0xd3, 0x2f, 0x33, 0xd2, 0x4f, 0xce, 0x4d,
|
|
0x81, 0xf0, 0x93, 0x75, 0xd3, 0x53, 0xf3, 0x74, 0xd3, 0xf3, 0xf5, 0x4b, 0x52, 0x8b, 0x4b, 0x52,
|
|
0x12, 0x4b, 0x12, 0xc1, 0x8e, 0x4e, 0x62, 0x03, 0x4b, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff,
|
|
0x8d, 0xbe, 0xc2, 0x16, 0xf5, 0x00, 0x00, 0x00,
|
|
}
|
|
|
|
func init() {
|
|
var err error
|
|
Deprecation_ProtoFile, err = prototype.NewFile(&xxx_Deprecation_ProtoFile_FileDesc)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
|
|
|
|
var Deprecation_ProtoFile protoreflect.FileDescriptor
|
|
|
|
var xxx_Deprecation_ProtoFile_FileDesc = prototype.File{
|
|
Syntax: protoreflect.Proto3,
|
|
Path: "grpc/deprecation.proto",
|
|
Package: "goproto.protoc.grpc",
|
|
Imports: []protoreflect.FileImport{
|
|
{FileDescriptor: prototype.PlaceholderFile("grpc/grpc.proto", "goproto.protoc.grpc")},
|
|
},
|
|
}
|