From d9d47a53bd254ad9855de4ff98336f0a9c257545 Mon Sep 17 00:00:00 2001 From: Raman Date: Sat, 9 Jul 2016 12:40:50 +0200 Subject: [PATCH] Update idl_gen_fbs.cpp --- src/idl_gen_fbs.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/idl_gen_fbs.cpp b/src/idl_gen_fbs.cpp index 5bbf39073..c391ed698 100644 --- a/src/idl_gen_fbs.cpp +++ b/src/idl_gen_fbs.cpp @@ -52,18 +52,18 @@ static void GenNameSpace(const Namespace &name_space, std::string *_schema, } // Generate a flatbuffer schema from the Parser's internal representation. -std::string GenerateFBS(const Parser &parser, const std::string &file_name, const bool &escape_proto_identifiers) { +std::string GenerateFBS(const Parser &parser, const std::string &file_name) { // Proto namespaces may clash with table names, so we have to prefix all: - - if (!escape_proto_identifiers) { - for (auto it = parser.namespaces_.begin(); it != parser.namespaces_.end(); - ++it) { - for (auto comp = (*it)->components.begin(); comp != (*it)->components.end(); - ++comp) { - (*comp) = "_" + (*comp); - } - } + if (!parser.opts.escape_proto_identifiers) { + for (auto it = parser.namespaces_.begin(); it != parser.namespaces_.end(); + ++it) { + for (auto comp = (*it)->components.begin(); comp != (*it)->components.end(); + ++comp) { + (*comp) = "_" + (*comp); + } + } } + std::string schema; schema += "// Generated from " + file_name + ".proto\n\n"; if (parser.opts.include_dependence_headers) { @@ -121,10 +121,9 @@ std::string GenerateFBS(const Parser &parser, const std::string &file_name, cons bool GenerateFBS(const Parser &parser, const std::string &path, - const std::string &file_name, - const bool &escape_proto_identifiers) { + const std::string &file_name) { return SaveFile((path + file_name + ".fbs").c_str(), - GenerateFBS(parser, file_name, escape_proto_identifiers), false); + GenerateFBS(parser, file_name), false); } } // namespace flatbuffers