Have grpc include file with correct filename-suffix given to flatc (#6954)

When generating code with --grpc,  --cpp and using filename-suffix, the generated grpc files where not including the correct header that had the filename-suffix. As a suffix, they used the default "_generated".
Free functions for these were used to get the suffix. FlatBufFile had such methods, but also needed to be into its base File and use these.
- grpc generated files include the correct message header.
- grpc generated files also have the suffix
- grpc generated cc file does not include initial message header
This commit is contained in:
Panagiotis Gourgaris
2021-12-02 19:49:12 +02:00
committed by GitHub
parent e47dc0e465
commit fadd40e402
3 changed files with 18 additions and 10 deletions

View File

@@ -242,9 +242,13 @@ class FlatBufFile : public grpc_generator::File {
return StripExtension(file_name_);
}
std::string message_header_ext() const { return "_generated.h"; }
std::string message_header_ext() const {
return parser_.opts.filename_suffix + ".h";
}
std::string service_header_ext() const { return ".grpc.fb.h"; }
std::string service_header_ext() const {
return parser_.opts.filename_suffix + ".grpc.fb.h";
}
std::string package() const {
return parser_.current_namespace_->GetFullyQualifiedName("");
@@ -370,10 +374,14 @@ bool GenerateCppGRPC(const Parser &parser, const std::string &path,
grpc_cpp_generator::GetSourceServices(&fbfile, generator_parameters) +
grpc_cpp_generator::GetSourceEpilogue(&fbfile, generator_parameters);
return flatbuffers::SaveFile((path + file_name + ".grpc.fb.h").c_str(),
header_code, false) &&
flatbuffers::SaveFile((path + file_name + ".grpc.fb.cc").c_str(),
source_code, false);
return flatbuffers::SaveFile(
(path + file_name + parser.opts.filename_suffix + ".grpc.fb.h")
.c_str(),
header_code, false) &&
flatbuffers::SaveFile(
(path + file_name + parser.opts.filename_suffix + ".grpc.fb.cc")
.c_str(),
source_code, false);
}
class JavaGRPCGenerator : public flatbuffers::BaseGenerator {