Fix flatc code gen.

Mutable functions should return a non-const reference to the member variable.

Change-Id: I833077d2c9a38a5d71868e43aca6b250d79b6625
This commit is contained in:
Wouter van Oortmerssen 2017-03-29 11:51:20 -07:00
parent cffd187fc7
commit b4bb1b103f
3 changed files with 3 additions and 1 deletions

View File

@ -1928,6 +1928,8 @@ class CppGenerator : public BaseGenerator {
code_ += " }";
if (parser_.opts.mutable_buffer) {
auto mut_field_type = GenTypeGet(field.value.type, " ", "", " &", true);
code_.SetValue("FIELD_TYPE", mut_field_type);
if (is_scalar) {
code_.SetValue("ARG", GenTypeBasic(field.value.type, true));
code_.SetValue("FIELD_VALUE",

Binary file not shown.

View File

@ -243,7 +243,7 @@ MANUALLY_ALIGNED_STRUCT(16) Vec3 FLATBUFFERS_FINAL_CLASS {
const Test &test3() const {
return test3_;
}
const Test &mutable_test3() {
Test &mutable_test3() {
return test3_;
}
};