protobuf-go/reflect/prototype
Joe Tsai 812d9137df reflect/protoreflect: add Has and Clear to KnownFields and Map
Change the API to use explicit Has/Clear methods instead of relying on the
"invalid" form of Value to represent nullability.

There are several reasons for this change:

* Much of the ecosystem around protobufs do not care about nullability alone.
For example, for the encoder to determine whether to emit a field:
it needs to first check if a field is nulled, and if not, it still needs to go
through a series of type-assertion to check whether the value is the zero value.
It is much easier to be able to just call Has.

* It enables representing the default value as part of the value API, rather
than only as part of the descriptor API.

* The C++ API also uses explicit has and clear methods. However, we differ from
them by defining Has for proto3 scalars (while C++ panics instead).

For internal consistency, we also use a Has/Clear API for Maps.

Change-Id: I30eda482c959d3e1454d72d9fc761c761ace27a6
Reviewed-on: https://go-review.googlesource.com/134998
Reviewed-by: Damien Neil <dneil@google.com>
2018-09-13 19:52:11 +00:00
..
descriptor.go
placeholder_type.go reflect: add Index method to descriptor 2018-09-07 17:57:37 +00:00
placeholder.go
protofile_desc.go reflect/protoreflect: add Has and Clear to KnownFields and Map 2018-09-13 19:52:11 +00:00
protofile_list_gen.go reflect: add Index method to descriptor 2018-09-07 17:57:37 +00:00
protofile_list.go
protofile_type.go reflect/protoreflect: add Has and Clear to KnownFields and Map 2018-09-13 19:52:11 +00:00
protofile.go reflect/prototype: add NewFileFromDescriptorProto constructor 2018-09-05 21:25:53 +00:00
standalone_type.go reflect/prototype: add HasDefault to FieldDescriptor 2018-09-13 18:13:20 +00:00
standalone.go reflect/prototype: add HasDefault to FieldDescriptor 2018-09-13 18:13:20 +00:00
stringer.go reflect/prototype: add HasDefault to FieldDescriptor 2018-09-13 18:13:20 +00:00
type_test.go reflect/prototype: add HasDefault to FieldDescriptor 2018-09-13 18:13:20 +00:00
validate.go reflect/prototype: add NewFileFromDescriptorProto constructor 2018-09-05 21:25:53 +00:00