diff options
author | Wouter van Oortmerssen <aardappel@gmail.com> | 2017-02-13 16:15:55 -0800 |
---|---|---|
committer | Wouter van Oortmerssen <aardappel@gmail.com> | 2017-02-13 16:47:17 -0800 |
commit | 1fb6b9ee6f817befae08f39549d5bd80de3931cc (patch) | |
tree | fb670b051bfaf459b723963a9f2a238151ee8205 /src | |
parent | 2d6e8f096b73d99ceeb75db93ee312d42f2e7db8 (diff) | |
download | flatbuffers-1fb6b9ee6f817befae08f39549d5bd80de3931cc.tar.gz flatbuffers-1fb6b9ee6f817befae08f39549d5bd80de3931cc.tar.bz2 flatbuffers-1fb6b9ee6f817befae08f39549d5bd80de3931cc.zip |
Added doc comments to the binary schema.
Change-Id: I87f291ab6e07b1425850cae25ed500db594f17c8
Tested: on Linux.
Diffstat (limited to 'src')
-rw-r--r-- | src/flatc.cpp | 3 | ||||
-rw-r--r-- | src/idl_parser.cpp | 16 |
2 files changed, 16 insertions, 3 deletions
diff --git a/src/flatc.cpp b/src/flatc.cpp index 053f112b..ed13c2ad 100644 --- a/src/flatc.cpp +++ b/src/flatc.cpp @@ -93,6 +93,7 @@ std::string FlatCompiler::GetUsageString(const char* program_name) const { " --proto Input is a .proto, translate to .fbs.\n" " --grpc Generate GRPC interfaces for the specified languages\n" " --schema Serialize schemas instead of JSON (use with -b)\n" + " --bfbs-comments Add doc comments to the binary schema files.\n" " --conform FILE Specify a schema the following schemas should be\n" " an evolution of. Gives errors if not.\n" " --conform-includes Include path for the schema given with --conform\n" @@ -204,6 +205,8 @@ int FlatCompiler::Compile(int argc, const char** argv) { exit(0); } else if(arg == "--grpc") { grpc_enabled = true; + } else if(arg == "--bfbs-comments") { + opts.binary_schema_comments = 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 454abd30..7adfcca2 100644 --- a/src/idl_parser.cpp +++ b/src/idl_parser.cpp @@ -2086,7 +2086,11 @@ Offset<reflection::Object> StructDef::Serialize(FlatBufferBuilder *builder, fixed, static_cast<int>(minalign), static_cast<int>(bytesize), - SerializeAttributes(builder, parser)); + SerializeAttributes(builder, parser), + parser.opts.binary_schema_comments + ? builder->CreateVectorOfStrings( + doc_comment) + : 0); } Offset<reflection::Field> FieldDef::Serialize(FlatBufferBuilder *builder, @@ -2106,7 +2110,10 @@ Offset<reflection::Field> FieldDef::Serialize(FlatBufferBuilder *builder, deprecated, required, key, - SerializeAttributes(builder, parser)); + SerializeAttributes(builder, parser), + parser.opts.binary_schema_comments + ? builder->CreateVectorOfStrings(doc_comment) + : 0); // TODO: value.constant is almost always "0", we could save quite a bit of // space by sharing it. Same for common values of value.type. } @@ -2123,7 +2130,10 @@ Offset<reflection::Enum> EnumDef::Serialize(FlatBufferBuilder *builder, builder->CreateVector(enumval_offsets), is_union, underlying_type.Serialize(builder), - SerializeAttributes(builder, parser)); + SerializeAttributes(builder, parser), + parser.opts.binary_schema_comments + ? builder->CreateVectorOfStrings(doc_comment) + : 0); } Offset<reflection::EnumVal> EnumVal::Serialize(FlatBufferBuilder *builder) const |