Change nested_root accessor to be const function.

The `<field>_nested_root()` is not viable from const object. (We usually get `const Monster *`.)

Change-Id: I0d0adcb38dd974318608417ee3094c34fb9c480d
This commit is contained in:
Hyungjin Kim 2015-02-10 15:42:38 +09:00 committed by Wouter van Oortmerssen
parent 620fe1c5cf
commit c9a840e935
2 changed files with 2 additions and 2 deletions

View File

@ -242,7 +242,7 @@ static void GenTable(const Parser &parser, StructDef &struct_def,
auto nested_root = parser.structs_.Lookup(nested->constant);
assert(nested_root); // Guaranteed to exist by parser.
code += " const " + nested_root->name + " *" + field.name;
code += "_nested_root() { return flatbuffers::GetRoot<";
code += "_nested_root() const { return flatbuffers::GetRoot<";
code += nested_root->name + ">(" + field.name + "()->Data()); }\n";
}
// Generate a comparison function for this field if it is a key.

View File

@ -138,7 +138,7 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
const flatbuffers::Vector<flatbuffers::Offset<Monster>> *testarrayoftables() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<Monster>> *>(26); }
const Monster *enemy() const { return GetPointer<const Monster *>(28); }
const flatbuffers::Vector<uint8_t> *testnestedflatbuffer() const { return GetPointer<const flatbuffers::Vector<uint8_t> *>(30); }
const Monster *testnestedflatbuffer_nested_root() { return flatbuffers::GetRoot<Monster>(testnestedflatbuffer()->Data()); }
const Monster *testnestedflatbuffer_nested_root() const { return flatbuffers::GetRoot<Monster>(testnestedflatbuffer()->Data()); }
const Stat *testempty() const { return GetPointer<const Stat *>(32); }
uint8_t testbool() const { return GetField<uint8_t>(34, 0); }
bool Verify(flatbuffers::Verifier &verifier) const {