diff --git a/include/flatbuffers/idl.h b/include/flatbuffers/idl.h index d092e44e7..87afae7ed 100644 --- a/include/flatbuffers/idl.h +++ b/include/flatbuffers/idl.h @@ -376,6 +376,7 @@ struct IDLOptions { std::string go_namespace; bool reexport_ts_modules; bool protobuf_ascii_alike; + bool prefix_size; // Possible options for the more general generator below. enum Language { @@ -428,6 +429,7 @@ struct IDLOptions { skip_flatbuffers_import(false), reexport_ts_modules(true), protobuf_ascii_alike(false), + prefix_size(false), lang(IDLOptions::kJava), mini_reflect(IDLOptions::kNone), lang_to_generate(0) {} diff --git a/src/flatc.cpp b/src/flatc.cpp index abc948c2c..61e434312 100644 --- a/src/flatc.cpp +++ b/src/flatc.cpp @@ -113,6 +113,7 @@ std::string FlatCompiler::GetUsageString(const char* program_name) const { " --no-ts-reexport Don't re-export imported dependencies for TypeScript.\n" " --reflect-types Add minimal type reflection to code generation.\n" " --reflect-names Add minimal type/name reflection.\n" + " --prefix-size Prefix size field to generated buffers.\n" "FILEs may be schemas (must end in .fbs), or JSON files (conforming to preceding\n" "schema). FILEs after the -- must be binary flatbuffer format files.\n" "Output files are named using the base file name of the input,\n" @@ -249,6 +250,8 @@ int FlatCompiler::Compile(int argc, const char** argv) { opts.mini_reflect = IDLOptions::kTypes; } else if(arg == "--reflect-names") { opts.mini_reflect = IDLOptions::kTypesAndNames; + } else if(arg == "--prefix-size") { + opts.prefix_size = true; } else { for (size_t i = 0; i < params_.num_generators; ++i) { if (arg == params_.generators[i].generator_opt_long || diff --git a/src/idl_parser.cpp b/src/idl_parser.cpp index b919c3c53..be52de006 100644 --- a/src/idl_parser.cpp +++ b/src/idl_parser.cpp @@ -2204,8 +2204,13 @@ CheckedError Parser::DoParse(const char *source, } uoffset_t toff; ECHECK(ParseTable(*root_struct_def_, nullptr, &toff)); - builder_.Finish(Offset