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
897c2a22
Unverified
Commit
897c2a22
authored
Nov 14, 2018
by
Adam Cozzette
Committed by
GitHub
Nov 14, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5349 from Allen-Webb/master
cpp_generator: Add generator options for --cpp_out.
parents
c0bc265b
375d32d3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
7 deletions
+22
-7
cpp_generator.cc
src/google/protobuf/compiler/cpp/cpp_generator.cc
+4
-1
cpp_helpers.h
src/google/protobuf/compiler/cpp/cpp_helpers.h
+11
-5
cpp_options.h
src/google/protobuf/compiler/cpp/cpp_options.h
+7
-1
No files found.
src/google/protobuf/compiler/cpp/cpp_generator.cc
View file @
897c2a22
...
@@ -92,9 +92,12 @@ bool CppGenerator::Generate(const FileDescriptor* file,
...
@@ -92,9 +92,12 @@ bool CppGenerator::Generate(const FileDescriptor* file,
file_options
.
annotation_pragma_name
=
options
[
i
].
second
;
file_options
.
annotation_pragma_name
=
options
[
i
].
second
;
}
else
if
(
options
[
i
].
first
==
"annotation_guard_name"
)
{
}
else
if
(
options
[
i
].
first
==
"annotation_guard_name"
)
{
file_options
.
annotation_guard_name
=
options
[
i
].
second
;
file_options
.
annotation_guard_name
=
options
[
i
].
second
;
}
else
if
(
options
[
i
].
first
==
"speed"
)
{
file_options
.
enforce_mode
=
EnforceOptimizeMode
::
kSpeed
;
}
else
if
(
options
[
i
].
first
==
"lite"
)
{
}
else
if
(
options
[
i
].
first
==
"lite"
)
{
file_options
.
enforce_
lite
=
tru
e
;
file_options
.
enforce_
mode
=
EnforceOptimizeMode
::
kLiteRuntim
e
;
}
else
if
(
options
[
i
].
first
==
"lite_implicit_weak_fields"
)
{
}
else
if
(
options
[
i
].
first
==
"lite_implicit_weak_fields"
)
{
file_options
.
enforce_mode
=
EnforceOptimizeMode
::
kLiteRuntime
;
file_options
.
lite_implicit_weak_fields
=
true
;
file_options
.
lite_implicit_weak_fields
=
true
;
if
(
!
options
[
i
].
second
.
empty
())
{
if
(
!
options
[
i
].
second
.
empty
())
{
file_options
.
num_cc_files
=
strto32
(
options
[
i
].
second
.
c_str
(),
file_options
.
num_cc_files
=
strto32
(
options
[
i
].
second
.
c_str
(),
...
...
src/google/protobuf/compiler/cpp/cpp_helpers.h
View file @
897c2a22
...
@@ -353,7 +353,7 @@ inline bool HasFastArraySerialization(const FileDescriptor* file,
...
@@ -353,7 +353,7 @@ inline bool HasFastArraySerialization(const FileDescriptor* file,
inline
bool
IsProto2MessageSet
(
const
Descriptor
*
descriptor
,
inline
bool
IsProto2MessageSet
(
const
Descriptor
*
descriptor
,
const
Options
&
options
)
{
const
Options
&
options
)
{
return
!
options
.
opensource_runtime
&&
return
!
options
.
opensource_runtime
&&
!
options
.
enforce_lit
e
&&
options
.
enforce_mode
!=
EnforceOptimizeMode
::
kLiteRuntim
e
&&
!
options
.
lite_implicit_weak_fields
&&
!
options
.
lite_implicit_weak_fields
&&
descriptor
->
options
().
message_set_wire_format
()
&&
descriptor
->
options
().
message_set_wire_format
()
&&
descriptor
->
full_name
()
==
"google.protobuf.bridge.MessageSet"
;
descriptor
->
full_name
()
==
"google.protobuf.bridge.MessageSet"
;
...
@@ -362,7 +362,7 @@ inline bool IsProto2MessageSet(const Descriptor* descriptor,
...
@@ -362,7 +362,7 @@ inline bool IsProto2MessageSet(const Descriptor* descriptor,
inline
bool
IsProto2MessageSetFile
(
const
FileDescriptor
*
file
,
inline
bool
IsProto2MessageSetFile
(
const
FileDescriptor
*
file
,
const
Options
&
options
)
{
const
Options
&
options
)
{
return
!
options
.
opensource_runtime
&&
return
!
options
.
opensource_runtime
&&
!
options
.
enforce_lit
e
&&
options
.
enforce_mode
!=
EnforceOptimizeMode
::
kLiteRuntim
e
&&
!
options
.
lite_implicit_weak_fields
&&
!
options
.
lite_implicit_weak_fields
&&
file
->
name
()
==
"net/proto2/bridge/proto/message_set.proto"
;
file
->
name
()
==
"net/proto2/bridge/proto/message_set.proto"
;
}
}
...
@@ -419,9 +419,15 @@ bool IsWellKnownMessage(const FileDescriptor* descriptor);
...
@@ -419,9 +419,15 @@ bool IsWellKnownMessage(const FileDescriptor* descriptor);
inline
FileOptions_OptimizeMode
GetOptimizeFor
(
const
FileDescriptor
*
file
,
inline
FileOptions_OptimizeMode
GetOptimizeFor
(
const
FileDescriptor
*
file
,
const
Options
&
options
)
{
const
Options
&
options
)
{
return
options
.
enforce_lite
switch
(
options
.
enforce_mode
)
{
?
FileOptions
::
LITE_RUNTIME
case
EnforceOptimizeMode
:
:
kSpeed
:
:
file
->
options
().
optimize_for
();
return
FileOptions
::
SPEED
;
case
EnforceOptimizeMode
:
:
kLiteRuntime
:
return
FileOptions
::
LITE_RUNTIME
;
case
EnforceOptimizeMode
:
:
kNoEnforcement
:
default:
return
file
->
options
().
optimize_for
();
}
}
}
// This orders the messages in a .pb.cc as it's outputted by file.cc
// This orders the messages in a .pb.cc as it's outputted by file.cc
...
...
src/google/protobuf/compiler/cpp/cpp_options.h
View file @
897c2a22
...
@@ -42,6 +42,12 @@ class AccessInfoMap;
...
@@ -42,6 +42,12 @@ class AccessInfoMap;
namespace
cpp
{
namespace
cpp
{
enum
class
EnforceOptimizeMode
{
kNoEnforcement
,
// Use the runtime specified by the file specific options.
kSpeed
,
// This is the full runtime.
kLiteRuntime
,
};
// Generator options (see generator.cc for a description of each):
// Generator options (see generator.cc for a description of each):
struct
Options
{
struct
Options
{
std
::
string
dllexport_decl
;
std
::
string
dllexport_decl
;
...
@@ -49,7 +55,7 @@ struct Options {
...
@@ -49,7 +55,7 @@ struct Options {
bool
proto_h
=
false
;
bool
proto_h
=
false
;
bool
transitive_pb_h
=
true
;
bool
transitive_pb_h
=
true
;
bool
annotate_headers
=
false
;
bool
annotate_headers
=
false
;
bool
enforce_lite
=
false
;
EnforceOptimizeMode
enforce_mode
=
EnforceOptimizeMode
::
kNoEnforcement
;
bool
table_driven_parsing
=
false
;
bool
table_driven_parsing
=
false
;
bool
table_driven_serialization
=
false
;
bool
table_driven_serialization
=
false
;
bool
lite_implicit_weak_fields
=
false
;
bool
lite_implicit_weak_fields
=
false
;
...
...
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