protobuf-go/reflect
Joe Tsai d0f8aa294e reflect/prototype: add NewGoEnum and NewGoMessage constructors
Add constructors for creating protoreflect.{Enum,Message}Type,
which extend the protobuf descriptor with Go type information.

Rationale for API:
* NewGoEnum and NewGoMessage take in a struct instead of multiple
function parameters to provide future flexibility in adding more parameters.
* NewGoEnum and NewGoMessage take in a pointer to a struct so that generated
code can batch allocate these structs and convert them to them to EnumTypes
or MessageTypes efficiently. In other words, allocations are entirely in the
control of the caller.
* The user provides a New function as opposed to a reflect.Type or pointer to
the concrete type to support dynamic protobufs, where a single Go type may be
used to represent multiple protobuf types.
* The New functions take in an EnumType or MessageType since an implementation
for dynamic protobufs would need to close over these types. All statically
generated messages can ignore that argument.

There are no tests added since these are just wrappers;
they will be heavily exercised by other code.

Change-Id: I9fca44e06f3388375be7eaca94f8fd75c17233a3
Reviewed-on: https://go-review.googlesource.com/135356
Reviewed-by: Damien Neil <dneil@google.com>
2018-09-13 23:01:27 +00:00
..
protoreflect reflect/protoreflect: add Has and Clear to KnownFields and Map 2018-09-13 19:52:11 +00:00
protoregistry reflect/prototype: add NewFileFromDescriptorProto constructor 2018-09-05 21:25:53 +00:00
prototype reflect/prototype: add NewGoEnum and NewGoMessage constructors 2018-09-13 23:01:27 +00:00