|
|
|
@ -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: |
|
|
|
@ -527,8 +531,11 @@ void GenerateNewStubMethods(Printer* out, const ServiceDescriptor *service) { |
|
|
|
|
out->Print("\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GenerateService(Printer* out, const ServiceDescriptor *service) { |
|
|
|
|
out->Print("public static class $classname$\n", "classname", |
|
|
|
|
void GenerateService(Printer* out, const ServiceDescriptor *service, |
|
|
|
|
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(); |
|
|
|
@ -542,13 +549,22 @@ void GenerateService(Printer* out, const ServiceDescriptor *service) { |
|
|
|
|
GenerateStaticMethodField(out, service->method(i)); |
|
|
|
|
} |
|
|
|
|
GenerateServiceDescriptorProperty(out, service); |
|
|
|
|
GenerateClientInterface(out, service); |
|
|
|
|
GenerateServerInterface(out, service); |
|
|
|
|
GenerateServerClass(out, service); |
|
|
|
|
GenerateClientStub(out, service); |
|
|
|
|
GenerateBindServiceMethod(out, service, false); |
|
|
|
|
GenerateBindServiceMethod(out, service, true); |
|
|
|
|
GenerateNewStubMethods(out, service); |
|
|
|
|
|
|
|
|
|
if (generate_client) { |
|
|
|
|
GenerateClientInterface(out, service); |
|
|
|
|
} |
|
|
|
|
if (generate_server) { |
|
|
|
|
GenerateServerInterface(out, service); |
|
|
|
|
GenerateServerClass(out, service); |
|
|
|
|
} |
|
|
|
|
if (generate_client) { |
|
|
|
|
GenerateClientStub(out, service); |
|
|
|
|
GenerateNewStubMethods(out, service); |
|
|
|
|
} |
|
|
|
|
if (generate_server) { |
|
|
|
|
GenerateBindServiceMethod(out, service, false); |
|
|
|
|
GenerateBindServiceMethod(out, service, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
out->Outdent(); |
|
|
|
|
out->Print("}\n"); |
|
|
|
@ -556,7 +572,8 @@ void GenerateService(Printer* out, const ServiceDescriptor *service) { |
|
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
|
|
grpc::string GetServices(const FileDescriptor *file) { |
|
|
|
|
grpc::string GetServices(const FileDescriptor *file, bool generate_client, |
|
|
|
|
bool generate_server, bool internal_access) { |
|
|
|
|
grpc::string output; |
|
|
|
|
{ |
|
|
|
|
// Scope the output stream so it closes and finalizes output to the string.
|
|
|
|
@ -584,7 +601,8 @@ grpc::string GetServices(const FileDescriptor *file) { |
|
|
|
|
out.Print("namespace $namespace$ {\n", "namespace", GetFileNamespace(file)); |
|
|
|
|
out.Indent(); |
|
|
|
|
for (int i = 0; i < file->service_count(); i++) { |
|
|
|
|
GenerateService(&out, file->service(i)); |
|
|
|
|
GenerateService(&out, file->service(i), generate_client, generate_server, |
|
|
|
|
internal_access); |
|
|
|
|
} |
|
|
|
|
out.Outdent(); |
|
|
|
|
out.Print("}\n"); |
|
|
|
|