|
|
|
@ -84,7 +84,7 @@ void PrintIncludes(grpc_generator::Printer* printer, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
grpc::string GetHeaderPrologue(grpc_generator::File* file, |
|
|
|
|
const Parameters& /*params*/) { |
|
|
|
|
const Parameters& params) { |
|
|
|
|
grpc::string output; |
|
|
|
|
{ |
|
|
|
|
// Scope the output stream so it closes and finalizes output to the string.
|
|
|
|
@ -94,7 +94,9 @@ grpc::string GetHeaderPrologue(grpc_generator::File* file, |
|
|
|
|
vars["filename"] = file->filename(); |
|
|
|
|
vars["filename_identifier"] = FilenameIdentifier(file->filename()); |
|
|
|
|
vars["filename_base"] = file->filename_without_ext(); |
|
|
|
|
vars["message_header_ext"] = kCppGeneratorMessageHeaderExt; |
|
|
|
|
vars["message_header_ext"] = params.message_header_extension.empty() |
|
|
|
|
? kCppGeneratorMessageHeaderExt |
|
|
|
|
: params.message_header_extension; |
|
|
|
|
|
|
|
|
|
printer->Print(vars, "// Generated by the gRPC C++ plugin.\n"); |
|
|
|
|
printer->Print(vars, |
|
|
|
@ -115,6 +117,13 @@ grpc::string GetHeaderPrologue(grpc_generator::File* file, |
|
|
|
|
return output; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Convert from "a/b/c.proto" to "#include \"a/b/c$message_header_ext$\"\n"
|
|
|
|
|
grpc::string ImportInludeFromProtoName(const grpc::string& proto_name) { |
|
|
|
|
return grpc::string("#include \"") + |
|
|
|
|
proto_name.substr(0, proto_name.size() - 6) + |
|
|
|
|
grpc::string("$message_header_ext$\"\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
grpc::string GetHeaderIncludes(grpc_generator::File* file, |
|
|
|
|
const Parameters& params) { |
|
|
|
|
grpc::string output; |
|
|
|
@ -152,6 +161,20 @@ grpc::string GetHeaderIncludes(grpc_generator::File* file, |
|
|
|
|
printer->Print(vars, "class ServerContext;\n"); |
|
|
|
|
printer->Print(vars, "} // namespace grpc\n\n"); |
|
|
|
|
|
|
|
|
|
vars["message_header_ext"] = params.message_header_extension.empty() |
|
|
|
|
? kCppGeneratorMessageHeaderExt |
|
|
|
|
: params.message_header_extension; |
|
|
|
|
|
|
|
|
|
if (params.include_import_headers) { |
|
|
|
|
const std::vector<grpc::string> import_names = file->GetImportNames(); |
|
|
|
|
for (const auto& import_name : import_names) { |
|
|
|
|
const grpc::string include_name = |
|
|
|
|
ImportInludeFromProtoName(import_name); |
|
|
|
|
printer->Print(vars, include_name.c_str()); |
|
|
|
|
} |
|
|
|
|
printer->PrintRaw("\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!file->package().empty()) { |
|
|
|
|
std::vector<grpc::string> parts = file->package_parts(); |
|
|
|
|
|
|
|
|
@ -1556,7 +1579,7 @@ grpc::string GetHeaderEpilogue(grpc_generator::File* file, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
grpc::string GetSourcePrologue(grpc_generator::File* file, |
|
|
|
|
const Parameters& /*params*/) { |
|
|
|
|
const Parameters& params) { |
|
|
|
|
grpc::string output; |
|
|
|
|
{ |
|
|
|
|
// Scope the output stream so it closes and finalizes output to the string.
|
|
|
|
@ -1565,7 +1588,9 @@ grpc::string GetSourcePrologue(grpc_generator::File* file, |
|
|
|
|
|
|
|
|
|
vars["filename"] = file->filename(); |
|
|
|
|
vars["filename_base"] = file->filename_without_ext(); |
|
|
|
|
vars["message_header_ext"] = kCppGeneratorMessageHeaderExt; |
|
|
|
|
vars["message_header_ext"] = params.message_header_extension.empty() |
|
|
|
|
? kCppGeneratorMessageHeaderExt |
|
|
|
|
: params.message_header_extension; |
|
|
|
|
vars["service_header_ext"] = kCppGeneratorServiceHeaderExt; |
|
|
|
|
|
|
|
|
|
printer->Print(vars, "// Generated by the gRPC C++ plugin.\n"); |
|
|
|
@ -1587,7 +1612,6 @@ grpc::string GetSourceIncludes(grpc_generator::File* file, |
|
|
|
|
// Scope the output stream so it closes and finalizes output to the string.
|
|
|
|
|
auto printer = file->CreatePrinter(&output); |
|
|
|
|
std::map<grpc::string, grpc::string> vars; |
|
|
|
|
|
|
|
|
|
static const char* headers_strs[] = { |
|
|
|
|
"functional", |
|
|
|
|
"grpcpp/impl/codegen/async_stream.h", |
|
|
|
@ -2046,7 +2070,7 @@ grpc::string GetSourceEpilogue(grpc_generator::File* file, |
|
|
|
|
|
|
|
|
|
// TODO(mmukhi): Make sure we need parameters or not.
|
|
|
|
|
grpc::string GetMockPrologue(grpc_generator::File* file, |
|
|
|
|
const Parameters& /*params*/) { |
|
|
|
|
const Parameters& params) { |
|
|
|
|
grpc::string output; |
|
|
|
|
{ |
|
|
|
|
// Scope the output stream so it closes and finalizes output to the string.
|
|
|
|
@ -2055,7 +2079,9 @@ grpc::string GetMockPrologue(grpc_generator::File* file, |
|
|
|
|
|
|
|
|
|
vars["filename"] = file->filename(); |
|
|
|
|
vars["filename_base"] = file->filename_without_ext(); |
|
|
|
|
vars["message_header_ext"] = kCppGeneratorMessageHeaderExt; |
|
|
|
|
vars["message_header_ext"] = params.message_header_extension.empty() |
|
|
|
|
? kCppGeneratorMessageHeaderExt |
|
|
|
|
: params.message_header_extension; |
|
|
|
|
vars["service_header_ext"] = kCppGeneratorServiceHeaderExt; |
|
|
|
|
|
|
|
|
|
printer->Print(vars, "// Generated by the gRPC C++ plugin.\n"); |
|
|
|
@ -2065,6 +2091,15 @@ grpc::string GetMockPrologue(grpc_generator::File* file, |
|
|
|
|
|
|
|
|
|
printer->Print(vars, "#include \"$filename_base$$message_header_ext$\"\n"); |
|
|
|
|
printer->Print(vars, "#include \"$filename_base$$service_header_ext$\"\n"); |
|
|
|
|
if (params.include_import_headers) { |
|
|
|
|
const std::vector<grpc::string> import_names = file->GetImportNames(); |
|
|
|
|
for (const auto& import_name : import_names) { |
|
|
|
|
const grpc::string include_name = |
|
|
|
|
ImportInludeFromProtoName(import_name); |
|
|
|
|
printer->Print(vars, include_name.c_str()); |
|
|
|
|
} |
|
|
|
|
printer->PrintRaw("\n"); |
|
|
|
|
} |
|
|
|
|
printer->Print(vars, file->additional_headers().c_str()); |
|
|
|
|
printer->Print(vars, "\n"); |
|
|
|
|
} |
|
|
|
|