aboutsummaryrefslogtreecommitdiff
path: root/objectivec
diff options
context:
space:
mode:
Diffstat (limited to 'objectivec')
-rw-r--r--objectivec/GPBCodedInputStream.m11
-rw-r--r--objectivec/GPBMessage.m35
-rw-r--r--objectivec/GPBUnknownFieldSet.m1
-rw-r--r--objectivec/GPBUtilities.m24
-rw-r--r--objectivec/GPBWireFormat.h1
-rw-r--r--objectivec/GPBWireFormat.m7
-rw-r--r--objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj18
-rw-r--r--objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme3
-rw-r--r--objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj18
-rw-r--r--objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme3
-rw-r--r--objectivec/Tests/GPBMessageTests+Runtime.m40
-rw-r--r--objectivec/Tests/GPBUnknownFieldSetTest.m4
-rw-r--r--objectivec/Tests/GPBWireFormatTests.m8
-rw-r--r--objectivec/google/protobuf/Any.pbobjc.h16
-rw-r--r--objectivec/google/protobuf/FieldMask.pbobjc.h52
-rw-r--r--objectivec/google/protobuf/SourceContext.pbobjc.h2
16 files changed, 170 insertions, 73 deletions
diff --git a/objectivec/GPBCodedInputStream.m b/objectivec/GPBCodedInputStream.m
index acba7156..2b578dd5 100644
--- a/objectivec/GPBCodedInputStream.m
+++ b/objectivec/GPBCodedInputStream.m
@@ -227,7 +227,13 @@ int32_t GPBCodedInputStreamReadTag(GPBCodedInputStreamState *state) {
state->lastTag = ReadRawVarint32(state);
if (state->lastTag == 0) {
// If we actually read zero, that's not a valid tag.
- RaiseException(GPBCodedInputStreamErrorInvalidTag, @"Last tag can't be 0");
+ RaiseException(GPBCodedInputStreamErrorInvalidTag,
+ @"A zero tag on the wire is invalid.");
+ }
+ // Tags have to include a valid wireformat, check that also.
+ if (!GPBWireFormatIsValidTag(state->lastTag)) {
+ RaiseException(GPBCodedInputStreamErrorInvalidTag,
+ @"Invalid wireformat in tag.");
}
return state->lastTag;
}
@@ -352,6 +358,7 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
}
- (BOOL)skipField:(int32_t)tag {
+ NSAssert(GPBWireFormatIsValidTag(tag), @"Invalid tag");
switch (GPBWireFormatGetTagWireType(tag)) {
case GPBWireFormatVarint:
GPBCodedInputStreamReadInt32(&state_);
@@ -374,8 +381,6 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
SkipRawData(&state_, sizeof(int32_t));
return YES;
}
- RaiseException(GPBCodedInputStreamErrorInvalidTag, nil);
- return NO;
}
- (void)skipMessage {
diff --git a/objectivec/GPBMessage.m b/objectivec/GPBMessage.m
index 919fb931..b9566bdf 100644
--- a/objectivec/GPBMessage.m
+++ b/objectivec/GPBMessage.m
@@ -2279,6 +2279,9 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
while (YES) {
BOOL merged = NO;
tag = GPBCodedInputStreamReadTag(state);
+ if (tag == 0) {
+ break; // Reached end.
+ }
for (NSUInteger i = 0; i < numFields; ++i) {
if (startingIndex >= numFields) startingIndex = 0;
GPBFieldDescriptor *fieldDescriptor = fields[startingIndex];
@@ -2317,7 +2320,7 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
}
} // for(i < numFields)
- if (!merged) {
+ if (!merged && (tag != 0)) {
// Primitive, repeated types can be packed on unpacked on the wire, and
// are parsed either way. The above loop covered tag in the preferred
// for, so this need to check the alternate form.
@@ -3199,4 +3202,34 @@ static void ResolveIvarSet(GPBFieldDescriptor *field,
@end
+#pragma mark - Messages from GPBUtilities.h but defined here for access to helpers.
+
+// Only exists for public api, no core code should use this.
+id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field) {
+#if defined(DEBUG) && DEBUG
+ if (field.fieldType != GPBFieldTypeRepeated) {
+ [NSException raise:NSInvalidArgumentException
+ format:@"%@.%@ is not a repeated field.",
+ [self class], field.name];
+ }
+#endif
+ GPBDescriptor *descriptor = [[self class] descriptor];
+ GPBFileSyntax syntax = descriptor.file.syntax;
+ return GetOrCreateArrayIvarWithField(self, field, syntax);
+}
+
+// Only exists for public api, no core code should use this.
+id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field) {
+#if defined(DEBUG) && DEBUG
+ if (field.fieldType != GPBFieldTypeMap) {
+ [NSException raise:NSInvalidArgumentException
+ format:@"%@.%@ is not a map<> field.",
+ [self class], field.name];
+ }
+#endif
+ GPBDescriptor *descriptor = [[self class] descriptor];
+ GPBFileSyntax syntax = descriptor.file.syntax;
+ return GetOrCreateMapIvarWithField(self, field, syntax);
+}
+
#pragma clang diagnostic pop
diff --git a/objectivec/GPBUnknownFieldSet.m b/objectivec/GPBUnknownFieldSet.m
index af08556e..9ba1d65c 100644
--- a/objectivec/GPBUnknownFieldSet.m
+++ b/objectivec/GPBUnknownFieldSet.m
@@ -359,6 +359,7 @@ static void GPBUnknownFieldSetMergeUnknownFields(const void *key,
}
- (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)) {
diff --git a/objectivec/GPBUtilities.m b/objectivec/GPBUtilities.m
index 4280b899..05375084 100644
--- a/objectivec/GPBUtilities.m
+++ b/objectivec/GPBUtilities.m
@@ -895,17 +895,7 @@ void GPBSetMessageGroupField(GPBMessage *self,
//%PDDM-EXPAND-END (4 expansions)
-// Only exists for public api, no core code should use this.
-id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field) {
-#if defined(DEBUG) && DEBUG
- if (field.fieldType != GPBFieldTypeRepeated) {
- [NSException raise:NSInvalidArgumentException
- format:@"%@.%@ is not a repeated field.",
- [self class], field.name];
- }
-#endif
- return GPBGetObjectIvarWithField(self, field);
-}
+// GPBGetMessageRepeatedField is defined in GPBMessage.m
// Only exists for public api, no core code should use this.
void GPBSetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field, id array) {
@@ -997,17 +987,7 @@ static NSString *TypeToStr(GPBDataType dataType) {
}
#endif
-// Only exists for public api, no core code should use this.
-id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field) {
-#if defined(DEBUG) && DEBUG
- if (field.fieldType != GPBFieldTypeMap) {
- [NSException raise:NSInvalidArgumentException
- format:@"%@.%@ is not a map<> field.",
- [self class], field.name];
- }
-#endif
- return GPBGetObjectIvarWithField(self, field);
-}
+// GPBGetMessageMapField is defined in GPBMessage.m
// Only exists for public api, no core code should use this.
void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field,
diff --git a/objectivec/GPBWireFormat.h b/objectivec/GPBWireFormat.h
index 29cf2f0b..c5941a38 100644
--- a/objectivec/GPBWireFormat.h
+++ b/objectivec/GPBWireFormat.h
@@ -53,6 +53,7 @@ uint32_t GPBWireFormatMakeTag(uint32_t fieldNumber, GPBWireFormat wireType)
__attribute__((const));
GPBWireFormat GPBWireFormatGetTagWireType(uint32_t tag) __attribute__((const));
uint32_t GPBWireFormatGetTagFieldNumber(uint32_t tag) __attribute__((const));
+BOOL GPBWireFormatIsValidTag(uint32_t tag) __attribute__((const));
GPBWireFormat GPBWireFormatForType(GPBDataType dataType, BOOL isPacked)
__attribute__((const));
diff --git a/objectivec/GPBWireFormat.m b/objectivec/GPBWireFormat.m
index 193235d6..860a339f 100644
--- a/objectivec/GPBWireFormat.m
+++ b/objectivec/GPBWireFormat.m
@@ -49,6 +49,13 @@ uint32_t GPBWireFormatGetTagFieldNumber(uint32_t tag) {
return GPBLogicalRightShift32(tag, GPBWireFormatTagTypeBits);
}
+BOOL GPBWireFormatIsValidTag(uint32_t tag) {
+ uint32_t formatBits = (tag & GPBWireFormatTagTypeMask);
+ // The valid GPBWireFormat* values are 0-5, anything else is not a valid tag.
+ BOOL result = (formatBits <= 5);
+ return result;
+}
+
GPBWireFormat GPBWireFormatForType(GPBDataType type, BOOL isPacked) {
if (isPacked) {
return GPBWireFormatLengthDelimited;
diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
index 2c5886a7..41ba7676 100644
--- a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
+++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
@@ -23,7 +23,6 @@
8B4248D21A927E1500BC1EC6 /* GPBWellKnownTypes.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248D01A927E1500BC1EC6 /* GPBWellKnownTypes.m */; };
8B4248DC1A92933A00BC1EC6 /* GPBWellKnownTypesTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248DB1A92933A00BC1EC6 /* GPBWellKnownTypesTest.m */; };
8B79657B14992E3F002FFBFC /* GPBRootObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B79657914992E3E002FFBFC /* GPBRootObject.m */; };
- 8B79657D14992E3F002FFBFC /* GPBRootObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B79657914992E3E002FFBFC /* GPBRootObject.m */; };
8B8B615D17DF7056002EE618 /* GPBARCUnittestProtos.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B8B615C17DF7056002EE618 /* GPBARCUnittestProtos.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
8B96157414C8C38C00A2AC0B /* GPBDescriptor.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B96157314C8C38C00A2AC0B /* GPBDescriptor.m */; };
8BBEA4A9147C727D00C4ADB7 /* GPBCodedInputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69B0F94FDF800A0C422 /* GPBCodedInputStreamTests.m */; };
@@ -64,14 +63,6 @@
F4E675A11B21D0000054530B /* Struct.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675911B21D0000054530B /* Struct.pbobjc.m */; };
F4E675A31B21D0000054530B /* Type.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675931B21D0000054530B /* Type.pbobjc.m */; };
F4E675A51B21D0000054530B /* Wrappers.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675951B21D0000054530B /* Wrappers.pbobjc.m */; };
- F4E675AE1B21D0A70054530B /* Any.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675871B21D0000054530B /* Any.pbobjc.m */; };
- F4E675AF1B21D0A70054530B /* Api.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675891B21D0000054530B /* Api.pbobjc.m */; };
- F4E675B01B21D0A70054530B /* Empty.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E6758B1B21D0000054530B /* Empty.pbobjc.m */; };
- F4E675B11B21D0A70054530B /* FieldMask.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E6758D1B21D0000054530B /* FieldMask.pbobjc.m */; };
- F4E675B21B21D0A70054530B /* SourceContext.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E6758F1B21D0000054530B /* SourceContext.pbobjc.m */; };
- F4E675B31B21D0A70054530B /* Struct.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675911B21D0000054530B /* Struct.pbobjc.m */; };
- F4E675B41B21D0A70054530B /* Type.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675931B21D0000054530B /* Type.pbobjc.m */; };
- F4E675B51B21D0A70054530B /* Wrappers.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675951B21D0000054530B /* Wrappers.pbobjc.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -660,19 +651,13 @@
F4353D361AC06F10005A6198 /* GPBDictionaryTests+Int64.m in Sources */,
F4353D391AC06F10005A6198 /* GPBDictionaryTests+UInt64.m in Sources */,
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOuputStreamTests.m in Sources */,
- F4E675B21B21D0A70054530B /* SourceContext.pbobjc.m in Sources */,
8BBEA4AC147C727D00C4ADB7 /* GPBMessageTests.m in Sources */,
F4B51B1E1BBC610700744318 /* GPBObjectiveCPlusPlusTest.mm in Sources */,
F4487C7F1AAF62CD00531423 /* GPBMessageTests+Serialization.m in Sources */,
8B4248DC1A92933A00BC1EC6 /* GPBWellKnownTypesTest.m in Sources */,
- F4E675B01B21D0A70054530B /* Empty.pbobjc.m in Sources */,
- F4E675B41B21D0A70054530B /* Type.pbobjc.m in Sources */,
F4353D1D1AB8822D005A6198 /* GPBDescriptorTests.m in Sources */,
- F4E675B51B21D0A70054530B /* Wrappers.pbobjc.m in Sources */,
- F4E675AE1B21D0A70054530B /* Any.pbobjc.m in Sources */,
8B4248BB1A8C256A00BC1EC6 /* GPBSwiftTests.swift in Sources */,
5102DABC1891A073002037B6 /* GPBConcurrencyTests.m in Sources */,
- F4E675B31B21D0A70054530B /* Struct.pbobjc.m in Sources */,
F4487C751AADF7F500531423 /* GPBMessageTests+Runtime.m in Sources */,
F4353D351AC06F10005A6198 /* GPBDictionaryTests+Int32.m in Sources */,
8BBEA4B0147C727D00C4ADB7 /* GPBTestUtilities.m in Sources */,
@@ -684,11 +669,8 @@
F4353D381AC06F10005A6198 /* GPBDictionaryTests+UInt32.m in Sources */,
8BBEA4B7147C727D00C4ADB7 /* GPBUtilitiesTests.m in Sources */,
8BBEA4B8147C727D00C4ADB7 /* GPBWireFormatTests.m in Sources */,
- 8B79657D14992E3F002FFBFC /* GPBRootObject.m in Sources */,
8BD3981F14BE59D70081D629 /* GPBUnittestProtos.m in Sources */,
- F4E675B11B21D0A70054530B /* FieldMask.pbobjc.m in Sources */,
8B8B615D17DF7056002EE618 /* GPBARCUnittestProtos.m in Sources */,
- F4E675AF1B21D0A70054530B /* Api.pbobjc.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme b/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
index 8f510f5d..3eb4f92b 100644
--- a/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
+++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
@@ -54,7 +54,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- shouldUseLaunchSchemeArgsEnv = "YES">
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
index 9c08c8b1..7f95a754 100644
--- a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
+++ b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
@@ -23,7 +23,6 @@
8B4248E41A929C8900BC1EC6 /* GPBWellKnownTypes.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248E21A929C8900BC1EC6 /* GPBWellKnownTypes.m */; };
8B4248E61A929C9900BC1EC6 /* GPBWellKnownTypesTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248E51A929C9900BC1EC6 /* GPBWellKnownTypesTest.m */; };
8B79657B14992E3F002FFBFC /* GPBRootObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B79657914992E3E002FFBFC /* GPBRootObject.m */; };
- 8B79657D14992E3F002FFBFC /* GPBRootObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B79657914992E3E002FFBFC /* GPBRootObject.m */; };
8B8B615D17DF7056002EE618 /* GPBARCUnittestProtos.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B8B615C17DF7056002EE618 /* GPBARCUnittestProtos.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
8B96157414C8C38C00A2AC0B /* GPBDescriptor.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B96157314C8C38C00A2AC0B /* GPBDescriptor.m */; };
8B9742331A89D19F00DCE92C /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8B9742321A89D19F00DCE92C /* LaunchScreen.xib */; };
@@ -64,14 +63,6 @@
F45C69CC16DFD08D0081955B /* GPBExtensionInternals.m in Sources */ = {isa = PBXBuildFile; fileRef = F45C69CB16DFD08D0081955B /* GPBExtensionInternals.m */; };
F45E57C91AE6DC98000B7D99 /* text_format_map_unittest_data.txt in Resources */ = {isa = PBXBuildFile; fileRef = F45E57C81AE6DC98000B7D99 /* text_format_map_unittest_data.txt */; };
F4B51B1C1BBC5C7100744318 /* GPBObjectiveCPlusPlusTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4B51B1B1BBC5C7100744318 /* GPBObjectiveCPlusPlusTest.mm */; };
- F4E675C81B21D1610054530B /* Any.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675B71B21D1440054530B /* Any.pbobjc.m */; };
- F4E675C91B21D1610054530B /* Api.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675B91B21D1440054530B /* Api.pbobjc.m */; };
- F4E675CA1B21D1610054530B /* Empty.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675BC1B21D1440054530B /* Empty.pbobjc.m */; };
- F4E675CB1B21D1610054530B /* FieldMask.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675BE1B21D1440054530B /* FieldMask.pbobjc.m */; };
- F4E675CC1B21D1610054530B /* SourceContext.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675C01B21D1440054530B /* SourceContext.pbobjc.m */; };
- F4E675CD1B21D1610054530B /* Struct.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675C21B21D1440054530B /* Struct.pbobjc.m */; };
- F4E675CE1B21D1610054530B /* Type.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675C51B21D1440054530B /* Type.pbobjc.m */; };
- F4E675CF1B21D1610054530B /* Wrappers.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675C71B21D1440054530B /* Wrappers.pbobjc.m */; };
F4E675D01B21D1620054530B /* Any.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675B71B21D1440054530B /* Any.pbobjc.m */; };
F4E675D11B21D1620054530B /* Api.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675B91B21D1440054530B /* Api.pbobjc.m */; };
F4E675D21B21D1620054530B /* Empty.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675BC1B21D1440054530B /* Empty.pbobjc.m */; };
@@ -756,19 +747,13 @@
F4353D441AC06F31005A6198 /* GPBDictionaryTests+Int64.m in Sources */,
F4353D471AC06F31005A6198 /* GPBDictionaryTests+UInt64.m in Sources */,
8BBEA4AA147C727D00C4ADB7 /* GPBCodedOuputStreamTests.m in Sources */,
- F4E675CC1B21D1610054530B /* SourceContext.pbobjc.m in Sources */,
8BBEA4AC147C727D00C4ADB7 /* GPBMessageTests.m in Sources */,
F4487C811AAF62FC00531423 /* GPBMessageTests+Serialization.m in Sources */,
8B4248E61A929C9900BC1EC6 /* GPBWellKnownTypesTest.m in Sources */,
- F4E675CA1B21D1610054530B /* Empty.pbobjc.m in Sources */,
- F4E675CE1B21D1610054530B /* Type.pbobjc.m in Sources */,
F4353D1F1AB88243005A6198 /* GPBDescriptorTests.m in Sources */,
- F4E675CF1B21D1610054530B /* Wrappers.pbobjc.m in Sources */,
F4B51B1C1BBC5C7100744318 /* GPBObjectiveCPlusPlusTest.mm in Sources */,
- F4E675C81B21D1610054530B /* Any.pbobjc.m in Sources */,
8B4248B41A8BD96E00BC1EC6 /* GPBSwiftTests.swift in Sources */,
5102DABC1891A073002037B6 /* GPBConcurrencyTests.m in Sources */,
- F4E675CD1B21D1610054530B /* Struct.pbobjc.m in Sources */,
F4487C771AADF84900531423 /* GPBMessageTests+Runtime.m in Sources */,
F4353D431AC06F31005A6198 /* GPBDictionaryTests+Int32.m in Sources */,
8BBEA4B0147C727D00C4ADB7 /* GPBTestUtilities.m in Sources */,
@@ -780,11 +765,8 @@
F4353D461AC06F31005A6198 /* GPBDictionaryTests+UInt32.m in Sources */,
8BBEA4B7147C727D00C4ADB7 /* GPBUtilitiesTests.m in Sources */,
8BBEA4B8147C727D00C4ADB7 /* GPBWireFormatTests.m in Sources */,
- 8B79657D14992E3F002FFBFC /* GPBRootObject.m in Sources */,
8BD3981F14BE59D70081D629 /* GPBUnittestProtos.m in Sources */,
- F4E675CB1B21D1610054530B /* FieldMask.pbobjc.m in Sources */,
8B8B615D17DF7056002EE618 /* GPBARCUnittestProtos.m in Sources */,
- F4E675C91B21D1610054530B /* Api.pbobjc.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme b/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
index 7d219bcd..d53a75f9 100644
--- a/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
+++ b/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
@@ -54,7 +54,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- shouldUseLaunchSchemeArgsEnv = "YES">
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
diff --git a/objectivec/Tests/GPBMessageTests+Runtime.m b/objectivec/Tests/GPBMessageTests+Runtime.m
index 5e197711..1520381b 100644
--- a/objectivec/Tests/GPBMessageTests+Runtime.m
+++ b/objectivec/Tests/GPBMessageTests+Runtime.m
@@ -2066,6 +2066,46 @@
}];
}
+- (void)test_GPBGetMessageRepeatedField {
+ TestAllTypes *message = [TestAllTypes message];
+ GPBFieldDescriptor *fieldDescriptor = [[message descriptor] fieldWithName:@"repeatedStringArray"];
+ XCTAssertNotNil(fieldDescriptor);
+ NSMutableArray *fieldArray = GPBGetMessageRepeatedField(message, fieldDescriptor);
+ XCTAssertNotNil(fieldArray); // Should have autocreated.
+ XCTAssertTrue(fieldArray == message.repeatedStringArray); // Same pointer
+}
+
+- (void)test_GPBSetMessageRepeatedField {
+ TestAllTypes *message = [TestAllTypes message];
+ GPBFieldDescriptor *fieldDescriptor = [[message descriptor] fieldWithName:@"repeatedStringArray"];
+ XCTAssertNotNil(fieldDescriptor);
+
+ NSMutableArray *fieldArray = [NSMutableArray arrayWithObject:@"foo"];
+ GPBSetMessageRepeatedField(message, fieldDescriptor, fieldArray);
+ XCTAssertTrue(fieldArray == message.repeatedStringArray); // Same pointer
+ XCTAssertEqualObjects(@"foo", message.repeatedStringArray.firstObject);
+}
+
+- (void)test_GPBGetMessageMapField {
+ TestMap *message = [TestMap message];
+ GPBFieldDescriptor *fieldDescriptor = [[message descriptor] fieldWithName:@"mapStringString"];
+ XCTAssertNotNil(fieldDescriptor);
+ NSMutableDictionary *fieldMap = GPBGetMessageMapField(message, fieldDescriptor);
+ XCTAssertNotNil(fieldMap); // Should have autocreated.
+ XCTAssertTrue(fieldMap == message.mapStringString); // Same pointer
+}
+
+- (void)test_GPBSetMessageMapField {
+ TestMap *message = [TestMap message];
+ GPBFieldDescriptor *fieldDescriptor = [[message descriptor] fieldWithName:@"mapStringString"];
+ XCTAssertNotNil(fieldDescriptor);
+
+ NSMutableDictionary *fieldMap = [NSMutableDictionary dictionaryWithObject:@"bar" forKey:@"foo"];
+ GPBSetMessageMapField(message, fieldDescriptor, fieldMap);
+ XCTAssertTrue(fieldMap == message.mapStringString); // Same pointer
+ XCTAssertEqualObjects(@"bar", message.mapStringString[@"foo"]);
+}
+
#pragma mark - Subset from from map_tests.cc
// TEST(GeneratedMapFieldTest, IsInitialized)
diff --git a/objectivec/Tests/GPBUnknownFieldSetTest.m b/objectivec/Tests/GPBUnknownFieldSetTest.m
index 01217ca6..b2b5b21e 100644
--- a/objectivec/Tests/GPBUnknownFieldSetTest.m
+++ b/objectivec/Tests/GPBUnknownFieldSetTest.m
@@ -60,10 +60,6 @@
unknownFields_ = emptyMessage_.unknownFields;
}
-- (GPBUnknownField *)getField:(int32_t)number {
- return [unknownFields_ getField:number];
-}
-
// Constructs a protocol buffer which contains fields with all the same
// numbers as allFieldsData except that each field is some other wire
// type.
diff --git a/objectivec/Tests/GPBWireFormatTests.m b/objectivec/Tests/GPBWireFormatTests.m
index 2a406f11..dbeab215 100644
--- a/objectivec/Tests/GPBWireFormatTests.m
+++ b/objectivec/Tests/GPBWireFormatTests.m
@@ -46,6 +46,7 @@
TestAllTypes* message = [self allSetRepeatedCount:kGPBDefaultRepeatCount];
NSData* rawBytes = message.data;
+ [self assertFieldsInOrder:rawBytes];
XCTAssertEqual(message.serializedSize, (size_t)rawBytes.length);
TestAllTypes* message2 = [TestAllTypes parseFromData:rawBytes error:NULL];
@@ -58,6 +59,7 @@
[self packedSetRepeatedCount:kGPBDefaultRepeatCount];
NSData* rawBytes = message.data;
+ [self assertFieldsInOrder:rawBytes];
XCTAssertEqual(message.serializedSize, (size_t)rawBytes.length);
TestPackedTypes* message2 =
@@ -74,6 +76,7 @@
TestAllExtensions* message =
[self allExtensionsSetRepeatedCount:kGPBDefaultRepeatCount];
NSData* rawBytes = message.data;
+ [self assertFieldsInOrder:rawBytes];
XCTAssertEqual(message.serializedSize, (size_t)rawBytes.length);
TestAllTypes* message2 = [TestAllTypes parseFromData:rawBytes error:NULL];
@@ -87,6 +90,7 @@
TestPackedExtensions* message =
[self packedExtensionsSetRepeatedCount:kGPBDefaultRepeatCount];
NSData* rawBytes = message.data;
+ [self assertFieldsInOrder:rawBytes];
TestPackedTypes* message2 =
[self packedSetRepeatedCount:kGPBDefaultRepeatCount];
@@ -102,6 +106,7 @@
TestAllTypes* message = [self allSetRepeatedCount:kGPBDefaultRepeatCount];
NSData* rawBytes = message.data;
+ [self assertFieldsInOrder:rawBytes];
GPBExtensionRegistry* registry = [self extensionRegistry];
@@ -113,7 +118,7 @@
}
-- (void) testExtensionsSerializedSize {
+- (void)testExtensionsSerializedSize {
size_t allSet = [self allSetRepeatedCount:kGPBDefaultRepeatCount].serializedSize;
size_t extensionSet = [self allExtensionsSetRepeatedCount:kGPBDefaultRepeatCount].serializedSize;
XCTAssertEqual(allSet, extensionSet);
@@ -124,6 +129,7 @@
TestPackedExtensions* message =
[self packedExtensionsSetRepeatedCount:kGPBDefaultRepeatCount];
NSData* rawBytes = message.data;
+ [self assertFieldsInOrder:rawBytes];
GPBExtensionRegistry* registry = [self extensionRegistry];
diff --git a/objectivec/google/protobuf/Any.pbobjc.h b/objectivec/google/protobuf/Any.pbobjc.h
index e9a8533a..4253b604 100644
--- a/objectivec/google/protobuf/Any.pbobjc.h
+++ b/objectivec/google/protobuf/Any.pbobjc.h
@@ -71,6 +71,16 @@ typedef GPB_ENUM(GPBAny_FieldNumber) {
/// foo = any.unpack(Foo.class);
/// }
///
+/// Example 3: Pack and unpack a message in Python.
+///
+/// foo = Foo(...)
+/// any = Any()
+/// any.Pack(foo)
+/// ...
+/// if any.Is(Foo.DESCRIPTOR):
+/// any.Unpack(foo)
+/// ...
+///
/// The pack methods provided by protobuf library will by default use
/// 'type.googleapis.com/full.type.name' as the type URL and the unpack
/// methods only use the fully qualified type name after the last '/'
@@ -110,10 +120,10 @@ typedef GPB_ENUM(GPBAny_FieldNumber) {
/// A URL/resource name whose content describes the type of the
/// serialized protocol buffer message.
///
-/// For URLs which use the schema `http`, `https`, or no schema, the
+/// For URLs which use the scheme `http`, `https`, or no scheme, the
/// following restrictions and interpretations apply:
///
-/// * If no schema is provided, `https` is assumed.
+/// * If no scheme is provided, `https` is assumed.
/// * The last segment of the URL's path must represent the fully
/// qualified name of the type (as in `path/google.protobuf.Duration`).
/// The name should be in a canonical form (e.g., leading "." is
@@ -126,7 +136,7 @@ typedef GPB_ENUM(GPBAny_FieldNumber) {
/// on changes to types. (Use versioned type names to manage
/// breaking changes.)
///
-/// Schemas other than `http`, `https` (or the empty schema) might be
+/// Schemes other than `http`, `https` (or the empty scheme) might be
/// used with implementation specific semantics.
@property(nonatomic, readwrite, copy, null_resettable) NSString *typeURL;
diff --git a/objectivec/google/protobuf/FieldMask.pbobjc.h b/objectivec/google/protobuf/FieldMask.pbobjc.h
index 52be4ab7..06053f1a 100644
--- a/objectivec/google/protobuf/FieldMask.pbobjc.h
+++ b/objectivec/google/protobuf/FieldMask.pbobjc.h
@@ -113,6 +113,58 @@ typedef GPB_ENUM(GPBFieldMask_FieldNumber) {
/// describe the updated values, the API ignores the values of all
/// fields not covered by the mask.
///
+/// If a repeated field is specified for an update operation, the existing
+/// repeated values in the target resource will be overwritten by the new values.
+/// Note that a repeated field is only allowed in the last position of a field
+/// mask.
+///
+/// If a sub-message is specified in the last position of the field mask for an
+/// update operation, then the existing sub-message in the target resource is
+/// overwritten. Given the target message:
+///
+/// f {
+/// b {
+/// d : 1
+/// x : 2
+/// }
+/// c : 1
+/// }
+///
+/// And an update message:
+///
+/// f {
+/// b {
+/// d : 10
+/// }
+/// }
+///
+/// then if the field mask is:
+///
+/// paths: "f.b"
+///
+/// then the result will be:
+///
+/// f {
+/// b {
+/// d : 10
+/// }
+/// c : 1
+/// }
+///
+/// However, if the update mask was:
+///
+/// paths: "f.b.d"
+///
+/// then the result would be:
+///
+/// f {
+/// b {
+/// d : 10
+/// x : 2
+/// }
+/// c : 1
+/// }
+///
/// In order to reset a field's value to the default, the field must
/// be in the mask and set to the default value in the provided resource.
/// Hence, in order to reset all fields of a resource, provide a default
diff --git a/objectivec/google/protobuf/SourceContext.pbobjc.h b/objectivec/google/protobuf/SourceContext.pbobjc.h
index 985d41d4..4514fa9f 100644
--- a/objectivec/google/protobuf/SourceContext.pbobjc.h
+++ b/objectivec/google/protobuf/SourceContext.pbobjc.h
@@ -50,7 +50,7 @@ typedef GPB_ENUM(GPBSourceContext_FieldNumber) {
@interface GPBSourceContext : GPBMessage
/// The path-qualified name of the .proto file that contained the associated
-/// protobuf element. For example: `"google/protobuf/source.proto"`.
+/// protobuf element. For example: `"google/protobuf/source_context.proto"`.
@property(nonatomic, readwrite, copy, null_resettable) NSString *fileName;
@end