protobuf-go/reflect
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
..
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/protoreflect: add Has and Clear to KnownFields and Map 2018-09-13 19:52:11 +00:00