(Optionally) add an additional suffix namespace to generated fbs files. (#5698)

This change allows for the generation of fbs files (from proto) that
don't contain name collisions with the protobuf generated C++ code,
allowing both the proto and fbs message types to be linked into the same binary.
This commit is contained in:
Michael Beardsworth
2020-01-06 10:00:59 -08:00
committed by Wouter van Oortmerssen
parent 35daaf83d3
commit 21b7061963
7 changed files with 190 additions and 0 deletions

View File

@@ -63,6 +63,13 @@ std::string GenerateFBS(const Parser &parser, const std::string &file_name) {
for (size_t i = 0; i < ns.from_table; i++) {
ns.components[ns.components.size() - 1 - i] += "_";
}
if (parser.opts.proto_mode && !parser.opts.proto_namespace_suffix.empty()) {
// Since we know that all these namespaces come from a .proto, and all are
// being converted, we can simply apply this suffix to all of them.
ns.components.insert(ns.components.end() - ns.from_table,
parser.opts.proto_namespace_suffix);
}
}
std::string schema;