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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
72e0fb83
Commit
72e0fb83
authored
May 1, 2015
by
Yang Gao
Browse files
Options
Downloads
Patches
Plain Diff
generate a StubInterface
parent
6f0812cd
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/compiler/cpp_generator.cc
+46
-25
46 additions, 25 deletions
src/compiler/cpp_generator.cc
with
46 additions
and
25 deletions
src/compiler/cpp_generator.cc
+
46
−
25
View file @
72e0fb83
...
@@ -218,52 +218,62 @@ grpc::string GetHeaderIncludes(const grpc::protobuf::FileDescriptor *file,
...
@@ -218,52 +218,62 @@ grpc::string GetHeaderIncludes(const grpc::protobuf::FileDescriptor *file,
void
PrintHeaderClientMethod
(
grpc
::
protobuf
::
io
::
Printer
*
printer
,
void
PrintHeaderClientMethod
(
grpc
::
protobuf
::
io
::
Printer
*
printer
,
const
grpc
::
protobuf
::
MethodDescriptor
*
method
,
const
grpc
::
protobuf
::
MethodDescriptor
*
method
,
std
::
map
<
grpc
::
string
,
grpc
::
string
>
*
vars
)
{
std
::
map
<
grpc
::
string
,
grpc
::
string
>
*
vars
,
bool
is_abstract
)
{
(
*
vars
)[
"Method"
]
=
method
->
name
();
(
*
vars
)[
"Method"
]
=
method
->
name
();
(
*
vars
)[
"Request"
]
=
(
*
vars
)[
"Request"
]
=
grpc_cpp_generator
::
ClassName
(
method
->
input_type
(),
true
);
grpc_cpp_generator
::
ClassName
(
method
->
input_type
(),
true
);
(
*
vars
)[
"Response"
]
=
(
*
vars
)[
"Response"
]
=
grpc_cpp_generator
::
ClassName
(
method
->
output_type
(),
true
);
grpc_cpp_generator
::
ClassName
(
method
->
output_type
(),
true
);
(
*
vars
)[
"IsAbstract"
]
=
is_abstract
?
" = 0"
:
""
;
(
*
vars
)[
"IsVirtual"
]
=
is_abstract
?
"virtual "
:
""
;
if
(
NoStreaming
(
method
))
{
if
(
NoStreaming
(
method
))
{
printer
->
Print
(
*
vars
,
"::grpc::Status $Method$(::grpc::ClientContext* context, "
"const $Request$& request, $Response$* response);
\n
"
);
printer
->
Print
(
printer
->
Print
(
*
vars
,
*
vars
,
"$IsVirtual$::grpc::Status $Method$(::grpc::ClientContext* context, "
"const $Request$& request, $Response$* response)$IsAbstract$;
\n
"
);
printer
->
Print
(
*
vars
,
"$IsVirtual$"
"std::unique_ptr< ::grpc::ClientAsyncResponseReader< $Response$>> "
"std::unique_ptr< ::grpc::ClientAsyncResponseReader< $Response$>> "
"Async$Method$(::grpc::ClientContext* context, "
"Async$Method$(::grpc::ClientContext* context, "
"const $Request$& request, "
"const $Request$& request, "
"::grpc::CompletionQueue* cq, void* tag);
\n
"
);
"::grpc::CompletionQueue* cq, void* tag)
$IsAbstract$
;
\n
"
);
}
else
if
(
ClientOnlyStreaming
(
method
))
{
}
else
if
(
ClientOnlyStreaming
(
method
))
{
printer
->
Print
(
printer
->
Print
(
*
vars
,
*
vars
,
"std::unique_ptr< ::grpc::ClientWriter< $Request$>> $Method$("
"$IsVirtual$std::unique_ptr< ::grpc::ClientWriter< $Request$>>"
"::grpc::ClientContext* context, $Response$* response);
\n
"
);
" $Method$("
"::grpc::ClientContext* context, $Response$* response)$IsAbstract$;
\n
"
);
printer
->
Print
(
printer
->
Print
(
*
vars
,
*
vars
,
"std::unique_ptr< ::grpc::ClientAsyncWriter< $Request$>>
Async$Method$(
"
"
$IsVirtual$
std::unique_ptr< ::grpc::ClientAsyncWriter< $Request$>>"
"::grpc::ClientContext* context, $Response$* response, "
"
Async$Method$(
::grpc::ClientContext* context, $Response$* response, "
"::grpc::CompletionQueue* cq, void* tag);
\n
"
);
"::grpc::CompletionQueue* cq, void* tag)
$IsAbstract$
;
\n
"
);
}
else
if
(
ServerOnlyStreaming
(
method
))
{
}
else
if
(
ServerOnlyStreaming
(
method
))
{
printer
->
Print
(
printer
->
Print
(
*
vars
,
*
vars
,
"std::unique_ptr< ::grpc::ClientReader< $Response$>> $Method$("
"$IsVirtual$std::unique_ptr< ::grpc::ClientReader< $Response$>>"
"::grpc::ClientContext* context, const $Request$& request);
\n
"
);
" $Method$(::grpc::ClientContext* context, const $Request$& request)"
printer
->
Print
(
*
vars
,
"$IsAbstract$;
\n
"
);
"std::unique_ptr< ::grpc::ClientAsyncReader< $Response$>> "
printer
->
Print
(
*
vars
,
"$IsVirtual$std::unique_ptr< ::grpc::ClientAsyncReader< $Response$>> "
"Async$Method$("
"Async$Method$("
"::grpc::ClientContext* context, const $Request$& request, "
"::grpc::ClientContext* context, const $Request$& request, "
"::grpc::CompletionQueue* cq, void* tag);
\n
"
);
"::grpc::CompletionQueue* cq, void* tag)
$IsAbstract$
;
\n
"
);
}
else
if
(
BidiStreaming
(
method
))
{
}
else
if
(
BidiStreaming
(
method
))
{
printer
->
Print
(
printer
->
Print
(
*
vars
,
*
vars
,
"$IsVirtual$"
"std::unique_ptr< ::grpc::ClientReaderWriter< $Request$, $Response$>> "
"std::unique_ptr< ::grpc::ClientReaderWriter< $Request$, $Response$>> "
"$Method$(::grpc::ClientContext* context);
\n
"
);
"$Method$(::grpc::ClientContext* context)$IsAbstract$;
\n
"
);
printer
->
Print
(
*
vars
,
printer
->
Print
(
"std::unique_ptr< ::grpc::ClientAsyncReaderWriter< "
*
vars
,
"$IsVirtual$std::unique_ptr< ::grpc::ClientAsyncReaderWriter< "
"$Request$, $Response$>> "
"$Request$, $Response$>> "
"Async$Method$(::grpc::ClientContext* context, "
"Async$Method$(::grpc::ClientContext* context, "
"::grpc::CompletionQueue* cq, void* tag);
\n
"
);
"::grpc::CompletionQueue* cq, void* tag)
$IsAbstract$
;
\n
"
);
}
}
}
}
...
@@ -357,13 +367,24 @@ void PrintHeaderService(grpc::protobuf::io::Printer *printer,
...
@@ -357,13 +367,24 @@ void PrintHeaderService(grpc::protobuf::io::Printer *printer,
// Client side
// Client side
printer
->
Print
(
printer
->
Print
(
"class Stub
GRPC_FINAL : public ::grpc::InternalStub
{
\n
"
"class Stub
Interface
{
\n
"
" public:
\n
"
);
" public:
\n
"
);
printer
->
Indent
();
printer
->
Indent
();
printer
->
Print
(
"StubInterface() {}
\n
"
);
printer
->
Print
(
"virtual ~StubInterface() {}
\n
"
);
for
(
int
i
=
0
;
i
<
service
->
method_count
();
++
i
)
{
PrintHeaderClientMethod
(
printer
,
service
->
method
(
i
),
vars
,
true
);
}
printer
->
Outdent
();
printer
->
Print
(
"};
\n
"
);
printer
->
Print
(
"class Stub GRPC_FINAL : public StubInterface,"
" public ::grpc::InternalStub {
\n
public:
\n
"
);
printer
->
Indent
();
printer
->
Print
(
printer
->
Print
(
"Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel);
\n
"
);
"Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel);
\n
"
);
for
(
int
i
=
0
;
i
<
service
->
method_count
();
++
i
)
{
for
(
int
i
=
0
;
i
<
service
->
method_count
();
++
i
)
{
PrintHeaderClientMethod
(
printer
,
service
->
method
(
i
),
vars
);
PrintHeaderClientMethod
(
printer
,
service
->
method
(
i
),
vars
,
false
);
}
}
printer
->
Outdent
();
printer
->
Outdent
();
printer
->
Print
(
" private:
\n
"
);
printer
->
Print
(
" private:
\n
"
);
...
...
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
sign in
to comment