Merge commit '6dccd64de51ea960cb6f0d975768c874814b4c75' into HEAD
Update flatbuffers. Relevant merge tasks:
* A field got added to reflection.fbs; this had fallout in
reflection_generated.h and the logger_test shas.
* Resolved merge conflict in rust/flatbuffers/src/lib.rs
* Reverted upstream change that made Table rust struct members private.
* FlatBufferBuilder Create*Vector calls now include alignment.
* nim codegen got added; needed to update to use scoped enums.
Main fix that motivated this update is
https://github.com/google/flatbuffers/pull/7588
Change-Id: I6bbe5d56846f426fa5f2a82c4f2bc77be2b93bb0
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/third_party/flatbuffers/src/bfbs_gen.h b/third_party/flatbuffers/src/bfbs_gen.h
index 63220e8..8e3c6f3 100644
--- a/third_party/flatbuffers/src/bfbs_gen.h
+++ b/third_party/flatbuffers/src/bfbs_gen.h
@@ -38,8 +38,9 @@
for (auto it = objects->cbegin(); it != objects->cend(); ++it) { func(*it); }
}
-static void ForAllEnumValues(const reflection::Enum *enum_def,
- std::function<void(const reflection::EnumVal *)> func) {
+static void ForAllEnumValues(
+ const reflection::Enum *enum_def,
+ std::function<void(const reflection::EnumVal *)> func) {
for (auto it = enum_def->values()->cbegin(); it != enum_def->values()->cend();
++it) {
func(*it);
@@ -91,7 +92,7 @@
return base_type == reflection::BaseType::Vector;
}
-} // namespace
+} // namespace
// A concrete base Flatbuffer Generator that specific language generators can
// derive from.
@@ -130,17 +131,29 @@
}
protected:
- const reflection::Object *GetObject(const reflection::Type *type) const {
- if (type->index() >= 0 && IsStructOrTable(type->base_type())) {
+ // GetObject returns the underlying object struct of the given type
+ // if element_type is true and GetObject is a list of objects then
+ // GetObject will correctly return the object struct of the vector's elements
+ const reflection::Object *GetObject(const reflection::Type *type,
+ bool element_type = false) const {
+ const reflection::BaseType base_type =
+ element_type ? type->element() : type->base_type();
+ if (type->index() >= 0 && IsStructOrTable(base_type)) {
return GetObjectByIndex(type->index());
}
return nullptr;
}
- const reflection::Enum *GetEnum(const reflection::Type *type) const {
+ // GetEnum returns the underlying enum struct of the given type
+ // if element_type is true and GetEnum is a list of enums then
+ // GetEnum will correctly return the enum struct of the vector's elements
+ const reflection::Enum *GetEnum(const reflection::Type *type,
+ bool element_type = false) const {
+ const reflection::BaseType base_type =
+ element_type ? type->element() : type->base_type();
// TODO(derekbailey): it would be better to have a explicit list of allowed
// base types, instead of negating Obj types.
- if (type->index() >= 0 && !IsStructOrTable(type->base_type())) {
+ if (type->index() >= 0 && !IsStructOrTable(base_type)) {
return GetEnumByIndex(type->index());
}
return nullptr;