|
|
|
@ -14,6 +14,7 @@ |
|
|
|
|
#import "GPBCodedOutputStream_PackagePrivate.h" |
|
|
|
|
#import "GPBDescriptor.h" |
|
|
|
|
#import "GPBMessage.h" |
|
|
|
|
#import "GPBMessage_PackagePrivate.h" |
|
|
|
|
#import "GPBUnknownField.h" |
|
|
|
|
#import "GPBUnknownFieldSet_PackagePrivate.h" |
|
|
|
|
#import "GPBUnknownField_PackagePrivate.h" |
|
|
|
@ -196,22 +197,8 @@ static BOOL MergeFromInputStream(GPBUnknownFields *self, GPBCodedInputStream *in |
|
|
|
|
self = [super init]; |
|
|
|
|
if (self) { |
|
|
|
|
fields_ = [[NSMutableArray alloc] init]; |
|
|
|
|
// TODO: b/349146447 - Move off the legacy class and directly to the data once Message is |
|
|
|
|
// updated. |
|
|
|
|
GPBUnknownFieldSet *legacyUnknownFields = [message unknownFields]; |
|
|
|
|
if (legacyUnknownFields) { |
|
|
|
|
NSData *data; |
|
|
|
|
if (message.descriptor.isWireFormat) { |
|
|
|
|
NSMutableData *mutableData = |
|
|
|
|
[NSMutableData dataWithLength:legacyUnknownFields.serializedSizeAsMessageSet]; |
|
|
|
|
GPBCodedOutputStream *output = [[GPBCodedOutputStream alloc] initWithData:mutableData]; |
|
|
|
|
[legacyUnknownFields writeAsMessageSetTo:output]; |
|
|
|
|
[output flush]; |
|
|
|
|
[output release]; |
|
|
|
|
data = mutableData; |
|
|
|
|
} else { |
|
|
|
|
data = [legacyUnknownFields data]; |
|
|
|
|
} |
|
|
|
|
NSData *data = GPBMessageUnknownFieldsData(message); |
|
|
|
|
if (data) { |
|
|
|
|
GPBCodedInputStream *input = [[GPBCodedInputStream alloc] initWithData:data]; |
|
|
|
|
// Parse until the end of the data (tag will be zero). |
|
|
|
|
if (!MergeFromInputStream(self, input, 0)) { |
|
|
|
|