2018-09-17 15:11:24 -07:00
|
|
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
|
|
|
// source: import_public/sub/a.proto
|
|
|
|
|
|
|
|
package sub
|
|
|
|
|
|
|
|
import (
|
2019-05-13 23:55:40 -07:00
|
|
|
sub2 "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/import_public/sub2"
|
|
|
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
|
|
protoregistry "google.golang.org/protobuf/reflect/protoregistry"
|
|
|
|
protoiface "google.golang.org/protobuf/runtime/protoiface"
|
|
|
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
2018-09-17 15:11:24 -07:00
|
|
|
math "math"
|
2019-03-28 01:13:26 -07:00
|
|
|
sync "sync"
|
2018-09-17 15:11:24 -07:00
|
|
|
)
|
|
|
|
|
2019-05-22 16:27:51 -04:00
|
|
|
const (
|
|
|
|
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
|
|
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 0)
|
|
|
|
// Verify that this generated code is sufficiently up-to-date.
|
|
|
|
_ = protoimpl.EnforceVersion(0 - protoimpl.MinVersion)
|
|
|
|
)
|
2019-03-28 01:13:26 -07:00
|
|
|
|
2019-01-06 16:22:13 -08:00
|
|
|
// Symbols defined in public import of import_public/sub2/a.proto
|
|
|
|
|
|
|
|
type Sub2Message = sub2.Sub2Message
|
|
|
|
|
2018-09-17 15:11:24 -07:00
|
|
|
type E int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
E_ZERO E = 0
|
|
|
|
)
|
|
|
|
|
2019-03-16 00:05:34 -07:00
|
|
|
// Deprecated: Use E.Type.Values instead.
|
2018-09-17 15:11:24 -07:00
|
|
|
var E_name = map[int32]string{
|
|
|
|
0: "ZERO",
|
|
|
|
}
|
|
|
|
|
2019-03-16 00:05:34 -07:00
|
|
|
// Deprecated: Use E.Type.Values instead.
|
2018-09-17 15:11:24 -07:00
|
|
|
var E_value = map[string]int32{
|
|
|
|
"ZERO": 0,
|
|
|
|
}
|
|
|
|
|
2018-10-09 12:49:13 -07:00
|
|
|
func (x E) Enum() *E {
|
2019-04-10 15:29:01 -07:00
|
|
|
p := new(E)
|
|
|
|
*p = x
|
|
|
|
return p
|
2018-10-09 12:49:13 -07:00
|
|
|
}
|
|
|
|
|
2018-09-17 15:11:24 -07:00
|
|
|
func (x E) String() string {
|
2019-05-01 12:29:25 -07:00
|
|
|
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
2018-09-17 15:11:24 -07:00
|
|
|
}
|
|
|
|
|
2019-05-01 12:29:25 -07:00
|
|
|
func (E) Descriptor() protoreflect.EnumDescriptor {
|
|
|
|
return file_import_public_sub_a_proto_enumTypes[0].Descriptor()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Deprecated: Use Descriptor instead.
|
2019-04-01 12:59:24 -07:00
|
|
|
func (E) Type() protoreflect.EnumType {
|
2019-04-15 13:57:56 -07:00
|
|
|
return file_import_public_sub_a_proto_enumTypes[0]
|
2019-04-01 12:59:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (x E) Number() protoreflect.EnumNumber {
|
|
|
|
return protoreflect.EnumNumber(x)
|
|
|
|
}
|
|
|
|
|
2019-03-16 00:05:34 -07:00
|
|
|
// Deprecated: Do not use.
|
|
|
|
func (x *E) UnmarshalJSON(b []byte) error {
|
2019-05-01 12:29:25 -07:00
|
|
|
num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
|
2018-10-09 12:49:13 -07:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-03-16 00:05:34 -07:00
|
|
|
*x = E(num)
|
2018-10-09 12:49:13 -07:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-03-16 00:05:34 -07:00
|
|
|
// Deprecated: Use E.Type instead.
|
2018-09-17 15:11:24 -07:00
|
|
|
func (E) EnumDescriptor() ([]byte, []int) {
|
2019-04-15 13:57:56 -07:00
|
|
|
return file_import_public_sub_a_proto_rawDescGZIP(), []int{0}
|
2018-09-17 15:11:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
type M_Subenum int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
M_M_ZERO M_Subenum = 0
|
|
|
|
)
|
|
|
|
|
2019-03-16 00:05:34 -07:00
|
|
|
// Deprecated: Use M_Subenum.Type.Values instead.
|
2018-09-17 15:11:24 -07:00
|
|
|
var M_Subenum_name = map[int32]string{
|
|
|
|
0: "M_ZERO",
|
|
|
|
}
|
|
|
|
|
2019-03-16 00:05:34 -07:00
|
|
|
// Deprecated: Use M_Subenum.Type.Values instead.
|
2018-09-17 15:11:24 -07:00
|
|
|
var M_Subenum_value = map[string]int32{
|
|
|
|
"M_ZERO": 0,
|
|
|
|
}
|
|
|
|
|
2018-10-09 12:49:13 -07:00
|
|
|
func (x M_Subenum) Enum() *M_Subenum {
|
2019-04-10 15:29:01 -07:00
|
|
|
p := new(M_Subenum)
|
|
|
|
*p = x
|
|
|
|
return p
|
2018-10-09 12:49:13 -07:00
|
|
|
}
|
|
|
|
|
2018-09-17 15:11:24 -07:00
|
|
|
func (x M_Subenum) String() string {
|
2019-05-01 12:29:25 -07:00
|
|
|
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (M_Subenum) Descriptor() protoreflect.EnumDescriptor {
|
|
|
|
return file_import_public_sub_a_proto_enumTypes[1].Descriptor()
|
2018-09-17 15:11:24 -07:00
|
|
|
}
|
|
|
|
|
2019-05-01 12:29:25 -07:00
|
|
|
// Deprecated: Use Descriptor instead.
|
2019-04-01 12:59:24 -07:00
|
|
|
func (M_Subenum) Type() protoreflect.EnumType {
|
2019-04-15 13:57:56 -07:00
|
|
|
return file_import_public_sub_a_proto_enumTypes[1]
|
2019-04-01 12:59:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (x M_Subenum) Number() protoreflect.EnumNumber {
|
|
|
|
return protoreflect.EnumNumber(x)
|
|
|
|
}
|
|
|
|
|
2019-03-16 00:05:34 -07:00
|
|
|
// Deprecated: Do not use.
|
|
|
|
func (x *M_Subenum) UnmarshalJSON(b []byte) error {
|
2019-05-01 12:29:25 -07:00
|
|
|
num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
|
2018-10-09 12:49:13 -07:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-03-16 00:05:34 -07:00
|
|
|
*x = M_Subenum(num)
|
2018-10-09 12:49:13 -07:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-03-16 00:05:34 -07:00
|
|
|
// Deprecated: Use M_Subenum.Type instead.
|
2018-09-17 15:11:24 -07:00
|
|
|
func (M_Subenum) EnumDescriptor() ([]byte, []int) {
|
2019-04-15 13:57:56 -07:00
|
|
|
return file_import_public_sub_a_proto_rawDescGZIP(), []int{0, 0}
|
2018-09-17 15:11:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
type M_Submessage_Submessage_Subenum int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
M_Submessage_M_SUBMESSAGE_ZERO M_Submessage_Submessage_Subenum = 0
|
|
|
|
)
|
|
|
|
|
2019-03-16 00:05:34 -07:00
|
|
|
// Deprecated: Use M_Submessage_Submessage_Subenum.Type.Values instead.
|
2018-09-17 15:11:24 -07:00
|
|
|
var M_Submessage_Submessage_Subenum_name = map[int32]string{
|
|
|
|
0: "M_SUBMESSAGE_ZERO",
|
|
|
|
}
|
|
|
|
|
2019-03-16 00:05:34 -07:00
|
|
|
// Deprecated: Use M_Submessage_Submessage_Subenum.Type.Values instead.
|
2018-09-17 15:11:24 -07:00
|
|
|
var M_Submessage_Submessage_Subenum_value = map[string]int32{
|
|
|
|
"M_SUBMESSAGE_ZERO": 0,
|
|
|
|
}
|
|
|
|
|
2018-10-09 12:49:13 -07:00
|
|
|
func (x M_Submessage_Submessage_Subenum) Enum() *M_Submessage_Submessage_Subenum {
|
2019-04-10 15:29:01 -07:00
|
|
|
p := new(M_Submessage_Submessage_Subenum)
|
|
|
|
*p = x
|
|
|
|
return p
|
2018-10-09 12:49:13 -07:00
|
|
|
}
|
|
|
|
|
2018-09-17 15:11:24 -07:00
|
|
|
func (x M_Submessage_Submessage_Subenum) String() string {
|
2019-05-01 12:29:25 -07:00
|
|
|
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (M_Submessage_Submessage_Subenum) Descriptor() protoreflect.EnumDescriptor {
|
|
|
|
return file_import_public_sub_a_proto_enumTypes[2].Descriptor()
|
2018-09-17 15:11:24 -07:00
|
|
|
}
|
|
|
|
|
2019-05-01 12:29:25 -07:00
|
|
|
// Deprecated: Use Descriptor instead.
|
2019-04-01 12:59:24 -07:00
|
|
|
func (M_Submessage_Submessage_Subenum) Type() protoreflect.EnumType {
|
2019-04-15 13:57:56 -07:00
|
|
|
return file_import_public_sub_a_proto_enumTypes[2]
|
2019-04-01 12:59:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (x M_Submessage_Submessage_Subenum) Number() protoreflect.EnumNumber {
|
|
|
|
return protoreflect.EnumNumber(x)
|
|
|
|
}
|
|
|
|
|
2019-03-16 00:05:34 -07:00
|
|
|
// Deprecated: Do not use.
|
|
|
|
func (x *M_Submessage_Submessage_Subenum) UnmarshalJSON(b []byte) error {
|
2019-05-01 12:29:25 -07:00
|
|
|
num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
|
2018-10-09 12:49:13 -07:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-03-16 00:05:34 -07:00
|
|
|
*x = M_Submessage_Submessage_Subenum(num)
|
2018-10-09 12:49:13 -07:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-03-16 00:05:34 -07:00
|
|
|
// Deprecated: Use M_Submessage_Submessage_Subenum.Type instead.
|
2018-09-17 15:11:24 -07:00
|
|
|
func (M_Submessage_Submessage_Subenum) EnumDescriptor() ([]byte, []int) {
|
2019-04-15 13:57:56 -07:00
|
|
|
return file_import_public_sub_a_proto_rawDescGZIP(), []int{0, 0, 0}
|
2018-09-17 15:11:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
type M struct {
|
|
|
|
// Field using a type in the same Go package, but a different source file.
|
2018-11-29 08:57:07 -08:00
|
|
|
M2 *M2 `protobuf:"bytes,1,opt,name=m2" json:"m2,omitempty"`
|
|
|
|
S *string `protobuf:"bytes,4,opt,name=s,def=default" json:"s,omitempty"`
|
|
|
|
B []byte `protobuf:"bytes,5,opt,name=b,def=default" json:"b,omitempty"`
|
|
|
|
F *float64 `protobuf:"fixed64,6,opt,name=f,def=nan" json:"f,omitempty"`
|
2018-09-17 15:11:24 -07:00
|
|
|
// Types that are valid to be assigned to OneofField:
|
|
|
|
// *M_OneofInt32
|
|
|
|
// *M_OneofInt64
|
2019-04-16 13:22:20 -07:00
|
|
|
OneofField isM_OneofField `protobuf_oneof:"oneof_field"`
|
|
|
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
|
|
|
XXX_InternalExtensions protoimpl.ExtensionFields `json:"-"`
|
|
|
|
XXX_unrecognized protoimpl.UnknownFields `json:"-"`
|
|
|
|
XXX_sizecache protoimpl.SizeCache `json:"-"`
|
2018-09-17 15:11:24 -07:00
|
|
|
}
|
|
|
|
|
2019-04-01 12:59:24 -07:00
|
|
|
func (x *M) Reset() {
|
|
|
|
*x = M{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *M) String() string {
|
|
|
|
return protoimpl.X.MessageStringOf(x)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*M) ProtoMessage() {}
|
|
|
|
|
|
|
|
func (x *M) ProtoReflect() protoreflect.Message {
|
2019-04-15 13:57:56 -07:00
|
|
|
return file_import_public_sub_a_proto_msgTypes[0].MessageOf(x)
|
cmd/protoc-gen-go: add support for protobuf reflection
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>
2018-11-15 14:44:37 -08:00
|
|
|
}
|
2019-03-16 00:05:34 -07:00
|
|
|
|
2019-04-01 13:31:55 -07:00
|
|
|
func (m *M) XXX_Methods() *protoiface.Methods {
|
2019-04-15 13:57:56 -07:00
|
|
|
return file_import_public_sub_a_proto_msgTypes[0].Methods()
|
2019-04-01 13:31:55 -07:00
|
|
|
}
|
|
|
|
|
2019-03-16 00:05:34 -07:00
|
|
|
// Deprecated: Use M.ProtoReflect.Type instead.
|
2018-09-17 15:11:24 -07:00
|
|
|
func (*M) Descriptor() ([]byte, []int) {
|
2019-04-15 13:57:56 -07:00
|
|
|
return file_import_public_sub_a_proto_rawDescGZIP(), []int{0}
|
2018-09-17 15:11:24 -07:00
|
|
|
}
|
|
|
|
|
all: move v1 types over to the v2 repository
As a goal, v2 should not depend on v1. As another step towards that end,
we move all the types that used to be in the v1 protoapi package over to v2.
For now, we place MessageV1, ExtensionRangeV1, and ExtensionDescV1
in runtime/protoiface since these are types that generated messages will
probably have to reference forever. An alternative location could be
reflect/protoreflect, but it seems unfortunate to have to dirty the
namespace of that package with these types.
We move ExtensionFieldV1, ExtensionFieldsV1, and ExtensionFieldsOf
to internal/impl, since these are related to the implementation of a
generated message.
Since moving these types from v1 to v2 implies that the v1 protoapi
package is useless, we update all usages of v1 protoapi in the v2
repository to point to the relevant v2 type or functionality.
CL/168538 is the corresponding change to alter v1.
There will be a temporary build failure as it is not possible
to submit CL/168519 and CL/168538 atomically.
Change-Id: Ide4025c1b6af5b7f0696f4b65b988b4d10a50f0b
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/168519
Reviewed-by: Herbie Ong <herbie@google.com>
2019-03-20 18:29:32 -07:00
|
|
|
var extRange_M = []protoiface.ExtensionRangeV1{
|
2018-10-29 09:14:14 -07:00
|
|
|
{Start: 100, End: 536870911},
|
|
|
|
}
|
|
|
|
|
2019-03-16 00:05:34 -07:00
|
|
|
// Deprecated: Use M.ProtoReflect.Type.ExtensionRanges instead.
|
all: move v1 types over to the v2 repository
As a goal, v2 should not depend on v1. As another step towards that end,
we move all the types that used to be in the v1 protoapi package over to v2.
For now, we place MessageV1, ExtensionRangeV1, and ExtensionDescV1
in runtime/protoiface since these are types that generated messages will
probably have to reference forever. An alternative location could be
reflect/protoreflect, but it seems unfortunate to have to dirty the
namespace of that package with these types.
We move ExtensionFieldV1, ExtensionFieldsV1, and ExtensionFieldsOf
to internal/impl, since these are related to the implementation of a
generated message.
Since moving these types from v1 to v2 implies that the v1 protoapi
package is useless, we update all usages of v1 protoapi in the v2
repository to point to the relevant v2 type or functionality.
CL/168538 is the corresponding change to alter v1.
There will be a temporary build failure as it is not possible
to submit CL/168519 and CL/168538 atomically.
Change-Id: Ide4025c1b6af5b7f0696f4b65b988b4d10a50f0b
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/168519
Reviewed-by: Herbie Ong <herbie@google.com>
2019-03-20 18:29:32 -07:00
|
|
|
func (*M) ExtensionRangeArray() []protoiface.ExtensionRangeV1 {
|
2018-10-29 09:14:14 -07:00
|
|
|
return extRange_M
|
|
|
|
}
|
|
|
|
|
2018-10-09 12:49:13 -07:00
|
|
|
const Default_M_S string = "default"
|
|
|
|
|
2018-11-29 08:57:07 -08:00
|
|
|
var Default_M_B []byte = []byte("default")
|
|
|
|
var Default_M_F float64 = math.NaN()
|
|
|
|
|
2019-04-01 12:59:24 -07:00
|
|
|
func (x *M) GetM2() *M2 {
|
|
|
|
if x != nil {
|
|
|
|
return x.M2
|
2018-09-17 15:11:24 -07:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-04-01 12:59:24 -07:00
|
|
|
func (x *M) GetS() string {
|
|
|
|
if x != nil && x.S != nil {
|
|
|
|
return *x.S
|
2018-10-09 12:49:13 -07:00
|
|
|
}
|
|
|
|
return Default_M_S
|
|
|
|
}
|
|
|
|
|
2019-04-01 12:59:24 -07:00
|
|
|
func (x *M) GetB() []byte {
|
|
|
|
if x != nil && x.B != nil {
|
|
|
|
return x.B
|
2018-11-29 08:57:07 -08:00
|
|
|
}
|
|
|
|
return append([]byte(nil), Default_M_B...)
|
|
|
|
}
|
|
|
|
|
2019-04-01 12:59:24 -07:00
|
|
|
func (x *M) GetF() float64 {
|
|
|
|
if x != nil && x.F != nil {
|
|
|
|
return *x.F
|
2018-11-29 08:57:07 -08:00
|
|
|
}
|
|
|
|
return Default_M_F
|
|
|
|
}
|
|
|
|
|
2018-09-17 15:11:24 -07:00
|
|
|
func (m *M) GetOneofField() isM_OneofField {
|
|
|
|
if m != nil {
|
|
|
|
return m.OneofField
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-04-01 12:59:24 -07:00
|
|
|
func (x *M) GetOneofInt32() int32 {
|
|
|
|
if x, ok := x.GetOneofField().(*M_OneofInt32); ok {
|
2018-09-17 15:11:24 -07:00
|
|
|
return x.OneofInt32
|
|
|
|
}
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2019-04-01 12:59:24 -07:00
|
|
|
func (x *M) GetOneofInt64() int64 {
|
|
|
|
if x, ok := x.GetOneofField().(*M_OneofInt64); ok {
|
2018-09-17 15:11:24 -07:00
|
|
|
return x.OneofInt64
|
|
|
|
}
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2018-11-26 12:57:27 -08:00
|
|
|
// XXX_OneofWrappers is for the internal use of the proto package.
|
|
|
|
func (*M) XXX_OneofWrappers() []interface{} {
|
|
|
|
return []interface{}{
|
2018-09-17 15:11:24 -07:00
|
|
|
(*M_OneofInt32)(nil),
|
|
|
|
(*M_OneofInt64)(nil),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-08 14:03:15 -07:00
|
|
|
type isM_OneofField interface {
|
|
|
|
isM_OneofField()
|
|
|
|
}
|
|
|
|
|
|
|
|
type M_OneofInt32 struct {
|
|
|
|
OneofInt32 int32 `protobuf:"varint,2,opt,name=oneof_int32,json=oneofInt32,oneof"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type M_OneofInt64 struct {
|
|
|
|
OneofInt64 int64 `protobuf:"varint,3,opt,name=oneof_int64,json=oneofInt64,oneof"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*M_OneofInt32) isM_OneofField() {}
|
|
|
|
|
|
|
|
func (*M_OneofInt64) isM_OneofField() {}
|
|
|
|
|
2018-09-17 15:11:24 -07:00
|
|
|
type M_Submessage struct {
|
|
|
|
// Types that are valid to be assigned to SubmessageOneofField:
|
|
|
|
// *M_Submessage_SubmessageOneofInt32
|
|
|
|
// *M_Submessage_SubmessageOneofInt64
|
|
|
|
SubmessageOneofField isM_Submessage_SubmessageOneofField `protobuf_oneof:"submessage_oneof_field"`
|
|
|
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
2019-04-16 13:22:20 -07:00
|
|
|
XXX_unrecognized protoimpl.UnknownFields `json:"-"`
|
|
|
|
XXX_sizecache protoimpl.SizeCache `json:"-"`
|
2018-09-17 15:11:24 -07:00
|
|
|
}
|
|
|
|
|
2019-04-01 12:59:24 -07:00
|
|
|
func (x *M_Submessage) Reset() {
|
|
|
|
*x = M_Submessage{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *M_Submessage) String() string {
|
|
|
|
return protoimpl.X.MessageStringOf(x)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*M_Submessage) ProtoMessage() {}
|
|
|
|
|
|
|
|
func (x *M_Submessage) ProtoReflect() protoreflect.Message {
|
2019-04-15 13:57:56 -07:00
|
|
|
return file_import_public_sub_a_proto_msgTypes[1].MessageOf(x)
|
cmd/protoc-gen-go: add support for protobuf reflection
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>
2018-11-15 14:44:37 -08:00
|
|
|
}
|
2019-03-16 00:05:34 -07:00
|
|
|
|
2019-04-01 13:31:55 -07:00
|
|
|
func (m *M_Submessage) XXX_Methods() *protoiface.Methods {
|
2019-04-15 13:57:56 -07:00
|
|
|
return file_import_public_sub_a_proto_msgTypes[1].Methods()
|
2019-04-01 13:31:55 -07:00
|
|
|
}
|
|
|
|
|
2019-03-16 00:05:34 -07:00
|
|
|
// Deprecated: Use M_Submessage.ProtoReflect.Type instead.
|
2018-09-17 15:11:24 -07:00
|
|
|
func (*M_Submessage) Descriptor() ([]byte, []int) {
|
2019-04-15 13:57:56 -07:00
|
|
|
return file_import_public_sub_a_proto_rawDescGZIP(), []int{0, 0}
|
2018-09-17 15:11:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *M_Submessage) GetSubmessageOneofField() isM_Submessage_SubmessageOneofField {
|
|
|
|
if m != nil {
|
|
|
|
return m.SubmessageOneofField
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-04-01 12:59:24 -07:00
|
|
|
func (x *M_Submessage) GetSubmessageOneofInt32() int32 {
|
|
|
|
if x, ok := x.GetSubmessageOneofField().(*M_Submessage_SubmessageOneofInt32); ok {
|
2018-09-17 15:11:24 -07:00
|
|
|
return x.SubmessageOneofInt32
|
|
|
|
}
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2019-04-01 12:59:24 -07:00
|
|
|
func (x *M_Submessage) GetSubmessageOneofInt64() int64 {
|
|
|
|
if x, ok := x.GetSubmessageOneofField().(*M_Submessage_SubmessageOneofInt64); ok {
|
2018-09-17 15:11:24 -07:00
|
|
|
return x.SubmessageOneofInt64
|
|
|
|
}
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2018-11-26 12:57:27 -08:00
|
|
|
// XXX_OneofWrappers is for the internal use of the proto package.
|
|
|
|
func (*M_Submessage) XXX_OneofWrappers() []interface{} {
|
|
|
|
return []interface{}{
|
2018-09-17 15:11:24 -07:00
|
|
|
(*M_Submessage_SubmessageOneofInt32)(nil),
|
|
|
|
(*M_Submessage_SubmessageOneofInt64)(nil),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-08 14:03:15 -07:00
|
|
|
type isM_Submessage_SubmessageOneofField interface {
|
|
|
|
isM_Submessage_SubmessageOneofField()
|
|
|
|
}
|
|
|
|
|
|
|
|
type M_Submessage_SubmessageOneofInt32 struct {
|
|
|
|
SubmessageOneofInt32 int32 `protobuf:"varint,1,opt,name=submessage_oneof_int32,json=submessageOneofInt32,oneof"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type M_Submessage_SubmessageOneofInt64 struct {
|
|
|
|
SubmessageOneofInt64 int64 `protobuf:"varint,2,opt,name=submessage_oneof_int64,json=submessageOneofInt64,oneof"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*M_Submessage_SubmessageOneofInt32) isM_Submessage_SubmessageOneofField() {}
|
|
|
|
|
|
|
|
func (*M_Submessage_SubmessageOneofInt64) isM_Submessage_SubmessageOneofField() {}
|
|
|
|
|
2019-04-15 13:57:56 -07:00
|
|
|
var file_import_public_sub_a_proto_extDescs = []protoiface.ExtensionDescV1{
|
2019-03-14 16:08:22 -07:00
|
|
|
{
|
|
|
|
ExtendedType: (*M)(nil),
|
|
|
|
ExtensionType: (*string)(nil),
|
|
|
|
Field: 100,
|
|
|
|
Name: "goproto.protoc.import_public.sub.extension_field",
|
|
|
|
Tag: "bytes,100,opt,name=extension_field",
|
|
|
|
Filename: "import_public/sub/a.proto",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
var (
|
|
|
|
// extend goproto.protoc.import_public.sub.M { optional string extension_field = 100; }
|
2019-04-15 13:57:56 -07:00
|
|
|
E_ExtensionField = &file_import_public_sub_a_proto_extDescs[0]
|
2019-03-14 16:08:22 -07:00
|
|
|
)
|
2019-03-28 01:13:26 -07:00
|
|
|
var File_import_public_sub_a_proto protoreflect.FileDescriptor
|
|
|
|
|
2019-04-15 13:57:56 -07:00
|
|
|
var file_import_public_sub_a_proto_rawDesc = []byte{
|
internal/fileinit: generate reflect data structures from raw descriptors
This CL takes a significantly different approach to generating support
for protobuf reflection. The previous approach involved generating a
large number of Go literals to represent the reflection information.
While that approach was correct, it resulted in too much binary bloat.
The approach taken here initializes the reflection information from
the raw descriptor proto, which is a relatively dense representation
of the protobuf reflection information. In order to keep initialization
cost low, several measures were taken:
* At program init, the bare minimum is parsed in order to initialize
naming information for enums, messages, extensions, and services declared
in the file. This is done because those top-level declarations are often
relevant for registration.
* Only upon first are most of the other data structures for protobuf
reflection actually initialized.
* Instead of using proto.Unmarshal, a hand-written unmarshaler is used.
This allows us to avoid a dependendency on the descriptor proto and also
because the API for the descriptor proto is fundamentally non-performant
since it requires an allocation for every primitive field.
At a high-level, the new implementation lives in internal/fileinit.
Several changes were made to other parts of the repository:
* cmd/protoc-gen-go:
* Stop compressing the raw descriptors. While compression does reduce
the size of the descriptors by approximately 2x, it is a pre-mature
optimization since the descriptors themselves are around 1% of the total
binary bloat that is due to generated protobufs.
* Seeding protobuf reflection from the raw descriptor significantly
simplifies the generator implementation since it is no longer responsible
for constructing a tree of Go literals to represent the same information.
* We remove the generation of the shadow types and instead call
protoimpl.MessageType.MessageOf. Unfortunately, this incurs an allocation
for every call to ProtoReflect since we need to allocate a tuple that wraps
a pointer to the message value, and a pointer to message type.
* internal/impl:
* We add a MessageType.GoType field and make it required that it is
set prior to first use. This is done so that we can avoid calling
MessageType.init except for when it is actually needed. The allows code
to call (*FooMessage)(nil).ProtoReflect().Type() without fearing that the
init code will run, possibly triggering a recursive deadlock (where the
init code depends on getting the Type of some dependency which may be
declared within the same file).
* internal/cmd/generate-types:
* The code to generate reflect/prototype/protofile_list_gen.go was copied
and altered to generated internal/fileinit.desc_list_gen.go.
At a high-level this CL adds significant technical complexity.
However, this is offset by several possible future changes:
* The prototype package can be drastically simplified. We can probably
reimplement internal/legacy to use internal/fileinit instead, allowing us
to drop another dependency on the prototype package. As a result, we can
probably delete most of the constructor types in that package.
* With the prototype package significantly pruned, and the fact that generated
code no longer depend on depends on that package, we can consider merging
what's left of prototype into protodesc.
Change-Id: I6090f023f2e1b6afaf62bd3ae883566242e30715
Reviewed-on: https://go-review.googlesource.com/c/158539
Reviewed-by: Herbie Ong <herbie@google.com>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-01-18 09:32:24 -08:00
|
|
|
0x0a, 0x19, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x2f,
|
|
|
|
0x73, 0x75, 0x62, 0x2f, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x20, 0x67, 0x6f, 0x70,
|
|
|
|
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2e, 0x69, 0x6d, 0x70, 0x6f,
|
|
|
|
0x72, 0x74, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x2e, 0x73, 0x75, 0x62, 0x1a, 0x19, 0x69,
|
|
|
|
0x6d, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x2f, 0x73, 0x75, 0x62,
|
|
|
|
0x2f, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1a, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74,
|
|
|
|
0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x2f, 0x73, 0x75, 0x62, 0x32, 0x2f, 0x61, 0x2e, 0x70,
|
|
|
|
0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb6, 0x03, 0x0a, 0x01, 0x4d, 0x12, 0x34, 0x0a, 0x02, 0x6d, 0x32,
|
|
|
|
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
|
|
|
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2e, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x70,
|
|
|
|
0x75, 0x62, 0x6c, 0x69, 0x63, 0x2e, 0x73, 0x75, 0x62, 0x2e, 0x4d, 0x32, 0x52, 0x02, 0x6d, 0x32,
|
|
|
|
0x12, 0x15, 0x0a, 0x01, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x3a, 0x07, 0x64, 0x65, 0x66,
|
|
|
|
0x61, 0x75, 0x6c, 0x74, 0x52, 0x01, 0x73, 0x12, 0x15, 0x0a, 0x01, 0x62, 0x18, 0x05, 0x20, 0x01,
|
|
|
|
0x28, 0x0c, 0x3a, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x52, 0x01, 0x62, 0x12, 0x11,
|
|
|
|
0x0a, 0x01, 0x66, 0x18, 0x06, 0x20, 0x01, 0x28, 0x01, 0x3a, 0x03, 0x6e, 0x61, 0x6e, 0x52, 0x01,
|
|
|
|
0x66, 0x12, 0x21, 0x0a, 0x0b, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x69, 0x6e, 0x74, 0x33, 0x32,
|
|
|
|
0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x0a, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x49,
|
|
|
|
0x6e, 0x74, 0x33, 0x32, 0x12, 0x21, 0x0a, 0x0b, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x69, 0x6e,
|
|
|
|
0x74, 0x36, 0x34, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, 0x52, 0x0a, 0x6f, 0x6e, 0x65,
|
|
|
|
0x6f, 0x66, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x1a, 0xc3, 0x01, 0x0a, 0x0a, 0x53, 0x75, 0x62, 0x6d,
|
|
|
|
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x36, 0x0a, 0x16, 0x73, 0x75, 0x62, 0x6d, 0x65, 0x73,
|
|
|
|
0x73, 0x61, 0x67, 0x65, 0x5f, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x69, 0x6e, 0x74, 0x33, 0x32,
|
|
|
|
0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x14, 0x73, 0x75, 0x62, 0x6d, 0x65, 0x73,
|
|
|
|
0x73, 0x61, 0x67, 0x65, 0x4f, 0x6e, 0x65, 0x6f, 0x66, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x12, 0x36,
|
|
|
|
0x0a, 0x16, 0x73, 0x75, 0x62, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x6f, 0x6e, 0x65,
|
|
|
|
0x6f, 0x66, 0x5f, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00,
|
|
|
|
0x52, 0x14, 0x73, 0x75, 0x62, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, 0x6e, 0x65, 0x6f,
|
|
|
|
0x66, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x22, 0x2b, 0x0a, 0x12, 0x53, 0x75, 0x62, 0x6d, 0x65, 0x73,
|
|
|
|
0x73, 0x61, 0x67, 0x65, 0x5f, 0x53, 0x75, 0x62, 0x65, 0x6e, 0x75, 0x6d, 0x12, 0x15, 0x0a, 0x11,
|
|
|
|
0x4d, 0x5f, 0x53, 0x55, 0x42, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x5f, 0x5a, 0x45, 0x52,
|
|
|
|
0x4f, 0x10, 0x00, 0x42, 0x18, 0x0a, 0x16, 0x73, 0x75, 0x62, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
|
|
|
|
0x65, 0x5f, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x22, 0x15, 0x0a,
|
|
|
|
0x07, 0x53, 0x75, 0x62, 0x65, 0x6e, 0x75, 0x6d, 0x12, 0x0a, 0x0a, 0x06, 0x4d, 0x5f, 0x5a, 0x45,
|
|
|
|
0x52, 0x4f, 0x10, 0x00, 0x2a, 0x08, 0x08, 0x64, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x42, 0x0d,
|
|
|
|
0x0a, 0x0b, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x2a, 0x0d, 0x0a,
|
|
|
|
0x01, 0x45, 0x12, 0x08, 0x0a, 0x04, 0x5a, 0x45, 0x52, 0x4f, 0x10, 0x00, 0x3a, 0x4c, 0x0a, 0x0f,
|
|
|
|
0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x12,
|
|
|
|
0x23, 0x2e, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63,
|
|
|
|
0x2e, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x2e, 0x73,
|
|
|
|
0x75, 0x62, 0x2e, 0x4d, 0x18, 0x64, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x65, 0x78, 0x74, 0x65,
|
2019-05-13 23:55:40 -07:00
|
|
|
0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x42, 0x49, 0x5a, 0x47, 0x67, 0x6f,
|
|
|
|
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f,
|
|
|
|
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x63, 0x6d, 0x64, 0x2f, 0x70, 0x72, 0x6f,
|
|
|
|
0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x64,
|
|
|
|
0x61, 0x74, 0x61, 0x2f, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69,
|
|
|
|
0x63, 0x2f, 0x73, 0x75, 0x62, 0x50, 0x01,
|
internal/fileinit: generate reflect data structures from raw descriptors
This CL takes a significantly different approach to generating support
for protobuf reflection. The previous approach involved generating a
large number of Go literals to represent the reflection information.
While that approach was correct, it resulted in too much binary bloat.
The approach taken here initializes the reflection information from
the raw descriptor proto, which is a relatively dense representation
of the protobuf reflection information. In order to keep initialization
cost low, several measures were taken:
* At program init, the bare minimum is parsed in order to initialize
naming information for enums, messages, extensions, and services declared
in the file. This is done because those top-level declarations are often
relevant for registration.
* Only upon first are most of the other data structures for protobuf
reflection actually initialized.
* Instead of using proto.Unmarshal, a hand-written unmarshaler is used.
This allows us to avoid a dependendency on the descriptor proto and also
because the API for the descriptor proto is fundamentally non-performant
since it requires an allocation for every primitive field.
At a high-level, the new implementation lives in internal/fileinit.
Several changes were made to other parts of the repository:
* cmd/protoc-gen-go:
* Stop compressing the raw descriptors. While compression does reduce
the size of the descriptors by approximately 2x, it is a pre-mature
optimization since the descriptors themselves are around 1% of the total
binary bloat that is due to generated protobufs.
* Seeding protobuf reflection from the raw descriptor significantly
simplifies the generator implementation since it is no longer responsible
for constructing a tree of Go literals to represent the same information.
* We remove the generation of the shadow types and instead call
protoimpl.MessageType.MessageOf. Unfortunately, this incurs an allocation
for every call to ProtoReflect since we need to allocate a tuple that wraps
a pointer to the message value, and a pointer to message type.
* internal/impl:
* We add a MessageType.GoType field and make it required that it is
set prior to first use. This is done so that we can avoid calling
MessageType.init except for when it is actually needed. The allows code
to call (*FooMessage)(nil).ProtoReflect().Type() without fearing that the
init code will run, possibly triggering a recursive deadlock (where the
init code depends on getting the Type of some dependency which may be
declared within the same file).
* internal/cmd/generate-types:
* The code to generate reflect/prototype/protofile_list_gen.go was copied
and altered to generated internal/fileinit.desc_list_gen.go.
At a high-level this CL adds significant technical complexity.
However, this is offset by several possible future changes:
* The prototype package can be drastically simplified. We can probably
reimplement internal/legacy to use internal/fileinit instead, allowing us
to drop another dependency on the prototype package. As a result, we can
probably delete most of the constructor types in that package.
* With the prototype package significantly pruned, and the fact that generated
code no longer depend on depends on that package, we can consider merging
what's left of prototype into protodesc.
Change-Id: I6090f023f2e1b6afaf62bd3ae883566242e30715
Reviewed-on: https://go-review.googlesource.com/c/158539
Reviewed-by: Herbie Ong <herbie@google.com>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-01-18 09:32:24 -08:00
|
|
|
}
|
|
|
|
|
2019-03-28 01:13:26 -07:00
|
|
|
var (
|
2019-04-15 13:57:56 -07:00
|
|
|
file_import_public_sub_a_proto_rawDescOnce sync.Once
|
|
|
|
file_import_public_sub_a_proto_rawDescData = file_import_public_sub_a_proto_rawDesc
|
2019-03-28 01:13:26 -07:00
|
|
|
)
|
cmd/protoc-gen-go: add support for protobuf reflection
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>
2018-11-15 14:44:37 -08:00
|
|
|
|
2019-04-15 13:57:56 -07:00
|
|
|
func file_import_public_sub_a_proto_rawDescGZIP() []byte {
|
|
|
|
file_import_public_sub_a_proto_rawDescOnce.Do(func() {
|
|
|
|
file_import_public_sub_a_proto_rawDescData = protoimpl.X.CompressGZIP(file_import_public_sub_a_proto_rawDescData)
|
2019-03-28 01:13:26 -07:00
|
|
|
})
|
2019-04-15 13:57:56 -07:00
|
|
|
return file_import_public_sub_a_proto_rawDescData
|
2019-03-28 01:13:26 -07:00
|
|
|
}
|
cmd/protoc-gen-go: add support for protobuf reflection
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>
2018-11-15 14:44:37 -08:00
|
|
|
|
2019-04-15 13:57:56 -07:00
|
|
|
var file_import_public_sub_a_proto_enumTypes = make([]protoreflect.EnumType, 3)
|
2019-05-22 05:12:36 -04:00
|
|
|
var file_import_public_sub_a_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
2019-04-15 13:57:56 -07:00
|
|
|
var file_import_public_sub_a_proto_goTypes = []interface{}{
|
internal/fileinit: generate reflect data structures from raw descriptors
This CL takes a significantly different approach to generating support
for protobuf reflection. The previous approach involved generating a
large number of Go literals to represent the reflection information.
While that approach was correct, it resulted in too much binary bloat.
The approach taken here initializes the reflection information from
the raw descriptor proto, which is a relatively dense representation
of the protobuf reflection information. In order to keep initialization
cost low, several measures were taken:
* At program init, the bare minimum is parsed in order to initialize
naming information for enums, messages, extensions, and services declared
in the file. This is done because those top-level declarations are often
relevant for registration.
* Only upon first are most of the other data structures for protobuf
reflection actually initialized.
* Instead of using proto.Unmarshal, a hand-written unmarshaler is used.
This allows us to avoid a dependendency on the descriptor proto and also
because the API for the descriptor proto is fundamentally non-performant
since it requires an allocation for every primitive field.
At a high-level, the new implementation lives in internal/fileinit.
Several changes were made to other parts of the repository:
* cmd/protoc-gen-go:
* Stop compressing the raw descriptors. While compression does reduce
the size of the descriptors by approximately 2x, it is a pre-mature
optimization since the descriptors themselves are around 1% of the total
binary bloat that is due to generated protobufs.
* Seeding protobuf reflection from the raw descriptor significantly
simplifies the generator implementation since it is no longer responsible
for constructing a tree of Go literals to represent the same information.
* We remove the generation of the shadow types and instead call
protoimpl.MessageType.MessageOf. Unfortunately, this incurs an allocation
for every call to ProtoReflect since we need to allocate a tuple that wraps
a pointer to the message value, and a pointer to message type.
* internal/impl:
* We add a MessageType.GoType field and make it required that it is
set prior to first use. This is done so that we can avoid calling
MessageType.init except for when it is actually needed. The allows code
to call (*FooMessage)(nil).ProtoReflect().Type() without fearing that the
init code will run, possibly triggering a recursive deadlock (where the
init code depends on getting the Type of some dependency which may be
declared within the same file).
* internal/cmd/generate-types:
* The code to generate reflect/prototype/protofile_list_gen.go was copied
and altered to generated internal/fileinit.desc_list_gen.go.
At a high-level this CL adds significant technical complexity.
However, this is offset by several possible future changes:
* The prototype package can be drastically simplified. We can probably
reimplement internal/legacy to use internal/fileinit instead, allowing us
to drop another dependency on the prototype package. As a result, we can
probably delete most of the constructor types in that package.
* With the prototype package significantly pruned, and the fact that generated
code no longer depend on depends on that package, we can consider merging
what's left of prototype into protodesc.
Change-Id: I6090f023f2e1b6afaf62bd3ae883566242e30715
Reviewed-on: https://go-review.googlesource.com/c/158539
Reviewed-by: Herbie Ong <herbie@google.com>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-01-18 09:32:24 -08:00
|
|
|
(E)(0), // 0: goproto.protoc.import_public.sub.E
|
|
|
|
(M_Subenum)(0), // 1: goproto.protoc.import_public.sub.M.Subenum
|
|
|
|
(M_Submessage_Submessage_Subenum)(0), // 2: goproto.protoc.import_public.sub.M.Submessage.Submessage_Subenum
|
|
|
|
(*M)(nil), // 3: goproto.protoc.import_public.sub.M
|
|
|
|
(*M_Submessage)(nil), // 4: goproto.protoc.import_public.sub.M.Submessage
|
|
|
|
(*M2)(nil), // 5: goproto.protoc.import_public.sub.M2
|
|
|
|
}
|
2019-04-15 13:57:56 -07:00
|
|
|
var file_import_public_sub_a_proto_depIdxs = []int32{
|
internal/fileinit: generate reflect data structures from raw descriptors
This CL takes a significantly different approach to generating support
for protobuf reflection. The previous approach involved generating a
large number of Go literals to represent the reflection information.
While that approach was correct, it resulted in too much binary bloat.
The approach taken here initializes the reflection information from
the raw descriptor proto, which is a relatively dense representation
of the protobuf reflection information. In order to keep initialization
cost low, several measures were taken:
* At program init, the bare minimum is parsed in order to initialize
naming information for enums, messages, extensions, and services declared
in the file. This is done because those top-level declarations are often
relevant for registration.
* Only upon first are most of the other data structures for protobuf
reflection actually initialized.
* Instead of using proto.Unmarshal, a hand-written unmarshaler is used.
This allows us to avoid a dependendency on the descriptor proto and also
because the API for the descriptor proto is fundamentally non-performant
since it requires an allocation for every primitive field.
At a high-level, the new implementation lives in internal/fileinit.
Several changes were made to other parts of the repository:
* cmd/protoc-gen-go:
* Stop compressing the raw descriptors. While compression does reduce
the size of the descriptors by approximately 2x, it is a pre-mature
optimization since the descriptors themselves are around 1% of the total
binary bloat that is due to generated protobufs.
* Seeding protobuf reflection from the raw descriptor significantly
simplifies the generator implementation since it is no longer responsible
for constructing a tree of Go literals to represent the same information.
* We remove the generation of the shadow types and instead call
protoimpl.MessageType.MessageOf. Unfortunately, this incurs an allocation
for every call to ProtoReflect since we need to allocate a tuple that wraps
a pointer to the message value, and a pointer to message type.
* internal/impl:
* We add a MessageType.GoType field and make it required that it is
set prior to first use. This is done so that we can avoid calling
MessageType.init except for when it is actually needed. The allows code
to call (*FooMessage)(nil).ProtoReflect().Type() without fearing that the
init code will run, possibly triggering a recursive deadlock (where the
init code depends on getting the Type of some dependency which may be
declared within the same file).
* internal/cmd/generate-types:
* The code to generate reflect/prototype/protofile_list_gen.go was copied
and altered to generated internal/fileinit.desc_list_gen.go.
At a high-level this CL adds significant technical complexity.
However, this is offset by several possible future changes:
* The prototype package can be drastically simplified. We can probably
reimplement internal/legacy to use internal/fileinit instead, allowing us
to drop another dependency on the prototype package. As a result, we can
probably delete most of the constructor types in that package.
* With the prototype package significantly pruned, and the fact that generated
code no longer depend on depends on that package, we can consider merging
what's left of prototype into protodesc.
Change-Id: I6090f023f2e1b6afaf62bd3ae883566242e30715
Reviewed-on: https://go-review.googlesource.com/c/158539
Reviewed-by: Herbie Ong <herbie@google.com>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-01-18 09:32:24 -08:00
|
|
|
3, // goproto.protoc.import_public.sub.extension_field:extendee -> goproto.protoc.import_public.sub.M
|
|
|
|
5, // goproto.protoc.import_public.sub.M.m2:type_name -> goproto.protoc.import_public.sub.M2
|
|
|
|
}
|
|
|
|
|
2019-04-15 13:57:56 -07:00
|
|
|
func init() { file_import_public_sub_a_proto_init() }
|
|
|
|
func file_import_public_sub_a_proto_init() {
|
2019-03-08 17:18:11 -08:00
|
|
|
if File_import_public_sub_a_proto != nil {
|
|
|
|
return
|
|
|
|
}
|
2019-04-15 13:57:56 -07:00
|
|
|
file_import_public_sub_b_proto_init()
|
2019-03-01 13:22:30 -08:00
|
|
|
extensionTypes := make([]protoreflect.ExtensionType, 1)
|
2019-02-27 20:25:51 -08:00
|
|
|
File_import_public_sub_a_proto = protoimpl.FileBuilder{
|
2019-04-15 13:57:56 -07:00
|
|
|
RawDescriptor: file_import_public_sub_a_proto_rawDesc,
|
|
|
|
GoTypes: file_import_public_sub_a_proto_goTypes,
|
|
|
|
DependencyIndexes: file_import_public_sub_a_proto_depIdxs,
|
|
|
|
LegacyExtensions: file_import_public_sub_a_proto_extDescs,
|
|
|
|
EnumOutputTypes: file_import_public_sub_a_proto_enumTypes,
|
|
|
|
MessageOutputTypes: file_import_public_sub_a_proto_msgTypes,
|
2019-03-01 13:22:30 -08:00
|
|
|
ExtensionOutputTypes: extensionTypes,
|
2019-03-25 14:41:32 -07:00
|
|
|
FilesRegistry: protoregistry.GlobalFiles,
|
|
|
|
TypesRegistry: protoregistry.GlobalTypes,
|
internal/fileinit: generate reflect data structures from raw descriptors
This CL takes a significantly different approach to generating support
for protobuf reflection. The previous approach involved generating a
large number of Go literals to represent the reflection information.
While that approach was correct, it resulted in too much binary bloat.
The approach taken here initializes the reflection information from
the raw descriptor proto, which is a relatively dense representation
of the protobuf reflection information. In order to keep initialization
cost low, several measures were taken:
* At program init, the bare minimum is parsed in order to initialize
naming information for enums, messages, extensions, and services declared
in the file. This is done because those top-level declarations are often
relevant for registration.
* Only upon first are most of the other data structures for protobuf
reflection actually initialized.
* Instead of using proto.Unmarshal, a hand-written unmarshaler is used.
This allows us to avoid a dependendency on the descriptor proto and also
because the API for the descriptor proto is fundamentally non-performant
since it requires an allocation for every primitive field.
At a high-level, the new implementation lives in internal/fileinit.
Several changes were made to other parts of the repository:
* cmd/protoc-gen-go:
* Stop compressing the raw descriptors. While compression does reduce
the size of the descriptors by approximately 2x, it is a pre-mature
optimization since the descriptors themselves are around 1% of the total
binary bloat that is due to generated protobufs.
* Seeding protobuf reflection from the raw descriptor significantly
simplifies the generator implementation since it is no longer responsible
for constructing a tree of Go literals to represent the same information.
* We remove the generation of the shadow types and instead call
protoimpl.MessageType.MessageOf. Unfortunately, this incurs an allocation
for every call to ProtoReflect since we need to allocate a tuple that wraps
a pointer to the message value, and a pointer to message type.
* internal/impl:
* We add a MessageType.GoType field and make it required that it is
set prior to first use. This is done so that we can avoid calling
MessageType.init except for when it is actually needed. The allows code
to call (*FooMessage)(nil).ProtoReflect().Type() without fearing that the
init code will run, possibly triggering a recursive deadlock (where the
init code depends on getting the Type of some dependency which may be
declared within the same file).
* internal/cmd/generate-types:
* The code to generate reflect/prototype/protofile_list_gen.go was copied
and altered to generated internal/fileinit.desc_list_gen.go.
At a high-level this CL adds significant technical complexity.
However, this is offset by several possible future changes:
* The prototype package can be drastically simplified. We can probably
reimplement internal/legacy to use internal/fileinit instead, allowing us
to drop another dependency on the prototype package. As a result, we can
probably delete most of the constructor types in that package.
* With the prototype package significantly pruned, and the fact that generated
code no longer depend on depends on that package, we can consider merging
what's left of prototype into protodesc.
Change-Id: I6090f023f2e1b6afaf62bd3ae883566242e30715
Reviewed-on: https://go-review.googlesource.com/c/158539
Reviewed-by: Herbie Ong <herbie@google.com>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-01-18 09:32:24 -08:00
|
|
|
}.Init()
|
2019-04-15 13:57:56 -07:00
|
|
|
file_import_public_sub_a_proto_rawDesc = nil
|
|
|
|
file_import_public_sub_a_proto_goTypes = nil
|
|
|
|
file_import_public_sub_a_proto_depIdxs = nil
|
cmd/protoc-gen-go: add support for protobuf reflection
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>
2018-11-15 14:44:37 -08:00
|
|
|
}
|