aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compiler/csharp_generator.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/csharp_generator.cc')
-rw-r--r--src/compiler/csharp_generator.cc82
1 files changed, 70 insertions, 12 deletions
diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc
index e0c1bcda19..9432bdda96 100644
--- a/src/compiler/csharp_generator.cc
+++ b/src/compiler/csharp_generator.cc
@@ -246,6 +246,8 @@ void GenerateStaticMethodField(Printer* out, const MethodDescriptor *method) {
out->Indent();
out->Print("$methodtype$,\n", "methodtype",
GetCSharpMethodType(GetMethodType(method)));
+ out->Print("$servicenamefield$,\n", "servicenamefield",
+ GetServiceNameFieldName());
out->Print("\"$methodname$\",\n", "methodname", method->name());
out->Print("$requestmarshaller$,\n", "requestmarshaller",
GetMarshallerFieldName(method->input_type()));
@@ -273,6 +275,13 @@ void GenerateClientInterface(Printer* out, const ServiceDescriptor *service) {
"methodname", method->name(), "request",
GetClassName(method->input_type()), "response",
GetClassName(method->output_type()));
+
+ // overload taking CallOptions as a param
+ out->Print(
+ "$response$ $methodname$($request$ request, CallOptions options);\n",
+ "methodname", method->name(), "request",
+ GetClassName(method->input_type()), "response",
+ GetClassName(method->output_type()));
}
std::string method_name = method->name();
@@ -284,6 +293,13 @@ void GenerateClientInterface(Printer* out, const ServiceDescriptor *service) {
"methodname", method_name, "request_maybe",
GetMethodRequestParamMaybe(method), "returntype",
GetMethodReturnTypeClient(method));
+
+ // overload taking CallOptions as a param
+ out->Print(
+ "$returntype$ $methodname$($request_maybe$CallOptions options);\n",
+ "methodname", method_name, "request_maybe",
+ GetMethodRequestParamMaybe(method), "returntype",
+ GetMethodReturnTypeClient(method));
}
out->Outdent();
out->Print("}\n");
@@ -340,10 +356,23 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor *service) {
GetClassName(method->output_type()));
out->Print("{\n");
out->Indent();
- out->Print("var call = CreateCall($servicenamefield$, $methodfield$, headers, deadline);\n",
- "servicenamefield", GetServiceNameFieldName(), "methodfield",
- GetMethodFieldName(method));
- out->Print("return Calls.BlockingUnaryCall(call, request, cancellationToken);\n");
+ out->Print("var call = CreateCall($methodfield$, new CallOptions(headers, deadline, cancellationToken));\n",
+ "methodfield", GetMethodFieldName(method));
+ out->Print("return Calls.BlockingUnaryCall(call, request);\n");
+ out->Outdent();
+ out->Print("}\n");
+
+ // overload taking CallOptions as a param
+ out->Print(
+ "public $response$ $methodname$($request$ request, CallOptions options)\n",
+ "methodname", method->name(), "request",
+ GetClassName(method->input_type()), "response",
+ GetClassName(method->output_type()));
+ out->Print("{\n");
+ out->Indent();
+ out->Print("var call = CreateCall($methodfield$, options);\n",
+ "methodfield", GetMethodFieldName(method));
+ out->Print("return Calls.BlockingUnaryCall(call, request);\n");
out->Outdent();
out->Print("}\n");
}
@@ -359,26 +388,55 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor *service) {
GetMethodReturnTypeClient(method));
out->Print("{\n");
out->Indent();
- out->Print("var call = CreateCall($servicenamefield$, $methodfield$, headers, deadline);\n",
- "servicenamefield", GetServiceNameFieldName(), "methodfield",
- GetMethodFieldName(method));
+ out->Print("var call = CreateCall($methodfield$, new CallOptions(headers, deadline, cancellationToken));\n",
+ "methodfield", GetMethodFieldName(method));
switch (GetMethodType(method)) {
case METHODTYPE_NO_STREAMING:
- out->Print("return Calls.AsyncUnaryCall(call, request, cancellationToken);\n");
+ out->Print("return Calls.AsyncUnaryCall(call, request);\n");
break;
case METHODTYPE_CLIENT_STREAMING:
- out->Print("return Calls.AsyncClientStreamingCall(call, cancellationToken);\n");
+ out->Print("return Calls.AsyncClientStreamingCall(call);\n");
break;
case METHODTYPE_SERVER_STREAMING:
out->Print(
- "return Calls.AsyncServerStreamingCall(call, request, cancellationToken);\n");
+ "return Calls.AsyncServerStreamingCall(call, request);\n");
break;
case METHODTYPE_BIDI_STREAMING:
- out->Print("return Calls.AsyncDuplexStreamingCall(call, cancellationToken);\n");
+ out->Print("return Calls.AsyncDuplexStreamingCall(call);\n");
break;
default:
GOOGLE_LOG(FATAL)<< "Can't get here.";
- }
+ }
+ out->Outdent();
+ out->Print("}\n");
+
+ // overload taking CallOptions as a param
+ out->Print(
+ "public $returntype$ $methodname$($request_maybe$CallOptions options)\n",
+ "methodname", method_name, "request_maybe",
+ GetMethodRequestParamMaybe(method), "returntype",
+ GetMethodReturnTypeClient(method));
+ out->Print("{\n");
+ out->Indent();
+ out->Print("var call = CreateCall($methodfield$, options);\n",
+ "methodfield", GetMethodFieldName(method));
+ switch (GetMethodType(method)) {
+ case METHODTYPE_NO_STREAMING:
+ out->Print("return Calls.AsyncUnaryCall(call, request);\n");
+ break;
+ case METHODTYPE_CLIENT_STREAMING:
+ out->Print("return Calls.AsyncClientStreamingCall(call);\n");
+ break;
+ case METHODTYPE_SERVER_STREAMING:
+ out->Print(
+ "return Calls.AsyncServerStreamingCall(call, request);\n");
+ break;
+ case METHODTYPE_BIDI_STREAMING:
+ out->Print("return Calls.AsyncDuplexStreamingCall(call);\n");
+ break;
+ default:
+ GOOGLE_LOG(FATAL)<< "Can't get here.";
+ }
out->Outdent();
out->Print("}\n");
}