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
d5557758
Commit
d5557758
authored
Jun 06, 2017
by
Thomas Van Lenten
Committed by
GitHub
Jun 06, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3189 from thomasvl/objc_proto3_unknown_fields
ObjC: Preserve unknown fields in proto3 syntax files.
parents
2aeb4ab9
1d0988b8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
44 deletions
+5
-44
GPBDescriptor_PackagePrivate.h
objectivec/GPBDescriptor_PackagePrivate.h
+0
-4
GPBMessage.m
objectivec/GPBMessage.m
+5
-11
GPBMessageTests+Serialization.m
objectivec/Tests/GPBMessageTests+Serialization.m
+0
-29
No files found.
objectivec/GPBDescriptor_PackagePrivate.h
View file @
d5557758
...
...
@@ -286,10 +286,6 @@ uint32_t GPBFieldTag(GPBFieldDescriptor *self);
// would be the wire type for packed.
uint32_t
GPBFieldAlternateTag
(
GPBFieldDescriptor
*
self
);
GPB_INLINE
BOOL
GPBPreserveUnknownFields
(
GPBFileSyntax
syntax
)
{
return
syntax
!=
GPBFileSyntaxProto3
;
}
GPB_INLINE
BOOL
GPBHasPreservingUnknownEnumSemantics
(
GPBFileSyntax
syntax
)
{
return
syntax
==
GPBFileSyntaxProto3
;
}
...
...
objectivec/GPBMessage.m
View file @
d5557758
...
...
@@ -2372,17 +2372,11 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
// zero signals EOF / limit reached
return
;
}
else
{
if
(
GPBPreserveUnknownFields
(
syntax
))
{
if
(
!
[
self
parseUnknownField
:
input
extensionRegistry
:
extensionRegistry
tag
:
tag
])
{
// it's an endgroup tag
return
;
}
}
else
{
if
(
!
[
input
skipField
:
tag
])
{
return
;
}
if
(
!
[
self
parseUnknownField
:
input
extensionRegistry
:
extensionRegistry
tag
:
tag
])
{
// it's an endgroup tag
return
;
}
}
}
// if(!merged)
...
...
objectivec/Tests/GPBMessageTests+Serialization.m
View file @
d5557758
...
...
@@ -113,35 +113,6 @@ static NSData *DataFromCStr(const char *str) {
[
msg
release
];
}
-
(
void
)
testProto3DroppingUnknownFields
{
DropUnknownsFooWithExtraFields
*
fooWithExtras
=
[[
DropUnknownsFooWithExtraFields
alloc
]
init
];
fooWithExtras
.
int32Value
=
1
;
fooWithExtras
.
enumValue
=
DropUnknownsFooWithExtraFields_NestedEnum_Baz
;
fooWithExtras
.
extraInt32Value
=
2
;
NSData
*
data
=
[
fooWithExtras
data
];
XCTAssertNotNil
(
data
);
DropUnknownsFoo
*
foo
=
[
DropUnknownsFoo
parseFromData
:
data
error
:
NULL
];
XCTAssertEqual
(
foo
.
int32Value
,
1
);
XCTAssertEqual
(
foo
.
enumValue
,
DropUnknownsFoo_NestedEnum_Baz
);
// Nothing should end up in the unknowns.
XCTAssertEqual
([
foo
.
unknownFields
countOfFields
],
0U
);
[
fooWithExtras
release
];
data
=
[
foo
data
];
fooWithExtras
=
[
DropUnknownsFooWithExtraFields
parseFromData
:
data
error
:
NULL
];
XCTAssertEqual
(
fooWithExtras
.
int32Value
,
1
);
XCTAssertEqual
(
fooWithExtras
.
enumValue
,
DropUnknownsFooWithExtraFields_NestedEnum_Baz
);
// And the extra value is gone (back to the default).
XCTAssertEqual
(
fooWithExtras
.
extraInt32Value
,
0
);
XCTAssertEqual
([
foo
.
unknownFields
countOfFields
],
0U
);
}
-
(
void
)
testProto2UnknownEnumToUnknownField
{
Message3
*
orig
=
[[
Message3
alloc
]
init
];
...
...
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