From 338331b55ba9cbc395ac7f473c7853c3e3c0b765 Mon Sep 17 00:00:00 2001 From: Herr Frei Date: Wed, 8 Sep 2021 22:19:00 +0200 Subject: [PATCH] Changes to support binary schema file loading and parsing (flatc) (#6823) * Changes to support binary schema file loading and parsing (flatc) - parser.reset() is also called if binary schema file is given - code flow changed to not try to load a binary schema as textual schema * Removed unneeded braces --- src/flatc.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/flatc.cpp b/src/flatc.cpp index 569d41c2e..f759c6651 100644 --- a/src/flatc.cpp +++ b/src/flatc.cpp @@ -482,16 +482,17 @@ int FlatCompiler::Compile(int argc, const char **argv) { contents.length() != strlen(contents.c_str())) { Error("input file appears to be binary: " + filename, true); } - if (is_schema) { + if (is_schema || is_binary_schema) { // If we're processing multiple schemas, make sure to start each // one from scratch. If it depends on previous schemas it must do // so explicitly using an include. parser.reset(new flatbuffers::Parser(opts)); } + // Try to parse the file contents (binary schema/flexbuffer/textual + // schema) if (is_binary_schema) { LoadBinarySchema(*parser.get(), filename, contents); - } - if (opts.use_flexbuffers) { + } else if (opts.use_flexbuffers) { if (opts.lang_to_generate == IDLOptions::kJson) { parser->flex_root_ = flexbuffers::GetRoot( reinterpret_cast(contents.c_str()),