Breaking change: Remove deprecated SupportsUnknownEnumValues method

PiperOrigin-RevId: 588109737
pull/14937/head
Mike Kruskal 1 year ago committed by Copybara-Service
parent 7c2acc9abf
commit 0a6a51655f
  1. 5
      src/google/protobuf/generated_message_reflection.cc
  2. 33
      src/google/protobuf/message.h

@ -2655,11 +2655,6 @@ const FieldDescriptor* Reflection::FindKnownExtensionByNumber(
return descriptor_pool_->FindExtensionByNumber(descriptor_, number); return descriptor_pool_->FindExtensionByNumber(descriptor_, number);
} }
bool Reflection::SupportsUnknownEnumValues() const {
return FileDescriptorLegacy(descriptor_->file()).syntax() ==
FileDescriptorLegacy::Syntax::SYNTAX_PROTO3;
}
// =================================================================== // ===================================================================
// Some private helpers. // Some private helpers.

@ -887,39 +887,6 @@ class PROTOBUF_EXPORT Reflection final {
// Returns nullptr if no extension is known for this name or number. // Returns nullptr if no extension is known for this name or number.
const FieldDescriptor* FindKnownExtensionByNumber(int number) const; const FieldDescriptor* FindKnownExtensionByNumber(int number) const;
// Feature Flags -------------------------------------------------------------
// Does this message support storing arbitrary integer values in enum fields?
// If |true|, GetEnumValue/SetEnumValue and associated repeated-field versions
// take arbitrary integer values, and the legacy GetEnum() getter will
// dynamically create an EnumValueDescriptor for any integer value without
// one. If |false|, setting an unknown enum value via the integer-based
// setters results in undefined behavior (in practice, ABSL_DCHECK-fails).
//
// Generic code that uses reflection to handle messages with enum fields
// should check this flag before using the integer-based setter, and either
// downgrade to a compatible value or use the UnknownFieldSet if not. For
// example:
//
// int new_value = GetValueFromApplicationLogic();
// if (reflection->SupportsUnknownEnumValues()) {
// reflection->SetEnumValue(message, field, new_value);
// } else {
// if (field_descriptor->enum_type()->
// FindValueByNumber(new_value) != nullptr) {
// reflection->SetEnumValue(message, field, new_value);
// } else if (emit_unknown_enum_values) {
// reflection->MutableUnknownFields(message)->AddVarint(
// field->number(), new_value);
// } else {
// // convert value to a compatible/default value.
// new_value = CompatibleDowngrade(new_value);
// reflection->SetEnumValue(message, field, new_value);
// }
// }
ABSL_DEPRECATED("Use EnumDescriptor::is_closed instead.")
bool SupportsUnknownEnumValues() const;
// Returns the MessageFactory associated with this message. This can be // Returns the MessageFactory associated with this message. This can be
// useful for determining if a message is a generated message or not, for // useful for determining if a message is a generated message or not, for
// example: // example:

Loading…
Cancel
Save