Skip to content

Commit

Permalink
[ObjC] Breaking Change: Remove GPBUnknownFieldSet.
Browse files Browse the repository at this point in the history
GPBUnknownFieldSet and the related apis have been replaced by
GPBUnknownFields. The new api allows the Objective-C Protobuf
implementation to be fully conformant around requirements for
parsing/re-serialization of unknown fields.

PiperOrigin-RevId: 684140581
  • Loading branch information
thomasvl authored and copybara-github committed Oct 9, 2024
1 parent 56e4aeb commit 2b93422
Show file tree
Hide file tree
Showing 35 changed files with 25 additions and 2,357 deletions.
3 changes: 0 additions & 3 deletions objectivec/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ objc_library(
"GPBRuntimeTypes.h",
"GPBUnknownField.h",
"GPBUnknownFields.h",
"GPBUnknownFieldSet.h",
"GPBUtilities.h",
"GPBWellKnownTypes.h",
"GPBWireFormat.h",
Expand All @@ -112,7 +111,6 @@ objc_library(
"GPBDictionary_PackagePrivate.h",
"GPBMessage_PackagePrivate.h",
"GPBRootObject_PackagePrivate.h",
"GPBUnknownFieldSet_PackagePrivate.h",
"GPBUnknownField_PackagePrivate.h",
"GPBUtilities_PackagePrivate.h",
],
Expand Down Expand Up @@ -142,7 +140,6 @@ objc_library(
"GPBTimestamp.pbobjc.m",
"GPBType.pbobjc.m",
"GPBUnknownField.m",
"GPBUnknownFieldSet.m",
"GPBUnknownFields.m",
"GPBUtilities.m",
"GPBWellKnownTypes.m",
Expand Down
14 changes: 0 additions & 14 deletions objectivec/GPBCodedInputStream.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#import "GPBDictionary_PackagePrivate.h"
#import "GPBMessage.h"
#import "GPBMessage_PackagePrivate.h"
#import "GPBUnknownFieldSet.h"
#import "GPBUnknownFieldSet_PackagePrivate.h"
#import "GPBUtilities.h"
#import "GPBUtilities_PackagePrivate.h"
#import "GPBWireFormat.h"
Expand Down Expand Up @@ -499,18 +497,6 @@ - (void)readGroup:(int32_t)fieldNumber
--state_.recursionDepth;
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void)readUnknownGroup:(int32_t)fieldNumber message:(GPBUnknownFieldSet *)message {
CheckRecursionLimit(&state_);
++state_.recursionDepth;
[message mergeFromCodedInputStream:self];
GPBCodedInputStreamCheckLastTagWas(&state_,
GPBWireFormatMakeTag(fieldNumber, GPBWireFormatEndGroup));
--state_.recursionDepth;
}
#pragma clang diagnostic pop

- (void)readMessage:(GPBMessage *)message
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry {
CheckRecursionLimit(&state_);
Expand Down
10 changes: 0 additions & 10 deletions objectivec/GPBCodedInputStream_PackagePrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
#import "GPBCodedInputStream.h"

#import "GPBDescriptor.h"
#import "GPBUnknownFieldSet.h"

@class GPBUnknownFieldSet;

typedef struct GPBCodedInputStreamState {
const uint8_t *bytes;
Expand Down Expand Up @@ -42,13 +39,6 @@ typedef struct GPBCodedInputStreamState {
message:(GPBMessage *)message
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry;

// Reads a group field value from the stream and merges it into the given
// UnknownFieldSet.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void)readUnknownGroup:(int32_t)fieldNumber message:(GPBUnknownFieldSet *)message;
#pragma clang diagnostic pop

// Reads a map entry.
- (void)readMapEntry:(id)mapDictionary
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
Expand Down
33 changes: 0 additions & 33 deletions objectivec/GPBCodedOutputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
#import "GPBWireFormat.h"

#import "GPBArray.h"
#import "GPBUnknownFieldSet.h"

@class GPBUnknownFieldSet;

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -587,36 +584,6 @@ __attribute__((objc_subclassing_restricted))

// clang-format on

/**
* Write a GPBUnknownFieldSet for the given field number.
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeUnknownGroup:(int32_t)fieldNumber
value:(GPBUnknownFieldSet *)value
__attribute__((deprecated("GPBUnknownFieldSet is going away.")));

/**
* Write an array of GPBUnknownFieldSet for the given field number.
*
* @param fieldNumber The field number assigned to the values.
* @param values The values to write out.
**/
- (void)writeUnknownGroupArray:(int32_t)fieldNumber
values:(NSArray<GPBUnknownFieldSet *> *)values
__attribute__((deprecated("GPBUnknownFieldSet is going away.")));

/**
* Write a GPBUnknownFieldSet without any tag (but does write the endGroup tag).
*
* @param fieldNumber The field number assigned to the value.
* @param value The value to write out.
**/
- (void)writeUnknownGroupNoTag:(int32_t)fieldNumber
value:(GPBUnknownFieldSet *)value
__attribute__((deprecated("GPBUnknownFieldSet is going away.")));

/**
Write a MessageSet extension field to the stream. For historical reasons,
the wire format differs from normal fields.
Expand Down
40 changes: 0 additions & 40 deletions objectivec/GPBCodedOutputStream.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#import <mach/vm_param.h>

#import "GPBArray.h"
#import "GPBUnknownFieldSet.h"
#import "GPBUnknownFieldSet_PackagePrivate.h"
#import "GPBUtilities.h"
#import "GPBUtilities_PackagePrivate.h"

Expand Down Expand Up @@ -355,21 +353,6 @@ - (void)writeGroup:(int32_t)fieldNumber value:(GPBMessage *)value {
[self writeGroupNoTag:fieldNumber value:value];
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"

- (void)writeUnknownGroupNoTag:(int32_t)fieldNumber value:(const GPBUnknownFieldSet *)value {
[value writeToCodedOutputStream:self];
GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatEndGroup);
}

- (void)writeUnknownGroup:(int32_t)fieldNumber value:(GPBUnknownFieldSet *)value {
GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatStartGroup);
[self writeUnknownGroupNoTag:fieldNumber value:value];
}

#pragma clang diagnostic pop

- (void)writeMessageNoTag:(GPBMessage *)value {
GPBWriteRawVarint32(&state_, (int32_t)[value serializedSize]);
[value writeToCodedOutputStream:self];
Expand Down Expand Up @@ -850,17 +833,6 @@ - (void)writeGroupArray:(int32_t)fieldNumber values:(NSArray *)values {

// clang-format on

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"

- (void)writeUnknownGroupArray:(int32_t)fieldNumber values:(NSArray *)values {
for (GPBUnknownFieldSet *value in values) {
[self writeUnknownGroup:fieldNumber value:value];
}
}

#pragma clang diagnostic pop

- (void)writeMessageSetExtension:(int32_t)fieldNumber value:(GPBMessage *)value {
GPBWriteTagWithFormat(&state_, GPBWireFormatMessageSetItem, GPBWireFormatStartGroup);
GPBWriteUInt32(&state_, GPBWireFormatMessageSetTypeId, fieldNumber);
Expand Down Expand Up @@ -992,11 +964,6 @@ size_t GPBComputeStringSizeNoTag(NSString *value) {

size_t GPBComputeGroupSizeNoTag(GPBMessage *value) { return [value serializedSize]; }

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
size_t GPBComputeUnknownGroupSizeNoTag(GPBUnknownFieldSet *value) { return value.serializedSize; }
#pragma clang diagnostic pop

size_t GPBComputeMessageSizeNoTag(GPBMessage *value) {
size_t size = [value serializedSize];
return GPBComputeRawVarint32SizeForInteger(size) + size;
Expand Down Expand Up @@ -1063,13 +1030,6 @@ size_t GPBComputeGroupSize(int32_t fieldNumber, GPBMessage *value) {
return GPBComputeTagSize(fieldNumber) * 2 + GPBComputeGroupSizeNoTag(value);
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
size_t GPBComputeUnknownGroupSize(int32_t fieldNumber, GPBUnknownFieldSet *value) {
return GPBComputeTagSize(fieldNumber) * 2 + GPBComputeUnknownGroupSizeNoTag(value);
}
#pragma clang diagnostic pop

size_t GPBComputeMessageSize(int32_t fieldNumber, GPBMessage *value) {
return GPBComputeTagSize(fieldNumber) + GPBComputeMessageSizeNoTag(value);
}
Expand Down
9 changes: 0 additions & 9 deletions objectivec/GPBCodedOutputStream_PackagePrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ size_t GPBComputeFixed32Size(int32_t fieldNumber, uint32_t value) __attribute__(
size_t GPBComputeBoolSize(int32_t fieldNumber, BOOL value) __attribute__((const));
size_t GPBComputeStringSize(int32_t fieldNumber, NSString *value) __attribute__((const));
size_t GPBComputeGroupSize(int32_t fieldNumber, GPBMessage *value) __attribute__((const));
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
size_t GPBComputeUnknownGroupSize(int32_t fieldNumber, GPBUnknownFieldSet *value)
__attribute__((const));
#pragma clang diagnostic pop
size_t GPBComputeMessageSize(int32_t fieldNumber, GPBMessage *value) __attribute__((const));
size_t GPBComputeBytesSize(int32_t fieldNumber, NSData *value) __attribute__((const));
size_t GPBComputeUInt32Size(int32_t fieldNumber, uint32_t value) __attribute__((const));
Expand All @@ -50,10 +45,6 @@ size_t GPBComputeFixed32SizeNoTag(uint32_t value) __attribute__((const));
size_t GPBComputeBoolSizeNoTag(BOOL value) __attribute__((const));
size_t GPBComputeStringSizeNoTag(NSString *value) __attribute__((const));
size_t GPBComputeGroupSizeNoTag(GPBMessage *value) __attribute__((const));
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
size_t GPBComputeUnknownGroupSizeNoTag(GPBUnknownFieldSet *value) __attribute__((const));
#pragma clang diagnostic pop
size_t GPBComputeMessageSizeNoTag(GPBMessage *value) __attribute__((const));
size_t GPBComputeBytesSizeNoTag(NSData *value) __attribute__((const));
size_t GPBComputeUInt32SizeNoTag(int32_t value) __attribute__((const));
Expand Down
9 changes: 0 additions & 9 deletions objectivec/GPBMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
#import "GPBCodedOutputStream.h"
#import "GPBDescriptor.h"
#import "GPBExtensionRegistry.h"
#import "GPBUnknownFieldSet.h"
#import "GPBUnknownFields.h"

@class GPBCodedInputStream;
@class GPBCodedOutputStream;
@class GPBUnknownFieldSet;
@class GPBUnknownFields;

NS_ASSUME_NONNULL_BEGIN
Expand Down Expand Up @@ -72,13 +70,6 @@ CF_EXTERN_C_END
// fields declared in protos, you need to update objective_helpers.cc. The main
// cases are methods that take no arguments, or setFoo:/hasFoo: type methods.

/**
* The set of unknown fields for this message.
**/
@property(nonatomic, copy, nullable) GPBUnknownFieldSet *unknownFields __attribute__((
deprecated("Use GPBUnknownFields and the -initFromMessage: initializer and "
"mergeUnknownFields:extensionRegistry:error: to add the data back to a message.")));

/**
* Whether the message, along with all submessages, have the required fields
* set.
Expand Down
Loading

0 comments on commit 2b93422

Please sign in to comment.