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
4e0f73cd
Commit
4e0f73cd
authored
8 years ago
by
Jan Tattermusch
Browse files
Options
Downloads
Patches
Plain Diff
add internal_access option for C# codegen
parent
5f8872f8
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/csharp_generator.cc
+11
-4
11 additions, 4 deletions
src/compiler/csharp_generator.cc
src/compiler/csharp_generator.h
+2
-1
2 additions, 1 deletion
src/compiler/csharp_generator.h
src/compiler/csharp_plugin.cc
+5
-1
5 additions, 1 deletion
src/compiler/csharp_plugin.cc
with
18 additions
and
6 deletions
src/compiler/csharp_generator.cc
+
11
−
4
View file @
4e0f73cd
...
...
@@ -123,6 +123,10 @@ std::string GetMethodRequestParamMaybe(const MethodDescriptor *method,
return
GetClassName
(
method
->
input_type
())
+
" request, "
;
}
std
::
string
GetAccessLevel
(
bool
internal_access
)
{
return
internal_access
?
"internal"
:
"public"
;
}
std
::
string
GetMethodReturnTypeClient
(
const
MethodDescriptor
*
method
)
{
switch
(
GetMethodType
(
method
))
{
case
METHODTYPE_NO_STREAMING
:
...
...
@@ -528,8 +532,10 @@ void GenerateNewStubMethods(Printer* out, const ServiceDescriptor *service) {
}
void
GenerateService
(
Printer
*
out
,
const
ServiceDescriptor
*
service
,
bool
generate_client
,
bool
generate_server
)
{
out
->
Print
(
"public static class $classname$
\n
"
,
"classname"
,
bool
generate_client
,
bool
generate_server
,
bool
internal_access
)
{
out
->
Print
(
"$access_level$ static class $classname$
\n
"
,
"access_level"
,
GetAccessLevel
(
internal_access
),
"classname"
,
GetServiceClassName
(
service
));
out
->
Print
(
"{
\n
"
);
out
->
Indent
();
...
...
@@ -567,7 +573,7 @@ void GenerateService(Printer* out, const ServiceDescriptor *service,
}
// anonymous namespace
grpc
::
string
GetServices
(
const
FileDescriptor
*
file
,
bool
generate_client
,
bool
generate_server
)
{
bool
generate_server
,
bool
internal_access
)
{
grpc
::
string
output
;
{
// Scope the output stream so it closes and finalizes output to the string.
...
...
@@ -595,7 +601,8 @@ grpc::string GetServices(const FileDescriptor *file, bool generate_client,
out
.
Print
(
"namespace $namespace$ {
\n
"
,
"namespace"
,
GetFileNamespace
(
file
));
out
.
Indent
();
for
(
int
i
=
0
;
i
<
file
->
service_count
();
i
++
)
{
GenerateService
(
&
out
,
file
->
service
(
i
),
generate_client
,
generate_server
);
GenerateService
(
&
out
,
file
->
service
(
i
),
generate_client
,
generate_server
,
internal_access
);
}
out
.
Outdent
();
out
.
Print
(
"}
\n
"
);
...
...
This diff is collapsed.
Click to expand it.
src/compiler/csharp_generator.h
+
2
−
1
View file @
4e0f73cd
...
...
@@ -41,7 +41,8 @@
namespace
grpc_csharp_generator
{
grpc
::
string
GetServices
(
const
grpc
::
protobuf
::
FileDescriptor
*
file
,
bool
generate_client
,
bool
generate_server
);
bool
generate_client
,
bool
generate_server
,
bool
internal_access
);
}
// namespace grpc_csharp_generator
...
...
This diff is collapsed.
Click to expand it.
src/compiler/csharp_plugin.cc
+
5
−
1
View file @
4e0f73cd
...
...
@@ -53,11 +53,14 @@ class CSharpGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
bool
generate_client
=
true
;
bool
generate_server
=
true
;
bool
internal_access
=
false
;
for
(
size_t
i
=
0
;
i
<
options
.
size
();
i
++
)
{
if
(
options
[
i
].
first
==
"no_client"
)
{
generate_client
=
false
;
}
else
if
(
options
[
i
].
first
==
"no_server"
)
{
generate_server
=
false
;
}
else
if
(
options
[
i
].
first
==
"internal_access"
)
{
internal_access
=
true
;
}
else
{
*
error
=
"Unknown generator option: "
+
options
[
i
].
first
;
return
false
;
...
...
@@ -66,7 +69,8 @@ class CSharpGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
grpc
::
string
code
=
grpc_csharp_generator
::
GetServices
(
file
,
generate_client
,
generate_server
);
generate_server
,
internal_access
);
if
(
code
.
size
()
==
0
)
{
return
true
;
// don't generate a file if there are no services
}
...
...
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