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
f173cdeb
Commit
f173cdeb
authored
Feb 18, 2015
by
Jisi Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hashcode and equals for oneofs in nano.
parent
06a2e298
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
12 deletions
+34
-12
javanano_field.cc
src/google/protobuf/compiler/javanano/javanano_field.cc
+22
-0
javanano_field.h
src/google/protobuf/compiler/javanano/javanano_field.h
+4
-0
javanano_message_field.cc
...ogle/protobuf/compiler/javanano/javanano_message_field.cc
+2
-10
javanano_primitive_field.cc
...le/protobuf/compiler/javanano/javanano_primitive_field.cc
+6
-2
No files found.
src/google/protobuf/compiler/javanano/javanano_field.cc
View file @
f173cdeb
...
...
@@ -168,6 +168,28 @@ void SetCommonOneofVariables(const FieldDescriptor* descriptor,
SimpleItoa
(
descriptor
->
number
());
}
void
GenerateOneofFieldEquals
(
const
map
<
string
,
string
>&
variables
,
io
::
Printer
*
printer
)
{
printer
->
Print
(
variables
,
"if (this.has$capitalized_name$()) {
\n
"
" if (!this.$oneof_name$_.equals(other.$oneof_name$_)) {
\n
"
" return false;
\n
"
" }
\n
"
"} else {
\n
"
" if (other.has$capitalized_name$()) {
\n
"
" return false;
\n
"
" }
\n
"
"}
\n
"
);
}
void
GenerateOneofFieldHashCode
(
const
map
<
string
,
string
>&
variables
,
io
::
Printer
*
printer
)
{
printer
->
Print
(
variables
,
"result = 31 * result +
\n
"
" ($has_oneof_case$ ? this.$oneof_name$_.hashCode() : 0);
\n
"
);
}
}
// namespace javanano
}
// namespace compiler
}
// namespace protobuf
...
...
src/google/protobuf/compiler/javanano/javanano_field.h
View file @
f173cdeb
...
...
@@ -114,6 +114,10 @@ class FieldGeneratorMap {
void
SetCommonOneofVariables
(
const
FieldDescriptor
*
descriptor
,
map
<
string
,
string
>*
variables
);
void
GenerateOneofFieldEquals
(
const
map
<
string
,
string
>&
variables
,
io
::
Printer
*
printer
);
void
GenerateOneofFieldHashCode
(
const
map
<
string
,
string
>&
variables
,
io
::
Printer
*
printer
);
}
// namespace javanano
}
// namespace compiler
...
...
src/google/protobuf/compiler/javanano/javanano_message_field.cc
View file @
f173cdeb
...
...
@@ -214,20 +214,12 @@ GenerateSerializedSizeCode(io::Printer* printer) const {
void
MessageOneofFieldGenerator
::
GenerateEqualsCode
(
io
::
Printer
*
printer
)
const
{
printer
->
Print
(
variables_
,
"if (this.has$capitalized_name$()) {
\n
"
" if (!this.$oneof_name$_.equals(other.$oneof_name$_)) {
\n
"
" return false;
\n
"
" }
\n
"
"} else {
\n
"
" if (other.has$capitalized_name$()) {
\n
"
" return false;
\n
"
" }
\n
"
"}
\n
"
);
GenerateOneofFieldEquals
(
variables_
,
printer
);
}
void
MessageOneofFieldGenerator
::
GenerateHashCodeCode
(
io
::
Printer
*
printer
)
const
{
GenerateOneofFieldHashCode
(
variables_
,
printer
);
}
// ===================================================================
...
...
src/google/protobuf/compiler/javanano/javanano_primitive_field.cc
View file @
f173cdeb
...
...
@@ -765,10 +765,14 @@ void PrimitiveOneofFieldGenerator::GenerateSerializedSizeCode(
"}
\n
"
);
}
void
PrimitiveOneofFieldGenerator
::
GenerateEqualsCode
(
io
::
Printer
*
printer
)
const
{
void
PrimitiveOneofFieldGenerator
::
GenerateEqualsCode
(
io
::
Printer
*
printer
)
const
{
GenerateOneofFieldEquals
(
variables_
,
printer
);
}
void
PrimitiveOneofFieldGenerator
::
GenerateHashCodeCode
(
io
::
Printer
*
printer
)
const
{
void
PrimitiveOneofFieldGenerator
::
GenerateHashCodeCode
(
io
::
Printer
*
printer
)
const
{
GenerateOneofFieldHashCode
(
variables_
,
printer
);
}
// ===================================================================
...
...
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