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
7a83d348
Commit
7a83d348
authored
Jul 15, 2014
by
Max Cai
Committed by
Gerrit Code Review
Jul 14, 2014
Browse files
Options
Browse Files
Download
Plain Diff
Merge "Fix access around unknownFieldData."
parents
30b1454d
d1a8a8f6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
13 deletions
+33
-13
ExtendableMessageNano.java
.../java/com/google/protobuf/nano/ExtendableMessageNano.java
+25
-0
NanoTest.java
java/src/test/java/com/google/protobuf/NanoTest.java
+4
-4
javanano_message.cc
src/google/protobuf/compiler/javanano/javanano_message.cc
+2
-7
unittest_extension_nano.proto
src/google/protobuf/unittest_extension_nano.proto
+1
-1
unittest_import_nano.proto
src/google/protobuf/unittest_import_nano.proto
+1
-1
No files found.
java/src/main/java/com/google/protobuf/nano/ExtendableMessageNano.java
View file @
7a83d348
...
...
@@ -147,4 +147,29 @@ public abstract class ExtendableMessageNano<M extends ExtendableMessageNano<M>>
field
.
addUnknownField
(
unknownField
);
return
true
;
}
/**
* Returns whether the stored unknown field data in this message is equivalent to that in the
* other message.
*
* @param other the other message.
* @return whether the two sets of unknown field data are equal.
*/
protected
final
boolean
unknownFieldDataEquals
(
M
other
)
{
if
(
unknownFieldData
==
null
||
unknownFieldData
.
isEmpty
())
{
return
other
.
unknownFieldData
==
null
||
other
.
unknownFieldData
.
isEmpty
();
}
else
{
return
unknownFieldData
.
equals
(
other
.
unknownFieldData
);
}
}
/**
* Computes the hashcode representing the unknown field data stored in this message.
*
* @return the hashcode for the unknown field data.
*/
protected
final
int
unknownFieldDataHashCode
()
{
return
(
unknownFieldData
==
null
||
unknownFieldData
.
isEmpty
()
?
0
:
unknownFieldData
.
hashCode
());
}
}
java/src/test/java/com/google/protobuf/NanoTest.java
View file @
7a83d348
...
...
@@ -35,9 +35,6 @@ import com.google.protobuf.nano.EnumClassNanoMultiple;
import
com.google.protobuf.nano.EnumClassNanos
;
import
com.google.protobuf.nano.EnumValidity
;
import
com.google.protobuf.nano.EnumValidityAccessors
;
import
com.google.protobuf.nano.Extensions
;
import
com.google.protobuf.nano.Extensions.AnotherMessage
;
import
com.google.protobuf.nano.Extensions.MessageWithGroup
;
import
com.google.protobuf.nano.FileScopeEnumMultiple
;
import
com.google.protobuf.nano.FileScopeEnumRefNano
;
import
com.google.protobuf.nano.InternalNano
;
...
...
@@ -57,11 +54,14 @@ import com.google.protobuf.nano.PackedExtensions;
import
com.google.protobuf.nano.RepeatedExtensions
;
import
com.google.protobuf.nano.SingularExtensions
;
import
com.google.protobuf.nano.TestRepeatedMergeNano
;
import
com.google.protobuf.nano.UnittestImportNano
;
import
com.google.protobuf.nano.UnittestMultipleNano
;
import
com.google.protobuf.nano.UnittestRecursiveNano.RecursiveMessageNano
;
import
com.google.protobuf.nano.UnittestSimpleNano.SimpleMessageNano
;
import
com.google.protobuf.nano.UnittestSingleNano.SingleMessageNano
;
import
com.google.protobuf.nano.testext.Extensions
;
import
com.google.protobuf.nano.testext.Extensions.AnotherMessage
;
import
com.google.protobuf.nano.testext.Extensions.MessageWithGroup
;
import
com.google.protobuf.nano.testimport.UnittestImportNano
;
import
junit.framework.TestCase
;
...
...
src/google/protobuf/compiler/javanano/javanano_message.cc
View file @
7a83d348
...
...
@@ -501,11 +501,7 @@ void MessageGenerator::GenerateEquals(io::Printer* printer) {
if
(
params_
.
store_unknown_fields
())
{
printer
->
Print
(
"if (unknownFieldData == null || unknownFieldData.isEmpty()) {
\n
"
" return other.unknownFieldData == null || other.unknownFieldData.isEmpty();"
"} else {
\n
"
" return unknownFieldData.equals(other.unknownFieldData);
\n
"
"}
\n
"
);
"return unknownFieldDataEquals(other);
\n
"
);
}
else
{
printer
->
Print
(
"return true;
\n
"
);
...
...
@@ -534,8 +530,7 @@ void MessageGenerator::GenerateHashCode(io::Printer* printer) {
if
(
params_
.
store_unknown_fields
())
{
printer
->
Print
(
"result = 31 * result + (unknownFieldData == null || unknownFieldData.isEmpty()
\n
"
" ? 0 : unknownFieldData.hashCode());
\n
"
);
"result = 31 * result + unknownFieldDataHashCode();
\n
"
);
}
printer
->
Print
(
"return result;
\n
"
);
...
...
src/google/protobuf/unittest_extension_nano.proto
View file @
7a83d348
syntax
=
"proto2"
;
option
java_outer_classname
=
"Extensions"
;
option
java_package
=
"com.google.protobuf.nano"
;
option
java_package
=
"com.google.protobuf.nano
.testext
"
;
message
ExtendableMessage
{
optional
int32
field
=
1
;
...
...
src/google/protobuf/unittest_import_nano.proto
View file @
7a83d348
...
...
@@ -35,7 +35,7 @@
package
protobuf_unittest_import
;
// java_package and java_outer_classname are specified on the command line.
//option java_package = "com.google.protobuf.nano";
//option java_package = "com.google.protobuf.nano
.testimport
";
//option java_outer_classname = "UnittestImportNano";
message
ImportMessageNano
{
...
...
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