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
517591b8
Commit
517591b8
authored
Oct 01, 2014
by
Brian Duff
Committed by
Gerrit Code Review
Oct 01, 2014
Browse files
Options
Browse Files
Download
Plain Diff
Merge "Adds a primitive enum mode for reftypes."
parents
14e2f6cb
a892068c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
4 deletions
+23
-4
javanano_enum_field.cc
src/google/protobuf/compiler/javanano/javanano_enum_field.cc
+5
-2
javanano_generator.cc
src/google/protobuf/compiler/javanano/javanano_generator.cc
+4
-1
javanano_helpers.cc
src/google/protobuf/compiler/javanano/javanano_helpers.cc
+4
-0
javanano_params.h
src/google/protobuf/compiler/javanano/javanano_params.h
+10
-1
No files found.
src/google/protobuf/compiler/javanano/javanano_enum_field.cc
View file @
517591b8
...
...
@@ -59,6 +59,7 @@ void SetEnumVariables(const Params& params,
RenameJavaKeywords
(
UnderscoresToCapitalizedCamelCase
(
descriptor
));
(
*
variables
)[
"number"
]
=
SimpleItoa
(
descriptor
->
number
());
if
(
params
.
use_reference_types_for_primitives
()
&&
!
params
.
reftypes_primitive_enums
()
&&
!
descriptor
->
is_repeated
())
{
(
*
variables
)[
"type"
]
=
"java.lang.Integer"
;
(
*
variables
)[
"default"
]
=
"null"
;
...
...
@@ -197,7 +198,8 @@ GenerateSerializedSizeCode(io::Printer* printer) const {
}
void
EnumFieldGenerator
::
GenerateEqualsCode
(
io
::
Printer
*
printer
)
const
{
if
(
params_
.
use_reference_types_for_primitives
())
{
if
(
params_
.
use_reference_types_for_primitives
()
&&
!
params_
.
reftypes_primitive_enums
())
{
printer
->
Print
(
variables_
,
"if (this.$name$ == null) {
\n
"
" if (other.$name$ != null) {
\n
"
...
...
@@ -228,7 +230,8 @@ void EnumFieldGenerator::GenerateEqualsCode(io::Printer* printer) const {
void
EnumFieldGenerator
::
GenerateHashCodeCode
(
io
::
Printer
*
printer
)
const
{
printer
->
Print
(
"result = 31 * result + "
);
if
(
params_
.
use_reference_types_for_primitives
())
{
if
(
params_
.
use_reference_types_for_primitives
()
&&
!
params_
.
reftypes_primitive_enums
())
{
printer
->
Print
(
variables_
,
"(this.$name$ == null ? 0 : this.$name$)"
);
}
else
{
...
...
src/google/protobuf/compiler/javanano/javanano_generator.cc
View file @
517591b8
...
...
@@ -139,7 +139,10 @@ bool JavaNanoGenerator::Generate(const FileDescriptor* file,
params
.
set_java_enum_style
(
option_value
==
"java"
);
}
else
if
(
option_name
==
"optional_field_style"
)
{
params
.
set_optional_field_accessors
(
option_value
==
"accessors"
);
params
.
set_use_reference_types_for_primitives
(
option_value
==
"reftypes"
);
params
.
set_use_reference_types_for_primitives
(
option_value
==
"reftypes"
||
option_value
==
"reftypes_primitive_enums"
);
params
.
set_reftypes_primitive_enums
(
option_value
==
"reftypes_primitive_enums"
);
}
else
if
(
option_name
==
"generate_equals"
)
{
params
.
set_generate_equals
(
option_value
==
"true"
);
}
else
if
(
option_name
==
"ignore_services"
)
{
...
...
src/google/protobuf/compiler/javanano/javanano_helpers.cc
View file @
517591b8
...
...
@@ -392,6 +392,10 @@ string DefaultValue(const Params& params, const FieldDescriptor* field) {
}
if
(
params
.
use_reference_types_for_primitives
())
{
if
(
params
.
reftypes_primitive_enums
()
&&
field
->
cpp_type
()
==
FieldDescriptor
::
CPPTYPE_ENUM
)
{
return
"Integer.MIN_VALUE"
;
}
return
"null"
;
}
...
...
src/google/protobuf/compiler/javanano/javanano_params.h
View file @
517591b8
...
...
@@ -64,6 +64,7 @@ class Params {
bool
generate_equals_
;
bool
ignore_services_
;
bool
parcelable_messages_
;
bool
reftypes_primitive_enums_
;
public
:
Params
(
const
string
&
base_name
)
:
...
...
@@ -77,7 +78,8 @@ class Params {
use_reference_types_for_primitives_
(
false
),
generate_equals_
(
false
),
ignore_services_
(
false
),
parcelable_messages_
(
false
)
{
parcelable_messages_
(
false
),
reftypes_primitive_enums_
(
false
)
{
}
const
string
&
base_name
()
const
{
...
...
@@ -213,6 +215,13 @@ class Params {
bool
parcelable_messages
()
const
{
return
parcelable_messages_
;
}
void
set_reftypes_primitive_enums
(
bool
value
)
{
reftypes_primitive_enums_
=
value
;
}
bool
reftypes_primitive_enums
()
const
{
return
reftypes_primitive_enums_
;
}
};
}
// namespace javanano
...
...
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