mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-05 21:17:25 +00:00
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
This commit is contained in:
@@ -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<const uint8_t *>(contents.c_str()),
|
||||
|
||||
Reference in New Issue
Block a user