Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
25df28ef
Commit
25df28ef
authored
9 years ago
by
yang-g
Browse files
Options
Downloads
Patches
Plain Diff
resolve comments
parent
2e08941a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/compiler/cpp_generator.h
+1
-0
1 addition, 0 deletions
src/compiler/cpp_generator.h
src/compiler/cpp_plugin.cc
+1
-32
1 addition, 32 deletions
src/compiler/cpp_plugin.cc
src/compiler/generator_helpers.h
+41
-0
41 additions, 0 deletions
src/compiler/generator_helpers.h
with
43 additions
and
32 deletions
src/compiler/cpp_generator.h
+
1
−
0
View file @
25df28ef
...
...
@@ -65,6 +65,7 @@ struct Parameters {
};
// A common interface for objects having comments in the source.
// Return formatted comments to be inserted in generated code.
struct
CommentHolder
{
virtual
~
CommentHolder
()
{}
virtual
grpc
::
string
GetLeadingComments
()
const
=
0
;
...
...
This diff is collapsed.
Click to expand it.
src/compiler/cpp_plugin.cc
+
1
−
32
View file @
25df28ef
...
...
@@ -43,38 +43,7 @@
#include
"src/compiler/cpp_generator_helpers.h"
#include
"src/compiler/generator_helpers.h"
grpc
::
string
GenerateComments
(
const
std
::
vector
<
grpc
::
string
>
&
in
)
{
std
::
ostringstream
oss
;
for
(
const
grpc
::
string
&
elem
:
in
)
{
if
(
elem
.
empty
())
{
oss
<<
"//
\n
"
;
}
else
if
(
elem
[
0
]
==
' '
)
{
oss
<<
"//"
<<
elem
<<
"
\n
"
;
}
else
{
oss
<<
"// "
<<
elem
<<
"
\n
"
;
}
}
return
oss
.
str
();
}
// Get leading or trailing comments in a string. Comment lines start with "// ".
// Leading detached comments are put in in front of leading comments.
template
<
typename
DescriptorType
>
grpc
::
string
GetComments
(
const
DescriptorType
*
desc
,
bool
leading
)
{
std
::
vector
<
grpc
::
string
>
out
;
if
(
leading
)
{
grpc_generator
::
GetComment
(
desc
,
grpc_generator
::
COMMENTTYPE_LEADING_DETACHED
,
&
out
);
std
::
vector
<
grpc
::
string
>
leading
;
grpc_generator
::
GetComment
(
desc
,
grpc_generator
::
COMMENTTYPE_LEADING
,
&
leading
);
out
.
insert
(
out
.
end
(),
leading
.
begin
(),
leading
.
end
());
}
else
{
grpc_generator
::
GetComment
(
desc
,
grpc_generator
::
COMMENTTYPE_TRAILING
,
&
out
);
}
return
GenerateComments
(
out
);
}
using
grpc_generator
::
GetComments
;
class
ProtoBufMethod
:
public
grpc_cpp_generator
::
Method
{
public:
...
...
This diff is collapsed.
Click to expand it.
src/compiler/generator_helpers.h
+
41
−
0
View file @
25df28ef
...
...
@@ -34,6 +34,7 @@
#ifndef GRPC_INTERNAL_COMPILER_GENERATOR_HELPERS_H
#define GRPC_INTERNAL_COMPILER_GENERATOR_HELPERS_H
#include
<iostream>
#include
<map>
#include
<sstream>
#include
<string>
...
...
@@ -203,6 +204,7 @@ inline void GetComment(const DescriptorType *desc, CommentType type,
out
->
push_back
(
""
);
}
}
else
{
std
::
cerr
<<
"Unknown comment type "
<<
type
<<
std
::
endl
;
abort
();
}
}
...
...
@@ -230,10 +232,49 @@ inline void GetComment(const grpc::protobuf::FileDescriptor *desc,
out
->
push_back
(
""
);
}
}
else
{
std
::
cerr
<<
"Unknown comment type "
<<
type
<<
std
::
endl
;
abort
();
}
}
namespace
{
// Prefix comment line with "// " and concatenate them into a string.
grpc
::
string
GenerateComments
(
const
std
::
vector
<
grpc
::
string
>
&
in
)
{
std
::
ostringstream
oss
;
for
(
const
grpc
::
string
&
elem
:
in
)
{
if
(
elem
.
empty
())
{
oss
<<
"//
\n
"
;
}
else
if
(
elem
[
0
]
==
' '
)
{
oss
<<
"//"
<<
elem
<<
"
\n
"
;
}
else
{
oss
<<
"// "
<<
elem
<<
"
\n
"
;
}
}
return
oss
.
str
();
}
}
// namespace
// Get leading or trailing comments in a string. Comment lines start with "// ".
// Leading detached comments are put in in front of leading comments.
template
<
typename
DescriptorType
>
inline
grpc
::
string
GetComments
(
const
DescriptorType
*
desc
,
bool
leading
)
{
std
::
vector
<
grpc
::
string
>
out
;
if
(
leading
)
{
grpc_generator
::
GetComment
(
desc
,
grpc_generator
::
COMMENTTYPE_LEADING_DETACHED
,
&
out
);
std
::
vector
<
grpc
::
string
>
leading
;
grpc_generator
::
GetComment
(
desc
,
grpc_generator
::
COMMENTTYPE_LEADING
,
&
leading
);
out
.
insert
(
out
.
end
(),
leading
.
begin
(),
leading
.
end
());
}
else
{
grpc_generator
::
GetComment
(
desc
,
grpc_generator
::
COMMENTTYPE_TRAILING
,
&
out
);
}
return
GenerateComments
(
out
);
}
}
// namespace grpc_generator
#endif // GRPC_INTERNAL_COMPILER_GENERATOR_HELPERS_H
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment