|
|
|
@ -2147,6 +2147,7 @@ std::string GetMockPrologue(grpc_generator::File* file, |
|
|
|
|
std::map<std::string, std::string> vars; |
|
|
|
|
|
|
|
|
|
vars["filename"] = file->filename(); |
|
|
|
|
vars["filename_identifier"] = FilenameIdentifier(file->filename()); |
|
|
|
|
vars["filename_base"] = file->filename_without_ext(); |
|
|
|
|
vars["message_header_ext"] = params.message_header_extension.empty() |
|
|
|
|
? kCppGeneratorMessageHeaderExt |
|
|
|
@ -2158,6 +2159,9 @@ std::string GetMockPrologue(grpc_generator::File* file, |
|
|
|
|
"// If you make any local change, they will be lost.\n"); |
|
|
|
|
printer->Print(vars, "// source: $filename$\n\n"); |
|
|
|
|
|
|
|
|
|
printer->Print(vars, "#ifndef GRPC_MOCK_$filename_identifier$__INCLUDED\n"); |
|
|
|
|
printer->Print(vars, "#define GRPC_MOCK_$filename_identifier$__INCLUDED\n"); |
|
|
|
|
printer->Print(vars, "\n"); |
|
|
|
|
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) { |
|
|
|
@ -2350,20 +2354,27 @@ std::string GetMockServices(grpc_generator::File* file, |
|
|
|
|
|
|
|
|
|
std::string GetMockEpilogue(grpc_generator::File* file, |
|
|
|
|
const Parameters& /*params*/) { |
|
|
|
|
std::string temp; |
|
|
|
|
|
|
|
|
|
if (!file->package().empty()) { |
|
|
|
|
std::vector<std::string> parts = file->package_parts(); |
|
|
|
|
std::string output; |
|
|
|
|
{ |
|
|
|
|
// Scope the output stream so it closes and finalizes output to the string.
|
|
|
|
|
auto printer = file->CreatePrinter(&output); |
|
|
|
|
std::map<std::string, std::string> vars; |
|
|
|
|
vars["filename_identifier"] = FilenameIdentifier(file->filename()); |
|
|
|
|
|
|
|
|
|
for (auto part = parts.begin(); part != parts.end(); part++) { |
|
|
|
|
temp.append("} // namespace "); |
|
|
|
|
temp.append(*part); |
|
|
|
|
temp.append("\n"); |
|
|
|
|
if (!file->package().empty()) { |
|
|
|
|
std::vector<std::string> parts = file->package_parts(); |
|
|
|
|
for (auto part = parts.rbegin(); part != parts.rend(); part++) { |
|
|
|
|
vars["part"] = *part; |
|
|
|
|
printer->Print(vars, "} // namespace $part$\n"); |
|
|
|
|
} |
|
|
|
|
printer->Print(vars, "\n"); |
|
|
|
|
} |
|
|
|
|
temp.append("\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return temp; |
|
|
|
|
printer->Print(vars, "\n"); |
|
|
|
|
printer->Print(vars, |
|
|
|
|
"#endif // GRPC_MOCK_$filename_identifier$__INCLUDED\n"); |
|
|
|
|
} |
|
|
|
|
return output; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} // namespace grpc_cpp_generator
|
|
|
|
|