Added "final" to generated types to block inheritance.

People sometimes accidentally inherit from these types.

Bug: 18224703
Change-Id: Ia09489a834ac4941f9b4a46f240cbdcf456f03a1
Tested: on Windows and Linux.
This commit is contained in:
Wouter van Oortmerssen
2014-11-19 11:03:32 -08:00
parent 0952143971
commit 285501f7be
4 changed files with 19 additions and 11 deletions

View File

@@ -208,7 +208,8 @@ static void GenTable(const Parser &parser, StructDef &struct_def,
// Generate an accessor struct, with methods of the form:
// type name() const { return GetField<type>(offset, defaultval); }
GenComment(struct_def.doc_comment, code_ptr);
code += "struct " + struct_def.name + " : private flatbuffers::Table";
code += "struct " + struct_def.name;
code += " FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table";
code += " {\n";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end();
@@ -414,7 +415,7 @@ static void GenStruct(const Parser &parser, StructDef &struct_def,
// platforms.
GenComment(struct_def.doc_comment, code_ptr);
code += "MANUALLY_ALIGNED_STRUCT(" + NumToString(struct_def.minalign) + ") ";
code += struct_def.name + " {\n private:\n";
code += struct_def.name + " FLATBUFFERS_FINAL_CLASS {\n private:\n";
int padding_id = 0;
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end();