Skip to content

Commit

Permalink
Breaking change: Remove deprecated SupportsUnknownEnumValues method
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 588109737
  • Loading branch information
mkruskal-google authored and Copybara-Service committed Dec 5, 2023
1 parent 7c2acc9 commit 0a6a516
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 38 deletions.
5 changes: 0 additions & 5 deletions src/google/protobuf/generated_message_reflection.cc
Expand Up @@ -2655,11 +2655,6 @@ const FieldDescriptor* Reflection::FindKnownExtensionByNumber(
return descriptor_pool_->FindExtensionByNumber(descriptor_, number);
}

bool Reflection::SupportsUnknownEnumValues() const {
return FileDescriptorLegacy(descriptor_->file()).syntax() ==
FileDescriptorLegacy::Syntax::SYNTAX_PROTO3;
}

// ===================================================================
// Some private helpers.

Expand Down
33 changes: 0 additions & 33 deletions src/google/protobuf/message.h
Expand Up @@ -887,39 +887,6 @@ class PROTOBUF_EXPORT Reflection final {
// Returns nullptr if no extension is known for this name or number.
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
// useful for determining if a message is a generated message or not, for
// example:
Expand Down

0 comments on commit 0a6a516

Please sign in to comment.