mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-08 14:15:17 +00:00
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:
committed by
GitHub
parent
e47dc0e465
commit
fadd40e402
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user