mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-01-01 11:58:21 +00:00
d0f8aa294e
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> |
||
---|---|---|
.. | ||
protoreflect | ||
protoregistry | ||
prototype |