[ObjC] Mark the syntax on FileDescriptor as deprecated.

This really shouldn't be used for making decisions, so mark it as such.

PiperOrigin-RevId: 488683993
pull/10995/head
Protobuf Team Bot 2 years ago committed by Copybara-Service
parent 7bb699be43
commit c79832bddc
  1. 12
      objectivec/GPBDescriptor.h
  2. 6
      objectivec/GPBDescriptor.m

@ -133,8 +133,16 @@ typedef NS_ENUM(uint8_t, GPBFieldType) {
@property(nonatomic, readonly, copy) NSString *package;
/** The objc prefix declared in the proto file. */
@property(nonatomic, readonly, copy, nullable) NSString *objcPrefix;
/** The syntax of the proto file. */
@property(nonatomic, readonly) GPBFileSyntax syntax;
/**
* The syntax of the proto file.
*
* This should not be used for making decisions about support
* features/behaviors, what proto2 vs. proto3 syntax has meant has evolved over
* time, and not more specific methods on the descriptors should be used
* instead.
*/
@property(nonatomic, readonly) GPBFileSyntax syntax
__attribute__((deprecated("Syntax is not a good way to decide things about behaviors.")));
@end

@ -505,8 +505,11 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
// - not repeated/map
// - not in a oneof (negative has index)
// - not a message (the flag doesn't make sense for messages)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
BOOL clearOnZero = ((file.syntax == GPBFileSyntaxProto3) && !isMapOrArray &&
(coreDesc->hasIndex >= 0) && !isMessage);
#pragma clang diagnostic pop
if (clearOnZero) {
coreDesc->flags |= GPBFieldClearHasIvarOnZero;
}
@ -521,7 +524,10 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
// to be what the runtime was doing (even though it was wrong). This is
// only wrong in the rare cases an enum is declared in a proto3 syntax
// file but used for a field in the proto2 syntax file.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
BOOL isClosedEnum = (dataType == GPBDataTypeEnum && file.syntax != GPBFileSyntaxProto3);
#pragma clang diagnostic pop
if (isClosedEnum) {
coreDesc->flags |= GPBFieldClosedEnum;
}

Loading…
Cancel
Save