commit | d0f8aa294eebce13a715ba92ae8e03c714715a28 | [log] [tgz] |
---|---|---|
author | Joe Tsai <joetsai@digital-static.net> | Thu Sep 13 15:41:08 2018 -0700 |
committer | Joe Tsai <thebrokentoaster@gmail.com> | Thu Sep 13 23:01:27 2018 +0000 |
tree | 1cd515404488825a5cfb04e77994879e278446b6 | |
parent | 0bd5a38474cd7cd42b2ae00f812ba3b475afa578 [diff] |
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>
WARNING: This repository is in active development. There are no guarantees about API stability. Breaking changes will occur until a stable release is made and announced.
This repository is for the development of the next major Go implementation of protocol buffers. This library makes breaking API changes relative to the existing Go protobuf library. Of particular note, this API aims to make protobuf reflection a first-class feature of the API and implements the protobuf ecosystem in terms of reflection.
List of relevant design documents:
We appreciate community contributions. See CONTRIBUTING.md.
Issues regarding the new API can be filed at github.com/golang/protobuf. Please use a APIv2:
prefix in the title to make it clear that the issue is regarding the new API work.