mirror of
https://github.com/protocolbuffers/protobuf
synced 2026-08-26 02:23:14 -04:00
[ObjC] Breaking Change: Remove GPBUnknownFieldSet.
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
This commit is contained in:
parent
56e4aeb506
commit
2b93422f7e
35 changed files with 25 additions and 2357 deletions
|
|
@ -89,7 +89,6 @@ objc_library(
|
|||
"GPBRuntimeTypes.h",
|
||||
"GPBUnknownField.h",
|
||||
"GPBUnknownFields.h",
|
||||
"GPBUnknownFieldSet.h",
|
||||
"GPBUtilities.h",
|
||||
"GPBWellKnownTypes.h",
|
||||
"GPBWireFormat.h",
|
||||
|
|
@ -112,7 +111,6 @@ objc_library(
|
|||
"GPBDictionary_PackagePrivate.h",
|
||||
"GPBMessage_PackagePrivate.h",
|
||||
"GPBRootObject_PackagePrivate.h",
|
||||
"GPBUnknownFieldSet_PackagePrivate.h",
|
||||
"GPBUnknownField_PackagePrivate.h",
|
||||
"GPBUtilities_PackagePrivate.h",
|
||||
],
|
||||
|
|
@ -142,7 +140,6 @@ objc_library(
|
|||
"GPBTimestamp.pbobjc.m",
|
||||
"GPBType.pbobjc.m",
|
||||
"GPBUnknownField.m",
|
||||
"GPBUnknownFieldSet.m",
|
||||
"GPBUnknownFields.m",
|
||||
"GPBUtilities.m",
|
||||
"GPBWellKnownTypes.m",
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
@ -499,18 +497,6 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state, int32_t
|
|||
--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_);
|
||||
|
|
|
|||
|
|
@ -12,9 +12,6 @@
|
|||
#import "GPBCodedInputStream.h"
|
||||
|
||||
#import "GPBDescriptor.h"
|
||||
#import "GPBUnknownFieldSet.h"
|
||||
|
||||
@class GPBUnknownFieldSet;
|
||||
|
||||
typedef struct GPBCodedInputStreamState {
|
||||
const uint8_t *bytes;
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -11,9 +11,6 @@
|
|||
#import "GPBWireFormat.h"
|
||||
|
||||
#import "GPBArray.h"
|
||||
#import "GPBUnknownFieldSet.h"
|
||||
|
||||
@class GPBUnknownFieldSet;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
||||
|
|
@ -355,21 +353,6 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t 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];
|
||||
|
|
@ -850,17 +833,6 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, int64_t value
|
|||
|
||||
// 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);
|
||||
|
|
@ -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;
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -29,8 +29,6 @@
|
|||
#import "GPBRootObject.h"
|
||||
#import "GPBRootObject_PackagePrivate.h"
|
||||
#import "GPBUnknownField.h"
|
||||
#import "GPBUnknownFieldSet.h"
|
||||
#import "GPBUnknownFieldSet_PackagePrivate.h"
|
||||
#import "GPBUnknownFields.h"
|
||||
#import "GPBUnknownFields_PackagePrivate.h"
|
||||
#import "GPBUtilities.h"
|
||||
|
|
@ -79,18 +77,7 @@ NSString *const GPBMessageExceptionMessageTooLarge =
|
|||
|
||||
@interface GPBMessage () {
|
||||
@package
|
||||
// Only one of these two is ever set, GPBUnknownFieldSet is being deprecated and will
|
||||
// eventually be removed, but because that api support mutation, once the property is
|
||||
// fetch it must continue to be used so any mutations will be honored in future operations
|
||||
// on the message.
|
||||
// Read only operations that access these two/cause things to migration between them should
|
||||
// be protected with an @synchronized(self) block (that way the code also doesn't have to
|
||||
// worry about throws).
|
||||
NSMutableData *unknownFieldData_;
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
GPBUnknownFieldSet *unknownFields_;
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
NSMutableDictionary *extensionMap_;
|
||||
// Readonly access to autocreatedExtensionMap_ is protected via readOnlyLock_.
|
||||
|
|
@ -198,10 +185,6 @@ static uint8_t *EncodeVarintS32(int32_t val, uint8_t *ptr) {
|
|||
|
||||
GPB_NOINLINE
|
||||
static void AddUnknownFieldVarint32(GPBMessage *self, uint32_t fieldNumber, int32_t value) {
|
||||
if (self->unknownFields_) {
|
||||
[self->unknownFields_ mergeVarintField:fieldNumber value:value];
|
||||
return;
|
||||
}
|
||||
uint8_t buf[20];
|
||||
uint8_t *ptr = buf;
|
||||
ptr = EncodeVarintU32(GPBWireFormatMakeTag(fieldNumber, GPBWireFormatVarint), ptr);
|
||||
|
|
@ -216,10 +199,6 @@ static void AddUnknownFieldVarint32(GPBMessage *self, uint32_t fieldNumber, int3
|
|||
|
||||
GPB_NOINLINE
|
||||
static void AddUnknownFieldLengthDelimited(GPBMessage *self, uint32_t fieldNumber, NSData *value) {
|
||||
if (self->unknownFields_) {
|
||||
[self->unknownFields_ mergeLengthDelimited:fieldNumber value:value];
|
||||
return;
|
||||
}
|
||||
uint8_t buf[20];
|
||||
uint8_t *ptr = buf;
|
||||
ptr = EncodeVarintU32(GPBWireFormatMakeTag(fieldNumber, GPBWireFormatLengthDelimited), ptr);
|
||||
|
|
@ -235,12 +214,6 @@ static void AddUnknownFieldLengthDelimited(GPBMessage *self, uint32_t fieldNumbe
|
|||
|
||||
GPB_NOINLINE
|
||||
static void AddUnknownMessageSetEntry(GPBMessage *self, uint32_t typeId, NSData *value) {
|
||||
if (self->unknownFields_) {
|
||||
// Legacy Set does this odd storage for MessageSet.
|
||||
[self->unknownFields_ mergeLengthDelimited:typeId value:value];
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t buf[60];
|
||||
uint8_t *ptr = buf;
|
||||
ptr = EncodeVarintU32(GPBWireFormatMessageSetItemTag, ptr);
|
||||
|
|
@ -264,13 +237,6 @@ static void AddUnknownMessageSetEntry(GPBMessage *self, uint32_t typeId, NSData
|
|||
|
||||
GPB_NOINLINE
|
||||
static void ParseUnknownField(GPBMessage *self, uint32_t tag, GPBCodedInputStream *input) {
|
||||
if (self->unknownFields_) {
|
||||
if (![self->unknownFields_ mergeFieldFrom:tag input:input]) {
|
||||
GPBRaiseStreamError(GPBCodedInputStreamErrorInvalidTag, @"Unexpected end-group tag");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t buf[20];
|
||||
uint8_t *ptr = buf;
|
||||
ptr = EncodeVarintU32(tag, ptr); // All will need the tag
|
||||
|
|
@ -1117,55 +1083,6 @@ void GPBClearMessageAutocreator(GPBMessage *self) {
|
|||
self->autocreatorExtension_ = nil;
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
GPB_NOINLINE
|
||||
static void MergeUnknownFieldDataIntoFieldSet(GPBMessage *self, NSData *data,
|
||||
GPBUnknownFieldSet *targetSet) {
|
||||
GPBUnknownFieldSet *unknownFields = targetSet ? targetSet : self->unknownFields_;
|
||||
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSCAssert(unknownFields != nil, @"Internal error: unknown fields not initialized.");
|
||||
#endif
|
||||
|
||||
BOOL isMessageSet = self.descriptor.isWireFormat;
|
||||
GPBUnknownFieldSet *decodeInto = isMessageSet ? [[GPBUnknownFieldSet alloc] init] : unknownFields;
|
||||
|
||||
GPBCodedInputStream *input = [[GPBCodedInputStream alloc] initWithData:data];
|
||||
@try {
|
||||
[decodeInto mergeFromCodedInputStream:input];
|
||||
} @catch (NSException *exception) {
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSLog(@"%@: Internal exception while parsing the unknown fields into a Set: %@", [self class],
|
||||
exception);
|
||||
#endif
|
||||
}
|
||||
[input release];
|
||||
|
||||
if (isMessageSet) {
|
||||
// Need to transform the groups back into how Message feeds the data into a MessageSet when
|
||||
// doing a full MessageSet based decode.
|
||||
GPBUnknownField *groupField = [decodeInto getField:GPBWireFormatMessageSetItem];
|
||||
for (GPBUnknownFieldSet *group in groupField.groupList) {
|
||||
GPBUnknownField *typeIdField = [group getField:GPBWireFormatMessageSetTypeId];
|
||||
GPBUnknownField *messageField = [group getField:GPBWireFormatMessageSetMessage];
|
||||
if (typeIdField.varintList.count != 1 || messageField.lengthDelimitedList.count != 1) {
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSCAssert(NO, @"Internal error: MessageSet group missing typeId or message.");
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
int32_t fieldNumber = (int32_t)[typeIdField.varintList valueAtIndex:0];
|
||||
GPBUnknownField *messageSetField = [[GPBUnknownField alloc] initWithNumber:fieldNumber];
|
||||
[messageSetField addLengthDelimited:messageField.lengthDelimitedList[0]];
|
||||
[unknownFields addField:messageSetField];
|
||||
[messageSetField release];
|
||||
}
|
||||
[decodeInto release];
|
||||
}
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@implementation GPBMessage
|
||||
|
||||
+ (void)initialize {
|
||||
|
|
@ -1402,11 +1319,7 @@ static void MergeUnknownFieldDataIntoFieldSet(GPBMessage *self, NSData *data,
|
|||
|
||||
[self copyFieldsInto:result zone:zone descriptor:descriptor];
|
||||
|
||||
@synchronized(self) {
|
||||
result->unknownFields_ = [unknownFields_ copyWithZone:zone];
|
||||
result->unknownFieldData_ = [unknownFieldData_ mutableCopyWithZone:zone];
|
||||
}
|
||||
|
||||
result->unknownFieldData_ = [unknownFieldData_ mutableCopyWithZone:zone];
|
||||
result->extensionMap_ = CloneExtensionMap(extensionMap_, zone);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1482,8 +1395,6 @@ static void MergeUnknownFieldDataIntoFieldSet(GPBMessage *self, NSData *data,
|
|||
extensionMap_ = nil;
|
||||
[unknownFieldData_ release];
|
||||
unknownFieldData_ = nil;
|
||||
[unknownFields_ release];
|
||||
unknownFields_ = nil;
|
||||
|
||||
// Note that clearing does not affect autocreator_. If we are being cleared
|
||||
// because of a dealloc, then autocreator_ should be nil anyway. If we are
|
||||
|
|
@ -1498,11 +1409,6 @@ static void MergeUnknownFieldDataIntoFieldSet(GPBMessage *self, NSData *data,
|
|||
- (void)clearUnknownFields {
|
||||
[unknownFieldData_ release];
|
||||
unknownFieldData_ = nil;
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[unknownFields_ release];
|
||||
unknownFields_ = nil;
|
||||
#pragma clang diagnostic pop
|
||||
GPBBecomeVisibleToAutocreator(self);
|
||||
}
|
||||
|
||||
|
|
@ -1690,20 +1596,9 @@ static void MergeUnknownFieldDataIntoFieldSet(GPBMessage *self, NSData *data,
|
|||
sortedExtensions:sortedExtensions];
|
||||
}
|
||||
}
|
||||
@synchronized(self) {
|
||||
if (unknownFieldData_) {
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(unknownFields_ == nil, @"Internal error both unknown states were set");
|
||||
#endif
|
||||
[output writeRawData:unknownFieldData_];
|
||||
} else {
|
||||
if (descriptor.isWireFormat) {
|
||||
[unknownFields_ writeAsMessageSetTo:output];
|
||||
} else {
|
||||
[unknownFields_ writeToCodedOutputStream:output];
|
||||
}
|
||||
}
|
||||
} // @synchronized(self)
|
||||
if (unknownFieldData_) {
|
||||
[output writeRawData:unknownFieldData_];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)writeDelimitedToOutputStream:(NSOutputStream *)output {
|
||||
|
|
@ -2421,34 +2316,6 @@ static void MergeUnknownFieldDataIntoFieldSet(GPBMessage *self, NSData *data,
|
|||
return result;
|
||||
}
|
||||
|
||||
#pragma mark - Unknown Field Support
|
||||
|
||||
- (GPBUnknownFieldSet *)unknownFields {
|
||||
@synchronized(self) {
|
||||
if (unknownFieldData_) {
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(unknownFields_ == nil, @"Internal error both unknown states were set");
|
||||
#endif
|
||||
unknownFields_ = [[GPBUnknownFieldSet alloc] init];
|
||||
MergeUnknownFieldDataIntoFieldSet(self, unknownFieldData_, nil);
|
||||
[unknownFieldData_ release];
|
||||
unknownFieldData_ = nil;
|
||||
}
|
||||
return unknownFields_;
|
||||
} // @synchronized(self)
|
||||
}
|
||||
|
||||
- (void)setUnknownFields:(GPBUnknownFieldSet *)unknownFields {
|
||||
if (unknownFields != unknownFields_ || unknownFieldData_ != nil) {
|
||||
// Changing sets or clearing.
|
||||
[unknownFieldData_ release];
|
||||
unknownFieldData_ = nil;
|
||||
[unknownFields_ release];
|
||||
unknownFields_ = [unknownFields copy];
|
||||
GPBBecomeVisibleToAutocreator(self);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)parseMessageSet:(GPBCodedInputStream *)input
|
||||
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry {
|
||||
uint32_t typeId = 0;
|
||||
|
|
@ -2973,28 +2840,11 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
|
|||
} // for(fields)
|
||||
|
||||
// Unknown fields.
|
||||
if (unknownFields_) {
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(unknownFieldData_ == nil, @"Internal error both unknown states were set");
|
||||
#endif
|
||||
@synchronized(other) {
|
||||
if (other->unknownFields_) {
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(other->unknownFieldData_ == nil, @"Internal error both unknown states were set");
|
||||
#endif
|
||||
[unknownFields_ mergeUnknownFields:other->unknownFields_];
|
||||
} else if (other->unknownFieldData_) {
|
||||
MergeUnknownFieldDataIntoFieldSet(self, other->unknownFieldData_, nil);
|
||||
}
|
||||
} // @synchronized(other)
|
||||
} else {
|
||||
NSData *otherData = GPBMessageUnknownFieldsData(other);
|
||||
if (otherData) {
|
||||
if (unknownFieldData_) {
|
||||
[unknownFieldData_ appendData:otherData];
|
||||
} else {
|
||||
unknownFieldData_ = [otherData mutableCopy];
|
||||
}
|
||||
if (other->unknownFieldData_) {
|
||||
if (unknownFieldData_) {
|
||||
[unknownFieldData_ appendData:other->unknownFieldData_];
|
||||
} else {
|
||||
unknownFieldData_ = [other->unknownFieldData_ mutableCopy];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3167,78 +3017,13 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
|
|||
}
|
||||
}
|
||||
|
||||
// Mutation while another thread is doing read only access is invalid, so the only thing we
|
||||
// need to guard against is concurrent r/o access, so we can grab the values (and retain them)
|
||||
// so we have a version to compare against safely incase the second access causes the transform
|
||||
// between internal states.
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
GPBUnknownFieldSet *selfUnknownFields;
|
||||
NSData *selfUnknownFieldData;
|
||||
@synchronized(self) {
|
||||
selfUnknownFields = [unknownFields_ retain];
|
||||
selfUnknownFieldData = [unknownFieldData_ retain];
|
||||
BOOL selfHas = unknownFieldData_ != nil;
|
||||
BOOL otherHas = otherMsg->unknownFieldData_ != nil;
|
||||
if (selfHas != otherHas) {
|
||||
return NO; // Only one has the data, not equal.
|
||||
}
|
||||
GPBUnknownFieldSet *otherUnknownFields;
|
||||
NSData *otherUnknownFieldData;
|
||||
@synchronized(otherMsg) {
|
||||
otherUnknownFields = [otherMsg->unknownFields_ retain];
|
||||
otherUnknownFieldData = [otherMsg->unknownFieldData_ retain];
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
#if defined(DEBUG) && DEBUG && !defined(NS_BLOCK_ASSERTIONS)
|
||||
if (selfUnknownFields) {
|
||||
NSAssert(selfUnknownFieldData == nil, @"Internal error both unknown states were set");
|
||||
}
|
||||
if (otherUnknownFields) {
|
||||
NSAssert(otherUnknownFieldData == nil, @"Internal error both unknown states were set");
|
||||
}
|
||||
#endif
|
||||
// Since a developer can set the legacy unknownFieldSet, treat nil and empty as the same.
|
||||
if (selfUnknownFields && selfUnknownFields.countOfFields == 0) {
|
||||
[selfUnknownFields release];
|
||||
selfUnknownFields = nil;
|
||||
}
|
||||
if (otherUnknownFields && otherUnknownFields.countOfFields == 0) {
|
||||
[otherUnknownFields release];
|
||||
otherUnknownFields = nil;
|
||||
}
|
||||
|
||||
BOOL result = YES;
|
||||
|
||||
if (selfUnknownFieldData && otherUnknownFieldData) {
|
||||
// Both had data, compare it.
|
||||
result = [selfUnknownFieldData isEqual:otherUnknownFieldData];
|
||||
} else if (selfUnknownFields && otherUnknownFields) {
|
||||
// Both had fields set, compare them.
|
||||
result = [selfUnknownFields isEqual:otherUnknownFields];
|
||||
} else {
|
||||
// At this point, we're done to one have a set/nothing, and the other having data/nothing.
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
GPBUnknownFieldSet *theSet = selfUnknownFields ? selfUnknownFields : otherUnknownFields;
|
||||
NSData *theData = selfUnknownFieldData ? selfUnknownFieldData : otherUnknownFieldData;
|
||||
if (theSet) {
|
||||
if (theData) {
|
||||
GPBUnknownFieldSet *tempSet = [[GPBUnknownFieldSet alloc] init];
|
||||
MergeUnknownFieldDataIntoFieldSet(self, theData, tempSet);
|
||||
result = [tempSet isEqual:theSet];
|
||||
[tempSet release];
|
||||
} else {
|
||||
result = NO;
|
||||
}
|
||||
} else {
|
||||
// It was a data/nothing and nothing, so they equal if the other didn't have data.
|
||||
result = theData == nil;
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
[selfUnknownFields release];
|
||||
[selfUnknownFieldData release];
|
||||
[otherUnknownFields release];
|
||||
[otherUnknownFieldData release];
|
||||
return result;
|
||||
// They both don't have (then equal) or they both have, and then compare the two.
|
||||
return !selfHas || [unknownFieldData_ isEqual:otherMsg->unknownFieldData_];
|
||||
}
|
||||
|
||||
// It is very difficult to implement a generic hash for ProtoBuf messages that
|
||||
|
|
@ -3501,20 +3286,7 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
|
|||
} // for(fields)
|
||||
|
||||
// Add any unknown fields.
|
||||
@synchronized(self) {
|
||||
if (unknownFieldData_) {
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSAssert(unknownFields_ == nil, @"Internal error both unknown states were set");
|
||||
#endif
|
||||
result += [unknownFieldData_ length];
|
||||
} else {
|
||||
if (descriptor.wireFormat) {
|
||||
result += [unknownFields_ serializedSizeAsMessageSet];
|
||||
} else {
|
||||
result += [unknownFields_ serializedSize];
|
||||
}
|
||||
}
|
||||
} // @synchronized(self)
|
||||
result += [unknownFieldData_ length];
|
||||
|
||||
// Add any extensions.
|
||||
for (GPBExtensionDescriptor *extension in extensionMap_) {
|
||||
|
|
@ -4040,35 +3812,6 @@ id GPBGetObjectIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) {
|
|||
return expected;
|
||||
}
|
||||
|
||||
NSData *GPBMessageUnknownFieldsData(GPBMessage *self) {
|
||||
NSData *result = nil;
|
||||
@synchronized(self) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
GPBUnknownFieldSet *unknownFields = self->unknownFields_;
|
||||
#pragma clang diagnostic pop
|
||||
if (unknownFields) {
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSCAssert(self->unknownFieldData_ == nil, @"Internal error both unknown states were set");
|
||||
#endif
|
||||
if (self.descriptor.isWireFormat) {
|
||||
NSMutableData *mutableData =
|
||||
[NSMutableData dataWithLength:unknownFields.serializedSizeAsMessageSet];
|
||||
GPBCodedOutputStream *output = [[GPBCodedOutputStream alloc] initWithData:mutableData];
|
||||
[unknownFields writeAsMessageSetTo:output];
|
||||
[output flush];
|
||||
[output release];
|
||||
result = mutableData;
|
||||
} else {
|
||||
result = [unknownFields data];
|
||||
}
|
||||
} else {
|
||||
// Internally we can borrow it without a copy since this is immediately used by callers
|
||||
// and multithreaded access with any mutation is not allow on messages.
|
||||
result = self->unknownFieldData_;
|
||||
}
|
||||
} // @synchronized(self)
|
||||
return result;
|
||||
}
|
||||
NSData *GPBMessageUnknownFieldsData(GPBMessage *self) { return self->unknownFieldData_; }
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
#import "GPBMessage.h"
|
||||
#import "GPBRootObject.h"
|
||||
#import "GPBUnknownField.h"
|
||||
#import "GPBUnknownFieldSet.h"
|
||||
#import "GPBUnknownFields.h"
|
||||
#import "GPBUtilities.h"
|
||||
#import "GPBWellKnownTypes.h"
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
#import "GPBMessage.m"
|
||||
#import "GPBRootObject.m"
|
||||
#import "GPBUnknownField.m"
|
||||
#import "GPBUnknownFieldSet.m"
|
||||
#import "GPBUnknownFields.m"
|
||||
#import "GPBUtilities.m"
|
||||
#import "GPBWellKnownTypes.m"
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ extension GPBUnknownField {
|
|||
}
|
||||
|
||||
/// The value of the field in a type-safe manner.
|
||||
///
|
||||
/// - Note: This is only valid for non-legacy fields.
|
||||
public var value: Value {
|
||||
switch type {
|
||||
case .varint:
|
||||
|
|
@ -32,8 +30,6 @@ extension GPBUnknownField {
|
|||
return .lengthDelimited(lengthDelimited)
|
||||
case .group:
|
||||
return .group(group)
|
||||
case .legacy:
|
||||
fatalError("`value` not valid for Legacy fields.")
|
||||
@unknown default:
|
||||
fatalError("Internal error: Unknown field type: \(type)")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,8 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GPBArray.h"
|
||||
#import "GPBUnknownFieldSet.h"
|
||||
#import "GPBUnknownFields.h"
|
||||
|
||||
@class GPBUnknownFieldSet;
|
||||
@class GPBUnknownFields;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
|
@ -22,13 +20,6 @@ typedef NS_ENUM(uint8_t, GPBUnknownFieldType) {
|
|||
GPBUnknownFieldTypeFixed64,
|
||||
GPBUnknownFieldTypeLengthDelimited, // Length prefixed
|
||||
GPBUnknownFieldTypeGroup, // Tag delimited
|
||||
|
||||
/**
|
||||
* This type is only used with fields from `GPBUnknownFieldsSet`. Some methods
|
||||
* only work with instances with this type and other apis require the other
|
||||
* type(s). It is a programming error to use the wrong methods.
|
||||
**/
|
||||
GPBUnknownFieldTypeLegacy,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -37,11 +28,6 @@ typedef NS_ENUM(uint8_t, GPBUnknownFieldType) {
|
|||
__attribute__((objc_subclassing_restricted))
|
||||
@interface GPBUnknownField : NSObject<NSCopying>
|
||||
|
||||
/** Initialize a field with the given number. */
|
||||
- (instancetype)initWithNumber:(int32_t)number
|
||||
__attribute__((deprecated(
|
||||
"Use the apis on GPBUnknownFields to add new fields instead of making them directly.")));
|
||||
|
||||
/** The field number the data is stored under. */
|
||||
@property(nonatomic, readonly, assign) int32_t number;
|
||||
|
||||
|
|
@ -84,106 +70,6 @@ __attribute__((objc_subclassing_restricted))
|
|||
*/
|
||||
@property(nonatomic, readonly, strong, nonnull) GPBUnknownFields *group;
|
||||
|
||||
/**
|
||||
* An array of varint values for this field.
|
||||
*
|
||||
* Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
|
||||
* to use with any other type.
|
||||
*/
|
||||
@property(nonatomic, readonly, strong) GPBUInt64Array *varintList
|
||||
__attribute__((deprecated("See the new apis on GPBUnknownFields and thus reduced api here.")));
|
||||
|
||||
/**
|
||||
* An array of fixed32 values for this field.
|
||||
*
|
||||
* Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
|
||||
* to use with any other type.
|
||||
*/
|
||||
@property(nonatomic, readonly, strong) GPBUInt32Array *fixed32List
|
||||
__attribute__((deprecated("See the new apis on GPBUnknownFields and thus reduced api here.")));
|
||||
|
||||
/**
|
||||
* An array of fixed64 values for this field.
|
||||
*
|
||||
* Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
|
||||
* to use with any other type.
|
||||
*/
|
||||
@property(nonatomic, readonly, strong) GPBUInt64Array *fixed64List
|
||||
__attribute__((deprecated("See the new apis on GPBUnknownFields and thus reduced api here.")));
|
||||
|
||||
/**
|
||||
* An array of data values for this field.
|
||||
*
|
||||
* Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
|
||||
* to use with any other type.
|
||||
*/
|
||||
@property(nonatomic, readonly, strong) NSArray<NSData *> *lengthDelimitedList
|
||||
__attribute__((deprecated("See the new apis on GPBUnknownFields and thus reduced api here.")));
|
||||
|
||||
/**
|
||||
* An array of groups of values for this field.
|
||||
*
|
||||
* Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
|
||||
* to use with any other type.
|
||||
*/
|
||||
@property(nonatomic, readonly, strong) NSArray<GPBUnknownFieldSet *> *groupList
|
||||
__attribute__((deprecated("See the new apis on GPBUnknownFields and thus reduced api here.")));
|
||||
|
||||
/**
|
||||
* Add a value to the varintList.
|
||||
*
|
||||
* Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
|
||||
* to use with any other type.
|
||||
*
|
||||
* @param value The value to add.
|
||||
**/
|
||||
- (void)addVarint:(uint64_t)value
|
||||
__attribute__((deprecated("See the new apis on GPBUnknownFields and thus reduced api here.")));
|
||||
|
||||
/**
|
||||
* Add a value to the fixed32List.
|
||||
*
|
||||
* Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
|
||||
* to use with any other type.
|
||||
*
|
||||
* @param value The value to add.
|
||||
**/
|
||||
- (void)addFixed32:(uint32_t)value
|
||||
__attribute__((deprecated("See the new apis on GPBUnknownFields and thus reduced api here.")));
|
||||
|
||||
/**
|
||||
* Add a value to the fixed64List.
|
||||
*
|
||||
* Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
|
||||
* to use with any other type.
|
||||
*
|
||||
* @param value The value to add.
|
||||
**/
|
||||
- (void)addFixed64:(uint64_t)value
|
||||
__attribute__((deprecated("See the new apis on GPBUnknownFields and thus reduced api here.")));
|
||||
|
||||
/**
|
||||
* Add a value to the lengthDelimitedList.
|
||||
*
|
||||
* Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
|
||||
* to use with any other type.
|
||||
*
|
||||
* @param value The value to add.
|
||||
**/
|
||||
- (void)addLengthDelimited:(NSData *)value
|
||||
__attribute__((deprecated("See the new apis on GPBUnknownFields and thus reduced api here.")));
|
||||
|
||||
/**
|
||||
* Add a value to the groupList.
|
||||
*
|
||||
* Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
|
||||
* to use with any other type.
|
||||
*
|
||||
* @param value The value to add.
|
||||
**/
|
||||
- (void)addGroup:(GPBUnknownFieldSet *)value
|
||||
__attribute__((deprecated("See the new apis on GPBUnknownFields and thus reduced api here.")));
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
|||
|
|
@ -8,10 +8,8 @@
|
|||
#import "GPBUnknownField.h"
|
||||
#import "GPBUnknownField_PackagePrivate.h"
|
||||
|
||||
#import "GPBArray.h"
|
||||
#import "GPBCodedOutputStream.h"
|
||||
#import "GPBCodedOutputStream_PackagePrivate.h"
|
||||
#import "GPBUnknownFieldSet.h"
|
||||
#import "GPBUnknownFields.h"
|
||||
#import "GPBUnknownFields_PackagePrivate.h"
|
||||
#import "GPBWireFormat.h"
|
||||
|
|
@ -27,14 +25,6 @@
|
|||
@synthesize number = number_;
|
||||
@synthesize type = type_;
|
||||
|
||||
- (instancetype)initWithNumber:(int32_t)number {
|
||||
if ((self = [super init])) {
|
||||
number_ = number;
|
||||
type_ = GPBUnknownFieldTypeLegacy;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithNumber:(int32_t)number varint:(uint64_t)varint {
|
||||
if ((self = [super init])) {
|
||||
number_ = number;
|
||||
|
|
@ -93,13 +83,6 @@
|
|||
case GPBUnknownFieldTypeGroup:
|
||||
[storage_.group release];
|
||||
break;
|
||||
case GPBUnknownFieldTypeLegacy:
|
||||
[storage_.legacy.mutableVarintList release];
|
||||
[storage_.legacy.mutableFixed32List release];
|
||||
[storage_.legacy.mutableFixed64List release];
|
||||
[storage_.legacy.mutableLengthDelimitedList release];
|
||||
[storage_.legacy.mutableGroupList release];
|
||||
break;
|
||||
}
|
||||
|
||||
[super dealloc];
|
||||
|
|
@ -136,31 +119,6 @@
|
|||
return storage_.group;
|
||||
}
|
||||
|
||||
- (GPBUInt64Array *)varintList {
|
||||
ASSERT_FIELD_TYPE(GPBUnknownFieldTypeLegacy);
|
||||
return storage_.legacy.mutableVarintList;
|
||||
}
|
||||
|
||||
- (GPBUInt32Array *)fixed32List {
|
||||
ASSERT_FIELD_TYPE(GPBUnknownFieldTypeLegacy);
|
||||
return storage_.legacy.mutableFixed32List;
|
||||
}
|
||||
|
||||
- (GPBUInt64Array *)fixed64List {
|
||||
ASSERT_FIELD_TYPE(GPBUnknownFieldTypeLegacy);
|
||||
return storage_.legacy.mutableFixed64List;
|
||||
}
|
||||
|
||||
- (NSArray<NSData *> *)lengthDelimitedList {
|
||||
ASSERT_FIELD_TYPE(GPBUnknownFieldTypeLegacy);
|
||||
return storage_.legacy.mutableLengthDelimitedList;
|
||||
}
|
||||
|
||||
- (NSArray<GPBUnknownFieldSet *> *)groupList {
|
||||
ASSERT_FIELD_TYPE(GPBUnknownFieldTypeLegacy);
|
||||
return storage_.legacy.mutableGroupList;
|
||||
}
|
||||
|
||||
- (id)copyWithZone:(NSZone *)zone {
|
||||
switch (type_) {
|
||||
case GPBUnknownFieldTypeVarint:
|
||||
|
|
@ -178,30 +136,6 @@
|
|||
[copyGroup release];
|
||||
return copy;
|
||||
}
|
||||
case GPBUnknownFieldTypeLegacy: {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
GPBUnknownField *result = [[GPBUnknownField allocWithZone:zone] initWithNumber:number_];
|
||||
result->storage_.legacy.mutableFixed32List =
|
||||
[storage_.legacy.mutableFixed32List copyWithZone:zone];
|
||||
result->storage_.legacy.mutableFixed64List =
|
||||
[storage_.legacy.mutableFixed64List copyWithZone:zone];
|
||||
result->storage_.legacy.mutableLengthDelimitedList =
|
||||
[storage_.legacy.mutableLengthDelimitedList mutableCopyWithZone:zone];
|
||||
result->storage_.legacy.mutableVarintList =
|
||||
[storage_.legacy.mutableVarintList copyWithZone:zone];
|
||||
if (storage_.legacy.mutableGroupList.count) {
|
||||
result->storage_.legacy.mutableGroupList = [[NSMutableArray allocWithZone:zone]
|
||||
initWithCapacity:storage_.legacy.mutableGroupList.count];
|
||||
for (GPBUnknownFieldSet *group in storage_.legacy.mutableGroupList) {
|
||||
GPBUnknownFieldSet *copied = [group copyWithZone:zone];
|
||||
[result->storage_.legacy.mutableGroupList addObject:copied];
|
||||
[copied release];
|
||||
}
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -220,34 +154,6 @@
|
|||
return [storage_.lengthDelimited isEqual:field->storage_.lengthDelimited];
|
||||
case GPBUnknownFieldTypeGroup:
|
||||
return [storage_.group isEqual:field->storage_.group];
|
||||
case GPBUnknownFieldTypeLegacy: {
|
||||
BOOL equalVarint =
|
||||
(storage_.legacy.mutableVarintList.count == 0 &&
|
||||
field->storage_.legacy.mutableVarintList.count == 0) ||
|
||||
[storage_.legacy.mutableVarintList isEqual:field->storage_.legacy.mutableVarintList];
|
||||
if (!equalVarint) return NO;
|
||||
BOOL equalFixed32 =
|
||||
(storage_.legacy.mutableFixed32List.count == 0 &&
|
||||
field->storage_.legacy.mutableFixed32List.count == 0) ||
|
||||
[storage_.legacy.mutableFixed32List isEqual:field->storage_.legacy.mutableFixed32List];
|
||||
if (!equalFixed32) return NO;
|
||||
BOOL equalFixed64 =
|
||||
(storage_.legacy.mutableFixed64List.count == 0 &&
|
||||
field->storage_.legacy.mutableFixed64List.count == 0) ||
|
||||
[storage_.legacy.mutableFixed64List isEqual:field->storage_.legacy.mutableFixed64List];
|
||||
if (!equalFixed64) return NO;
|
||||
BOOL equalLDList = (storage_.legacy.mutableLengthDelimitedList.count == 0 &&
|
||||
field->storage_.legacy.mutableLengthDelimitedList.count == 0) ||
|
||||
[storage_.legacy.mutableLengthDelimitedList
|
||||
isEqual:field->storage_.legacy.mutableLengthDelimitedList];
|
||||
if (!equalLDList) return NO;
|
||||
BOOL equalGroupList =
|
||||
(storage_.legacy.mutableGroupList.count == 0 &&
|
||||
field->storage_.legacy.mutableGroupList.count == 0) ||
|
||||
[storage_.legacy.mutableGroupList isEqual:field->storage_.legacy.mutableGroupList];
|
||||
if (!equalGroupList) return NO;
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -265,89 +171,6 @@
|
|||
break;
|
||||
case GPBUnknownFieldTypeGroup:
|
||||
result = prime * result + [storage_.group hash];
|
||||
case GPBUnknownFieldTypeLegacy:
|
||||
result = prime * result + [storage_.legacy.mutableVarintList hash];
|
||||
result = prime * result + [storage_.legacy.mutableFixed32List hash];
|
||||
result = prime * result + [storage_.legacy.mutableFixed64List hash];
|
||||
result = prime * result + [storage_.legacy.mutableLengthDelimitedList hash];
|
||||
result = prime * result + [storage_.legacy.mutableGroupList hash];
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void)writeToOutput:(GPBCodedOutputStream *)output {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
ASSERT_FIELD_TYPE(GPBUnknownFieldTypeLegacy);
|
||||
NSUInteger count = storage_.legacy.mutableVarintList.count;
|
||||
if (count > 0) {
|
||||
[output writeUInt64Array:number_ values:storage_.legacy.mutableVarintList tag:0];
|
||||
}
|
||||
count = storage_.legacy.mutableFixed32List.count;
|
||||
if (count > 0) {
|
||||
[output writeFixed32Array:number_ values:storage_.legacy.mutableFixed32List tag:0];
|
||||
}
|
||||
count = storage_.legacy.mutableFixed64List.count;
|
||||
if (count > 0) {
|
||||
[output writeFixed64Array:number_ values:storage_.legacy.mutableFixed64List tag:0];
|
||||
}
|
||||
count = storage_.legacy.mutableLengthDelimitedList.count;
|
||||
if (count > 0) {
|
||||
[output writeBytesArray:number_ values:storage_.legacy.mutableLengthDelimitedList];
|
||||
}
|
||||
count = storage_.legacy.mutableGroupList.count;
|
||||
if (count > 0) {
|
||||
[output writeUnknownGroupArray:number_ values:storage_.legacy.mutableGroupList];
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
- (size_t)serializedSize {
|
||||
ASSERT_FIELD_TYPE(GPBUnknownFieldTypeLegacy);
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
__block size_t result = 0;
|
||||
int32_t number = number_;
|
||||
[storage_.legacy.mutableVarintList
|
||||
enumerateValuesWithBlock:^(uint64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
result += GPBComputeUInt64Size(number, value);
|
||||
}];
|
||||
|
||||
[storage_.legacy.mutableFixed32List
|
||||
enumerateValuesWithBlock:^(uint32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
result += GPBComputeFixed32Size(number, value);
|
||||
}];
|
||||
|
||||
[storage_.legacy.mutableFixed64List
|
||||
enumerateValuesWithBlock:^(uint64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
result += GPBComputeFixed64Size(number, value);
|
||||
}];
|
||||
|
||||
for (NSData *data in storage_.legacy.mutableLengthDelimitedList) {
|
||||
result += GPBComputeBytesSize(number, data);
|
||||
}
|
||||
|
||||
for (GPBUnknownFieldSet *set in storage_.legacy.mutableGroupList) {
|
||||
result += GPBComputeUnknownGroupSize(number, set);
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void)writeAsMessageSetExtensionToOutput:(GPBCodedOutputStream *)output {
|
||||
ASSERT_FIELD_TYPE(GPBUnknownFieldTypeLegacy);
|
||||
for (NSData *data in storage_.legacy.mutableLengthDelimitedList) {
|
||||
[output writeRawMessageSetExtension:number_ value:data];
|
||||
}
|
||||
}
|
||||
|
||||
- (size_t)serializedSizeAsMessageSetExtension {
|
||||
ASSERT_FIELD_TYPE(GPBUnknownFieldTypeLegacy);
|
||||
size_t result = 0;
|
||||
for (NSData *data in storage_.legacy.mutableLengthDelimitedList) {
|
||||
result += GPBComputeRawMessageSetExtensionSize(number_, data);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -371,137 +194,10 @@
|
|||
case GPBUnknownFieldTypeGroup:
|
||||
[description appendFormat:@" group: %@", storage_.group];
|
||||
break;
|
||||
case GPBUnknownFieldTypeLegacy:
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[description appendString:@" {\n"];
|
||||
[storage_.legacy.mutableVarintList
|
||||
enumerateValuesWithBlock:^(uint64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
[description appendFormat:@"\t%llu\n", value];
|
||||
}];
|
||||
[storage_.legacy.mutableFixed32List
|
||||
enumerateValuesWithBlock:^(uint32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
[description appendFormat:@"\t%u\n", value];
|
||||
}];
|
||||
[storage_.legacy.mutableFixed64List
|
||||
enumerateValuesWithBlock:^(uint64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
[description appendFormat:@"\t%llu\n", value];
|
||||
}];
|
||||
for (NSData *data in storage_.legacy.mutableLengthDelimitedList) {
|
||||
[description appendFormat:@"\t%@\n", data];
|
||||
}
|
||||
for (GPBUnknownFieldSet *set in storage_.legacy.mutableGroupList) {
|
||||
[description appendFormat:@"\t%@\n", set];
|
||||
}
|
||||
[description appendString:@"}"];
|
||||
#pragma clang diagnostic pop
|
||||
break;
|
||||
}
|
||||
return description;
|
||||
}
|
||||
|
||||
- (void)mergeFromField:(GPBUnknownField *)other {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
ASSERT_FIELD_TYPE(GPBUnknownFieldTypeLegacy);
|
||||
GPBUInt64Array *otherVarintList = other.varintList;
|
||||
if (otherVarintList.count > 0) {
|
||||
if (storage_.legacy.mutableVarintList == nil) {
|
||||
storage_.legacy.mutableVarintList = [otherVarintList copy];
|
||||
} else {
|
||||
[storage_.legacy.mutableVarintList addValuesFromArray:otherVarintList];
|
||||
}
|
||||
}
|
||||
|
||||
GPBUInt32Array *otherFixed32List = other.fixed32List;
|
||||
if (otherFixed32List.count > 0) {
|
||||
if (storage_.legacy.mutableFixed32List == nil) {
|
||||
storage_.legacy.mutableFixed32List = [otherFixed32List copy];
|
||||
} else {
|
||||
[storage_.legacy.mutableFixed32List addValuesFromArray:otherFixed32List];
|
||||
}
|
||||
}
|
||||
|
||||
GPBUInt64Array *otherFixed64List = other.fixed64List;
|
||||
if (otherFixed64List.count > 0) {
|
||||
if (storage_.legacy.mutableFixed64List == nil) {
|
||||
storage_.legacy.mutableFixed64List = [otherFixed64List copy];
|
||||
} else {
|
||||
[storage_.legacy.mutableFixed64List addValuesFromArray:otherFixed64List];
|
||||
}
|
||||
}
|
||||
|
||||
NSArray *otherLengthDelimitedList = other.lengthDelimitedList;
|
||||
if (otherLengthDelimitedList.count > 0) {
|
||||
if (storage_.legacy.mutableLengthDelimitedList == nil) {
|
||||
storage_.legacy.mutableLengthDelimitedList = [otherLengthDelimitedList mutableCopy];
|
||||
} else {
|
||||
[storage_.legacy.mutableLengthDelimitedList addObjectsFromArray:otherLengthDelimitedList];
|
||||
}
|
||||
}
|
||||
|
||||
NSArray *otherGroupList = other.groupList;
|
||||
if (otherGroupList.count > 0) {
|
||||
if (storage_.legacy.mutableGroupList == nil) {
|
||||
storage_.legacy.mutableGroupList =
|
||||
[[NSMutableArray alloc] initWithCapacity:otherGroupList.count];
|
||||
}
|
||||
// Make our own mutable copies.
|
||||
for (GPBUnknownFieldSet *group in otherGroupList) {
|
||||
GPBUnknownFieldSet *copied = [group copy];
|
||||
[storage_.legacy.mutableGroupList addObject:copied];
|
||||
[copied release];
|
||||
}
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
- (void)addVarint:(uint64_t)value {
|
||||
ASSERT_FIELD_TYPE(GPBUnknownFieldTypeLegacy);
|
||||
if (storage_.legacy.mutableVarintList == nil) {
|
||||
storage_.legacy.mutableVarintList = [[GPBUInt64Array alloc] initWithValues:&value count:1];
|
||||
} else {
|
||||
[storage_.legacy.mutableVarintList addValue:value];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addFixed32:(uint32_t)value {
|
||||
ASSERT_FIELD_TYPE(GPBUnknownFieldTypeLegacy);
|
||||
if (storage_.legacy.mutableFixed32List == nil) {
|
||||
storage_.legacy.mutableFixed32List = [[GPBUInt32Array alloc] initWithValues:&value count:1];
|
||||
} else {
|
||||
[storage_.legacy.mutableFixed32List addValue:value];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addFixed64:(uint64_t)value {
|
||||
ASSERT_FIELD_TYPE(GPBUnknownFieldTypeLegacy);
|
||||
if (storage_.legacy.mutableFixed64List == nil) {
|
||||
storage_.legacy.mutableFixed64List = [[GPBUInt64Array alloc] initWithValues:&value count:1];
|
||||
} else {
|
||||
[storage_.legacy.mutableFixed64List addValue:value];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addLengthDelimited:(NSData *)value {
|
||||
ASSERT_FIELD_TYPE(GPBUnknownFieldTypeLegacy);
|
||||
if (storage_.legacy.mutableLengthDelimitedList == nil) {
|
||||
storage_.legacy.mutableLengthDelimitedList = [[NSMutableArray alloc] initWithObjects:&value
|
||||
count:1];
|
||||
} else {
|
||||
[storage_.legacy.mutableLengthDelimitedList addObject:value];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addGroup:(GPBUnknownFieldSet *)value {
|
||||
ASSERT_FIELD_TYPE(GPBUnknownFieldTypeLegacy);
|
||||
if (storage_.legacy.mutableGroupList == nil) {
|
||||
storage_.legacy.mutableGroupList = [[NSMutableArray alloc] initWithObjects:&value count:1];
|
||||
} else {
|
||||
[storage_.legacy.mutableGroupList addObject:value];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -1,61 +0,0 @@
|
|||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GPBUnknownField.h"
|
||||
|
||||
@class GPBUnknownField;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* A collection of unknown fields. Fields parsed from the binary representation
|
||||
* of a message that are unknown end up in an instance of this set.
|
||||
**/
|
||||
__attribute__((deprecated("Use GPBUnknownFields instead.", "GPBUnknownFields")))
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
@interface GPBUnknownFieldSet : NSObject<NSCopying>
|
||||
|
||||
/**
|
||||
* Tests to see if the given field number has a value.
|
||||
*
|
||||
* @param number The field number to check.
|
||||
*
|
||||
* @return YES if there is an unknown field for the given field number.
|
||||
**/
|
||||
- (BOOL)hasField:(int32_t)number;
|
||||
|
||||
/**
|
||||
* Fetches the GPBUnknownField for the given field number.
|
||||
*
|
||||
* @param number The field number to look up.
|
||||
*
|
||||
* @return The GPBUnknownField or nil if none found.
|
||||
**/
|
||||
- (nullable GPBUnknownField *)getField:(int32_t)number;
|
||||
|
||||
/**
|
||||
* @return The number of fields in this set.
|
||||
**/
|
||||
- (NSUInteger)countOfFields;
|
||||
|
||||
/**
|
||||
* Adds the given field to the set.
|
||||
*
|
||||
* @param field The field to add to the set.
|
||||
**/
|
||||
- (void)addField:(GPBUnknownField *)field;
|
||||
|
||||
/**
|
||||
* @return An array of the GPBUnknownFields sorted by the field numbers.
|
||||
**/
|
||||
- (NSArray<GPBUnknownField *> *)sortedFields;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
@ -1,348 +0,0 @@
|
|||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#import "GPBUnknownFieldSet.h"
|
||||
#import "GPBUnknownFieldSet_PackagePrivate.h"
|
||||
|
||||
#import "GPBCodedInputStream.h"
|
||||
#import "GPBCodedInputStream_PackagePrivate.h"
|
||||
#import "GPBCodedOutputStream.h"
|
||||
#import "GPBUnknownField.h"
|
||||
#import "GPBUnknownField_PackagePrivate.h"
|
||||
#import "GPBUtilities.h"
|
||||
#import "GPBWireFormat.h"
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
|
||||
|
||||
#pragma mark Helpers
|
||||
|
||||
static void checkNumber(int32_t number) {
|
||||
if (number == 0) {
|
||||
[NSException raise:NSInvalidArgumentException format:@"Zero is not a valid field number."];
|
||||
}
|
||||
}
|
||||
|
||||
@implementation GPBUnknownFieldSet {
|
||||
@package
|
||||
CFMutableDictionaryRef fields_;
|
||||
}
|
||||
|
||||
static void CopyWorker(__unused const void *key, const void *value, void *context) {
|
||||
GPBUnknownField *field = value;
|
||||
GPBUnknownFieldSet *result = context;
|
||||
|
||||
GPBUnknownField *copied = [field copy];
|
||||
[result addField:copied];
|
||||
[copied release];
|
||||
}
|
||||
|
||||
// Direct access is use for speed, to avoid even internally declaring things
|
||||
// read/write, etc. The warning is enabled in the project to ensure code calling
|
||||
// protos can turn on -Wdirect-ivar-access without issues.
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
|
||||
- (id)copyWithZone:(NSZone *)zone {
|
||||
GPBUnknownFieldSet *result = [[GPBUnknownFieldSet allocWithZone:zone] init];
|
||||
if (fields_) {
|
||||
CFDictionaryApplyFunction(fields_, CopyWorker, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
if (fields_) {
|
||||
CFRelease(fields_);
|
||||
}
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (BOOL)isEqual:(id)object {
|
||||
BOOL equal = NO;
|
||||
if ([object isKindOfClass:[GPBUnknownFieldSet class]]) {
|
||||
GPBUnknownFieldSet *set = (GPBUnknownFieldSet *)object;
|
||||
if ((fields_ == NULL) && (set->fields_ == NULL)) {
|
||||
equal = YES;
|
||||
} else if ((fields_ != NULL) && (set->fields_ != NULL)) {
|
||||
equal = CFEqual(fields_, set->fields_);
|
||||
}
|
||||
}
|
||||
return equal;
|
||||
}
|
||||
|
||||
- (NSUInteger)hash {
|
||||
// Return the hash of the fields dictionary (or just some value).
|
||||
if (fields_) {
|
||||
return CFHash(fields_);
|
||||
}
|
||||
return (NSUInteger)[GPBUnknownFieldSet class];
|
||||
}
|
||||
|
||||
#pragma mark - Public Methods
|
||||
|
||||
- (BOOL)hasField:(int32_t)number {
|
||||
ssize_t key = number;
|
||||
return fields_ ? (CFDictionaryGetValue(fields_, (void *)key) != nil) : NO;
|
||||
}
|
||||
|
||||
- (GPBUnknownField *)getField:(int32_t)number {
|
||||
ssize_t key = number;
|
||||
GPBUnknownField *result = fields_ ? CFDictionaryGetValue(fields_, (void *)key) : nil;
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSUInteger)countOfFields {
|
||||
return fields_ ? CFDictionaryGetCount(fields_) : 0;
|
||||
}
|
||||
|
||||
- (NSArray *)sortedFields {
|
||||
if (!fields_) return [NSArray array];
|
||||
size_t count = CFDictionaryGetCount(fields_);
|
||||
ssize_t keys[count];
|
||||
GPBUnknownField *values[count];
|
||||
CFDictionaryGetKeysAndValues(fields_, (const void **)keys, (const void **)values);
|
||||
struct GPBFieldPair {
|
||||
ssize_t key;
|
||||
GPBUnknownField *value;
|
||||
} pairs[count];
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
pairs[i].key = keys[i];
|
||||
pairs[i].value = values[i];
|
||||
};
|
||||
qsort_b(pairs, count, sizeof(struct GPBFieldPair), ^(const void *first, const void *second) {
|
||||
const struct GPBFieldPair *a = first;
|
||||
const struct GPBFieldPair *b = second;
|
||||
return (a->key > b->key) ? 1 : ((a->key == b->key) ? 0 : -1);
|
||||
});
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
values[i] = pairs[i].value;
|
||||
};
|
||||
return [NSArray arrayWithObjects:values count:count];
|
||||
}
|
||||
|
||||
#pragma mark - Internal Methods
|
||||
|
||||
- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)output {
|
||||
if (!fields_) return;
|
||||
size_t count = CFDictionaryGetCount(fields_);
|
||||
ssize_t keys[count];
|
||||
GPBUnknownField *values[count];
|
||||
CFDictionaryGetKeysAndValues(fields_, (const void **)keys, (const void **)values);
|
||||
if (count > 1) {
|
||||
struct GPBFieldPair {
|
||||
ssize_t key;
|
||||
GPBUnknownField *value;
|
||||
} pairs[count];
|
||||
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
pairs[i].key = keys[i];
|
||||
pairs[i].value = values[i];
|
||||
};
|
||||
qsort_b(pairs, count, sizeof(struct GPBFieldPair), ^(const void *first, const void *second) {
|
||||
const struct GPBFieldPair *a = first;
|
||||
const struct GPBFieldPair *b = second;
|
||||
return (a->key > b->key) ? 1 : ((a->key == b->key) ? 0 : -1);
|
||||
});
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
GPBUnknownField *value = pairs[i].value;
|
||||
[value writeToOutput:output];
|
||||
}
|
||||
} else {
|
||||
[values[0] writeToOutput:output];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)description {
|
||||
NSMutableString *description =
|
||||
[NSMutableString stringWithFormat:@"<%@ %p>: TextFormat: {\n", [self class], self];
|
||||
NSString *textFormat = GPBTextFormatForUnknownFieldSet(self, @" ");
|
||||
[description appendString:textFormat];
|
||||
[description appendString:@"}"];
|
||||
return description;
|
||||
}
|
||||
|
||||
static void GPBUnknownFieldSetSerializedSize(__unused const void *key, const void *value,
|
||||
void *context) {
|
||||
GPBUnknownField *field = value;
|
||||
size_t *result = context;
|
||||
*result += [field serializedSize];
|
||||
}
|
||||
|
||||
- (size_t)serializedSize {
|
||||
size_t result = 0;
|
||||
if (fields_) {
|
||||
CFDictionaryApplyFunction(fields_, GPBUnknownFieldSetSerializedSize, &result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static void GPBUnknownFieldSetWriteAsMessageSetTo(__unused const void *key, const void *value,
|
||||
void *context) {
|
||||
GPBUnknownField *field = value;
|
||||
GPBCodedOutputStream *output = context;
|
||||
[field writeAsMessageSetExtensionToOutput:output];
|
||||
}
|
||||
|
||||
- (void)writeAsMessageSetTo:(GPBCodedOutputStream *)output {
|
||||
if (fields_) {
|
||||
CFDictionaryApplyFunction(fields_, GPBUnknownFieldSetWriteAsMessageSetTo, output);
|
||||
}
|
||||
}
|
||||
|
||||
static void GPBUnknownFieldSetSerializedSizeAsMessageSet(__unused const void *key,
|
||||
const void *value, void *context) {
|
||||
GPBUnknownField *field = value;
|
||||
size_t *result = context;
|
||||
*result += [field serializedSizeAsMessageSetExtension];
|
||||
}
|
||||
|
||||
- (size_t)serializedSizeAsMessageSet {
|
||||
size_t result = 0;
|
||||
if (fields_) {
|
||||
CFDictionaryApplyFunction(fields_, GPBUnknownFieldSetSerializedSizeAsMessageSet, &result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSData *)data {
|
||||
NSMutableData *data = [NSMutableData dataWithLength:self.serializedSize];
|
||||
GPBCodedOutputStream *output = [[GPBCodedOutputStream alloc] initWithData:data];
|
||||
[self writeToCodedOutputStream:output];
|
||||
[output flush];
|
||||
[output release];
|
||||
return data;
|
||||
}
|
||||
|
||||
- (void)addField:(GPBUnknownField *)field {
|
||||
int32_t number = [field number];
|
||||
checkNumber(number);
|
||||
if (!fields_) {
|
||||
// Use a custom dictionary here because the keys are numbers and conversion
|
||||
// back and forth from NSNumber isn't worth the cost.
|
||||
fields_ =
|
||||
CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL, &kCFTypeDictionaryValueCallBacks);
|
||||
}
|
||||
ssize_t key = number;
|
||||
CFDictionarySetValue(fields_, (const void *)key, field);
|
||||
}
|
||||
|
||||
- (GPBUnknownField *)mutableFieldForNumber:(int32_t)number create:(BOOL)create {
|
||||
ssize_t key = number;
|
||||
GPBUnknownField *existing = fields_ ? CFDictionaryGetValue(fields_, (const void *)key) : nil;
|
||||
if (!existing && create) {
|
||||
existing = [[GPBUnknownField alloc] initWithNumber:number];
|
||||
// This retains existing.
|
||||
[self addField:existing];
|
||||
[existing release];
|
||||
}
|
||||
return existing;
|
||||
}
|
||||
|
||||
static void GPBUnknownFieldSetMergeUnknownFields(__unused const void *key, const void *value,
|
||||
void *context) {
|
||||
GPBUnknownField *field = value;
|
||||
GPBUnknownFieldSet *self = context;
|
||||
|
||||
int32_t number = [field number];
|
||||
checkNumber(number);
|
||||
GPBUnknownField *oldField = [self mutableFieldForNumber:number create:NO];
|
||||
if (oldField) {
|
||||
[oldField mergeFromField:field];
|
||||
} else {
|
||||
// Merge only comes from GPBMessage's mergeFrom:, so it means we are on
|
||||
// mutable message and are an mutable instance, so make sure we need
|
||||
// mutable fields.
|
||||
GPBUnknownField *fieldCopy = [field copy];
|
||||
[self addField:fieldCopy];
|
||||
[fieldCopy release];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)mergeUnknownFields:(GPBUnknownFieldSet *)other {
|
||||
if (other && other->fields_) {
|
||||
CFDictionaryApplyFunction(other->fields_, GPBUnknownFieldSetMergeUnknownFields, self);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)mergeVarintField:(int32_t)number value:(int32_t)value {
|
||||
checkNumber(number);
|
||||
[[self mutableFieldForNumber:number create:YES] addVarint:value];
|
||||
}
|
||||
|
||||
- (void)mergeLengthDelimited:(int32_t)fieldNum value:(NSData *)value {
|
||||
checkNumber(fieldNum);
|
||||
[[self mutableFieldForNumber:fieldNum create:YES] addLengthDelimited:value];
|
||||
}
|
||||
|
||||
- (BOOL)mergeFieldFrom:(int32_t)tag input:(GPBCodedInputStream *)input {
|
||||
NSAssert(GPBWireFormatIsValidTag(tag), @"Got passed an invalid tag");
|
||||
int32_t number = GPBWireFormatGetTagFieldNumber(tag);
|
||||
GPBCodedInputStreamState *state = &input->state_;
|
||||
switch (GPBWireFormatGetTagWireType(tag)) {
|
||||
case GPBWireFormatVarint: {
|
||||
GPBUnknownField *field = [self mutableFieldForNumber:number create:YES];
|
||||
[field addVarint:GPBCodedInputStreamReadInt64(state)];
|
||||
return YES;
|
||||
}
|
||||
case GPBWireFormatFixed64: {
|
||||
GPBUnknownField *field = [self mutableFieldForNumber:number create:YES];
|
||||
[field addFixed64:GPBCodedInputStreamReadFixed64(state)];
|
||||
return YES;
|
||||
}
|
||||
case GPBWireFormatLengthDelimited: {
|
||||
NSData *data = GPBCodedInputStreamReadRetainedBytes(state);
|
||||
GPBUnknownField *field = [self mutableFieldForNumber:number create:YES];
|
||||
[field addLengthDelimited:data];
|
||||
[data release];
|
||||
return YES;
|
||||
}
|
||||
case GPBWireFormatStartGroup: {
|
||||
GPBUnknownFieldSet *unknownFieldSet = [[GPBUnknownFieldSet alloc] init];
|
||||
GPBUnknownField *field = [self mutableFieldForNumber:number create:YES];
|
||||
[field addGroup:unknownFieldSet];
|
||||
// The field will now retain unknownFieldSet, so go ahead and release it in case
|
||||
// -readUnknownGroup:message: throws so it won't be leaked.
|
||||
[unknownFieldSet release];
|
||||
[input readUnknownGroup:number message:unknownFieldSet];
|
||||
return YES;
|
||||
}
|
||||
case GPBWireFormatEndGroup:
|
||||
return NO;
|
||||
case GPBWireFormatFixed32: {
|
||||
GPBUnknownField *field = [self mutableFieldForNumber:number create:YES];
|
||||
[field addFixed32:GPBCodedInputStreamReadFixed32(state)];
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input {
|
||||
while (YES) {
|
||||
int32_t tag = GPBCodedInputStreamReadTag(&input->state_);
|
||||
if (tag == 0 || ![self mergeFieldFrom:tag input:input]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)getTags:(int32_t *)tags {
|
||||
if (!fields_) return;
|
||||
size_t count = CFDictionaryGetCount(fields_);
|
||||
ssize_t keys[count];
|
||||
CFDictionaryGetKeysAndValues(fields_, (const void **)keys, NULL);
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
tags[i] = (int32_t)keys[i];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@end
|
||||
|
||||
#pragma clang diagnostic pop // -Wdeprecated-declarations suppression
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GPBCodedInputStream.h"
|
||||
#import "GPBCodedOutputStream.h"
|
||||
#import "GPBUnknownFieldSet.h"
|
||||
|
||||
@interface GPBUnknownFieldSet ()
|
||||
|
||||
- (NSData *)data;
|
||||
|
||||
- (size_t)serializedSize;
|
||||
- (size_t)serializedSizeAsMessageSet;
|
||||
|
||||
- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)output;
|
||||
- (void)writeAsMessageSetTo:(GPBCodedOutputStream *)output;
|
||||
|
||||
- (void)mergeUnknownFields:(GPBUnknownFieldSet *)other;
|
||||
|
||||
- (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input;
|
||||
|
||||
- (void)mergeVarintField:(int32_t)number value:(int32_t)value;
|
||||
- (void)mergeLengthDelimited:(int32_t)number value:(NSData *)value;
|
||||
- (BOOL)mergeFieldFrom:(int32_t)tag input:(GPBCodedInputStream *)input;
|
||||
|
||||
@end
|
||||
|
|
@ -9,10 +9,6 @@
|
|||
|
||||
#import "GPBUnknownField.h"
|
||||
|
||||
#import "GPBArray.h"
|
||||
|
||||
@class GPBCodedOutputStream;
|
||||
|
||||
@interface GPBUnknownField () {
|
||||
@package
|
||||
int32_t number_;
|
||||
|
|
@ -22,16 +18,6 @@
|
|||
uint64_t intValue; // type == Varint, Fixed32, Fixed64
|
||||
NSData *_Nonnull lengthDelimited; // type == LengthDelimited
|
||||
GPBUnknownFields *_Nonnull group; // type == Group
|
||||
struct { // type == Legacy
|
||||
GPBUInt64Array *_Null_unspecified mutableVarintList;
|
||||
GPBUInt32Array *_Null_unspecified mutableFixed32List;
|
||||
GPBUInt64Array *_Null_unspecified mutableFixed64List;
|
||||
NSMutableArray<NSData *> *_Null_unspecified mutableLengthDelimitedList;
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
NSMutableArray<GPBUnknownFieldSet *> *_Null_unspecified mutableGroupList;
|
||||
#pragma clang diagnostic pop
|
||||
} legacy;
|
||||
} storage_;
|
||||
}
|
||||
|
||||
|
|
@ -41,12 +27,4 @@
|
|||
- (nonnull instancetype)initWithNumber:(int32_t)number lengthDelimited:(nonnull NSData *)data;
|
||||
- (nonnull instancetype)initWithNumber:(int32_t)number group:(nonnull GPBUnknownFields *)group;
|
||||
|
||||
- (void)writeToOutput:(nonnull GPBCodedOutputStream *)output;
|
||||
- (size_t)serializedSize;
|
||||
|
||||
- (void)writeAsMessageSetExtensionToOutput:(nonnull GPBCodedOutputStream *)output;
|
||||
- (size_t)serializedSizeAsMessageSetExtension;
|
||||
|
||||
- (void)mergeFromField:(nonnull GPBUnknownField *)other;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -121,8 +121,6 @@ __attribute__((objc_subclassing_restricted))
|
|||
* the `.group` of that result is also new, so if you intent is to modify the group
|
||||
* it *must* be fetched out of the result.
|
||||
*
|
||||
* It is a programming error to call this when the `type` is a legacy field.
|
||||
*
|
||||
* @param field The field to add.
|
||||
*
|
||||
* @return The autoreleased field that was added.
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@
|
|||
#import "GPBMessage.h"
|
||||
#import "GPBMessage_PackagePrivate.h"
|
||||
#import "GPBUnknownField.h"
|
||||
#import "GPBUnknownFieldSet.h"
|
||||
#import "GPBUnknownFieldSet_PackagePrivate.h"
|
||||
#import "GPBUnknownField_PackagePrivate.h"
|
||||
#import "GPBWireFormat.h"
|
||||
|
||||
|
|
@ -66,11 +64,6 @@ static size_t ComputeSerializeSize(GPBUnknownFields *_Nonnull self) {
|
|||
result +=
|
||||
(GPBComputeTagSize(fieldNumber) * 2) + ComputeSerializeSize(field->storage_.group);
|
||||
break;
|
||||
case GPBUnknownFieldTypeLegacy:
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSCAssert(NO, @"Internal error within the library");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
@ -99,11 +92,6 @@ static void WriteToCoddedOutputStream(GPBUnknownFields *_Nonnull self,
|
|||
WriteToCoddedOutputStream(field->storage_.group, output);
|
||||
[output writeRawVarint32:GPBWireFormatMakeTag(fieldNumber, GPBWireFormatEndGroup)];
|
||||
break;
|
||||
case GPBUnknownFieldTypeLegacy:
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSCAssert(NO, @"Internal error within the library");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -326,10 +314,6 @@ static BOOL MergeFromInputStream(GPBUnknownFields *self, GPBCodedInputStream *in
|
|||
}
|
||||
|
||||
- (GPBUnknownField *)addCopyOfField:(nonnull GPBUnknownField *)field {
|
||||
if (field->type_ == GPBUnknownFieldTypeLegacy) {
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"GPBUnknownField is the wrong type"];
|
||||
}
|
||||
GPBUnknownField *result = [field copy];
|
||||
[fields_ addObject:result];
|
||||
return [result autorelease];
|
||||
|
|
|
|||
|
|
@ -28,21 +28,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
**/
|
||||
NSString *GPBTextFormatForMessage(GPBMessage *message, NSString *__nullable lineIndent);
|
||||
|
||||
/**
|
||||
* Generates a string that should be a valid "TextFormat" for the C++ version
|
||||
* of Protocol Buffers.
|
||||
*
|
||||
* @param unknownSet The unknown field set to generate from.
|
||||
* @param lineIndent A string to use as the prefix for all lines generated. Can
|
||||
* be nil if no extra indent is needed.
|
||||
*
|
||||
* @return An NSString with the TextFormat of the unknown field set.
|
||||
**/
|
||||
NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet *__nullable unknownSet,
|
||||
NSString *__nullable lineIndent)
|
||||
__attribute__((deprecated("Use GPBTextFormatForMessage will include the unknown fields, and "
|
||||
"GPBUnknownFieldSet it going away.")));
|
||||
|
||||
/**
|
||||
* Checks if the given field number is set on a message.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
#import "GPBMessage.h"
|
||||
#import "GPBMessage_PackagePrivate.h"
|
||||
#import "GPBUnknownField.h"
|
||||
#import "GPBUnknownFieldSet.h"
|
||||
#import "GPBUnknownField_PackagePrivate.h"
|
||||
#import "GPBUnknownFields.h"
|
||||
#import "GPBUtilities.h"
|
||||
|
|
@ -2004,13 +2003,6 @@ static void AppendTextFormatForUnknownFields(GPBUnknownFields *ufs, NSMutableStr
|
|||
[toStr appendFormat:@"%@}\n", lineIndent];
|
||||
}
|
||||
} break;
|
||||
case GPBUnknownFieldTypeLegacy:
|
||||
#if defined(DEBUG) && DEBUG
|
||||
NSCAssert(
|
||||
NO,
|
||||
@"Internal error: Shouldn't have gotten a legacy field type in the unknown fields.");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
[subIndent release];
|
||||
|
|
@ -2056,45 +2048,6 @@ NSString *GPBTextFormatForMessage(GPBMessage *message, NSString *lineIndent) {
|
|||
return buildString;
|
||||
}
|
||||
|
||||
NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet *unknownSet, NSString *lineIndent) {
|
||||
if (unknownSet == nil) return @"";
|
||||
if (lineIndent == nil) lineIndent = @"";
|
||||
|
||||
NSMutableString *result = [NSMutableString string];
|
||||
for (GPBUnknownField *field in [unknownSet sortedFields]) {
|
||||
int32_t fieldNumber = [field number];
|
||||
|
||||
#define PRINT_LOOP(PROPNAME, CTYPE, FORMAT) \
|
||||
[field.PROPNAME \
|
||||
enumerateValuesWithBlock:^(CTYPE value, __unused NSUInteger idx, __unused BOOL * stop) { \
|
||||
[result appendFormat:@"%@%d: " FORMAT "\n", lineIndent, fieldNumber, value]; \
|
||||
}];
|
||||
|
||||
PRINT_LOOP(varintList, uint64_t, "%llu");
|
||||
PRINT_LOOP(fixed32List, uint32_t, "0x%X");
|
||||
PRINT_LOOP(fixed64List, uint64_t, "0x%llX");
|
||||
|
||||
#undef PRINT_LOOP
|
||||
|
||||
// NOTE: C++ version of TextFormat tries to parse this as a message
|
||||
// and print that if it succeeds.
|
||||
for (NSData *data in field.lengthDelimitedList) {
|
||||
[result appendFormat:@"%@%d: ", lineIndent, fieldNumber];
|
||||
AppendBufferAsString(data, result);
|
||||
[result appendString:@"\n"];
|
||||
}
|
||||
|
||||
for (GPBUnknownFieldSet *subUnknownSet in field.groupList) {
|
||||
[result appendFormat:@"%@%d: {\n", lineIndent, fieldNumber];
|
||||
NSString *subIndent = [lineIndent stringByAppendingString:@" "];
|
||||
NSString *subUnknownSetStr = GPBTextFormatForUnknownFieldSet(subUnknownSet, subIndent);
|
||||
[result appendString:subUnknownSetStr];
|
||||
[result appendFormat:@"%@}\n", lineIndent];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Helpers to decode a varint. Not using GPBCodedInputStream version because
|
||||
// that needs a state object, and we don't want to create an input stream out
|
||||
// of the data.
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
7461B5490F94FB4E00A0C422 /* GPBExtensionRegistry.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B4A90F94F99000A0C422 /* GPBExtensionRegistry.m */; };
|
||||
7461B54C0F94FB4E00A0C422 /* GPBUnknownField.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B4AF0F94F99000A0C422 /* GPBUnknownField.m */; };
|
||||
7461B5530F94FB4E00A0C422 /* GPBMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B4BF0F94F99000A0C422 /* GPBMessage.m */; };
|
||||
7461B5610F94FB4E00A0C422 /* GPBUnknownFieldSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B4E20F94F99000A0C422 /* GPBUnknownFieldSet.m */; };
|
||||
7461B5630F94FB4E00A0C422 /* GPBUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B4E60F94F99000A0C422 /* GPBUtilities.m */; };
|
||||
7461B5640F94FB4E00A0C422 /* GPBWireFormat.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B4E80F94F99000A0C422 /* GPBWireFormat.m */; };
|
||||
8B210CCE159383D60032D72D /* golden_message in Resources */ = {isa = PBXBuildFile; fileRef = 8B210CCD159383D60032D72D /* golden_message */; };
|
||||
|
|
@ -29,7 +28,6 @@
|
|||
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOutputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69D0F94FDF800A0C422 /* GPBCodedOutputStreamTests.m */; };
|
||||
8BBEA4AC147C727D00C4ADB7 /* GPBMessageTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */; };
|
||||
8BBEA4B0147C727D00C4ADB7 /* GPBTestUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6AC0F94FDF800A0C422 /* GPBTestUtilities.m */; };
|
||||
8BBEA4B6147C727D00C4ADB7 /* GPBUnknownFieldSetTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6B80F94FDF900A0C422 /* GPBUnknownFieldSetTest.m */; };
|
||||
8BBEA4B7147C727D00C4ADB7 /* GPBUtilitiesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6BA0F94FDF900A0C422 /* GPBUtilitiesTests.m */; };
|
||||
8BBEA4B8147C727D00C4ADB7 /* GPBWireFormatTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6BC0F94FDF900A0C422 /* GPBWireFormatTests.m */; };
|
||||
8BBEA4BB147C729200C4ADB7 /* libProtocolBuffers.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7461B52E0F94FAF800A0C422 /* libProtocolBuffers.a */; };
|
||||
|
|
@ -73,7 +71,6 @@
|
|||
F43ADD302C2F2B91005312E5 /* GPBUnknownFields.m in Sources */ = {isa = PBXBuildFile; fileRef = F43ADD2E2C2F2B91005312E5 /* GPBUnknownFields.m */; };
|
||||
F43ADD312C2F2B91005312E5 /* GPBUnknownFields.h in Headers */ = {isa = PBXBuildFile; fileRef = F43ADD2F2C2F2B91005312E5 /* GPBUnknownFields.h */; };
|
||||
F43ADD332C2F2BAD005312E5 /* GPBUnknownFieldsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F43ADD322C2F2BAD005312E5 /* GPBUnknownFieldsTest.m */; };
|
||||
F43ADD432C2F381F005312E5 /* GPBCompileTest25.m in Sources */ = {isa = PBXBuildFile; fileRef = F43ADD422C2F381F005312E5 /* GPBCompileTest25.m */; };
|
||||
F43ADD502C333D6C005312E5 /* GPBUnknownFields+Additions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F43ADD4F2C333D6B005312E5 /* GPBUnknownFields+Additions.swift */; };
|
||||
F43ADD562C345CED005312E5 /* GPBUnknownField+Additions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F43ADD552C345CED005312E5 /* GPBUnknownField+Additions.swift */; };
|
||||
F43ADD5C2C35A6CC005312E5 /* GPBUnknownFields_PackagePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = F43ADD5B2C35A6CC005312E5 /* GPBUnknownFields_PackagePrivate.h */; };
|
||||
|
|
@ -139,8 +136,6 @@
|
|||
7461B4BE0F94F99000A0C422 /* GPBMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBMessage.h; sourceTree = "<group>"; };
|
||||
7461B4BF0F94F99000A0C422 /* GPBMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBMessage.m; sourceTree = "<group>"; };
|
||||
7461B4CD0F94F99000A0C422 /* GPBProtocolBuffers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBProtocolBuffers.h; sourceTree = "<group>"; };
|
||||
7461B4E10F94F99000A0C422 /* GPBUnknownFieldSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBUnknownFieldSet.h; sourceTree = "<group>"; };
|
||||
7461B4E20F94F99000A0C422 /* GPBUnknownFieldSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUnknownFieldSet.m; sourceTree = "<group>"; };
|
||||
7461B4E50F94F99000A0C422 /* GPBUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBUtilities.h; sourceTree = "<group>"; };
|
||||
7461B4E60F94F99000A0C422 /* GPBUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUtilities.m; sourceTree = "<group>"; };
|
||||
7461B4E70F94F99000A0C422 /* GPBWireFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBWireFormat.h; sourceTree = "<group>"; };
|
||||
|
|
@ -151,7 +146,6 @@
|
|||
7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBMessageTests.m; sourceTree = "<group>"; };
|
||||
7461B6AB0F94FDF800A0C422 /* GPBTestUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBTestUtilities.h; sourceTree = "<group>"; };
|
||||
7461B6AC0F94FDF800A0C422 /* GPBTestUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBTestUtilities.m; sourceTree = "<group>"; };
|
||||
7461B6B80F94FDF900A0C422 /* GPBUnknownFieldSetTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUnknownFieldSetTest.m; sourceTree = "<group>"; };
|
||||
7461B6BA0F94FDF900A0C422 /* GPBUtilitiesTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUtilitiesTests.m; sourceTree = "<group>"; };
|
||||
7461B6BC0F94FDF900A0C422 /* GPBWireFormatTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBWireFormatTests.m; sourceTree = "<group>"; };
|
||||
8B09AAF614B663A7007B4184 /* unittest_objc.proto */ = {isa = PBXFileReference; lastKnownFileType = text; path = unittest_objc.proto; sourceTree = "<group>"; };
|
||||
|
|
@ -216,7 +210,6 @@
|
|||
F43ADD2E2C2F2B91005312E5 /* GPBUnknownFields.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUnknownFields.m; sourceTree = "<group>"; };
|
||||
F43ADD2F2C2F2B91005312E5 /* GPBUnknownFields.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBUnknownFields.h; sourceTree = "<group>"; };
|
||||
F43ADD322C2F2BAD005312E5 /* GPBUnknownFieldsTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUnknownFieldsTest.m; sourceTree = "<group>"; };
|
||||
F43ADD422C2F381F005312E5 /* GPBCompileTest25.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest25.m; sourceTree = "<group>"; };
|
||||
F43ADD4F2C333D6B005312E5 /* GPBUnknownFields+Additions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "GPBUnknownFields+Additions.swift"; sourceTree = "<group>"; };
|
||||
F43ADD552C345CED005312E5 /* GPBUnknownField+Additions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "GPBUnknownField+Additions.swift"; sourceTree = "<group>"; };
|
||||
F43ADD5B2C35A6CC005312E5 /* GPBUnknownFields_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBUnknownFields_PackagePrivate.h; sourceTree = "<group>"; };
|
||||
|
|
@ -275,7 +268,6 @@
|
|||
F4AC9E1D1A8BEB3500BD6E83 /* unittest_cycle.proto */ = {isa = PBXFileReference; lastKnownFileType = text; path = unittest_cycle.proto; sourceTree = "<group>"; };
|
||||
F4B51B1D1BBC610700744318 /* GPBObjectiveCPlusPlusTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPBObjectiveCPlusPlusTest.mm; sourceTree = "<group>"; };
|
||||
F4B6B8AF1A9CC98000892426 /* GPBUnknownField_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBUnknownField_PackagePrivate.h; sourceTree = "<group>"; };
|
||||
F4B6B8B21A9CCBDA00892426 /* GPBUnknownFieldSet_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBUnknownFieldSet_PackagePrivate.h; sourceTree = "<group>"; };
|
||||
F4B6B8B61A9CD1DE00892426 /* GPBExtensionInternals.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBExtensionInternals.h; sourceTree = "<group>"; };
|
||||
F4B6B8B81A9CD1DE00892426 /* GPBRootObject_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBRootObject_PackagePrivate.h; sourceTree = "<group>"; };
|
||||
F4C4B9E21E1D974F00D3B61D /* GPBDictionaryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDictionaryTests.m; sourceTree = "<group>"; };
|
||||
|
|
@ -428,9 +420,6 @@
|
|||
F43ADD2F2C2F2B91005312E5 /* GPBUnknownFields.h */,
|
||||
F43ADD2E2C2F2B91005312E5 /* GPBUnknownFields.m */,
|
||||
F43ADD4F2C333D6B005312E5 /* GPBUnknownFields+Additions.swift */,
|
||||
F4B6B8B21A9CCBDA00892426 /* GPBUnknownFieldSet_PackagePrivate.h */,
|
||||
7461B4E10F94F99000A0C422 /* GPBUnknownFieldSet.h */,
|
||||
7461B4E20F94F99000A0C422 /* GPBUnknownFieldSet.m */,
|
||||
);
|
||||
name = Fields;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -497,7 +486,6 @@
|
|||
F40EE48A206BF8B00071091A /* GPBCompileTest22.m */,
|
||||
F40EE487206BF8B00071091A /* GPBCompileTest23.m */,
|
||||
F4A92AFC2B88E105001E4F69 /* GPBCompileTest24.m */,
|
||||
F43ADD422C2F381F005312E5 /* GPBCompileTest25.m */,
|
||||
5102DABB1891A052002037B6 /* GPBConcurrencyTests.m */,
|
||||
F4353D1C1AB8822D005A6198 /* GPBDescriptorTests.m */,
|
||||
F4C4B9E21E1D974F00D3B61D /* GPBDictionaryTests.m */,
|
||||
|
|
@ -521,7 +509,6 @@
|
|||
7461B6AC0F94FDF800A0C422 /* GPBTestUtilities.m */,
|
||||
8BD3981E14BE59D70081D629 /* GPBUnittestProtos.m */,
|
||||
F4F8D8811D789FCE002CE128 /* GPBUnittestProtos2.m */,
|
||||
7461B6B80F94FDF900A0C422 /* GPBUnknownFieldSetTest.m */,
|
||||
F43ADD322C2F2BAD005312E5 /* GPBUnknownFieldsTest.m */,
|
||||
7461B6BA0F94FDF900A0C422 /* GPBUtilitiesTests.m */,
|
||||
8B4248DB1A92933A00BC1EC6 /* GPBWellKnownTypesTest.m */,
|
||||
|
|
@ -743,7 +730,6 @@
|
|||
7461B5490F94FB4E00A0C422 /* GPBExtensionRegistry.m in Sources */,
|
||||
7461B54C0F94FB4E00A0C422 /* GPBUnknownField.m in Sources */,
|
||||
7461B5530F94FB4E00A0C422 /* GPBMessage.m in Sources */,
|
||||
7461B5610F94FB4E00A0C422 /* GPBUnknownFieldSet.m in Sources */,
|
||||
F47CF93423D9006000C7B24C /* GPBFieldMask.pbobjc.m in Sources */,
|
||||
7461B5630F94FB4E00A0C422 /* GPBUtilities.m in Sources */,
|
||||
7461B5640F94FB4E00A0C422 /* GPBWireFormat.m in Sources */,
|
||||
|
|
@ -798,7 +784,6 @@
|
|||
5102DABC1891A073002037B6 /* GPBConcurrencyTests.m in Sources */,
|
||||
F4487C751AADF7F500531423 /* GPBMessageTests+Runtime.m in Sources */,
|
||||
F40EE4AC206BF8B90071091A /* GPBCompileTest02.m in Sources */,
|
||||
F43ADD432C2F381F005312E5 /* GPBCompileTest25.m in Sources */,
|
||||
F4353D351AC06F10005A6198 /* GPBDictionaryTests+Int32.m in Sources */,
|
||||
F40EE4AF206BF8B90071091A /* GPBCompileTest05.m in Sources */,
|
||||
F40EE4B8206BF8B90071091A /* GPBCompileTest14.m in Sources */,
|
||||
|
|
@ -810,7 +795,6 @@
|
|||
F4353D341AC06F10005A6198 /* GPBDictionaryTests+Bool.m in Sources */,
|
||||
F4487C831AAF6AB300531423 /* GPBMessageTests+Merge.m in Sources */,
|
||||
F40EE4AB206BF8B90071091A /* GPBCompileTest01.m in Sources */,
|
||||
8BBEA4B6147C727D00C4ADB7 /* GPBUnknownFieldSetTest.m in Sources */,
|
||||
F4353D371AC06F10005A6198 /* GPBDictionaryTests+String.m in Sources */,
|
||||
F4353D381AC06F10005A6198 /* GPBDictionaryTests+UInt32.m in Sources */,
|
||||
F40EE4B3206BF8B90071091A /* GPBCompileTest09.m in Sources */,
|
||||
|
|
|
|||
|
|
@ -278,9 +278,6 @@
|
|||
<Test
|
||||
Identifier = "MessageTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "UnknownFieldSetTest">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "UtilitiesTests">
|
||||
</Test>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
7461B5490F94FB4E00A0C422 /* GPBExtensionRegistry.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B4A90F94F99000A0C422 /* GPBExtensionRegistry.m */; };
|
||||
7461B54C0F94FB4E00A0C422 /* GPBUnknownField.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B4AF0F94F99000A0C422 /* GPBUnknownField.m */; };
|
||||
7461B5530F94FB4E00A0C422 /* GPBMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B4BF0F94F99000A0C422 /* GPBMessage.m */; };
|
||||
7461B5610F94FB4E00A0C422 /* GPBUnknownFieldSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B4E20F94F99000A0C422 /* GPBUnknownFieldSet.m */; };
|
||||
7461B5630F94FB4E00A0C422 /* GPBUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B4E60F94F99000A0C422 /* GPBUtilities.m */; };
|
||||
7461B5640F94FB4E00A0C422 /* GPBWireFormat.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B4E80F94F99000A0C422 /* GPBWireFormat.m */; };
|
||||
8B210CCE159383D60032D72D /* golden_message in Resources */ = {isa = PBXBuildFile; fileRef = 8B210CCD159383D60032D72D /* golden_message */; };
|
||||
|
|
@ -30,7 +29,6 @@
|
|||
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOutputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69D0F94FDF800A0C422 /* GPBCodedOutputStreamTests.m */; };
|
||||
8BBEA4AC147C727D00C4ADB7 /* GPBMessageTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */; };
|
||||
8BBEA4B0147C727D00C4ADB7 /* GPBTestUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6AC0F94FDF800A0C422 /* GPBTestUtilities.m */; };
|
||||
8BBEA4B6147C727D00C4ADB7 /* GPBUnknownFieldSetTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6B80F94FDF900A0C422 /* GPBUnknownFieldSetTest.m */; };
|
||||
8BBEA4B7147C727D00C4ADB7 /* GPBUtilitiesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6BA0F94FDF900A0C422 /* GPBUtilitiesTests.m */; };
|
||||
8BBEA4B8147C727D00C4ADB7 /* GPBWireFormatTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6BC0F94FDF900A0C422 /* GPBWireFormatTests.m */; };
|
||||
8BBEA4BB147C729200C4ADB7 /* libProtocolBuffers.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7461B52E0F94FAF800A0C422 /* libProtocolBuffers.a */; };
|
||||
|
|
@ -72,7 +70,6 @@
|
|||
F4353D471AC06F31005A6198 /* GPBDictionaryTests+UInt64.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D401AC06F31005A6198 /* GPBDictionaryTests+UInt64.m */; };
|
||||
F43ADD352C2F2CE9005312E5 /* GPBUnknownFieldsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F43ADD342C2F2CE9005312E5 /* GPBUnknownFieldsTest.m */; };
|
||||
F43ADD412C2F2D60005312E5 /* GPBUnknownFields.m in Sources */ = {isa = PBXBuildFile; fileRef = F43ADD362C2F2D06005312E5 /* GPBUnknownFields.m */; };
|
||||
F43ADD472C2F387A005312E5 /* GPBCompileTest25.m in Sources */ = {isa = PBXBuildFile; fileRef = F43ADD462C2F387A005312E5 /* GPBCompileTest25.m */; };
|
||||
F43ADD522C333E58005312E5 /* GPBUnknownFields+Additions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F43ADD512C333E58005312E5 /* GPBUnknownFields+Additions.swift */; };
|
||||
F43ADD582C345D0D005312E5 /* GPBUnknownField+Additions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F43ADD572C345D0D005312E5 /* GPBUnknownField+Additions.swift */; };
|
||||
F43ADD5E2C35A6E1005312E5 /* GPBUnknownFields_PackagePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = F43ADD5D2C35A6E1005312E5 /* GPBUnknownFields_PackagePrivate.h */; };
|
||||
|
|
@ -139,8 +136,6 @@
|
|||
7461B4BE0F94F99000A0C422 /* GPBMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBMessage.h; sourceTree = "<group>"; };
|
||||
7461B4BF0F94F99000A0C422 /* GPBMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBMessage.m; sourceTree = "<group>"; };
|
||||
7461B4CD0F94F99000A0C422 /* GPBProtocolBuffers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBProtocolBuffers.h; sourceTree = "<group>"; };
|
||||
7461B4E10F94F99000A0C422 /* GPBUnknownFieldSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBUnknownFieldSet.h; sourceTree = "<group>"; };
|
||||
7461B4E20F94F99000A0C422 /* GPBUnknownFieldSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUnknownFieldSet.m; sourceTree = "<group>"; };
|
||||
7461B4E50F94F99000A0C422 /* GPBUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBUtilities.h; sourceTree = "<group>"; };
|
||||
7461B4E60F94F99000A0C422 /* GPBUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUtilities.m; sourceTree = "<group>"; };
|
||||
7461B4E70F94F99000A0C422 /* GPBWireFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBWireFormat.h; sourceTree = "<group>"; };
|
||||
|
|
@ -151,7 +146,6 @@
|
|||
7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBMessageTests.m; sourceTree = "<group>"; };
|
||||
7461B6AB0F94FDF800A0C422 /* GPBTestUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBTestUtilities.h; sourceTree = "<group>"; };
|
||||
7461B6AC0F94FDF800A0C422 /* GPBTestUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBTestUtilities.m; sourceTree = "<group>"; };
|
||||
7461B6B80F94FDF900A0C422 /* GPBUnknownFieldSetTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUnknownFieldSetTest.m; sourceTree = "<group>"; };
|
||||
7461B6BA0F94FDF900A0C422 /* GPBUtilitiesTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUtilitiesTests.m; sourceTree = "<group>"; };
|
||||
7461B6BC0F94FDF900A0C422 /* GPBWireFormatTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBWireFormatTests.m; sourceTree = "<group>"; };
|
||||
8B09AAF614B663A7007B4184 /* unittest_objc.proto */ = {isa = PBXFileReference; lastKnownFileType = text; path = unittest_objc.proto; sourceTree = "<group>"; };
|
||||
|
|
@ -216,7 +210,6 @@
|
|||
F43ADD342C2F2CE9005312E5 /* GPBUnknownFieldsTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUnknownFieldsTest.m; sourceTree = "<group>"; };
|
||||
F43ADD362C2F2D06005312E5 /* GPBUnknownFields.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUnknownFields.m; sourceTree = "<group>"; };
|
||||
F43ADD372C2F2D06005312E5 /* GPBUnknownFields.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBUnknownFields.h; sourceTree = "<group>"; };
|
||||
F43ADD462C2F387A005312E5 /* GPBCompileTest25.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest25.m; sourceTree = "<group>"; };
|
||||
F43ADD512C333E58005312E5 /* GPBUnknownFields+Additions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "GPBUnknownFields+Additions.swift"; sourceTree = "<group>"; };
|
||||
F43ADD572C345D0D005312E5 /* GPBUnknownField+Additions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "GPBUnknownField+Additions.swift"; sourceTree = "<group>"; };
|
||||
F43ADD5D2C35A6E1005312E5 /* GPBUnknownFields_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBUnknownFields_PackagePrivate.h; sourceTree = "<group>"; };
|
||||
|
|
@ -277,7 +270,6 @@
|
|||
F4AC9E1C1A8BEB1000BD6E83 /* unittest_cycle.proto */ = {isa = PBXFileReference; lastKnownFileType = text; path = unittest_cycle.proto; sourceTree = "<group>"; };
|
||||
F4B51B1B1BBC5C7100744318 /* GPBObjectiveCPlusPlusTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPBObjectiveCPlusPlusTest.mm; sourceTree = "<group>"; };
|
||||
F4B6B8B01A9CC99500892426 /* GPBUnknownField_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBUnknownField_PackagePrivate.h; sourceTree = "<group>"; };
|
||||
F4B6B8B11A9CCBBB00892426 /* GPBUnknownFieldSet_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBUnknownFieldSet_PackagePrivate.h; sourceTree = "<group>"; };
|
||||
F4B6B8B31A9CD1C600892426 /* GPBExtensionInternals.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBExtensionInternals.h; sourceTree = "<group>"; };
|
||||
F4B6B8B51A9CD1C600892426 /* GPBRootObject_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBRootObject_PackagePrivate.h; sourceTree = "<group>"; };
|
||||
F4C4B9E51E1D97BB00D3B61D /* GPBDictionaryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDictionaryTests.m; sourceTree = "<group>"; };
|
||||
|
|
@ -433,9 +425,6 @@
|
|||
F43ADD372C2F2D06005312E5 /* GPBUnknownFields.h */,
|
||||
F43ADD362C2F2D06005312E5 /* GPBUnknownFields.m */,
|
||||
F43ADD512C333E58005312E5 /* GPBUnknownFields+Additions.swift */,
|
||||
F4B6B8B11A9CCBBB00892426 /* GPBUnknownFieldSet_PackagePrivate.h */,
|
||||
7461B4E10F94F99000A0C422 /* GPBUnknownFieldSet.h */,
|
||||
7461B4E20F94F99000A0C422 /* GPBUnknownFieldSet.m */,
|
||||
);
|
||||
name = Fields;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -502,7 +491,6 @@
|
|||
F40EE4CF206BF9170071091A /* GPBCompileTest22.m */,
|
||||
F40EE4CC206BF9170071091A /* GPBCompileTest23.m */,
|
||||
F4A92AFE2B88E662001E4F69 /* GPBCompileTest24.m */,
|
||||
F43ADD462C2F387A005312E5 /* GPBCompileTest25.m */,
|
||||
5102DABB1891A052002037B6 /* GPBConcurrencyTests.m */,
|
||||
F4353D1E1AB88243005A6198 /* GPBDescriptorTests.m */,
|
||||
F4C4B9E51E1D97BB00D3B61D /* GPBDictionaryTests.m */,
|
||||
|
|
@ -526,7 +514,6 @@
|
|||
7461B6AC0F94FDF800A0C422 /* GPBTestUtilities.m */,
|
||||
8BD3981E14BE59D70081D629 /* GPBUnittestProtos.m */,
|
||||
F4F8D8841D78A186002CE128 /* GPBUnittestProtos2.m */,
|
||||
7461B6B80F94FDF900A0C422 /* GPBUnknownFieldSetTest.m */,
|
||||
F43ADD342C2F2CE9005312E5 /* GPBUnknownFieldsTest.m */,
|
||||
7461B6BA0F94FDF900A0C422 /* GPBUtilitiesTests.m */,
|
||||
8B4248E51A929C9900BC1EC6 /* GPBWellKnownTypesTest.m */,
|
||||
|
|
@ -749,7 +736,6 @@
|
|||
F47CF95F23D903C600C7B24C /* GPBDuration.pbobjc.m in Sources */,
|
||||
7461B54C0F94FB4E00A0C422 /* GPBUnknownField.m in Sources */,
|
||||
7461B5530F94FB4E00A0C422 /* GPBMessage.m in Sources */,
|
||||
7461B5610F94FB4E00A0C422 /* GPBUnknownFieldSet.m in Sources */,
|
||||
7461B5630F94FB4E00A0C422 /* GPBUtilities.m in Sources */,
|
||||
7461B5640F94FB4E00A0C422 /* GPBWireFormat.m in Sources */,
|
||||
F47CF96023D903C600C7B24C /* GPBWrappers.pbobjc.m in Sources */,
|
||||
|
|
@ -803,7 +789,6 @@
|
|||
5102DABC1891A073002037B6 /* GPBConcurrencyTests.m in Sources */,
|
||||
F4487C771AADF84900531423 /* GPBMessageTests+Runtime.m in Sources */,
|
||||
F40EE4F1206BF91E0071091A /* GPBCompileTest02.m in Sources */,
|
||||
F43ADD472C2F387A005312E5 /* GPBCompileTest25.m in Sources */,
|
||||
F4353D431AC06F31005A6198 /* GPBDictionaryTests+Int32.m in Sources */,
|
||||
F40EE4F4206BF91E0071091A /* GPBCompileTest05.m in Sources */,
|
||||
F40EE4FD206BF91E0071091A /* GPBCompileTest14.m in Sources */,
|
||||
|
|
@ -815,7 +800,6 @@
|
|||
F4353D421AC06F31005A6198 /* GPBDictionaryTests+Bool.m in Sources */,
|
||||
F4487C851AAF6AC500531423 /* GPBMessageTests+Merge.m in Sources */,
|
||||
F40EE4F0206BF91E0071091A /* GPBCompileTest01.m in Sources */,
|
||||
8BBEA4B6147C727D00C4ADB7 /* GPBUnknownFieldSetTest.m in Sources */,
|
||||
F4353D451AC06F31005A6198 /* GPBDictionaryTests+String.m in Sources */,
|
||||
F4353D461AC06F31005A6198 /* GPBDictionaryTests+UInt32.m in Sources */,
|
||||
F40EE4F8206BF91E0071091A /* GPBCompileTest09.m in Sources */,
|
||||
|
|
|
|||
|
|
@ -278,9 +278,6 @@
|
|||
<Test
|
||||
Identifier = "MessageTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "UnknownFieldSetTest">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "UtilitiesTests">
|
||||
</Test>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
7461B5490F94FB4E00A0C422 /* GPBExtensionRegistry.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B4A90F94F99000A0C422 /* GPBExtensionRegistry.m */; };
|
||||
7461B54C0F94FB4E00A0C422 /* GPBUnknownField.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B4AF0F94F99000A0C422 /* GPBUnknownField.m */; };
|
||||
7461B5530F94FB4E00A0C422 /* GPBMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B4BF0F94F99000A0C422 /* GPBMessage.m */; };
|
||||
7461B5610F94FB4E00A0C422 /* GPBUnknownFieldSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B4E20F94F99000A0C422 /* GPBUnknownFieldSet.m */; };
|
||||
7461B5630F94FB4E00A0C422 /* GPBUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B4E60F94F99000A0C422 /* GPBUtilities.m */; };
|
||||
7461B5640F94FB4E00A0C422 /* GPBWireFormat.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B4E80F94F99000A0C422 /* GPBWireFormat.m */; };
|
||||
8B210CCE159383D60032D72D /* golden_message in Resources */ = {isa = PBXBuildFile; fileRef = 8B210CCD159383D60032D72D /* golden_message */; };
|
||||
|
|
@ -30,7 +29,6 @@
|
|||
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOutputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69D0F94FDF800A0C422 /* GPBCodedOutputStreamTests.m */; };
|
||||
8BBEA4AC147C727D00C4ADB7 /* GPBMessageTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */; };
|
||||
8BBEA4B0147C727D00C4ADB7 /* GPBTestUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6AC0F94FDF800A0C422 /* GPBTestUtilities.m */; };
|
||||
8BBEA4B6147C727D00C4ADB7 /* GPBUnknownFieldSetTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6B80F94FDF900A0C422 /* GPBUnknownFieldSetTest.m */; };
|
||||
8BBEA4B7147C727D00C4ADB7 /* GPBUtilitiesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6BA0F94FDF900A0C422 /* GPBUtilitiesTests.m */; };
|
||||
8BBEA4B8147C727D00C4ADB7 /* GPBWireFormatTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6BC0F94FDF900A0C422 /* GPBWireFormatTests.m */; };
|
||||
8BBEA4BB147C729200C4ADB7 /* libProtocolBuffers.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7461B52E0F94FAF800A0C422 /* libProtocolBuffers.a */; };
|
||||
|
|
@ -73,7 +71,6 @@
|
|||
F43ADD3A2C2F2D26005312E5 /* GPBUnknownFieldsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F43ADD392C2F2D26005312E5 /* GPBUnknownFieldsTest.m */; };
|
||||
F43ADD3D2C2F2D3D005312E5 /* GPBUnknownFields.m in Sources */ = {isa = PBXBuildFile; fileRef = F43ADD3B2C2F2D3D005312E5 /* GPBUnknownFields.m */; };
|
||||
F43ADD3E2C2F2D3D005312E5 /* GPBUnknownFields.h in Headers */ = {isa = PBXBuildFile; fileRef = F43ADD3C2C2F2D3D005312E5 /* GPBUnknownFields.h */; };
|
||||
F43ADD492C2F389D005312E5 /* GPBCompileTest25.m in Sources */ = {isa = PBXBuildFile; fileRef = F43ADD482C2F389D005312E5 /* GPBCompileTest25.m */; };
|
||||
F43ADD542C333EE5005312E5 /* GPBUnknownFields+Additions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F43ADD532C333EE5005312E5 /* GPBUnknownFields+Additions.swift */; };
|
||||
F43ADD5A2C345D36005312E5 /* GPBUnknownField+Additions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F43ADD592C345D36005312E5 /* GPBUnknownField+Additions.swift */; };
|
||||
F43ADD602C35A6F4005312E5 /* GPBUnknownFields_PackagePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = F43ADD5F2C35A6F4005312E5 /* GPBUnknownFields_PackagePrivate.h */; };
|
||||
|
|
@ -140,8 +137,6 @@
|
|||
7461B4BE0F94F99000A0C422 /* GPBMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBMessage.h; sourceTree = "<group>"; };
|
||||
7461B4BF0F94F99000A0C422 /* GPBMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBMessage.m; sourceTree = "<group>"; };
|
||||
7461B4CD0F94F99000A0C422 /* GPBProtocolBuffers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBProtocolBuffers.h; sourceTree = "<group>"; };
|
||||
7461B4E10F94F99000A0C422 /* GPBUnknownFieldSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBUnknownFieldSet.h; sourceTree = "<group>"; };
|
||||
7461B4E20F94F99000A0C422 /* GPBUnknownFieldSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUnknownFieldSet.m; sourceTree = "<group>"; };
|
||||
7461B4E50F94F99000A0C422 /* GPBUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBUtilities.h; sourceTree = "<group>"; };
|
||||
7461B4E60F94F99000A0C422 /* GPBUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUtilities.m; sourceTree = "<group>"; };
|
||||
7461B4E70F94F99000A0C422 /* GPBWireFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBWireFormat.h; sourceTree = "<group>"; };
|
||||
|
|
@ -152,7 +147,6 @@
|
|||
7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBMessageTests.m; sourceTree = "<group>"; };
|
||||
7461B6AB0F94FDF800A0C422 /* GPBTestUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBTestUtilities.h; sourceTree = "<group>"; };
|
||||
7461B6AC0F94FDF800A0C422 /* GPBTestUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBTestUtilities.m; sourceTree = "<group>"; };
|
||||
7461B6B80F94FDF900A0C422 /* GPBUnknownFieldSetTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUnknownFieldSetTest.m; sourceTree = "<group>"; };
|
||||
7461B6BA0F94FDF900A0C422 /* GPBUtilitiesTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUtilitiesTests.m; sourceTree = "<group>"; };
|
||||
7461B6BC0F94FDF900A0C422 /* GPBWireFormatTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBWireFormatTests.m; sourceTree = "<group>"; };
|
||||
8B09AAF614B663A7007B4184 /* unittest_objc.proto */ = {isa = PBXFileReference; lastKnownFileType = text; path = unittest_objc.proto; sourceTree = "<group>"; };
|
||||
|
|
@ -217,7 +211,6 @@
|
|||
F43ADD392C2F2D26005312E5 /* GPBUnknownFieldsTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUnknownFieldsTest.m; sourceTree = "<group>"; };
|
||||
F43ADD3B2C2F2D3D005312E5 /* GPBUnknownFields.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUnknownFields.m; sourceTree = "<group>"; };
|
||||
F43ADD3C2C2F2D3D005312E5 /* GPBUnknownFields.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBUnknownFields.h; sourceTree = "<group>"; };
|
||||
F43ADD482C2F389D005312E5 /* GPBCompileTest25.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest25.m; sourceTree = "<group>"; };
|
||||
F43ADD532C333EE5005312E5 /* GPBUnknownFields+Additions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "GPBUnknownFields+Additions.swift"; sourceTree = "<group>"; };
|
||||
F43ADD592C345D36005312E5 /* GPBUnknownField+Additions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "GPBUnknownField+Additions.swift"; sourceTree = "<group>"; };
|
||||
F43ADD5F2C35A6F4005312E5 /* GPBUnknownFields_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBUnknownFields_PackagePrivate.h; sourceTree = "<group>"; };
|
||||
|
|
@ -278,7 +271,6 @@
|
|||
F4AC9E1C1A8BEB1000BD6E83 /* unittest_cycle.proto */ = {isa = PBXFileReference; lastKnownFileType = text; path = unittest_cycle.proto; sourceTree = "<group>"; };
|
||||
F4B51B1B1BBC5C7100744318 /* GPBObjectiveCPlusPlusTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPBObjectiveCPlusPlusTest.mm; sourceTree = "<group>"; };
|
||||
F4B6B8B01A9CC99500892426 /* GPBUnknownField_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBUnknownField_PackagePrivate.h; sourceTree = "<group>"; };
|
||||
F4B6B8B11A9CCBBB00892426 /* GPBUnknownFieldSet_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBUnknownFieldSet_PackagePrivate.h; sourceTree = "<group>"; };
|
||||
F4B6B8B31A9CD1C600892426 /* GPBExtensionInternals.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBExtensionInternals.h; sourceTree = "<group>"; };
|
||||
F4B6B8B51A9CD1C600892426 /* GPBRootObject_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBRootObject_PackagePrivate.h; sourceTree = "<group>"; };
|
||||
F4C4B9E51E1D97BB00D3B61D /* GPBDictionaryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDictionaryTests.m; sourceTree = "<group>"; };
|
||||
|
|
@ -434,9 +426,6 @@
|
|||
F43ADD3C2C2F2D3D005312E5 /* GPBUnknownFields.h */,
|
||||
F43ADD3B2C2F2D3D005312E5 /* GPBUnknownFields.m */,
|
||||
F43ADD532C333EE5005312E5 /* GPBUnknownFields+Additions.swift */,
|
||||
F4B6B8B11A9CCBBB00892426 /* GPBUnknownFieldSet_PackagePrivate.h */,
|
||||
7461B4E10F94F99000A0C422 /* GPBUnknownFieldSet.h */,
|
||||
7461B4E20F94F99000A0C422 /* GPBUnknownFieldSet.m */,
|
||||
);
|
||||
name = Fields;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -503,7 +492,6 @@
|
|||
F40EE4CF206BF9170071091A /* GPBCompileTest22.m */,
|
||||
F40EE4CC206BF9170071091A /* GPBCompileTest23.m */,
|
||||
F4A92B002B88E683001E4F69 /* GPBCompileTest24.m */,
|
||||
F43ADD482C2F389D005312E5 /* GPBCompileTest25.m */,
|
||||
5102DABB1891A052002037B6 /* GPBConcurrencyTests.m */,
|
||||
F4353D1E1AB88243005A6198 /* GPBDescriptorTests.m */,
|
||||
F4C4B9E51E1D97BB00D3B61D /* GPBDictionaryTests.m */,
|
||||
|
|
@ -527,7 +515,6 @@
|
|||
7461B6AC0F94FDF800A0C422 /* GPBTestUtilities.m */,
|
||||
8BD3981E14BE59D70081D629 /* GPBUnittestProtos.m */,
|
||||
F4F8D8841D78A186002CE128 /* GPBUnittestProtos2.m */,
|
||||
7461B6B80F94FDF900A0C422 /* GPBUnknownFieldSetTest.m */,
|
||||
F43ADD392C2F2D26005312E5 /* GPBUnknownFieldsTest.m */,
|
||||
7461B6BA0F94FDF900A0C422 /* GPBUtilitiesTests.m */,
|
||||
8B4248E51A929C9900BC1EC6 /* GPBWellKnownTypesTest.m */,
|
||||
|
|
@ -752,7 +739,6 @@
|
|||
7461B5530F94FB4E00A0C422 /* GPBMessage.m in Sources */,
|
||||
F47CF99323D904E600C7B24C /* GPBWrappers.pbobjc.m in Sources */,
|
||||
F47CF98F23D904E600C7B24C /* GPBTimestamp.pbobjc.m in Sources */,
|
||||
7461B5610F94FB4E00A0C422 /* GPBUnknownFieldSet.m in Sources */,
|
||||
7461B5630F94FB4E00A0C422 /* GPBUtilities.m in Sources */,
|
||||
7461B5640F94FB4E00A0C422 /* GPBWireFormat.m in Sources */,
|
||||
F4353D271ABB156F005A6198 /* GPBDictionary.m in Sources */,
|
||||
|
|
@ -805,7 +791,6 @@
|
|||
5102DABC1891A073002037B6 /* GPBConcurrencyTests.m in Sources */,
|
||||
F4487C771AADF84900531423 /* GPBMessageTests+Runtime.m in Sources */,
|
||||
F40EE4F1206BF91E0071091A /* GPBCompileTest02.m in Sources */,
|
||||
F43ADD492C2F389D005312E5 /* GPBCompileTest25.m in Sources */,
|
||||
F4353D431AC06F31005A6198 /* GPBDictionaryTests+Int32.m in Sources */,
|
||||
F40EE4F4206BF91E0071091A /* GPBCompileTest05.m in Sources */,
|
||||
F40EE4FD206BF91E0071091A /* GPBCompileTest14.m in Sources */,
|
||||
|
|
@ -817,7 +802,6 @@
|
|||
F4353D421AC06F31005A6198 /* GPBDictionaryTests+Bool.m in Sources */,
|
||||
F4487C851AAF6AC500531423 /* GPBMessageTests+Merge.m in Sources */,
|
||||
F40EE4F0206BF91E0071091A /* GPBCompileTest01.m in Sources */,
|
||||
8BBEA4B6147C727D00C4ADB7 /* GPBUnknownFieldSetTest.m in Sources */,
|
||||
F4353D451AC06F31005A6198 /* GPBDictionaryTests+String.m in Sources */,
|
||||
F4353D461AC06F31005A6198 /* GPBDictionaryTests+UInt32.m in Sources */,
|
||||
F40EE4F8206BF91E0071091A /* GPBCompileTest09.m in Sources */,
|
||||
|
|
|
|||
|
|
@ -304,9 +304,6 @@
|
|||
<Test
|
||||
Identifier = "PerfTests/testHas">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "UnknownFieldSetTest">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "UtilitiesTests">
|
||||
</Test>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
#import "GPBCodedOutputStream.h"
|
||||
#import "GPBTestUtilities.h"
|
||||
#import "GPBUnknownField.h"
|
||||
#import "GPBUnknownFieldSet_PackagePrivate.h"
|
||||
#import "GPBUnknownFields.h"
|
||||
#import "GPBUtilities.h"
|
||||
#import "GPBUtilities_PackagePrivate.h"
|
||||
|
|
@ -293,10 +292,6 @@
|
|||
case GPBUnknownFieldTypeGroup:
|
||||
wireFormat = GPBWireFormatStartGroup;
|
||||
break;
|
||||
case GPBUnknownFieldTypeLegacy:
|
||||
XCTFail(@"Legacy field type not expected");
|
||||
wireFormat = GPBWireFormatVarint;
|
||||
break;
|
||||
}
|
||||
uint32_t tag = GPBWireFormatMakeTag(field.number, wireFormat);
|
||||
[fieldNumbers addObject:@(tag)];
|
||||
|
|
@ -304,23 +299,16 @@
|
|||
|
||||
// Check the tags compared to what's in the UnknownFields to confirm the stream is
|
||||
// skipping as expected (this covers the tags within a group also).
|
||||
GPBCodedInputStream* input1 = [GPBCodedInputStream streamWithData:rawBytes];
|
||||
GPBCodedInputStream* input2 = [GPBCodedInputStream streamWithData:rawBytes];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
GPBUnknownFieldSet* unknownFields = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
NSUInteger idx = 0;
|
||||
while (YES) {
|
||||
int32_t tag = [input1 readTag];
|
||||
XCTAssertEqual(tag, [input2 readTag]);
|
||||
int32_t tag = [input2 readTag];
|
||||
if (tag == 0) {
|
||||
XCTAssertEqual(idx, fieldNumbers.count);
|
||||
break;
|
||||
}
|
||||
XCTAssertEqual(tag, [fieldNumbers[idx] intValue]);
|
||||
[unknownFields mergeFieldFrom:tag input:input1];
|
||||
[input2 skipField:tag];
|
||||
++idx;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBUnknownFieldSet.h"
|
||||
#import "GPBUnknownFields.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2024 Google Inc. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBUnknownFields.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_25 = 0;
|
||||
|
|
@ -428,30 +428,6 @@
|
|||
XCTAssertEqual(varint, (uint64_t)Message3_Enum_Extra3);
|
||||
[ufs release];
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
GPBUnknownFieldSet *unknownFields = msg.unknownFields;
|
||||
|
||||
XCTAssertEqual([unknownFields countOfFields], 3U);
|
||||
XCTAssertTrue([unknownFields hasField:Message2_FieldNumber_OptionalEnum]);
|
||||
XCTAssertTrue([unknownFields hasField:Message2_FieldNumber_RepeatedEnumArray]);
|
||||
XCTAssertTrue([unknownFields hasField:Message2_FieldNumber_OneofEnum]);
|
||||
|
||||
GPBUnknownField *field = [unknownFields getField:Message2_FieldNumber_OptionalEnum];
|
||||
XCTAssertEqual(field.varintList.count, 1U);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:0], (uint64_t)Message3_Enum_Extra3);
|
||||
|
||||
field = [unknownFields getField:Message2_FieldNumber_RepeatedEnumArray];
|
||||
XCTAssertEqual(field.varintList.count, 1U);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:0], (uint64_t)Message3_Enum_Extra3);
|
||||
|
||||
field = [unknownFields getField:Message2_FieldNumber_OneofEnum];
|
||||
XCTAssertEqual(field.varintList.count, 1U);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:0], (uint64_t)Message3_Enum_Extra3);
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
[msg release];
|
||||
[orig release];
|
||||
}
|
||||
|
|
@ -1415,10 +1391,6 @@
|
|||
GPBUnknownFields *ufs = [[GPBUnknownFields alloc] initFromMessage:msg1];
|
||||
XCTAssertEqual(ufs.count, 1U);
|
||||
[ufs release];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
XCTAssertEqual(msg1.unknownFields.countOfFields, 1U);
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
data = [msg1 data];
|
||||
TestEnumMapPlusExtra *msg2 = [TestEnumMapPlusExtra parseFromData:data error:NULL];
|
||||
|
|
@ -1433,10 +1405,6 @@
|
|||
ufs = [[GPBUnknownFields alloc] initFromMessage:msg2];
|
||||
XCTAssertTrue(ufs.empty);
|
||||
[ufs release];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
XCTAssertEqual(msg2.unknownFields.countOfFields, 0U);
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
XCTAssertEqualObjects(orig, msg2);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
#import "GPBMessage_PackagePrivate.h"
|
||||
#import "GPBTestUtilities.h"
|
||||
#import "GPBUnknownField.h"
|
||||
#import "GPBUnknownFieldSet.h"
|
||||
#import "GPBUnknownFieldSet_PackagePrivate.h"
|
||||
#import "GPBUnknownField_PackagePrivate.h"
|
||||
#import "GPBUnknownFields.h"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
|
|
@ -496,19 +494,6 @@
|
|||
TestAllTypes *message = [TestAllTypes message];
|
||||
[self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
GPBUnknownFieldSet *unknownFields = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField *field = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
|
||||
[field addVarint:2];
|
||||
[unknownFields addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
|
||||
[field addVarint:4];
|
||||
[unknownFields addField:field];
|
||||
|
||||
[message setUnknownFields:unknownFields];
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
GPBUnknownFields *ufs = [[[GPBUnknownFields alloc] init] autorelease];
|
||||
[ufs addFieldNumber:1234 fixed32:1234];
|
||||
[ufs addFieldNumber:2345 varint:54321];
|
||||
|
|
@ -981,47 +966,6 @@
|
|||
[nestedMessage release];
|
||||
}
|
||||
|
||||
- (void)testAutocreatedUnknownFields {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
// Doing anything with (except reading) unknown fields should cause the
|
||||
// submessage to become visible.
|
||||
TestAllTypes *message = [TestAllTypes message];
|
||||
XCTAssertNotNil(message.optionalNestedMessage);
|
||||
XCTAssertFalse([message hasOptionalNestedMessage]);
|
||||
XCTAssertNil(message.optionalNestedMessage.unknownFields);
|
||||
XCTAssertFalse([message hasOptionalNestedMessage]);
|
||||
|
||||
GPBUnknownFieldSet *unknownFields = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
message.optionalNestedMessage.unknownFields = unknownFields;
|
||||
XCTAssertTrue([message hasOptionalNestedMessage]);
|
||||
|
||||
message.optionalNestedMessage = nil;
|
||||
XCTAssertFalse([message hasOptionalNestedMessage]);
|
||||
[message.optionalNestedMessage setUnknownFields:unknownFields];
|
||||
XCTAssertTrue([message hasOptionalNestedMessage]);
|
||||
|
||||
message.optionalNestedMessage = nil;
|
||||
XCTAssertFalse([message hasOptionalNestedMessage]);
|
||||
GPBUnknownFields *ufs = [[[GPBUnknownFields alloc] init] autorelease];
|
||||
[ufs addFieldNumber:1 varint:1];
|
||||
XCTAssertTrue([message.optionalNestedMessage mergeUnknownFields:ufs
|
||||
extensionRegistry:nil
|
||||
error:NULL]);
|
||||
XCTAssertTrue([message hasOptionalNestedMessage]);
|
||||
|
||||
message.optionalNestedMessage = nil;
|
||||
XCTAssertFalse([message hasOptionalNestedMessage]);
|
||||
[ufs clear]; // Also make sure merging zero length forces it to become visible.
|
||||
XCTAssertTrue([message.optionalNestedMessage mergeUnknownFields:ufs
|
||||
extensionRegistry:nil
|
||||
error:NULL]);
|
||||
XCTAssertTrue([message hasOptionalNestedMessage]);
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
- (void)testSetAutocreatedSubmessageToSelf {
|
||||
// Setting submessage to itself should cause it to become visible.
|
||||
TestAllTypes *message = [TestAllTypes message];
|
||||
|
|
@ -1529,24 +1473,6 @@
|
|||
varint:&varint]);
|
||||
XCTAssertEqual(varint, 12);
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
GPBUnknownFieldSet *unknownFields = msg.unknownFields;
|
||||
GPBUnknownField *field =
|
||||
[unknownFields getField:[UnittestRoot optionalNestedEnumExtension].fieldNumber];
|
||||
XCTAssertNotNil(field);
|
||||
XCTAssertEqual(field.varintList.count, 1);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:0], 10);
|
||||
field = [unknownFields getField:[UnittestRoot repeatedNestedEnumExtension].fieldNumber];
|
||||
XCTAssertNotNil(field);
|
||||
XCTAssertEqual(field.varintList.count, 1);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:0], 11);
|
||||
field = [unknownFields getField:[UnittestRoot repeatedForeignEnumExtension].fieldNumber];
|
||||
XCTAssertNotNil(field);
|
||||
XCTAssertEqual(field.varintList.count, 1);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:0], 12);
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// Unknown and known, the known come though an unknown go to unknown fields.
|
||||
|
||||
data = DataFromCStr(
|
||||
|
|
@ -1585,23 +1511,6 @@
|
|||
XCTAssertTrue([ufs getFirst:[UnittestRoot repeatedForeignEnumExtension].fieldNumber
|
||||
varint:&varint]);
|
||||
XCTAssertEqual(varint, 12);
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
unknownFields = msg.unknownFields;
|
||||
field = [unknownFields getField:[UnittestRoot optionalNestedEnumExtension].fieldNumber];
|
||||
XCTAssertNotNil(field);
|
||||
XCTAssertEqual(field.varintList.count, 1);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:0], 10);
|
||||
field = [unknownFields getField:[UnittestRoot repeatedNestedEnumExtension].fieldNumber];
|
||||
XCTAssertNotNil(field);
|
||||
XCTAssertEqual(field.varintList.count, 1);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:0], 11);
|
||||
field = [unknownFields getField:[UnittestRoot repeatedForeignEnumExtension].fieldNumber];
|
||||
XCTAssertNotNil(field);
|
||||
XCTAssertEqual(field.varintList.count, 1);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:0], 12);
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
- (void)testDefaultingExtensionMessages {
|
||||
|
|
@ -1902,15 +1811,9 @@
|
|||
}
|
||||
|
||||
- (void)testGenerateAndParseUnknownMessage {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
GPBUnknownFieldSet *unknowns = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
[unknowns mergeVarintField:123 value:456];
|
||||
GPBMessage *message = [GPBMessage message];
|
||||
[message setUnknownFields:unknowns];
|
||||
#pragma clang diagnostic pop
|
||||
GPBUnknownFields *ufs = [[[GPBUnknownFields alloc] init] autorelease];
|
||||
[ufs addFieldNumber:1234 varint:5678];
|
||||
GPBMessage *message = [GPBMessage message];
|
||||
XCTAssertTrue([message mergeUnknownFields:ufs extensionRegistry:nil error:NULL]);
|
||||
NSData *data = [message data];
|
||||
GPBMessage *message2 = [GPBMessage parseFromData:data extensionRegistry:nil error:NULL];
|
||||
|
|
@ -1918,28 +1821,15 @@
|
|||
}
|
||||
|
||||
- (void)testDelimitedWriteAndParseMultipleMessages {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
GPBUnknownFieldSet *unknowns1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
[unknowns1 mergeVarintField:123 value:456];
|
||||
GPBMessage *message1 = [GPBMessage message];
|
||||
[message1 setUnknownFields:unknowns1];
|
||||
#pragma clang diagnostic pop
|
||||
GPBUnknownFields *ufs1 = [[[GPBUnknownFields alloc] init] autorelease];
|
||||
[ufs1 addFieldNumber:1234 varint:5678];
|
||||
GPBMessage *message1 = [GPBMessage message];
|
||||
XCTAssertTrue([message1 mergeUnknownFields:ufs1 extensionRegistry:nil error:NULL]);
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
GPBUnknownFieldSet *unknowns2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
[unknowns2 mergeVarintField:789 value:987];
|
||||
[unknowns2 mergeVarintField:654 value:321];
|
||||
GPBMessage *message2 = [GPBMessage message];
|
||||
[message2 setUnknownFields:unknowns2];
|
||||
#pragma clang diagnostic pop
|
||||
GPBUnknownFields *ufs2 = [[[GPBUnknownFields alloc] init] autorelease];
|
||||
[ufs2 addFieldNumber:2345 fixed32:6789];
|
||||
[ufs2 addFieldNumber:3456 fixed32:7890];
|
||||
GPBMessage *message2 = [GPBMessage message];
|
||||
XCTAssertTrue([message2 mergeUnknownFields:ufs2 extensionRegistry:nil error:NULL]);
|
||||
|
||||
NSMutableData *delimitedData = [NSMutableData data];
|
||||
|
|
@ -2136,26 +2026,6 @@
|
|||
XCTAssertEqual(fields.count, 2U);
|
||||
XCTAssertEqual(fields[0].varint, (uint64_t)EnumTestMsg_MyEnum_Two);
|
||||
XCTAssertEqual(fields[1].varint, (uint64_t)EnumTestMsg_MyEnum_NegTwo);
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
GPBUnknownFieldSet *unknownFields = msg2.unknownFields;
|
||||
XCTAssertNotNil(unknownFields);
|
||||
XCTAssertEqual(unknownFields.countOfFields, 3U);
|
||||
XCTAssertTrue([unknownFields hasField:EnumTestMsg_FieldNumber_Bar]);
|
||||
XCTAssertTrue([unknownFields hasField:EnumTestMsg_FieldNumber_Baz]);
|
||||
XCTAssertTrue([unknownFields hasField:EnumTestMsg_FieldNumber_MumbleArray]);
|
||||
GPBUnknownField *field = [unknownFields getField:EnumTestMsg_FieldNumber_Bar];
|
||||
XCTAssertEqual(field.varintList.count, 1U);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:0], (uint64_t)EnumTestMsg_MyEnum_NegTwo);
|
||||
field = [unknownFields getField:EnumTestMsg_FieldNumber_Baz];
|
||||
XCTAssertEqual(field.varintList.count, 1U);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:0], (uint64_t)EnumTestMsg_MyEnum_Two);
|
||||
field = [unknownFields getField:EnumTestMsg_FieldNumber_MumbleArray];
|
||||
XCTAssertEqual(field.varintList.count, 2U);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:0], (uint64_t)EnumTestMsg_MyEnum_Two);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:1], (uint64_t)EnumTestMsg_MyEnum_NegTwo);
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
- (void)testReservedWordNaming {
|
||||
|
|
|
|||
|
|
@ -1,674 +0,0 @@
|
|||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
#import "GPBUnknownFieldSet.h"
|
||||
#import "GPBUnknownFieldSet_PackagePrivate.h"
|
||||
#import "GPBUnknownField_PackagePrivate.h"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
@interface GPBUnknownFieldSet (GPBUnknownFieldSetTest)
|
||||
- (void)getTags:(int32_t*)tags;
|
||||
@end
|
||||
|
||||
@interface UnknownFieldSetTest : GPBTestCase {
|
||||
@private
|
||||
TestAllTypes* allFields_;
|
||||
NSData* allFieldsData_;
|
||||
|
||||
// An empty message that has been parsed from allFieldsData. So, it has
|
||||
// unknown fields of every type.
|
||||
TestEmptyMessage* emptyMessage_;
|
||||
GPBUnknownFieldSet* unknownFields_;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UnknownFieldSetTest
|
||||
|
||||
- (void)setUp {
|
||||
allFields_ = [self allSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
allFieldsData_ = [allFields_ data];
|
||||
emptyMessage_ = [TestEmptyMessage parseFromData:allFieldsData_ error:NULL];
|
||||
unknownFields_ = emptyMessage_.unknownFields;
|
||||
}
|
||||
|
||||
- (void)testInvalidFieldNumber {
|
||||
GPBUnknownFieldSet* set = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* field = [[[GPBUnknownField alloc] initWithNumber:0] autorelease];
|
||||
XCTAssertThrowsSpecificNamed([set addField:field], NSException, NSInvalidArgumentException);
|
||||
}
|
||||
|
||||
- (void)testEqualityAndHash {
|
||||
// Empty
|
||||
|
||||
GPBUnknownFieldSet* set1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
XCTAssertTrue([set1 isEqual:set1]);
|
||||
XCTAssertFalse([set1 isEqual:@"foo"]);
|
||||
GPBUnknownFieldSet* set2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
XCTAssertEqualObjects(set1, set2);
|
||||
XCTAssertEqual([set1 hash], [set2 hash]);
|
||||
|
||||
// Varint
|
||||
|
||||
GPBUnknownField* field1 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
|
||||
[field1 addVarint:1];
|
||||
[set1 addField:field1];
|
||||
XCTAssertNotEqualObjects(set1, set2);
|
||||
GPBUnknownField* field2 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
|
||||
[field2 addVarint:1];
|
||||
[set2 addField:field2];
|
||||
XCTAssertEqualObjects(set1, set2);
|
||||
XCTAssertEqual([set1 hash], [set2 hash]);
|
||||
|
||||
// Fixed32
|
||||
|
||||
field1 = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
|
||||
[field1 addFixed32:2];
|
||||
[set1 addField:field1];
|
||||
XCTAssertNotEqualObjects(set1, set2);
|
||||
field2 = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
|
||||
[field2 addFixed32:2];
|
||||
[set2 addField:field2];
|
||||
XCTAssertEqualObjects(set1, set2);
|
||||
XCTAssertEqual([set1 hash], [set2 hash]);
|
||||
|
||||
// Fixed64
|
||||
|
||||
field1 = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
|
||||
[field1 addFixed64:3];
|
||||
[set1 addField:field1];
|
||||
XCTAssertNotEqualObjects(set1, set2);
|
||||
field2 = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
|
||||
[field2 addFixed64:3];
|
||||
[set2 addField:field2];
|
||||
XCTAssertEqualObjects(set1, set2);
|
||||
XCTAssertEqual([set1 hash], [set2 hash]);
|
||||
|
||||
// LengthDelimited
|
||||
|
||||
field1 = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
|
||||
[field1 addLengthDelimited:DataFromCStr("foo")];
|
||||
[set1 addField:field1];
|
||||
XCTAssertNotEqualObjects(set1, set2);
|
||||
field2 = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
|
||||
[field2 addLengthDelimited:DataFromCStr("foo")];
|
||||
[set2 addField:field2];
|
||||
XCTAssertEqualObjects(set1, set2);
|
||||
XCTAssertEqual([set1 hash], [set2 hash]);
|
||||
|
||||
// Group
|
||||
|
||||
GPBUnknownFieldSet* group1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* fieldGroup1 = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
|
||||
[fieldGroup1 addVarint:1];
|
||||
[group1 addField:fieldGroup1];
|
||||
GPBUnknownFieldSet* group2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* fieldGroup2 = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
|
||||
[fieldGroup2 addVarint:1];
|
||||
[group2 addField:fieldGroup2];
|
||||
|
||||
field1 = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
|
||||
[field1 addGroup:group1];
|
||||
[set1 addField:field1];
|
||||
XCTAssertNotEqualObjects(set1, set2);
|
||||
field2 = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
|
||||
[field2 addGroup:group2];
|
||||
[set2 addField:field2];
|
||||
XCTAssertEqualObjects(set1, set2);
|
||||
XCTAssertEqual([set1 hash], [set2 hash]);
|
||||
|
||||
// Exercise description for completeness.
|
||||
XCTAssertTrue(set1.description.length > 10);
|
||||
}
|
||||
|
||||
// Constructs a protocol buffer which contains fields with all the same
|
||||
// numbers as allFieldsData except that each field is some other wire
|
||||
// type.
|
||||
- (NSData*)getBizarroData {
|
||||
GPBUnknownFieldSet* bizarroFields = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
NSUInteger count = [unknownFields_ countOfFields];
|
||||
int32_t* tags = malloc(count * sizeof(int32_t));
|
||||
if (!tags) {
|
||||
XCTFail(@"Failed to make scratch buffer for testing");
|
||||
return [NSData data];
|
||||
}
|
||||
@try {
|
||||
[unknownFields_ getTags:tags];
|
||||
for (NSUInteger i = 0; i < count; ++i) {
|
||||
int32_t tag = tags[i];
|
||||
GPBUnknownField* field = [unknownFields_ getField:tag];
|
||||
if (field.varintList.count == 0) {
|
||||
// Original field is not a varint, so use a varint.
|
||||
GPBUnknownField* varintField = [[[GPBUnknownField alloc] initWithNumber:tag] autorelease];
|
||||
[varintField addVarint:1];
|
||||
[bizarroFields addField:varintField];
|
||||
} else {
|
||||
// Original field *is* a varint, so use something else.
|
||||
GPBUnknownField* fixed32Field = [[[GPBUnknownField alloc] initWithNumber:tag] autorelease];
|
||||
[fixed32Field addFixed32:1];
|
||||
[bizarroFields addField:fixed32Field];
|
||||
}
|
||||
}
|
||||
} @finally {
|
||||
free(tags);
|
||||
}
|
||||
|
||||
return [bizarroFields data];
|
||||
}
|
||||
|
||||
- (void)testSerialize {
|
||||
// Check that serializing the UnknownFieldSet produces the original data
|
||||
// again.
|
||||
NSData* data = [emptyMessage_ data];
|
||||
XCTAssertEqualObjects(allFieldsData_, data);
|
||||
}
|
||||
|
||||
- (void)testCopyFrom {
|
||||
TestEmptyMessage* message = [TestEmptyMessage message];
|
||||
[message mergeFrom:emptyMessage_];
|
||||
|
||||
XCTAssertEqualObjects(emptyMessage_.data, message.data);
|
||||
}
|
||||
|
||||
- (void)testMergeFrom {
|
||||
GPBUnknownFieldSet* set1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* field = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
|
||||
[field addVarint:2];
|
||||
[set1 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
|
||||
[field addVarint:4];
|
||||
[set1 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
|
||||
[field addFixed32:6];
|
||||
[set1 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
|
||||
[field addFixed64:20];
|
||||
[set1 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
|
||||
[field addLengthDelimited:DataFromCStr("data1")];
|
||||
[set1 addField:field];
|
||||
|
||||
GPBUnknownFieldSet* group1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* fieldGroup1 = [[[GPBUnknownField alloc] initWithNumber:200] autorelease];
|
||||
[fieldGroup1 addVarint:100];
|
||||
[group1 addField:fieldGroup1];
|
||||
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:11] autorelease];
|
||||
[field addGroup:group1];
|
||||
[set1 addField:field];
|
||||
|
||||
GPBUnknownFieldSet* set2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
|
||||
[field addVarint:1];
|
||||
[set2 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
|
||||
[field addVarint:3];
|
||||
[set2 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
|
||||
[field addFixed32:7];
|
||||
[set2 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
|
||||
[field addFixed64:30];
|
||||
[set2 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
|
||||
[field addLengthDelimited:DataFromCStr("data2")];
|
||||
[set2 addField:field];
|
||||
|
||||
GPBUnknownFieldSet* group2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* fieldGroup2 = [[[GPBUnknownField alloc] initWithNumber:201] autorelease];
|
||||
[fieldGroup2 addVarint:99];
|
||||
[group2 addField:fieldGroup2];
|
||||
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:11] autorelease];
|
||||
[field addGroup:group2];
|
||||
[set2 addField:field];
|
||||
|
||||
GPBUnknownFieldSet* set3 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
|
||||
[field addVarint:1];
|
||||
[set3 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
|
||||
[field addVarint:2];
|
||||
[set3 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
|
||||
[field addVarint:4];
|
||||
[set3 addField:field];
|
||||
[field addVarint:3];
|
||||
[set3 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
|
||||
[field addFixed32:6];
|
||||
[field addFixed32:7];
|
||||
[set3 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
|
||||
[field addFixed64:20];
|
||||
[field addFixed64:30];
|
||||
[set3 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
|
||||
[field addLengthDelimited:DataFromCStr("data1")];
|
||||
[field addLengthDelimited:DataFromCStr("data2")];
|
||||
[set3 addField:field];
|
||||
|
||||
GPBUnknownFieldSet* group3a = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* fieldGroup3a1 = [[[GPBUnknownField alloc] initWithNumber:200] autorelease];
|
||||
[fieldGroup3a1 addVarint:100];
|
||||
[group3a addField:fieldGroup3a1];
|
||||
GPBUnknownFieldSet* group3b = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* fieldGroup3b2 = [[[GPBUnknownField alloc] initWithNumber:201] autorelease];
|
||||
[fieldGroup3b2 addVarint:99];
|
||||
[group3b addField:fieldGroup3b2];
|
||||
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:11] autorelease];
|
||||
[field addGroup:group1];
|
||||
[field addGroup:group3b];
|
||||
[set3 addField:field];
|
||||
|
||||
TestEmptyMessage* source1 = [TestEmptyMessage message];
|
||||
[source1 setUnknownFields:set1];
|
||||
TestEmptyMessage* source2 = [TestEmptyMessage message];
|
||||
[source2 setUnknownFields:set2];
|
||||
TestEmptyMessage* source3 = [TestEmptyMessage message];
|
||||
[source3 setUnknownFields:set3];
|
||||
|
||||
TestEmptyMessage* destination1 = [TestEmptyMessage message];
|
||||
[destination1 mergeFrom:source1];
|
||||
[destination1 mergeFrom:source2];
|
||||
|
||||
TestEmptyMessage* destination2 = [TestEmptyMessage message];
|
||||
[destination2 mergeFrom:source3];
|
||||
|
||||
XCTAssertEqualObjects(destination1.unknownFields, destination2.unknownFields);
|
||||
XCTAssertEqualObjects(destination1.unknownFields, source3.unknownFields);
|
||||
XCTAssertEqualObjects(destination2.unknownFields, source3.unknownFields);
|
||||
|
||||
XCTAssertEqualObjects(destination1.data, destination2.data);
|
||||
XCTAssertEqualObjects(destination1.data, source3.data);
|
||||
XCTAssertEqualObjects(destination2.data, source3.data);
|
||||
}
|
||||
|
||||
- (void)testClearMessage {
|
||||
TestEmptyMessage* message = [TestEmptyMessage message];
|
||||
[message mergeFrom:emptyMessage_];
|
||||
[message clear];
|
||||
XCTAssertEqual(message.serializedSize, (size_t)0);
|
||||
}
|
||||
|
||||
- (void)testParseKnownAndUnknown {
|
||||
// Test mixing known and unknown fields when parsing.
|
||||
GPBUnknownFieldSet* fields = [[unknownFields_ copy] autorelease];
|
||||
GPBUnknownField* field = [[[GPBUnknownField alloc] initWithNumber:123456] autorelease];
|
||||
[field addVarint:654321];
|
||||
[fields addField:field];
|
||||
|
||||
NSData* data = fields.data;
|
||||
TestAllTypes* destination = [TestAllTypes parseFromData:data error:NULL];
|
||||
|
||||
[self assertAllFieldsSet:destination repeatedCount:kGPBDefaultRepeatCount];
|
||||
XCTAssertEqual(destination.unknownFields.countOfFields, (NSUInteger)1);
|
||||
|
||||
GPBUnknownField* field2 = [destination.unknownFields getField:123456];
|
||||
XCTAssertEqual(field2.varintList.count, (NSUInteger)1);
|
||||
XCTAssertEqual(654321ULL, [field2.varintList valueAtIndex:0]);
|
||||
}
|
||||
|
||||
- (void)testWrongTypeTreatedAsUnknown {
|
||||
// Test that fields of the wrong wire type are treated like unknown fields
|
||||
// when parsing.
|
||||
|
||||
NSData* bizarroData = [self getBizarroData];
|
||||
TestAllTypes* allTypesMessage = [TestAllTypes parseFromData:bizarroData error:NULL];
|
||||
TestEmptyMessage* emptyMessage = [TestEmptyMessage parseFromData:bizarroData error:NULL];
|
||||
|
||||
// All fields should have been interpreted as unknown, so the debug strings
|
||||
// should be the same.
|
||||
XCTAssertEqualObjects(emptyMessage.data, allTypesMessage.data);
|
||||
}
|
||||
|
||||
- (void)testUnknownExtensions {
|
||||
// Make sure fields are properly parsed to the UnknownFieldSet even when
|
||||
// they are declared as extension numbers.
|
||||
|
||||
TestEmptyMessageWithExtensions* message =
|
||||
[TestEmptyMessageWithExtensions parseFromData:allFieldsData_ error:NULL];
|
||||
|
||||
XCTAssertEqual(unknownFields_.countOfFields, message.unknownFields.countOfFields);
|
||||
XCTAssertEqualObjects(allFieldsData_, message.data);
|
||||
|
||||
// Just confirm as known extensions, they don't go into unknown data and end up in the
|
||||
// extensions dictionary.
|
||||
TestAllExtensions* allExtensionsMessage =
|
||||
[TestAllExtensions parseFromData:allFieldsData_
|
||||
extensionRegistry:[UnittestRoot extensionRegistry]
|
||||
error:NULL];
|
||||
XCTAssertEqual(allExtensionsMessage.unknownFields.countOfFields, (NSUInteger)0);
|
||||
XCTAssertEqualObjects([allExtensionsMessage data], allFieldsData_);
|
||||
}
|
||||
|
||||
- (void)testWrongExtensionTypeTreatedAsUnknown {
|
||||
// Test that fields of the wrong wire type are treated like unknown fields
|
||||
// when parsing extensions.
|
||||
|
||||
NSData* bizarroData = [self getBizarroData];
|
||||
TestAllExtensions* allExtensionsMessage =
|
||||
[TestAllExtensions parseFromData:bizarroData
|
||||
extensionRegistry:[UnittestRoot extensionRegistry]
|
||||
error:NULL];
|
||||
TestEmptyMessage* emptyMessage = [TestEmptyMessage parseFromData:bizarroData error:NULL];
|
||||
|
||||
// All fields should have been interpreted as unknown, so the debug strings
|
||||
// should be the same.
|
||||
XCTAssertEqualObjects(emptyMessage.data, allExtensionsMessage.data);
|
||||
}
|
||||
|
||||
- (void)testLargeVarint {
|
||||
GPBUnknownFieldSet* fields = [[unknownFields_ copy] autorelease];
|
||||
GPBUnknownField* field = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
|
||||
[field addVarint:0x7FFFFFFFFFFFFFFFL];
|
||||
[fields addField:field];
|
||||
|
||||
NSData* data = [fields data];
|
||||
|
||||
GPBUnknownFieldSet* parsed = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBCodedInputStream* input = [[[GPBCodedInputStream alloc] initWithData:data] autorelease];
|
||||
[parsed mergeFromCodedInputStream:input];
|
||||
GPBUnknownField* field2 = [parsed getField:1];
|
||||
XCTAssertEqual(field2.varintList.count, (NSUInteger)1);
|
||||
XCTAssertEqual(0x7FFFFFFFFFFFFFFFULL, [field2.varintList valueAtIndex:0]);
|
||||
}
|
||||
|
||||
static NSData* DataForGroupsOfDepth(NSUInteger depth) {
|
||||
NSMutableData* data = [NSMutableData dataWithCapacity:0];
|
||||
|
||||
uint32_t byte = 35; // 35 = 0b100011 -> field 4/start group
|
||||
for (NSUInteger i = 0; i < depth; ++i) {
|
||||
[data appendBytes:&byte length:1];
|
||||
}
|
||||
|
||||
byte = 8; // 8 = 0b1000, -> field 1/varint
|
||||
[data appendBytes:&byte length:1];
|
||||
byte = 1; // 1 -> varint value of 1
|
||||
[data appendBytes:&byte length:1];
|
||||
|
||||
byte = 36; // 36 = 0b100100 -> field 4/end group
|
||||
for (NSUInteger i = 0; i < depth; ++i) {
|
||||
[data appendBytes:&byte length:1];
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
- (void)testParsingNestingGroupData {
|
||||
// 35 = 0b100011 -> field 4/start group
|
||||
// 36 = 0b100100 -> field 4/end group
|
||||
// 43 = 0b101011 -> field 5/end group
|
||||
// 44 = 0b101100 -> field 5/end group
|
||||
// 8 = 0b1000, 1 -> field 1/varint, value of 1
|
||||
// 21 = 0b10101, 0x78, 0x56, 0x34, 0x12 -> field 2/fixed32, value of 0x12345678
|
||||
// 25 = 0b11001, 0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12 -> field 3/fixed64,
|
||||
// value of 0x123456789abcdef0LL
|
||||
// 50 = 0b110010, 0x0 -> field 6/length delimited, length 0
|
||||
// 50 = 0b110010, 0x1, 42 -> field 6/length delimited, length 1, byte 42
|
||||
// 0 -> field 0 which is invalid/varint
|
||||
// 15 = 0b1111 -> field 1, wire type 7 which is invalid
|
||||
|
||||
TestEmptyMessage* m = [TestEmptyMessage parseFromData:DataFromBytes(35, 36)
|
||||
error:NULL]; // empty group
|
||||
XCTAssertEqual(m.unknownFields.countOfFields, (NSUInteger)1);
|
||||
GPBUnknownField* field = [m.unknownFields getField:4];
|
||||
XCTAssertEqual(field.groupList.count, (NSUInteger)1);
|
||||
GPBUnknownFieldSet* group = field.groupList[0];
|
||||
XCTAssertEqual(group.countOfFields, (NSUInteger)0);
|
||||
|
||||
m = [TestEmptyMessage parseFromData:DataFromBytes(35, 8, 1, 36) error:NULL]; // varint
|
||||
XCTAssertEqual(m.unknownFields.countOfFields, (NSUInteger)1);
|
||||
field = [m.unknownFields getField:4];
|
||||
XCTAssertEqual(field.groupList.count, (NSUInteger)1);
|
||||
group = field.groupList[0];
|
||||
field = [group getField:1];
|
||||
XCTAssertEqual(field.varintList.count, (NSUInteger)1);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:0], 1);
|
||||
|
||||
m = [TestEmptyMessage parseFromData:DataFromBytes(35, 21, 0x78, 0x56, 0x34, 0x12, 36)
|
||||
error:NULL]; // fixed32
|
||||
XCTAssertEqual(m.unknownFields.countOfFields, (NSUInteger)1);
|
||||
field = [m.unknownFields getField:4];
|
||||
XCTAssertEqual(field.groupList.count, (NSUInteger)1);
|
||||
group = field.groupList[0];
|
||||
field = [group getField:2];
|
||||
XCTAssertEqual(field.fixed32List.count, (NSUInteger)1);
|
||||
XCTAssertEqual([field.fixed32List valueAtIndex:0], 0x12345678);
|
||||
|
||||
m = [TestEmptyMessage
|
||||
parseFromData:DataFromBytes(35, 25, 0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12,
|
||||
36)
|
||||
error:NULL]; // fixed64
|
||||
XCTAssertEqual(m.unknownFields.countOfFields, (NSUInteger)1);
|
||||
field = [m.unknownFields getField:4];
|
||||
XCTAssertEqual(field.groupList.count, (NSUInteger)1);
|
||||
group = field.groupList[0];
|
||||
field = [group getField:3];
|
||||
XCTAssertEqual(field.fixed64List.count, (NSUInteger)1);
|
||||
XCTAssertEqual([field.fixed64List valueAtIndex:0], 0x123456789abcdef0LL);
|
||||
|
||||
m = [TestEmptyMessage parseFromData:DataFromBytes(35, 50, 0, 36)
|
||||
error:NULL]; // length delimited, length 0
|
||||
XCTAssertEqual(m.unknownFields.countOfFields, (NSUInteger)1);
|
||||
field = [m.unknownFields getField:4];
|
||||
XCTAssertEqual(field.groupList.count, (NSUInteger)1);
|
||||
group = field.groupList[0];
|
||||
field = [group getField:6];
|
||||
XCTAssertEqual(field.lengthDelimitedList.count, (NSUInteger)1);
|
||||
XCTAssertEqualObjects(field.lengthDelimitedList[0], [NSData data]);
|
||||
|
||||
m = [TestEmptyMessage parseFromData:DataFromBytes(35, 50, 1, 42, 36)
|
||||
error:NULL]; // length delimited, length 1, byte 42
|
||||
XCTAssertEqual(m.unknownFields.countOfFields, (NSUInteger)1);
|
||||
field = [m.unknownFields getField:4];
|
||||
XCTAssertEqual(field.groupList.count, (NSUInteger)1);
|
||||
group = field.groupList[0];
|
||||
field = [group getField:6];
|
||||
XCTAssertEqual(field.lengthDelimitedList.count, (NSUInteger)1);
|
||||
XCTAssertEqualObjects(field.lengthDelimitedList[0], DataFromBytes(42));
|
||||
|
||||
m = [TestEmptyMessage parseFromData:DataFromBytes(35, 43, 44, 36) error:NULL]; // Sub group
|
||||
field = [m.unknownFields getField:4];
|
||||
XCTAssertEqual(field.groupList.count, (NSUInteger)1);
|
||||
group = field.groupList[0];
|
||||
XCTAssertEqual(group.countOfFields, (NSUInteger)1);
|
||||
field = [group getField:5];
|
||||
XCTAssertEqual(field.groupList.count, (NSUInteger)1);
|
||||
group = field.groupList[0];
|
||||
XCTAssertEqual(group.countOfFields, (NSUInteger)0);
|
||||
|
||||
m = [TestEmptyMessage parseFromData:DataFromBytes(35, 8, 1, 43, 8, 2, 44, 36)
|
||||
error:NULL]; // varint and sub group with varint
|
||||
XCTAssertEqual(m.unknownFields.countOfFields, (NSUInteger)1);
|
||||
field = [m.unknownFields getField:4];
|
||||
XCTAssertEqual(field.groupList.count, (NSUInteger)1);
|
||||
group = field.groupList[0];
|
||||
XCTAssertEqual(group.countOfFields, (NSUInteger)2);
|
||||
field = [group getField:1];
|
||||
XCTAssertEqual(field.varintList.count, (NSUInteger)1);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:0], 1);
|
||||
field = [group getField:5];
|
||||
XCTAssertEqual(field.groupList.count, (NSUInteger)1);
|
||||
group = field.groupList[0];
|
||||
field = [group getField:1];
|
||||
XCTAssertEqual(field.varintList.count, (NSUInteger)1);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:0], 2);
|
||||
|
||||
XCTAssertNil([TestEmptyMessage parseFromData:DataFromBytes(35, 0, 36)
|
||||
error:NULL]); // Invalid field number
|
||||
XCTAssertNil([TestEmptyMessage parseFromData:DataFromBytes(35, 15, 36)
|
||||
error:NULL]); // Invalid wire type
|
||||
XCTAssertNil([TestEmptyMessage parseFromData:DataFromBytes(35, 21, 0x78, 0x56, 0x34)
|
||||
error:NULL]); // truncated fixed32
|
||||
XCTAssertNil([TestEmptyMessage
|
||||
parseFromData:DataFromBytes(35, 25, 0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56,
|
||||
0x34)
|
||||
error:NULL]); // truncated fixed64
|
||||
|
||||
// Missing end group
|
||||
XCTAssertNil([TestEmptyMessage parseFromData:DataFromBytes(35) error:NULL]);
|
||||
XCTAssertNil([TestEmptyMessage parseFromData:DataFromBytes(35, 8, 1) error:NULL]);
|
||||
XCTAssertNil([TestEmptyMessage parseFromData:DataFromBytes(35, 43) error:NULL]);
|
||||
XCTAssertNil([TestEmptyMessage parseFromData:DataFromBytes(35, 43, 8, 1) error:NULL]);
|
||||
|
||||
// Wrong end group
|
||||
XCTAssertNil([TestEmptyMessage parseFromData:DataFromBytes(35, 44) error:NULL]);
|
||||
XCTAssertNil([TestEmptyMessage parseFromData:DataFromBytes(35, 8, 1, 44) error:NULL]);
|
||||
XCTAssertNil([TestEmptyMessage parseFromData:DataFromBytes(35, 43, 36) error:NULL]);
|
||||
XCTAssertNil([TestEmptyMessage parseFromData:DataFromBytes(35, 43, 8, 1, 36) error:NULL]);
|
||||
XCTAssertNil([TestEmptyMessage parseFromData:DataFromBytes(35, 43, 44, 44) error:NULL]);
|
||||
XCTAssertNil([TestEmptyMessage parseFromData:DataFromBytes(35, 43, 8, 1, 44, 44) error:NULL]);
|
||||
|
||||
// This is the same limit as within GPBCodedInputStream.
|
||||
const NSUInteger kDefaultRecursionLimit = 100;
|
||||
// That depth parses.
|
||||
NSData* testData = DataForGroupsOfDepth(kDefaultRecursionLimit);
|
||||
m = [TestEmptyMessage parseFromData:testData error:NULL];
|
||||
XCTAssertEqual(m.unknownFields.countOfFields, (NSUInteger)1);
|
||||
field = [m.unknownFields getField:4];
|
||||
for (NSUInteger i = 0; i < kDefaultRecursionLimit; ++i) {
|
||||
XCTAssertEqual(field.varintList.count, (NSUInteger)0);
|
||||
XCTAssertEqual(field.fixed32List.count, (NSUInteger)0);
|
||||
XCTAssertEqual(field.fixed64List.count, (NSUInteger)0);
|
||||
XCTAssertEqual(field.lengthDelimitedList.count, (NSUInteger)0);
|
||||
XCTAssertEqual(field.groupList.count, (NSUInteger)1);
|
||||
group = field.groupList[0];
|
||||
XCTAssertEqual(group.countOfFields, (NSUInteger)1);
|
||||
field = [group getField:(i < (kDefaultRecursionLimit - 1) ? 4 : 1)];
|
||||
}
|
||||
// field is of the inner most group
|
||||
XCTAssertEqual(field.varintList.count, (NSUInteger)1);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:0], (NSUInteger)1);
|
||||
XCTAssertEqual(field.fixed32List.count, (NSUInteger)0);
|
||||
XCTAssertEqual(field.fixed64List.count, (NSUInteger)0);
|
||||
XCTAssertEqual(field.lengthDelimitedList.count, (NSUInteger)0);
|
||||
XCTAssertEqual(field.groupList.count, (NSUInteger)0);
|
||||
// One more level deep fails.
|
||||
testData = DataForGroupsOfDepth(kDefaultRecursionLimit + 1);
|
||||
XCTAssertNil([TestEmptyMessage parseFromData:testData error:NULL]);
|
||||
}
|
||||
|
||||
#pragma mark - Field tests
|
||||
// Some tests directly on fields since the dictionary in FieldSet can gate
|
||||
// testing some of these.
|
||||
|
||||
- (void)testFieldEqualityAndHash {
|
||||
GPBUnknownField* field1 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
|
||||
XCTAssertTrue([field1 isEqual:field1]);
|
||||
XCTAssertFalse([field1 isEqual:@"foo"]);
|
||||
GPBUnknownField* field2 = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
|
||||
field2 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
|
||||
// Varint
|
||||
|
||||
[field1 addVarint:10];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
[field2 addVarint:10];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
[field1 addVarint:11];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
[field2 addVarint:11];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
|
||||
// Fixed32
|
||||
|
||||
[field1 addFixed32:20];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
[field2 addFixed32:20];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
[field1 addFixed32:21];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
[field2 addFixed32:21];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
|
||||
// Fixed64
|
||||
|
||||
[field1 addFixed64:30];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
[field2 addFixed64:30];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
[field1 addFixed64:31];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
[field2 addFixed64:31];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
|
||||
// LengthDelimited
|
||||
|
||||
[field1 addLengthDelimited:DataFromCStr("foo")];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
[field2 addLengthDelimited:DataFromCStr("foo")];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
[field1 addLengthDelimited:DataFromCStr("bar")];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
[field2 addLengthDelimited:DataFromCStr("bar")];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
|
||||
// Group
|
||||
|
||||
GPBUnknownFieldSet* group = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* fieldGroup = [[[GPBUnknownField alloc] initWithNumber:100] autorelease];
|
||||
[fieldGroup addVarint:100];
|
||||
[group addField:fieldGroup];
|
||||
[field1 addGroup:group];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
group = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
fieldGroup = [[[GPBUnknownField alloc] initWithNumber:100] autorelease];
|
||||
[fieldGroup addVarint:100];
|
||||
[group addField:fieldGroup];
|
||||
[field2 addGroup:group];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
|
||||
group = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
fieldGroup = [[[GPBUnknownField alloc] initWithNumber:101] autorelease];
|
||||
[fieldGroup addVarint:101];
|
||||
[group addField:fieldGroup];
|
||||
[field1 addGroup:group];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
group = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
fieldGroup = [[[GPBUnknownField alloc] initWithNumber:101] autorelease];
|
||||
[fieldGroup addVarint:101];
|
||||
[group addField:fieldGroup];
|
||||
[field2 addGroup:group];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
|
||||
// Exercise description for completeness.
|
||||
XCTAssertTrue(field1.description.length > 10);
|
||||
}
|
||||
|
||||
- (void)testMergingFields {
|
||||
GPBUnknownField* field1 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
|
||||
[field1 addVarint:1];
|
||||
[field1 addFixed32:2];
|
||||
[field1 addFixed64:3];
|
||||
[field1 addLengthDelimited:[NSData dataWithBytes:"hello" length:5]];
|
||||
[field1 addGroup:[[unknownFields_ copy] autorelease]];
|
||||
GPBUnknownField* field2 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
|
||||
[field2 mergeFromField:field1];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
|
@ -239,20 +239,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
// Helper to make an unknown field set with something in it.
|
||||
static GPBUnknownFieldSet *UnknownFieldsSetHelper(int num) {
|
||||
GPBUnknownFieldSet *result = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
|
||||
GPBUnknownField *field = [[[GPBUnknownField alloc] initWithNumber:num] autorelease];
|
||||
[field addVarint:num];
|
||||
[result addField:field];
|
||||
|
||||
return result;
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// Helper to add an unknown field data to messages.
|
||||
static void AddUnknownFields(GPBMessage *message, int num) {
|
||||
GPBUnknownFields *ufs = [[GPBUnknownFields alloc] init];
|
||||
|
|
@ -272,11 +258,7 @@ static BOOL HasUnknownFields(GPBMessage *message) {
|
|||
- (void)testDropMessageUnknownFieldsRecursively {
|
||||
TestAllExtensions *message = [TestAllExtensions message];
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
// Give it unknownFields.
|
||||
message.unknownFields = UnknownFieldsSetHelper(777);
|
||||
AddUnknownFields(message, 1777);
|
||||
|
||||
// Given it extensions that include a message with unknown fields of its own.
|
||||
|
|
@ -287,21 +269,18 @@ static BOOL HasUnknownFields(GPBMessage *message) {
|
|||
// Group
|
||||
OptionalGroup_extension *optionalGroup = [OptionalGroup_extension message];
|
||||
optionalGroup.a = 123;
|
||||
optionalGroup.unknownFields = UnknownFieldsSetHelper(779);
|
||||
AddUnknownFields(optionalGroup, 1779);
|
||||
[message setExtension:[UnittestRoot optionalGroupExtension] value:optionalGroup];
|
||||
|
||||
// Message
|
||||
TestAllTypes_NestedMessage *nestedMessage = [TestAllTypes_NestedMessage message];
|
||||
nestedMessage.bb = 456;
|
||||
nestedMessage.unknownFields = UnknownFieldsSetHelper(778);
|
||||
AddUnknownFields(nestedMessage, 1778);
|
||||
[message setExtension:[UnittestRoot optionalNestedMessageExtension] value:nestedMessage];
|
||||
|
||||
// Repeated Group
|
||||
RepeatedGroup_extension *repeatedGroup = [[RepeatedGroup_extension alloc] init];
|
||||
repeatedGroup.a = 567;
|
||||
repeatedGroup.unknownFields = UnknownFieldsSetHelper(780);
|
||||
AddUnknownFields(repeatedGroup, 1780);
|
||||
[message addExtension:[UnittestRoot repeatedGroupExtension] value:repeatedGroup];
|
||||
[repeatedGroup release];
|
||||
|
|
@ -309,7 +288,6 @@ static BOOL HasUnknownFields(GPBMessage *message) {
|
|||
// Repeated Message
|
||||
nestedMessage = [[TestAllTypes_NestedMessage alloc] init];
|
||||
nestedMessage.bb = 678;
|
||||
nestedMessage.unknownFields = UnknownFieldsSetHelper(781);
|
||||
AddUnknownFields(nestedMessage, 1781);
|
||||
[message addExtension:[UnittestRoot repeatedNestedMessageExtension] value:nestedMessage];
|
||||
[nestedMessage release];
|
||||
|
|
@ -319,7 +297,6 @@ static BOOL HasUnknownFields(GPBMessage *message) {
|
|||
|
||||
XCTAssertNotNil(message);
|
||||
XCTAssertTrue(HasUnknownFields(message));
|
||||
XCTAssertNotNil(message.unknownFields);
|
||||
XCTAssertTrue([message hasExtension:[UnittestRoot optionalInt32Extension]]);
|
||||
|
||||
{
|
||||
|
|
@ -329,7 +306,6 @@ static BOOL HasUnknownFields(GPBMessage *message) {
|
|||
XCTAssertNotNil(optionalGroup);
|
||||
XCTAssertEqual(optionalGroup.a, 123);
|
||||
XCTAssertTrue(HasUnknownFields(optionalGroup));
|
||||
XCTAssertNotNil(optionalGroup.unknownFields);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -339,7 +315,6 @@ static BOOL HasUnknownFields(GPBMessage *message) {
|
|||
XCTAssertNotNil(nestedMessage);
|
||||
XCTAssertEqual(nestedMessage.bb, 456);
|
||||
XCTAssertTrue(HasUnknownFields(nestedMessage));
|
||||
XCTAssertNotNil(nestedMessage.unknownFields);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -350,7 +325,6 @@ static BOOL HasUnknownFields(GPBMessage *message) {
|
|||
XCTAssertNotNil(repeatedGroup);
|
||||
XCTAssertEqual(repeatedGroup.a, 567);
|
||||
XCTAssertTrue(HasUnknownFields(repeatedGroup));
|
||||
XCTAssertNotNil(repeatedGroup.unknownFields);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -362,7 +336,6 @@ static BOOL HasUnknownFields(GPBMessage *message) {
|
|||
XCTAssertNotNil(repeatedNestedMessage);
|
||||
XCTAssertEqual(repeatedNestedMessage.bb, 678);
|
||||
XCTAssertTrue(HasUnknownFields(repeatedNestedMessage));
|
||||
XCTAssertNotNil(repeatedNestedMessage.unknownFields);
|
||||
}
|
||||
|
||||
// Drop them.
|
||||
|
|
@ -372,7 +345,6 @@ static BOOL HasUnknownFields(GPBMessage *message) {
|
|||
|
||||
XCTAssertNotNil(message);
|
||||
XCTAssertFalse(HasUnknownFields(message));
|
||||
XCTAssertNil(message.unknownFields);
|
||||
XCTAssertTrue([message hasExtension:[UnittestRoot optionalInt32Extension]]);
|
||||
|
||||
{
|
||||
|
|
@ -382,7 +354,6 @@ static BOOL HasUnknownFields(GPBMessage *message) {
|
|||
XCTAssertNotNil(optionalGroup);
|
||||
XCTAssertEqual(optionalGroup.a, 123);
|
||||
XCTAssertFalse(HasUnknownFields(optionalGroup));
|
||||
XCTAssertNil(optionalGroup.unknownFields);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -392,7 +363,6 @@ static BOOL HasUnknownFields(GPBMessage *message) {
|
|||
XCTAssertNotNil(nestedMessage);
|
||||
XCTAssertEqual(nestedMessage.bb, 456);
|
||||
XCTAssertFalse(HasUnknownFields(nestedMessage));
|
||||
XCTAssertNil(nestedMessage.unknownFields);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -403,7 +373,6 @@ static BOOL HasUnknownFields(GPBMessage *message) {
|
|||
XCTAssertNotNil(repeatedGroup);
|
||||
XCTAssertEqual(repeatedGroup.a, 567);
|
||||
XCTAssertFalse(HasUnknownFields(repeatedGroup));
|
||||
XCTAssertNil(repeatedGroup.unknownFields);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -415,26 +384,18 @@ static BOOL HasUnknownFields(GPBMessage *message) {
|
|||
XCTAssertNotNil(repeatedNestedMessage);
|
||||
XCTAssertEqual(repeatedNestedMessage.bb, 678);
|
||||
XCTAssertFalse(HasUnknownFields(repeatedNestedMessage));
|
||||
XCTAssertNil(repeatedNestedMessage.unknownFields);
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
- (void)testDropMessageUnknownFieldsRecursively_Maps {
|
||||
TestMap *message = [TestMap message];
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
{
|
||||
ForeignMessage *foreignMessage = [ForeignMessage message];
|
||||
foreignMessage.unknownFields = UnknownFieldsSetHelper(100);
|
||||
AddUnknownFields(foreignMessage, 1000);
|
||||
[message.mapInt32ForeignMessage setObject:foreignMessage forKey:100];
|
||||
|
||||
foreignMessage = [ForeignMessage message];
|
||||
foreignMessage.unknownFields = UnknownFieldsSetHelper(101);
|
||||
AddUnknownFields(foreignMessage, 1001);
|
||||
[message.mapStringForeignMessage setObject:foreignMessage forKey:@"101"];
|
||||
}
|
||||
|
|
@ -447,14 +408,12 @@ static BOOL HasUnknownFields(GPBMessage *message) {
|
|||
ForeignMessage *foreignMessage = [message.mapInt32ForeignMessage objectForKey:100];
|
||||
XCTAssertNotNil(foreignMessage);
|
||||
XCTAssertTrue(HasUnknownFields(foreignMessage));
|
||||
XCTAssertNotNil(foreignMessage.unknownFields);
|
||||
}
|
||||
|
||||
{
|
||||
ForeignMessage *foreignMessage = [message.mapStringForeignMessage objectForKey:@"101"];
|
||||
XCTAssertNotNil(foreignMessage);
|
||||
XCTAssertTrue(HasUnknownFields(foreignMessage));
|
||||
XCTAssertNotNil(foreignMessage.unknownFields);
|
||||
}
|
||||
|
||||
GPBMessageDropUnknownFieldsRecursively(message);
|
||||
|
|
@ -467,17 +426,13 @@ static BOOL HasUnknownFields(GPBMessage *message) {
|
|||
ForeignMessage *foreignMessage = [message.mapInt32ForeignMessage objectForKey:100];
|
||||
XCTAssertNotNil(foreignMessage);
|
||||
XCTAssertFalse(HasUnknownFields(foreignMessage));
|
||||
XCTAssertNil(foreignMessage.unknownFields);
|
||||
}
|
||||
|
||||
{
|
||||
ForeignMessage *foreignMessage = [message.mapStringForeignMessage objectForKey:@"101"];
|
||||
XCTAssertNotNil(foreignMessage);
|
||||
XCTAssertFalse(HasUnknownFields(foreignMessage));
|
||||
XCTAssertNil(foreignMessage.unknownFields);
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -120,16 +120,6 @@ const int kUnknownTypeId2 = 1550056;
|
|||
[[message_set getExtension:[MSetMessageExtension1 messageSetExtension]] setI:123];
|
||||
[[message_set getExtension:[MSetMessageExtension2 messageSetExtension]] setStr:@"foo"];
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
GPBUnknownField* unknownField =
|
||||
[[[GPBUnknownField alloc] initWithNumber:kUnknownTypeId] autorelease];
|
||||
[unknownField addLengthDelimited:DataFromCStr("bar")];
|
||||
GPBUnknownFieldSet* unknownFieldSet = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
[unknownFieldSet addField:unknownField];
|
||||
[message_set setUnknownFields:unknownFieldSet];
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
GPBUnknownFields* ufs = [[[GPBUnknownFields alloc] init] autorelease];
|
||||
GPBUnknownFields* group = [ufs addGroupWithFieldNumber:GPBWireFormatMessageSetItem];
|
||||
[group addFieldNumber:GPBWireFormatMessageSetTypeId varint:kUnknownTypeId2];
|
||||
|
|
@ -145,18 +135,13 @@ const int kUnknownTypeId2 = 1550056;
|
|||
|
||||
GPBUnknownFields* ufs2 = [[[GPBUnknownFields alloc] initFromMessage:raw] autorelease];
|
||||
XCTAssertTrue(ufs2.empty);
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
XCTAssertEqual([raw.unknownFields countOfFields], (NSUInteger)0);
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
XCTAssertEqual(raw.itemArray.count, (NSUInteger)4);
|
||||
XCTAssertEqual(raw.itemArray.count, (NSUInteger)3);
|
||||
XCTAssertEqual((uint32_t)[raw.itemArray[0] typeId],
|
||||
[MSetMessageExtension1 messageSetExtension].fieldNumber);
|
||||
XCTAssertEqual((uint32_t)[raw.itemArray[1] typeId],
|
||||
[MSetMessageExtension2 messageSetExtension].fieldNumber);
|
||||
XCTAssertEqual([raw.itemArray[2] typeId], kUnknownTypeId);
|
||||
XCTAssertEqual([raw.itemArray[3] typeId], kUnknownTypeId2);
|
||||
XCTAssertEqual([raw.itemArray[2] typeId], kUnknownTypeId2);
|
||||
|
||||
MSetMessageExtension1* message1 =
|
||||
[MSetMessageExtension1 parseFromData:[((MSetRawMessageSet_Item*)raw.itemArray[0]) message]
|
||||
|
|
@ -168,8 +153,7 @@ const int kUnknownTypeId2 = 1550056;
|
|||
error:NULL];
|
||||
XCTAssertEqualObjects(message2.str, @"foo");
|
||||
|
||||
XCTAssertEqualObjects([raw.itemArray[2] message], DataFromCStr("bar"));
|
||||
XCTAssertEqualObjects([raw.itemArray[3] message], DataFromCStr("baz"));
|
||||
XCTAssertEqualObjects([raw.itemArray[2] message], DataFromCStr("baz"));
|
||||
}
|
||||
|
||||
- (void)testParseMessageSet {
|
||||
|
|
@ -222,15 +206,6 @@ const int kUnknownTypeId2 = 1550056;
|
|||
XCTAssertEqual(varint, kUnknownTypeId);
|
||||
XCTAssertEqualObjects([group firstLengthDelimited:GPBWireFormatMessageSetMessage],
|
||||
DataFromCStr("bar"));
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
XCTAssertEqual([messageSet.unknownFields countOfFields], (NSUInteger)1);
|
||||
GPBUnknownField* unknownField = [messageSet.unknownFields getField:kUnknownTypeId];
|
||||
XCTAssertNotNil(unknownField);
|
||||
XCTAssertEqual(unknownField.lengthDelimitedList.count, (NSUInteger)1);
|
||||
XCTAssertEqualObjects(unknownField.lengthDelimitedList[0], DataFromCStr("bar"));
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
- (void)testParseMessageSet_FirstValueSticks {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue