Commit Graph

573 Commits

Author SHA1 Message Date
Joe Tsai
cbdefb1530 internal/impl: move filetype.EnumInfo to impl
Change-Id: I5558d9d4618df80dd08969fb8af1bc16191176b5
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/195620
Reviewed-by: Damien Neil <dneil@google.com>
2019-09-16 22:07:05 +00:00
Joe Tsai
fd4c605bfb internal: simplify ExtensionInfo initialization
This CL:
* Make the meaning of impl/ExtensionInfo.goType consistent. Before,
it was sometimes a T and other times a []T depending on the current
state of initialization. Change it so that it is the constructor's
responsibility to pass in a []T if it is repeated.
* Make internal/filetype responsible for constructing a []T for
repeated extension fields.
* Makes filedesc/Extension.Cardinality one of the eagerly initialized
pieces of information since it is useful to internal/filetype.
* Unify ExtensionInfo.desc and ExtensionInfo.tdesc.ExtensionField,
which held the same information.
* Remove the internal implementation for impl.X.ExtensionDescFromType
since we are dropping support for this from v1.

Change-Id: Ie95c4de66cd674c1d886da4f63b133b7d763c7ef
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/195777
Reviewed-by: Damien Neil <dneil@google.com>
2019-09-16 22:06:06 +00:00
Joe Tsai
3c4ab8c6f1 encoding/prototext: drop trailing newline for empty
This is more consistent with the indent documentation:
	If indent is a non-empty string, it causes every entry in a List or Message
	to be preceded by the indent and trailed by a newline.

Since an empty message has no entries, there should be no newlines.

Change-Id: I5d57165aaf94ca6b184bb35bf05d5d68f5ee9dd5
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/194877
Reviewed-by: Herbie Ong <herbie@google.com>
2019-09-14 21:08:43 +00:00
Joe Tsai
2df47c918b internal/impl: fix race ExtensionInfo.lazyInitSlow
The xi.init flag should not be set until after we have truly
initialized everything.

Change-Id: I43dcb300917145ce19a7199fa871acd0df325c6c
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/194439
Reviewed-by: Damien Neil <dneil@google.com>
2019-09-10 20:33:39 +00:00
Joe Tsai
e87cf53d57 internal/impl: fix panic calling XXX_MessageName on aberrant messages
Call XXX_MessageName with best-effort. If it panics, oh-well.

Change-Id: I605ea074470b0c90b0bea8b36fa7d4a69368692d
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/194598
Reviewed-by: Damien Neil <dneil@google.com>
2019-09-10 20:25:26 +00:00
Joe Tsai
3e80249d38 compiler/protogen: deprecate certain ways to derive Go package information
There are currently at least 5 ways to derive Go package information:
* From the 'M' command-line flag.
* From the 'import_path' command-line flag.
* From the 'go_package' proto file option.
* From the proto package name in proto source file.
* From the path of the proto source file.
Technically, there are more than 5 ways since information can be derived
from a convoluted combination of all the methods.

We should move towards a sensible and consistent world where each
Go package information for each proto source file is:
* only derived from the command-line OR
* only derived from the proto source file itself.
It should never be derived from a mixture of methods.

In the future, all .proto source files will be required to have a
"go_package" option specified, unless the "M" command-line argument is
specified. If the "M" flag is given it takes precedence over 'go_package'.

This CL prints warnings if the user is generating proto files without
a "M" flag or "go_package" option specified. It suggests to the user
a "go_package" option that preserves the current semantics.

Change-Id: I5cf8d40a245146bb145b3b610d42f1bcd140b449
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/194158
Reviewed-by: Damien Neil <dneil@google.com>
2019-09-09 23:57:33 +00:00
Joe Tsai
8ee364e4bf internal/impl: fix SetLazyValue
Since the internal body calls ExtensionType.ValueOf, it seems that the
intent is for lazyExtensionValue.value to store a:
	func() protoreflect.Value
instead of a:
	func() interface{}

This seems more apparent given that GetValue returns a pref.Value.

Change-Id: I1679fe56088c20d5c8d36360e75dd773850da4c2
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/193757
Reviewed-by: Damien Neil <dneil@google.com>
2019-09-09 18:58:35 +00:00
Joe Tsai
531a03af35 internal/impl: preserve nil in ProtoMessageVXOf
ProtoMessageV1(nil) now returns nil.
ProtoMessageV2(nil) now returns nil.

Note that the following continue to panic:
	MessageOf(nil)
	MessageDescriptorOf(nil)
	MessageTypeOf(nil)
It may be reasonable for them to also return nil in the future.

Change-Id: Icc14857252d844eb6d4dbfe0c248cef22023e930
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/193758
Reviewed-by: Damien Neil <dneil@google.com>
2019-09-09 18:40:39 +00:00
Joe Tsai
27af11f144 internal: improve use of detrand in descfmt and errors
Use a non-breaking space instead of two spaces to vary the output.
This keeps the mutated version aesthetically similar to the normal one.

Change-Id: Ib4ade2795004fe5b30e454e7e533e5a0e3a9ffa2
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/194157
Reviewed-by: Herbie Ong <herbie@google.com>
2019-09-09 18:30:00 +00:00
Herbie Ong
9e356dea53 encoding/prototext: document unstable marshal output
Fixes golang/protobuf#920.

Change-Id: I04c12de9a662eb67994fc7eeceee1af4a9efee55
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/188937
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-09-07 00:56:21 +00:00
Herbie Ong
582ab3de42 encoding/protojson: add random whitespaces in encoding output
This is meant to deter users from doing byte for byte comparison.

Change-Id: If005d2dc1eba45eaa4254171d2f247820db109e4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/194037
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-09-07 00:48:34 +00:00
Herbie Ong
4eb4d61b0c internal/encoding/text: minor tweak in inserting random whitespace
Simply move logic into similar code block.  Maintains the same logic.

Change-Id: I7b5a3f3d57f6102c7919cdc03dd105f08d21aca3
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/194039
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-09-07 00:43:37 +00:00
Joe Tsai
09217f08d2 all: make error messages unstable
Use internal/detrand in the construction of our error messages.
This alters whether there is one or two spaces following the "proto:" prefix.
While it is easy for users to still work around this mutation,
sit at least forces them to write test infrastructure to more fuzzily
match on error strings.

Change-Id: I4ddca717526ee3fc4dbb1e0b36cfca8c6e0df36d
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/194038
Reviewed-by: Herbie Ong <herbie@google.com>
2019-09-07 00:39:30 +00:00
Herbie Ong
956cd6ddcd encoding/protojson: add MarshalOptions.UseProtoNames
UseProtoNames=true uses proto field name in JSON field names.

Change-Id: I23249dc1787d9735bef780b1ef8d294a9c55c043
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/193998
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-09-06 23:56:51 +00:00
Herbie Ong
9111f3b439 encoding/protojson: add MarshalOptions.UseEnumNumbers
UseEnumNumbers=true will emit enum values as JSON numbers.

Change-Id: I6f3c814e06dc1e3dd595ad35aa79871a49718cd5
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/194017
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-09-06 23:39:23 +00:00
Herbie Ong
984e528fd1 encoding/protojson: add MarshalOptions.EmitUnpopulated
Add option to marshal out all fields including unset ones except for
unset oneof fields and extension fields.

This is to make V2 compatible with V1's EmitDefaults option.

Change-Id: Ifa7bae48e82740b623c74f936bcbe9e66b11344a
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/193759
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-09-06 21:15:05 +00:00
Herbie Ong
3924625c77 all: update to go1.13 release
Change-Id: Id090455ddf30620bd5be809a095d187afc2047c5
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/193937
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-09-06 18:27:08 +00:00
Joe Tsai
0bf4113643 encoding: verify that the target message is extendable
After resolving a FieldDescriptor from the resolver, verify that the
returned descriptor truly does extend the target message.

This will never happen with the global registry, since it checks this
but can happen with poorly written custom resolvers.

Change-Id: I2de5b9d2fb9d32e076ec4e82adda98d672891444
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/193737
Reviewed-by: Herbie Ong <herbie@google.com>
2019-09-06 07:13:15 +00:00
Joe Tsai
592e52e148 internal/mapsort: use explicit kind for strings
Rather than handle the string kind in the default case,
explicitly check for the string kind.
Instead, panic with a more useful message for unknown kinds.

Change-Id: I7e205a19658edd62a03f47f5b50a556dd942bf52
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/191579
Reviewed-by: Herbie Ong <herbie@google.com>
2019-09-05 22:07:15 +00:00
Joe Tsai
6c30280ad6 reflect/protoreflect: emit valid Go from GoString
Rather than using the <unknown:%d> syntax for GoString,
emit something similar to TypeName(%d),
which is functionally equivalent to casting the integer
to the specified type.

Change-Id: Ibf4bd680d1672fcaba9022fb6bd03bbfe249b8b7
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/191580
Reviewed-by: Herbie Ong <herbie@google.com>
2019-09-05 21:59:19 +00:00
Joe Tsai
72980ee410 reflect/protoregistry: add Num methods for every Range method
The Num methods provide an O(1) lookup for the number of entries that Range
would return. This is needed to implement efficient cache invalidation logic
for caches that wrap the global registry.

Change-Id: I7c4ff97f674c4e9e4caae291f017cfad7294856c
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/193599
Reviewed-by: Damien Neil <dneil@google.com>
2019-09-05 18:06:52 +00:00
Joe Tsai
ea5ada15be internal/impl: support legacy message names
This change:
* Adds aberrant support for the undocumented XXX_MessageName method.
* Adds LegacyMessageTypeOf so that v1 registration can suggest a
fullname to use with a legacy message with no Descriptor support.

Change-Id: I0265bd3cf67f4d4815358148f5817695c1122dc8
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/193518
Reviewed-by: Damien Neil <dneil@google.com>
2019-09-05 17:56:38 +00:00
Damien Neil
2eaed36627 all: remove NewMessage methods
Superseded by New{Field,Element,Value}.

Change-Id: Iad09f3b0c6bac7b75cf28925eef2982d45267317
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/193598
Reviewed-by: Joe Tsai <joetsai@google.com>
2019-09-05 17:49:46 +00:00
Joe Tsai
576cfb3dae release.bash: support reproducible builds
Manually specifying the "-buildid" removes the last source of variability
when the release binaries is built on one system or another.

See https://github.com/golang/go/issues/33772#issuecomment-528176001

Change-Id: Ibc9b8e99b5b76719735942a510570bcbf96dfea6
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/193498
Reviewed-by: Damien Neil <dneil@google.com>
2019-09-05 17:44:33 +00:00
Damien Neil
4b3a82f6b1 internal/impl: clean up Value codecs
Remove the Go type from consideration when creating Value codecs, as it
is unnecessary. Value codecs convert between wire form and Values,
while Converters convert between Values and the Go type.

Change-Id: Iaa4bc7db81ad0a29dabd42c2229e6f33a0c91c67
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/193457
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-09-05 16:31:05 +00:00
Joe Tsai
fd528ff53f internal/impl: unexport Unwrapper
This interface is only ever used within the impl package.
Unexport it to avoid potential abuse by users.

Change-Id: I58d0cc2e8cb01c8c9d36cdec469c8d2196c4f836
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/193197
Reviewed-by: Damien Neil <dneil@google.com>
2019-09-05 06:07:39 +00:00
Damien Neil
d91c422d95 all: remove use of deprecated NewMessage
Replace NewMessage calls with NewField, NewElement, or NewValue.

Change-Id: I6d2bb4f11f0eb2ba7a52308b1addb111137ad4b9
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/193266
Reviewed-by: Joe Tsai <joetsai@google.com>
2019-09-04 17:55:31 +00:00
Damien Neil
dfae831ab7 types/dynamicpb: New->NewMessage, add NewMessageType
Rename New to NewMessage, since messages are not the only type in this
package.

Add NewMessageType to allow creating a MessageType without first
creating a Message.

Fixes golang/protobuf#934

Change-Id: I9c59594a436dec75d3e26078b0055a4aa08e0169
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/193157
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-09-04 04:34:35 +00:00
Damien Neil
0e00e666b1 cmd/protoc-gen-go: remove go version from header
The Go toolchain version isn't particularly interesting; short of bugs
in the toolchain, the protoc-gen-go output should be identical for any
version of the compiler and stdlib. Including it introduces pointless
variance in generated output when switching between compiler versions.

Change-Id: I74a709cf227ecf68dd62579947e03c07349f04de
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/193122
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-09-04 04:34:11 +00:00
Joe Tsai
6663f3a630 internal/impl: add ProtoMessageV1Of and ProtoMessageV2Of
These functions are used by v1 code to switch between
protoV1.Message and protoV2.Message.
Wrappers over them may be exposed in a hypothetical protoadapt package.

Change-Id: Ib5265420e34e9888b540307962c70189625d663c
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/193180
Reviewed-by: Damien Neil <dneil@google.com>
2019-09-03 23:27:40 +00:00
Damien Neil
290ceea663 types/dynamicpb: support dynamic extensions
Add a dynamicpb.NewExtensionType function to permit creating extension
types from descriptors.

Also fix a some bugs around extension field handling:
When creating a new value for an extension field, use the
ExtensionType's Zero or New method to create the value.

Ensure that prototest exercises true zero-values of fields. (i.e.,
getting a list, map, or message from an empty message rather than
creating a new empty one with NewField.)

Change-Id: Idb8e87cdc92692610e12a4b8a68c34b129fae617
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/186180
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-09-03 21:40:45 +00:00
Damien Neil
293dc761cb internal/impl: change Go representation of extension lists to []T
Change-Id: Iebcefe0330c8f858c7735f9362abfd87043ee39d
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/192458
Reviewed-by: Joe Tsai <joetsai@google.com>
2019-09-03 21:19:03 +00:00
Damien Neil
68b81c3117 internal/impl: store extension values as Values
Change the storage type of ExtensionField from interface{} to
protoreflect.Value.

Replace the codec functions operating on interface{}s with ones
operating on Values.

Values are potentially more efficient, since they can represent
non-pointer types without allocation. This also reduces the number of
types used to represent field values.

Additionally, this change lays groundwork for changing the
user-visible representation of repeated extension fields from
*[]T to []T. The storage type for extension fields must support mutation
(thus *[]T currently); changing the storage type to a Value permits this
without the need to introduce yet another view on field values.

Change-Id: Ida336be14112bb940f655236eb58df21bf312525
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/192218
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-09-03 20:58:28 +00:00
Damien Neil
835b271169 reflect/protoreflect: add ExtensionType IsValid{Interface,Value} methods
Add a way to typecheck a Value or interface{} without converting it to
the other form.  This permits implementations which store field values as
a Value (such as dynamicpb, or (soon) extensions in generated messages)
to validate inputs without an unnecessary conversion.

Fixes golang/protobuf#905

Change-Id: I1b78612b22ae832efbb55f81ae420871729e3a02
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/192457
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-09-03 20:58:16 +00:00
Joe Tsai
50f860a45a internal/filedesc: fix dependency on legacy generated enums
Suppose you have a generated message with an enum field that
has a default value, where the enum is declared in another proto file
that does not register its descriptors.
In such a situation, the enum dependency cannot be resolved and will
be left as a placeholder.

When unmarshalDefault is called, it will attempt to parse the enum
name stored as the default value, but panic since the placeholder enum
has no enum values known to it.

Instead of panicking, use a placeholder enum value that preserves the
name of default enum value and just use the enum number of 0.
This is not ideal, but is a better alternative than panicking.

Change-Id: I5ff6c351adbdd6fe7b41f2d4f215be4aa09e751f
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/192500
Reviewed-by: Damien Neil <dneil@google.com>
2019-09-03 20:42:35 +00:00
Damien Neil
95539ea04c internal/filetype: fix EnumInfo.New
Previously panicked due to operating on the *T instead of the T.

Change-Id: I2aa23a63d1451d1fb29351abbe230d8d2518bd69
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/192579
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-08-30 17:34:31 +00:00
Damien Neil
3cda377ed2 all: rename ExtensionType Descriptor method to TypeDescriptor (2/2)
Remove the ExtensionType Descriptor method.

Change-Id: I89c985c45f2a5abc4e4e3770f9652bc2a444251e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/192141
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-08-28 19:46:47 +00:00
Damien Neil
79bfdbe45b all: rename ExtensionType Descriptor method to TypeDescriptor (1/2)
Descriptor methods generally return a Descriptor with no Go type
information. ExtensionType's Descriptor is an exception, returning an
ExtensionTypeDescriptor containing both the proto descriptor and a
reference back to the ExtensionType. The pure descriptor is accessed
by xt.Descriptor().Descriptor().

Rename ExtensionType's Descriptor method to TypeDescriptor to make it
clear that it behaves a bit differently.

Change 1/2: Add the TypeDescriptor method and deprecate Descriptor.

Change-Id: I1806095044d35a474d60f94d2a28bdf528f12238
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/192139
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-08-28 18:34:29 +00:00
Damien Neil
95758c0892 internal/filetype, internal/filedesc: avoid gccgo bug
Returning an anonymous struct is tickling a gccgo bug:
https://github.com/golang/go/issues/33866

Change to a named type. We could make the type unexpoerted, but this is
an internal package anyway so leave it exported for general style
cleanliness.

Change-Id: Idf33f1e354c0e07066ab68640308af1498a01447
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/191960
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-08-27 19:57:09 +00:00
Joe Tsai
26aef9d6d6 cmd/protoc-gen-go: add support for field-tracking
Field-tracking is an experimental feature in the Go linker
where it statically tracks whether a Go struct field is used.
This CL modifies the generator to emit special markers that
tells the linker to know which fields to track.

Change-Id: I235da3f3d6c0ef2021b5fe1c16106ebb8fd6f557
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/189558
Reviewed-by: Damien Neil <dneil@google.com>
2019-08-26 17:54:17 +00:00
Joe Tsai
2e7817f117 compiler/protogen, internal/strs, internal/impl: expose enum Go name derivation
In order to migrate v1 to wrap v2, we need a way to reproduce
the awful enum "names" that v1 used, which was the concatenation of
the proto package with the Go identifier used for the enum.

To support this:
* Move the camel case logic from compiler/protogen to internal/strs
* Add a small stub in internal/impl to expose this functionality

Change-Id: I8ff31daa9ae541e5788dc04d2e89eae1574877e4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/191637
Reviewed-by: Damien Neil <dneil@google.com>
2019-08-26 17:49:17 +00:00
Damien Neil
c5060d2fe6 reflect/protoreflect: add non-allocating Value constructors
Passing a non-pointer type to protoreflect.NewValue causes an
unnecessary allocation in order to store the value in an interface{}.
While this allocation could be avoided by a smarter compiler, no such
compiler exists today.

Add functions for creating new values of a specific type, avoiding the
allocation. (And also adding a small amount of type safety, although
this is unlikely to be important.)

Update the proto and internal/impl packages to use these functions.

Change-Id: Ic733de22ddf19c530189166c853348e1b54b7391
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/191457
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-08-26 17:48:05 +00:00
Tuo Shan
6e25d8c6a6 proto: add tests for unmarshalling invalid field numbers
This change adds tests for unmarshalling fields with various invalid field
numbers. Our current behavior is that proto.Unmarshal will return an error when
it sees zero and larger than max field numbers and return nil for reserved
ones, which matches the C++ behavior. (Note: depending on which parser helper
in the C++ implementation, one may need to call additional method to check the
result, which we don't have in Go)

Change-Id: I8791fd077f25656107556f5606d55d05c1b4a120
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/191459
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-08-23 21:35:40 +00:00
Joe Tsai
08ff730048 all: add go1.13rc1 to list of supported Go versions
Change-Id: I2ba52055bcb0e434b66dbcd4763afd2fce5b4264
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/191179
Reviewed-by: Herbie Ong <herbie@google.com>
2019-08-21 21:14:39 +00:00
Joe Tsai
ef6e524dca compiler/protogen: move name mangling logic to protogen
The name mangling logic should be unified in a single place
rather than being split between compiler/protogen and cmd/protoc-gen-go.
Move it over compiler/protogen.

Change-Id: Iea65e0b3fba45e0c95c76e3fc1f061e0fa8f84d7
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/191117
Reviewed-by: Damien Neil <dneil@google.com>
2019-08-21 20:49:58 +00:00
Joe Tsai
4df99fd526 compiler/protogen: add EnumValue.Parent
EnumValues, Fields, Oneofs, and Methods are all declarations that exist
within some parent declaration. The later three have a Parent field.
It seems only consistent that EnumValue have one as well.

Change-Id: I774576565046ede4a96f86ceaa446a39613a39f5
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/191097
Reviewed-by: Damien Neil <dneil@google.com>
2019-08-21 20:40:24 +00:00
Joe Tsai
2cec484ed7 compiler/protogen: export Plugin.FilesByPath
The Plugin.FileByName method seems like an unnecessary indirection that
provides little benefit over just exposing the map.
If the intention to provide some form of immutability, there are already
many leakages in the abstraction given that most things returned by
protogen is by pointer.

Change-Id: I0c793a8d7dab7632b92968a74f8c1ba5accb242f
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/191039
Reviewed-by: Damien Neil <dneil@google.com>
2019-08-21 20:35:20 +00:00
Joe Tsai
7762ec2098 compiler/protogen: reorder code
This CL reorders code in the protogen package to consistently match
the typical ordering of enum, message, extension, service seen in
the rest of the module.

Change-Id: I42c3a2ab7ff01857ce9a8e0a71c757b7ea791521
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/191038
Reviewed-by: Damien Neil <dneil@google.com>
2019-08-21 20:31:39 +00:00
Joe Tsai
945a1706d0 all: rely on message_set_extension name mangling in ExtensionDescV1
Too much code inside Google rely on ExtensionDescV1.Name being the
target message name rather than the real name of the extension.
Double down on this assumption consistently across our codebase.

Change-Id: If0b7cd16dd1f2f7acfb2e562dbf1a2b5487162b5
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/186980
Reviewed-by: Herbie Ong <herbie@google.com>
2019-08-21 02:47:33 +00:00
Joe Tsai
4f3de44102 release.bash: add support for building release binaries
Updates golang/protobuf#738

Change-Id: I6dd85ff0129bfcfb67b12b06549c568eebfd68e3
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/189342
Reviewed-by: Damien Neil <dneil@google.com>
2019-08-21 01:15:26 +00:00