mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-03 04:21:13 +00:00
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user