Fix merging schemas in aos configs
Since all configs are practically required to have schemas today, we are
now getting into situations where we need to merge 2 configs both with
schemas. Naively merging the schemas together results in all the fields
being duplicated and nothing making sense.
The proper thing to do would be to merge the schemas together while
retaining meaning. That would let us dynamically add fields and such.
That is hard to do and probably not worth it. We typically merge new
schemas into old configs, so the easy thing to do is always replace the
existing schema with the new schema.
Through this whole activity, I discovered that if ForceDefaults isn't
set to true, we don't copy over fields with 0 values. We assume 0 is
the default, even if that is wrong. This changes the meaning. Instead,
ignore ForceDefaults when merging.
Change-Id: If83978dd73a542d070eaeb242532e7ee52104999
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/aos/flatbuffer_merge.cc b/aos/flatbuffer_merge.cc
index 18a190f..17f4468 100644
--- a/aos/flatbuffer_merge.cc
+++ b/aos/flatbuffer_merge.cc
@@ -38,9 +38,9 @@
const bool t2_has = val2 != nullptr;
if (t2_has) {
- fbb->AddElement<T>(field_offset, flatbuffers::ReadScalar<T>(val2), 0);
+ fbb->AddElement<T>(field_offset, flatbuffers::ReadScalar<T>(val2));
} else if (t1_has) {
- fbb->AddElement<T>(field_offset, flatbuffers::ReadScalar<T>(val1), 0);
+ fbb->AddElement<T>(field_offset, flatbuffers::ReadScalar<T>(val1));
}
}