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
137dc026
Commit
137dc026
authored
Dec 22, 2016
by
Feng Xiao
Committed by
GitHub
Dec 22, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2525 from camillol/lite
Eliminate redundant methods in C++ generated code for lite protos
parents
d948b66d
abe17256
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
14 deletions
+32
-14
cpp_message.cc
src/google/protobuf/compiler/cpp/cpp_message.cc
+2
-14
callback.h
src/google/protobuf/stubs/callback.h
+30
-0
No files found.
src/google/protobuf/compiler/cpp/cpp_message.cc
View file @
137dc026
...
...
@@ -1661,18 +1661,6 @@ void MessageGenerator::
GenerateClassMethods
(
io
::
Printer
*
printer
)
{
if
(
IsMapEntryMessage
(
descriptor_
))
return
;
// mutable_unknown_fields wrapper function for LazyStringOutputStream
// callback.
if
(
PreserveUnknownFields
(
descriptor_
)
&&
!
UseUnknownFieldSet
(
descriptor_
->
file
(),
options_
))
{
printer
->
Print
(
"static ::std::string* MutableUnknownFieldsFor$classname$(
\n
"
" $classname$* ptr) {
\n
"
" return ptr->mutable_unknown_fields();
\n
"
"}
\n
"
"
\n
"
,
"classname"
,
classname_
);
}
if
(
IsAnyMessage
(
descriptor_
))
{
printer
->
Print
(
"void $classname$::PackFrom(const ::google::protobuf::Message& message) {
\n
"
...
...
@@ -2936,8 +2924,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
// on the CodedOutputStream.
printer
->
Print
(
" ::google::protobuf::io::LazyStringOutputStream unknown_fields_string(
\n
"
"
NewPermanentCallback(
\n
"
" &
MutableUnknownFieldsFor$classname$, thi
s));
\n
"
"
::google::protobuf::NewPermanentCallback(&_internal_metadata_,
\n
"
" &
::google::protobuf::internal::InternalMetadataWithArenaLite::mutable_unknown_field
s));
\n
"
" ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
\n
"
" &unknown_fields_string, false);
\n
"
,
"classname"
,
classname_
);
...
...
src/google/protobuf/stubs/callback.h
View file @
137dc026
...
...
@@ -346,6 +346,29 @@ struct InternalConstRef {
typedef
const
base_type
&
type
;
};
template
<
typename
R
,
typename
T
>
class
MethodResultCallback_0_0
:
public
ResultCallback
<
R
>
{
public
:
typedef
R
(
T
::*
MethodType
)();
MethodResultCallback_0_0
(
T
*
object
,
MethodType
method
,
bool
self_deleting
)
:
object_
(
object
),
method_
(
method
),
self_deleting_
(
self_deleting
)
{}
~
MethodResultCallback_0_0
()
{}
R
Run
()
{
bool
needs_delete
=
self_deleting_
;
R
result
=
(
object_
->*
method_
)();
if
(
needs_delete
)
delete
this
;
return
result
;
}
private
:
T
*
object_
;
MethodType
method_
;
bool
self_deleting_
;
};
template
<
typename
R
,
typename
T
,
typename
P1
,
typename
P2
,
typename
P3
,
typename
P4
,
typename
P5
,
typename
A1
,
typename
A2
>
class
MethodResultCallback_5_2
:
public
ResultCallback2
<
R
,
A1
,
A2
>
{
...
...
@@ -520,6 +543,13 @@ inline ResultCallback1<R, A1>* NewPermanentCallback(
function
,
false
,
p1
);
}
// See MethodResultCallback_0_0
template
<
typename
R
,
typename
T1
,
typename
T2
>
inline
ResultCallback
<
R
>*
NewPermanentCallback
(
T1
*
object
,
R
(
T2
::*
function
)())
{
return
new
internal
::
MethodResultCallback_0_0
<
R
,
T1
>
(
object
,
function
,
false
);
}
// See MethodResultCallback_5_2
template
<
typename
R
,
typename
T
,
typename
P1
,
typename
P2
,
typename
P3
,
typename
P4
,
typename
P5
,
typename
A1
,
typename
A2
>
...
...
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