Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
c2831a34
Commit
c2831a34
authored
Jul 26, 2017
by
Thomas Van Lenten
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the proto2 message conformance support for ObjC.
parent
9fd5e59c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
conformance_objc.m
conformance/conformance_objc.m
+12
-10
No files found.
conformance/conformance_objc.m
View file @
c2831a34
...
...
@@ -31,6 +31,7 @@
#import <Foundation/Foundation.h>
#import "Conformance.pbobjc.h"
#import "google/protobuf/TestMessagesProto2.pbobjc.h"
#import "google/protobuf/TestMessagesProto3.pbobjc.h"
static
void
Die
(
NSString
*
format
,
...)
__dead2
;
...
...
@@ -63,7 +64,7 @@ static NSData *CheckedReadDataOfLength(NSFileHandle *handle, NSUInteger numBytes
static
ConformanceResponse
*
DoTest
(
ConformanceRequest
*
request
)
{
ConformanceResponse
*
response
=
[
ConformanceResponse
message
];
Proto3TestAllTypesProto3
*
testMessage
=
nil
;
GPBMessage
*
testMessage
=
nil
;
switch
(
request
.
payloadOneOfCase
)
{
case
ConformanceRequest_Payload_OneOfCase_GPBUnsetOneOfCase
:
...
...
@@ -71,20 +72,21 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) {
break
;
case
ConformanceRequest_Payload_OneOfCase_ProtobufPayload
:
{
if
([
request
.
messageType
isEqualToString
:
@"protobuf_test_messages.proto3.TestAllTypesProto3"
])
{
Class
msgClass
=
nil
;
if
([
request
.
messageType
isEqual
:
@"protobuf_test_messages.proto3.TestAllTypesProto3"
])
{
msgClass
=
[
Proto3TestAllTypesProto3
class
];
}
else
if
([
request
.
messageType
isEqual
:
@"protobuf_test_messages.proto2.TestAllTypesProto2"
])
{
msgClass
=
[
TestAllTypesProto2
class
];
}
else
{
Die
(
@"Protobuf request doesn't have specific payload type"
);
}
if
(
msgClass
)
{
NSError
*
error
=
nil
;
testMessage
=
[
Proto3TestAllTypesProto3
parseFromData
:
request
.
protobufPayload
error
:
&
error
];
testMessage
=
[
msgClass
parseFromData
:
request
.
protobufPayload
error
:
&
error
];
if
(
!
testMessage
)
{
response
.
parseError
=
[
NSString
stringWithFormat
:
@"Parse error: %@"
,
error
];
}
}
else
if
([
request
.
messageType
isEqualToString
:
@"protobuf_test_messages.proto2.TestAllTypesProto2"
])
{
response
.
skipped
=
@"ObjC doesn't support proto2"
;
break
;
}
else
{
Die
(
@"Protobuf request doesn't have specific payload type"
);
break
;
}
break
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment