Skip to content

Commit

Permalink
[ObjC] Add the missing registries for parsing.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 724008162
  • Loading branch information
thomasvl authored and copybara-github committed Feb 6, 2025
1 parent 7804f69 commit c4b502f
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions conformance/conformance_objc.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static void Die(NSString *format, ...) {
break;

case ConformanceRequest_Payload_OneOfCase_ProtobufPayload: {
NSDictionary *mappings = @{
NSDictionary *classMappings = @{
@"protobuf_test_messages.proto2.TestAllTypesProto2" : [Proto2TestAllTypesProto2 class],
@"protobuf_test_messages.proto3.TestAllTypesProto3" : [Proto3TestAllTypesProto3 class],
@"protobuf_test_messages.editions.TestAllTypesEdition2023" :
Expand All @@ -62,10 +62,23 @@ static void Die(NSString *format, ...) {
@"protobuf_test_messages.editions.proto3.TestAllTypesProto3" :
[EditionsProto3TestAllTypesProto3 class],
};
Class msgClass = mappings[request.messageType];
NSDictionary *rootMappings = @{
@"protobuf_test_messages.proto2.TestAllTypesProto2" : [Proto2TestMessagesProto2Root class],
@"protobuf_test_messages.proto3.TestAllTypesProto3" : [Proto3TestMessagesProto3Root class],
@"protobuf_test_messages.editions.TestAllTypesEdition2023" :
[EditionsTestMessagesEdition2023Root class],
@"protobuf_test_messages.editions.proto2.TestAllTypesProto2" :
[EditionsProto2TestMessagesProto2EditionsRoot class],
@"protobuf_test_messages.editions.proto3.TestAllTypesProto3" :
[EditionsProto3TestMessagesProto3EditionsRoot class],
};
Class msgClass = classMappings[request.messageType];
if (msgClass) {
GPBExtensionRegistry *registery = [rootMappings[request.messageType] extensionRegistry];
NSError *error = nil;
testMessage = [msgClass parseFromData:request.protobufPayload error:&error];
testMessage = [msgClass parseFromData:request.protobufPayload
extensionRegistry:registery
error:&error];
if (!testMessage) {
response.parseError = [NSString stringWithFormat:@"Parse error: %@", error];
}
Expand Down

0 comments on commit c4b502f

Please sign in to comment.