aboutsummaryrefslogtreecommitdiff
path: root/objectivec/GPBMessage.m
diff options
context:
space:
mode:
authorThomas Van Lenten <thomasvl@google.com>2016-06-28 08:29:19 -0400
committerGitHub <noreply@github.com>2016-06-28 08:29:19 -0400
commite0016c5b6ae61ad60d260a78c5834cc537b46d10 (patch)
treebcf1c6961b29ed5b0c003931175ef4a8fec2cd73 /objectivec/GPBMessage.m
parentdc0aeaa9030bdac264b44d56d07b6839a1ae94e9 (diff)
parentfc4c6171999243695166747108cf7d65e34bf4c0 (diff)
downloadprotobuf-e0016c5b6ae61ad60d260a78c5834cc537b46d10.tar.gz
protobuf-e0016c5b6ae61ad60d260a78c5834cc537b46d10.tar.bz2
protobuf-e0016c5b6ae61ad60d260a78c5834cc537b46d10.zip
Merge pull request #1720 from thomasvl/issue_1716
Fix GPBGetMessage{Repeated,Map}Field()
Diffstat (limited to 'objectivec/GPBMessage.m')
-rw-r--r--objectivec/GPBMessage.m30
1 files changed, 30 insertions, 0 deletions
diff --git a/objectivec/GPBMessage.m b/objectivec/GPBMessage.m
index 919fb931..7ab184c1 100644
--- a/objectivec/GPBMessage.m
+++ b/objectivec/GPBMessage.m
@@ -3199,4 +3199,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