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
b015dfb5
Commit
b015dfb5
authored
9 years ago
by
Jorge Canizales
Browse files
Options
Downloads
Patches
Plain Diff
Add ::grpc:: prefix
parent
685674c5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/compiler/objective_c_generator.cc
+16
-17
16 additions, 17 deletions
src/compiler/objective_c_generator.cc
src/compiler/objective_c_plugin.cc
+14
-14
14 additions, 14 deletions
src/compiler/objective_c_plugin.cc
with
30 additions
and
31 deletions
src/compiler/objective_c_generator.cc
+
16
−
17
View file @
b015dfb5
...
...
@@ -44,7 +44,6 @@ using ::google::protobuf::compiler::objectivec::ClassName;
using
::
grpc
::
protobuf
::
io
::
Printer
;
using
::
grpc
::
protobuf
::
MethodDescriptor
;
using
::
grpc
::
protobuf
::
ServiceDescriptor
;
using
::
grpc
::
string
;
using
::
std
::
map
;
namespace
grpc_objective_c_generator
{
...
...
@@ -52,7 +51,7 @@ namespace {
void
PrintProtoRpcDeclarationAsPragma
(
Printer
*
printer
,
const
MethodDescriptor
*
method
,
map
<
string
,
string
>
vars
)
{
map
<
::
grpc
::
string
,
::
grpc
::
string
>
vars
)
{
vars
[
"client_stream"
]
=
method
->
client_streaming
()
?
"stream "
:
""
;
vars
[
"server_stream"
]
=
method
->
server_streaming
()
?
"stream "
:
""
;
...
...
@@ -62,7 +61,7 @@ void PrintProtoRpcDeclarationAsPragma(Printer *printer,
}
void
PrintMethodSignature
(
Printer
*
printer
,
const
MethodDescriptor
*
method
,
const
map
<
string
,
string
>
&
vars
)
{
const
map
<
::
grpc
::
string
,
::
grpc
::
string
>
&
vars
)
{
// TODO(jcanizales): Print method comments.
printer
->
Print
(
vars
,
"- ($return_type$)$method_name$With"
);
...
...
@@ -85,7 +84,7 @@ void PrintMethodSignature(Printer *printer, const MethodDescriptor *method,
}
void
PrintSimpleSignature
(
Printer
*
printer
,
const
MethodDescriptor
*
method
,
map
<
string
,
string
>
vars
)
{
map
<
::
grpc
::
string
,
::
grpc
::
string
>
vars
)
{
vars
[
"method_name"
]
=
grpc_generator
::
LowercaseFirstLetter
(
vars
[
"method_name"
]);
vars
[
"return_type"
]
=
"void"
;
...
...
@@ -93,14 +92,14 @@ void PrintSimpleSignature(Printer *printer, const MethodDescriptor *method,
}
void
PrintAdvancedSignature
(
Printer
*
printer
,
const
MethodDescriptor
*
method
,
map
<
string
,
string
>
vars
)
{
map
<
::
grpc
::
string
,
::
grpc
::
string
>
vars
)
{
vars
[
"method_name"
]
=
"RPCTo"
+
vars
[
"method_name"
];
vars
[
"return_type"
]
=
"ProtoRPC *"
;
PrintMethodSignature
(
printer
,
method
,
vars
);
}
inline
map
<
string
,
string
>
GetMethodVars
(
const
MethodDescriptor
*
method
)
{
map
<
string
,
string
>
res
;
inline
map
<
::
grpc
::
string
,
::
grpc
::
string
>
GetMethodVars
(
const
MethodDescriptor
*
method
)
{
map
<
::
grpc
::
string
,
::
grpc
::
string
>
res
;
res
[
"method_name"
]
=
method
->
name
();
res
[
"request_type"
]
=
method
->
input_type
()
->
name
();
res
[
"response_type"
]
=
method
->
output_type
()
->
name
();
...
...
@@ -110,7 +109,7 @@ inline map<string, string> GetMethodVars(const MethodDescriptor *method) {
}
void
PrintMethodDeclarations
(
Printer
*
printer
,
const
MethodDescriptor
*
method
)
{
map
<
string
,
string
>
vars
=
GetMethodVars
(
method
);
map
<
::
grpc
::
string
,
::
grpc
::
string
>
vars
=
GetMethodVars
(
method
);
PrintProtoRpcDeclarationAsPragma
(
printer
,
method
,
vars
);
...
...
@@ -121,7 +120,7 @@ void PrintMethodDeclarations(Printer *printer, const MethodDescriptor *method) {
}
void
PrintSimpleImplementation
(
Printer
*
printer
,
const
MethodDescriptor
*
method
,
map
<
string
,
string
>
vars
)
{
map
<
::
grpc
::
string
,
::
grpc
::
string
>
vars
)
{
printer
->
Print
(
"{
\n
"
);
printer
->
Print
(
vars
,
" [[self RPCTo$method_name$With"
);
if
(
method
->
client_streaming
())
{
...
...
@@ -139,7 +138,7 @@ void PrintSimpleImplementation(Printer *printer, const MethodDescriptor *method,
void
PrintAdvancedImplementation
(
Printer
*
printer
,
const
MethodDescriptor
*
method
,
map
<
string
,
string
>
vars
)
{
map
<
::
grpc
::
string
,
::
grpc
::
string
>
vars
)
{
printer
->
Print
(
"{
\n
"
);
printer
->
Print
(
vars
,
" return [self RPCToMethod:@
\"
$method_name$
\"\n
"
);
...
...
@@ -164,7 +163,7 @@ void PrintAdvancedImplementation(Printer *printer,
void
PrintMethodImplementations
(
Printer
*
printer
,
const
MethodDescriptor
*
method
)
{
map
<
string
,
string
>
vars
=
GetMethodVars
(
method
);
map
<
::
grpc
::
string
,
::
grpc
::
string
>
vars
=
GetMethodVars
(
method
);
PrintProtoRpcDeclarationAsPragma
(
printer
,
method
,
vars
);
...
...
@@ -179,14 +178,14 @@ void PrintMethodImplementations(Printer *printer,
}
// namespace
string
GetHeader
(
const
ServiceDescriptor
*
service
)
{
string
output
;
::
grpc
::
string
GetHeader
(
const
ServiceDescriptor
*
service
)
{
::
grpc
::
string
output
;
{
// Scope the output stream so it closes and finalizes output to the string.
grpc
::
protobuf
::
io
::
StringOutputStream
output_stream
(
&
output
);
Printer
printer
(
&
output_stream
,
'$'
);
map
<
string
,
string
>
vars
=
{{
"service_class"
,
ServiceClassName
(
service
)}};
map
<
::
grpc
::
string
,
::
grpc
::
string
>
vars
=
{{
"service_class"
,
ServiceClassName
(
service
)}};
printer
.
Print
(
vars
,
"@protocol $service_class$ <NSObject>
\n\n
"
);
...
...
@@ -209,14 +208,14 @@ string GetHeader(const ServiceDescriptor *service) {
return
output
;
}
string
GetSource
(
const
ServiceDescriptor
*
service
)
{
string
output
;
::
grpc
::
string
GetSource
(
const
ServiceDescriptor
*
service
)
{
::
grpc
::
string
output
;
{
// Scope the output stream so it closes and finalizes output to the string.
grpc
::
protobuf
::
io
::
StringOutputStream
output_stream
(
&
output
);
Printer
printer
(
&
output_stream
,
'$'
);
map
<
string
,
string
>
vars
=
{{
"service_name"
,
service
->
name
()},
map
<
::
grpc
::
string
,
::
grpc
::
string
>
vars
=
{{
"service_name"
,
service
->
name
()},
{
"service_class"
,
ServiceClassName
(
service
)},
{
"package"
,
service
->
file
()
->
package
()}};
...
...
This diff is collapsed.
Click to expand it.
src/compiler/objective_c_plugin.cc
+
14
−
14
View file @
b015dfb5
...
...
@@ -39,44 +39,43 @@
#include
"src/compiler/objective_c_generator.h"
#include
"src/compiler/objective_c_generator_helpers.h"
using
::
grpc
::
string
;
class
ObjectiveCGrpcGenerator
:
public
grpc
::
protobuf
::
compiler
::
CodeGenerator
{
public:
ObjectiveCGrpcGenerator
()
{}
virtual
~
ObjectiveCGrpcGenerator
()
{}
virtual
bool
Generate
(
const
grpc
::
protobuf
::
FileDescriptor
*
file
,
const
string
&
parameter
,
const
::
grpc
::
string
&
parameter
,
grpc
::
protobuf
::
compiler
::
GeneratorContext
*
context
,
string
*
error
)
const
{
::
grpc
::
string
*
error
)
const
{
if
(
file
->
service_count
()
==
0
)
{
// No services. Do nothing.
return
true
;
}
string
file_name
=
grpc_generator
::
FileNameInUpperCamel
(
file
);
string
prefix
=
file
->
options
().
objc_class_prefix
();
::
grpc
::
string
file_name
=
grpc_generator
::
FileNameInUpperCamel
(
file
);
::
grpc
::
string
prefix
=
file
->
options
().
objc_class_prefix
();
{
// Generate .pbrpc.h
string
imports
=
string
(
"#import
\"
"
)
+
file_name
+
".pbobjc.h
\"\n\n
"
::
grpc
::
string
imports
=
::
grpc
::
string
(
"#import
\"
"
)
+
file_name
+
".pbobjc.h
\"\n\n
"
"#import <ProtoRPC/ProtoService.h>
\n
"
"#import <RxLibrary/GRXWriteable.h>
\n
"
"#import <RxLibrary/GRXWriter.h>
\n
"
;
// TODO(jcanizales): Instead forward-declare the input and output types
// and import the files in the .pbrpc.m
string
proto_imports
;
::
grpc
::
string
proto_imports
;
for
(
int
i
=
0
;
i
<
file
->
dependency_count
();
i
++
)
{
string
header
=
grpc_objective_c_generator
::
MessageHeaderName
(
::
grpc
::
string
header
=
grpc_objective_c_generator
::
MessageHeaderName
(
file
->
dependency
(
i
));
proto_imports
+=
string
(
"#import
\"
"
)
+
header
+
"
\"\n
"
;
proto_imports
+=
::
grpc
::
string
(
"#import
\"
"
)
+
header
+
"
\"\n
"
;
}
string
declarations
;
::
grpc
::
string
declarations
;
for
(
int
i
=
0
;
i
<
file
->
service_count
();
i
++
)
{
const
grpc
::
protobuf
::
ServiceDescriptor
*
service
=
file
->
service
(
i
);
declarations
+=
grpc_objective_c_generator
::
GetHeader
(
service
);
...
...
@@ -89,11 +88,12 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
{
// Generate .pbrpc.m
string
imports
=
string
(
"#import
\"
"
)
+
file_name
+
".pbrpc.h
\"\n\n
"
::
grpc
::
string
imports
=
::
grpc
::
string
(
"#import
\"
"
)
+
file_name
+
".pbrpc.h
\"\n\n
"
"#import <ProtoRPC/ProtoRPC.h>
\n
"
"#import <RxLibrary/GRXWriter+Immediate.h>
\n
"
;
string
definitions
;
::
grpc
::
string
definitions
;
for
(
int
i
=
0
;
i
<
file
->
service_count
();
i
++
)
{
const
grpc
::
protobuf
::
ServiceDescriptor
*
service
=
file
->
service
(
i
);
definitions
+=
grpc_objective_c_generator
::
GetSource
(
service
);
...
...
@@ -108,7 +108,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
private
:
// Write the given code into the given file.
void
Write
(
grpc
::
protobuf
::
compiler
::
GeneratorContext
*
context
,
const
string
&
filename
,
const
string
&
code
)
const
{
const
::
grpc
::
string
&
filename
,
const
::
grpc
::
string
&
code
)
const
{
std
::
unique_ptr
<
grpc
::
protobuf
::
io
::
ZeroCopyOutputStream
>
output
(
context
->
Open
(
filename
));
grpc
::
protobuf
::
io
::
CodedOutputStream
coded_out
(
output
.
get
());
...
...
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